Skip to content

Commit 095531b

Browse files
committed
update bedrock DefiLlama#12229
1 parent d609390 commit 095531b

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

projects/bedrock/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
const { sumTokens } = require('../helper/chain/bitcoin')
22
const bitcoinAddressBook = require('../helper/bitcoin-book/index.js')
3+
const { getConfig } = require('../helper/cache.js')
34

45
async function tvl() {
56
return sumTokens({ owners: await bitcoinAddressBook.bedrock() })
67
}
78

89
module.exports = {
910
timetravel: false,
10-
doublecounted:true,
11+
doublecounted: true,
1112
bitcoin: {
1213
tvl
1314
}
1415
}
16+
17+
async function tvlEvm(api) {
18+
const API_URL = 'https://raw.githubusercontent.com/Bedrock-Technology/uniBTC/refs/heads/main/data/tvl/reserve_address.json'
19+
const { evm, } = await getConfig('bedrock.btc_address', API_URL)
20+
const chain = api.chain == 'btr' ? 'bitlayer' : api.chain
21+
const { vault, tokens } = evm[chain] ?? {}
22+
if (!vault) return;
23+
return api.sumTokens({ api, owner: vault, tokens })
24+
}
25+
26+
['btr', 'ethereum', 'bsc', 'arbitrum', 'mantle', 'merlin', 'optimism', 'bob', 'bsquared', 'zeta', 'mode'].forEach(chain => {
27+
module.exports[chain] = { tvl: tvlEvm }
28+
})

projects/helper/bitcoin-book/fetchers.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const abi = { getQualifiedUserInfo: 'function getQualifiedUserInfo(address _user
88

99
module.exports = {
1010
bedrock: async () => {
11-
const API_URL = 'https://bedrock-datacenter.rockx.com/uniBTC/reserve/address'
11+
const API_URL = 'https://raw.githubusercontent.com/Bedrock-Technology/uniBTC/refs/heads/main/data/tvl/reserve_address.json'
1212
const { btc } = await getConfig('bedrock.btc_address', API_URL)
1313
return btc
1414
},
@@ -52,19 +52,19 @@ module.exports = {
5252
let offset = 0;
5353
let batchNumber = 1;
5454
let hasMore = true;
55-
55+
5656
while (hasMore) {
5757
const { addresses: data, has_more } = await get(`${API_URL}?limit=${BATCH_SIZE}&offset=${offset}`);
5858
const newAddresses = data.map(a => a.btc_address);
59-
59+
6060
allAddresses.push(...newAddresses);
6161
sdk.log(`Batch ${batchNumber} completed: ${newAddresses.length} addresses`);
62-
62+
6363
hasMore = has_more;
6464
offset += BATCH_SIZE;
6565
batchNumber++;
6666
}
67-
67+
6868
return allAddresses;
6969
}
7070
})
@@ -101,25 +101,25 @@ module.exports = {
101101
let hasMore = true;
102102

103103
while (hasMore) {
104-
const { data: response } = await axios.post(API2_URL, {
105-
"json": true,
106-
"code": "brdgmng.xsat",
107-
"scope": custody_id,
108-
"table": "addrmappings",
109-
"lower_bound": lower_bound,
110-
"upper_bound": null,
111-
"index_position": 1,
112-
"key_type": "",
113-
"limit": "100",
114-
"reverse": false,
115-
"show_payer": true
116-
});
104+
const { data: response } = await axios.post(API2_URL, {
105+
"json": true,
106+
"code": "brdgmng.xsat",
107+
"scope": custody_id,
108+
"table": "addrmappings",
109+
"lower_bound": lower_bound,
110+
"upper_bound": null,
111+
"index_position": 1,
112+
"key_type": "",
113+
"limit": "100",
114+
"reverse": false,
115+
"show_payer": true
116+
});
117117

118-
const addrs = response.rows.map(row => row.data.btc_address);
119-
owners.push(...addrs);
118+
const addrs = response.rows.map(row => row.data.btc_address);
119+
owners.push(...addrs);
120120

121-
hasMore = response.more;
122-
lower_bound = response.next_key;
121+
hasMore = response.more;
122+
lower_bound = response.next_key;
123123
}
124124
}
125125
return owners

0 commit comments

Comments
 (0)