diff --git a/.changeset/yellow-cups-talk.md b/.changeset/yellow-cups-talk.md new file mode 100644 index 0000000..9f09352 --- /dev/null +++ b/.changeset/yellow-cups-talk.md @@ -0,0 +1,5 @@ +--- +"@shadeprotocol/shadejs": patch +--- + +rectified the feature with the contract diff --git a/src/contracts/services/moneyMarket.ts b/src/contracts/services/moneyMarket.ts index 36010f8..e30bc4c 100644 --- a/src/contracts/services/moneyMarket.ts +++ b/src/contracts/services/moneyMarket.ts @@ -29,45 +29,44 @@ import { msgQueryMoneyMarketCollaterals, msgQueryMoneyMarketConfig, msgQueryMone const parseMoneyMarketGetMarkets = ( response: GetMarketsResponse, ): ParsedGetMarketsResponse => ({ - page: response.paginated_response.page, - pageSize: response.paginated_response.page_size, - totalPages: response.paginated_response.total_pages, - totalItems: response.paginated_response.total_items, - data: response.paginated_response.data.reduce((prev, cur) => ({ + page: response.page, + pageSize: response.page_size, + totalPages: response.total_pages, + totalItems: response.total_items, + data: response.data.reduce((prev, cur) => ({ ...prev, - [cur.market.market_token.address]: { + [cur.market_token.address]: { marketToken: { - contractAddress: cur.market.market_token.address, - codeHash: cur.market.market_token.code_hash, + contractAddress: cur.market_token.address, + codeHash: cur.market_token.code_hash, }, lToken: { - contractAddress: cur.market.l_token.address, - codeHash: cur.market.l_token.address, + contractAddress: cur.l_token.address, + codeHash: cur.l_token.address, }, - decimals: cur.market.decimals, - oracleKey: cur.market.oracle_key, + decimals: cur.decimals, + oracleKey: cur.oracle_key, interest: { - base: cur.market.interest.inner.interest.linear?.base - ?? cur.market.interest.inner.interest.piecewise_linear!.base, - slope1: cur.market.interest.inner.interest.linear?.slope - ?? cur.market.interest.inner.interest.piecewise_linear!.slope1, - slope2: cur.market.interest.inner.interest.piecewise_linear?.slope2, + base: cur.interest.base, + slope1: cur.interest.slope1, + slope2: cur.interest.slope2, optimalUtilisation: - cur.market.interest.inner.interest.piecewise_linear?.optimal_utilisation, + cur.interest.optimal_utilisation, }, - loanableAmount: cur.market.loanable, - lentAmount: cur.market.lent_amount, - lifetimeInterestPaid: cur.market.lifetime_interest_paid, - lifetimeInterestOwed: cur.market.lifetime_interest_owed, - interestPerUtoken: cur.market.interest_per_utoken, - lastInterestAccrued: new Date(cur.market.last_interest_accrued), - maxSupplyAmount: cur.market.max_supply, - flashLoanInterest: cur.market.flash_loan_interest, - supplyEnabled: cur.market.status.market_status.supply_enabled, - borrowEnabled: cur.market.status.market_status.borrow_enabled, - repayEnabled: cur.market.status.market_status.repay_enabled, - liquidationEnabled: cur.market.status.market_status.liquidation_enabled, - interestAccrualEnabled: cur.market.status.market_status.interest_accrual_enabled, + loanableAmount: cur.loanable, + lentAmount: cur.lent_amount, + lifetimeInterestPaid: cur.lifetime_interest_paid, + lifetimeInterestOwed: cur.lifetime_interest_owed, + interestPerUtoken: cur.interest_per_utoken, + lastInterestAccrued: new Date(cur.last_interest_accrued), + maxSupplyAmount: cur.max_supply, + daoInterestFee: cur.dao_interest_fee, + flashLoanInterest: cur.flash_loan_interest, + supplyEnabled: cur.status.supply_enabled, + borrowEnabled: cur.status.borrow_enabled, + repayEnabled: cur.status.repay_enabled, + liquidationEnabled: cur.status.liquidation_enabled, + interestAccrualEnabled: cur.status.interest_accrual_enabled, }, }), {}), }); @@ -80,27 +79,27 @@ const parseMoneyMarketConfig = ( response: ConfigResponse, ):ParsedConfigResponse => ({ adminAuth: { - contractAddress: response.config.admin_auth.address, - codeHash: response.config.admin_auth.code_hash, + contractAddress: response.admin_auth.address, + codeHash: response.admin_auth.code_hash, }, queryAuth: { - contractAddress: response.config.query_auth.address, - codeHash: response.config.query_auth.code_hash, + contractAddress: response.query_auth.address, + codeHash: response.query_auth.code_hash, }, oracle: { - contractAddress: response.config.oracle.address, - codeHash: response.config.query_auth.code_hash, + contractAddress: response.oracle.address, + codeHash: response.query_auth.code_hash, }, - feeCollector: response.config.fee_collector, - lTokenId: response.config.l_token_id, - lTokenCodeHash: response.config.l_token_code_hash, - lTokenBlockchainAdmin: response.config.l_token_blockchain_admin, - supplyEnabled: response.config.status.global_status.supply_enabled, - borrowEnabled: response.config.status.global_status.borrow_enabled, - repayEnabled: response.config.status.global_status.repay_enabled, - liquidationEnabled: response.config.status.global_status.liquidation_enabled, - interestAccrualEnabled: response.config.status.global_status.interest_accrual_enabled, - collateralDepositEnabled: response.config.status.global_status.collateral_deposit_enabled, + feeCollector: response.fee_collector, + lTokenId: response.l_token_id, + lTokenCodeHash: response.l_token_code_hash, + lTokenBlockchainAdmin: response.l_token_blockchain_admin, + supplyEnabled: response.status.supply_enabled, + borrowEnabled: response.status.borrow_enabled, + repayEnabled: response.status.repay_enabled, + liquidationEnabled: response.status.liquidation_enabled, + interestAccrualEnabled: response.status.interest_accrual_enabled, + collateralDepositEnabled: response.status.collateral_deposit_enabled, }); /** @@ -110,25 +109,25 @@ const parseMoneyMarketConfig = ( const parseMoneyMarketGetCollateral = ( response: GetCollateralResponse, ): ParsedGetCollateralResponse => ({ - page: response.paginated_response.page, - pageSize: response.paginated_response.page_size, - totalPages: response.paginated_response.total_pages, - totalItems: response.paginated_response.total_items, - data: response.paginated_response.data.reduce((prev, cur) => ({ + page: response.page, + pageSize: response.page_size, + totalPages: response.total_pages, + totalItems: response.total_items, + data: response.data.reduce((prev, cur) => ({ ...prev, - [cur.collateral_state.token.address]: { + [cur.token.address]: { token: { - contractAddress: cur.collateral_state.token.address, - codeHash: cur.collateral_state.token.code_hash, + contractAddress: cur.token.address, + codeHash: cur.token.code_hash, }, - collateralAmount: cur.collateral_state.amount, - decimals: cur.collateral_state.decimals, - maxInitialLtv: cur.collateral_state.max_initial_ltv, - liquidationThreshold: cur.collateral_state.liquidation_threshold, - liquidationDiscount: cur.collateral_state.liquidation_discount, - oracleKey: cur.collateral_state.oracle_key, - depositEnabled: cur.collateral_state.status.collateral_status.deposit_enabled, - liquidationEnabled: cur.collateral_state.status.collateral_status.liquidation_enabled, + collateralAmount: cur.amount, + decimals: cur.decimals, + maxInitialLtv: cur.max_initial_ltv, + liquidationThreshold: cur.liquidation_threshold, + liquidationDiscount: cur.liquidation_discount, + oracleKey: cur.oracle_key, + depositEnabled: cur.status.deposit_enabled, + liquidationEnabled: cur.status.liquidations_enabled, }, }), {}), }); @@ -577,6 +576,9 @@ export { queryMoneyMarketConfig, queryMoneyMarketGetMarkets, queryMoneyMarketGetCollateral, + batchQueryMoneyMarketConfig$, + batchQueryMoneyMarketGetMarkets$, + batchQueryMoneyMarketGetCollateral$, batchQueryMoneyMarketConfig, batchQueryMoneyMarketGetMarkets, batchQueryMoneyMarketGetCollateral, diff --git a/src/types/contracts/moneyMarket/model.ts b/src/types/contracts/moneyMarket/model.ts index 18f6c5c..1d3f569 100644 --- a/src/types/contracts/moneyMarket/model.ts +++ b/src/types/contracts/moneyMarket/model.ts @@ -75,6 +75,7 @@ type ParsedMarketResponse = { interestPerUtoken: string, lastInterestAccrued: Date, maxSupplyAmount: string, + daoInterestFee: string, flashLoanInterest: string, supplyEnabled: boolean, borrowEnabled: boolean, diff --git a/src/types/contracts/moneyMarket/response.ts b/src/types/contracts/moneyMarket/response.ts index 8eec99c..107fd0b 100644 --- a/src/types/contracts/moneyMarket/response.ts +++ b/src/types/contracts/moneyMarket/response.ts @@ -1,46 +1,39 @@ type ConfigResponse = { - config: { - admin_auth: { - address: string, - code_hash: string, - } - query_auth: { - address: string, - code_hash: string, - } - oracle: { - address: string, - code_hash: string, - } - fee_collector: string, - l_token_id: number, - l_token_code_hash: string, - l_token_blockchain_admin: string, - status: { - global_status: { - supply_enabled: boolean, - borrow_enabled: boolean, - repay_enabled: boolean, - liquidation_enabled: boolean, - interest_accrual_enabled: boolean, - collateral_deposit_enabled: boolean, - } - } + admin_auth: { + address: string, + code_hash: string, + } + query_auth: { + address: string, + code_hash: string, + } + oracle: { + address: string, + code_hash: string, + } + fee_collector: string, + l_token_id: number, + l_token_code_hash: string, + l_token_blockchain_admin: string, + status: { + supply_enabled: boolean, + borrow_enabled: boolean, + repay_enabled: boolean, + liquidation_enabled: boolean, + interest_accrual_enabled: boolean, + collateral_deposit_enabled: boolean, } } type PaginatedResponse = { - paginated_response: { - page: number, - page_size: number, - total_pages: number, - total_items: number, - data: T[] - } + page: number, + page_size: number, + total_pages: number, + total_items: number, + data: T[] } type MarketReponse = { - market: { market_token: { address: string, code_hash: string, @@ -52,21 +45,11 @@ type MarketReponse = { decimals: number, oracle_key: string, interest: { - inner: { - interest: { - linear?: { - base: string, - slope: string, - }, - piecewise_linear?: { - base: string, - slope1: string, - slope2: string, - optimal_utilisation: string, - } - } - } - } + base: string, + slope1: string, + slope2: string, + optimal_utilisation: string, + }, loanable: string, lent_amount: string, lifetime_interest_paid: string, @@ -74,39 +57,33 @@ type MarketReponse = { interest_per_utoken: string, last_interest_accrued: number, max_supply: string, + dao_interest_fee: string, flash_loan_interest: string, status: { - market_status: { supply_enabled: boolean, borrow_enabled: boolean, repay_enabled: boolean, liquidation_enabled: boolean, interest_accrual_enabled: boolean, - } } - } } type GetMarketsResponse = PaginatedResponse; type CollateralReponse = { - collateral_state: { - token: { - address: string, - code_hash: string, - }, - amount: string, - decimals: number, - max_initial_ltv: string, - liquidation_threshold: string, - liquidation_discount: string, - oracle_key: string, - status: { - collateral_status: { - deposit_enabled: boolean, - liquidation_enabled: boolean, - } - } + token: { + address: string, + code_hash: string, + }, + amount: string, + decimals: number, + max_initial_ltv: string, + liquidation_threshold: string, + liquidation_discount: string, + oracle_key: string, + status: { + deposit_enabled: boolean, + liquidations_enabled: boolean, } }