Skip to content

Commit

Permalink
refactor: rename decimal field to coinDecimal in market pools and col…
Browse files Browse the repository at this point in the history
…laterals
  • Loading branch information
mr-donor committed Oct 2, 2023
1 parent 38bd69c commit 5716107
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/queries/coreQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const queryMarket = async (query: ScallopQuery) => {
coinType: coinType,
marketCoinType: query.utils.parseMarketCoinType(coinName),
coinWrappedType: query.utils.getCoinWrappedType(coinName),
decimal: query.utils.getCoinDecimal(coinName),
coinDecimal: query.utils.getCoinDecimal(coinName),
coinPrice: coinPrice,
...calculatedMarketPoolData,
});
Expand Down Expand Up @@ -122,7 +122,7 @@ export const queryMarket = async (query: ScallopQuery) => {
coinType: coinType,
marketCoinType: query.utils.parseMarketCoinType(coinName),
coinWrappedType: query.utils.getCoinWrappedType(coinName),
decimal: query.utils.getCoinDecimal(coinName),
coinDecimal: query.utils.getCoinDecimal(coinName),
coinPrice: coinPrice,
...parsedMarketCollateralData,
});
Expand Down Expand Up @@ -323,7 +323,7 @@ export const getMarketPool = async (
coinType: query.utils.parseCoinType(coinName),
marketCoinType: query.utils.parseMarketCoinType(coinName),
coinWrappedType: query.utils.getCoinWrappedType(coinName),
decimal: query.utils.getCoinDecimal(coinName),
coinDecimal: query.utils.getCoinDecimal(coinName),
coinPrice: coinPrice ?? 0,
...calculatedMarketPoolData,
};
Expand Down Expand Up @@ -477,7 +477,7 @@ export const getMarketCollateral = async (
coinType: query.utils.parseCoinType(coinName),
marketCoinType: query.utils.parseMarketCoinType(coinName),
coinWrappedType: query.utils.getCoinWrappedType(coinName),
decimal: query.utils.getCoinDecimal(coinName),
coinDecimal: query.utils.getCoinDecimal(coinName),
coinPrice: coinPrice ?? 0,
...parsedMarketCollateralData,
};
Expand Down Expand Up @@ -617,7 +617,6 @@ export const getCoinAmounts = async (
const type = coinObject.type as string;
if (coinObject.content && 'fields' in coinObject.content) {
const fields = coinObject.content.fields as any;
console.log(type);
const coinName = query.utils.parseCoinName(type);
if (coinName) {
coins[coinName] = BigNumber(coins[coinName] ?? 0)
Expand Down
4 changes: 2 additions & 2 deletions src/types/query/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export type MarketPool = {
coinType: string;
marketCoinType: string;
coinWrappedType: CoinWrappedType;
decimal: number;
coinDecimal: number;
coinPrice: number;
} & CalculatedMarketPoolData;

Expand All @@ -127,7 +127,7 @@ export type MarketCollateral = {
coinType: string;
marketCoinType: string;
coinWrappedType: CoinWrappedType;
decimal: number;
coinDecimal: number;
coinPrice: number;
} & ParsedMarketCollateralData;

Expand Down
6 changes: 6 additions & 0 deletions src/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export const calculateMarketPoolData = (
};
};

/**
* Parse origin market collateral data to a more readable format.
*
* @param originMarketCollateralData - Origin market collateral data
* @return Parsed market collateral data
*/
export const parseOriginMarketCollateralData = (
originMarketCollateralData: OriginMarketCollateralData
): ParsedMarketCollateralData => {
Expand Down

0 comments on commit 5716107

Please sign in to comment.