-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating the Lombard Info #11526
Updating the Lombard Info #11526
Changes from all commits
2e1b6f4
566bdbf
709c6ef
64df934
6403b72
a883094
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { ethereum } = require('./index.js'); | ||
|
||
async function testTVL() { | ||
try { | ||
const timestamp = Math.floor(Date.now() / 1000); | ||
const block = 'latest'; | ||
|
||
const result = await ethereum.tvl(timestamp, block); | ||
console.log('TVL Result:', result); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
} | ||
|
||
testTVL(); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added this to existing ether-fi vault listing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. *this was meant for lombard-vault listing For this file, the backing of these tokens are already counted in lomard/inde.js on bitcoin side right? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const sdk = require("@defillama/sdk"); | ||
|
||
async function tvl(timestamp, block) { | ||
const lbtcAddress = "0x8236a87084f8B84306f72007F36F2618A5634494"; | ||
|
||
const totalSupply = await sdk.api.erc20.totalSupply({ | ||
target: lbtcAddress, | ||
block | ||
}); | ||
|
||
return { | ||
bitcoin: totalSupply.output / 1e8 | ||
}; | ||
} | ||
|
||
module.exports = { | ||
doublecounted: true, | ||
ethereum: { | ||
tvl, | ||
}, | ||
methodology: `TVL for LBTC consists of the total supply of the LBTC ERC-20 token on Ethereum, backed by locked Bitcoin`, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const axios = require('axios'); | ||
|
||
const vaultAddress = '0x5401b8620E5FB570064CA9114fd1e135fd77D57c'; | ||
|
||
async function fetchTVL() { | ||
const response = await axios.get(`https://api.sevenseas.capital/hourlyData/ethereum/${vaultAddress}/1725321600/latest`); | ||
const latestData = response.data.Response[0]; | ||
return parseFloat(latestData.tvl); | ||
} | ||
|
||
module.exports = { | ||
doublecounted: true, | ||
ethereum: { | ||
tvl: async () => { | ||
const tvl = await fetchTVL(); | ||
return { | ||
'usd': tvl | ||
}; | ||
}, | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { getConfig } = require('../helper/cache') | ||
const { sumTokens } = require('../helper/chain/bitcoin') | ||
const { get } = require('../helper/http') | ||
const sdk = require('@defillama/sdk') | ||
|
||
const API_URL = 'https://mainnet.prod.lombard.finance/api/v1/addresses' | ||
const BATCH_SIZE = 1000 | ||
|
||
async function getAllAddresses() { | ||
let allAddresses = [] | ||
let offset = 0 | ||
let hasMore = true | ||
let batchNumber = 1 | ||
|
||
while (hasMore) { | ||
const response = await get(`${API_URL}?limit=${BATCH_SIZE}&offset=${offset}`) | ||
const data = response.addresses | ||
|
||
const newAddresses = data.map(a => a.btc_address) | ||
allAddresses = allAddresses.concat(newAddresses) | ||
|
||
sdk.log(`Batch ${batchNumber} completed: ${newAddresses.length} addresses`) | ||
|
||
hasMore = response.has_more | ||
offset += BATCH_SIZE | ||
batchNumber++ | ||
} | ||
|
||
return allAddresses | ||
} | ||
|
||
async function tvl() { | ||
const addresses = await getConfig('lombard', undefined, { fetcher: getAllAddresses}) | ||
return sumTokens({ owners: addresses }) | ||
} | ||
|
||
module.exports = { | ||
timetravel: false, | ||
isHeavyProtocol: true, | ||
bitcoin: { | ||
tvl | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can test tvl of an adapter by running
npm test projects/<adapterName>
I am tempted to reject this PR as it bring nothing new