Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
realdealshaman committed Jan 7, 2025
1 parent 325a471 commit 99ebbf7
Showing 1 changed file with 2 additions and 66 deletions.
68 changes: 2 additions & 66 deletions src/adapters/peggedAssets/dtrinity-usd/index.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,9 @@
const sdk = require("@defillama/sdk");
import { sumSingleBalance } from "../helper/generalUtil";
import {
Balances,
ChainBlocks,
PeggedIssuanceAdapter,
} from "../peggedAsset.type";

const chainContracts = {
fraxtal: {
issued: "0x788D96f655735f52c676A133f4dFC53cEC614d4A",
amoManager: "0x49a0c8030Ca199f6F246517aE689E3cC0775271a",
issuer: "0x1ec13EF0b22C53298A00b23b03203E03D999b7a2",
},
};

async function dUSDMinted(chain: string, decimals: number) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks,
) {
let balances = {} as Balances;
const circulatingSupply = (
await sdk.api.abi.call({
abi: {
inputs: [],
name: "circulatingDusd",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
target: chainContracts[chain as keyof typeof chainContracts].issuer,
chain: chain,
block: _chainBlocks?.[chain],
})
).output;

const amoSupply = (
await sdk.api.abi.call({
abi: {
inputs: [],
name: "totalAmoSupply",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
target: chainContracts[chain as keyof typeof chainContracts].amoManager,
chain: chain,
block: _chainBlocks?.[chain],
})
).output;


sumSingleBalance(
balances,
"peggedUSD",
Number((BigInt(circulatingSupply) + BigInt(amoSupply))/ BigInt(10 ** decimals)),
"issued",
false,
);

return balances;
};
}

const adapter: PeggedIssuanceAdapter = {
fraxtal: {
minted: dUSDMinted("fraxtal", 6),
},
};

import { addChainExports } from "../helper/getSupply";
const adapter = addChainExports(chainContracts);
export default adapter;

0 comments on commit 99ebbf7

Please sign in to comment.