Skip to content

Commit 5d5910b

Browse files
committed
track hyperlend isolated DefiLlama#15362
1 parent bbaec41 commit 5d5910b

File tree

8 files changed

+145
-843
lines changed

8 files changed

+145
-843
lines changed

projects/fraxlend/abi.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

projects/fraxlend/index.js

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,10 @@
11
const ADDRESSES = require('../helper/coreAssets.json')
2-
const abi = require("./abi.json");
3-
const { sumTokens2 } = require('../helper/unwrapLPs')
4-
const sdk = require('@defillama/sdk');
5-
6-
const REGISTRY_ADDR_ETHEREUM = "0xD6E9D27C75Afd88ad24Cd5EdccdC76fd2fc3A751"
7-
const REGISTRY_ADDR_FRAXTAL = "0x8c22EBc8f9B96cEac97EA21c53F3B27ef2F45e57";
8-
const REGISTRY_ADDR_ARBITRUM = "0x0bD2fFBcB0A17De2d5a543ec2D47C772eeaD316d"
2+
const { fraxlendExports } = require('../helper/fraxlend');
93

104
const registry_config = {
11-
fraxtal: REGISTRY_ADDR_FRAXTAL,
12-
ethereum: REGISTRY_ADDR_ETHEREUM,
13-
arbitrum: REGISTRY_ADDR_ARBITRUM
14-
}
15-
16-
const frax_config = {
17-
ethereum: ADDRESSES.ethereum.FRAX,
18-
fraxtal: ADDRESSES.fraxtal.FRAX,
19-
arbitrum: ADDRESSES.arbitrum.FRAX
20-
}
21-
22-
async function tvl(api) {
23-
const pairs = await api.call({ target: registry_config[api.chain], abi: abi['getAllPairAddresses'], chain: api.chain})
24-
const tokens = await api.multiCall({ abi: abi.collateralContract, calls: pairs })
25-
return sumTokens2({ api, tokensAndOwners: tokens.map((v, i) => [v, pairs[i]]) })
26-
}
27-
async function borrowed(api) {
28-
const pairs = await api.call({ target: registry_config[api.chain], abi: abi['getAllPairAddresses'], chain: api.chain})
29-
const bals = await api.multiCall({ abi: 'function totalBorrow() view returns (uint128 amount, uint128 shares)', calls: pairs })
30-
bals.forEach(bal => api.add(frax_config[api.chain], bal.amount))
5+
fraxtal: { blacklistedTokens: [ADDRESSES.fraxtal.FRAX], registry: '0x8c22EBc8f9B96cEac97EA21c53F3B27ef2F45e57', },
6+
ethereum: { blacklistedTokens: [ADDRESSES.ethereum.FRAX], registry: '0xD6E9D27C75Afd88ad24Cd5EdccdC76fd2fc3A751', },
7+
arbitrum: { blacklistedTokens: [ADDRESSES.arbitrum.FRAX], registry: '0x0bD2fFBcB0A17De2d5a543ec2D47C772eeaD316d' },
318
}
329

33-
module.exports = {
34-
methodology: 'Gets the pairs from the REGISTRY_ADDRESS and adds the collateral amounts from each pair',
35-
ethereum: {
36-
tvl, borrowed,
37-
},
38-
fraxtal: {
39-
tvl, borrowed
40-
},
41-
arbitrum: {
42-
tvl, borrowed
43-
}
44-
}
10+
module.exports = fraxlendExports(registry_config)

projects/helper/env.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const DEFAULTS = {
3636
KATANA_RPC: "https://rpc.katana.network",
3737
KATANA_RPC_MULTICALL: '0xcA11bde05977b3631167028862bE2a173976CA11',
3838
BTNX_RPC_MULTICALL: '0xcA11bde05977b3631167028862bE2a173976CA11',
39+
VECHAIN_RPC_MULTICALL: '0x8B2fF167683c5e1DFD6717d934B560F20cf9F2a3',
3940
}
4041

4142
const ENV_KEYS = [

projects/helper/fraxlend.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const { sumTokens2 } = require("./unwrapLPs")
2+
3+
const abi = {
4+
asset: "address:asset",
5+
collateralContract: "address:collateralContract",
6+
getAllPairAddresses: "address[]:getAllPairAddresses",
7+
totalAssets: "uint256:totalAsset",
8+
totalCollateral: "uint256:totalCollateral",
9+
totalBorrow: 'function totalBorrow() view returns (uint128 amount, uint128 shares)',
10+
}
11+
12+
function fraxlendExports(config) {
13+
const exports = {
14+
methodology: 'Gets the pairs from the REGISTRY_ADDRESS and adds the collateral amounts from each pair',
15+
}
16+
17+
Object.keys(config).forEach(chain => {
18+
let { registry, blacklistedTokens = [] } = typeof config[chain] === 'string' ? { registry: config[chain] } : config[chain]
19+
20+
async function tvl(api) {
21+
const pairs = await api.call({ target: registry, abi: abi.getAllPairAddresses, chain: api.chain })
22+
const assets = await api.multiCall({ abi: abi.asset, calls: pairs })
23+
const collaterals = await api.multiCall({ abi: abi.collateralContract, calls: pairs })
24+
const tokens = collaterals.concat(assets)
25+
const owners = pairs.concat(pairs)
26+
return sumTokens2({ api, tokensAndOwners2: [tokens, owners], blacklistedTokens, })
27+
}
28+
29+
async function borrowed(api) {
30+
const pairs = await api.call({ target: registry, abi: abi.getAllPairAddresses, chain: api.chain })
31+
const assets = await api.multiCall({ abi: abi.asset, calls: pairs })
32+
const bals = (await api.multiCall({ abi: abi.totalBorrow, calls: pairs })).map(i => i.amount)
33+
api.add(assets, bals)
34+
}
35+
36+
exports[chain] = {
37+
tvl, borrowed,
38+
}
39+
})
40+
41+
42+
return exports
43+
}
44+
45+
module.exports = { fraxlendExports }

projects/hyperlend-isolated/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { fraxlendExports } = require('../helper/fraxlend')
2+
module.exports = fraxlendExports({ hyperliquid: '0xf55AF86c9EC3a7d5fa6367c00a120E6B262f718d'})

projects/hypurrfi-isolated/abi.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

projects/hypurrfi-isolated/index.js

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,2 @@
1-
const ADDRESSES = require('../helper/coreAssets.json')
2-
const abi = require("./abi.json");
3-
const { sumTokens2 } = require('../helper/unwrapLPs')
4-
const sdk = require('@defillama/sdk');
5-
6-
const REGISTRY_ADDR_HYPERLIQUID = "0x5aB54F5Ca61ab60E81079c95280AF1Ee864EA3e7"
7-
8-
const registry_config = {
9-
hyperliquid: REGISTRY_ADDR_HYPERLIQUID,
10-
}
11-
12-
const usdxl_config = {
13-
hyperliquid: "0xca79db4B49f608eF54a5CB813FbEd3a6387bC645"
14-
}
15-
16-
async function tvl(api) {
17-
const pairs = await api.call({ target: registry_config[api.chain], abi: abi['getAllPairAddresses'], chain: api.chain})
18-
const assets = await api.multiCall({ abi: abi.asset, calls: pairs })
19-
const collaterals = await api.multiCall({ abi: abi.collateralContract, calls: pairs })
20-
let tokensAndOwners = assets.map((v, i) => [v, pairs[i]])
21-
tokensAndOwners = tokensAndOwners.concat(collaterals.map((v, i) => [v, pairs[i]]))
22-
return sumTokens2({ api, tokensAndOwners: tokensAndOwners })
23-
}
24-
async function borrowed(api) {
25-
const pairs = await api.call({ target: registry_config[api.chain], abi: abi['getAllPairAddresses'], chain: api.chain})
26-
const assets = await api.multiCall({ abi: abi.asset, calls: pairs })
27-
const bals = await api.multiCall({ abi: 'function totalBorrow() view returns (uint128 amount, uint128 shares)', calls: pairs })
28-
bals.forEach((bal, i) => api.add(assets[i], bal.amount))
29-
}
30-
31-
module.exports = {
32-
methodology: 'Gets the pairs from the REGISTRY_ADDRESS and adds the asset and collateral amounts from each pair',
33-
hyperliquid: {
34-
tvl, borrowed
35-
},
36-
}
1+
const { fraxlendExports } = require('../helper/fraxlend')
2+
module.exports = fraxlendExports({ hyperliquid: '0x5aB54F5Ca61ab60E81079c95280AF1Ee864EA3e7'})

0 commit comments

Comments
 (0)