diff --git a/src/adapters/peggedAssets/index.ts b/src/adapters/peggedAssets/index.ts index 31519157..64f76796 100644 --- a/src/adapters/peggedAssets/index.ts +++ b/src/adapters/peggedAssets/index.ts @@ -102,6 +102,7 @@ import cash from "./stabl-fi"; import dsu from "./digital-standard-unit"; import electronicusd from "./electronic-usd"; import hyusd from "./high-yield-usd"; +import usd3 from "./web-3-dollar"; import eure from "./monerium-eur-money"; import anonusd from "./offshift-anonusd"; import nxusd from "./nxusd"; @@ -281,6 +282,7 @@ export default { "digital-standard-unit": dsu, "electronic-usd": electronicusd, "high-yield-usd": hyusd, + "web-3-dollar": usd3, "monerium-eur-money": eure, "offshift-anonusd": anonusd, nxusd, diff --git a/src/adapters/peggedAssets/web-3-dollar/index.ts b/src/adapters/peggedAssets/web-3-dollar/index.ts new file mode 100644 index 00000000..085edc6a --- /dev/null +++ b/src/adapters/peggedAssets/web-3-dollar/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: ["0x0d86883FAf4FfD7aEb116390af37746F45b6f378"], + }, +}; + +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 edbb4830..87a85633 100644 --- a/src/peggedData/peggedData.ts +++ b/src/peggedData/peggedData.ts @@ -3566,4 +3566,24 @@ export default [ twitter: "https://twitter.com/nostrafinance", wiki: null, }, + { + id: "178", + name: "Web 3 Dollar", + address: "0x0d86883FAf4FfD7aEb116390af37746F45b6f378", + symbol: "USD3", + url: "https://app.reserve.org/ethereum/token/0x0d86883faf4ffd7aeb116390af37746f45b6f378/overview", + description: + "Earn the DeFi rate any time you're in stables", + mintRedeemDescription: + "Minting requires a deposit of the defined collateral tokens in equal value amounts to the RToken smart contracts.", + onCoinGecko: null, + gecko_id: "web-3-dollar", //fakecg + cmcId: null, + pegType: "peggedUSD", + pegMechanism: "crypto-backed", + priceSource: "defillama", + auditLinks: null, + twitter: "https://twitter.com/USD_3", + wiki: "https://app.reserve.org/ethereum/token/0x0d86883faf4ffd7aeb116390af37746f45b6f378/overview", + } ] as PeggedAsset[];