feat: add missing stellar usdc price (#16946)

This commit is contained in:
P
2025-11-05 16:30:18 +01:00
committed by GitHub
parent 666f906e6f
commit 3e362dca45

View File

@@ -15,7 +15,7 @@ function detectCrossChainToken(tokenId) {
if (tokenId.includes('v2_1.omni.hot.tg:1100_')) {
const stellarMappings = {
'111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz': 'coingecko:stellar',
'111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu': 'stellar:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
'111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu': 'coingecko:usd-coin',
}
const match = tokenId.match(/1100_([a-zA-Z0-9]+)$/)
if (match && stellarMappings[match[1]]) {
@@ -103,13 +103,11 @@ function validateConfiguration(configuration) {
if (!configuration.collateral_asset) throw new Error('Missing collateral_asset in configuration')
}
function scaleTokenAmount(amount, tokenAddress) {
if (tokenAddress === 'coingecko:bitcoin') {
return amount.div(1e8).toFixed()
}
if (tokenAddress === 'coingecko:stellar') {
return amount.div(1e7).toFixed()
function scaleTokenAmount(amount, tokenAddress, decimals) {
if (tokenAddress.startsWith('coingecko')) {
return amount.div(Math.pow(10, decimals)).toFixed();
}
return amount.toFixed()
}
@@ -224,6 +222,9 @@ async function processMarket(marketContract) {
const borrowAssetToken = extractTokenAddress(configuration.borrow_asset, 'borrow')
const collateralAssetToken = extractTokenAddress(configuration.collateral_asset, 'collateral')
const borrowDecimals = configuration.price_oracle_configuration.borrow_asset_decimals
const collateralDecimals = configuration.price_oracle_configuration.collateral_asset_decimals
const borrow_asset_deposited_active = BigNumber(snapshot.borrow_asset_deposited_active)
const borrow_asset_deposited_incoming = BigNumber(snapshot.borrow_asset_deposited_incoming)
const collateral_asset_deposited = BigNumber(snapshot.collateral_asset_deposited)
@@ -239,6 +240,8 @@ async function processMarket(marketContract) {
availableLiquidity,
totalBorrowed: borrow_asset_borrowed,
totalCollateral: collateral_asset_deposited,
borrowDecimals,
collateralDecimals,
}
}
@@ -255,9 +258,9 @@ async function tvl() {
results.forEach((result, index) => {
if (result.status === 'fulfilled') {
const { borrowAssetToken, collateralAssetToken, availableLiquidity, totalCollateral } = result.value
sumSingleBalance(balances, borrowAssetToken, scaleTokenAmount(availableLiquidity, borrowAssetToken))
sumSingleBalance(balances, collateralAssetToken, scaleTokenAmount(totalCollateral, collateralAssetToken))
const { borrowAssetToken, collateralAssetToken, availableLiquidity, totalCollateral, borrowDecimals, collateralDecimals } = result.value
sumSingleBalance(balances, borrowAssetToken, scaleTokenAmount(availableLiquidity, borrowAssetToken, borrowDecimals))
sumSingleBalance(balances, collateralAssetToken, scaleTokenAmount(totalCollateral, collateralAssetToken, collateralDecimals))
} else {
throw new Error(`Market ${deployments[index]} failed: ${result.reason?.message || result.reason}`)
}
@@ -279,8 +282,8 @@ async function borrowed() {
results.forEach((result, index) => {
if (result.status === 'fulfilled') {
const { borrowAssetToken, totalBorrowed } = result.value
sumSingleBalance(balances, borrowAssetToken, scaleTokenAmount(totalBorrowed, borrowAssetToken))
const { borrowAssetToken, totalBorrowed, borrowDecimals } = result.value
sumSingleBalance(balances, borrowAssetToken, scaleTokenAmount(totalBorrowed, borrowAssetToken, borrowDecimals))
} else {
throw new Error(`Market ${deployments[index]} failed: ${result.reason?.message || result.reason}`)
}