From e3bb37dcde3761bffb5eb30f827318be9debdf79 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Wed, 8 Nov 2023 14:51:37 -0500 Subject: [PATCH 1/6] fix usdt and dai --- src/adapters/peggedAssets/dai/index.ts | 7 ++++++- src/adapters/peggedAssets/helper/getSupply.ts | 6 +++--- src/adapters/peggedAssets/tether/index.ts | 13 ++++++++++++- src/adapters/peggedAssets/usd-coin/index.ts | 9 +++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/adapters/peggedAssets/dai/index.ts b/src/adapters/peggedAssets/dai/index.ts index b92d8b78..78202f7c 100644 --- a/src/adapters/peggedAssets/dai/index.ts +++ b/src/adapters/peggedAssets/dai/index.ts @@ -9,6 +9,7 @@ import { solanaMintedOrBridged, terraSupply, osmosisSupply, + cosmosSupply, } from "../helper/getSupply"; import { getTotalSupply as ontologyGetTotalSupply, @@ -209,6 +210,9 @@ const chainContracts: ChainContracts = { mixin: { ethAssetIds: ["8549b4ad-917c-3461-a646-481adc5d7f7f"], }, + osmosis: { + bridgedFromETH: ["ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7"], // axelar + } }; /* @@ -574,7 +578,8 @@ const adapter: PeggedIssuanceAdapter = { osmosis: { minted: async () => ({}), unreleased: async () => ({}), - ethereum: osmosisSupply("dai", "Axelar", "Ethereum"), + ethereum: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromETH, 18, "Axelar"), + }, starknet: { minted: async () => ({}), diff --git a/src/adapters/peggedAssets/helper/getSupply.ts b/src/adapters/peggedAssets/helper/getSupply.ts index ecb89af2..7f01d7ec 100644 --- a/src/adapters/peggedAssets/helper/getSupply.ts +++ b/src/adapters/peggedAssets/helper/getSupply.ts @@ -188,7 +188,7 @@ export async function terraSupply(addresses: string[], decimals: number) { }; } -export async function osmosisSupply(token: string, bridgeName: string, bridgedFrom: string) { +export async function osmosisLiquidity(token: string, bridgeName: string, bridgedFrom: string) { return async function ( _timestamp: number, _ethBlock: number, @@ -199,8 +199,8 @@ export async function osmosisSupply(token: string, bridgeName: string, bridgedFr async (_bail: any) => await axios.get(`https://api-osmosis.imperator.co/tokens/v2/${token}`) ); - const totalSupply = res.data[0].liquidity; - sumSingleBalance(balances, "peggedUSD", totalSupply, bridgeName, false, bridgedFrom); + const totalLiquidity = res.data[0].liquidity; + sumSingleBalance(balances, "peggedUSD", totalLiquidity, bridgeName, false, bridgedFrom); return balances; }; } diff --git a/src/adapters/peggedAssets/tether/index.ts b/src/adapters/peggedAssets/tether/index.ts index 06447ab7..303b3e15 100644 --- a/src/adapters/peggedAssets/tether/index.ts +++ b/src/adapters/peggedAssets/tether/index.ts @@ -5,6 +5,7 @@ import { supplyInEthereumBridge, solanaMintedOrBridged, terraSupply, + cosmosSupply, } from "../helper/getSupply"; import { getTokenBalance as solanaGetTokenBalance } from "../helper/solana"; import { @@ -339,6 +340,10 @@ const chainContracts: ChainContracts = { "0x4f3C8E20942461e2c3Bdd8311AC57B0c222f2b82" ], }, + osmosis: { + bridgedFromETH: ["ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4"], + bridgedFromKava: ["ibc/4ABBEF4C8926DDDB320AE5188CFD63267ABBCEFC0583E4AE05D6E5AA2401DDAB"], + } }; /* @@ -1308,7 +1313,13 @@ const adapter: PeggedIssuanceAdapter = { minted: async () => ({}), unreleased: async () => ({}), ethereum: bridgedSupply("thundercore", 6, chainContracts.thundercore.bridgeFromETH), - } + }, + osmosis: { + minted: async () => ({}), + unreleased: async () => ({}), + ethereum: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromETH, 6, "Axelar"), + kava: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromKava, 6, "Kava"), + }, }; export default adapter; diff --git a/src/adapters/peggedAssets/usd-coin/index.ts b/src/adapters/peggedAssets/usd-coin/index.ts index b36b1262..fc79b247 100644 --- a/src/adapters/peggedAssets/usd-coin/index.ts +++ b/src/adapters/peggedAssets/usd-coin/index.ts @@ -9,7 +9,7 @@ import { supplyInEthereumBridge, solanaMintedOrBridged, terraSupply, - osmosisSupply, + cosmosSupply, kujiraSupply, } from "../helper/getSupply"; import { @@ -347,6 +347,10 @@ const chainContracts: ChainContracts = { kujira: { bridgedFromETH: ["ibc/295548A78785A1007F232DE286149A6FF512F180AF5657780FC89C009E2C348F"], bridgedFromNoble: ["ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9"], + }, + osmosis: { + bridgedFromETH: ["ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858"], + bridgedFromNoble: ["ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"], } }; @@ -1031,7 +1035,8 @@ const adapter: PeggedIssuanceAdapter = { osmosis: { minted: async () => ({}), unreleased: async () => ({}), - ethereum: osmosisSupply("usdc", "Axelar", "Ethereum"), + ethereum: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromETH, 6, "Axelar"), + noble: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromNoble, 6, "Noble"), }, fantom: { minted: async () => ({}), From 63216054db56d5016b08dc93ad23b1141647b9dc Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Wed, 8 Nov 2023 14:54:45 -0500 Subject: [PATCH 2/6] Apply suggestions from code review --- src/adapters/peggedAssets/tether/index.ts | 2 +- src/adapters/peggedAssets/usd-coin/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adapters/peggedAssets/tether/index.ts b/src/adapters/peggedAssets/tether/index.ts index 303b3e15..f17a5c53 100644 --- a/src/adapters/peggedAssets/tether/index.ts +++ b/src/adapters/peggedAssets/tether/index.ts @@ -341,7 +341,7 @@ const chainContracts: ChainContracts = { ], }, osmosis: { - bridgedFromETH: ["ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4"], + bridgedFromETH: ["ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4"], // axelar bridgedFromKava: ["ibc/4ABBEF4C8926DDDB320AE5188CFD63267ABBCEFC0583E4AE05D6E5AA2401DDAB"], } }; diff --git a/src/adapters/peggedAssets/usd-coin/index.ts b/src/adapters/peggedAssets/usd-coin/index.ts index fc79b247..4bac3c87 100644 --- a/src/adapters/peggedAssets/usd-coin/index.ts +++ b/src/adapters/peggedAssets/usd-coin/index.ts @@ -349,7 +349,7 @@ const chainContracts: ChainContracts = { bridgedFromNoble: ["ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9"], }, osmosis: { - bridgedFromETH: ["ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858"], + bridgedFromETH: ["ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858"], // axelar bridgedFromNoble: ["ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"], } }; From f3800179dd25f7fab5c886c764df630847bfdc38 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Wed, 8 Nov 2023 19:13:43 -0500 Subject: [PATCH 3/6] fix ustc --- src/adapters/package-lock.json | 4 ++-- src/adapters/peggedAssets/terrausd/index.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/adapters/package-lock.json b/src/adapters/package-lock.json index 4909d068..8d33d89e 100644 --- a/src/adapters/package-lock.json +++ b/src/adapters/package-lock.json @@ -26015,7 +26015,7 @@ "requires": { "base64-url": "^2.3.3", "eventsource": "^1.1.0", - "node-fetch": "2.6.7", + "node-fetch": "^2.6.1", "p-retry": "^4.5.0" } }, @@ -27933,7 +27933,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "requires": { - "ansi-regex": "5.0.1" + "ansi-regex": "^4.1.0" } }, "strip-json-comments": { diff --git a/src/adapters/peggedAssets/terrausd/index.ts b/src/adapters/peggedAssets/terrausd/index.ts index 42b3361f..792ba2e3 100644 --- a/src/adapters/peggedAssets/terrausd/index.ts +++ b/src/adapters/peggedAssets/terrausd/index.ts @@ -6,7 +6,7 @@ import { import { bridgedSupply, solanaMintedOrBridged, - osmosisSupply, + cosmosSupply, } from "../helper/getSupply"; import { ChainBlocks, @@ -88,6 +88,9 @@ const chainContracts: ChainContracts = { dfk: { bridgedFromTerra: ["0x360d6dd540e3448371876662fbe7f1acaf08c5ab"], // synapse }, + osmosis: { + bridgedFromTerra: ["ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC"], + }, }; /* @@ -201,7 +204,7 @@ const adapter: PeggedIssuanceAdapter = { osmosis: { minted: async () => ({}), unreleased: async () => ({}), - terra: osmosisSupply("ustc", "Axelar", "Terra"), + terra: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromTerra, 6, "Terra"), }, moonbeam: { minted: async () => ({}), From 436eede0e1e37ed8b80cae12f11d8caa55dc3586 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Wed, 8 Nov 2023 19:18:17 -0500 Subject: [PATCH 4/6] revert package-lock.json --- src/adapters/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adapters/package-lock.json b/src/adapters/package-lock.json index 8d33d89e..4909d068 100644 --- a/src/adapters/package-lock.json +++ b/src/adapters/package-lock.json @@ -26015,7 +26015,7 @@ "requires": { "base64-url": "^2.3.3", "eventsource": "^1.1.0", - "node-fetch": "^2.6.1", + "node-fetch": "2.6.7", "p-retry": "^4.5.0" } }, @@ -27933,7 +27933,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "requires": { - "ansi-regex": "^4.1.0" + "ansi-regex": "5.0.1" } }, "strip-json-comments": { From 39034ecc0812895c8f1b8e62dc49518cc750acc7 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Wed, 8 Nov 2023 19:19:16 -0500 Subject: [PATCH 5/6] catch unused import --- src/adapters/package-lock.json | 4 ++-- src/adapters/peggedAssets/dai/index.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/adapters/package-lock.json b/src/adapters/package-lock.json index 4909d068..8d33d89e 100644 --- a/src/adapters/package-lock.json +++ b/src/adapters/package-lock.json @@ -26015,7 +26015,7 @@ "requires": { "base64-url": "^2.3.3", "eventsource": "^1.1.0", - "node-fetch": "2.6.7", + "node-fetch": "^2.6.1", "p-retry": "^4.5.0" } }, @@ -27933,7 +27933,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "requires": { - "ansi-regex": "5.0.1" + "ansi-regex": "^4.1.0" } }, "strip-json-comments": { diff --git a/src/adapters/peggedAssets/dai/index.ts b/src/adapters/peggedAssets/dai/index.ts index 78202f7c..c3f36241 100644 --- a/src/adapters/peggedAssets/dai/index.ts +++ b/src/adapters/peggedAssets/dai/index.ts @@ -8,7 +8,6 @@ import { supplyInEthereumBridge, solanaMintedOrBridged, terraSupply, - osmosisSupply, cosmosSupply, } from "../helper/getSupply"; import { From 466e812270d56934e9822b80e9efb7aa2bcb6e78 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 9 Nov 2023 16:18:12 -0500 Subject: [PATCH 6/6] fixed and is working --- src/adapters/peggedAssets/dai/index.ts | 4 ++-- src/adapters/peggedAssets/helper/getSupply.ts | 24 +++++++++++++++++++ src/adapters/peggedAssets/terrausd/index.ts | 4 ++-- src/adapters/peggedAssets/tether/index.ts | 6 ++--- src/adapters/peggedAssets/usd-coin/index.ts | 5 ++-- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/adapters/peggedAssets/dai/index.ts b/src/adapters/peggedAssets/dai/index.ts index c3f36241..adc72c8c 100644 --- a/src/adapters/peggedAssets/dai/index.ts +++ b/src/adapters/peggedAssets/dai/index.ts @@ -8,7 +8,7 @@ import { supplyInEthereumBridge, solanaMintedOrBridged, terraSupply, - cosmosSupply, + osmosisSupply, } from "../helper/getSupply"; import { getTotalSupply as ontologyGetTotalSupply, @@ -577,7 +577,7 @@ const adapter: PeggedIssuanceAdapter = { osmosis: { minted: async () => ({}), unreleased: async () => ({}), - ethereum: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromETH, 18, "Axelar"), + ethereum: osmosisSupply(chainContracts.osmosis.bridgedFromETH, 18, "Axelar"), }, starknet: { diff --git a/src/adapters/peggedAssets/helper/getSupply.ts b/src/adapters/peggedAssets/helper/getSupply.ts index 7f01d7ec..40151d30 100644 --- a/src/adapters/peggedAssets/helper/getSupply.ts +++ b/src/adapters/peggedAssets/helper/getSupply.ts @@ -230,6 +230,30 @@ export async function cosmosSupply(chain: string, tokens: string[], decimals: nu }; } +export async function osmosisSupply(tokens: string[], decimals: number, bridgedFromChain: string) { + return async function ( + _timestamp: number, + _ethBlock: number, + _chainBlocks: ChainBlocks + ) { + let balances = {} as Balances; + for (let token of tokens) { + const res = await retry( + async (_bail: any) => + await axios.get(`https://lcd.osmosis.zone/osmosis/superfluid/v1beta1/supply?denom=${token}`) + ); + sumSingleBalance( + balances, + "peggedUSD", + parseInt(res.data.amount.amount) / 10 ** decimals, + token, + false, + bridgedFromChain + ); + } + return balances; + }; +} export async function kujiraSupply(tokens: string[], decimals: number, bridgedFromChain: string) { return cosmosSupply("kujira", tokens, decimals, bridgedFromChain); diff --git a/src/adapters/peggedAssets/terrausd/index.ts b/src/adapters/peggedAssets/terrausd/index.ts index 792ba2e3..37e85b8a 100644 --- a/src/adapters/peggedAssets/terrausd/index.ts +++ b/src/adapters/peggedAssets/terrausd/index.ts @@ -6,7 +6,7 @@ import { import { bridgedSupply, solanaMintedOrBridged, - cosmosSupply, + osmosisSupply, } from "../helper/getSupply"; import { ChainBlocks, @@ -204,7 +204,7 @@ const adapter: PeggedIssuanceAdapter = { osmosis: { minted: async () => ({}), unreleased: async () => ({}), - terra: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromTerra, 6, "Terra"), + terra: osmosisSupply(chainContracts.osmosis.bridgedFromTerra, 6, "Terra"), }, moonbeam: { minted: async () => ({}), diff --git a/src/adapters/peggedAssets/tether/index.ts b/src/adapters/peggedAssets/tether/index.ts index f17a5c53..ccf8b983 100644 --- a/src/adapters/peggedAssets/tether/index.ts +++ b/src/adapters/peggedAssets/tether/index.ts @@ -5,7 +5,7 @@ import { supplyInEthereumBridge, solanaMintedOrBridged, terraSupply, - cosmosSupply, + osmosisSupply, } from "../helper/getSupply"; import { getTokenBalance as solanaGetTokenBalance } from "../helper/solana"; import { @@ -1317,8 +1317,8 @@ const adapter: PeggedIssuanceAdapter = { osmosis: { minted: async () => ({}), unreleased: async () => ({}), - ethereum: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromETH, 6, "Axelar"), - kava: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromKava, 6, "Kava"), + ethereum: osmosisSupply(chainContracts.osmosis.bridgedFromETH, 6, "Axelar"), + kava: osmosisSupply(chainContracts.osmosis.bridgedFromKava, 6, "Kava"), }, }; diff --git a/src/adapters/peggedAssets/usd-coin/index.ts b/src/adapters/peggedAssets/usd-coin/index.ts index 4bac3c87..593ec47f 100644 --- a/src/adapters/peggedAssets/usd-coin/index.ts +++ b/src/adapters/peggedAssets/usd-coin/index.ts @@ -11,6 +11,7 @@ import { terraSupply, cosmosSupply, kujiraSupply, + osmosisSupply, } from "../helper/getSupply"; import { getTotalSupply as ontologyGetTotalSupply, @@ -1035,8 +1036,8 @@ const adapter: PeggedIssuanceAdapter = { osmosis: { minted: async () => ({}), unreleased: async () => ({}), - ethereum: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromETH, 6, "Axelar"), - noble: cosmosSupply("osmosis", chainContracts.osmosis.bridgedFromNoble, 6, "Noble"), + ethereum: osmosisSupply(chainContracts.osmosis.bridgedFromETH, 6, "Axelar"), + noble: osmosisSupply(chainContracts.osmosis.bridgedFromNoble, 6, "Noble"), }, fantom: { minted: async () => ({}),