Skip to content

Commit

Permalink
Add sturgeon and refactor code (#10784)
Browse files Browse the repository at this point in the history
* add sturgeon

* code refactor

* review fixes

---------

Co-authored-by: Alien Deployer <[email protected]>
  • Loading branch information
g1nt0ki and a17 authored Jul 5, 2024
1 parent fa81663 commit f22f500
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions projects/helper/tokenMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const fixBalancesTokens = {
ozone: {
// '0x83048f0bf34feed8ced419455a4320a735a92e9d': { coingeckoId: "ozonechain", decimals: 18 }, // was mapped to wrong chain
},

real: {
'0x4644066f535ead0cde82d209df78d94572fcbf14': { coingeckoId: 're-al', decimals: 18 },
'0xaec9e50e3397f9ddc635c6c429c8c7eca418a143': { coingeckoId: 'arcana-2', decimals: 18 },
'0xce1581d7b4ba40176f0e219b2cac30088ad50c7a': { coingeckoId: 'pearl', decimals: 18 },
},
}

ibcChains.forEach(chain => fixBalancesTokens[chain] = { ...ibcMappings, ...(fixBalancesTokens[chain] || {}) })
Expand Down
31 changes: 31 additions & 0 deletions projects/sturgeon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { sumTokens2 } = require("../helper/unwrapLPs")

const config = {
"real": {
controller: "0xE0E71B484Bb20E37d18Ab51fB60c32deC778478A",
},
}

Object.keys(config).forEach(chain => {
const { controller } = config[chain]
module.exports[chain] = {
tvl: async function (api) {
const compounderVaults = await api.call({ abi: 'address[]:compounderVaultsList', target: controller })
const harvesterVaults = await api.call({ abi: 'address[]:harvesterVaultsList', target: controller })
await api.erc4626Sum({ calls: compounderVaults, isOG4626: true })
const tridents = await api.multiCall({ abi: 'address:asset', calls: harvesterVaults })
const tridentBalances = await api.multiCall({ abi: 'uint256:totalAssets', calls: harvesterVaults })
const token0s = await api.multiCall({ abi: 'address:token0', calls: tridents })
const tokenBals = await api.multiCall({ abi: 'function getTotalAmounts() external view returns (uint total0, uint total1, uint128 liquidity)', calls: tridents })
const token1s = await api.multiCall({ abi: 'address:token1', calls: tridents })
const totalSupplies = await api.multiCall({ abi: 'erc20:totalSupply', calls: tridents })

tridents.forEach((_, i) => {
const ratio = tridentBalances[i] / totalSupplies[i]
api.add(token0s[i], tokenBals[i].total0 * ratio)
api.add(token1s[i], tokenBals[i].total1 * ratio)
})
return sumTokens2({ api })
},
}
})

0 comments on commit f22f500

Please sign in to comment.