Skip to content

Commit

Permalink
feat(nolus): add noble usdc astroport (#11159)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivivanov authored Jul 31, 2024
1 parent a3cb12a commit f13af09
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions projects/nolus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const astroportOracleAddr = 'nolus1jew4l5nq7m3xhkqzy8j7cc99083m5j8d9w004ayyv8xl3
const astroportLppAddr = 'nolus1qqcr7exupnymvg6m63eqwu8pd4n5x6r5t3pyyxdy7r97rcgajmhqy3gn94'
const astroportLeaserAddr = 'nolus1et45v5gepxs44jxewfxah0hk4wqmw34m8pm4alf44ucxvj895kas5yrxd8'

// Astroport Noble USDC Protocol Contracts (NEUTRON-ASTROPORT-USDC_NOBLE) pirin-1
const astroportNobleOracleAddr = 'nolus1vhzdx9lqexuqc0wqd48c5hc437yzw7jy7ggum9k25yy2hz7eaatq0mepvn'
const astroportNobleLeaserAddr = 'nolus1aftavx3jaa20srgwclakxh8xcc84nndn7yvkq98k3pz8ydhy9rvqkhj8dz'
const astroportNobleLppAddr = 'nolus17vsedux675vc44yu7et9m64ndxsy907v7sfgrk7tw3xnjtqemx3q6t3xw6'

const _6Zeros = 1000000

const nativeTokens = {
Expand All @@ -42,9 +47,9 @@ async function getLeases(leaseAddresses) {
return await queryManyContracts({ permitFailure: true, contracts: leaseAddresses, chain: 'nolus', data: {} })
}

async function getLppTvl(lppAddresses) {
async function getLppTvl(lppAddresses) {
const lpps = await queryManyContracts({ contracts: lppAddresses, chain: 'nolus', data: { 'lpp_balance': [] } })

let totalLpp = 0
lpps.forEach(v => {
totalLpp += Number(v.balance.amount)
Expand All @@ -59,21 +64,24 @@ function sumAssests(balances, leases, currencies) {
let ticker = v.opened.amount.ticker
const amount = parseInt(v.opened.amount.amount, 10)
const currencyData = find(currencies, (n) => n.ticker == ticker)
if (nativeTokens.hasOwnProperty(currencyData.dex_symbol)) {
sdk.util.sumSingleBalance(balances, nativeTokens[currencyData.dex_symbol], amount)
if (currencyData) {
if (nativeTokens.hasOwnProperty(currencyData.dex_symbol)) {
sdk.util.sumSingleBalance(balances, nativeTokens[currencyData.dex_symbol], amount)
}
sdk.util.sumSingleBalance(balances, currencyData.dex_symbol, amount)
}
sdk.util.sumSingleBalance(balances, currencyData.dex_symbol, amount)
}
})
}

function find (collection, predicate) {
function find(collection, predicate) {
for (let i = 0; i < collection.length; i++) {
if (predicate(collection[i])) {
return collection[i];
return collection[i]
}
}
return undefined;

return undefined
}

async function tvl(protocols) {
Expand All @@ -95,14 +103,15 @@ module.exports = {
tvl: async () => {
return {
'axlusdc': await getLppTvl([osmosisAxlLppAddr, astroportLppAddr]),
'usd-coin': await getLppTvl([osmosisNobleLppAddr])
'usd-coin': await getLppTvl([osmosisNobleLppAddr, astroportNobleLppAddr])
}
}
},
neutron: {
tvl: async () => {
return await tvl([
{ leaser: astroportLeaserAddr, oracle: astroportOracleAddr }
{ leaser: astroportLeaserAddr, oracle: astroportOracleAddr },
{ leaser: astroportNobleLeaserAddr, oracle: astroportNobleOracleAddr },
])
}
},
Expand Down

0 comments on commit f13af09

Please sign in to comment.