Skip to content

Commit b83093c

Browse files
authored
Aera Finance: add symbiotic integration (DefiLlama#13378)
1 parent 6b66041 commit b83093c

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

projects/aera/index.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const LLAMAPAY_ROUTER_ORACLE_NAME = 'LlamaPayRouterOracle'
88
const GEARBOX_TOKEN_PREFIX = 'Farming of'
99
const ARRAKIS_TOKEN_PREFIX = 'Arrakis Vault V2'
1010
const ESXAI_POSITION_ORACLE_NAME = 'EsXai Position Oracle'
11+
const SYMBIOTIC_TOKEN_PREFIX = 'Symbiotic Vault'
1112

1213
const config = {
1314
polygon: {
@@ -190,6 +191,7 @@ Object.keys(config).forEach(chain => {
190191
const arrakisVaults = []
191192
const xaiPositionVaults = []
192193
const esXaiVaults = []
194+
const symbioticVaults = []
193195

194196
for (let i = 0; i < vaults.length; ++i) {
195197
const vault = vaults[i]
@@ -222,6 +224,10 @@ Object.keys(config).forEach(chain => {
222224
xaiPositionVaults.push(vault)
223225
continue
224226
}
227+
if (assetName.startsWith(SYMBIOTIC_TOKEN_PREFIX)) {
228+
symbioticVaults.push([vault, assetInfo.asset])
229+
continue
230+
}
225231
}
226232

227233

@@ -256,7 +262,8 @@ Object.keys(config).forEach(chain => {
256262
processLlamaPayTvl(llamapayRouters, api),
257263
processGearboxTvl(gearboxFarmingPools, api),
258264
processArrakisTvl(arrakisVaults, api, ARRAKIS_HELPER),
259-
processXaiTvl(xaiPositionVaults, api, ESXAI_POOL_FACTORY, XAI)
265+
processXaiTvl(xaiPositionVaults, api, ESXAI_POOL_FACTORY, XAI),
266+
processSymbioticTvl(symbioticVaults, api)
260267
])
261268

262269
Object.keys(erc4626UnderylingMap).forEach((erc4626Asset, i) => erc4626UnderylingMap[erc4626Asset] = underlyingTokens[i])
@@ -409,6 +416,18 @@ async function processAaveTvl(aaveVaults, api, AAVE_POOL, AAVE_POOL_DATA_PROVIDE
409416

410417
}
411418

419+
async function processSymbioticTvl(symbioticVaults, api) {
420+
if (symbioticVaults.length === 0) return
421+
422+
const collaterals = await api.multiCall({ abi: abi.collateral, calls: symbioticVaults.map(x => ({target: x[1]}))})
423+
424+
const balances = await api.multiCall({ abi: 'erc20:balanceOf', calls: symbioticVaults.map(x => ({target: x[1], params: [x[0]]}))})
425+
426+
collaterals.forEach((collateral, i) => {
427+
api.addToken(collateral, balances[i])
428+
})
429+
}
430+
412431
const abi = {
413432
"collateralBalanceOf": "function collateralBalanceOf(address account, address asset) view returns (uint128)",
414433
"getReserveData": "function getReserveData(address asset) view returns (((uint256 data) configuration, uint128 liquidityIndex, uint128 currentLiquidityRate, uint128 variableBorrowIndex, uint128 currentVariableBorrowRate, uint128 currentStableBorrowRate, uint40 lastUpdateTimestamp, uint16 id, address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress, address interestRateStrategyAddress, uint128 accruedToTreasury, uint128 unbacked, uint128 isolationModeTotalDebt))",
@@ -438,5 +457,6 @@ const abi = {
438457
"getPoolIndicesOfUser": "function getPoolIndicesOfUser(address user) returns (address[])",
439458
"esXaiStakeBucket": "function esXaiStakeBucket() returns (address)",
440459
"getStakedAmounts": "function getStakedAmounts(address) returns (uint256)",
441-
"withdrawableDividendOf": "function withdrawableDividendOf(address) returns (uint256)"
460+
"withdrawableDividendOf": "function withdrawableDividendOf(address) returns (uint256)",
461+
"collateral": "function collateral() returns (address)"
442462
}

0 commit comments

Comments
 (0)