diff --git a/src/adapters/peggedAssets/index.ts b/src/adapters/peggedAssets/index.ts index 116a39e0..4a8a063a 100644 --- a/src/adapters/peggedAssets/index.ts +++ b/src/adapters/peggedAssets/index.ts @@ -130,6 +130,7 @@ import usdy from './ondo-us-dollar-yield'; import svusd from './savvy-usd'; import uaht from './uaht' import usdm from './usdm' +import nars from './nars' export default { tether, @@ -263,5 +264,6 @@ export default { "ondo-us-dollar-yield": usdy, "savvy-usd": svusd, uaht, - "mountain-protocol-usdm": usdm + "mountain-protocol-usdm": usdm, + "num-ars": nars }; diff --git a/src/adapters/peggedAssets/nars/index.ts b/src/adapters/peggedAssets/nars/index.ts new file mode 100644 index 00000000..f8f8fa86 --- /dev/null +++ b/src/adapters/peggedAssets/nars/index.ts @@ -0,0 +1,87 @@ +const sdk = require("@defillama/sdk"); +import { sumSingleBalance } from "../helper/generalUtil"; +import { + ChainBlocks, + PeggedIssuanceAdapter, + Balances, +} from "../peggedAsset.type"; + +type ChainContracts = { + [chain: string]: { + issued: string; + unreleased: string[]; + }; +}; + +const chainContracts: ChainContracts = { + polygon: { + issued: "0x65517425ac3ce259a34400bb67ceb39ff3ddc0bd", + unreleased: [ + "0x8388A0f91875e74Dc4705Abf2C9bBDD1bD40C585" + ], + }, +}; + +async function chainMinted(chain: string, decimals: number) { + return async function ( + _timestamp: number, + _ethBlock: number, + _chainBlocks: ChainBlocks + ) { + let balances = {} as Balances; + const totalSupply = ( + await sdk.api.abi.call({ + abi: "erc20:totalSupply", + target: chainContracts[chain].issued, + block: _chainBlocks?.[chain], + chain: chain, + }) + ).output; + sumSingleBalance( + balances, + "peggedARS", + totalSupply / 10 ** decimals, + "issued", + false + ); + return balances; + }; +} + +async function chainUnreleased(chain: string, decimals: number) { + return async function ( + _timestamp: number, + _ethBlock: number, + _chainBlocks: ChainBlocks + ) { + let balances = {} as Balances; + for (let unreleased of chainContracts[chain].unreleased) { + const unreleasedBalance = ( + await sdk.api.abi.call({ + abi: "erc20:balanceOf", + target: chainContracts[chain].issued, + params: [unreleased], + block: _chainBlocks?.[chain], + chain: chain, + }) + ).output; + sumSingleBalance( + balances, + "peggedARS", + unreleasedBalance / 10 ** decimals, + "unreleased", + false + ); + } + return balances; + }; +} + +const adapter: PeggedIssuanceAdapter = { + polygon: { + minted: chainMinted("polygon", 18), + unreleased: chainUnreleased("polygon", 18), + }, + }; + +export default adapter; \ No newline at end of file diff --git a/src/adapters/peggedAssets/peggedAsset.type.ts b/src/adapters/peggedAssets/peggedAsset.type.ts index 993832f3..1b2cfe5e 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" | "peggedUAH"; +export type PeggedAssetType = "peggedUSD" | "peggedVAR" | "peggedEUR" | "peggedSGD" | "peggedJPY" | "peggedCNY" | "peggedUAH" | "peggedARS" ; type StringNumber = string; type PeggedBalances = { diff --git a/src/peggedData/peggedData.ts b/src/peggedData/peggedData.ts index c56d20e6..b1ae4500 100644 --- a/src/peggedData/peggedData.ts +++ b/src/peggedData/peggedData.ts @@ -2656,4 +2656,24 @@ export default [ twitter: "https://twitter.com/MountainUSDM", wiki: "https://docs.mountainprotocol.com/reference/usdm-token", }, +{ + id: "133", + name: "NARS", + address: "0x65517425ac3ce259a34400bb67ceb39ff3ddc0bd", + symbol: "NARS", + url: "https://num.finance/stablecoins", + description: + "Seamlessly scale your financial operations globally.On Ramps, Loans and Yields.", + mintRedeemDescription: + "Num-S are collateralized stablecoins, minted and issued by Num Finance.", + onCoinGecko: "true", + gecko_id: "num-ars", + cmcId: null, + pegType: "peggedARS", + pegMechanism: "fiat-backed", + priceSource: "coingecko", + auditLinks: null, + twitter: "https://twitter.com/Num_Finance", + wiki: "https://num.finance/transparency", +}, ] as PeggedAsset[]; diff --git a/src/peggedData/types.ts b/src/peggedData/types.ts index 936b786b..b6334157 100644 --- a/src/peggedData/types.ts +++ b/src/peggedData/types.ts @@ -3,9 +3,10 @@ type PegType = | "peggedVAR" | "peggedEUR" | "peggedSGD" - | "peggedJPY" - | "peggedCNY" - "peggedUAH"; + | "peggedJPY" //japan + | "peggedCNY" //china + "peggedUAH" //ukraine + "peggedARS" //ARGENTINE type PegMechanism = "algorithmic" | "fiat-backed" | "crypto-backed"; export type PriceSource =