Skip to content

Commit

Permalink
satosh protocol add pellStrategy vaults V2
Browse files Browse the repository at this point in the history
  • Loading branch information
imfeng committed Jan 9, 2025
1 parent e226e9e commit 558c17e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion projects/satoshi-protocol/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const { sumTokens2 } = require("../helper/unwrapLPs")
const { getLogs } = require("../helper/cache/getLogs");
const AssetConfigSettingEventABI = "event AssetConfigSetting(address asset,uint256 feeIn,uint256 feeOut,uint256 debtTokenMintCap,uint256 dailyMintCap,address oracle,bool isUsingOracle,uint256 swapWaitingPeriod,uint256 maxPrice,uint256 minPrice)";
const VaultTokenStrategySetEventABI = "event TokenStrategySet(address token, address strategy)";


function createExports({
troveList,
nymInformation, // { address, fromBlock }
aaveStrategyVaults, // { address, asset, aToken }[]
pellStrategyVaults, // { address, asset }[]
pellStrategyVaultsV2, // { address, fromBlock }[]
}) {
return {
tvl: async (api) => {
Expand Down Expand Up @@ -48,6 +50,17 @@ function createExports({
api.add(tokens, bals)
}

if (pellStrategyVaultsV2) {
for(let i = 0; i < pellStrategyVaultsV2.length; i++) {
const { address: vaultAddress, fromBlock } = pellStrategyVaultsV2[i];
const logs = await getLogs({ api, target: vaultAddress, fromBlock, eventAbi: VaultTokenStrategySetEventABI, onlyArgs: true });
const assets = logs.map(item => item.token);
const calls = assets.map((asset) => ({ target: vaultAddress, params: asset }))
const assetAmounts = await api.multiCall({ abi: "function getPosition(address) external view returns (uint256)", calls: calls })
api.add(assets, assetAmounts)
}
}

return sumTokens2({ api, tokensAndOwners2: [tokens, owners] })
},
}
Expand Down Expand Up @@ -114,5 +127,11 @@ module.exports = {
'0xa79241206c3008bE4EB4B62A48A4F98303060D4f', // BSquare WBTC Collateral
'0xc6F361db5eC432E95D0A08A9Fbe0d7412971cE6c', // BSquare uBTC Collateral
],
pellStrategyVaultsV2: [
{
address: '0x1F745AEC91A7349E4F846Ae1D94915ec4f6cF053',
fromBlock: 11581100,
}
]
}),
}
}

0 comments on commit 558c17e

Please sign in to comment.