Skip to content

Commit

Permalink
Merge pull request #2316 from buchaoqun/main
Browse files Browse the repository at this point in the history
add solv-protocol
  • Loading branch information
g1nt0ki authored Apr 20, 2022
2 parents 2cfae6a + 62850d4 commit 871c2ca
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 16 deletions.
16 changes: 0 additions & 16 deletions projects/scrub/index.js

This file was deleted.

84 changes: 84 additions & 0 deletions projects/solv-protocol/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const { sumTokens, } = require('../helper/unwrapLPs')
const axios = require('axios')
const { staking } = require('../helper/staking');
const { transformBscAddress, transformEthereumAddress, transformPolygonAddress, transformArbitrumAddress } = require("../helper/portedTokens");

// token list
const tokenListsApiEndpoint = "https://token-list.solv.finance/vouchers-prod.json"

// Staking Tvls
const solvEthereumTokenAddress = '0x256F2d67e52fE834726D2DDCD8413654F5Eb8b53'
const solvEthereumPoolAddress = '0x7D0C93DcAD6f6B38C81431d7262CF0E48770B81a'
const solvBscTokenAddress = '0xC073c4eD65622A9423b5e5BDe2BFC8B81EBC471c'
const solvBscPoolAddress = '0xE5742912EDb4599779ACC1CE2acB6a06E01f1089'

const ethereumTVL = async (timestamp, block, chainBlocks) => {
const transform = await transformEthereumAddress();
return tvl(timestamp, block, chainBlocks, "ethereum", 1, transform);
}

const polygonTVL = async (timestamp, block, chainBlocks) => {
const transform = await transformPolygonAddress();
return tvl(timestamp, block, chainBlocks, "polygon", 137, transform);
}

const arbitrumTVL = async (timestamp, block, chainBlocks) => {
const transform = await transformArbitrumAddress();
return tvl(timestamp, block, chainBlocks, "arbitrum", 42161, transform);
};

const bscTVL = async (timestamp, block, chainBlocks) => {
const transform = await transformBscAddress();
return tvl(timestamp, block, chainBlocks, "bsc", 56, transform);
};

async function tvl(timestamp, block, chainBlocks, network, chainId, transform) {
let balances = {}; // Setup the balances object
const tokens = await tokenList(chainId);
let tokenPairs = []
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
tokenPairs.push([
token.address,
token.pool
])
}

await sumTokens(balances, tokenPairs, block, network, transform)

return balances;
}

async function tokenList(chainId) {
let tokens = [];
const allTokens = (await axios.get(tokenListsApiEndpoint)).data.tokens;
for (let token of allTokens) {
if (chainId == token.chainId) {
if (token.extensions.voucher.underlyingToken.symbol != "SOLV") {
tokens.push({
address: token.extensions.voucher.underlyingToken.address,
pool: token.extensions.voucher.vestingPool
})
}
}
}

return tokens;
}
// node test.js projects/solv-protocol/index.js
module.exports = {
ethereum: {
tvl: ethereumTVL,
staking: staking(solvEthereumPoolAddress, solvEthereumTokenAddress)
},
bsc: {
tvl: bscTVL,
staking: staking(solvBscPoolAddress, solvBscTokenAddress, "bsc")
},
polygon: {
tvl: polygonTVL
},
arbitrum: {
tvl: arbitrumTVL
}
};

0 comments on commit 871c2ca

Please sign in to comment.