Skip to content

Instantly share code, notes, and snippets.

@bonustrack
Last active Sep 26, 2020
Embed
What would you like to do?
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