Skip to content

Commit

Permalink
add zunUSD and zunETH pegged assets (#302)
Browse files Browse the repository at this point in the history
Co-authored-by: Define101 <93603962+Define101@users.noreply.github.com>
  • Loading branch information
fextr and Define101 authored Apr 16, 2024
1 parent ad9947e commit 57b1a27
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/adapters/peggedAssets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -268,6 +270,8 @@ export default {
bob,
"real-usd": usdr,
"zunami-protocol": uzd,
zunUSD,
zunETH,
"bank-of-chain": bankofchain,
xai,
iusd,
Expand Down
56 changes: 56 additions & 0 deletions src/adapters/peggedAssets/zun-eth/index.ts
Original file line number Diff line number Diff line change
@@ -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;
56 changes: 56 additions & 0 deletions src/adapters/peggedAssets/zun-usd/index.ts
Original file line number Diff line number Diff line change
@@ -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;
44 changes: 42 additions & 2 deletions src/peggedData/peggedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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[];

0 comments on commit 57b1a27

Please sign in to comment.