Skip to content

Commit

Permalink
add nars + ARS argentina peso support
Browse files Browse the repository at this point in the history
  • Loading branch information
Define101 committed Oct 6, 2023
1 parent 9f10094 commit 41c42c4
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/adapters/peggedAssets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
};
87 changes: 87 additions & 0 deletions src/adapters/peggedAssets/nars/index.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/adapters/peggedAssets/peggedAsset.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
20 changes: 20 additions & 0 deletions src/peggedData/peggedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
7 changes: 4 additions & 3 deletions src/peggedData/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 41c42c4

Please sign in to comment.