Skip to content

Commit 6e90cdc

Browse files
committed
feat: updated superloop tvl adapter
1 parent b53ff18 commit 6e90cdc

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

projects/superloop/config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const ADDRESSES = require('../helper/coreAssets.json')
22
module.exports = {
3-
'VAULTS' : ['0xe24e5deba01ab0b5d78a0093442de0864832803e','0xc557529dd252e5a02e6c653b0b88984afa3c8199'],
3+
'V1_VAULTS' : ['0xe24e5deba01ab0b5d78a0093442de0864832803e','0xc557529dd252e5a02e6c653b0b88984afa3c8199'],
4+
'VAULTS' : ['0xdd160351c9b75ac2984b5e11367e06ab25ee49eb','0xe6da0bb72a818ed519edb51717b86077464f0857'],
5+
'MIGRATION_BLOCKS' : [29421087, 29426956],
46
"SUPERLEND_PROTOCOL_DATA_PROVIDER": "0x99e8269dDD5c7Af0F1B3973A591b47E8E001BCac",
57
'VAULT_TOKENS' : {
68
'0xe24e5deba01ab0b5d78a0093442de0864832803e' : {
@@ -10,6 +12,14 @@ module.exports = {
1012
'0xc557529dd252e5a02e6c653b0b88984afa3c8199' : {
1113
"lend" : ADDRESSES.etlk.LBTC,
1214
"borrow" : ADDRESSES.etlk.WBTC,
15+
},
16+
'0xdd160351c9b75ac2984b5e11367e06ab25ee49eb' : {
17+
"lend" : ADDRESSES.etlk.STXTZ,
18+
"borrow" : ADDRESSES.etlk.WXTZ,
19+
},
20+
'0xe6da0bb72a818ed519edb51717b86077464f0857' : {
21+
"lend" : ADDRESSES.etlk.LBTC,
22+
"borrow" : ADDRESSES.etlk.WBTC,
1323
}
1424
}
1525
}

projects/superloop/index.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ const userReserveDataAbi = "function getUserReserveData(address asset, address u
55

66
async function tvl(api) {
77
const balances = {};
8-
9-
for(const vault of config.VAULTS) {
10-
await processVault(api, vault, balances);
11-
}
8+
9+
for(let i = 0; i < config.VAULTS.length; i++) {
10+
const vault = config.VAULTS[i];
11+
const v1Vault = config.V1_VAULTS[i];
12+
const migrationBlock = config.MIGRATION_BLOCKS[i];
1213

14+
if(!api.block || api.block > migrationBlock) {
15+
await processVault(api, vault, balances);
16+
} else {
17+
await processVault(api, v1Vault, balances);
18+
}
19+
}
20+
1321
return balances;
1422
}
1523

@@ -37,8 +45,16 @@ async function processVault(api, vault, balances) {
3745
async function borrowed(api) {
3846
const balances = {}
3947

40-
for(const vault of config.VAULTS) {
41-
await processVaultBorrow(api, vault, balances);
48+
for(let i = 0; i < config.VAULTS.length; i++) {
49+
const vault = config.VAULTS[i];
50+
const v1Vault = config.V1_VAULTS[i];
51+
const migrationBlock = config.MIGRATION_BLOCKS[i];
52+
53+
if(!api.block || api.block > migrationBlock) {
54+
await processVaultBorrow(api, vault, balances);
55+
} else {
56+
await processVaultBorrow(api, v1Vault, balances);
57+
}
4258
}
4359

4460
return balances;

0 commit comments

Comments
 (0)