This commit is contained in:
waynebruce0x
2022-03-18 15:39:00 +00:00
parent 1288e37d19
commit 860e3297c5
2 changed files with 34 additions and 4 deletions

15
projects/defil/abi.json Normal file
View File

@@ -0,0 +1,15 @@
{
"constant": true,
"inputs": [],
"name": "totalBorrows",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}

View File

@@ -3,7 +3,8 @@ const { unwrapUniswapLPs } = require('../helper/unwrapLPs');
const { getChainTransform } = require('../helper/portedTokens');
const { staking } = require("../helper/staking.js");
const contracts = require('./contracts.json');
// node test.js projects/defil/index.js
const abi = require('./abi.json');
function tvl(chain) {
return async (timestamp, block, chainBlocks) => {
const balances = {};
@@ -58,7 +59,19 @@ function tvl(chain) {
return balances;
};
};
function borrowed(chain) {
return async (timestamp, block, chainBlocks) => {
return {
[contracts.ethereum.tokens.eFIL.address]: (
await sdk.api.abi.call({
target: contracts[chain].holders.eFIL,
abi,
chain,
block: chainBlocks[chain]
})).output
};
};
};
module.exports = {
bsc: {
tvl: tvl('bsc'),
@@ -67,13 +80,15 @@ module.exports = {
contracts.bsc.tokens.DFL.address,
'bsc',
contracts.ethereum.tokens.DFL.address
)
),
//borrowed: borrowed('bsc')
},
ethereum: {
tvl: tvl('ethereum'),
staking: staking(
contracts.ethereum.holders.DFL,
contracts.ethereum.tokens.DFL.address
)
),
borrowed: borrowed('ethereum')
}
};