Skip to content

Instantly share code, notes, and snippets.

@bonustrack
Last active September 26, 2020 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonustrack/a8a2b4b8f9e302ff188a484c267a1f67 to your computer and use it in GitHub Desktop.
Save bonustrack/a8a2b4b8f9e302ff188a484c267a1f67 to your computer and use it in GitHub Desktop.
STONK pool balances block 10356001
// https://etherscan.io/tx/0xeb008786a7d230180dbd890c76d6a7735430e836d55729a3ff6e22e254121192 Transaction
// https://etherscan.io/address/0x1985365e9f78359a9B6AD760e32412f4a445E862 Balancer pool
const { JsonRpcProvider } = require('@ethersproject/providers');
const snapshot = require('@bonustrack/snapshot.js/src');
// https://thegraph.com/explorer/subgraph/bonustrack/balancer?query=STONK%20pool%20before%20exploit
const poolShares = require('./subgraph-pool-shares.json');
const url = 'https://eth-mainnet.alchemyapi.io/v2/rXKbp7PTFm6hcrxU8NL-JGp5RMfRHDwg';
const provider = new JsonRpcProvider(url);
const bptAddress = '0xb9eaf49d9f913bc1314e37bb5482891840c8e3c1';
const strategiesHolders = [
['erc20-balance-of', { address: bptAddress, decimals: 18 }]
];
const strategies = [
['erc20-balance-of', { address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', decimals: 18 }], // WETH
['erc20-balance-of', { address: '0x514910771AF9Ca656af840dff83E8264EcF986CA', decimals: 18 }], // LINK
['erc20-balance-of', { address: '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F', decimals: 18 }], // SNX
['erc20-balance-of', { address: '0xc00e94Cb662C3520282E6f5717214004A7f26888', decimals: 18 }], // COMP
['erc20-balance-of', { address: '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', decimals: 18 }], // KNC
['erc20-balance-of', { address: '0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD', decimals: 18 }], // LRC
['erc20-balance-of', { address: '0x1985365e9f78359a9B6AD760e32412f4a445E862', decimals: 18 }], // REP
['erc20-balance-of', { address: '0xb60Fde5D798236fBF1e2697B2A0645380921FccF', decimals: 18 }] // STONK
];
const holders = poolShares.data.poolShares.map(poolShare => poolShare.userAddress.id);
console.log('Holders', holders.length);
async function test() {
const poolBalances = await snapshot.utils.getScores(strategies, 1, provider, [bptAddress], 10356001);
console.log('Pool balances', poolBalances);
const holdersBalances = await snapshot.utils.getScores(strategiesHolders, 1, provider, holders, 10356001);
const totalShares = Object.values(holdersBalances[0]).reduce((a, b) => a + b, 0);
console.log('Total shares', totalShares);
console.log('Holders BPT balances', holdersBalances);
}
test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment