Skip to content

Commit

Permalink
feat: functions working, should add types
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPresident committed Nov 19, 2024
1 parent 3cdb253 commit 45d2e27
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
41 changes: 22 additions & 19 deletions src/contracts/services/moneyMarket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
BatchMoneyMarketGetMarkets,
ContractAndPagination,
Pagination, ParsedConfigResponse, ParsedGetCollateralResponse, ParsedGetMarketsResponse,
RewardPool, PaginatedRewardPools,
} from '~/types/contracts/moneyMarket/model';
import { Contract } from '~/types/contracts/shared/index';
import {
Expand Down Expand Up @@ -124,7 +123,8 @@ const parseMoneyMarketGetCollateral = (
collateralAmount: cur.amount,
decimals: cur.decimals,
maxInitialLtv: cur.max_initial_ltv,
liquidationThreshold: cur.liquidation_threshold,
publicLiquidationThreshold: cur.public_liquidation_threshold,
privateLiquidationThreshold: cur.private_liquidation_threshold,
liquidationDiscount: cur.liquidation_discount,
oracleKey: cur.oracle_key,
depositEnabled: cur.status.deposit_enabled,
Expand Down Expand Up @@ -729,23 +729,20 @@ async function batchQueryMoneyMarketPublicLogs({
}));
}

const parseBatchQueryMoneyMarketRewardPools = (response: any): PaginatedRewardPools => ({
page: response.page,
pageSize: response.page_size,
totalPages: response.total_pages,
totalItems: response.total_items,
debtMarket: response.id,
blockHeight: response.blockHeight,
data: response.data ? response.data.map((rewardPool: RewardPool) => ({
id: rewardPool.id,
amount: rewardPool.amount,
token: rewardPool.token,
start: rewardPool.start,
end: rewardPool.end,
rate: rewardPool.rate,
const parseBatchQueryMoneyMarketRewardPools = (responses: any) => (
responses.map((response: any) => ({
debtMarket: response.id,
blockHeight: response.blockHeight,
rewardPools: response.response.map((pool: any) => ({
rewardPoolId: pool.id,
amount: pool.amount,
token: pool.token,
start: pool.start,
end: pool.end,
rate: pool.rate,
})),
}))
: [],
});
);

function batchQueryMoneyMarketRewardPools$({
queryRouterContractAddress,
Expand Down Expand Up @@ -780,6 +777,7 @@ function batchQueryMoneyMarketRewardPools$({
},
},
}));
console.error('shadejs reward pools batch queries', queries);

Check warning on line 780 in src/contracts/services/moneyMarket.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

return batchQuery$({
contractAddress: queryRouterContractAddress,
Expand All @@ -791,7 +789,12 @@ function batchQueryMoneyMarketRewardPools$({
minBlockHeightValidationOptions,
blockHeight,
}).pipe(
map((response) => parseBatchQueryMoneyMarketRewardPools(response)),
map((response) => {
console.error('Parsing', JSON.stringify(response));

Check warning on line 793 in src/contracts/services/moneyMarket.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
const x = parseBatchQueryMoneyMarketRewardPools(response);
console.error('Parsed', JSON.stringify(x));

Check warning on line 795 in src/contracts/services/moneyMarket.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
return x;
}),
first(),
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/types/contracts/moneyMarket/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ type ParsedCollateralReponse = {
collateralAmount: string,
decimals: number,
maxInitialLtv: string,
liquidationThreshold: string,
publicLiquidationThreshold: string,
privateLiquidationThreshold: string,
liquidationDiscount: string,
oracleKey: string,
depositEnabled: boolean,
Expand Down
3 changes: 2 additions & 1 deletion src/types/contracts/moneyMarket/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ type CollateralReponse = {
amount: string,
decimals: number,
max_initial_ltv: string,
liquidation_threshold: string,
public_liquidation_threshold: string,
private_liquidation_threshold: string,
liquidation_discount: string,
oracle_key: string,
status: {
Expand Down

0 comments on commit 45d2e27

Please sign in to comment.