From aab3764d93966f08a2e31036925af09cf155ec71 Mon Sep 17 00:00:00 2001 From: define Date: Wed, 4 Oct 2023 10:49:37 +0100 Subject: [PATCH 1/2] Draft PR adding support UAH --- src/adapters/peggedAssets/peggedAsset.type.ts | 2 +- src/adapters/peggedAssets/uaht/index.ts | 50 +++++++++++++++++++ src/peggedData/types.ts | 4 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/adapters/peggedAssets/uaht/index.ts diff --git a/src/adapters/peggedAssets/peggedAsset.type.ts b/src/adapters/peggedAssets/peggedAsset.type.ts index b89a8e82..993832f3 100644 --- a/src/adapters/peggedAssets/peggedAsset.type.ts +++ b/src/adapters/peggedAssets/peggedAsset.type.ts @@ -4,7 +4,7 @@ export type ChainBlocks = { [x: string]: number; }; -export type PeggedAssetType = "peggedUSD" | "peggedVAR" | "peggedEUR" | "peggedSGD" | "peggedJPY" | "peggedCNY"; +export type PeggedAssetType = "peggedUSD" | "peggedVAR" | "peggedEUR" | "peggedSGD" | "peggedJPY" | "peggedCNY" | "peggedUAH"; type StringNumber = string; type PeggedBalances = { diff --git a/src/adapters/peggedAssets/uaht/index.ts b/src/adapters/peggedAssets/uaht/index.ts new file mode 100644 index 00000000..d1febb1a --- /dev/null +++ b/src/adapters/peggedAssets/uaht/index.ts @@ -0,0 +1,50 @@ +const sdk = require("@defillama/sdk"); +import { sumSingleBalance } from "../helper/generalUtil"; +import { + ChainBlocks, + PeggedIssuanceAdapter, + Balances, +} from "../peggedAsset.type"; + +type ChainContracts = { + [chain: string]: { + [contract: string]: string[]; + }; +}; + +const chainContracts: ChainContracts = { + polygon: { + issued: ["0x0d9447e16072b636b4a1e8f2b8c644e58f3eaa6a"], + }, +}; + +async function chainMinted(chain: string, decimals: number) { + return async function ( + _timestamp: number, + _ethBlock: number, + _chainBlocks: ChainBlocks + ) { + let balances = {} as Balances; + for (let issued of chainContracts[chain].issued) { + const totalSupply = ( + await sdk.api.abi.call({ + abi: "erc20:totalSupply", + target: issued, + block: _chainBlocks?.[chain], + chain: chain, + }) + ).output; + sumSingleBalance(balances, "peggedUAH", totalSupply / 10 ** decimals, "issued", false); + } + return balances; + }; +} + +const adapter: PeggedIssuanceAdapter = { + polygon: { + minted: chainMinted("polygon", 2), + unreleased: async () => ({}), + }, +}; + +export default adapter; \ No newline at end of file diff --git a/src/peggedData/types.ts b/src/peggedData/types.ts index ca44f33d..936b786b 100644 --- a/src/peggedData/types.ts +++ b/src/peggedData/types.ts @@ -4,7 +4,9 @@ type PegType = | "peggedEUR" | "peggedSGD" | "peggedJPY" - | "peggedCNY"; + | "peggedCNY" + "peggedUAH"; + type PegMechanism = "algorithmic" | "fiat-backed" | "crypto-backed"; export type PriceSource = | "chainlink" From 4d0ce9973478950c40bf8f075e3466a70d4744ba Mon Sep 17 00:00:00 2001 From: define Date: Wed, 4 Oct 2023 11:17:45 +0100 Subject: [PATCH 2/2] add UAHT --- src/adapters/peggedAssets/index.ts | 6 ++++-- src/peggedData/peggedData.ts | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/adapters/peggedAssets/index.ts b/src/adapters/peggedAssets/index.ts index 37be9e8a..a17c2d08 100644 --- a/src/adapters/peggedAssets/index.ts +++ b/src/adapters/peggedAssets/index.ts @@ -127,7 +127,8 @@ import prismamkusd from './prisma-mkusd'; import lcny from './alternity-cny'; import nexus1 from './nexus'; import usdy from './ondo-us-dollar-yield'; -import svusd from './savvy-usd' +import svusd from './savvy-usd'; +import uaht from './uaht' export default { tether, @@ -259,5 +260,6 @@ export default { "alternity-cny": lcny, "nexus1": nexus1, "ondo-us-dollar-yield": usdy, - "savvy-usd": svusd + "savvy-usd": svusd, + uaht }; diff --git a/src/peggedData/peggedData.ts b/src/peggedData/peggedData.ts index 4ef2c4a8..cd1c5ae9 100644 --- a/src/peggedData/peggedData.ts +++ b/src/peggedData/peggedData.ts @@ -2616,4 +2616,24 @@ export default [ twitter: "https://twitter.com/SavvyDefi", wiki: "https://app.savvydefi.io/dashboard", }, +{ + id: "131", + name: "UAHT", + address: "0x0D9447E16072b636b4a1E8f2b8C644e58F3eaA6A", + symbol: "UAHT", + url: "https://uaht.io", + description: + "Welcome to the platform where people matter.", + mintRedeemDescription: + "UAHT is pegged to UAH Ukraine Currency", + onCoinGecko: "true", + gecko_id: "uaht", + cmcId: null, + pegType: "peggedUAH", + pegMechanism: "fiat-backed", + priceSource: "coingecko", + auditLinks: null, + twitter: "https://twitter.com/starscrowding", + wiki: "https://github.com/starscrowding/UAHT#readme", +}, ] as PeggedAsset[];