Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Nov 20, 2024
1 parent 5012176 commit 496e614
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/adapters/peggedAssets/gyen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function gmoAPIChainMinted(chain: string) {
const filteredChainsData = await gyenData[0].chains.filter(
(obj: any) => obj.chain === chain
);
const supply = parseInt(filteredChainsData[0].amount);
const supply = parseInt(filteredChainsData[0].amount ?? 0);
sumSingleBalance(balances, "peggedJPY", supply, "issued", false);

return balances;
Expand Down
25 changes: 13 additions & 12 deletions src/adapters/peggedAssets/helper/starknet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
validateAndParseAddress,
number,
hash,
uint256,
CallData,
} = require("starknet");
const axios = require("axios");
const plimit = require("p-limit");
Expand Down Expand Up @@ -48,21 +48,22 @@ function formCallBody(
}

function parseOutput(result, abi, allAbi) {
const contract = new Contract([abi, ...allAbi], null, null);
let response = contract.parseResponse(abi.name, result);
if (abi.outputs.length === 1) {
response = response[0];
if (abi.outputs[0].type === "Uint256") return response;
let response = new CallData([abi, ...allAbi]).parse(abi.name, result)
// convert BigInt to string
for (const key in response) {
if (typeof response[key] === 'bigint') response[key] = response[key].toString()
}

if (abi.outputs.length === 1 && !abi.outputs[0].type.includes('::')) {
response = response[abi.outputs[0].name]
if (abi.outputs[0].type === 'Uint256') return +response
switch (abi.customType) {
case "address":
return validateAndParseAddress(response);
case "Uint256":
return response;
case 'address': return validateAndParseAddress(response)
case 'Uint256': return +response
}
}
return response;
return response
}

async function call({ abi, target, params = [], allAbi = [] } = {}, ...rest) {
const {
data: { result },
Expand Down
7 changes: 3 additions & 4 deletions src/adapters/peggedAssets/nostra-uno/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ async function chainMinted(chain: string, decimals: number) {
target: issued,
abi: starknetTotalSupplyAbi,
params: [],
},
_chainBlocks?.[chain]
}
);
} else {
totalSupply = (
Expand All @@ -51,7 +50,7 @@ async function chainMinted(chain: string, decimals: number) {
sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** decimals,
totalSupply.toString() / 10 ** decimals,
"issued",
false
);
Expand Down Expand Up @@ -90,7 +89,7 @@ async function chainUnreleased(chain: string, decimals: number) {
sumSingleBalance(
balances,
"peggedUSD",
unreleased / 10 ** decimals,
unreleased.toString() / 10 ** decimals,
"issued",
false
);
Expand Down
21 changes: 4 additions & 17 deletions src/adapters/peggedAssets/opus-cash/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,16 @@ const chainContracts = {
},
};

async function starknetMinted(chain: string, decimals: number) {
return async function (
async function starknetMinted(_chain: string, decimals: number) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
const totalSupply = await call(
{
target: chainContracts.starknet.issued,
abi: starknetTotalSupplyAbi,
params: [],
},
_chainBlocks?.[chain]
);
const totalSupply = await call({ target: chainContracts.starknet.issued, abi: starknetTotalSupplyAbi, });

sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** decimals,
"issued",
false,
);
sumSingleBalance(balances, "peggedUSD", totalSupply.toString() / 10 ** decimals, "issued", false,);

return balances;
};
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/peggedAssets/terrausd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const adapter: PeggedIssuanceAdapter = {
// hardcoded value as zero since it is no longer a stablecoin
Object.keys(adapter).forEach((chain) => {
Object.keys(adapter[chain]).forEach((key) => {
adapter[chain][key] = () => {}
adapter[chain][key] = () => ({})
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/peggedAssets/zusd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function gmoAPIChainMinted(chain: string) {
const filteredChainsData = await gyenData[0].chains.filter(
(obj: any) => obj.chain === chain
);
const supply = parseInt(filteredChainsData[0].amount);
const supply = parseInt(filteredChainsData[0].amount ?? 0);
sumSingleBalance(balances, "peggedUSD", supply, "issued", false);
return balances;
};
Expand Down
2 changes: 1 addition & 1 deletion src/peggedData/peggedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3686,7 +3686,7 @@ export default [
onCoinGecko: "true",
gecko_id: "bitcoin-usd-btcfi",
cmcId: null,
pegType: "peggedVAR",
pegType: "peggedUSD",
pegMechanism: "crypto-backed",
priceSource: "defillama",
auditLinks: null,
Expand Down

0 comments on commit 496e614

Please sign in to comment.