Skip to content

Commit fb6927e

Browse files
xianshuig1nt0ki
andauthored
feat: udpate pumpbtc adapter logic (DefiLlama#12147)
Co-authored-by: g1nt0ki <[email protected]>
1 parent acc32bf commit fb6927e

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

projects/helper/bitcoin-book/fetchers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ module.exports = {
7474
return Object.values(await getConfig('solv-protocol/solv-btc-lst', API_URL)).flat();
7575
},
7676
pumpBTC: async () => {
77-
const API_URL = 'https://dashboard.pumpbtc.xyz/api/dashboard/btc/addresses'
78-
return getConfig('pumpbtc', undefined, {
77+
const API_URL = 'https://dashboard.pumpbtc.xyz/api/dashboard/asset/tokenowners'
78+
return getConfig('pumpbtc/v2', undefined, {
7979
fetcher: async () => {
8080
const { data } = await axios.get(API_URL)
81-
return data.data || []
81+
return data.data.bitcoin.owners
8282
}
8383
})
8484
},

projects/pumpbtc/index.js

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
1-
const ADDRESSES = require('../helper/coreAssets.json')
21
const { sumTokens } = require('../helper/sumTokens');
3-
const bitcoinAddressBook = require('../helper/bitcoin-book/index.js')
2+
const utils = require('../helper/utils');
3+
const { getConfig } = require('../helper/cache');
4+
const bitcoinBook = require('../helper/bitcoin-book');
45

56
module.exports = {
67
methodology: 'TVL for pumpBTC is calculated based on the total value of WBTC, FBTC, BTCB held in the contract that were utilized in the minting process of pumpBTC.',
78
}
8-
const config = {
9-
ethereum: { owners: ['0x1fCca65fb6Ae3b2758b9b2B394CB227eAE404e1E', '0x3d9bCcA8Bc7D438a4c5171435f41a0AF5d5E6083', '0xAC364d14020f1da0044699691a91f06ca6131Fe3', '0x1fCca65fb6Ae3b2758b9b2B394CB227eAE404e1E'], tokens: ['0xC96dE26018A54D51c097160568752c4E3BD6C364', ADDRESSES.ethereum.WBTC], },
10-
bsc: { owners: ['0x2Ee808F769AB697C477E0aF8357315069b66bCBb', '0x80922aD2771c5Ea9C14bA5FF4a903EC6B0f7e7C9', '0x2b4B9047C9fEA54705218388bFC7Aa7bADA4BB5E', '0x8A0727B87fa1027c419c3aa2caf56C799d5Bd8c5'], tokens: [ADDRESSES.bsc.BTCB, '0xC96dE26018A54D51c097160568752c4E3BD6C364'], },
11-
mantle: { owners: ['0xd6Ab15B2458B6EC3E94cE210174d860FdBdd6b96'], tokens: ['0xC96dE26018A54D51c097160568752c4E3BD6C364'], },
12-
bitcoin: {},
13-
base: { owners: ['0x1fCca65fb6Ae3b2758b9b2B394CB227eAE404e1E', '0x4913D495cBA3e1380218d2258126F22Ea5dE5f8B', '0xC7DA129335F8815d62fBd3ca7183A3b2791CdB5e', '0xca873913BBf124441857d32Bb23f723b68433465', '0xF1D06Be8dF2F7Ed4Cdc9ac05915EA2b618FFA3Fb'], tokens: ['0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf'], },
9+
10+
async function getStakingAddresses() {
11+
let res = await utils.fetchURL('https://dashboard.pumpbtc.xyz/api/dashboard/asset/tokenowners')
12+
13+
const btcAddresses = res.data.data || {}
14+
//console.log('>>', btcAddresses.length)
15+
return btcAddresses
16+
}
17+
18+
async function bitcoinTvl(api) {
19+
const owners = await bitcoinBook.pumpBTC()
20+
return sumTokens({ api, owners })
21+
}
22+
23+
async function otherTvl(api) {
24+
const addresses = await getConfig('pumpbtc/v2', undefined, { fetcher: getStakingAddresses })
25+
26+
if (!addresses[api.chain]) {
27+
return;
28+
}
29+
30+
const { owners, tokens } = addresses[api.chain]
31+
return api.sumTokens({ owners, tokens })
1432
}
1533

16-
Object.keys(config).forEach(chain => {
17-
const { owners, tokens, } = config[chain]
34+
module.exports.isHeavyProtocol = true;
1835

19-
if (chain === 'bitcoin') {
36+
['bitcoin', 'ethereum', 'bsc', 'mantle', 'base'].forEach(chain => {
37+
if (chain == 'bitcoin') {
2038
module.exports[chain] = {
21-
tvl: async (api) => { return sumTokens({ api, owners: await bitcoinAddressBook.pumpBTC() }) }
39+
tvl: bitcoinTvl,
2240
}
2341
} else {
2442
module.exports[chain] = {
25-
tvl: async (api) => api.sumTokens({ owners, tokens })
43+
tvl: otherTvl
2644
}
2745
}
2846
})
29-
30-
module.exports.isHeavyProtocol = true

0 commit comments

Comments
 (0)