Skip to content

Commit 2bd3d78

Browse files
VaitaRAndrew Shivalin
andauthored
Lombard/BTC.b as several adapter, correct tvl for LBTC and BTC.b, names update (#16971)
Co-authored-by: Andrew Shivalin <[email protected]>
1 parent 5e9decb commit 2bd3d78

File tree

2 files changed

+63
-4
lines changed

2 files changed

+63
-4
lines changed

projects/lombard-btcb/index.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const { sumTokens } = require('../helper/chain/bitcoin')
2+
const bitcoinAddressBook = require('../helper/bitcoin-book/index.js')
3+
const { sumTokensExport } = require('../helper/unwrapLPs')
4+
const { getConfig } = require('../helper/cache')
5+
6+
// Lombard protocol design requires mixed wallets for LBTC(/lombard adapter) and BTC.b (/avalanche-btc adapter)
7+
8+
async function tvl(api) {
9+
const lombardOwners = await bitcoinAddressBook.lombard()
10+
const avalancheOwners = bitcoinAddressBook.avalanche
11+
const allOwners = [...lombardOwners, ...avalancheOwners]
12+
13+
const balances = await sumTokens({ owners: allOwners, forceCacheUse: true })
14+
15+
const data = await getConfig(
16+
'lombard-staking-vault',
17+
'https://ledger-mainnet.lombard-fi.com:1317/lombard-finance/ledger/btcstaking/staking_vault_base_balance'
18+
)
19+
20+
const lbtcBackingInBTC = Number(data.balance) / 1e8
21+
22+
if (balances.bitcoin) {
23+
balances.bitcoin = balances.bitcoin - lbtcBackingInBTC
24+
}
25+
26+
return balances
27+
}
28+
29+
module.exports = {
30+
doublecounted: true,
31+
timetravel: false,
32+
isHeavyProtocol: true,
33+
bitcoin: { tvl },
34+
ethereum: { tvl: sumTokensExport({ owners: ['0x838f0c257ab27856ee9be57f776b186140834b58'], tokens: ['0xfe4ecd930a1282325aef8e946f17c0e25744de45'] })}
35+
}
36+
37+
module.exports.hallmarks = [
38+
[1761782400, 'Lombard has acquired BTC.b'], //2025-10-30
39+
]

projects/lombard/index.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
11
const { sumTokens } = require('../helper/chain/bitcoin')
22
const bitcoinAddressBook = require('../helper/bitcoin-book/index.js')
33
const { sumTokensExport } = require('../helper/unwrapLPs')
4+
const { getConfig } = require('../helper/cache')
45

5-
async function tvl() {
6-
return sumTokens({ owners: await bitcoinAddressBook.lombard(), forceCacheUse: true })
6+
// Lombard protocol design requires mixed wallets for LBTC(/lombard adapter) and BTC.b (/avalanche-btc adapter)
7+
8+
async function tvl(api) {
9+
const lombardOwners = await bitcoinAddressBook.lombard()
10+
const avalancheOwners = bitcoinAddressBook.avalanche
11+
const allOwners = [...lombardOwners, ...avalancheOwners]
12+
13+
const balances = await sumTokens({ owners: allOwners, forceCacheUse: true })
14+
15+
const data = await getConfig(
16+
'lombard-staking-vault',
17+
'https://ledger-mainnet.lombard-fi.com:1317/lombard-finance/ledger/btcstaking/staking_vault_base_balance'
18+
)
19+
20+
const lbtcBackingInBTC = Number(data.balance) / 1e8
21+
22+
if (balances.bitcoin) {
23+
balances.bitcoin = Math.min(balances.bitcoin, lbtcBackingInBTC)
24+
}
25+
26+
return balances
727
}
828

929
module.exports = {
10-
doublecounted:true,
30+
doublecounted: true,
1131
timetravel: false,
1232
isHeavyProtocol: true,
1333
bitcoin: { tvl },
1434
ethereum: { tvl: sumTokensExport({ owners: ['0x838f0c257ab27856ee9be57f776b186140834b58'], tokens: ['0xfe4ecd930a1282325aef8e946f17c0e25744de45'] })}
15-
}
35+
}

0 commit comments

Comments
 (0)