Skip to content

Commit

Permalink
Merge pull request #158 from iamvukasin/master
Browse files Browse the repository at this point in the history
Ignore deadlocked R tokens
  • Loading branch information
Define101 authored Oct 17, 2023
2 parents 80dc0c1 + 29de3ed commit fbfb9fa
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/adapters/peggedAssets/r/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import {

type ChainContracts = {
[chain: string]: {
[contract: string]: string[];
issued: string[];
ignored?: string[]; // ignored addresses which have deadlock tokens
};
};

const chainContracts: ChainContracts = {
ethereum: {
issued: ["0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21"],
ignored: ["0x2ba26baE6dF1153e29813d7f926143f9c94402f3"],
},
base: {
issued: ["0xafb2820316e7bc5ef78d295ab9b8bb2257534576"],
Expand All @@ -28,15 +30,31 @@ async function chainMinted(chain: string, decimals: number) {
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
for (let issued of chainContracts[chain].issued) {
const totalSupply = (
const { issued: issuedAddresses, ignored: ignoredAddresses = [] } =
chainContracts[chain];
for (let issued of issuedAddresses) {
let totalSupply = (
await sdk.api.abi.call({
abi: "erc20:totalSupply",
target: issued,
block: _chainBlocks?.[chain],
chain: chain,
})
).output;

for (let ignored of ignoredAddresses) {
const ignoredBalance = (
await sdk.api.abi.call({
abi: "erc20:balanceOf",
target: issued,
params: ignored,
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
totalSupply -= ignoredBalance;
}

sumSingleBalance(
balances,
"peggedUSD",
Expand All @@ -60,4 +78,4 @@ const adapter: PeggedIssuanceAdapter = {
},
};

export default adapter;
export default adapter;

0 comments on commit fbfb9fa

Please sign in to comment.