Skip to content

Commit

Permalink
export mantle
Browse files Browse the repository at this point in the history
  • Loading branch information
realdealshaman committed Nov 3, 2023
1 parent 9db3d0d commit 03f22c8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/adapters/peggedAssets/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,6 @@
"comdex",
"polygon_zkevm",
"base",
"linea"
"linea",
"mantle"
]
57 changes: 47 additions & 10 deletions src/adapters/peggedAssets/ondo-us-dollar-yield/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@ import {
Balances,
} from "../peggedAsset.type";


type ChainContracts = {
[chain: string]: {
[contract: string]: string[];
issued: string;
unreleased: string[];
};
};

const chainContracts: ChainContracts = {
ethereum: {
issued: ["0x96F6eF951840721AdBF46Ac996b59E0235CB985C"],
issued: "0x96F6eF951840721AdBF46Ac996b59E0235CB985C",
unreleased: []
},
polygon: {
issued: ["0x96F6eF951840721AdBF46Ac996b59E0235CB985C"],
issued: "0x96F6eF951840721AdBF46Ac996b59E0235CB985C",
unreleased: []
},
mantle: {
issued: ["0x5bE26527e817998A7206475496fDE1E68957c5A6"],
issued: "0x5bE26527e817998A7206475496fDE1E68957c5A6",
unreleased: ["0x94FEC56BBEcEaCC71c9e61623ACE9F8e1B1cf473"]
},
};

Expand All @@ -32,27 +37,55 @@ async function chainMinted(chain: string, decimals: number) {
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
for (let issued of chainContracts[chain].issued) {
const totalSupply = (
const totalSupply = (
await sdk.api.abi.call({
abi: "erc20:totalSupply",
target: chainContracts[chain].issued,
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(
balances,
"peggedUSD",
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:totalSupply",
target: issued,
abi: "erc20:balanceOf",
target: chainContracts[chain].issued,
params: [unreleased],
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** decimals,
"issued",
unreleasedBalance / 10 ** decimals,
"unreleased",
false
);
}
return balances;
};
}


const adapter: PeggedIssuanceAdapter = {
ethereum: {
minted: chainMinted("ethereum", 18),
Expand All @@ -62,6 +95,10 @@ const adapter: PeggedIssuanceAdapter = {
minted: chainMinted("polygon", 18),
unreleased: async () => ({}),
},
mantle: {
minted: chainMinted("mantle", 18),
unreleased: chainUnreleased("mantle", 18),
},
};

export default adapter;

0 comments on commit 03f22c8

Please sign in to comment.