|
| 1 | +const {getLogs2, getAddress,} = require('../helper/cache/getLogs'); |
| 2 | +const {sumTokens2} = require('../helper/unwrapLPs'); |
| 3 | + |
| 4 | + |
| 5 | +async function tvl(api) { |
| 6 | + const {factory, fromBlock, optionsTrade} = config[api.chain] |
| 7 | + const privateLogs = await getLogs2({ |
| 8 | + api, |
| 9 | + factory, |
| 10 | + fromBlock, |
| 11 | + extraKey: 'private-pool', |
| 12 | + topics: ['0x321e5276dc2982b3e95825088a15cf891d1f691c70b6236b506afa3810ec0297'] |
| 13 | + }) |
| 14 | + const publicLogs = await getLogs2({ |
| 15 | + api, |
| 16 | + factory, |
| 17 | + fromBlock, |
| 18 | + extraKey: 'public-pool', |
| 19 | + topics: ['0x53aad570e9fba02f275a68e410f634e241c8301d036a94761d71bcba65941a36'] |
| 20 | + }) |
| 21 | + const logs = privateLogs.concat(publicLogs) |
| 22 | + const ownerTokens = [] |
| 23 | + const allTokens = [] |
| 24 | + logs.forEach(({topics}) => { |
| 25 | + const token = getAddress(topics[2]) |
| 26 | + const pool = getAddress(topics[3]) |
| 27 | + ownerTokens.push([[token], pool]) |
| 28 | + allTokens.push(token) |
| 29 | + }) |
| 30 | + ownerTokens.push([allTokens, optionsTrade]) |
| 31 | + return sumTokens2({api, ownerTokens, permitFailure: true}) |
| 32 | +} |
| 33 | + |
| 34 | +module.exports = { |
| 35 | + methodology: "The world's first decentralized currency standard Perpetual options Transaction agreement", |
| 36 | +}; |
| 37 | + |
| 38 | +const config = { |
| 39 | + bsc: { |
| 40 | + factory: '0x88f29D34c9602130B21Be4E1EaBEB7797177f259', |
| 41 | + fromBlock: 46616446, |
| 42 | + optionsTrade: '0x4e10384e98F2f170E00bfB1C3363D6f108a9ee68' |
| 43 | + }, |
| 44 | + acala:{ |
| 45 | + factory: '0xec676347105e7e898e0d8e24f524989cbff23d55', |
| 46 | + fromBlock: 7253471, |
| 47 | + optionsTrade: '0x5e413ed5e35506488779c5188ea58628955c83b8' |
| 48 | + }, |
| 49 | + // bitlayer:{ |
| 50 | + // factory: '0xb711ba37fa74b99e70c27e82def0b15a50ac7a9e', |
| 51 | + // fromBlock: 4328431, |
| 52 | + // optionsTrade: '0x482390a90a49d17d119f5c7dfe5e5bedb149fd9d' |
| 53 | + // }, |
| 54 | + op_bnb:{ |
| 55 | + factory: '0x91ABFdd51c0959016c54AbDfb012E81Ef82008d1', |
| 56 | + fromBlock: 51301555, |
| 57 | + optionsTrade: '0x91e644C8Fd5d5B799e0D238F31D9b46a91b8Ca03' |
| 58 | + }, |
| 59 | + // aia:{ |
| 60 | + // factory: '0x0e1e15b77de5924650da76f9e1ae46b07f493aec', |
| 61 | + // fromBlock: 34771150, |
| 62 | + // optionsTrade: '0x599bcd62cfa06c7e566da0ce62b376d0359d4a24' |
| 63 | + // }, |
| 64 | + base:{ |
| 65 | + factory: '0x344d02cEBb36ABBA6e55A9cefC703A75cA09E4E0', |
| 66 | + fromBlock: 28996468, |
| 67 | + optionsTrade: '0x43F323AcA25b57182bDc87564410ea7056975265' |
| 68 | + }, |
| 69 | + // avalanche:{ |
| 70 | + // factory: '0x5874ee8e6e96bFB17212962537e5Bf359630a268', |
| 71 | + // fromBlock: 57296254, |
| 72 | + // optionsTrade: '0x344d02cEBb36ABBA6e55A9cefC703A75cA09E4E0' |
| 73 | + // }, |
| 74 | + conflux:{ |
| 75 | + factory: '0xdc8091d097ca47afbbcc1ec216f3c5c26c587d19', |
| 76 | + fromBlock: 117895905, |
| 77 | + optionsTrade: '0x34bfe094c1275026475d37df3bb63a8d0adbc558' |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +Object.keys(config).forEach(chain => { |
| 82 | + module.exports[chain] = {tvl} |
| 83 | +}) |
0 commit comments