Skip to content

Commit

Permalink
Merge pull request #173 from osmosis-labs/sunny/add-osmosis-stables
Browse files Browse the repository at this point in the history
Add more Osmosis stablecoins
  • Loading branch information
realdealshaman authored Nov 10, 2023
2 parents 649c3f7 + e67f84c commit ca03930
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 5 deletions.
38 changes: 38 additions & 0 deletions src/adapters/peggedAssets/cdt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { sumSingleBalance } from "../helper/generalUtil";
import {
Balances,
ChainBlocks,
PeggedIssuanceAdapter,
} from "../peggedAsset.type";
const axios = require("axios");
const retry = require("async-retry");

// There appears to be no explorer API that can give total supply; this endpoint was provided by dev.
async function osmosisMinted(decimals: number) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
const res = await retry(
async (_bail: any) =>
await axios.get(
"https://lcd.osmosis.zone/osmosis/superfluid/v1beta1/supply?denom=factory/osmo1s794h9rxggytja3a4pmwul53u98k06zy2qtrdvjnfuxruh7s8yjs6cyxgd/ucdt"
)
);
const cdtInfo = res?.data?.amount;
const supply = cdtInfo?.amount / 10 ** decimals;
sumSingleBalance(balances, "peggedVAR", supply, "issued", false);
return balances;
};
}

const adapter: PeggedIssuanceAdapter = {
osmosis: {
minted: osmosisMinted(6),
unreleased: async () => ({}),
},
};

export default adapter;
18 changes: 18 additions & 0 deletions src/adapters/peggedAssets/composite/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sumSingleBalance } from "../helper/generalUtil";
import { osmosisSupply } from "../helper/getSupply";
import {
ChainBlocks,
PeggedIssuanceAdapter,
Expand All @@ -7,6 +8,18 @@ import {
const axios = require("axios");
const retry = require("async-retry");

type ChainContracts = {
[chain: string]: {
[contract: string]: string[];
};
};

const chainContracts: ChainContracts = {
osmosis: {
bridgedFromComdex: ["ibc/23CA6C8D1AB2145DD13EB1E089A2E3F960DC298B468CCE034E19E5A78B61136E"],
},
};

async function compositeMinted(decimals: number) {
return async function (
_timestamp: number,
Expand All @@ -32,6 +45,11 @@ const adapter: PeggedIssuanceAdapter = {
minted: compositeMinted(6),
unreleased: async () => ({}),
},
osmosis: {
minted: async () => ({}),
unreleased: async () => ({}),
comdex: osmosisSupply(chainContracts.osmosis.bridgedFromComdex, 6, "Comdex"),
}
};

export default adapter;
80 changes: 80 additions & 0 deletions src/adapters/peggedAssets/eeur/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { sumSingleBalance } from "../helper/generalUtil";
import {
Balances,
ChainBlocks,
PeggedIssuanceAdapter,
} from "../peggedAsset.type";
const axios = require("axios");
const retry = require("async-retry");

type ChainContracts = {
[chain: string]: {
[contract: string]: string[];
};
};

const chainContracts: ChainContracts = {
osmosis: {
bridgedFromEmoney: ["ibc/5973C068568365FFF40DEDCF1A1CB7582B6116B731CD31A12231AE25E20B871F"],
},
}

async function emoneyMinted(decimals: number) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
const res = await retry(
async (_bail: any) =>
await axios.get(
"https://rest.cosmos.directory/emoney/cosmos/bank/v1beta1/supply/eeur"
)
);
const uskInfo = res?.data?.amount;
const supply = uskInfo?.amount / 10 ** decimals;
sumSingleBalance(balances, "peggedEUR", supply, "issued", false);
return balances;
};
}

// Copied this one from helpers in order to change the peggedUSD to peggedEUR
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,
"peggedEUR",
parseInt(res.data.amount.amount) / 10 ** decimals,
token,
false,
bridgedFromChain
);
}
return balances;
};
}

const adapter: PeggedIssuanceAdapter = {
emoney: {
minted: emoneyMinted(6),
unreleased: async () => ({}),
},
osmosis: {
minted: async () => ({}),
unreleased: async () => ({}),
emoney: osmosisSupply(chainContracts.osmosis.bridgedFromEmoney, 6, "e-Money"),
}
};

export default adapter;
11 changes: 10 additions & 1 deletion src/adapters/peggedAssets/frax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
bridgedSupply,
supplyInEthereumBridge,
solanaMintedOrBridged,
osmosisSupply,
} from "../helper/getSupply";
import {
ChainBlocks,
Expand Down Expand Up @@ -72,7 +73,10 @@ const chainContracts: ChainContracts = {
},
dogechain: {
bridgedFromETH: ["0xf27Ee99622C3C9b264583dACB2cCE056e194494f"], // multichain
}
},
osmosis: {
bridgedFromETH: ["ibc/0E43EDE2E2A3AFA36D0CD38BDDC0B49FECA64FA426A82E102F304E430ECF46EE"], // axelar
},
};

/*
Expand Down Expand Up @@ -228,6 +232,11 @@ const adapter: PeggedIssuanceAdapter = {
unreleased: async () => ({}),
ethereum: bridgedSupply("dogechain", 18, chainContracts.dogechain.bridgedFromETH),
},
osmosis: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: osmosisSupply(chainContracts.osmosis.bridgedFromETH, 18, "Axelar"),
}
};

export default adapter;
4 changes: 3 additions & 1 deletion src/adapters/peggedAssets/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,7 @@
"polygon_zkevm",
"base",
"linea",
"mantle"
"mantle",
"agoric",
"emoney"
]
55 changes: 55 additions & 0 deletions src/adapters/peggedAssets/inter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { sumSingleBalance } from "../helper/generalUtil";
import { osmosisSupply } from "../helper/getSupply";
import {
Balances,
ChainBlocks,
PeggedIssuanceAdapter,
} from "../peggedAsset.type";
const axios = require("axios");
const retry = require("async-retry");

type ChainContracts = {
[chain: string]: {
[contract: string]: string[];
};
};

const chainContracts: ChainContracts = {
osmosis: {
bridgedFromAgoric: ["ibc/92BE0717F4678905E53F4E45B2DED18BC0CB97BF1F8B6A25AFEDF3D5A879B4D5"],
},
}

async function agoricMinted(decimals: number) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
const res = await retry(
async (_bail: any) =>
await axios.get(
"https://rest.cosmos.directory/agoric/cosmos/bank/v1beta1/supply/uist"
)
);
const uskInfo = res?.data?.amount;
const supply = uskInfo?.amount / 10 ** decimals;
sumSingleBalance(balances, "peggedUSD", supply, "issued", false);
return balances;
};
}

const adapter: PeggedIssuanceAdapter = {
agoric: {
minted: agoricMinted(6),
unreleased: async () => ({}),
},
osmosis: {
minted: async () => ({}),
unreleased: async () => ({}),
agoric: osmosisSupply(chainContracts.osmosis.bridgedFromAgoric, 6, "Agoric"),
}
};

export default adapter;
3 changes: 2 additions & 1 deletion src/adapters/peggedAssets/llama-helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@
"lbry",
"rvn",
"ore",
"genshiro"
"genshiro",
"aroric"
]
5 changes: 4 additions & 1 deletion src/adapters/peggedAssets/usd-coin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ const chainContracts: ChainContracts = {
bridgedFromNoble: ["ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9"],
},
osmosis: {
bridgedFromETH: ["ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858"], // axelar
bridgedFromETH: [
"ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // axelar
"ibc/9F9B07EF9AD291167CF5700628145DE1DEB777C2CFC7907553B24446515F6D0E", // gravity
],
bridgedFromNoble: ["ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"],
}
};
Expand Down
12 changes: 11 additions & 1 deletion src/adapters/peggedAssets/usk/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sumSingleBalance } from "../helper/generalUtil";
import { osmosisSupply } from "../helper/getSupply";
import {
Balances,
ChainBlocks,
Expand All @@ -13,7 +14,11 @@ type ChainContracts = {
};
};

const chainContracts: ChainContracts = {};
const chainContracts: ChainContracts = {
osmosis: {
bridgedFromKujira: ["ibc/44492EAB24B72E3FB59B9FA619A22337FB74F95D8808FE6BC78CC0E6C18DC2EC"],
},
};

// There appears to be no explorer API that can give total supply; this endpoint was provided by dev.
async function kujiraMinted(decimals: number) {
Expand Down Expand Up @@ -41,6 +46,11 @@ const adapter: PeggedIssuanceAdapter = {
minted: kujiraMinted(6),
unreleased: async () => ({}),
},
osmosis: {
minted: async () => ({}),
unreleased: async () => ({}),
kujira: osmosisSupply(chainContracts.osmosis.bridgedFromKujira, 6, "Kujira"),
}
};

export default adapter;
62 changes: 62 additions & 0 deletions src/peggedData/peggedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2696,5 +2696,67 @@ export default [
twitter: "https://twitter.com/0xPhase",
wiki: "https://docs.phase.cash/protocol/what-is-phase",
},
{
id: "135",
name: "Inter",
address: null,
symbol: "IST",
url: "https://inter.trade/",
description:
"IST is the over-collateralized, risk-managed stable token for the interchain.",
mintRedeemDescription:
"Inter Protocol’s Vaults let you mint IST against the value of your IBC assets (like ATOM) to unlock liquidity. IST minters actively manage their positions to avoid liquidations if their asset value falls. Anyone can participate in bidding on liquidation auctions to profit from auctioned collateral.",
onCoinGecko: "true",
gecko_id: "inter-stable-token",
cmcId: 22736,
pegType: "peggedUSD",
pegMechanism: "crypto-backed",
priceSource: "coingecko",
auditLinks: "https://assets.ctfassets.net/xm0kp9xt5r54/1pucZFh1QsF1PgL5vhGAtS/054cd042b32f962fce8843758d6f3483/Atredis_Partners_-_Agoric_Vaults_Implementation_Assessment__-_Report_v1.0___1_.pdf",
twitter: "https://twitter.com/inter_protocol",
wiki: "https://docs.inter.trade/",
},
{
id: "136",
name: "e-Money Euro",
address: null,
symbol: "EEUR",
url: "https://e-money.com",
description:
"e-Money EUR stablecoin. Audited and backed by fiat EUR deposits and government bonds.",
mintRedeemDescription:
"Unlike most existing stablecoins which aim to maintain a static 1:1 peg with their underlying assets, the value of e-Money’s currency-backed tokens continually shifts in line with the interest accrued on the reserve assets. This means that holders benefit from the interest accrued on their assets while they sit securely in your wallet.",
onCoinGecko: "true",
gecko_id: "e-money-eur",
cmcId: 13877,
pegType: "peggedEUR",
pegMechanism: "fiat-backed",
priceSource: "coingecko",
auditLinks: null,
twitter: "https://twitter.com/emoney_com",
wiki: null,
},
{
id: "137",
name: "Membrane",
address: null,
symbol: "CDT",
url: "https://membrane-ui-mainnet.vercel.app/",
description:
"Membrane is an experimental protocol that uses collateralized debt positions to synthesize credit demand into composable debt tokens that traverse the Cosmos in the form of $CDT.",
mintRedeemDescription:
"The mechanism is roughly analogous to a “Line of Credit”, wherein vault owners can deposit their collateral to receive a line of credit against it. This unique functionality enables a large amount of flexibility in otherwise rigid token positions.",
onCoinGecko: "false",
gecko_id: "cdt",
cmcId: null,
pegType: "peggedVAR",
pegMechanism: "crypto-backed",
priceSource: null,
auditLinks: "https://github.com/oak-security/audit-reports/blob/master/Membrane/2023-06-15%20Audit%20Report%20-%20Membrane%20v1.0.pdf",
twitter: "https://twitter.com/insaneinthembrn",
wiki: "https://membrane-finance.gitbook.io/",
},



] as PeggedAsset[];
12 changes: 12 additions & 0 deletions src/utils/normalizeChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,18 @@ export const chainCoingeckoIds = {
types: ["L2", "gas"]
},
},
Agoric: {
geckoId: "agoric",
symbol: "BLD",
cmcId: "16697",
categories: ["Cosmos"],
},
eMoney: {
geckoId: "e-money",
symbol: "NGM",
cmcId: "8279",
categories: ["Cosmos"],
},
} as {
[chain: string]: {
geckoId: string | null;
Expand Down

0 comments on commit ca03930

Please sign in to comment.