forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5efdf0
commit 63fbeaf
Showing
1 changed file
with
16 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,16 @@ | ||
const ADDRESSES = require('../helper/coreAssets.json') | ||
/*================================================== | ||
Modules | ||
==================================================*/ | ||
|
||
const sdk = require('@defillama/sdk'); | ||
|
||
const BigNumber = require('bignumber.js'); | ||
|
||
/*================================================== | ||
Vars | ||
==================================================*/ | ||
|
||
const oldLoopringExchange = '0x944644Ea989Ec64c2Ab9eF341D383cEf586A5777'; | ||
const newLoopringExchangeDepositContract = '0x674bdf20A0F284D710BC40872100128e2d66Bd3f'; | ||
|
||
const listedTokens = [ | ||
'0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD', // LRC | ||
ADDRESSES.ethereum.USDT, // USDT | ||
ADDRESSES.ethereum.DAI, // DAI | ||
ADDRESSES.ethereum.LINK, // LINK | ||
ADDRESSES.ethereum.USDC, // USDC | ||
ADDRESSES.ethereum.WBTC, // WBTC | ||
ADDRESSES.ethereum.MKR, // MKR | ||
]; | ||
|
||
/*================================================== | ||
TVL | ||
==================================================*/ | ||
|
||
async function tvl(timestamp, block) { | ||
let ethBalanceOld = await sdk.api.eth.getBalance({target: oldLoopringExchange, block}); | ||
let ethBalanceNew = await sdk.api.eth.getBalance({target: newLoopringExchangeDepositContract, block}); | ||
let ethBlanaceTotal = BigNumber(ethBalanceOld.output || 0).plus(ethBalanceNew.output); | ||
|
||
let balances = { | ||
[ADDRESSES.null]: ethBlanaceTotal | ||
}; | ||
|
||
let calls = []; | ||
listedTokens.forEach((token) => { | ||
calls.push({ | ||
target: token, | ||
params: oldLoopringExchange | ||
}); | ||
calls.push({ | ||
target: token, | ||
params: newLoopringExchangeDepositContract | ||
}); | ||
}); | ||
|
||
let balanceOfResults = await sdk.api.abi.multiCall({ | ||
block, | ||
calls, | ||
abi: 'erc20:balanceOf' | ||
}); | ||
|
||
sdk.util.sumMultiBalanceOf(balances, balanceOfResults, true); | ||
|
||
return balances; | ||
} | ||
|
||
/*================================================== | ||
Exports | ||
==================================================*/ | ||
|
||
module.exports = { | ||
start: 1574241665, // 11/20/2019 @ 09:21AM (UTC) | ||
ethereum: { tvl } | ||
} | ||
const { sumTokens2 } = require("../helper/unwrapLPs"); | ||
|
||
module.exports = { | ||
ethereum: { | ||
tvl: (_, _b, _c, { api, logArray }) => | ||
sumTokens2({ | ||
api, | ||
owners: [ | ||
"0x944644Ea989Ec64c2Ab9eF341D383cEf586A5777", | ||
"0x674bdf20A0F284D710BC40872100128e2d66Bd3f", | ||
], | ||
fetchCoValentTokens: true, | ||
logArray, | ||
}), | ||
}, | ||
}; |