Skip to content

Commit

Permalink
Merge pull request #201 from Define101/master
Browse files Browse the repository at this point in the history
clear code (npm run format)
  • Loading branch information
Define101 authored Dec 17, 2023
2 parents cc5baf2 + 24cc572 commit 0df5531
Show file tree
Hide file tree
Showing 124 changed files with 2,415 additions and 2,033 deletions.
11 changes: 8 additions & 3 deletions src/adapters/peggedAssets/alchemix-usd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ChainContracts = {
const chainContracts: ChainContracts = {
ethereum: {
issued: ["0xbc6da0fe9ad5f3b0d58160288917aa56653660e9"],
unreleased: ["0x9735f7d3ea56b454b24ffd74c58e9bd85cfad31b"] // AMO
unreleased: ["0x9735f7d3ea56b454b24ffd74c58e9bd85cfad31b"], // AMO
},
arbitrum: {
bridgedFromETH: ["0x2130d2a1e51112D349cCF78D2a1EE65843ba36e0"], // multichain
Expand All @@ -25,7 +25,7 @@ const chainContracts: ChainContracts = {
bridgedFromETH: [
"0xb2c22A9fb4FC02eb9D1d337655Ce079a04a526C7", // multichain
"0xCB8FA9a76b8e203D8C3797bF438d8FB81Ea3326A", // also multichain?
],
],
},
fantom: {
bridgedFromETH: ["0xB67FA6deFCe4042070Eb1ae1511Dcd6dcc6a532E"], // has more than in multichain bridge contract
Expand Down Expand Up @@ -90,7 +90,12 @@ async function chainUnreleased(
const adapter: PeggedIssuanceAdapter = {
ethereum: {
minted: chainMinted("ethereum", 18),
unreleased: chainUnreleased("ethereum", 18, chainContracts.ethereum.issued[0], chainContracts.ethereum.unreleased)
unreleased: chainUnreleased(
"ethereum",
18,
chainContracts.ethereum.issued[0],
chainContracts.ethereum.unreleased
),
},
arbitrum: {
minted: async () => ({}),
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/peggedAssets/anchored-coins-eur/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function chainMinted(chain: string, decimals: number) {
sumSingleBalance(
balances,
"peggedEUR",
totalSupply / 10 ** decimals,
totalSupply / 10 ** decimals,
"issued",
false
);
Expand All @@ -57,7 +57,7 @@ const adapter: PeggedIssuanceAdapter = {
bsc: {
minted: chainMinted("bsc", 18),
unreleased: async () => ({}),
},
},
};

export default adapter;
export default adapter;
6 changes: 5 additions & 1 deletion src/adapters/peggedAssets/bacon-protocol-home/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const sdk = require("@defillama/sdk");
import { sumSingleBalance } from "../helper/generalUtil";
import { ChainBlocks, PeggedIssuanceAdapter, Balances } from "../peggedAsset.type";
import {
ChainBlocks,
PeggedIssuanceAdapter,
Balances,
} from "../peggedAsset.type";

const chainContracts = {
ethereum: {
Expand Down
12 changes: 9 additions & 3 deletions src/adapters/peggedAssets/bank-of-chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type ChainContracts = {

const chainContracts: ChainContracts = {
ethereum: {
issued: ["0x83131242843257bc6C43771762ba467346Efb2CF"],//USDi
}
issued: ["0x83131242843257bc6C43771762ba467346Efb2CF"], //USDi
},
};

async function chainMinted(chain: string, decimals: number) {
Expand All @@ -34,7 +34,13 @@ async function chainMinted(chain: string, decimals: number) {
chain: chain,
})
).output;
sumSingleBalance(balances, "peggedUSD", totalSupply / 10 ** decimals, "issued", false);
sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** decimals,
"issued",
false
);
}
return balances;
};
Expand Down
10 changes: 8 additions & 2 deletions src/adapters/peggedAssets/baousd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ async function chainMinted(chain: string) {
chain: chain,
})
).output;
sumSingleBalance(balances, "peggedUSD", totalSupply / 10 ** 18, "issued", false);
sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** 18,
"issued",
false
);
}
return balances;
};
Expand All @@ -47,4 +53,4 @@ const adapter: PeggedIssuanceAdapter = {
},
};

export default adapter;
export default adapter;
62 changes: 37 additions & 25 deletions src/adapters/peggedAssets/binance-usd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ const chainContracts: ChainContracts = {
bridgedFromBSC: ["0xBEB0131D95AC3F03fd15894D0aDE5DBf7451d171"],
},
osmosis: {
bridgedFromETH: ["ibc/6329DD8CF31A334DD5BE3F68C846C9FE313281362B37686A62343BAC1EB1546D"],
}
bridgedFromETH: [
"ibc/6329DD8CF31A334DD5BE3F68C846C9FE313281362B37686A62343BAC1EB1546D",
],
},
};

/*
Expand Down Expand Up @@ -297,21 +299,21 @@ async function chainUnreleased(chain: string, decimals: number) {
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
const reserve = (
await sdk.api.erc20.balanceOf({
target: chainContracts[chain].issued[0],
owner: chainContracts[chain].reserves[0],
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(
balances,
"peggedUSD",
reserve / 10 ** decimals,
"issued",
false
);
const reserve = (
await sdk.api.erc20.balanceOf({
target: chainContracts[chain].issued[0],
owner: chainContracts[chain].reserves[0],
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(
balances,
"peggedUSD",
reserve / 10 ** decimals,
"issued",
false
);
return balances;
};
}
Expand Down Expand Up @@ -451,9 +453,7 @@ const adapter: PeggedIssuanceAdapter = {
minted: async () => ({}),
unreleased: async () => ({}),
bsc: sumMultipleBalanceFunctions(
[
bridgedSupply("metis", 18, chainContracts.metis.bridgedFromBSC),
],
[bridgedSupply("metis", 18, chainContracts.metis.bridgedFromBSC)],
"peggedUSD"
),
},
Expand Down Expand Up @@ -486,7 +486,7 @@ const adapter: PeggedIssuanceAdapter = {
kava: {
minted: async () => ({}),
unreleased: async () => ({}),
bsc: kavaMinted(chainContracts.kava.bridgeOnBNB),
bsc: kavaMinted(chainContracts.kava.bridgeOnBNB),
},
loopring: {
minted: async () => ({}),
Expand Down Expand Up @@ -528,14 +528,26 @@ const adapter: PeggedIssuanceAdapter = {
thundercore: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupply("thundercore", 18, chainContracts.thundercore.bridgedFromETH),
bsc: bridgedSupply("thundercore", 18, chainContracts.thundercore.bridgedFromBSC),
ethereum: bridgedSupply(
"thundercore",
18,
chainContracts.thundercore.bridgedFromETH
),
bsc: bridgedSupply(
"thundercore",
18,
chainContracts.thundercore.bridgedFromBSC
),
},
osmosis: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: osmosisSupply(chainContracts.osmosis.bridgedFromETH, 18, "Axelar"),
}
ethereum: osmosisSupply(
chainContracts.osmosis.bridgedFromETH,
18,
"Axelar"
),
},
};

export default adapter;
9 changes: 5 additions & 4 deletions src/adapters/peggedAssets/bob/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async function getChainCollateralUsdValue(chain: string) {
) {
let balances = {} as Balances;
const uniPools = uniPoolsMapping[chain];
let tokenBalances = {} as {[token: string]: number};
let tokenBalances = {} as { [token: string]: number };
await Promise.all(
Object.entries(uniPools).map(async ([pool, token]) => {
const balance = await returnBalance(
Expand All @@ -101,7 +101,8 @@ async function getChainCollateralUsdValue(chain: string) {
_chainBlocks?.[chain],
chain
);
tokenBalances[`${chain}:${token}`] = (tokenBalances[`${chain}:${token}`] ?? 0) + balance;
tokenBalances[`${chain}:${token}`] =
(tokenBalances[`${chain}:${token}`] ?? 0) + balance;
})
);
const tokens = Object.keys(tokenBalances);
Expand All @@ -111,9 +112,9 @@ async function getChainCollateralUsdValue(chain: string) {
)
).data.coins;
Object.entries(tokenBalances).map(([token, balance]) => {
const usdValue = balance * (prices[token]?.price ?? 0)
const usdValue = balance * (prices[token]?.price ?? 0);
sumSingleBalance(balances, "peggedUSD", usdValue, "issued", false);
})
});
return balances;
};
}
Expand Down
30 changes: 15 additions & 15 deletions src/adapters/peggedAssets/cadc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ async function chainUnreleased(chain: string, decimals: number) {
}

const adapter: PeggedIssuanceAdapter = {
ethereum: {
minted: chainMinted("ethereum", 18),
unreleased: async () => ({}),
},
polygon: {
minted: chainMinted("polygon", 18),
unreleased: async () => ({}),
},
arbitrum: {
minted: chainMinted("arbitrum", 18),
unreleased: async () => ({}),
},
};
export default adapter;
ethereum: {
minted: chainMinted("ethereum", 18),
unreleased: async () => ({}),
},
polygon: {
minted: chainMinted("polygon", 18),
unreleased: async () => ({}),
},
arbitrum: {
minted: chainMinted("arbitrum", 18),
unreleased: async () => ({}),
},
};

export default adapter;
2 changes: 1 addition & 1 deletion src/adapters/peggedAssets/celo-dollar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const adapter: PeggedIssuanceAdapter = {
solana: {
minted: async () => ({}),
unreleased: async () => ({}),
celo: solanaMintedOrBridged(chainContracts.solana.bridgedFromCelo)
celo: solanaMintedOrBridged(chainContracts.solana.bridgedFromCelo),
},
klaytn: {
minted: async () => ({}),
Expand Down
10 changes: 8 additions & 2 deletions src/adapters/peggedAssets/clever-usd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ async function chainMinted(chain: string) {
chain: chain,
})
).output;
sumSingleBalance(balances, "peggedUSD", totalSupply / 10 ** 18, "issued", false);
sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** 18,
"issued",
false
);
}
return balances;
};
Expand All @@ -47,4 +53,4 @@ const adapter: PeggedIssuanceAdapter = {
},
};

export default adapter;
export default adapter;
22 changes: 11 additions & 11 deletions src/adapters/peggedAssets/coin98-dollar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const sdk = require("@defillama/sdk");
import {
ChainBlocks,
PeggedIssuanceAdapter,
Balances
Balances,
} from "../peggedAsset.type";
import { sumSingleBalance } from "../helper/generalUtil";
import { solanaMintedOrBridged } from "../helper/getSupply";
Expand All @@ -14,15 +14,15 @@ type ChainContracts = {
};

const chainContracts: ChainContracts = {
ethereum: {
issued: ["0xC285B7E09A4584D027E5BC36571785B515898246"],
},
bsc: {
issued: ["0xFa4BA88Cf97e282c505BEa095297786c16070129"],
},
solana: {
issued: ["CUSDvqAQLbt7fRofcmV2EXfPA2t36kzj7FjzdmqDiNQL"],
}
ethereum: {
issued: ["0xC285B7E09A4584D027E5BC36571785B515898246"],
},
bsc: {
issued: ["0xFa4BA88Cf97e282c505BEa095297786c16070129"],
},
solana: {
issued: ["CUSDvqAQLbt7fRofcmV2EXfPA2t36kzj7FjzdmqDiNQL"],
},
};

async function chainMinted(chain: string, decimals: number) {
Expand Down Expand Up @@ -68,4 +68,4 @@ const adapter: PeggedIssuanceAdapter = {
},
};

export default adapter;
export default adapter;
14 changes: 10 additions & 4 deletions src/adapters/peggedAssets/composite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type ChainContracts = {

const chainContracts: ChainContracts = {
osmosis: {
bridgedFromComdex: ["ibc/23CA6C8D1AB2145DD13EB1E089A2E3F960DC298B468CCE034E19E5A78B61136E"],
bridgedFromComdex: [
"ibc/23CA6C8D1AB2145DD13EB1E089A2E3F960DC298B468CCE034E19E5A78B61136E",
],
},
};

Expand All @@ -33,7 +35,7 @@ async function compositeMinted(decimals: number) {
"https://rest.comdex.one/cosmos/bank/v1beta1/supply/ucmst"
)
);

const supply = res?.data?.amount?.amount / 10 ** decimals;
sumSingleBalance(balances, "peggedUSD", supply, "issued", false);
return balances;
Expand All @@ -48,8 +50,12 @@ const adapter: PeggedIssuanceAdapter = {
osmosis: {
minted: async () => ({}),
unreleased: async () => ({}),
comdex: osmosisSupply(chainContracts.osmosis.bridgedFromComdex, 6, "Comdex"),
}
comdex: osmosisSupply(
chainContracts.osmosis.bridgedFromComdex,
6,
"Comdex"
),
},
};

export default adapter;
Loading

0 comments on commit 0df5531

Please sign in to comment.