diff --git a/contracts/params/src/msg.rs b/contracts/params/src/msg.rs index 7f192d08d..d4fbd3177 100644 --- a/contracts/params/src/msg.rs +++ b/contracts/params/src/msg.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{Coin, Decimal}; +use cosmwasm_std::{Decimal, Uint128}; use mars_owner::OwnerUpdate; use crate::types::{asset::AssetParamsUnchecked, vault::VaultConfigUnchecked}; @@ -57,12 +57,19 @@ pub enum QueryMsg { /// Compute the total amount deposited of the given asset across Red Bank /// and Credit Manager. - #[returns(Coin)] + #[returns(TotalDepositResponse)] TotalDeposit { denom: String, }, } +#[cw_serde] +pub struct TotalDepositResponse { + pub denom: String, + pub cap: Uint128, + pub amount: Uint128, +} + #[cw_serde] pub enum AssetParamsUpdate { AddOrUpdate { diff --git a/contracts/params/src/query.rs b/contracts/params/src/query.rs index d7a5b8256..c5e53bd0d 100644 --- a/contracts/params/src/query.rs +++ b/contracts/params/src/query.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Addr, Coin, Deps, Env, Order, StdResult, Uint128}; +use cosmwasm_std::{Addr, Deps, Env, Order, StdResult, Uint128}; use cw_storage_plus::Bound; use mars_interest_rate::get_underlying_liquidity_amount; use mars_red_bank_types::{ @@ -7,6 +7,7 @@ use mars_red_bank_types::{ }; use crate::{ + msg::TotalDepositResponse, state::{ADDRESS_PROVIDER, ASSET_PARAMS, VAULT_CONFIGS}, types::{asset::AssetParams, vault::VaultConfig}, }; @@ -73,7 +74,11 @@ pub fn query_all_vault_configs( /// For example, when computing the deposited amount of ATOM, we only include /// ATOM deposited in RB and CM; we don't include the ATOM-OSMO LP token, or /// the ATOM-OSMO farming vault. -pub fn query_total_deposit(deps: Deps, env: &Env, denom: String) -> StdResult { +pub fn query_total_deposit( + deps: Deps, + env: &Env, + denom: String, +) -> StdResult { let current_timestamp = env.block.time.seconds(); // query contract addresses @@ -124,8 +129,15 @@ pub fn query_total_deposit(deps: Deps, env: &Env, denom: String) -> StdResult Promise targetHealthFactor: () => Promise - totalDeposit: ({ denom }: { denom: string }) => Promise + totalDeposit: ({ denom }: { denom: string }) => Promise } export class MarsParamsQueryClient implements MarsParamsReadOnlyInterface { client: CosmWasmClient @@ -127,7 +128,7 @@ export class MarsParamsQueryClient implements MarsParamsReadOnlyInterface { target_health_factor: {}, }) } - totalDeposit = async ({ denom }: { denom: string }): Promise => { + totalDeposit = async ({ denom }: { denom: string }): Promise => { return this.client.queryContractSmart(this.contractAddress, { total_deposit: { denom, diff --git a/scripts/types/generated/mars-params/MarsParams.react-query.ts b/scripts/types/generated/mars-params/MarsParams.react-query.ts index beae94e83..54b185c5b 100644 --- a/scripts/types/generated/mars-params/MarsParams.react-query.ts +++ b/scripts/types/generated/mars-params/MarsParams.react-query.ts @@ -37,6 +37,7 @@ import { ArrayOfVaultConfigBaseForAddr, VaultConfigBaseForAddr, OwnerResponse, + TotalDepositResponse, } from './MarsParams.types' import { MarsParamsQueryClient, MarsParamsClient } from './MarsParams.client' export const marsParamsQueryKeys = { @@ -79,17 +80,18 @@ export interface MarsParamsReactQuery { initialData?: undefined } } -export interface MarsParamsTotalDepositQuery extends MarsParamsReactQuery { +export interface MarsParamsTotalDepositQuery + extends MarsParamsReactQuery { args: { denom: string } } -export function useMarsParamsTotalDepositQuery({ +export function useMarsParamsTotalDepositQuery({ client, args, options, }: MarsParamsTotalDepositQuery) { - return useQuery( + return useQuery( marsParamsQueryKeys.totalDeposit(client?.contractAddress, args), () => client diff --git a/scripts/types/generated/mars-params/MarsParams.types.ts b/scripts/types/generated/mars-params/MarsParams.types.ts index 11eb13940..d27e9d118 100644 --- a/scripts/types/generated/mars-params/MarsParams.types.ts +++ b/scripts/types/generated/mars-params/MarsParams.types.ts @@ -208,3 +208,8 @@ export interface OwnerResponse { owner?: string | null proposed?: string | null } +export interface TotalDepositResponse { + amount: Uint128 + cap: Uint128 + denom: string +}