Skip to content

Commit

Permalink
Fix adapter dependent on Noble chain (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche authored Jan 3, 2025
1 parent 37ae44b commit 0594623
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
14 changes: 6 additions & 8 deletions src/adapters/peggedAssets/helper/getSupply.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ChainApi } from "@defillama/sdk";
import * as aptos from "../helper/aptos";
import { getTokenSupply as solanaGetTokenSupply } from "../helper/solana";
import * as sui from "../helper/sui";
import type {
Balances,
ChainBlocks,
PeggedAssetType,
PeggedIssuanceAdapter,
} from "../peggedAsset.type";
import { sumSingleBalance } from "./generalUtil";
import { getTokenSupply as solanaGetTokenSupply } from "../helper/solana";
import { ChainApi } from "@defillama/sdk";
import * as sui from "../helper/sui";
import * as aptos from "../helper/aptos";
const axios = require("axios");
const retry = require("async-retry");
process.env.TAIKO_RPC = 'https://rpc.taiko.xyz'
Expand Down Expand Up @@ -197,13 +197,13 @@ const cosmosEndpoints: any = {
nibiru: "https://lcd.nibiru.fi",
bostrom: "https://lcd.bostrom.cybernode.ai",
joltify: "https://lcd.joltify.io",
noble: "https://api.noble.xyz"
noble: "https://noble-api.polkachu.com"
};


function getCosmosRPC(chain: string) {
if (cosmosEndpoints[chain]) return cosmosEndpoints[chain];
return `https://rest.cosmos.directory/${chain}`;
return `https://rest.cosmos.directory/${chain}/`;
}

export function cosmosSupply(
Expand All @@ -221,8 +221,6 @@ export function cosmosSupply(
let balances = {} as Balances;
for (let token of tokens) {
let api = `cosmos/bank/v1beta1/supply/by_denom?denom=${token}`
if (chain === 'noble')
api = `cosmos/bank/v1beta1/supply/${token}`
const res = await retry(
async (_bail: any) =>
await axios.get(
Expand Down
3 changes: 2 additions & 1 deletion src/adapters/peggedAssets/monerium-eur-money/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ const sdk = require("@defillama/sdk");
import { sumSingleBalance } from "../helper/generalUtil";
import { cosmosSupply } from "../helper/getSupply";
import {
Balances,
ChainBlocks,
ChainContracts,
PeggedIssuanceAdapter,
Balances, ChainContracts,
} from "../peggedAsset.type";
const axios = require("axios");
const retry = require("async-retry");
Expand Down
23 changes: 5 additions & 18 deletions src/adapters/peggedAssets/ondo-us-dollar-yield/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
const sdk = require("@defillama/sdk");
import { sumSingleBalance } from '../helper/generalUtil';
import { addChainExports, cosmosSupply } from "../helper/getSupply";
import { ChainBlocks, PeggedIssuanceAdapter } from "../peggedAsset.type";
const axios = require("axios");
const retry = require("async-retry");
import { addChainExports } from "../helper/getSupply";
import { sumSingleBalance } from '../helper/generalUtil';

async function nobleNative() {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
const supplyData = await retry(async (_bail: any) =>
axios.get("https://noble-api.polkachu.com/cosmos/bank/v1beta1/supply/ausdy")
);

const circulatingSupply = supplyData?.data?.amount?.amount / 1e18;
let balances = {};
sumSingleBalance(balances, "peggedUSD", circulatingSupply, "issued", false);
return balances;
};
function nobleSupply() {
return cosmosSupply("noble", ['ausdy'], 18, '', 'peggedUSD');
}

async function bridgedFromNoble(channel: string) {
Expand Down Expand Up @@ -78,7 +65,7 @@ const chainContracts = {
const adapter: PeggedIssuanceAdapter = {
...addChainExports(chainContracts),
noble: {
minted: nobleNative()
minted: nobleSupply()
},
injective: {
noble: bridgedFromNoble("channel-31"),
Expand Down

0 comments on commit 0594623

Please sign in to comment.