-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from osmosis-labs/sunny/add-osmosis-stables
Add more Osmosis stablecoins
- Loading branch information
Showing
11 changed files
with
295 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,5 +133,7 @@ | |
"polygon_zkevm", | ||
"base", | ||
"linea", | ||
"mantle" | ||
"mantle", | ||
"agoric", | ||
"emoney" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,5 +131,6 @@ | |
"lbry", | ||
"rvn", | ||
"ore", | ||
"genshiro" | ||
"genshiro", | ||
"aroric" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters