From 57b1a274e57244483630182e604df5231b03c97d Mon Sep 17 00:00:00 2001 From: fextr <34183870+fextr@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:36:21 +0400 Subject: [PATCH] add zunUSD and zunETH pegged assets (#302) Co-authored-by: Define101 <93603962+Define101@users.noreply.github.com> --- src/adapters/peggedAssets/index.ts | 4 ++ src/adapters/peggedAssets/zun-eth/index.ts | 56 ++++++++++++++++++++++ src/adapters/peggedAssets/zun-usd/index.ts | 56 ++++++++++++++++++++++ src/peggedData/peggedData.ts | 44 ++++++++++++++++- 4 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 src/adapters/peggedAssets/zun-eth/index.ts create mode 100644 src/adapters/peggedAssets/zun-usd/index.ts diff --git a/src/adapters/peggedAssets/index.ts b/src/adapters/peggedAssets/index.ts index c949d6f9..ac7078b0 100644 --- a/src/adapters/peggedAssets/index.ts +++ b/src/adapters/peggedAssets/index.ts @@ -86,6 +86,8 @@ import usdw from "./usdw"; import bob from "./bob"; import usdr from "./real-usd"; import uzd from "./zunami-protocol"; +import zunUSD from "./zun-usd" +import zunETH from "./zun-eth" import bankofchain from "./bank-of-chain"; import xai from "./xai"; import iusd from "./iusd"; @@ -268,6 +270,8 @@ export default { bob, "real-usd": usdr, "zunami-protocol": uzd, + zunUSD, + zunETH, "bank-of-chain": bankofchain, xai, iusd, diff --git a/src/adapters/peggedAssets/zun-eth/index.ts b/src/adapters/peggedAssets/zun-eth/index.ts new file mode 100644 index 00000000..b08054e1 --- /dev/null +++ b/src/adapters/peggedAssets/zun-eth/index.ts @@ -0,0 +1,56 @@ +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 = { + ethereum: { + issued: ["0xc2e660C62F72c2ad35AcE6DB78a616215E2F2222"], + }, +}; + +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, + "peggedVAR", + totalSupply / 10 ** decimals, + "issued", + false + ); + } + return balances; + }; +} + +const adapter: PeggedIssuanceAdapter = { + ethereum: { + minted: chainMinted("ethereum", 18), + unreleased: async () => ({}), + }, +}; + +export default adapter; diff --git a/src/adapters/peggedAssets/zun-usd/index.ts b/src/adapters/peggedAssets/zun-usd/index.ts new file mode 100644 index 00000000..9ae3c959 --- /dev/null +++ b/src/adapters/peggedAssets/zun-usd/index.ts @@ -0,0 +1,56 @@ +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 = { + ethereum: { + issued: ["0x8C0D76C9B18779665475F3E212D9Ca1Ed6A1A0e6"], + }, +}; + +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, + "peggedUSD", + totalSupply / 10 ** decimals, + "issued", + false + ); + } + return balances; + }; +} + +const adapter: PeggedIssuanceAdapter = { + ethereum: { + minted: chainMinted("ethereum", 18), + unreleased: async () => ({}), + }, +}; + +export default adapter; diff --git a/src/peggedData/peggedData.ts b/src/peggedData/peggedData.ts index 4d79c462..7f5ce268 100644 --- a/src/peggedData/peggedData.ts +++ b/src/peggedData/peggedData.ts @@ -3606,7 +3606,7 @@ export default [ twitter: "https://twitter.com/YamatoProtocol", wiki: "https://docs.yamato.fi/v/en", }, -{ + { id: "180", name: "Bread", address: "gnosis:0xa555d5344f6fb6c65da19e403cb4c1ec4a1a5ee3", @@ -3625,5 +3625,45 @@ export default [ auditLinks: null, twitter: "https://twitter.com/breadchain_", wiki: null, -} +}, + { + id: "181", + name: "Zunami USD", + address: "0x8C0D76C9B18779665475F3E212D9Ca1Ed6A1A0e6", + symbol: "zunUSD", + url: "https://www.zunami.io/", + description: + "zunUSD is an ERC-20 stablecoin minted using the USD Omnipool as collateral. The Omnipool functions as a Yield Aggregator, providing liquidity to multiple strategies and reinvesting profits.", + mintRedeemDescription: + "The Algorithmic Peg Stabilizer (APS) stands as the foundational mechanism for both minting and redeeming zunStables, as well as maintaining their peg to USD. The concept of APS draws inspiration from AMO of FRAX and bears resemblance to similar mechanisms such as Elixir from Alchemix.", + onCoinGecko: "false", + gecko_id: null, + cmcId: null, + pegType: "peggedUSD", + pegMechanism: "crypto-backed", + priceSource: "defillama", + auditLinks: "https://github.com/ZunamiProtocol/ZunamiProtocolV2/tree/main/audit", + twitter: "https://twitter.com/ZunamiProtocol", + wiki: "https://wiki.defillama.com/wiki/Zunami_Protocol", + }, + { + id: "182", + name: "Zunami ETH", + address: "0xc2e660C62F72c2ad35AcE6DB78a616215E2F2222", + symbol: "zunETH", + url: "https://www.zunami.io/", + description: + "zunETH is an ERC-20 stablecoin minted using the ETH Omnipool as collateral. The Omnipool functions as a Yield Aggregator, providing liquidity to multiple strategies and reinvesting profits.", + mintRedeemDescription: + "The Algorithmic Peg Stabilizer (APS) stands as the foundational mechanism for both minting and redeeming zunStables, as well as maintaining their peg to ETH. The concept of APS draws inspiration from AMO of FRAX and bears resemblance to similar mechanisms such as Elixir from Alchemix.", + onCoinGecko: "false", + gecko_id: null, + cmcId: null, + pegType: "peggedVAR", + pegMechanism: "crypto-backed", + priceSource: "defillama", + auditLinks: "https://github.com/ZunamiProtocol/ZunamiProtocolV2/tree/main/audit", + twitter: "https://twitter.com/ZunamiProtocol", + wiki: "https://wiki.defillama.com/wiki/Zunami_Protocol", + }, ] as PeggedAsset[];