diff --git a/components/Trade/TradeActionModule.tsx b/components/Trade/TradeActionModule.tsx new file mode 100644 index 00000000..46c0a7c3 --- /dev/null +++ b/components/Trade/TradeActionModule.tsx @@ -0,0 +1,338 @@ +import React, { useEffect, useMemo, useState } from 'react' +import { Switch } from '@headlessui/react' +import BigNumber from 'bignumber.js' +import { toast } from 'react-toastify' +import { ArrowsUpDownIcon } from '@heroicons/react/24/solid' + +import Button from 'components/Button' +import useAllowedCoins from 'hooks/useAllowedCoins' +import { getTokenDecimals, getTokenSymbol } from 'utils/tokens' +import Slider from 'components/Slider' +import useTradeAsset from 'hooks/mutations/useTradeAsset' +import useAllBalances from 'hooks/useAllBalances' +import useMarkets from 'hooks/useMarkets' +import useCreditManagerStore from 'stores/useCreditManagerStore' +import useCreditAccountPositions from 'hooks/useCreditAccountPositions' +import useTokenPrices from 'hooks/useTokenPrices' +import useCalculateMaxTradeAmount from 'hooks/useCalculateMaxTradeAmount' +import Spinner from 'components/Spinner' + +enum FundingMode { + Account = 'Account', + WalletAndAccount = 'WalletAndAccount', +} + +const TradeActionModule = () => { + const [selectedTokenIn, setSelectedTokenIn] = useState('') + const [selectedTokenOut, setSelectedTokenOut] = useState('') + const [amountIn, setAmountIn] = useState(0) + const [amountOut, setAmountOut] = useState(0) + const [fundingMode, setFundingMode] = useState(FundingMode.WalletAndAccount) + + const [isMarginEnabled, setIsMarginEnabled] = React.useState(false) + + const selectedAccount = useCreditManagerStore((s) => s.selectedAccount) + + const { data: allowedCoinsData } = useAllowedCoins() + const { data: balancesData } = useAllBalances() + const { data: marketsData } = useMarkets() + const { data: tokenPrices } = useTokenPrices() + const { data: positionsData } = useCreditAccountPositions(selectedAccount ?? '') + + const resetAmounts = () => { + setAmountIn(0) + setAmountOut(0) + } + + useEffect(() => { + resetAmounts() + }, [selectedAccount]) + + const accountAmount = useMemo(() => { + return Number(positionsData?.coins?.find((coin) => coin.denom === selectedTokenIn)?.amount ?? 0) + }, [positionsData, selectedTokenIn]) + + const walletAmount = useMemo(() => { + return Number(balancesData?.find((balance) => balance.denom === selectedTokenIn)?.amount ?? 0) + }, [balancesData, selectedTokenIn]) + + const { swapAmount, borrowAmount, depositAmount } = useMemo(() => { + const swapAmount = amountIn + + let borrowAmount = 0 + let depositAmount = 0 + + if (fundingMode === FundingMode.WalletAndAccount) { + const walletAndAccountAmount = walletAmount + accountAmount + + borrowAmount = + amountIn > walletAndAccountAmount + ? BigNumber(amountIn).minus(walletAndAccountAmount).toNumber() + : 0 + + depositAmount = amountIn > walletAmount ? walletAmount : amountIn + } + + if (fundingMode === FundingMode.Account) { + borrowAmount = + amountIn > accountAmount ? BigNumber(amountIn).minus(accountAmount).toNumber() : 0 + } + + return { swapAmount, borrowAmount, depositAmount } + }, [accountAmount, amountIn, fundingMode, walletAmount]) + + const { mutate, isLoading } = useTradeAsset( + swapAmount, + borrowAmount, + depositAmount, + selectedTokenIn, + selectedTokenOut, + 0.1, + { + onSuccess: () => { + toast.success( + `${amountIn} ${getTokenSymbol(selectedTokenIn)} swapped for ${amountOut} ${getTokenSymbol( + selectedTokenOut, + )}`, + ) + resetAmounts() + }, + }, + ) + + useEffect(() => { + if (allowedCoinsData && allowedCoinsData.length > 0) { + // initialize selected token when allowedCoins fetch data is available + setSelectedTokenIn(allowedCoinsData[0]) + + if (allowedCoinsData.length > 1) { + setSelectedTokenOut(allowedCoinsData[1]) + } else { + setSelectedTokenOut(allowedCoinsData[0]) + } + } + }, [allowedCoinsData]) + + const handleSelectedTokenInChange = (e: React.ChangeEvent) => { + setSelectedTokenIn(e.target.value) + resetAmounts() + } + + const handleSelectedTokenOutChange = (e: React.ChangeEvent) => { + setSelectedTokenOut(e.target.value) + resetAmounts() + } + + const handleFundingModeChange = (e: React.ChangeEvent) => { + setFundingMode(e.target.value as FundingMode) + resetAmounts() + } + + // max amount that can be traded without considering wallet amount + // wallet amount should just be directly added to this amount in case user wants to include wallet as funding source + const maxTradeAmount = useCalculateMaxTradeAmount( + selectedTokenIn, + selectedTokenOut, + isMarginEnabled, + ) + + // if funding from wallet & account, add wallet amount to the max trade amount + const maxAmount = useMemo(() => { + if (fundingMode === FundingMode.WalletAndAccount) { + return walletAmount + maxTradeAmount + } + + return maxTradeAmount + }, [fundingMode, maxTradeAmount, walletAmount]) + + const percentageValue = useMemo(() => { + if (isNaN(amountIn) || amountIn === 0) return 0 + + return amountIn / maxAmount > 1 ? 100 : (amountIn / maxAmount) * 100 + }, [amountIn, maxAmount]) + + const borrowRate = Number(marketsData?.[selectedTokenOut]?.borrow_rate) + + const handleAmountChange = (value: number, mode: 'in' | 'out') => { + const tokenInPrice = tokenPrices?.[selectedTokenIn] ?? 1 + const tokenOutPrice = tokenPrices?.[selectedTokenOut] ?? 1 + + const priceRatio = BigNumber(tokenInPrice).div(tokenOutPrice) + + if (mode === 'in') { + setAmountIn(value) + setAmountOut(BigNumber(value).times(priceRatio).decimalPlaces(0).toNumber()) + } else { + setAmountOut(value) + setAmountIn(BigNumber(value).div(BigNumber(1).times(priceRatio)).decimalPlaces(0).toNumber()) + } + } + + const submitDisabled = selectedTokenIn === selectedTokenOut || !amountIn || amountIn > maxAmount + + return ( +
+ {isLoading && ( +
+ +
+ )} +
+
+

From:

+
+ + { + const valueAsNumber = e.target.valueAsNumber + const valueWithDecimals = valueAsNumber * 10 ** getTokenDecimals(selectedTokenIn) + + handleAmountChange(valueWithDecimals, 'in') + }} + /> +
+
+ { + setSelectedTokenIn(selectedTokenOut) + setSelectedTokenOut(selectedTokenIn) + resetAmounts() + }} + /> +
+

To:

+
+ + { + const valueAsNumber = e.target.valueAsNumber + const valueWithDecimals = valueAsNumber * 10 ** getTokenDecimals(selectedTokenOut) + + handleAmountChange(valueWithDecimals, 'out') + }} + /> +
+
+
+ In Wallet:{' '} + {BigNumber(walletAmount) + .dividedBy(10 ** getTokenDecimals(selectedTokenIn)) + .toNumber() + .toLocaleString(undefined, { + maximumFractionDigits: getTokenDecimals(selectedTokenIn), + })}{' '} + {getTokenSymbol(selectedTokenIn)} +
+
+ In Account:{' '} + {BigNumber(accountAmount) + .dividedBy(10 ** getTokenDecimals(selectedTokenIn)) + .toNumber() + .toLocaleString(undefined, { + maximumFractionDigits: getTokenDecimals(selectedTokenIn), + })}{' '} + {getTokenSymbol(selectedTokenIn)} +
+ { + const decimal = value[0] / 100 + const tokenDecimals = getTokenDecimals(selectedTokenIn) + // limit decimal precision based on token contract decimals + const newAmount = Number((decimal * maxAmount).toFixed(0)) + + handleAmountChange(newAmount, 'in') + }} + onMaxClick={() => handleAmountChange(maxAmount, 'in')} + /> +
+
+
+

Margin

+ { + // reset amounts only if margin is turned off + if (!value) resetAmounts() + + setIsMarginEnabled(value) + }} + className={`${ + isMarginEnabled ? 'bg-[#524BB1]' : 'bg-gray-400' + } relative inline-flex h-4 w-8 items-center rounded-full`} + > + + +
+
+

Borrow

+

+ {isMarginEnabled + ? BigNumber(borrowAmount) + .dividedBy(10 ** getTokenDecimals(selectedTokenIn)) + .toNumber() + .toLocaleString(undefined, { + maximumFractionDigits: getTokenDecimals(selectedTokenIn), + }) + : '-'} +

+
+
+

Borrow Rate

+

{isMarginEnabled ? `${(borrowRate * 100).toFixed(2)}%` : '-'}

+
+
+
+
OTHER INFO PLACEHOLDER
+
+

Funded From

+ +
+
+ +
+ ) +} + +export default TradeActionModule diff --git a/config/contracts.ts b/config/contracts.ts index 8377ae26..cc8fa83e 100644 --- a/config/contracts.ts +++ b/config/contracts.ts @@ -1,13 +1,15 @@ // https://github.com/mars-protocol/rover/blob/master/scripts/deploy/addresses/osmo-test-4.json export const roverContracts = { - accountNft: 'osmo1dravtyd0425fkdmkysc3ns7zud05clf5uhj6qqsnkdtrpkewu73q9f3f02', - mockVault: 'osmo1emcckulm2mkx36xeanhsn3z3zjeql6pgd8yf8a5cf03ccvy7a4dqjw9tl7', - marsOracleAdapter: 'osmo1cw6pv97g7fmhqykrn0gc9ngrx5tnky75rmlwkzxuqhsk58u0n8asz036g0', - swapper: 'osmo1w2552km2u9w4k2gjw4n8drmuz5yxw8x4qzy6dl3da824km5cjlys00x3qp', - creditManager: 'osmo18dt5y0ecyd5qg8nqwzrgxuljfejglyh2fjd984s8cy7fcx8mxh9qfl3hwq', + accountNft: 'osmo1xvne7u9svgy9vtqtqnaet4nvn8zcpp984zzrlezfzgk4798tps8srkf5wa', + mockVault: 'osmo1yqgjaehalz0pv5j22fdnaaekuprlggd7hth8m66jmdxe58ztqs4sjqtrlk', + marsOracleAdapter: 'osmo1tlad2hj9rm7az7atx2qq8pdpl2007hrhpzua42j8wgxr0kc0ct4sahuyh7', + swapper: 'osmo15kxcpvjaqlrj8ezecnghf2qs2x87veqx0fcemye0jpdr8jq7qkvsnyvuuf', + mockZapper: 'osmo1axad429tgnvzvfax08s4ytmf7ndg0f9z4jy355zyh4m6nasgtnzs5aw8u7', + creditManager: 'osmo1krz37p6xkkyu0f240enyt4ccxk7ds69kfgc5pnldsmpmmuvn3vpsnmpjaf', } export const contractAddresses = { ...roverContracts, - redBank: 'osmo1w5rqrdhut890jplmsqnr8gj3uf0wq6lj5rfdnhrtl63lpf6e7v6qalrhhn', + redBank: 'osmo1g30recyv8pfy3qd4qn3dn7plc0rn5z68y5gn32j39e96tjhthzxsw3uvvu', + oracle: 'osmo1hkkx42777dyfz7wc8acjjhfdh9x2ugcjvdt7shtft6ha9cn420cquz3u3j', } diff --git a/config/tokenInfo.ts b/config/tokenInfo.ts index 16f38119..578453c7 100644 --- a/config/tokenInfo.ts +++ b/config/tokenInfo.ts @@ -1,4 +1,5 @@ type Token = { + denom: string symbol: string decimals: number icon: string @@ -7,17 +8,26 @@ type Token = { const tokenInfo: { [key in string]: Token } = { uosmo: { + denom: 'uosmo', symbol: 'OSMO', decimals: 6, icon: '/tokens/osmo.svg', chain: 'Osmosis', }, 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2': { + denom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2', symbol: 'ATOM', icon: '/tokens/atom.svg', decimals: 6, chain: 'Cosmos', }, + 'ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1': { + denom: 'ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1', + symbol: 'CRO', + icon: '/tokens/cro.jpg', + decimals: 8, + chain: 'Crypto.org', + }, } export default tokenInfo diff --git a/hooks/mutations/useTradeAsset.tsx b/hooks/mutations/useTradeAsset.tsx new file mode 100644 index 00000000..681600bc --- /dev/null +++ b/hooks/mutations/useTradeAsset.tsx @@ -0,0 +1,78 @@ +import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query' +import { useMemo } from 'react' +import { toast } from 'react-toastify' + +import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' +import { queryKeys } from 'types/query-keys-factory' +import { hardcodedFee } from 'utils/contants' +import { Action } from 'types/generated/mars-credit-manager/MarsCreditManager.types' + +const useTradeAsset = ( + amount: number, + borrowAmount: number, + depositAmount: number, + tokenIn: string, + tokenOut: string, + slippage: number, + options?: Omit, +) => { + const creditManagerClient = useWalletStore((s) => s.clients.creditManager) + const selectedAccount = useCreditManagerStore((s) => s.selectedAccount ?? '') + + const queryClient = useQueryClient() + + // actions need to be executed in order deposit -> borrow -> swap + // first two are optional + const actions = useMemo(() => { + const actionsBase = [ + { + swap_exact_in: { + coin_in: { amount: String(amount), denom: tokenIn }, + denom_out: tokenOut, + slippage: String(slippage), + }, + }, + ] as Action[] + + if (borrowAmount > 0) { + actionsBase.unshift({ + borrow: { + denom: tokenIn, + amount: String(borrowAmount), + }, + }) + } + + if (depositAmount > 0) { + actionsBase.unshift({ + deposit: { + denom: tokenIn, + amount: String(depositAmount), + }, + }) + } + + return actionsBase + }, [amount, tokenIn, tokenOut, slippage, borrowAmount, depositAmount]) + + return useMutation( + async () => + await creditManagerClient?.updateCreditAccount( + { accountId: selectedAccount, actions }, + hardcodedFee, + ), + { + onSettled: () => { + queryClient.invalidateQueries(queryKeys.creditAccountsPositions(selectedAccount)) + queryClient.invalidateQueries(queryKeys.redbankBalances()) + }, + onError: (err: Error) => { + toast.error(err.message) + }, + ...options, + }, + ) +} + +export default useTradeAsset diff --git a/hooks/useCalculateMaxTradeAmount.tsx b/hooks/useCalculateMaxTradeAmount.tsx new file mode 100644 index 00000000..63594be5 --- /dev/null +++ b/hooks/useCalculateMaxTradeAmount.tsx @@ -0,0 +1,144 @@ +import { useCallback, useMemo } from 'react' +import BigNumber from 'bignumber.js' + +import useCreditManagerStore from 'stores/useCreditManagerStore' + +import useCreditAccountPositions from './useCreditAccountPositions' +import useMarkets from './useMarkets' +import useRedbankBalances from './useRedbankBalances' +import useTokenPrices from './useTokenPrices' + +const getApproximateHourlyInterest = (amount: string, borrowAPY: string) => { + const hourlyAPY = BigNumber(borrowAPY).div(24 * 365) + + return hourlyAPY.times(amount).toNumber() +} + +// max trade amount doesnt consider wallet balance as its not relevant +// the entire token balance within the wallet will always be able to be fully swapped +const useCalculateMaxTradeAmount = (tokenIn: string, tokenOut: string, isMargin: boolean) => { + const selectedAccount = useCreditManagerStore((s) => s.selectedAccount) + + const { data: positionsData } = useCreditAccountPositions(selectedAccount ?? '') + const { data: marketsData } = useMarkets() + const { data: tokenPrices } = useTokenPrices() + const { data: redbankBalances } = useRedbankBalances() + + const accountAmount = useMemo(() => { + return BigNumber( + positionsData?.coins?.find((coin) => coin.denom === tokenIn)?.amount ?? 0, + ).toNumber() + }, [positionsData, tokenIn]) + + const getTokenValue = useCallback( + (amount: string, denom: string) => { + if (!tokenPrices) return 0 + + return BigNumber(amount).times(tokenPrices[denom]).toNumber() + }, + [tokenPrices], + ) + + return useMemo(() => { + if (!marketsData || !tokenPrices || !positionsData || !redbankBalances || !tokenIn || !tokenOut) + return 0 + + const totalWeightedPositions = positionsData.coins.reduce((acc, coin) => { + const tokenWeightedValue = BigNumber(getTokenValue(coin.amount, coin.denom)).times( + Number(marketsData[coin.denom].max_loan_to_value), + ) + + return tokenWeightedValue.plus(acc).toNumber() + }, 0) + + // approximate debt value in an hour timespan to avoid throwing on smart contract level + // due to debt interest being applied + const totalLiabilitiesValue = positionsData.debts.reduce((acc, coin) => { + const estimatedInterestAmount = getApproximateHourlyInterest( + coin.amount, + marketsData[coin.denom].borrow_rate, + ) + + const tokenDebtValue = BigNumber(getTokenValue(coin.amount, coin.denom)).plus( + estimatedInterestAmount, + ) + + return tokenDebtValue.plus(acc).toNumber() + }, 0) + + const tokenOutLTV = Number(marketsData[tokenOut].max_loan_to_value) + const tokenInLTV = Number(marketsData[tokenIn].max_loan_to_value) + + // if the target token ltv higher, the full amount will always be able to be swapped + if (tokenOutLTV < tokenInLTV) { + // in theory, the most you can swap from x to y while keeping an health factor of 1 + const maxSwapValue = BigNumber(totalLiabilitiesValue) + .minus(totalWeightedPositions) + .dividedBy(tokenOutLTV - tokenInLTV) + + const maxSwapAmount = maxSwapValue.div(tokenPrices[tokenIn]).decimalPlaces(0) + + // if the swappable amount is lower than the account amount, any further calculations are irrelevant + if (maxSwapAmount.isLessThanOrEqualTo(accountAmount)) return maxSwapAmount.toNumber() + } + + // if margin is disabled, the max swap amount is capped at the account amount + if (!isMargin) { + return accountAmount + } + + const estimatedTokenOutAmount = BigNumber(accountAmount).times( + tokenPrices[tokenIn] / tokenPrices[tokenOut], + ) + + let positionsCoins = [...positionsData.coins] + + // if the target token is not in the account, add it to the positions + if (!positionsCoins.find((coin) => coin.denom === tokenOut)) { + positionsCoins.push({ + amount: '0', + denom: tokenOut, + }) + } + + // calculate weighted positions assuming the initial swap is made + const totalWeightedPositionsAfterSwap = positionsCoins + .filter((coin) => coin.denom !== tokenIn) + .reduce((acc, coin) => { + const coinAmount = + coin.denom === tokenOut + ? BigNumber(coin.amount).plus(estimatedTokenOutAmount).toString() + : coin.amount + + const tokenWeightedValue = BigNumber(getTokenValue(coinAmount, coin.denom)).times( + Number(marketsData[coin.denom].max_loan_to_value), + ) + + return tokenWeightedValue.plus(acc).toNumber() + }, 0) + + const maxBorrowValue = + totalWeightedPositionsAfterSwap === 0 + ? 0 + : BigNumber(totalWeightedPositionsAfterSwap) + .minus(totalLiabilitiesValue) + .dividedBy(1 - tokenOutLTV) + .toNumber() + + const maxBorrowAmount = BigNumber(maxBorrowValue).dividedBy(tokenPrices[tokenIn]).toNumber() + + return BigNumber(accountAmount).plus(maxBorrowAmount).decimalPlaces(0).toNumber() + }, [ + accountAmount, + getTokenValue, + isMargin, + marketsData, + positionsData, + redbankBalances, + tokenIn, + tokenOut, + tokenPrices, + ]) +} + +export default useCalculateMaxTradeAmount diff --git a/hooks/useMarkets.tsx b/hooks/useMarkets.tsx index 58b3f7ef..8fc8c7b3 100644 --- a/hooks/useMarkets.tsx +++ b/hooks/useMarkets.tsx @@ -48,16 +48,16 @@ const useMarkets = () => { slope_1: '0.25', slope_2: '0.3', }, - borrow_index: '1.002171957411401332', - liquidity_index: '1.00055035491698614', - borrow_rate: '0.1', - liquidity_rate: '0', - indexes_last_updated: 1664544343, - collateral_total_scaled: '89947659146708', - debt_total_scaled: '0', + borrow_index: '1.009983590233269535', + liquidity_index: '1.002073497939302451', + borrow_rate: '0.350254719559196173', + liquidity_rate: '0.039428374060840366', + indexes_last_updated: 1668271634, + collateral_total_scaled: '8275583285688290', + debt_total_scaled: '1155363812346122', deposit_enabled: true, borrow_enabled: true, - deposit_cap: '1000000000000', + deposit_cap: '15000000000000', }, 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2': { denom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2', @@ -71,16 +71,39 @@ const useMarkets = () => { slope_1: '0.25', slope_2: '0.3', }, - borrow_index: '1.000000224611044228', - liquidity_index: '1.000000023465246067', - borrow_rate: '0.25', + borrow_index: '1.015550607619308095', + liquidity_index: '1.003284932040106733', + borrow_rate: '0.75632500115230499', + liquidity_rate: '0.435023016254423759', + indexes_last_updated: 1668273756, + collateral_total_scaled: '3309105730887721', + debt_total_scaled: '2350429206911653', + deposit_enabled: true, + borrow_enabled: true, + deposit_cap: '15000000000000', + }, + 'ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1': { + denom: 'ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1', + max_loan_to_value: '0.65', + liquidation_threshold: '0.7', + liquidation_bonus: '0.1', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.1', + base: '0.3', + slope_1: '0.25', + slope_2: '0.3', + }, + borrow_index: '1.001519837645865043', + liquidity_index: '1', + borrow_rate: '0.3', liquidity_rate: '0', - indexes_last_updated: 1664367327, - collateral_total_scaled: '0', + indexes_last_updated: 1667995650, + collateral_total_scaled: '1000000000000000', debt_total_scaled: '0', deposit_enabled: true, borrow_enabled: true, - deposit_cap: '1000000000', + deposit_cap: '15000000000000', }, }, }), diff --git a/hooks/useTokenPrices.tsx b/hooks/useTokenPrices.tsx index 83e7218e..34ed83f0 100644 --- a/hooks/useTokenPrices.tsx +++ b/hooks/useTokenPrices.tsx @@ -1,16 +1,66 @@ import { useQuery } from '@tanstack/react-query' +import { useMemo } from 'react' +import { gql, request } from 'graphql-request' -const useTokenPrices = () => { - return useQuery<{ [key in string]: number }>( - ['tokenPrices'], - () => ({ - uosmo: 1, - 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2': 1.5, - }), - { - staleTime: Infinity, - }, +import { contractAddresses } from 'config/contracts' +import { queryKeys } from 'types/query-keys-factory' +import { chain } from 'utils/chains' +import tokenInfo from 'config/tokenInfo' + +interface Result { + prices: { + [key: string]: { + denom: string + price: string + } + } +} + +const tokenInfoList = Object.values(tokenInfo) + +// TODO: build gql query dynamically on whitelisted tokens +const fetchTokenPrices = () => { + return request( + chain.hive, + gql` + query PriceOracle { + prices: wasm { + ${tokenInfoList.map((token) => { + return `${token.symbol}: contractQuery( + contractAddress: "${contractAddresses.oracle}" + query: { + price: { + denom: "${token.denom}" + } + } + )` + })} + } + } + `, ) } +const useTokenPrices = () => { + const result = useQuery(queryKeys.tokenPrices(), fetchTokenPrices, { + refetchInterval: 30000, + staleTime: Infinity, + }) + + return { + ...result, + data: useMemo(() => { + if (!result.data) return + + return Object.values(result.data?.prices).reduce( + (acc, entry) => ({ + ...acc, + [entry.denom]: Number(entry.price), + }), + {}, + ) as { [key in string]: number } + }, [result.data]), + } +} + export default useTokenPrices diff --git a/package.json b/package.json index 00259a9c..d874fe25 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "bech32": "^2.0.0", "bignumber.js": "^9.1.0", "ethereumjs-util": "^7.1.5", + "graphql": "^16.6.0", + "graphql-request": "^5.0.0", "next": "12.3.1", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/pages/index.tsx b/pages/index.tsx index 8019bef8..bc243194 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -18,6 +18,8 @@ import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' import { chain } from 'utils/chains' import { hardcodedFee } from 'utils/contants' +import useMarkets from 'hooks/useMarkets' +import useTokenPrices from 'hooks/useTokenPrices' const Home: NextPage = () => { const [sendAmount, setSendAmount] = useState('') @@ -37,6 +39,9 @@ const Home: NextPage = () => { const [signingClient, setSigningClient] = useState() + const { data: marketsData } = useMarkets() + const { data: tokenPrices } = useTokenPrices() + useEffect(() => { ;(async () => { if (!window.keplr) return @@ -324,6 +329,20 @@ const Home: NextPage = () => { )} +
+ {tokenPrices && ( +
+

Token Prices:

+
{JSON.stringify(tokenPrices, null, 2)}
+
+ )} + {marketsData && ( +
+

Markets Data:

+
{JSON.stringify(marketsData, null, 2)}
+
+ )} +
{error &&
{error}
} {isLoading && (
diff --git a/pages/trade.tsx b/pages/trade.tsx index 108eb70f..8e25e4a6 100644 --- a/pages/trade.tsx +++ b/pages/trade.tsx @@ -1,17 +1,19 @@ import React from 'react' import Container from 'components/Container' +import TradeActionModule from 'components/Trade/TradeActionModule' const Trade = () => { return (
- Graph/Tradingview Module + Graph/Tradingview Module
- Buy/Sell module + + + Orderbook module (optional)
- Credit Account essential module
Trader order overview
diff --git a/public/tokens/cro.jpg b/public/tokens/cro.jpg new file mode 100644 index 00000000..d1ab38f0 Binary files /dev/null and b/public/tokens/cro.jpg differ diff --git a/stores/useWalletStore.tsx b/stores/useWalletStore.tsx index 35546299..7d03e257 100644 --- a/stores/useWalletStore.tsx +++ b/stores/useWalletStore.tsx @@ -4,8 +4,9 @@ import { persist } from 'zustand/middleware' import { contractAddresses } from 'config/contracts' import { Wallet } from 'types' -import { AccountNftClient } from 'types/generated/account-nft/AccountNft.client' -import { CreditManagerClient } from 'types/generated/credit-manager/CreditManager.client' +import { MarsAccountNftClient } from 'types/generated/mars-account-nft/MarsAccountNft.client' +import { MarsCreditManagerClient } from 'types/generated/mars-credit-manager/MarsCreditManager.client' +import { MarsSwapperBaseClient } from 'types/generated/mars-swapper-base/MarsSwapperBase.client' import { chain } from 'utils/chains' interface WalletStore { @@ -15,8 +16,9 @@ interface WalletStore { client?: CosmWasmClient signingClient?: SigningCosmWasmClient clients: { - accountNft: AccountNftClient | null - creditManager: CreditManagerClient | null + accountNft: MarsAccountNftClient | null + creditManager: MarsCreditManagerClient | null + swapperBase: MarsSwapperBaseClient | null } actions: { disconnect: () => void @@ -36,27 +38,34 @@ const useWalletStore = create()( clients: { accountNft: null, creditManager: null, + swapperBase: null, }, actions: { disconnect: () => { set(() => ({ address: '', wallet: null, signingClient: undefined })) }, initClients: (address, signingClient) => { - const accountNft = new AccountNftClient( + const accountNft = new MarsAccountNftClient( signingClient, address, contractAddresses.accountNft, ) - const creditManager = new CreditManagerClient( + const creditManager = new MarsCreditManagerClient( signingClient, address, contractAddresses.creditManager, ) + const swapperBase = new MarsSwapperBaseClient( + signingClient, + address, + contractAddresses.swapper, + ) set(() => ({ clients: { accountNft, creditManager, + swapperBase, }, })) }, diff --git a/types/generated/account-nft/bundle.ts b/types/generated/account-nft/bundle.ts deleted file mode 100644 index 61eeb569..00000000 --- a/types/generated/account-nft/bundle.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import * as _1 from './AccountNft.client' -import * as _2 from './AccountNft.react-query' -import * as _0 from './AccountNft.types' -export namespace contracts { - export const AccountNft = { ..._0, ..._1, ..._2 } -} diff --git a/types/generated/credit-manager/CreditManager.react-query.ts b/types/generated/credit-manager/CreditManager.react-query.ts deleted file mode 100644 index 43374638..00000000 --- a/types/generated/credit-manager/CreditManager.react-query.ts +++ /dev/null @@ -1,470 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import { StdFee } from '@cosmjs/amino' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { CreditManagerClient, CreditManagerQueryClient } from './CreditManager.client' -import { - Action, - Addr, - ArrayOfCoinBalanceResponseItem, - ArrayOfDebtShares, - ArrayOfSharesResponseItem, - ArrayOfString, - ArrayOfVaultBaseForString, - ArrayOfVaultPositionResponseItem, - ArrayOfVaultWithBalance, - CallbackMsg, - Coin, - CoinBalanceResponseItem, - ConfigResponse, - ConfigUpdates, - DebtAmount, - DebtShares, - Decimal, - ExecuteMsg, - HealthResponse, - InstantiateMsg, - OracleBaseForString, - Positions, - QueryMsg, - RedBankBaseForString, - SharesResponseItem, - SwapperBaseForString, - Uint128, - VaultBaseForAddr, - VaultBaseForString, - VaultPosition, - VaultPositionResponseItem, - VaultPositionState, - VaultWithBalance, -} from './CreditManager.types' -export const creditManagerQueryKeys = { - contract: [ - { - contract: 'creditManager', - }, - ] as const, - address: (contractAddress: string | undefined) => - [{ ...creditManagerQueryKeys.contract[0], address: contractAddress }] as const, - config: (contractAddress: string | undefined, args?: Record) => - [{ ...creditManagerQueryKeys.address(contractAddress)[0], method: 'config', args }] as const, - allowedVaults: (contractAddress: string | undefined, args?: Record) => - [ - { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'allowed_vaults', args }, - ] as const, - allowedCoins: (contractAddress: string | undefined, args?: Record) => - [ - { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'allowed_coins', args }, - ] as const, - positions: (contractAddress: string | undefined, args?: Record) => - [{ ...creditManagerQueryKeys.address(contractAddress)[0], method: 'positions', args }] as const, - health: (contractAddress: string | undefined, args?: Record) => - [{ ...creditManagerQueryKeys.address(contractAddress)[0], method: 'health', args }] as const, - allCoinBalances: (contractAddress: string | undefined, args?: Record) => - [ - { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'all_coin_balances', args }, - ] as const, - allDebtShares: (contractAddress: string | undefined, args?: Record) => - [ - { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'all_debt_shares', args }, - ] as const, - totalDebtShares: (contractAddress: string | undefined, args?: Record) => - [ - { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'total_debt_shares', args }, - ] as const, - allTotalDebtShares: (contractAddress: string | undefined, args?: Record) => - [ - { - ...creditManagerQueryKeys.address(contractAddress)[0], - method: 'all_total_debt_shares', - args, - }, - ] as const, - allVaultPositions: (contractAddress: string | undefined, args?: Record) => - [ - { - ...creditManagerQueryKeys.address(contractAddress)[0], - method: 'all_vault_positions', - args, - }, - ] as const, - totalVaultCoinBalance: (contractAddress: string | undefined, args?: Record) => - [ - { - ...creditManagerQueryKeys.address(contractAddress)[0], - method: 'total_vault_coin_balance', - args, - }, - ] as const, - allTotalVaultCoinBalances: ( - contractAddress: string | undefined, - args?: Record, - ) => - [ - { - ...creditManagerQueryKeys.address(contractAddress)[0], - method: 'all_total_vault_coin_balances', - args, - }, - ] as const, -} -export interface CreditManagerReactQuery { - client: CreditManagerQueryClient | undefined - options?: Omit< - UseQueryOptions, - "'queryKey' | 'queryFn' | 'initialData'" - > & { - initialData?: undefined - } -} -export interface CreditManagerAllTotalVaultCoinBalancesQuery - extends CreditManagerReactQuery { - args: { - limit?: number - startAfter?: VaultBaseForString - } -} -export function useCreditManagerAllTotalVaultCoinBalancesQuery({ - client, - args, - options, -}: CreditManagerAllTotalVaultCoinBalancesQuery) { - return useQuery( - creditManagerQueryKeys.allTotalVaultCoinBalances(client?.contractAddress, args), - () => - client - ? client.allTotalVaultCoinBalances({ - limit: args.limit, - startAfter: args.startAfter, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerTotalVaultCoinBalanceQuery - extends CreditManagerReactQuery { - args: { - vault: VaultBaseForString - } -} -export function useCreditManagerTotalVaultCoinBalanceQuery({ - client, - args, - options, -}: CreditManagerTotalVaultCoinBalanceQuery) { - return useQuery( - creditManagerQueryKeys.totalVaultCoinBalance(client?.contractAddress, args), - () => - client - ? client.totalVaultCoinBalance({ - vault: args.vault, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerAllVaultPositionsQuery - extends CreditManagerReactQuery { - args: { - limit?: number - startAfter?: string[][] - } -} -export function useCreditManagerAllVaultPositionsQuery({ - client, - args, - options, -}: CreditManagerAllVaultPositionsQuery) { - return useQuery( - creditManagerQueryKeys.allVaultPositions(client?.contractAddress, args), - () => - client - ? client.allVaultPositions({ - limit: args.limit, - startAfter: args.startAfter, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerAllTotalDebtSharesQuery - extends CreditManagerReactQuery { - args: { - limit?: number - startAfter?: string - } -} -export function useCreditManagerAllTotalDebtSharesQuery({ - client, - args, - options, -}: CreditManagerAllTotalDebtSharesQuery) { - return useQuery( - creditManagerQueryKeys.allTotalDebtShares(client?.contractAddress, args), - () => - client - ? client.allTotalDebtShares({ - limit: args.limit, - startAfter: args.startAfter, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerTotalDebtSharesQuery - extends CreditManagerReactQuery {} -export function useCreditManagerTotalDebtSharesQuery({ - client, - options, -}: CreditManagerTotalDebtSharesQuery) { - return useQuery( - creditManagerQueryKeys.totalDebtShares(client?.contractAddress), - () => (client ? client.totalDebtShares() : Promise.reject(new Error('Invalid client'))), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerAllDebtSharesQuery - extends CreditManagerReactQuery { - args: { - limit?: number - startAfter?: string[][] - } -} -export function useCreditManagerAllDebtSharesQuery({ - client, - args, - options, -}: CreditManagerAllDebtSharesQuery) { - return useQuery( - creditManagerQueryKeys.allDebtShares(client?.contractAddress, args), - () => - client - ? client.allDebtShares({ - limit: args.limit, - startAfter: args.startAfter, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerAllCoinBalancesQuery - extends CreditManagerReactQuery { - args: { - limit?: number - startAfter?: string[][] - } -} -export function useCreditManagerAllCoinBalancesQuery({ - client, - args, - options, -}: CreditManagerAllCoinBalancesQuery) { - return useQuery( - creditManagerQueryKeys.allCoinBalances(client?.contractAddress, args), - () => - client - ? client.allCoinBalances({ - limit: args.limit, - startAfter: args.startAfter, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerHealthQuery - extends CreditManagerReactQuery { - args: { - accountId: string - } -} -export function useCreditManagerHealthQuery({ - client, - args, - options, -}: CreditManagerHealthQuery) { - return useQuery( - creditManagerQueryKeys.health(client?.contractAddress, args), - () => - client - ? client.health({ - accountId: args.accountId, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerPositionsQuery - extends CreditManagerReactQuery { - args: { - accountId: string - } -} -export function useCreditManagerPositionsQuery({ - client, - args, - options, -}: CreditManagerPositionsQuery) { - return useQuery( - creditManagerQueryKeys.positions(client?.contractAddress, args), - () => - client - ? client.positions({ - accountId: args.accountId, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerAllowedCoinsQuery - extends CreditManagerReactQuery { - args: { - limit?: number - startAfter?: string - } -} -export function useCreditManagerAllowedCoinsQuery({ - client, - args, - options, -}: CreditManagerAllowedCoinsQuery) { - return useQuery( - creditManagerQueryKeys.allowedCoins(client?.contractAddress, args), - () => - client - ? client.allowedCoins({ - limit: args.limit, - startAfter: args.startAfter, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerAllowedVaultsQuery - extends CreditManagerReactQuery { - args: { - limit?: number - startAfter?: VaultBaseForString - } -} -export function useCreditManagerAllowedVaultsQuery({ - client, - args, - options, -}: CreditManagerAllowedVaultsQuery) { - return useQuery( - creditManagerQueryKeys.allowedVaults(client?.contractAddress, args), - () => - client - ? client.allowedVaults({ - limit: args.limit, - startAfter: args.startAfter, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerConfigQuery - extends CreditManagerReactQuery {} -export function useCreditManagerConfigQuery({ - client, - options, -}: CreditManagerConfigQuery) { - return useQuery( - creditManagerQueryKeys.config(client?.contractAddress), - () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface CreditManagerCallbackMutation { - client: CreditManagerClient - msg: CallbackMsg - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useCreditManagerCallbackMutation( - options?: Omit< - UseMutationOptions, - 'mutationFn' - >, -) { - return useMutation( - ({ client, msg, args: { fee, memo, funds } = {} }) => client.callback(msg, fee, memo, funds), - options, - ) -} -export interface CreditManagerUpdateConfigMutation { - client: CreditManagerClient - msg: { - newConfig: ConfigUpdates - } - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useCreditManagerUpdateConfigMutation( - options?: Omit< - UseMutationOptions, - 'mutationFn' - >, -) { - return useMutation( - ({ client, msg, args: { fee, memo, funds } = {} }) => - client.updateConfig(msg, fee, memo, funds), - options, - ) -} -export interface CreditManagerUpdateCreditAccountMutation { - client: CreditManagerClient - msg: { - accountId: string - actions: Action[] - } - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useCreditManagerUpdateCreditAccountMutation( - options?: Omit< - UseMutationOptions, - 'mutationFn' - >, -) { - return useMutation( - ({ client, msg, args: { fee, memo, funds } = {} }) => - client.updateCreditAccount(msg, fee, memo, funds), - options, - ) -} -export interface CreditManagerCreateCreditAccountMutation { - client: CreditManagerClient - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useCreditManagerCreateCreditAccountMutation( - options?: Omit< - UseMutationOptions, - 'mutationFn' - >, -) { - return useMutation( - ({ client, args: { fee, memo, funds } = {} }) => client.createCreditAccount(fee, memo, funds), - options, - ) -} diff --git a/types/generated/account-nft/AccountNft.client.ts b/types/generated/mars-account-nft/MarsAccountNft.client.ts similarity index 96% rename from types/generated/account-nft/AccountNft.client.ts rename to types/generated/mars-account-nft/MarsAccountNft.client.ts index 3e4cd96c..643927d1 100644 --- a/types/generated/account-nft/AccountNft.client.ts +++ b/types/generated/mars-account-nft/MarsAccountNft.client.ts @@ -1,36 +1,35 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { Coin, StdFee } from '@cosmjs/amino' -import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' - import { + InstantiateMsg, + ExecuteMsg, + Binary, + Expiration, + Timestamp, + Uint64, + QueryMsg, AllNftInfoResponseForEmpty, + OwnerOfResponse, Approval, + NftInfoResponseForEmpty, + Empty, + OperatorsResponse, + TokensResponse, ApprovalResponse, ApprovalsResponse, - Binary, ContractInfoResponse, - Empty, - ExecuteMsg, - Expiration, - InstantiateMsg, MinterResponse, - NftInfoResponseForEmpty, NumTokensResponse, - OperatorsResponse, - OwnerOfResponse, - QueryMsg, String, - Timestamp, - TokensResponse, - Uint64, -} from './AccountNft.types' -export interface AccountNftReadOnlyInterface { +} from './MarsAccountNft.types' +export interface MarsAccountNftReadOnlyInterface { contractAddress: string proposedNewOwner: () => Promise ownerOf: ({ @@ -95,7 +94,7 @@ export interface AccountNftReadOnlyInterface { }) => Promise minter: () => Promise } -export class AccountNftQueryClient implements AccountNftReadOnlyInterface { +export class MarsAccountNftQueryClient implements MarsAccountNftReadOnlyInterface { client: CosmWasmClient contractAddress: string @@ -254,7 +253,7 @@ export class AccountNftQueryClient implements AccountNftReadOnlyInterface { }) } } -export interface AccountNftInterface extends AccountNftReadOnlyInterface { +export interface MarsAccountNftInterface extends MarsAccountNftReadOnlyInterface { contractAddress: string sender: string proposeNewOwner: ( @@ -367,7 +366,10 @@ export interface AccountNftInterface extends AccountNftReadOnlyInterface { funds?: Coin[], ) => Promise } -export class AccountNftClient extends AccountNftQueryClient implements AccountNftInterface { +export class MarsAccountNftClient + extends MarsAccountNftQueryClient + implements MarsAccountNftInterface +{ client: SigningCosmWasmClient sender: string contractAddress: string diff --git a/types/generated/mars-account-nft/MarsAccountNft.message-composer.ts b/types/generated/mars-account-nft/MarsAccountNft.message-composer.ts new file mode 100644 index 00000000..24761e47 --- /dev/null +++ b/types/generated/mars-account-nft/MarsAccountNft.message-composer.ts @@ -0,0 +1,396 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { Coin } from '@cosmjs/amino' +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + InstantiateMsg, + ExecuteMsg, + Binary, + Expiration, + Timestamp, + Uint64, + QueryMsg, + AllNftInfoResponseForEmpty, + OwnerOfResponse, + Approval, + NftInfoResponseForEmpty, + Empty, + OperatorsResponse, + TokensResponse, + ApprovalResponse, + ApprovalsResponse, + ContractInfoResponse, + MinterResponse, + NumTokensResponse, + String, +} from './MarsAccountNft.types' +export interface MarsAccountNftMessage { + contractAddress: string + sender: string + proposeNewOwner: ( + { + newOwner, + }: { + newOwner: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + acceptOwnership: (funds?: Coin[]) => MsgExecuteContractEncodeObject + mint: ( + { + user, + }: { + user: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + transferNft: ( + { + recipient, + tokenId, + }: { + recipient: string + tokenId: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + sendNft: ( + { + contract, + msg, + tokenId, + }: { + contract: string + msg: Binary + tokenId: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + approve: ( + { + expires, + spender, + tokenId, + }: { + expires?: Expiration + spender: string + tokenId: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + revoke: ( + { + spender, + tokenId, + }: { + spender: string + tokenId: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + approveAll: ( + { + expires, + operator, + }: { + expires?: Expiration + operator: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + revokeAll: ( + { + operator, + }: { + operator: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + burn: ( + { + tokenId, + }: { + tokenId: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject +} +export class MarsAccountNftMessageComposer implements MarsAccountNftMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.proposeNewOwner = this.proposeNewOwner.bind(this) + this.acceptOwnership = this.acceptOwnership.bind(this) + this.mint = this.mint.bind(this) + this.transferNft = this.transferNft.bind(this) + this.sendNft = this.sendNft.bind(this) + this.approve = this.approve.bind(this) + this.revoke = this.revoke.bind(this) + this.approveAll = this.approveAll.bind(this) + this.revokeAll = this.revokeAll.bind(this) + this.burn = this.burn.bind(this) + } + + proposeNewOwner = ( + { + newOwner, + }: { + newOwner: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + propose_new_owner: { + new_owner: newOwner, + }, + }), + ), + funds, + }), + } + } + acceptOwnership = (funds?: Coin[]): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + accept_ownership: {}, + }), + ), + funds, + }), + } + } + mint = ( + { + user, + }: { + user: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + mint: { + user, + }, + }), + ), + funds, + }), + } + } + transferNft = ( + { + recipient, + tokenId, + }: { + recipient: string + tokenId: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + transfer_nft: { + recipient, + token_id: tokenId, + }, + }), + ), + funds, + }), + } + } + sendNft = ( + { + contract, + msg, + tokenId, + }: { + contract: string + msg: Binary + tokenId: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + send_nft: { + contract, + msg, + token_id: tokenId, + }, + }), + ), + funds, + }), + } + } + approve = ( + { + expires, + spender, + tokenId, + }: { + expires?: Expiration + spender: string + tokenId: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + approve: { + expires, + spender, + token_id: tokenId, + }, + }), + ), + funds, + }), + } + } + revoke = ( + { + spender, + tokenId, + }: { + spender: string + tokenId: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + revoke: { + spender, + token_id: tokenId, + }, + }), + ), + funds, + }), + } + } + approveAll = ( + { + expires, + operator, + }: { + expires?: Expiration + operator: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + approve_all: { + expires, + operator, + }, + }), + ), + funds, + }), + } + } + revokeAll = ( + { + operator, + }: { + operator: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + revoke_all: { + operator, + }, + }), + ), + funds, + }), + } + } + burn = ( + { + tokenId, + }: { + tokenId: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + burn: { + token_id: tokenId, + }, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/account-nft/AccountNft.react-query.ts b/types/generated/mars-account-nft/MarsAccountNft.react-query.ts similarity index 53% rename from types/generated/account-nft/AccountNft.react-query.ts rename to types/generated/mars-account-nft/MarsAccountNft.react-query.ts index 9c01f5ef..44f64ae5 100644 --- a/types/generated/account-nft/AccountNft.react-query.ts +++ b/types/generated/mars-account-nft/MarsAccountNft.react-query.ts @@ -1,78 +1,89 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { Coin, StdFee } from '@cosmjs/amino' +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { AccountNftClient, AccountNftQueryClient } from './AccountNft.client' +import { StdFee, Coin } from '@cosmjs/amino' import { + InstantiateMsg, + ExecuteMsg, + Binary, + Expiration, + Timestamp, + Uint64, + QueryMsg, AllNftInfoResponseForEmpty, + OwnerOfResponse, Approval, + NftInfoResponseForEmpty, + Empty, + OperatorsResponse, + TokensResponse, ApprovalResponse, ApprovalsResponse, - Binary, ContractInfoResponse, - Empty, - ExecuteMsg, - Expiration, - InstantiateMsg, MinterResponse, - NftInfoResponseForEmpty, NumTokensResponse, - OperatorsResponse, - OwnerOfResponse, - QueryMsg, String, - Timestamp, - TokensResponse, - Uint64, -} from './AccountNft.types' -export const accountNftQueryKeys = { +} from './MarsAccountNft.types' +import { MarsAccountNftQueryClient, MarsAccountNftClient } from './MarsAccountNft.client' +export const marsAccountNftQueryKeys = { contract: [ { - contract: 'accountNft', + contract: 'marsAccountNft', }, ] as const, address: (contractAddress: string | undefined) => - [{ ...accountNftQueryKeys.contract[0], address: contractAddress }] as const, + [{ ...marsAccountNftQueryKeys.contract[0], address: contractAddress }] as const, proposedNewOwner: (contractAddress: string | undefined, args?: Record) => [ - { ...accountNftQueryKeys.address(contractAddress)[0], method: 'proposed_new_owner', args }, + { + ...marsAccountNftQueryKeys.address(contractAddress)[0], + method: 'proposed_new_owner', + args, + }, ] as const, ownerOf: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'owner_of', args }] as const, + [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'owner_of', args }] as const, approval: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'approval', args }] as const, + [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'approval', args }] as const, approvals: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'approvals', args }] as const, + [ + { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'approvals', args }, + ] as const, allOperators: (contractAddress: string | undefined, args?: Record) => [ - { ...accountNftQueryKeys.address(contractAddress)[0], method: 'all_operators', args }, + { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'all_operators', args }, ] as const, numTokens: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'num_tokens', args }] as const, + [ + { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'num_tokens', args }, + ] as const, contractInfo: (contractAddress: string | undefined, args?: Record) => [ - { ...accountNftQueryKeys.address(contractAddress)[0], method: 'contract_info', args }, + { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'contract_info', args }, ] as const, nftInfo: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'nft_info', args }] as const, + [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'nft_info', args }] as const, allNftInfo: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'all_nft_info', args }] as const, + [ + { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'all_nft_info', args }, + ] as const, tokens: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'tokens', args }] as const, + [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'tokens', args }] as const, allTokens: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'all_tokens', args }] as const, + [ + { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'all_tokens', args }, + ] as const, minter: (contractAddress: string | undefined, args?: Record) => - [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'minter', args }] as const, + [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'minter', args }] as const, } -export interface AccountNftReactQuery { - client: AccountNftQueryClient | undefined +export interface MarsAccountNftReactQuery { + client: MarsAccountNftQueryClient | undefined options?: Omit< UseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'" @@ -80,31 +91,32 @@ export interface AccountNftReactQuery { initialData?: undefined } } -export interface AccountNftMinterQuery extends AccountNftReactQuery {} -export function useAccountNftMinterQuery({ +export interface MarsAccountNftMinterQuery + extends MarsAccountNftReactQuery {} +export function useMarsAccountNftMinterQuery({ client, options, -}: AccountNftMinterQuery) { +}: MarsAccountNftMinterQuery) { return useQuery( - accountNftQueryKeys.minter(client?.contractAddress), + marsAccountNftQueryKeys.minter(client?.contractAddress), () => (client ? client.minter() : Promise.reject(new Error('Invalid client'))), { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftAllTokensQuery - extends AccountNftReactQuery { +export interface MarsAccountNftAllTokensQuery + extends MarsAccountNftReactQuery { args: { limit?: number startAfter?: string } } -export function useAccountNftAllTokensQuery({ +export function useMarsAccountNftAllTokensQuery({ client, args, options, -}: AccountNftAllTokensQuery) { +}: MarsAccountNftAllTokensQuery) { return useQuery( - accountNftQueryKeys.allTokens(client?.contractAddress, args), + marsAccountNftQueryKeys.allTokens(client?.contractAddress, args), () => client ? client.allTokens({ @@ -115,20 +127,21 @@ export function useAccountNftAllTokensQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftTokensQuery extends AccountNftReactQuery { +export interface MarsAccountNftTokensQuery + extends MarsAccountNftReactQuery { args: { limit?: number owner: string startAfter?: string } } -export function useAccountNftTokensQuery({ +export function useMarsAccountNftTokensQuery({ client, args, options, -}: AccountNftTokensQuery) { +}: MarsAccountNftTokensQuery) { return useQuery( - accountNftQueryKeys.tokens(client?.contractAddress, args), + marsAccountNftQueryKeys.tokens(client?.contractAddress, args), () => client ? client.tokens({ @@ -140,20 +153,20 @@ export function useAccountNftTokensQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftAllNftInfoQuery - extends AccountNftReactQuery { +export interface MarsAccountNftAllNftInfoQuery + extends MarsAccountNftReactQuery { args: { includeExpired?: boolean tokenId: string } } -export function useAccountNftAllNftInfoQuery({ +export function useMarsAccountNftAllNftInfoQuery({ client, args, options, -}: AccountNftAllNftInfoQuery) { +}: MarsAccountNftAllNftInfoQuery) { return useQuery( - accountNftQueryKeys.allNftInfo(client?.contractAddress, args), + marsAccountNftQueryKeys.allNftInfo(client?.contractAddress, args), () => client ? client.allNftInfo({ @@ -164,19 +177,19 @@ export function useAccountNftAllNftInfoQuery { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftNftInfoQuery - extends AccountNftReactQuery { +export interface MarsAccountNftNftInfoQuery + extends MarsAccountNftReactQuery { args: { tokenId: string } } -export function useAccountNftNftInfoQuery({ +export function useMarsAccountNftNftInfoQuery({ client, args, options, -}: AccountNftNftInfoQuery) { +}: MarsAccountNftNftInfoQuery) { return useQuery( - accountNftQueryKeys.nftInfo(client?.contractAddress, args), + marsAccountNftQueryKeys.nftInfo(client?.contractAddress, args), () => client ? client.nftInfo({ @@ -186,32 +199,32 @@ export function useAccountNftNftInfoQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftContractInfoQuery - extends AccountNftReactQuery {} -export function useAccountNftContractInfoQuery({ +export interface MarsAccountNftContractInfoQuery + extends MarsAccountNftReactQuery {} +export function useMarsAccountNftContractInfoQuery({ client, options, -}: AccountNftContractInfoQuery) { +}: MarsAccountNftContractInfoQuery) { return useQuery( - accountNftQueryKeys.contractInfo(client?.contractAddress), + marsAccountNftQueryKeys.contractInfo(client?.contractAddress), () => (client ? client.contractInfo() : Promise.reject(new Error('Invalid client'))), { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftNumTokensQuery - extends AccountNftReactQuery {} -export function useAccountNftNumTokensQuery({ +export interface MarsAccountNftNumTokensQuery + extends MarsAccountNftReactQuery {} +export function useMarsAccountNftNumTokensQuery({ client, options, -}: AccountNftNumTokensQuery) { +}: MarsAccountNftNumTokensQuery) { return useQuery( - accountNftQueryKeys.numTokens(client?.contractAddress), + marsAccountNftQueryKeys.numTokens(client?.contractAddress), () => (client ? client.numTokens() : Promise.reject(new Error('Invalid client'))), { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftAllOperatorsQuery - extends AccountNftReactQuery { +export interface MarsAccountNftAllOperatorsQuery + extends MarsAccountNftReactQuery { args: { includeExpired?: boolean limit?: number @@ -219,13 +232,13 @@ export interface AccountNftAllOperatorsQuery startAfter?: string } } -export function useAccountNftAllOperatorsQuery({ +export function useMarsAccountNftAllOperatorsQuery({ client, args, options, -}: AccountNftAllOperatorsQuery) { +}: MarsAccountNftAllOperatorsQuery) { return useQuery( - accountNftQueryKeys.allOperators(client?.contractAddress, args), + marsAccountNftQueryKeys.allOperators(client?.contractAddress, args), () => client ? client.allOperators({ @@ -238,20 +251,20 @@ export function useAccountNftAllOperatorsQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftApprovalsQuery - extends AccountNftReactQuery { +export interface MarsAccountNftApprovalsQuery + extends MarsAccountNftReactQuery { args: { includeExpired?: boolean tokenId: string } } -export function useAccountNftApprovalsQuery({ +export function useMarsAccountNftApprovalsQuery({ client, args, options, -}: AccountNftApprovalsQuery) { +}: MarsAccountNftApprovalsQuery) { return useQuery( - accountNftQueryKeys.approvals(client?.contractAddress, args), + marsAccountNftQueryKeys.approvals(client?.contractAddress, args), () => client ? client.approvals({ @@ -262,21 +275,21 @@ export function useAccountNftApprovalsQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftApprovalQuery - extends AccountNftReactQuery { +export interface MarsAccountNftApprovalQuery + extends MarsAccountNftReactQuery { args: { includeExpired?: boolean spender: string tokenId: string } } -export function useAccountNftApprovalQuery({ +export function useMarsAccountNftApprovalQuery({ client, args, options, -}: AccountNftApprovalQuery) { +}: MarsAccountNftApprovalQuery) { return useQuery( - accountNftQueryKeys.approval(client?.contractAddress, args), + marsAccountNftQueryKeys.approval(client?.contractAddress, args), () => client ? client.approval({ @@ -288,20 +301,20 @@ export function useAccountNftApprovalQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftOwnerOfQuery - extends AccountNftReactQuery { +export interface MarsAccountNftOwnerOfQuery + extends MarsAccountNftReactQuery { args: { includeExpired?: boolean tokenId: string } } -export function useAccountNftOwnerOfQuery({ +export function useMarsAccountNftOwnerOfQuery({ client, args, options, -}: AccountNftOwnerOfQuery) { +}: MarsAccountNftOwnerOfQuery) { return useQuery( - accountNftQueryKeys.ownerOf(client?.contractAddress, args), + marsAccountNftQueryKeys.ownerOf(client?.contractAddress, args), () => client ? client.ownerOf({ @@ -312,20 +325,20 @@ export function useAccountNftOwnerOfQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftProposedNewOwnerQuery - extends AccountNftReactQuery {} -export function useAccountNftProposedNewOwnerQuery({ +export interface MarsAccountNftProposedNewOwnerQuery + extends MarsAccountNftReactQuery {} +export function useMarsAccountNftProposedNewOwnerQuery({ client, options, -}: AccountNftProposedNewOwnerQuery) { +}: MarsAccountNftProposedNewOwnerQuery) { return useQuery( - accountNftQueryKeys.proposedNewOwner(client?.contractAddress), + marsAccountNftQueryKeys.proposedNewOwner(client?.contractAddress), () => (client ? client.proposedNewOwner() : Promise.reject(new Error('Invalid client'))), { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface AccountNftBurnMutation { - client: AccountNftClient +export interface MarsAccountNftBurnMutation { + client: MarsAccountNftClient msg: { tokenId: string } @@ -335,16 +348,19 @@ export interface AccountNftBurnMutation { funds?: Coin[] } } -export function useAccountNftBurnMutation( - options?: Omit, 'mutationFn'>, +export function useMarsAccountNftBurnMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.burn(msg, fee, memo, funds), options, ) } -export interface AccountNftRevokeAllMutation { - client: AccountNftClient +export interface MarsAccountNftRevokeAllMutation { + client: MarsAccountNftClient msg: { operator: string } @@ -354,19 +370,19 @@ export interface AccountNftRevokeAllMutation { funds?: Coin[] } } -export function useAccountNftRevokeAllMutation( +export function useMarsAccountNftRevokeAllMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.revokeAll(msg, fee, memo, funds), options, ) } -export interface AccountNftApproveAllMutation { - client: AccountNftClient +export interface MarsAccountNftApproveAllMutation { + client: MarsAccountNftClient msg: { expires?: Expiration operator: string @@ -377,19 +393,19 @@ export interface AccountNftApproveAllMutation { funds?: Coin[] } } -export function useAccountNftApproveAllMutation( +export function useMarsAccountNftApproveAllMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.approveAll(msg, fee, memo, funds), options, ) } -export interface AccountNftRevokeMutation { - client: AccountNftClient +export interface MarsAccountNftRevokeMutation { + client: MarsAccountNftClient msg: { spender: string tokenId: string @@ -400,16 +416,19 @@ export interface AccountNftRevokeMutation { funds?: Coin[] } } -export function useAccountNftRevokeMutation( - options?: Omit, 'mutationFn'>, +export function useMarsAccountNftRevokeMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.revoke(msg, fee, memo, funds), options, ) } -export interface AccountNftApproveMutation { - client: AccountNftClient +export interface MarsAccountNftApproveMutation { + client: MarsAccountNftClient msg: { expires?: Expiration spender: string @@ -421,16 +440,19 @@ export interface AccountNftApproveMutation { funds?: Coin[] } } -export function useAccountNftApproveMutation( - options?: Omit, 'mutationFn'>, +export function useMarsAccountNftApproveMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.approve(msg, fee, memo, funds), options, ) } -export interface AccountNftSendNftMutation { - client: AccountNftClient +export interface MarsAccountNftSendNftMutation { + client: MarsAccountNftClient msg: { contract: string msg: Binary @@ -442,16 +464,19 @@ export interface AccountNftSendNftMutation { funds?: Coin[] } } -export function useAccountNftSendNftMutation( - options?: Omit, 'mutationFn'>, +export function useMarsAccountNftSendNftMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.sendNft(msg, fee, memo, funds), options, ) } -export interface AccountNftTransferNftMutation { - client: AccountNftClient +export interface MarsAccountNftTransferNftMutation { + client: MarsAccountNftClient msg: { recipient: string tokenId: string @@ -462,19 +487,19 @@ export interface AccountNftTransferNftMutation { funds?: Coin[] } } -export function useAccountNftTransferNftMutation( +export function useMarsAccountNftTransferNftMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.transferNft(msg, fee, memo, funds), options, ) } -export interface AccountNftMintMutation { - client: AccountNftClient +export interface MarsAccountNftMintMutation { + client: MarsAccountNftClient msg: { user: string } @@ -484,35 +509,38 @@ export interface AccountNftMintMutation { funds?: Coin[] } } -export function useAccountNftMintMutation( - options?: Omit, 'mutationFn'>, +export function useMarsAccountNftMintMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.mint(msg, fee, memo, funds), options, ) } -export interface AccountNftAcceptOwnershipMutation { - client: AccountNftClient +export interface MarsAccountNftAcceptOwnershipMutation { + client: MarsAccountNftClient args?: { fee?: number | StdFee | 'auto' memo?: string funds?: Coin[] } } -export function useAccountNftAcceptOwnershipMutation( +export function useMarsAccountNftAcceptOwnershipMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, args: { fee, memo, funds } = {} }) => client.acceptOwnership(fee, memo, funds), options, ) } -export interface AccountNftProposeNewOwnerMutation { - client: AccountNftClient +export interface MarsAccountNftProposeNewOwnerMutation { + client: MarsAccountNftClient msg: { newOwner: string } @@ -522,13 +550,13 @@ export interface AccountNftProposeNewOwnerMutation { funds?: Coin[] } } -export function useAccountNftProposeNewOwnerMutation( +export function useMarsAccountNftProposeNewOwnerMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.proposeNewOwner(msg, fee, memo, funds), options, diff --git a/types/generated/account-nft/AccountNft.types.ts b/types/generated/mars-account-nft/MarsAccountNft.types.ts similarity index 99% rename from types/generated/account-nft/AccountNft.types.ts rename to types/generated/mars-account-nft/MarsAccountNft.types.ts index 84408b14..062be620 100644 --- a/types/generated/account-nft/AccountNft.types.ts +++ b/types/generated/mars-account-nft/MarsAccountNft.types.ts @@ -1,6 +1,6 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ diff --git a/types/generated/credit-manager/bundle.ts b/types/generated/mars-account-nft/bundle.ts similarity index 50% rename from types/generated/credit-manager/bundle.ts rename to types/generated/mars-account-nft/bundle.ts index d1b8912c..b6237eba 100644 --- a/types/generated/credit-manager/bundle.ts +++ b/types/generated/mars-account-nft/bundle.ts @@ -1,13 +1,14 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _4 from './CreditManager.client' -import * as _5 from './CreditManager.react-query' -import * as _3 from './CreditManager.types' +import * as _0 from './MarsAccountNft.types' +import * as _1 from './MarsAccountNft.client' +import * as _2 from './MarsAccountNft.message-composer' +import * as _3 from './MarsAccountNft.react-query' export namespace contracts { - export const CreditManager = { ..._3, ..._4, ..._5 } + export const MarsAccountNft = { ..._0, ..._1, ..._2, ..._3 } } diff --git a/types/generated/credit-manager/CreditManager.client.ts b/types/generated/mars-credit-manager/MarsCreditManager.client.ts similarity index 82% rename from types/generated/credit-manager/CreditManager.client.ts rename to types/generated/mars-credit-manager/MarsCreditManager.client.ts index 93763a88..2599bb9a 100644 --- a/types/generated/credit-manager/CreditManager.client.ts +++ b/types/generated/mars-credit-manager/MarsCreditManager.client.ts @@ -1,58 +1,66 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' -import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' - import { - Action, - Addr, - ArrayOfCoinBalanceResponseItem, - ArrayOfDebtShares, - ArrayOfSharesResponseItem, - ArrayOfString, - ArrayOfVaultBaseForString, - ArrayOfVaultPositionResponseItem, - ArrayOfVaultWithBalance, - CallbackMsg, - Coin, - CoinBalanceResponseItem, - ConfigResponse, - ConfigUpdates, - DebtAmount, - DebtShares, - Decimal, - ExecuteMsg, - HealthResponse, - InstantiateMsg, - OracleBaseForString, - Positions, - QueryMsg, - RedBankBaseForString, - SharesResponseItem, - SwapperBaseForString, Uint128, - VaultBaseForAddr, + Decimal, + OracleBaseForString, + RedBankBaseForString, + SwapperBaseForString, + ZapperBaseForString, + InstantiateMsg, + VaultInstantiateConfig, + VaultConfig, + Coin, VaultBaseForString, - VaultPosition, - VaultPositionResponseItem, - VaultPositionState, + ExecuteMsg, + Action, + CallbackMsg, + Addr, + ConfigUpdates, + VaultBaseForAddr, + QueryMsg, + ArrayOfCoinBalanceResponseItem, + CoinBalanceResponseItem, + ArrayOfSharesResponseItem, + SharesResponseItem, + ArrayOfDebtShares, + DebtShares, + ArrayOfVaultWithBalance, VaultWithBalance, -} from './CreditManager.types' -export interface CreditManagerReadOnlyInterface { + VaultPositionAmount, + VaultAmount, + VaultAmount1, + UnlockingPositions, + ArrayOfVaultPositionResponseItem, + VaultPositionResponseItem, + VaultPosition, + LockingVaultAmount, + VaultUnlockingPosition, + ArrayOfString, + ConfigResponse, + ArrayOfCoin, + HealthResponse, + Positions, + DebtAmount, + ArrayOfVaultInstantiateConfig, +} from './MarsCreditManager.types' +export interface MarsCreditManagerReadOnlyInterface { contractAddress: string config: () => Promise - allowedVaults: ({ + vaultConfigs: ({ limit, startAfter, }: { limit?: number startAfter?: VaultBaseForString - }) => Promise + }) => Promise allowedCoins: ({ limit, startAfter, @@ -99,8 +107,16 @@ export interface CreditManagerReadOnlyInterface { limit?: number startAfter?: VaultBaseForString }) => Promise + estimateProvideLiquidity: ({ + coinsIn, + lpTokenOut, + }: { + coinsIn: Coin[] + lpTokenOut: string + }) => Promise + estimateWithdrawLiquidity: ({ lpToken }: { lpToken: Coin }) => Promise } -export class CreditManagerQueryClient implements CreditManagerReadOnlyInterface { +export class MarsCreditManagerQueryClient implements MarsCreditManagerReadOnlyInterface { client: CosmWasmClient contractAddress: string @@ -108,7 +124,7 @@ export class CreditManagerQueryClient implements CreditManagerReadOnlyInterface this.client = client this.contractAddress = contractAddress this.config = this.config.bind(this) - this.allowedVaults = this.allowedVaults.bind(this) + this.vaultConfigs = this.vaultConfigs.bind(this) this.allowedCoins = this.allowedCoins.bind(this) this.positions = this.positions.bind(this) this.health = this.health.bind(this) @@ -119,6 +135,8 @@ export class CreditManagerQueryClient implements CreditManagerReadOnlyInterface this.allVaultPositions = this.allVaultPositions.bind(this) this.totalVaultCoinBalance = this.totalVaultCoinBalance.bind(this) this.allTotalVaultCoinBalances = this.allTotalVaultCoinBalances.bind(this) + this.estimateProvideLiquidity = this.estimateProvideLiquidity.bind(this) + this.estimateWithdrawLiquidity = this.estimateWithdrawLiquidity.bind(this) } config = async (): Promise => { @@ -126,15 +144,15 @@ export class CreditManagerQueryClient implements CreditManagerReadOnlyInterface config: {}, }) } - allowedVaults = async ({ + vaultConfigs = async ({ limit, startAfter, }: { limit?: number startAfter?: VaultBaseForString - }): Promise => { + }): Promise => { return this.client.queryContractSmart(this.contractAddress, { - allowed_vaults: { + vault_configs: { limit, start_after: startAfter, }, @@ -250,8 +268,29 @@ export class CreditManagerQueryClient implements CreditManagerReadOnlyInterface }, }) } + estimateProvideLiquidity = async ({ + coinsIn, + lpTokenOut, + }: { + coinsIn: Coin[] + lpTokenOut: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + estimate_provide_liquidity: { + coins_in: coinsIn, + lp_token_out: lpTokenOut, + }, + }) + } + estimateWithdrawLiquidity = async ({ lpToken }: { lpToken: Coin }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + estimate_withdraw_liquidity: { + lp_token: lpToken, + }, + }) + } } -export interface CreditManagerInterface extends CreditManagerReadOnlyInterface { +export interface MarsCreditManagerInterface extends MarsCreditManagerReadOnlyInterface { contractAddress: string sender: string createCreditAccount: ( @@ -287,9 +326,9 @@ export interface CreditManagerInterface extends CreditManagerReadOnlyInterface { funds?: Coin[], ) => Promise } -export class CreditManagerClient - extends CreditManagerQueryClient - implements CreditManagerInterface +export class MarsCreditManagerClient + extends MarsCreditManagerQueryClient + implements MarsCreditManagerInterface { client: SigningCosmWasmClient sender: string diff --git a/types/generated/mars-credit-manager/MarsCreditManager.message-composer.ts b/types/generated/mars-credit-manager/MarsCreditManager.message-composer.ts new file mode 100644 index 00000000..b628fa4e --- /dev/null +++ b/types/generated/mars-credit-manager/MarsCreditManager.message-composer.ts @@ -0,0 +1,173 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + Uint128, + Decimal, + OracleBaseForString, + RedBankBaseForString, + SwapperBaseForString, + ZapperBaseForString, + InstantiateMsg, + VaultInstantiateConfig, + VaultConfig, + Coin, + VaultBaseForString, + ExecuteMsg, + Action, + CallbackMsg, + Addr, + ConfigUpdates, + VaultBaseForAddr, + QueryMsg, + ArrayOfCoinBalanceResponseItem, + CoinBalanceResponseItem, + ArrayOfSharesResponseItem, + SharesResponseItem, + ArrayOfDebtShares, + DebtShares, + ArrayOfVaultWithBalance, + VaultWithBalance, + VaultPositionAmount, + VaultAmount, + VaultAmount1, + UnlockingPositions, + ArrayOfVaultPositionResponseItem, + VaultPositionResponseItem, + VaultPosition, + LockingVaultAmount, + VaultUnlockingPosition, + ArrayOfString, + ConfigResponse, + ArrayOfCoin, + HealthResponse, + Positions, + DebtAmount, + ArrayOfVaultInstantiateConfig, +} from './MarsCreditManager.types' +export interface MarsCreditManagerMessage { + contractAddress: string + sender: string + createCreditAccount: (funds?: Coin[]) => MsgExecuteContractEncodeObject + updateCreditAccount: ( + { + accountId, + actions, + }: { + accountId: string + actions: Action[] + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + updateConfig: ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + callback: (funds?: Coin[]) => MsgExecuteContractEncodeObject +} +export class MarsCreditManagerMessageComposer implements MarsCreditManagerMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.createCreditAccount = this.createCreditAccount.bind(this) + this.updateCreditAccount = this.updateCreditAccount.bind(this) + this.updateConfig = this.updateConfig.bind(this) + this.callback = this.callback.bind(this) + } + + createCreditAccount = (funds?: Coin[]): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + create_credit_account: {}, + }), + ), + funds, + }), + } + } + updateCreditAccount = ( + { + accountId, + actions, + }: { + accountId: string + actions: Action[] + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_credit_account: { + account_id: accountId, + actions, + }, + }), + ), + funds, + }), + } + } + updateConfig = ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_config: { + new_config: newConfig, + }, + }), + ), + funds, + }), + } + } + callback = (funds?: Coin[]): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + callback: {}, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/mars-credit-manager/MarsCreditManager.react-query.ts b/types/generated/mars-credit-manager/MarsCreditManager.react-query.ts new file mode 100644 index 00000000..b0f029ce --- /dev/null +++ b/types/generated/mars-credit-manager/MarsCreditManager.react-query.ts @@ -0,0 +1,557 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + Uint128, + Decimal, + OracleBaseForString, + RedBankBaseForString, + SwapperBaseForString, + ZapperBaseForString, + InstantiateMsg, + VaultInstantiateConfig, + VaultConfig, + Coin, + VaultBaseForString, + ExecuteMsg, + Action, + CallbackMsg, + Addr, + ConfigUpdates, + VaultBaseForAddr, + QueryMsg, + ArrayOfCoinBalanceResponseItem, + CoinBalanceResponseItem, + ArrayOfSharesResponseItem, + SharesResponseItem, + ArrayOfDebtShares, + DebtShares, + ArrayOfVaultWithBalance, + VaultWithBalance, + VaultPositionAmount, + VaultAmount, + VaultAmount1, + UnlockingPositions, + ArrayOfVaultPositionResponseItem, + VaultPositionResponseItem, + VaultPosition, + LockingVaultAmount, + VaultUnlockingPosition, + ArrayOfString, + ConfigResponse, + ArrayOfCoin, + HealthResponse, + Positions, + DebtAmount, + ArrayOfVaultInstantiateConfig, +} from './MarsCreditManager.types' +import { MarsCreditManagerQueryClient, MarsCreditManagerClient } from './MarsCreditManager.client' +export const marsCreditManagerQueryKeys = { + contract: [ + { + contract: 'marsCreditManager', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...marsCreditManagerQueryKeys.contract[0], address: contractAddress }] as const, + config: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'config', args }, + ] as const, + vaultConfigs: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'vault_configs', args }, + ] as const, + allowedCoins: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'allowed_coins', args }, + ] as const, + positions: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'positions', args }, + ] as const, + health: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'health', args }, + ] as const, + allCoinBalances: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'all_coin_balances', + args, + }, + ] as const, + allDebtShares: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'all_debt_shares', + args, + }, + ] as const, + totalDebtShares: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'total_debt_shares', + args, + }, + ] as const, + allTotalDebtShares: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'all_total_debt_shares', + args, + }, + ] as const, + allVaultPositions: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'all_vault_positions', + args, + }, + ] as const, + totalVaultCoinBalance: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'total_vault_coin_balance', + args, + }, + ] as const, + allTotalVaultCoinBalances: ( + contractAddress: string | undefined, + args?: Record, + ) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'all_total_vault_coin_balances', + args, + }, + ] as const, + estimateProvideLiquidity: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'estimate_provide_liquidity', + args, + }, + ] as const, + estimateWithdrawLiquidity: ( + contractAddress: string | undefined, + args?: Record, + ) => + [ + { + ...marsCreditManagerQueryKeys.address(contractAddress)[0], + method: 'estimate_withdraw_liquidity', + args, + }, + ] as const, +} +export interface MarsCreditManagerReactQuery { + client: MarsCreditManagerQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MarsCreditManagerEstimateWithdrawLiquidityQuery + extends MarsCreditManagerReactQuery { + args: { + lpToken: Coin + } +} +export function useMarsCreditManagerEstimateWithdrawLiquidityQuery({ + client, + args, + options, +}: MarsCreditManagerEstimateWithdrawLiquidityQuery) { + return useQuery( + marsCreditManagerQueryKeys.estimateWithdrawLiquidity(client?.contractAddress, args), + () => + client + ? client.estimateWithdrawLiquidity({ + lpToken: args.lpToken, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerEstimateProvideLiquidityQuery + extends MarsCreditManagerReactQuery { + args: { + coinsIn: Coin[] + lpTokenOut: string + } +} +export function useMarsCreditManagerEstimateProvideLiquidityQuery({ + client, + args, + options, +}: MarsCreditManagerEstimateProvideLiquidityQuery) { + return useQuery( + marsCreditManagerQueryKeys.estimateProvideLiquidity(client?.contractAddress, args), + () => + client + ? client.estimateProvideLiquidity({ + coinsIn: args.coinsIn, + lpTokenOut: args.lpTokenOut, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerAllTotalVaultCoinBalancesQuery + extends MarsCreditManagerReactQuery { + args: { + limit?: number + startAfter?: VaultBaseForString + } +} +export function useMarsCreditManagerAllTotalVaultCoinBalancesQuery< + TData = ArrayOfVaultWithBalance, +>({ client, args, options }: MarsCreditManagerAllTotalVaultCoinBalancesQuery) { + return useQuery( + marsCreditManagerQueryKeys.allTotalVaultCoinBalances(client?.contractAddress, args), + () => + client + ? client.allTotalVaultCoinBalances({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerTotalVaultCoinBalanceQuery + extends MarsCreditManagerReactQuery { + args: { + vault: VaultBaseForString + } +} +export function useMarsCreditManagerTotalVaultCoinBalanceQuery({ + client, + args, + options, +}: MarsCreditManagerTotalVaultCoinBalanceQuery) { + return useQuery( + marsCreditManagerQueryKeys.totalVaultCoinBalance(client?.contractAddress, args), + () => + client + ? client.totalVaultCoinBalance({ + vault: args.vault, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerAllVaultPositionsQuery + extends MarsCreditManagerReactQuery { + args: { + limit?: number + startAfter?: string[][] + } +} +export function useMarsCreditManagerAllVaultPositionsQuery< + TData = ArrayOfVaultPositionResponseItem, +>({ client, args, options }: MarsCreditManagerAllVaultPositionsQuery) { + return useQuery( + marsCreditManagerQueryKeys.allVaultPositions(client?.contractAddress, args), + () => + client + ? client.allVaultPositions({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerAllTotalDebtSharesQuery + extends MarsCreditManagerReactQuery { + args: { + limit?: number + startAfter?: string + } +} +export function useMarsCreditManagerAllTotalDebtSharesQuery({ + client, + args, + options, +}: MarsCreditManagerAllTotalDebtSharesQuery) { + return useQuery( + marsCreditManagerQueryKeys.allTotalDebtShares(client?.contractAddress, args), + () => + client + ? client.allTotalDebtShares({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerTotalDebtSharesQuery + extends MarsCreditManagerReactQuery {} +export function useMarsCreditManagerTotalDebtSharesQuery({ + client, + options, +}: MarsCreditManagerTotalDebtSharesQuery) { + return useQuery( + marsCreditManagerQueryKeys.totalDebtShares(client?.contractAddress), + () => (client ? client.totalDebtShares() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerAllDebtSharesQuery + extends MarsCreditManagerReactQuery { + args: { + limit?: number + startAfter?: string[][] + } +} +export function useMarsCreditManagerAllDebtSharesQuery({ + client, + args, + options, +}: MarsCreditManagerAllDebtSharesQuery) { + return useQuery( + marsCreditManagerQueryKeys.allDebtShares(client?.contractAddress, args), + () => + client + ? client.allDebtShares({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerAllCoinBalancesQuery + extends MarsCreditManagerReactQuery { + args: { + limit?: number + startAfter?: string[][] + } +} +export function useMarsCreditManagerAllCoinBalancesQuery({ + client, + args, + options, +}: MarsCreditManagerAllCoinBalancesQuery) { + return useQuery( + marsCreditManagerQueryKeys.allCoinBalances(client?.contractAddress, args), + () => + client + ? client.allCoinBalances({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerHealthQuery + extends MarsCreditManagerReactQuery { + args: { + accountId: string + } +} +export function useMarsCreditManagerHealthQuery({ + client, + args, + options, +}: MarsCreditManagerHealthQuery) { + return useQuery( + marsCreditManagerQueryKeys.health(client?.contractAddress, args), + () => + client + ? client.health({ + accountId: args.accountId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerPositionsQuery + extends MarsCreditManagerReactQuery { + args: { + accountId: string + } +} +export function useMarsCreditManagerPositionsQuery({ + client, + args, + options, +}: MarsCreditManagerPositionsQuery) { + return useQuery( + marsCreditManagerQueryKeys.positions(client?.contractAddress, args), + () => + client + ? client.positions({ + accountId: args.accountId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerAllowedCoinsQuery + extends MarsCreditManagerReactQuery { + args: { + limit?: number + startAfter?: string + } +} +export function useMarsCreditManagerAllowedCoinsQuery({ + client, + args, + options, +}: MarsCreditManagerAllowedCoinsQuery) { + return useQuery( + marsCreditManagerQueryKeys.allowedCoins(client?.contractAddress, args), + () => + client + ? client.allowedCoins({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerVaultConfigsQuery + extends MarsCreditManagerReactQuery { + args: { + limit?: number + startAfter?: VaultBaseForString + } +} +export function useMarsCreditManagerVaultConfigsQuery({ + client, + args, + options, +}: MarsCreditManagerVaultConfigsQuery) { + return useQuery( + marsCreditManagerQueryKeys.vaultConfigs(client?.contractAddress, args), + () => + client + ? client.vaultConfigs({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerConfigQuery + extends MarsCreditManagerReactQuery {} +export function useMarsCreditManagerConfigQuery({ + client, + options, +}: MarsCreditManagerConfigQuery) { + return useQuery( + marsCreditManagerQueryKeys.config(client?.contractAddress), + () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsCreditManagerCallbackMutation { + client: MarsCreditManagerClient + msg: CallbackMsg + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsCreditManagerCallbackMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.callback(msg, fee, memo, funds), + options, + ) +} +export interface MarsCreditManagerUpdateConfigMutation { + client: MarsCreditManagerClient + msg: { + newConfig: ConfigUpdates + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsCreditManagerUpdateConfigMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateConfig(msg, fee, memo, funds), + options, + ) +} +export interface MarsCreditManagerUpdateCreditAccountMutation { + client: MarsCreditManagerClient + msg: { + accountId: string + actions: Action[] + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsCreditManagerUpdateCreditAccountMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateCreditAccount(msg, fee, memo, funds), + options, + ) +} +export interface MarsCreditManagerCreateCreditAccountMutation { + client: MarsCreditManagerClient + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsCreditManagerCreateCreditAccountMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, args: { fee, memo, funds } = {} }) => client.createCreditAccount(fee, memo, funds), + options, + ) +} diff --git a/types/generated/credit-manager/CreditManager.types.ts b/types/generated/mars-credit-manager/MarsCreditManager.types.ts similarity index 67% rename from types/generated/credit-manager/CreditManager.types.ts rename to types/generated/mars-credit-manager/MarsCreditManager.types.ts index 9268d76e..5cefad83 100644 --- a/types/generated/credit-manager/CreditManager.types.ts +++ b/types/generated/mars-credit-manager/MarsCreditManager.types.ts @@ -1,23 +1,41 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ +export type Uint128 = string export type Decimal = string export type OracleBaseForString = string export type RedBankBaseForString = string export type SwapperBaseForString = string +export type ZapperBaseForString = string export interface InstantiateMsg { allowed_coins: string[] - allowed_vaults: VaultBaseForString[] + allowed_vaults: VaultInstantiateConfig[] max_close_factor: Decimal max_liquidation_bonus: Decimal oracle: OracleBaseForString owner: string red_bank: RedBankBaseForString swapper: SwapperBaseForString + zapper: ZapperBaseForString +} +export interface VaultInstantiateConfig { + config: VaultConfig + vault: VaultBaseForString +} +export interface VaultConfig { + deposit_cap: Coin + liquidation_threshold: Decimal + max_ltv: Decimal + whitelisted: boolean +} +export interface Coin { + amount: Uint128 + denom: string + [k: string]: unknown } export interface VaultBaseForString { address: string @@ -54,17 +72,30 @@ export type Action = repay: Coin } | { - vault_deposit: { - coins: Coin[] + enter_vault: { + amount?: Uint128 | null + denom: string vault: VaultBaseForString } } | { - vault_withdraw: { + exit_vault: { amount: Uint128 vault: VaultBaseForString } } + | { + request_vault_unlock: { + amount: Uint128 + vault: VaultBaseForString + } + } + | { + exit_vault_unlocked: { + id: number + vault: VaultBaseForString + } + } | { liquidate_coin: { debt_coin: Coin @@ -72,6 +103,13 @@ export type Action = request_coin_denom: string } } + | { + liquidate_vault: { + debt_coin: Coin + liquidatee_account_id: string + request_vault: VaultBaseForString + } + } | { swap_exact_in: { coin_in: Coin @@ -79,7 +117,21 @@ export type Action = slippage: Decimal } } -export type Uint128 = string + | { + provide_liquidity: { + coins_in: Coin[] + lp_token_out: string + minimum_receive: Uint128 + } + } + | { + withdraw_liquidity: { + lp_token: Coin + } + } + | { + refund_all_coin_balances: {} + } export type CallbackMsg = | { withdraw: { @@ -106,9 +158,17 @@ export type CallbackMsg = } } | { - vault_deposit: { + enter_vault: { account_id: string - coins: Coin[] + amount?: Uint128 | null + denom: string + vault: VaultBaseForAddr + } + } + | { + exit_vault: { + account_id: string + amount: Uint128 vault: VaultBaseForAddr } } @@ -120,19 +180,26 @@ export type CallbackMsg = } } | { - vault_withdraw: { + force_exit_vault: { account_id: string amount: Uint128 vault: VaultBaseForAddr } } | { - vault_force_withdraw: { + request_vault_unlock: { account_id: string amount: Uint128 vault: VaultBaseForAddr } } + | { + exit_vault_unlocked: { + account_id: string + position_id: number + vault: VaultBaseForAddr + } + } | { liquidate_coin: { debt_coin: Coin @@ -142,9 +209,11 @@ export type CallbackMsg = } } | { - assert_health_factor_improved: { - account_id: string - previous_health_factor: Decimal + liquidate_vault: { + debt_coin: Coin + liquidatee_account_id: string + liquidator_account_id: string + request_vault: VaultBaseForAddr } } | { @@ -156,27 +225,47 @@ export type CallbackMsg = } } | { - update_coin_balances: { + update_coin_balance: { + account_id: string + previous_balance: Coin + } + } + | { + provide_liquidity: { + account_id: string + coins_in: Coin[] + lp_token_out: string + minimum_receive: Uint128 + } + } + | { + withdraw_liquidity: { + account_id: string + lp_token: Coin + } + } + | { + assert_one_vault_position_only: { + account_id: string + } + } + | { + refund_all_coin_balances: { account_id: string - previous_balances: Coin[] } } export type Addr = string -export interface Coin { - amount: Uint128 - denom: string - [k: string]: unknown -} export interface ConfigUpdates { account_nft?: string | null allowed_coins?: string[] | null - allowed_vaults?: VaultBaseForString[] | null max_close_factor?: Decimal | null max_liquidation_bonus?: Decimal | null oracle?: OracleBaseForString | null owner?: string | null red_bank?: RedBankBaseForString | null swapper?: SwapperBaseForString | null + vault_configs?: VaultInstantiateConfig[] | null + zapper?: ZapperBaseForString | null } export interface VaultBaseForAddr { address: Addr @@ -186,7 +275,7 @@ export type QueryMsg = config: {} } | { - allowed_vaults: { + vault_configs: { limit?: number | null start_after?: VaultBaseForString | null } @@ -245,6 +334,17 @@ export type QueryMsg = start_after?: VaultBaseForString | null } } + | { + estimate_provide_liquidity: { + coins_in: Coin[] + lp_token_out: string + } + } + | { + estimate_withdraw_liquidity: { + lp_token: Coin + } + } export type ArrayOfCoinBalanceResponseItem = CoinBalanceResponseItem[] export interface CoinBalanceResponseItem { account_id: string @@ -267,21 +367,34 @@ export interface VaultWithBalance { balance: Uint128 vault: VaultBaseForAddr } +export type VaultPositionAmount = + | { + unlocked: VaultAmount + } + | { + locking: LockingVaultAmount + } +export type VaultAmount = string +export type VaultAmount1 = string +export type UnlockingPositions = VaultUnlockingPosition[] export type ArrayOfVaultPositionResponseItem = VaultPositionResponseItem[] export interface VaultPositionResponseItem { account_id: string position: VaultPosition } export interface VaultPosition { - state: VaultPositionState + amount: VaultPositionAmount vault: VaultBaseForAddr } -export interface VaultPositionState { - locked: Uint128 - unlocked: Uint128 +export interface LockingVaultAmount { + locked: VaultAmount1 + unlocking: UnlockingPositions +} +export interface VaultUnlockingPosition { + coin: Coin + id: number } export type ArrayOfString = string[] -export type ArrayOfVaultBaseForString = VaultBaseForString[] export interface ConfigResponse { account_nft?: string | null max_close_factor: Decimal @@ -290,7 +403,9 @@ export interface ConfigResponse { owner: string red_bank: string swapper: string + zapper: string } +export type ArrayOfCoin = Coin[] export interface HealthResponse { above_max_ltv: boolean liquidatable: boolean @@ -312,3 +427,4 @@ export interface DebtAmount { denom: string shares: Uint128 } +export type ArrayOfVaultInstantiateConfig = VaultInstantiateConfig[] diff --git a/types/generated/mars-credit-manager/bundle.ts b/types/generated/mars-credit-manager/bundle.ts new file mode 100644 index 00000000..5878326c --- /dev/null +++ b/types/generated/mars-credit-manager/bundle.ts @@ -0,0 +1,14 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _4 from './MarsCreditManager.types' +import * as _5 from './MarsCreditManager.client' +import * as _6 from './MarsCreditManager.message-composer' +import * as _7 from './MarsCreditManager.react-query' +export namespace contracts { + export const MarsCreditManager = { ..._4, ..._5, ..._6, ..._7 } +} diff --git a/types/generated/mock-oracle/MockOracle.client.ts b/types/generated/mars-mock-oracle/MarsMockOracle.client.ts similarity index 82% rename from types/generated/mock-oracle/MockOracle.client.ts rename to types/generated/mars-mock-oracle/MarsMockOracle.client.ts index b88a6453..2a4748b5 100644 --- a/types/generated/mock-oracle/MockOracle.client.ts +++ b/types/generated/mars-mock-oracle/MarsMockOracle.client.ts @@ -1,26 +1,25 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { Coin, StdFee } from '@cosmjs/amino' -import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' - import { - CoinPrice, Decimal, - ExecuteMsg, InstantiateMsg, - PriceResponse, + CoinPrice, + ExecuteMsg, QueryMsg, -} from './MockOracle.types' -export interface MockOracleReadOnlyInterface { + PriceResponse, +} from './MarsMockOracle.types' +export interface MarsMockOracleReadOnlyInterface { contractAddress: string price: ({ denom }: { denom: string }) => Promise } -export class MockOracleQueryClient implements MockOracleReadOnlyInterface { +export class MarsMockOracleQueryClient implements MarsMockOracleReadOnlyInterface { client: CosmWasmClient contractAddress: string @@ -38,7 +37,7 @@ export class MockOracleQueryClient implements MockOracleReadOnlyInterface { }) } } -export interface MockOracleInterface extends MockOracleReadOnlyInterface { +export interface MarsMockOracleInterface extends MarsMockOracleReadOnlyInterface { contractAddress: string sender: string changePrice: ( @@ -54,7 +53,10 @@ export interface MockOracleInterface extends MockOracleReadOnlyInterface { funds?: Coin[], ) => Promise } -export class MockOracleClient extends MockOracleQueryClient implements MockOracleInterface { +export class MarsMockOracleClient + extends MarsMockOracleQueryClient + implements MarsMockOracleInterface +{ client: SigningCosmWasmClient sender: string contractAddress: string diff --git a/types/generated/mars-mock-oracle/MarsMockOracle.message-composer.ts b/types/generated/mars-mock-oracle/MarsMockOracle.message-composer.ts new file mode 100644 index 00000000..6db18084 --- /dev/null +++ b/types/generated/mars-mock-oracle/MarsMockOracle.message-composer.ts @@ -0,0 +1,71 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { Coin } from '@cosmjs/amino' +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + Decimal, + InstantiateMsg, + CoinPrice, + ExecuteMsg, + QueryMsg, + PriceResponse, +} from './MarsMockOracle.types' +export interface MarsMockOracleMessage { + contractAddress: string + sender: string + changePrice: ( + { + denom, + price, + }: { + denom: string + price: Decimal + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject +} +export class MarsMockOracleMessageComposer implements MarsMockOracleMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.changePrice = this.changePrice.bind(this) + } + + changePrice = ( + { + denom, + price, + }: { + denom: string + price: Decimal + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + change_price: { + denom, + price, + }, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/mock-oracle/MockOracle.react-query.ts b/types/generated/mars-mock-oracle/MarsMockOracle.react-query.ts similarity index 53% rename from types/generated/mock-oracle/MockOracle.react-query.ts rename to types/generated/mars-mock-oracle/MarsMockOracle.react-query.ts index 6c9a7324..a255e74a 100644 --- a/types/generated/mock-oracle/MockOracle.react-query.ts +++ b/types/generated/mars-mock-oracle/MarsMockOracle.react-query.ts @@ -1,36 +1,35 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { Coin, StdFee } from '@cosmjs/amino' +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { MockOracleClient, MockOracleQueryClient } from './MockOracle.client' +import { StdFee, Coin } from '@cosmjs/amino' import { - CoinPrice, Decimal, - ExecuteMsg, InstantiateMsg, - PriceResponse, + CoinPrice, + ExecuteMsg, QueryMsg, -} from './MockOracle.types' -export const mockOracleQueryKeys = { + PriceResponse, +} from './MarsMockOracle.types' +import { MarsMockOracleQueryClient, MarsMockOracleClient } from './MarsMockOracle.client' +export const marsMockOracleQueryKeys = { contract: [ { - contract: 'mockOracle', + contract: 'marsMockOracle', }, ] as const, address: (contractAddress: string | undefined) => - [{ ...mockOracleQueryKeys.contract[0], address: contractAddress }] as const, + [{ ...marsMockOracleQueryKeys.contract[0], address: contractAddress }] as const, price: (contractAddress: string | undefined, args?: Record) => - [{ ...mockOracleQueryKeys.address(contractAddress)[0], method: 'price', args }] as const, + [{ ...marsMockOracleQueryKeys.address(contractAddress)[0], method: 'price', args }] as const, } -export interface MockOracleReactQuery { - client: MockOracleQueryClient | undefined +export interface MarsMockOracleReactQuery { + client: MarsMockOracleQueryClient | undefined options?: Omit< UseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'" @@ -38,18 +37,19 @@ export interface MockOracleReactQuery { initialData?: undefined } } -export interface MockOraclePriceQuery extends MockOracleReactQuery { +export interface MarsMockOraclePriceQuery + extends MarsMockOracleReactQuery { args: { denom: string } } -export function useMockOraclePriceQuery({ +export function useMarsMockOraclePriceQuery({ client, args, options, -}: MockOraclePriceQuery) { +}: MarsMockOraclePriceQuery) { return useQuery( - mockOracleQueryKeys.price(client?.contractAddress, args), + marsMockOracleQueryKeys.price(client?.contractAddress, args), () => client ? client.price({ @@ -59,8 +59,8 @@ export function useMockOraclePriceQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface MockOracleChangePriceMutation { - client: MockOracleClient +export interface MarsMockOracleChangePriceMutation { + client: MarsMockOracleClient msg: CoinPrice args?: { fee?: number | StdFee | 'auto' @@ -68,13 +68,13 @@ export interface MockOracleChangePriceMutation { funds?: Coin[] } } -export function useMockOracleChangePriceMutation( +export function useMarsMockOracleChangePriceMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.changePrice(msg, fee, memo, funds), options, ) diff --git a/types/generated/mock-oracle/MockOracle.types.ts b/types/generated/mars-mock-oracle/MarsMockOracle.types.ts similarity index 91% rename from types/generated/mock-oracle/MockOracle.types.ts rename to types/generated/mars-mock-oracle/MarsMockOracle.types.ts index 833e13cb..56d42aa7 100644 --- a/types/generated/mock-oracle/MockOracle.types.ts +++ b/types/generated/mars-mock-oracle/MarsMockOracle.types.ts @@ -1,13 +1,13 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ export type Decimal = string export interface InstantiateMsg { - coins: CoinPrice[] + prices: CoinPrice[] } export interface CoinPrice { denom: string @@ -24,5 +24,4 @@ export type QueryMsg = { export interface PriceResponse { denom: string price: Decimal - [k: string]: unknown } diff --git a/types/generated/mars-mock-oracle/bundle.ts b/types/generated/mars-mock-oracle/bundle.ts new file mode 100644 index 00000000..9077d952 --- /dev/null +++ b/types/generated/mars-mock-oracle/bundle.ts @@ -0,0 +1,14 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _8 from './MarsMockOracle.types' +import * as _9 from './MarsMockOracle.client' +import * as _10 from './MarsMockOracle.message-composer' +import * as _11 from './MarsMockOracle.react-query' +export namespace contracts { + export const MarsMockOracle = { ..._8, ..._9, ..._10, ..._11 } +} diff --git a/types/generated/mars-mock-red-bank/MarsMockRedBank.client.ts b/types/generated/mars-mock-red-bank/MarsMockRedBank.client.ts new file mode 100644 index 00000000..2eda55c0 --- /dev/null +++ b/types/generated/mars-mock-red-bank/MarsMockRedBank.client.ts @@ -0,0 +1,723 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { Coin, StdFee } from '@cosmjs/amino' +import { + Decimal, + InstantiateMsg, + CoinMarketInfo, + ExecuteMsg, + Uint128, + CreateOrUpdateConfig, + InitOrUpdateAssetParams, + InterestRateModel, + QueryMsg, + ConfigForString, + Market, + ArrayOfMarket, + UncollateralizedLoanLimitResponse, + ArrayOfUncollateralizedLoanLimitResponse, + UserCollateralResponse, + ArrayOfUserCollateralResponse, + UserDebtResponse, + ArrayOfUserDebtResponse, + UserHealthStatus, + UserPositionResponse, +} from './MarsMockRedBank.types' +export interface MarsMockRedBankReadOnlyInterface { + contractAddress: string + config: () => Promise + market: ({ denom }: { denom: string }) => Promise + markets: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }) => Promise + uncollateralizedLoanLimit: ({ + denom, + user, + }: { + denom: string + user: string + }) => Promise + uncollateralizedLoanLimits: ({ + limit, + startAfter, + user, + }: { + limit?: number + startAfter?: string + user: string + }) => Promise + userDebt: ({ denom, user }: { denom: string; user: string }) => Promise + userDebts: ({ + limit, + startAfter, + user, + }: { + limit?: number + startAfter?: string + user: string + }) => Promise + userCollateral: ({ + denom, + user, + }: { + denom: string + user: string + }) => Promise + userCollaterals: ({ + limit, + startAfter, + user, + }: { + limit?: number + startAfter?: string + user: string + }) => Promise + userPosition: ({ user }: { user: string }) => Promise + scaledLiquidityAmount: ({ amount, denom }: { amount: Uint128; denom: string }) => Promise + scaledDebtAmount: ({ amount, denom }: { amount: Uint128; denom: string }) => Promise + underlyingLiquidityAmount: ({ + amountScaled, + denom, + }: { + amountScaled: Uint128 + denom: string + }) => Promise + underlyingDebtAmount: ({ + amountScaled, + denom, + }: { + amountScaled: Uint128 + denom: string + }) => Promise +} +export class MarsMockRedBankQueryClient implements MarsMockRedBankReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.config = this.config.bind(this) + this.market = this.market.bind(this) + this.markets = this.markets.bind(this) + this.uncollateralizedLoanLimit = this.uncollateralizedLoanLimit.bind(this) + this.uncollateralizedLoanLimits = this.uncollateralizedLoanLimits.bind(this) + this.userDebt = this.userDebt.bind(this) + this.userDebts = this.userDebts.bind(this) + this.userCollateral = this.userCollateral.bind(this) + this.userCollaterals = this.userCollaterals.bind(this) + this.userPosition = this.userPosition.bind(this) + this.scaledLiquidityAmount = this.scaledLiquidityAmount.bind(this) + this.scaledDebtAmount = this.scaledDebtAmount.bind(this) + this.underlyingLiquidityAmount = this.underlyingLiquidityAmount.bind(this) + this.underlyingDebtAmount = this.underlyingDebtAmount.bind(this) + } + + config = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + config: {}, + }) + } + market = async ({ denom }: { denom: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + market: { + denom, + }, + }) + } + markets = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + markets: { + limit, + start_after: startAfter, + }, + }) + } + uncollateralizedLoanLimit = async ({ + denom, + user, + }: { + denom: string + user: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + uncollateralized_loan_limit: { + denom, + user, + }, + }) + } + uncollateralizedLoanLimits = async ({ + limit, + startAfter, + user, + }: { + limit?: number + startAfter?: string + user: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + uncollateralized_loan_limits: { + limit, + start_after: startAfter, + user, + }, + }) + } + userDebt = async ({ + denom, + user, + }: { + denom: string + user: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + user_debt: { + denom, + user, + }, + }) + } + userDebts = async ({ + limit, + startAfter, + user, + }: { + limit?: number + startAfter?: string + user: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + user_debts: { + limit, + start_after: startAfter, + user, + }, + }) + } + userCollateral = async ({ + denom, + user, + }: { + denom: string + user: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + user_collateral: { + denom, + user, + }, + }) + } + userCollaterals = async ({ + limit, + startAfter, + user, + }: { + limit?: number + startAfter?: string + user: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + user_collaterals: { + limit, + start_after: startAfter, + user, + }, + }) + } + userPosition = async ({ user }: { user: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + user_position: { + user, + }, + }) + } + scaledLiquidityAmount = async ({ + amount, + denom, + }: { + amount: Uint128 + denom: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + scaled_liquidity_amount: { + amount, + denom, + }, + }) + } + scaledDebtAmount = async ({ + amount, + denom, + }: { + amount: Uint128 + denom: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + scaled_debt_amount: { + amount, + denom, + }, + }) + } + underlyingLiquidityAmount = async ({ + amountScaled, + denom, + }: { + amountScaled: Uint128 + denom: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + underlying_liquidity_amount: { + amount_scaled: amountScaled, + denom, + }, + }) + } + underlyingDebtAmount = async ({ + amountScaled, + denom, + }: { + amountScaled: Uint128 + denom: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + underlying_debt_amount: { + amount_scaled: amountScaled, + denom, + }, + }) + } +} +export interface MarsMockRedBankInterface extends MarsMockRedBankReadOnlyInterface { + contractAddress: string + sender: string + updateConfig: ( + { + config, + }: { + config: CreateOrUpdateConfig + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + initAsset: ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + updateAsset: ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + updateUncollateralizedLoanLimit: ( + { + denom, + newLimit, + user, + }: { + denom: string + newLimit: Uint128 + user: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + deposit: ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + withdraw: ( + { + amount, + denom, + recipient, + }: { + amount?: Uint128 + denom: string + recipient?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + borrow: ( + { + amount, + denom, + recipient, + }: { + amount: Uint128 + denom: string + recipient?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + repay: ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + liquidate: ( + { + collateralDenom, + recipient, + user, + }: { + collateralDenom: string + recipient?: string + user: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + updateAssetCollateralStatus: ( + { + denom, + enable, + }: { + denom: string + enable: boolean + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class MarsMockRedBankClient + extends MarsMockRedBankQueryClient + implements MarsMockRedBankInterface +{ + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.updateConfig = this.updateConfig.bind(this) + this.initAsset = this.initAsset.bind(this) + this.updateAsset = this.updateAsset.bind(this) + this.updateUncollateralizedLoanLimit = this.updateUncollateralizedLoanLimit.bind(this) + this.deposit = this.deposit.bind(this) + this.withdraw = this.withdraw.bind(this) + this.borrow = this.borrow.bind(this) + this.repay = this.repay.bind(this) + this.liquidate = this.liquidate.bind(this) + this.updateAssetCollateralStatus = this.updateAssetCollateralStatus.bind(this) + } + + updateConfig = async ( + { + config, + }: { + config: CreateOrUpdateConfig + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_config: { + config, + }, + }, + fee, + memo, + funds, + ) + } + initAsset = async ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + init_asset: { + denom, + params, + }, + }, + fee, + memo, + funds, + ) + } + updateAsset = async ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_asset: { + denom, + params, + }, + }, + fee, + memo, + funds, + ) + } + updateUncollateralizedLoanLimit = async ( + { + denom, + newLimit, + user, + }: { + denom: string + newLimit: Uint128 + user: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_uncollateralized_loan_limit: { + denom, + new_limit: newLimit, + user, + }, + }, + fee, + memo, + funds, + ) + } + deposit = async ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + deposit: { + on_behalf_of: onBehalfOf, + }, + }, + fee, + memo, + funds, + ) + } + withdraw = async ( + { + amount, + denom, + recipient, + }: { + amount?: Uint128 + denom: string + recipient?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + withdraw: { + amount, + denom, + recipient, + }, + }, + fee, + memo, + funds, + ) + } + borrow = async ( + { + amount, + denom, + recipient, + }: { + amount: Uint128 + denom: string + recipient?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + borrow: { + amount, + denom, + recipient, + }, + }, + fee, + memo, + funds, + ) + } + repay = async ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + repay: { + on_behalf_of: onBehalfOf, + }, + }, + fee, + memo, + funds, + ) + } + liquidate = async ( + { + collateralDenom, + recipient, + user, + }: { + collateralDenom: string + recipient?: string + user: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + liquidate: { + collateral_denom: collateralDenom, + recipient, + user, + }, + }, + fee, + memo, + funds, + ) + } + updateAssetCollateralStatus = async ( + { + denom, + enable, + }: { + denom: string + enable: boolean + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_asset_collateral_status: { + denom, + enable, + }, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/mars-mock-red-bank/MarsMockRedBank.message-composer.ts b/types/generated/mars-mock-red-bank/MarsMockRedBank.message-composer.ts new file mode 100644 index 00000000..5f75dbe1 --- /dev/null +++ b/types/generated/mars-mock-red-bank/MarsMockRedBank.message-composer.ts @@ -0,0 +1,432 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { Coin } from '@cosmjs/amino' +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + Decimal, + InstantiateMsg, + CoinMarketInfo, + ExecuteMsg, + Uint128, + CreateOrUpdateConfig, + InitOrUpdateAssetParams, + InterestRateModel, + QueryMsg, + ConfigForString, + Market, + ArrayOfMarket, + UncollateralizedLoanLimitResponse, + ArrayOfUncollateralizedLoanLimitResponse, + UserCollateralResponse, + ArrayOfUserCollateralResponse, + UserDebtResponse, + ArrayOfUserDebtResponse, + UserHealthStatus, + UserPositionResponse, +} from './MarsMockRedBank.types' +export interface MarsMockRedBankMessage { + contractAddress: string + sender: string + updateConfig: ( + { + config, + }: { + config: CreateOrUpdateConfig + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + initAsset: ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + updateAsset: ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + updateUncollateralizedLoanLimit: ( + { + denom, + newLimit, + user, + }: { + denom: string + newLimit: Uint128 + user: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + deposit: ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + withdraw: ( + { + amount, + denom, + recipient, + }: { + amount?: Uint128 + denom: string + recipient?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + borrow: ( + { + amount, + denom, + recipient, + }: { + amount: Uint128 + denom: string + recipient?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + repay: ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + liquidate: ( + { + collateralDenom, + recipient, + user, + }: { + collateralDenom: string + recipient?: string + user: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + updateAssetCollateralStatus: ( + { + denom, + enable, + }: { + denom: string + enable: boolean + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject +} +export class MarsMockRedBankMessageComposer implements MarsMockRedBankMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.updateConfig = this.updateConfig.bind(this) + this.initAsset = this.initAsset.bind(this) + this.updateAsset = this.updateAsset.bind(this) + this.updateUncollateralizedLoanLimit = this.updateUncollateralizedLoanLimit.bind(this) + this.deposit = this.deposit.bind(this) + this.withdraw = this.withdraw.bind(this) + this.borrow = this.borrow.bind(this) + this.repay = this.repay.bind(this) + this.liquidate = this.liquidate.bind(this) + this.updateAssetCollateralStatus = this.updateAssetCollateralStatus.bind(this) + } + + updateConfig = ( + { + config, + }: { + config: CreateOrUpdateConfig + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_config: { + config, + }, + }), + ), + funds, + }), + } + } + initAsset = ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + init_asset: { + denom, + params, + }, + }), + ), + funds, + }), + } + } + updateAsset = ( + { + denom, + params, + }: { + denom: string + params: InitOrUpdateAssetParams + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_asset: { + denom, + params, + }, + }), + ), + funds, + }), + } + } + updateUncollateralizedLoanLimit = ( + { + denom, + newLimit, + user, + }: { + denom: string + newLimit: Uint128 + user: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_uncollateralized_loan_limit: { + denom, + new_limit: newLimit, + user, + }, + }), + ), + funds, + }), + } + } + deposit = ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + deposit: { + on_behalf_of: onBehalfOf, + }, + }), + ), + funds, + }), + } + } + withdraw = ( + { + amount, + denom, + recipient, + }: { + amount?: Uint128 + denom: string + recipient?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + withdraw: { + amount, + denom, + recipient, + }, + }), + ), + funds, + }), + } + } + borrow = ( + { + amount, + denom, + recipient, + }: { + amount: Uint128 + denom: string + recipient?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + borrow: { + amount, + denom, + recipient, + }, + }), + ), + funds, + }), + } + } + repay = ( + { + onBehalfOf, + }: { + onBehalfOf?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + repay: { + on_behalf_of: onBehalfOf, + }, + }), + ), + funds, + }), + } + } + liquidate = ( + { + collateralDenom, + recipient, + user, + }: { + collateralDenom: string + recipient?: string + user: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + liquidate: { + collateral_denom: collateralDenom, + recipient, + user, + }, + }), + ), + funds, + }), + } + } + updateAssetCollateralStatus = ( + { + denom, + enable, + }: { + denom: string + enable: boolean + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_asset_collateral_status: { + denom, + enable, + }, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/mars-mock-red-bank/MarsMockRedBank.react-query.ts b/types/generated/mars-mock-red-bank/MarsMockRedBank.react-query.ts new file mode 100644 index 00000000..55f99f41 --- /dev/null +++ b/types/generated/mars-mock-red-bank/MarsMockRedBank.react-query.ts @@ -0,0 +1,694 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee, Coin } from '@cosmjs/amino' +import { + Decimal, + InstantiateMsg, + CoinMarketInfo, + ExecuteMsg, + Uint128, + CreateOrUpdateConfig, + InitOrUpdateAssetParams, + InterestRateModel, + QueryMsg, + ConfigForString, + Market, + ArrayOfMarket, + UncollateralizedLoanLimitResponse, + ArrayOfUncollateralizedLoanLimitResponse, + UserCollateralResponse, + ArrayOfUserCollateralResponse, + UserDebtResponse, + ArrayOfUserDebtResponse, + UserHealthStatus, + UserPositionResponse, +} from './MarsMockRedBank.types' +import { MarsMockRedBankQueryClient, MarsMockRedBankClient } from './MarsMockRedBank.client' +export const marsMockRedBankQueryKeys = { + contract: [ + { + contract: 'marsMockRedBank', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...marsMockRedBankQueryKeys.contract[0], address: contractAddress }] as const, + config: (contractAddress: string | undefined, args?: Record) => + [{ ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'config', args }] as const, + market: (contractAddress: string | undefined, args?: Record) => + [{ ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'market', args }] as const, + markets: (contractAddress: string | undefined, args?: Record) => + [{ ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'markets', args }] as const, + uncollateralizedLoanLimit: ( + contractAddress: string | undefined, + args?: Record, + ) => + [ + { + ...marsMockRedBankQueryKeys.address(contractAddress)[0], + method: 'uncollateralized_loan_limit', + args, + }, + ] as const, + uncollateralizedLoanLimits: ( + contractAddress: string | undefined, + args?: Record, + ) => + [ + { + ...marsMockRedBankQueryKeys.address(contractAddress)[0], + method: 'uncollateralized_loan_limits', + args, + }, + ] as const, + userDebt: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'user_debt', args }, + ] as const, + userDebts: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'user_debts', args }, + ] as const, + userCollateral: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'user_collateral', args }, + ] as const, + userCollaterals: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'user_collaterals', args }, + ] as const, + userPosition: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockRedBankQueryKeys.address(contractAddress)[0], method: 'user_position', args }, + ] as const, + scaledLiquidityAmount: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsMockRedBankQueryKeys.address(contractAddress)[0], + method: 'scaled_liquidity_amount', + args, + }, + ] as const, + scaledDebtAmount: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsMockRedBankQueryKeys.address(contractAddress)[0], + method: 'scaled_debt_amount', + args, + }, + ] as const, + underlyingLiquidityAmount: ( + contractAddress: string | undefined, + args?: Record, + ) => + [ + { + ...marsMockRedBankQueryKeys.address(contractAddress)[0], + method: 'underlying_liquidity_amount', + args, + }, + ] as const, + underlyingDebtAmount: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsMockRedBankQueryKeys.address(contractAddress)[0], + method: 'underlying_debt_amount', + args, + }, + ] as const, +} +export interface MarsMockRedBankReactQuery { + client: MarsMockRedBankQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MarsMockRedBankUnderlyingDebtAmountQuery + extends MarsMockRedBankReactQuery { + args: { + amountScaled: Uint128 + denom: string + } +} +export function useMarsMockRedBankUnderlyingDebtAmountQuery({ + client, + args, + options, +}: MarsMockRedBankUnderlyingDebtAmountQuery) { + return useQuery( + marsMockRedBankQueryKeys.underlyingDebtAmount(client?.contractAddress, args), + () => + client + ? client.underlyingDebtAmount({ + amountScaled: args.amountScaled, + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUnderlyingLiquidityAmountQuery + extends MarsMockRedBankReactQuery { + args: { + amountScaled: Uint128 + denom: string + } +} +export function useMarsMockRedBankUnderlyingLiquidityAmountQuery({ + client, + args, + options, +}: MarsMockRedBankUnderlyingLiquidityAmountQuery) { + return useQuery( + marsMockRedBankQueryKeys.underlyingLiquidityAmount(client?.contractAddress, args), + () => + client + ? client.underlyingLiquidityAmount({ + amountScaled: args.amountScaled, + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankScaledDebtAmountQuery + extends MarsMockRedBankReactQuery { + args: { + amount: Uint128 + denom: string + } +} +export function useMarsMockRedBankScaledDebtAmountQuery({ + client, + args, + options, +}: MarsMockRedBankScaledDebtAmountQuery) { + return useQuery( + marsMockRedBankQueryKeys.scaledDebtAmount(client?.contractAddress, args), + () => + client + ? client.scaledDebtAmount({ + amount: args.amount, + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankScaledLiquidityAmountQuery + extends MarsMockRedBankReactQuery { + args: { + amount: Uint128 + denom: string + } +} +export function useMarsMockRedBankScaledLiquidityAmountQuery({ + client, + args, + options, +}: MarsMockRedBankScaledLiquidityAmountQuery) { + return useQuery( + marsMockRedBankQueryKeys.scaledLiquidityAmount(client?.contractAddress, args), + () => + client + ? client.scaledLiquidityAmount({ + amount: args.amount, + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUserPositionQuery + extends MarsMockRedBankReactQuery { + args: { + user: string + } +} +export function useMarsMockRedBankUserPositionQuery({ + client, + args, + options, +}: MarsMockRedBankUserPositionQuery) { + return useQuery( + marsMockRedBankQueryKeys.userPosition(client?.contractAddress, args), + () => + client + ? client.userPosition({ + user: args.user, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUserCollateralsQuery + extends MarsMockRedBankReactQuery { + args: { + limit?: number + startAfter?: string + user: string + } +} +export function useMarsMockRedBankUserCollateralsQuery({ + client, + args, + options, +}: MarsMockRedBankUserCollateralsQuery) { + return useQuery( + marsMockRedBankQueryKeys.userCollaterals(client?.contractAddress, args), + () => + client + ? client.userCollaterals({ + limit: args.limit, + startAfter: args.startAfter, + user: args.user, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUserCollateralQuery + extends MarsMockRedBankReactQuery { + args: { + denom: string + user: string + } +} +export function useMarsMockRedBankUserCollateralQuery({ + client, + args, + options, +}: MarsMockRedBankUserCollateralQuery) { + return useQuery( + marsMockRedBankQueryKeys.userCollateral(client?.contractAddress, args), + () => + client + ? client.userCollateral({ + denom: args.denom, + user: args.user, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUserDebtsQuery + extends MarsMockRedBankReactQuery { + args: { + limit?: number + startAfter?: string + user: string + } +} +export function useMarsMockRedBankUserDebtsQuery({ + client, + args, + options, +}: MarsMockRedBankUserDebtsQuery) { + return useQuery( + marsMockRedBankQueryKeys.userDebts(client?.contractAddress, args), + () => + client + ? client.userDebts({ + limit: args.limit, + startAfter: args.startAfter, + user: args.user, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUserDebtQuery + extends MarsMockRedBankReactQuery { + args: { + denom: string + user: string + } +} +export function useMarsMockRedBankUserDebtQuery({ + client, + args, + options, +}: MarsMockRedBankUserDebtQuery) { + return useQuery( + marsMockRedBankQueryKeys.userDebt(client?.contractAddress, args), + () => + client + ? client.userDebt({ + denom: args.denom, + user: args.user, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUncollateralizedLoanLimitsQuery + extends MarsMockRedBankReactQuery { + args: { + limit?: number + startAfter?: string + user: string + } +} +export function useMarsMockRedBankUncollateralizedLoanLimitsQuery< + TData = ArrayOfUncollateralizedLoanLimitResponse, +>({ client, args, options }: MarsMockRedBankUncollateralizedLoanLimitsQuery) { + return useQuery( + marsMockRedBankQueryKeys.uncollateralizedLoanLimits(client?.contractAddress, args), + () => + client + ? client.uncollateralizedLoanLimits({ + limit: args.limit, + startAfter: args.startAfter, + user: args.user, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUncollateralizedLoanLimitQuery + extends MarsMockRedBankReactQuery { + args: { + denom: string + user: string + } +} +export function useMarsMockRedBankUncollateralizedLoanLimitQuery< + TData = UncollateralizedLoanLimitResponse, +>({ client, args, options }: MarsMockRedBankUncollateralizedLoanLimitQuery) { + return useQuery( + marsMockRedBankQueryKeys.uncollateralizedLoanLimit(client?.contractAddress, args), + () => + client + ? client.uncollateralizedLoanLimit({ + denom: args.denom, + user: args.user, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankMarketsQuery + extends MarsMockRedBankReactQuery { + args: { + limit?: number + startAfter?: string + } +} +export function useMarsMockRedBankMarketsQuery({ + client, + args, + options, +}: MarsMockRedBankMarketsQuery) { + return useQuery( + marsMockRedBankQueryKeys.markets(client?.contractAddress, args), + () => + client + ? client.markets({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankMarketQuery + extends MarsMockRedBankReactQuery { + args: { + denom: string + } +} +export function useMarsMockRedBankMarketQuery({ + client, + args, + options, +}: MarsMockRedBankMarketQuery) { + return useQuery( + marsMockRedBankQueryKeys.market(client?.contractAddress, args), + () => + client + ? client.market({ + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankConfigQuery + extends MarsMockRedBankReactQuery {} +export function useMarsMockRedBankConfigQuery({ + client, + options, +}: MarsMockRedBankConfigQuery) { + return useQuery( + marsMockRedBankQueryKeys.config(client?.contractAddress), + () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockRedBankUpdateAssetCollateralStatusMutation { + client: MarsMockRedBankClient + msg: { + denom: string + enable: boolean + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankUpdateAssetCollateralStatusMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateAssetCollateralStatus(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankLiquidateMutation { + client: MarsMockRedBankClient + msg: { + collateralDenom: string + recipient?: string + user: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankLiquidateMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.liquidate(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankRepayMutation { + client: MarsMockRedBankClient + msg: { + onBehalfOf?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankRepayMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.repay(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankBorrowMutation { + client: MarsMockRedBankClient + msg: { + amount: Uint128 + denom: string + recipient?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankBorrowMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.borrow(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankWithdrawMutation { + client: MarsMockRedBankClient + msg: { + amount?: Uint128 + denom: string + recipient?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankWithdrawMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.withdraw(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankDepositMutation { + client: MarsMockRedBankClient + msg: { + onBehalfOf?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankDepositMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.deposit(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankUpdateUncollateralizedLoanLimitMutation { + client: MarsMockRedBankClient + msg: { + denom: string + newLimit: Uint128 + user: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankUpdateUncollateralizedLoanLimitMutation( + options?: Omit< + UseMutationOptions< + ExecuteResult, + Error, + MarsMockRedBankUpdateUncollateralizedLoanLimitMutation + >, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateUncollateralizedLoanLimit(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankUpdateAssetMutation { + client: MarsMockRedBankClient + msg: { + denom: string + params: InitOrUpdateAssetParams + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankUpdateAssetMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.updateAsset(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankInitAssetMutation { + client: MarsMockRedBankClient + msg: { + denom: string + params: InitOrUpdateAssetParams + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankInitAssetMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.initAsset(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockRedBankUpdateConfigMutation { + client: MarsMockRedBankClient + msg: { + config: CreateOrUpdateConfig + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockRedBankUpdateConfigMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateConfig(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/mars-mock-red-bank/MarsMockRedBank.types.ts b/types/generated/mars-mock-red-bank/MarsMockRedBank.types.ts new file mode 100644 index 00000000..d3227a84 --- /dev/null +++ b/types/generated/mars-mock-red-bank/MarsMockRedBank.types.ts @@ -0,0 +1,242 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export type Decimal = string +export interface InstantiateMsg { + coins: CoinMarketInfo[] +} +export interface CoinMarketInfo { + denom: string + liquidation_threshold: Decimal + max_ltv: Decimal +} +export type ExecuteMsg = + | { + update_config: { + config: CreateOrUpdateConfig + } + } + | { + init_asset: { + denom: string + params: InitOrUpdateAssetParams + } + } + | { + update_asset: { + denom: string + params: InitOrUpdateAssetParams + } + } + | { + update_uncollateralized_loan_limit: { + denom: string + new_limit: Uint128 + user: string + } + } + | { + deposit: { + on_behalf_of?: string | null + } + } + | { + withdraw: { + amount?: Uint128 | null + denom: string + recipient?: string | null + } + } + | { + borrow: { + amount: Uint128 + denom: string + recipient?: string | null + } + } + | { + repay: { + on_behalf_of?: string | null + } + } + | { + liquidate: { + collateral_denom: string + recipient?: string | null + user: string + } + } + | { + update_asset_collateral_status: { + denom: string + enable: boolean + } + } +export type Uint128 = string +export interface CreateOrUpdateConfig { + address_provider?: string | null + close_factor?: Decimal | null + owner?: string | null +} +export interface InitOrUpdateAssetParams { + borrow_enabled?: boolean | null + deposit_cap?: Uint128 | null + deposit_enabled?: boolean | null + initial_borrow_rate?: Decimal | null + interest_rate_model?: InterestRateModel | null + liquidation_bonus?: Decimal | null + liquidation_threshold?: Decimal | null + max_loan_to_value?: Decimal | null + reserve_factor?: Decimal | null +} +export interface InterestRateModel { + base: Decimal + optimal_utilization_rate: Decimal + slope_1: Decimal + slope_2: Decimal +} +export type QueryMsg = + | { + config: {} + } + | { + market: { + denom: string + } + } + | { + markets: { + limit?: number | null + start_after?: string | null + } + } + | { + uncollateralized_loan_limit: { + denom: string + user: string + } + } + | { + uncollateralized_loan_limits: { + limit?: number | null + start_after?: string | null + user: string + } + } + | { + user_debt: { + denom: string + user: string + } + } + | { + user_debts: { + limit?: number | null + start_after?: string | null + user: string + } + } + | { + user_collateral: { + denom: string + user: string + } + } + | { + user_collaterals: { + limit?: number | null + start_after?: string | null + user: string + } + } + | { + user_position: { + user: string + } + } + | { + scaled_liquidity_amount: { + amount: Uint128 + denom: string + } + } + | { + scaled_debt_amount: { + amount: Uint128 + denom: string + } + } + | { + underlying_liquidity_amount: { + amount_scaled: Uint128 + denom: string + } + } + | { + underlying_debt_amount: { + amount_scaled: Uint128 + denom: string + } + } +export interface ConfigForString { + address_provider: string + close_factor: Decimal + owner: string +} +export interface Market { + borrow_enabled: boolean + borrow_index: Decimal + borrow_rate: Decimal + collateral_total_scaled: Uint128 + debt_total_scaled: Uint128 + denom: string + deposit_cap: Uint128 + deposit_enabled: boolean + indexes_last_updated: number + interest_rate_model: InterestRateModel + liquidation_bonus: Decimal + liquidation_threshold: Decimal + liquidity_index: Decimal + liquidity_rate: Decimal + max_loan_to_value: Decimal + reserve_factor: Decimal +} +export type ArrayOfMarket = Market[] +export interface UncollateralizedLoanLimitResponse { + denom: string + limit: Uint128 +} +export type ArrayOfUncollateralizedLoanLimitResponse = UncollateralizedLoanLimitResponse[] +export interface UserCollateralResponse { + amount: Uint128 + amount_scaled: Uint128 + denom: string + enabled: boolean +} +export type ArrayOfUserCollateralResponse = UserCollateralResponse[] +export interface UserDebtResponse { + amount: Uint128 + amount_scaled: Uint128 + denom: string + uncollateralized: boolean +} +export type ArrayOfUserDebtResponse = UserDebtResponse[] +export type UserHealthStatus = + | 'not_borrowing' + | { + borrowing: { + liq_threshold_hf: Decimal + max_ltv_hf: Decimal + } + } +export interface UserPositionResponse { + health_status: UserHealthStatus + total_collateralized_debt: Decimal + total_enabled_collateral: Decimal + weighted_liquidation_threshold_collateral: Decimal + weighted_max_ltv_collateral: Decimal +} diff --git a/types/generated/mars-mock-red-bank/bundle.ts b/types/generated/mars-mock-red-bank/bundle.ts new file mode 100644 index 00000000..2fa1eefe --- /dev/null +++ b/types/generated/mars-mock-red-bank/bundle.ts @@ -0,0 +1,14 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _12 from './MarsMockRedBank.types' +import * as _13 from './MarsMockRedBank.client' +import * as _14 from './MarsMockRedBank.message-composer' +import * as _15 from './MarsMockRedBank.react-query' +export namespace contracts { + export const MarsMockRedBank = { ..._12, ..._13, ..._14, ..._15 } +} diff --git a/types/generated/mars-mock-vault/MarsMockVault.client.ts b/types/generated/mars-mock-vault/MarsMockVault.client.ts new file mode 100644 index 00000000..e10d9622 --- /dev/null +++ b/types/generated/mars-mock-vault/MarsMockVault.client.ts @@ -0,0 +1,229 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { Coin, StdFee } from '@cosmjs/amino' +import { + Duration, + OracleBaseForString, + InstantiateMsg, + ExecuteMsg, + Uint128, + ExtensionExecuteMsg, + LockupExecuteMsg, + ForceUnlockExecuteMsg, + QueryMsg, + ExtensionQueryMsg, + LockupQueryMsg, + VaultInfo, + Empty, + VaultStandardInfo, +} from './MarsMockVault.types' +export interface MarsMockVaultReadOnlyInterface { + contractAddress: string + vaultStandardInfo: () => Promise + info: () => Promise + previewDeposit: ({ amount }: { amount: Uint128 }) => Promise + previewRedeem: ({ amount }: { amount: Uint128 }) => Promise + totalAssets: () => Promise + totalVaultTokenSupply: () => Promise + convertToShares: ({ amount }: { amount: Uint128 }) => Promise + convertToAssets: ({ amount }: { amount: Uint128 }) => Promise + vaultExtension: () => Promise +} +export class MarsMockVaultQueryClient implements MarsMockVaultReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.vaultStandardInfo = this.vaultStandardInfo.bind(this) + this.info = this.info.bind(this) + this.previewDeposit = this.previewDeposit.bind(this) + this.previewRedeem = this.previewRedeem.bind(this) + this.totalAssets = this.totalAssets.bind(this) + this.totalVaultTokenSupply = this.totalVaultTokenSupply.bind(this) + this.convertToShares = this.convertToShares.bind(this) + this.convertToAssets = this.convertToAssets.bind(this) + this.vaultExtension = this.vaultExtension.bind(this) + } + + vaultStandardInfo = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + vault_standard_info: {}, + }) + } + info = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + info: {}, + }) + } + previewDeposit = async ({ amount }: { amount: Uint128 }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + preview_deposit: { + amount, + }, + }) + } + previewRedeem = async ({ amount }: { amount: Uint128 }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + preview_redeem: { + amount, + }, + }) + } + totalAssets = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + total_assets: {}, + }) + } + totalVaultTokenSupply = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + total_vault_token_supply: {}, + }) + } + convertToShares = async ({ amount }: { amount: Uint128 }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + convert_to_shares: { + amount, + }, + }) + } + convertToAssets = async ({ amount }: { amount: Uint128 }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + convert_to_assets: { + amount, + }, + }) + } + vaultExtension = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + vault_extension: {}, + }) + } +} +export interface MarsMockVaultInterface extends MarsMockVaultReadOnlyInterface { + contractAddress: string + sender: string + deposit: ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + redeem: ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + vaultExtension: ( + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class MarsMockVaultClient + extends MarsMockVaultQueryClient + implements MarsMockVaultInterface +{ + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.deposit = this.deposit.bind(this) + this.redeem = this.redeem.bind(this) + this.vaultExtension = this.vaultExtension.bind(this) + } + + deposit = async ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + deposit: { + amount, + recipient, + }, + }, + fee, + memo, + funds, + ) + } + redeem = async ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + redeem: { + amount, + recipient, + }, + }, + fee, + memo, + funds, + ) + } + vaultExtension = async ( + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + vault_extension: {}, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/mars-mock-vault/MarsMockVault.message-composer.ts b/types/generated/mars-mock-vault/MarsMockVault.message-composer.ts new file mode 100644 index 00000000..3e119026 --- /dev/null +++ b/types/generated/mars-mock-vault/MarsMockVault.message-composer.ts @@ -0,0 +1,134 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { Coin } from '@cosmjs/amino' +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + Duration, + OracleBaseForString, + InstantiateMsg, + ExecuteMsg, + Uint128, + ExtensionExecuteMsg, + LockupExecuteMsg, + ForceUnlockExecuteMsg, + QueryMsg, + ExtensionQueryMsg, + LockupQueryMsg, + VaultInfo, + Empty, + VaultStandardInfo, +} from './MarsMockVault.types' +export interface MarsMockVaultMessage { + contractAddress: string + sender: string + deposit: ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + redeem: ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + vaultExtension: (funds?: Coin[]) => MsgExecuteContractEncodeObject +} +export class MarsMockVaultMessageComposer implements MarsMockVaultMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.deposit = this.deposit.bind(this) + this.redeem = this.redeem.bind(this) + this.vaultExtension = this.vaultExtension.bind(this) + } + + deposit = ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + deposit: { + amount, + recipient, + }, + }), + ), + funds, + }), + } + } + redeem = ( + { + amount, + recipient, + }: { + amount: Uint128 + recipient?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + redeem: { + amount, + recipient, + }, + }), + ), + funds, + }), + } + } + vaultExtension = (funds?: Coin[]): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + vault_extension: {}, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/mars-mock-vault/MarsMockVault.react-query.ts b/types/generated/mars-mock-vault/MarsMockVault.react-query.ts new file mode 100644 index 00000000..2cfe68ea --- /dev/null +++ b/types/generated/mars-mock-vault/MarsMockVault.react-query.ts @@ -0,0 +1,301 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee, Coin } from '@cosmjs/amino' +import { + Duration, + OracleBaseForString, + InstantiateMsg, + ExecuteMsg, + Uint128, + ExtensionExecuteMsg, + LockupExecuteMsg, + ForceUnlockExecuteMsg, + QueryMsg, + ExtensionQueryMsg, + LockupQueryMsg, + VaultInfo, + Empty, + VaultStandardInfo, +} from './MarsMockVault.types' +import { MarsMockVaultQueryClient, MarsMockVaultClient } from './MarsMockVault.client' +export const marsMockVaultQueryKeys = { + contract: [ + { + contract: 'marsMockVault', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...marsMockVaultQueryKeys.contract[0], address: contractAddress }] as const, + vaultStandardInfo: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsMockVaultQueryKeys.address(contractAddress)[0], + method: 'vault_standard_info', + args, + }, + ] as const, + info: (contractAddress: string | undefined, args?: Record) => + [{ ...marsMockVaultQueryKeys.address(contractAddress)[0], method: 'info', args }] as const, + previewDeposit: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockVaultQueryKeys.address(contractAddress)[0], method: 'preview_deposit', args }, + ] as const, + previewRedeem: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockVaultQueryKeys.address(contractAddress)[0], method: 'preview_redeem', args }, + ] as const, + totalAssets: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockVaultQueryKeys.address(contractAddress)[0], method: 'total_assets', args }, + ] as const, + totalVaultTokenSupply: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsMockVaultQueryKeys.address(contractAddress)[0], + method: 'total_vault_token_supply', + args, + }, + ] as const, + convertToShares: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockVaultQueryKeys.address(contractAddress)[0], method: 'convert_to_shares', args }, + ] as const, + convertToAssets: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockVaultQueryKeys.address(contractAddress)[0], method: 'convert_to_assets', args }, + ] as const, + vaultExtension: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsMockVaultQueryKeys.address(contractAddress)[0], method: 'vault_extension', args }, + ] as const, +} +export interface MarsMockVaultReactQuery { + client: MarsMockVaultQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MarsMockVaultVaultExtensionQuery + extends MarsMockVaultReactQuery {} +export function useMarsMockVaultVaultExtensionQuery({ + client, + options, +}: MarsMockVaultVaultExtensionQuery) { + return useQuery( + marsMockVaultQueryKeys.vaultExtension(client?.contractAddress), + () => (client ? client.vaultExtension() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultConvertToAssetsQuery + extends MarsMockVaultReactQuery { + args: { + amount: Uint128 + } +} +export function useMarsMockVaultConvertToAssetsQuery({ + client, + args, + options, +}: MarsMockVaultConvertToAssetsQuery) { + return useQuery( + marsMockVaultQueryKeys.convertToAssets(client?.contractAddress, args), + () => + client + ? client.convertToAssets({ + amount: args.amount, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultConvertToSharesQuery + extends MarsMockVaultReactQuery { + args: { + amount: Uint128 + } +} +export function useMarsMockVaultConvertToSharesQuery({ + client, + args, + options, +}: MarsMockVaultConvertToSharesQuery) { + return useQuery( + marsMockVaultQueryKeys.convertToShares(client?.contractAddress, args), + () => + client + ? client.convertToShares({ + amount: args.amount, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultTotalVaultTokenSupplyQuery + extends MarsMockVaultReactQuery {} +export function useMarsMockVaultTotalVaultTokenSupplyQuery({ + client, + options, +}: MarsMockVaultTotalVaultTokenSupplyQuery) { + return useQuery( + marsMockVaultQueryKeys.totalVaultTokenSupply(client?.contractAddress), + () => (client ? client.totalVaultTokenSupply() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultTotalAssetsQuery + extends MarsMockVaultReactQuery {} +export function useMarsMockVaultTotalAssetsQuery({ + client, + options, +}: MarsMockVaultTotalAssetsQuery) { + return useQuery( + marsMockVaultQueryKeys.totalAssets(client?.contractAddress), + () => (client ? client.totalAssets() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultPreviewRedeemQuery + extends MarsMockVaultReactQuery { + args: { + amount: Uint128 + } +} +export function useMarsMockVaultPreviewRedeemQuery({ + client, + args, + options, +}: MarsMockVaultPreviewRedeemQuery) { + return useQuery( + marsMockVaultQueryKeys.previewRedeem(client?.contractAddress, args), + () => + client + ? client.previewRedeem({ + amount: args.amount, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultPreviewDepositQuery + extends MarsMockVaultReactQuery { + args: { + amount: Uint128 + } +} +export function useMarsMockVaultPreviewDepositQuery({ + client, + args, + options, +}: MarsMockVaultPreviewDepositQuery) { + return useQuery( + marsMockVaultQueryKeys.previewDeposit(client?.contractAddress, args), + () => + client + ? client.previewDeposit({ + amount: args.amount, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultInfoQuery extends MarsMockVaultReactQuery {} +export function useMarsMockVaultInfoQuery({ + client, + options, +}: MarsMockVaultInfoQuery) { + return useQuery( + marsMockVaultQueryKeys.info(client?.contractAddress), + () => (client ? client.info() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultVaultStandardInfoQuery + extends MarsMockVaultReactQuery {} +export function useMarsMockVaultVaultStandardInfoQuery({ + client, + options, +}: MarsMockVaultVaultStandardInfoQuery) { + return useQuery( + marsMockVaultQueryKeys.vaultStandardInfo(client?.contractAddress), + () => (client ? client.vaultStandardInfo() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockVaultVaultExtensionMutation { + client: MarsMockVaultClient + msg: ExtensionExecuteMsg + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockVaultVaultExtensionMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.vaultExtension(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockVaultRedeemMutation { + client: MarsMockVaultClient + msg: { + amount: Uint128 + recipient?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockVaultRedeemMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.redeem(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockVaultDepositMutation { + client: MarsMockVaultClient + msg: { + amount: Uint128 + recipient?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockVaultDepositMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.deposit(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/mars-mock-vault/MarsMockVault.types.ts b/types/generated/mars-mock-vault/MarsMockVault.types.ts new file mode 100644 index 00000000..59ab6660 --- /dev/null +++ b/types/generated/mars-mock-vault/MarsMockVault.types.ts @@ -0,0 +1,143 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export type Duration = + | { + height: number + } + | { + time: number + } +export type OracleBaseForString = string +export interface InstantiateMsg { + base_token_denom: string + lockup?: Duration | null + oracle: OracleBaseForString + vault_token_denom: string +} +export type ExecuteMsg = + | { + deposit: { + amount: Uint128 + recipient?: string | null + } + } + | { + redeem: { + amount: Uint128 + recipient?: string | null + } + } + | { + vault_extension: ExtensionExecuteMsg + } +export type Uint128 = string +export type ExtensionExecuteMsg = + | { + lockup: LockupExecuteMsg + } + | { + force_unlock: ForceUnlockExecuteMsg + } +export type LockupExecuteMsg = + | { + unlock: { + amount: Uint128 + } + } + | { + withdraw_unlocked: { + lockup_id: number + recipient?: string | null + } + } +export type ForceUnlockExecuteMsg = + | { + force_redeem: { + amount: Uint128 + recipient?: string | null + } + } + | { + force_withdraw_unlocking: { + amount?: Uint128 | null + lockup_id: number + recipient?: string | null + } + } + | { + update_force_withdraw_whitelist: { + add_addresses: string[] + remove_addresses: string[] + } + } +export type QueryMsg = + | { + vault_standard_info: {} + } + | { + info: {} + } + | { + preview_deposit: { + amount: Uint128 + } + } + | { + preview_redeem: { + amount: Uint128 + } + } + | { + total_assets: {} + } + | { + total_vault_token_supply: {} + } + | { + convert_to_shares: { + amount: Uint128 + } + } + | { + convert_to_assets: { + amount: Uint128 + } + } + | { + vault_extension: ExtensionQueryMsg + } +export type ExtensionQueryMsg = { + lockup: LockupQueryMsg +} +export type LockupQueryMsg = + | { + lockups: { + limit?: number | null + owner: string + start_after?: number | null + } + } + | { + lockup: { + lockup_id: number + } + } + | { + lockup_duration: {} + } +export interface VaultInfo { + base_token: string + vault_token: string +} +export interface Empty { + [k: string]: unknown +} +export interface VaultStandardInfo { + extensions: string[] + version: number +} diff --git a/types/generated/mars-mock-vault/bundle.ts b/types/generated/mars-mock-vault/bundle.ts new file mode 100644 index 00000000..cc834795 --- /dev/null +++ b/types/generated/mars-mock-vault/bundle.ts @@ -0,0 +1,14 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _16 from './MarsMockVault.types' +import * as _17 from './MarsMockVault.client' +import * as _18 from './MarsMockVault.message-composer' +import * as _19 from './MarsMockVault.react-query' +export namespace contracts { + export const MarsMockVault = { ..._16, ..._17, ..._18, ..._19 } +} diff --git a/types/generated/mock-red-bank/MockRedBank.client.ts b/types/generated/mars-mock-zapper/MarsMockZapper.client.ts similarity index 52% rename from types/generated/mock-red-bank/MockRedBank.client.ts rename to types/generated/mars-mock-zapper/MarsMockZapper.client.ts index af987b13..c1d176a4 100644 --- a/types/generated/mock-red-bank/MockRedBank.client.ts +++ b/types/generated/mars-mock-zapper/MarsMockZapper.client.ts @@ -1,98 +1,98 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' -import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' - import { - Coin, - CoinMarketInfo, - Decimal, - ExecuteMsg, + OracleBaseForString, InstantiateMsg, - InterestRateModel, - Market, - QueryMsg, + LpConfig, + ExecuteMsg, Uint128, - UserAssetDebtResponse, -} from './MockRedBank.types' -export interface MockRedBankReadOnlyInterface { + QueryMsg, + Coin, + ArrayOfCoin, +} from './MarsMockZapper.types' +export interface MarsMockZapperReadOnlyInterface { contractAddress: string - userAssetDebt: ({ - denom, - userAddress, + estimateProvideLiquidity: ({ + coinsIn, + lpTokenOut, }: { - denom: string - userAddress: string - }) => Promise - market: ({ denom }: { denom: string }) => Promise + coinsIn: Coin[] + lpTokenOut: string + }) => Promise + estimateWithdrawLiquidity: ({ coinIn }: { coinIn: Coin }) => Promise } -export class MockRedBankQueryClient implements MockRedBankReadOnlyInterface { +export class MarsMockZapperQueryClient implements MarsMockZapperReadOnlyInterface { client: CosmWasmClient contractAddress: string constructor(client: CosmWasmClient, contractAddress: string) { this.client = client this.contractAddress = contractAddress - this.userAssetDebt = this.userAssetDebt.bind(this) - this.market = this.market.bind(this) + this.estimateProvideLiquidity = this.estimateProvideLiquidity.bind(this) + this.estimateWithdrawLiquidity = this.estimateWithdrawLiquidity.bind(this) } - userAssetDebt = async ({ - denom, - userAddress, + estimateProvideLiquidity = async ({ + coinsIn, + lpTokenOut, }: { - denom: string - userAddress: string - }): Promise => { + coinsIn: Coin[] + lpTokenOut: string + }): Promise => { return this.client.queryContractSmart(this.contractAddress, { - user_asset_debt: { - denom, - user_address: userAddress, + estimate_provide_liquidity: { + coins_in: coinsIn, + lp_token_out: lpTokenOut, }, }) } - market = async ({ denom }: { denom: string }): Promise => { + estimateWithdrawLiquidity = async ({ coinIn }: { coinIn: Coin }): Promise => { return this.client.queryContractSmart(this.contractAddress, { - market: { - denom, + estimate_withdraw_liquidity: { + coin_in: coinIn, }, }) } } -export interface MockRedBankInterface extends MockRedBankReadOnlyInterface { +export interface MarsMockZapperInterface extends MarsMockZapperReadOnlyInterface { contractAddress: string sender: string - borrow: ( + provideLiquidity: ( { - coin, + lpTokenOut, + minimumReceive, recipient, }: { - coin: Coin + lpTokenOut: string + minimumReceive: Uint128 recipient?: string }, fee?: number | StdFee | 'auto', memo?: string, funds?: Coin[], ) => Promise - repay: ( + withdrawLiquidity: ( { - denom, - onBehalfOf, + recipient, }: { - denom: string - onBehalfOf?: string + recipient?: string }, fee?: number | StdFee | 'auto', memo?: string, funds?: Coin[], ) => Promise } -export class MockRedBankClient extends MockRedBankQueryClient implements MockRedBankInterface { +export class MarsMockZapperClient + extends MarsMockZapperQueryClient + implements MarsMockZapperInterface +{ client: SigningCosmWasmClient sender: string contractAddress: string @@ -102,16 +102,18 @@ export class MockRedBankClient extends MockRedBankQueryClient implements MockRed this.client = client this.sender = sender this.contractAddress = contractAddress - this.borrow = this.borrow.bind(this) - this.repay = this.repay.bind(this) + this.provideLiquidity = this.provideLiquidity.bind(this) + this.withdrawLiquidity = this.withdrawLiquidity.bind(this) } - borrow = async ( + provideLiquidity = async ( { - coin, + lpTokenOut, + minimumReceive, recipient, }: { - coin: Coin + lpTokenOut: string + minimumReceive: Uint128 recipient?: string }, fee: number | StdFee | 'auto' = 'auto', @@ -122,8 +124,9 @@ export class MockRedBankClient extends MockRedBankQueryClient implements MockRed this.sender, this.contractAddress, { - borrow: { - coin, + provide_liquidity: { + lp_token_out: lpTokenOut, + minimum_receive: minimumReceive, recipient, }, }, @@ -132,13 +135,11 @@ export class MockRedBankClient extends MockRedBankQueryClient implements MockRed funds, ) } - repay = async ( + withdrawLiquidity = async ( { - denom, - onBehalfOf, + recipient, }: { - denom: string - onBehalfOf?: string + recipient?: string }, fee: number | StdFee | 'auto' = 'auto', memo?: string, @@ -148,9 +149,8 @@ export class MockRedBankClient extends MockRedBankQueryClient implements MockRed this.sender, this.contractAddress, { - repay: { - denom, - on_behalf_of: onBehalfOf, + withdraw_liquidity: { + recipient, }, }, fee, diff --git a/types/generated/mars-mock-zapper/MarsMockZapper.message-composer.ts b/types/generated/mars-mock-zapper/MarsMockZapper.message-composer.ts new file mode 100644 index 00000000..822a00b2 --- /dev/null +++ b/types/generated/mars-mock-zapper/MarsMockZapper.message-composer.ts @@ -0,0 +1,110 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + OracleBaseForString, + InstantiateMsg, + LpConfig, + ExecuteMsg, + Uint128, + QueryMsg, + Coin, + ArrayOfCoin, +} from './MarsMockZapper.types' +export interface MarsMockZapperMessage { + contractAddress: string + sender: string + provideLiquidity: ( + { + lpTokenOut, + minimumReceive, + recipient, + }: { + lpTokenOut: string + minimumReceive: Uint128 + recipient?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + withdrawLiquidity: ( + { + recipient, + }: { + recipient?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject +} +export class MarsMockZapperMessageComposer implements MarsMockZapperMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.provideLiquidity = this.provideLiquidity.bind(this) + this.withdrawLiquidity = this.withdrawLiquidity.bind(this) + } + + provideLiquidity = ( + { + lpTokenOut, + minimumReceive, + recipient, + }: { + lpTokenOut: string + minimumReceive: Uint128 + recipient?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + provide_liquidity: { + lp_token_out: lpTokenOut, + minimum_receive: minimumReceive, + recipient, + }, + }), + ), + funds, + }), + } + } + withdrawLiquidity = ( + { + recipient, + }: { + recipient?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + withdraw_liquidity: { + recipient, + }, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/mars-mock-zapper/MarsMockZapper.react-query.ts b/types/generated/mars-mock-zapper/MarsMockZapper.react-query.ts new file mode 100644 index 00000000..6f9fff7d --- /dev/null +++ b/types/generated/mars-mock-zapper/MarsMockZapper.react-query.ts @@ -0,0 +1,152 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + OracleBaseForString, + InstantiateMsg, + LpConfig, + ExecuteMsg, + Uint128, + QueryMsg, + Coin, + ArrayOfCoin, +} from './MarsMockZapper.types' +import { MarsMockZapperQueryClient, MarsMockZapperClient } from './MarsMockZapper.client' +export const marsMockZapperQueryKeys = { + contract: [ + { + contract: 'marsMockZapper', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...marsMockZapperQueryKeys.contract[0], address: contractAddress }] as const, + estimateProvideLiquidity: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsMockZapperQueryKeys.address(contractAddress)[0], + method: 'estimate_provide_liquidity', + args, + }, + ] as const, + estimateWithdrawLiquidity: ( + contractAddress: string | undefined, + args?: Record, + ) => + [ + { + ...marsMockZapperQueryKeys.address(contractAddress)[0], + method: 'estimate_withdraw_liquidity', + args, + }, + ] as const, +} +export interface MarsMockZapperReactQuery { + client: MarsMockZapperQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MarsMockZapperEstimateWithdrawLiquidityQuery + extends MarsMockZapperReactQuery { + args: { + coinIn: Coin + } +} +export function useMarsMockZapperEstimateWithdrawLiquidityQuery({ + client, + args, + options, +}: MarsMockZapperEstimateWithdrawLiquidityQuery) { + return useQuery( + marsMockZapperQueryKeys.estimateWithdrawLiquidity(client?.contractAddress, args), + () => + client + ? client.estimateWithdrawLiquidity({ + coinIn: args.coinIn, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockZapperEstimateProvideLiquidityQuery + extends MarsMockZapperReactQuery { + args: { + coinsIn: Coin[] + lpTokenOut: string + } +} +export function useMarsMockZapperEstimateProvideLiquidityQuery({ + client, + args, + options, +}: MarsMockZapperEstimateProvideLiquidityQuery) { + return useQuery( + marsMockZapperQueryKeys.estimateProvideLiquidity(client?.contractAddress, args), + () => + client + ? client.estimateProvideLiquidity({ + coinsIn: args.coinsIn, + lpTokenOut: args.lpTokenOut, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsMockZapperWithdrawLiquidityMutation { + client: MarsMockZapperClient + msg: { + recipient?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockZapperWithdrawLiquidityMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.withdrawLiquidity(msg, fee, memo, funds), + options, + ) +} +export interface MarsMockZapperProvideLiquidityMutation { + client: MarsMockZapperClient + msg: { + lpTokenOut: string + minimumReceive: Uint128 + recipient?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsMockZapperProvideLiquidityMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.provideLiquidity(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/mock-vault/MockVault.types.ts b/types/generated/mars-mock-zapper/MarsMockZapper.types.ts similarity index 57% rename from types/generated/mock-vault/MockVault.types.ts rename to types/generated/mars-mock-zapper/MarsMockZapper.types.ts index 8114114a..64b08650 100644 --- a/types/generated/mock-vault/MockVault.types.ts +++ b/types/generated/mars-mock-zapper/MarsMockZapper.types.ts @@ -1,45 +1,45 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ export type OracleBaseForString = string export interface InstantiateMsg { - asset_denoms: string[] - lockup?: number | null - lp_token_denom: string + lp_configs: LpConfig[] oracle: OracleBaseForString } +export interface LpConfig { + lp_pair_denoms: [string, string] + lp_token_denom: string +} export type ExecuteMsg = | { - deposit: {} - } - | { - withdraw: {} - } - | { - force_withdraw: {} - } -export type QueryMsg = - | { - info: {} - } - | { - preview_redeem: { - amount: Uint128 + provide_liquidity: { + lp_token_out: string + minimum_receive: Uint128 + recipient?: string | null } } | { - total_vault_coins_issued: {} + withdraw_liquidity: { + recipient?: string | null + } } export type Uint128 = string -export interface VaultInfo { - coins: Coin[] - lockup?: number | null - token_denom: string -} +export type QueryMsg = + | { + estimate_provide_liquidity: { + coins_in: Coin[] + lp_token_out: string + } + } + | { + estimate_withdraw_liquidity: { + coin_in: Coin + } + } export interface Coin { amount: Uint128 denom: string diff --git a/types/generated/mars-mock-zapper/bundle.ts b/types/generated/mars-mock-zapper/bundle.ts new file mode 100644 index 00000000..6bffb33f --- /dev/null +++ b/types/generated/mars-mock-zapper/bundle.ts @@ -0,0 +1,14 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _20 from './MarsMockZapper.types' +import * as _21 from './MarsMockZapper.client' +import * as _22 from './MarsMockZapper.message-composer' +import * as _23 from './MarsMockZapper.react-query' +export namespace contracts { + export const MarsMockZapper = { ..._20, ..._21, ..._22, ..._23 } +} diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts index 3ec2fd9e..3dd7dd65 100644 --- a/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts @@ -1,31 +1,34 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { Coin, StdFee } from '@cosmjs/amino' -import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' - +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' import { - Addr, - ArrayOfVaultPricingInfo, - ConfigResponse, - ConfigUpdates, - Decimal, - ExecuteMsg, - InstantiateMsg, - OracleBaseForAddr, OracleBaseForString, - PriceResponse, + Addr, PricingMethod, - QueryMsg, + InstantiateMsg, VaultPricingInfo, + ExecuteMsg, + ConfigUpdates, + QueryMsg, + Uint128, + Coin, + ArrayOfVaultPricingInfo, + OracleBaseForAddr, + ConfigResponse, + Decimal, + PriceResponse, + ArrayOfCoin, } from './MarsOracleAdapter.types' export interface MarsOracleAdapterReadOnlyInterface { contractAddress: string price: ({ denom }: { denom: string }) => Promise + priceableUnderlying: ({ coin }: { coin: Coin }) => Promise config: () => Promise pricingInfo: ({ denom }: { denom: string }) => Promise allPricingInfo: ({ @@ -44,6 +47,7 @@ export class MarsOracleAdapterQueryClient implements MarsOracleAdapterReadOnlyIn this.client = client this.contractAddress = contractAddress this.price = this.price.bind(this) + this.priceableUnderlying = this.priceableUnderlying.bind(this) this.config = this.config.bind(this) this.pricingInfo = this.pricingInfo.bind(this) this.allPricingInfo = this.allPricingInfo.bind(this) @@ -56,6 +60,13 @@ export class MarsOracleAdapterQueryClient implements MarsOracleAdapterReadOnlyIn }, }) } + priceableUnderlying = async ({ coin }: { coin: Coin }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + priceable_underlying: { + coin, + }, + }) + } config = async (): Promise => { return this.client.queryContractSmart(this.contractAddress, { config: {}, diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.message-composer.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.message-composer.ts new file mode 100644 index 00000000..0ce7b8ca --- /dev/null +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.message-composer.ts @@ -0,0 +1,75 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + OracleBaseForString, + Addr, + PricingMethod, + InstantiateMsg, + VaultPricingInfo, + ExecuteMsg, + ConfigUpdates, + QueryMsg, + Uint128, + Coin, + ArrayOfVaultPricingInfo, + OracleBaseForAddr, + ConfigResponse, + Decimal, + PriceResponse, + ArrayOfCoin, +} from './MarsOracleAdapter.types' +export interface MarsOracleAdapterMessage { + contractAddress: string + sender: string + updateConfig: ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject +} +export class MarsOracleAdapterMessageComposer implements MarsOracleAdapterMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.updateConfig = this.updateConfig.bind(this) + } + + updateConfig = ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_config: { + new_config: newConfig, + }, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts index d3959660..8637ecdb 100644 --- a/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts @@ -1,30 +1,32 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { Coin, StdFee } from '@cosmjs/amino' +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { MarsOracleAdapterClient, MarsOracleAdapterQueryClient } from './MarsOracleAdapter.client' +import { StdFee } from '@cosmjs/amino' import { - Addr, - ArrayOfVaultPricingInfo, - ConfigResponse, - ConfigUpdates, - Decimal, - ExecuteMsg, - InstantiateMsg, - OracleBaseForAddr, OracleBaseForString, - PriceResponse, + Addr, PricingMethod, - QueryMsg, + InstantiateMsg, VaultPricingInfo, + ExecuteMsg, + ConfigUpdates, + QueryMsg, + Uint128, + Coin, + ArrayOfVaultPricingInfo, + OracleBaseForAddr, + ConfigResponse, + Decimal, + PriceResponse, + ArrayOfCoin, } from './MarsOracleAdapter.types' +import { MarsOracleAdapterQueryClient, MarsOracleAdapterClient } from './MarsOracleAdapter.client' export const marsOracleAdapterQueryKeys = { contract: [ { @@ -35,6 +37,14 @@ export const marsOracleAdapterQueryKeys = { [{ ...marsOracleAdapterQueryKeys.contract[0], address: contractAddress }] as const, price: (contractAddress: string | undefined, args?: Record) => [{ ...marsOracleAdapterQueryKeys.address(contractAddress)[0], method: 'price', args }] as const, + priceableUnderlying: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsOracleAdapterQueryKeys.address(contractAddress)[0], + method: 'priceable_underlying', + args, + }, + ] as const, config: (contractAddress: string | undefined, args?: Record) => [ { ...marsOracleAdapterQueryKeys.address(contractAddress)[0], method: 'config', args }, @@ -119,6 +129,28 @@ export function useMarsOracleAdapterConfigQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } +export interface MarsOracleAdapterPriceableUnderlyingQuery + extends MarsOracleAdapterReactQuery { + args: { + coin: Coin + } +} +export function useMarsOracleAdapterPriceableUnderlyingQuery({ + client, + args, + options, +}: MarsOracleAdapterPriceableUnderlyingQuery) { + return useQuery( + marsOracleAdapterQueryKeys.priceableUnderlying(client?.contractAddress, args), + () => + client + ? client.priceableUnderlying({ + coin: args.coin, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} export interface MarsOracleAdapterPriceQuery extends MarsOracleAdapterReactQuery { args: { diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.types.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.types.ts index 4dca1c4f..3072f9a6 100644 --- a/types/generated/mars-oracle-adapter/MarsOracleAdapter.types.ts +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.types.ts @@ -1,6 +1,6 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ @@ -15,8 +15,9 @@ export interface InstantiateMsg { } export interface VaultPricingInfo { addr: Addr - denom: string + base_denom: string method: PricingMethod + vault_coin_denom: string } export type ExecuteMsg = { update_config: { @@ -34,6 +35,11 @@ export type QueryMsg = denom: string } } + | { + priceable_underlying: { + coin: Coin + } + } | { config: {} } @@ -48,6 +54,12 @@ export type QueryMsg = start_after?: string | null } } +export type Uint128 = string +export interface Coin { + amount: Uint128 + denom: string + [k: string]: unknown +} export type ArrayOfVaultPricingInfo = VaultPricingInfo[] export type OracleBaseForAddr = string export interface ConfigResponse { @@ -58,5 +70,5 @@ export type Decimal = string export interface PriceResponse { denom: string price: Decimal - [k: string]: unknown } +export type ArrayOfCoin = Coin[] diff --git a/types/generated/mars-oracle-adapter/bundle.ts b/types/generated/mars-oracle-adapter/bundle.ts index 7faed529..63503f7f 100644 --- a/types/generated/mars-oracle-adapter/bundle.ts +++ b/types/generated/mars-oracle-adapter/bundle.ts @@ -1,13 +1,14 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _7 from './MarsOracleAdapter.client' -import * as _8 from './MarsOracleAdapter.react-query' -import * as _6 from './MarsOracleAdapter.types' +import * as _24 from './MarsOracleAdapter.types' +import * as _25 from './MarsOracleAdapter.client' +import * as _26 from './MarsOracleAdapter.message-composer' +import * as _27 from './MarsOracleAdapter.react-query' export namespace contracts { - export const MarsOracleAdapter = { ..._6, ..._7, ..._8 } + export const MarsOracleAdapter = { ..._24, ..._25, ..._26, ..._27 } } diff --git a/types/generated/swapper-base/SwapperBase.client.ts b/types/generated/mars-swapper-base/MarsSwapperBase.client.ts similarity index 93% rename from types/generated/swapper-base/SwapperBase.client.ts rename to types/generated/mars-swapper-base/MarsSwapperBase.client.ts index 580a3544..f297c7f0 100644 --- a/types/generated/swapper-base/SwapperBase.client.ts +++ b/types/generated/mars-swapper-base/MarsSwapperBase.client.ts @@ -1,28 +1,27 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' -import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' - import { - Addr, - ArrayOfRouteResponseForEmpty, - Coin, - ConfigForString, - Decimal, - Empty, - EstimateExactInSwapResponse, - ExecuteMsg, InstantiateMsg, - QueryMsg, - RouteResponseForEmpty, + ExecuteMsg, Uint128, -} from './SwapperBase.types' -export interface SwapperBaseReadOnlyInterface { + Decimal, + Addr, + Empty, + Coin, + QueryMsg, + ConfigForString, + EstimateExactInSwapResponse, + RouteResponseForEmpty, + ArrayOfRouteResponseForEmpty, +} from './MarsSwapperBase.types' +export interface MarsSwapperBaseReadOnlyInterface { contractAddress: string config: () => Promise route: ({ @@ -47,7 +46,7 @@ export interface SwapperBaseReadOnlyInterface { denomOut: string }) => Promise } -export class SwapperBaseQueryClient implements SwapperBaseReadOnlyInterface { +export class MarsSwapperBaseQueryClient implements MarsSwapperBaseReadOnlyInterface { client: CosmWasmClient contractAddress: string @@ -108,7 +107,7 @@ export class SwapperBaseQueryClient implements SwapperBaseReadOnlyInterface { }) } } -export interface SwapperBaseInterface extends SwapperBaseReadOnlyInterface { +export interface MarsSwapperBaseInterface extends MarsSwapperBaseReadOnlyInterface { contractAddress: string sender: string updateConfig: ( @@ -164,7 +163,10 @@ export interface SwapperBaseInterface extends SwapperBaseReadOnlyInterface { funds?: Coin[], ) => Promise } -export class SwapperBaseClient extends SwapperBaseQueryClient implements SwapperBaseInterface { +export class MarsSwapperBaseClient + extends MarsSwapperBaseQueryClient + implements MarsSwapperBaseInterface +{ client: SigningCosmWasmClient sender: string contractAddress: string diff --git a/types/generated/mars-swapper-base/MarsSwapperBase.message-composer.ts b/types/generated/mars-swapper-base/MarsSwapperBase.message-composer.ts new file mode 100644 index 00000000..ac2e3c46 --- /dev/null +++ b/types/generated/mars-swapper-base/MarsSwapperBase.message-composer.ts @@ -0,0 +1,200 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { MsgExecuteContractEncodeObject } from 'cosmwasm' +import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx' +import { toUtf8 } from '@cosmjs/encoding' +import { + InstantiateMsg, + ExecuteMsg, + Uint128, + Decimal, + Addr, + Empty, + Coin, + QueryMsg, + ConfigForString, + EstimateExactInSwapResponse, + RouteResponseForEmpty, + ArrayOfRouteResponseForEmpty, +} from './MarsSwapperBase.types' +export interface MarsSwapperBaseMessage { + contractAddress: string + sender: string + updateConfig: ( + { + owner, + }: { + owner?: string + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + setRoute: ( + { + denomIn, + denomOut, + route, + }: { + denomIn: string + denomOut: string + route: Empty + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + swapExactIn: ( + { + coinIn, + denomOut, + slippage, + }: { + coinIn: Coin + denomOut: string + slippage: Decimal + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject + transferResult: ( + { + denomIn, + denomOut, + recipient, + }: { + denomIn: string + denomOut: string + recipient: Addr + }, + funds?: Coin[], + ) => MsgExecuteContractEncodeObject +} +export class MarsSwapperBaseMessageComposer implements MarsSwapperBaseMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.updateConfig = this.updateConfig.bind(this) + this.setRoute = this.setRoute.bind(this) + this.swapExactIn = this.swapExactIn.bind(this) + this.transferResult = this.transferResult.bind(this) + } + + updateConfig = ( + { + owner, + }: { + owner?: string + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_config: { + owner, + }, + }), + ), + funds, + }), + } + } + setRoute = ( + { + denomIn, + denomOut, + route, + }: { + denomIn: string + denomOut: string + route: Empty + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + set_route: { + denom_in: denomIn, + denom_out: denomOut, + route, + }, + }), + ), + funds, + }), + } + } + swapExactIn = ( + { + coinIn, + denomOut, + slippage, + }: { + coinIn: Coin + denomOut: string + slippage: Decimal + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + swap_exact_in: { + coin_in: coinIn, + denom_out: denomOut, + slippage, + }, + }), + ), + funds, + }), + } + } + transferResult = ( + { + denomIn, + denomOut, + recipient, + }: { + denomIn: string + denomOut: string + recipient: Addr + }, + funds?: Coin[], + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract', + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + transfer_result: { + denom_in: denomIn, + denom_out: denomOut, + recipient, + }, + }), + ), + funds, + }), + } + } +} diff --git a/types/generated/swapper-base/SwapperBase.react-query.ts b/types/generated/mars-swapper-base/MarsSwapperBase.react-query.ts similarity index 55% rename from types/generated/swapper-base/SwapperBase.react-query.ts rename to types/generated/mars-swapper-base/MarsSwapperBase.react-query.ts index 7683bb62..1c41e583 100644 --- a/types/generated/swapper-base/SwapperBase.react-query.ts +++ b/types/generated/mars-swapper-base/MarsSwapperBase.react-query.ts @@ -1,54 +1,53 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { StdFee } from '@cosmjs/amino' +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { SwapperBaseClient, SwapperBaseQueryClient } from './SwapperBase.client' +import { StdFee } from '@cosmjs/amino' import { - Addr, - ArrayOfRouteResponseForEmpty, - Coin, - ConfigForString, - Decimal, - Empty, - EstimateExactInSwapResponse, - ExecuteMsg, InstantiateMsg, - QueryMsg, - RouteResponseForEmpty, + ExecuteMsg, Uint128, -} from './SwapperBase.types' -export const swapperBaseQueryKeys = { + Decimal, + Addr, + Empty, + Coin, + QueryMsg, + ConfigForString, + EstimateExactInSwapResponse, + RouteResponseForEmpty, + ArrayOfRouteResponseForEmpty, +} from './MarsSwapperBase.types' +import { MarsSwapperBaseQueryClient, MarsSwapperBaseClient } from './MarsSwapperBase.client' +export const marsSwapperBaseQueryKeys = { contract: [ { - contract: 'swapperBase', + contract: 'marsSwapperBase', }, ] as const, address: (contractAddress: string | undefined) => - [{ ...swapperBaseQueryKeys.contract[0], address: contractAddress }] as const, + [{ ...marsSwapperBaseQueryKeys.contract[0], address: contractAddress }] as const, config: (contractAddress: string | undefined, args?: Record) => - [{ ...swapperBaseQueryKeys.address(contractAddress)[0], method: 'config', args }] as const, + [{ ...marsSwapperBaseQueryKeys.address(contractAddress)[0], method: 'config', args }] as const, route: (contractAddress: string | undefined, args?: Record) => - [{ ...swapperBaseQueryKeys.address(contractAddress)[0], method: 'route', args }] as const, + [{ ...marsSwapperBaseQueryKeys.address(contractAddress)[0], method: 'route', args }] as const, routes: (contractAddress: string | undefined, args?: Record) => - [{ ...swapperBaseQueryKeys.address(contractAddress)[0], method: 'routes', args }] as const, + [{ ...marsSwapperBaseQueryKeys.address(contractAddress)[0], method: 'routes', args }] as const, estimateExactInSwap: (contractAddress: string | undefined, args?: Record) => [ { - ...swapperBaseQueryKeys.address(contractAddress)[0], + ...marsSwapperBaseQueryKeys.address(contractAddress)[0], method: 'estimate_exact_in_swap', args, }, ] as const, } -export interface SwapperBaseReactQuery { - client: SwapperBaseQueryClient | undefined +export interface MarsSwapperBaseReactQuery { + client: MarsSwapperBaseQueryClient | undefined options?: Omit< UseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'" @@ -56,20 +55,20 @@ export interface SwapperBaseReactQuery { initialData?: undefined } } -export interface SwapperBaseEstimateExactInSwapQuery - extends SwapperBaseReactQuery { +export interface MarsSwapperBaseEstimateExactInSwapQuery + extends MarsSwapperBaseReactQuery { args: { coinIn: Coin denomOut: string } } -export function useSwapperBaseEstimateExactInSwapQuery({ +export function useMarsSwapperBaseEstimateExactInSwapQuery({ client, args, options, -}: SwapperBaseEstimateExactInSwapQuery) { +}: MarsSwapperBaseEstimateExactInSwapQuery) { return useQuery( - swapperBaseQueryKeys.estimateExactInSwap(client?.contractAddress, args), + marsSwapperBaseQueryKeys.estimateExactInSwap(client?.contractAddress, args), () => client ? client.estimateExactInSwap({ @@ -80,20 +79,20 @@ export function useSwapperBaseEstimateExactInSwapQuery - extends SwapperBaseReactQuery { +export interface MarsSwapperBaseRoutesQuery + extends MarsSwapperBaseReactQuery { args: { limit?: number startAfter?: string[][] } } -export function useSwapperBaseRoutesQuery({ +export function useMarsSwapperBaseRoutesQuery({ client, args, options, -}: SwapperBaseRoutesQuery) { +}: MarsSwapperBaseRoutesQuery) { return useQuery( - swapperBaseQueryKeys.routes(client?.contractAddress, args), + marsSwapperBaseQueryKeys.routes(client?.contractAddress, args), () => client ? client.routes({ @@ -104,20 +103,20 @@ export function useSwapperBaseRoutesQuery( { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface SwapperBaseRouteQuery - extends SwapperBaseReactQuery { +export interface MarsSwapperBaseRouteQuery + extends MarsSwapperBaseReactQuery { args: { denomIn: string denomOut: string } } -export function useSwapperBaseRouteQuery({ +export function useMarsSwapperBaseRouteQuery({ client, args, options, -}: SwapperBaseRouteQuery) { +}: MarsSwapperBaseRouteQuery) { return useQuery( - swapperBaseQueryKeys.route(client?.contractAddress, args), + marsSwapperBaseQueryKeys.route(client?.contractAddress, args), () => client ? client.route({ @@ -128,20 +127,20 @@ export function useSwapperBaseRouteQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface SwapperBaseConfigQuery - extends SwapperBaseReactQuery {} -export function useSwapperBaseConfigQuery({ +export interface MarsSwapperBaseConfigQuery + extends MarsSwapperBaseReactQuery {} +export function useMarsSwapperBaseConfigQuery({ client, options, -}: SwapperBaseConfigQuery) { +}: MarsSwapperBaseConfigQuery) { return useQuery( - swapperBaseQueryKeys.config(client?.contractAddress), + marsSwapperBaseQueryKeys.config(client?.contractAddress), () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } -export interface SwapperBaseTransferResultMutation { - client: SwapperBaseClient +export interface MarsSwapperBaseTransferResultMutation { + client: MarsSwapperBaseClient msg: { denomIn: string denomOut: string @@ -153,20 +152,20 @@ export interface SwapperBaseTransferResultMutation { funds?: Coin[] } } -export function useSwapperBaseTransferResultMutation( +export function useMarsSwapperBaseTransferResultMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.transferResult(msg, fee, memo, funds), options, ) } -export interface SwapperBaseSwapExactInMutation { - client: SwapperBaseClient +export interface MarsSwapperBaseSwapExactInMutation { + client: MarsSwapperBaseClient msg: { coinIn: Coin denomOut: string @@ -178,19 +177,19 @@ export interface SwapperBaseSwapExactInMutation { funds?: Coin[] } } -export function useSwapperBaseSwapExactInMutation( +export function useMarsSwapperBaseSwapExactInMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.swapExactIn(msg, fee, memo, funds), options, ) } -export interface SwapperBaseSetRouteMutation { - client: SwapperBaseClient +export interface MarsSwapperBaseSetRouteMutation { + client: MarsSwapperBaseClient msg: { denomIn: string denomOut: string @@ -202,19 +201,19 @@ export interface SwapperBaseSetRouteMutation { funds?: Coin[] } } -export function useSwapperBaseSetRouteMutation( +export function useMarsSwapperBaseSetRouteMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.setRoute(msg, fee, memo, funds), options, ) } -export interface SwapperBaseUpdateConfigMutation { - client: SwapperBaseClient +export interface MarsSwapperBaseUpdateConfigMutation { + client: MarsSwapperBaseClient msg: { owner?: string } @@ -224,13 +223,13 @@ export interface SwapperBaseUpdateConfigMutation { funds?: Coin[] } } -export function useSwapperBaseUpdateConfigMutation( +export function useMarsSwapperBaseUpdateConfigMutation( options?: Omit< - UseMutationOptions, + UseMutationOptions, 'mutationFn' >, ) { - return useMutation( + return useMutation( ({ client, msg, args: { fee, memo, funds } = {} }) => client.updateConfig(msg, fee, memo, funds), options, diff --git a/types/generated/swapper-base/SwapperBase.types.ts b/types/generated/mars-swapper-base/MarsSwapperBase.types.ts similarity index 99% rename from types/generated/swapper-base/SwapperBase.types.ts rename to types/generated/mars-swapper-base/MarsSwapperBase.types.ts index b6863f76..1d2483af 100644 --- a/types/generated/swapper-base/SwapperBase.types.ts +++ b/types/generated/mars-swapper-base/MarsSwapperBase.types.ts @@ -1,6 +1,6 @@ // @ts-nocheck /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ diff --git a/types/generated/mars-swapper-base/bundle.ts b/types/generated/mars-swapper-base/bundle.ts new file mode 100644 index 00000000..b3664011 --- /dev/null +++ b/types/generated/mars-swapper-base/bundle.ts @@ -0,0 +1,14 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.20.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _28 from './MarsSwapperBase.types' +import * as _29 from './MarsSwapperBase.client' +import * as _30 from './MarsSwapperBase.message-composer' +import * as _31 from './MarsSwapperBase.react-query' +export namespace contracts { + export const MarsSwapperBase = { ..._28, ..._29, ..._30, ..._31 } +} diff --git a/types/generated/mock-oracle/bundle.ts b/types/generated/mock-oracle/bundle.ts deleted file mode 100644 index 11e9ab83..00000000 --- a/types/generated/mock-oracle/bundle.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import * as _10 from './MockOracle.client' -import * as _11 from './MockOracle.react-query' -import * as _9 from './MockOracle.types' -export namespace contracts { - export const MockOracle = { ..._9, ..._10, ..._11 } -} diff --git a/types/generated/mock-red-bank/MockRedBank.react-query.ts b/types/generated/mock-red-bank/MockRedBank.react-query.ts deleted file mode 100644 index 1c9f3885..00000000 --- a/types/generated/mock-red-bank/MockRedBank.react-query.ts +++ /dev/null @@ -1,133 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import { StdFee } from '@cosmjs/amino' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { MockRedBankClient, MockRedBankQueryClient } from './MockRedBank.client' -import { - Coin, - CoinMarketInfo, - Decimal, - ExecuteMsg, - InstantiateMsg, - InterestRateModel, - Market, - QueryMsg, - Uint128, - UserAssetDebtResponse, -} from './MockRedBank.types' -export const mockRedBankQueryKeys = { - contract: [ - { - contract: 'mockRedBank', - }, - ] as const, - address: (contractAddress: string | undefined) => - [{ ...mockRedBankQueryKeys.contract[0], address: contractAddress }] as const, - userAssetDebt: (contractAddress: string | undefined, args?: Record) => - [ - { ...mockRedBankQueryKeys.address(contractAddress)[0], method: 'user_asset_debt', args }, - ] as const, - market: (contractAddress: string | undefined, args?: Record) => - [{ ...mockRedBankQueryKeys.address(contractAddress)[0], method: 'market', args }] as const, -} -export interface MockRedBankReactQuery { - client: MockRedBankQueryClient | undefined - options?: Omit< - UseQueryOptions, - "'queryKey' | 'queryFn' | 'initialData'" - > & { - initialData?: undefined - } -} -export interface MockRedBankMarketQuery extends MockRedBankReactQuery { - args: { - denom: string - } -} -export function useMockRedBankMarketQuery({ - client, - args, - options, -}: MockRedBankMarketQuery) { - return useQuery( - mockRedBankQueryKeys.market(client?.contractAddress, args), - () => - client - ? client.market({ - denom: args.denom, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MockRedBankUserAssetDebtQuery - extends MockRedBankReactQuery { - args: { - denom: string - userAddress: string - } -} -export function useMockRedBankUserAssetDebtQuery({ - client, - args, - options, -}: MockRedBankUserAssetDebtQuery) { - return useQuery( - mockRedBankQueryKeys.userAssetDebt(client?.contractAddress, args), - () => - client - ? client.userAssetDebt({ - denom: args.denom, - userAddress: args.userAddress, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MockRedBankRepayMutation { - client: MockRedBankClient - msg: { - denom: string - onBehalfOf?: string - } - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useMockRedBankRepayMutation( - options?: Omit, 'mutationFn'>, -) { - return useMutation( - ({ client, msg, args: { fee, memo, funds } = {} }) => client.repay(msg, fee, memo, funds), - options, - ) -} -export interface MockRedBankBorrowMutation { - client: MockRedBankClient - msg: { - coin: Coin - recipient?: string - } - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useMockRedBankBorrowMutation( - options?: Omit, 'mutationFn'>, -) { - return useMutation( - ({ client, msg, args: { fee, memo, funds } = {} }) => client.borrow(msg, fee, memo, funds), - options, - ) -} diff --git a/types/generated/mock-red-bank/MockRedBank.types.ts b/types/generated/mock-red-bank/MockRedBank.types.ts deleted file mode 100644 index ee4ae957..00000000 --- a/types/generated/mock-red-bank/MockRedBank.types.ts +++ /dev/null @@ -1,77 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -export type Decimal = string -export interface InstantiateMsg { - coins: CoinMarketInfo[] -} -export interface CoinMarketInfo { - denom: string - liquidation_threshold: Decimal - max_ltv: Decimal -} -export type ExecuteMsg = - | { - borrow: { - coin: Coin - recipient?: string | null - } - } - | { - repay: { - denom: string - on_behalf_of?: string | null - } - } -export type Uint128 = string -export interface Coin { - amount: Uint128 - denom: string - [k: string]: unknown -} -export type QueryMsg = - | { - user_asset_debt: { - denom: string - user_address: string - } - } - | { - market: { - denom: string - } - } -export interface Market { - borrow_enabled: boolean - borrow_index: Decimal - borrow_rate: Decimal - collateral_total_scaled: Uint128 - debt_total_scaled: Uint128 - denom: string - deposit_cap: Uint128 - deposit_enabled: boolean - indexes_last_updated: number - interest_rate_model: InterestRateModel - liquidation_bonus: Decimal - liquidation_threshold: Decimal - liquidity_index: Decimal - liquidity_rate: Decimal - max_loan_to_value: Decimal - reserve_factor: Decimal - [k: string]: unknown -} -export interface InterestRateModel { - base: Decimal - optimal_utilization_rate: Decimal - slope_1: Decimal - slope_2: Decimal - [k: string]: unknown -} -export interface UserAssetDebtResponse { - amount: Uint128 - denom: string -} diff --git a/types/generated/mock-red-bank/bundle.ts b/types/generated/mock-red-bank/bundle.ts deleted file mode 100644 index 9486e666..00000000 --- a/types/generated/mock-red-bank/bundle.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import * as _13 from './MockRedBank.client' -import * as _14 from './MockRedBank.react-query' -import * as _12 from './MockRedBank.types' -export namespace contracts { - export const MockRedBank = { ..._12, ..._13, ..._14 } -} diff --git a/types/generated/mock-vault/MockVault.client.ts b/types/generated/mock-vault/MockVault.client.ts deleted file mode 100644 index b0719bbd..00000000 --- a/types/generated/mock-vault/MockVault.client.ts +++ /dev/null @@ -1,135 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import { StdFee } from '@cosmjs/amino' -import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' - -import { - ArrayOfCoin, - Coin, - ExecuteMsg, - InstantiateMsg, - OracleBaseForString, - QueryMsg, - Uint128, - VaultInfo, -} from './MockVault.types' -export interface MockVaultReadOnlyInterface { - contractAddress: string - info: () => Promise - previewRedeem: ({ amount }: { amount: Uint128 }) => Promise - totalVaultCoinsIssued: () => Promise -} -export class MockVaultQueryClient implements MockVaultReadOnlyInterface { - client: CosmWasmClient - contractAddress: string - - constructor(client: CosmWasmClient, contractAddress: string) { - this.client = client - this.contractAddress = contractAddress - this.info = this.info.bind(this) - this.previewRedeem = this.previewRedeem.bind(this) - this.totalVaultCoinsIssued = this.totalVaultCoinsIssued.bind(this) - } - - info = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - info: {}, - }) - } - previewRedeem = async ({ amount }: { amount: Uint128 }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - preview_redeem: { - amount, - }, - }) - } - totalVaultCoinsIssued = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - total_vault_coins_issued: {}, - }) - } -} -export interface MockVaultInterface extends MockVaultReadOnlyInterface { - contractAddress: string - sender: string - deposit: (fee?: number | StdFee | 'auto', memo?: string, funds?: Coin[]) => Promise - withdraw: ( - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise - forceWithdraw: ( - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise -} -export class MockVaultClient extends MockVaultQueryClient implements MockVaultInterface { - client: SigningCosmWasmClient - sender: string - contractAddress: string - - constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { - super(client, contractAddress) - this.client = client - this.sender = sender - this.contractAddress = contractAddress - this.deposit = this.deposit.bind(this) - this.withdraw = this.withdraw.bind(this) - this.forceWithdraw = this.forceWithdraw.bind(this) - } - - deposit = async ( - fee: number | StdFee | 'auto' = 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - deposit: {}, - }, - fee, - memo, - funds, - ) - } - withdraw = async ( - fee: number | StdFee | 'auto' = 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - withdraw: {}, - }, - fee, - memo, - funds, - ) - } - forceWithdraw = async ( - fee: number | StdFee | 'auto' = 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - force_withdraw: {}, - }, - fee, - memo, - funds, - ) - } -} diff --git a/types/generated/mock-vault/MockVault.react-query.ts b/types/generated/mock-vault/MockVault.react-query.ts deleted file mode 100644 index 6e765ba4..00000000 --- a/types/generated/mock-vault/MockVault.react-query.ts +++ /dev/null @@ -1,150 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import { StdFee } from '@cosmjs/amino' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { MockVaultClient, MockVaultQueryClient } from './MockVault.client' -import { - ArrayOfCoin, - Coin, - ExecuteMsg, - InstantiateMsg, - OracleBaseForString, - QueryMsg, - Uint128, - VaultInfo, -} from './MockVault.types' -export const mockVaultQueryKeys = { - contract: [ - { - contract: 'mockVault', - }, - ] as const, - address: (contractAddress: string | undefined) => - [{ ...mockVaultQueryKeys.contract[0], address: contractAddress }] as const, - info: (contractAddress: string | undefined, args?: Record) => - [{ ...mockVaultQueryKeys.address(contractAddress)[0], method: 'info', args }] as const, - previewRedeem: (contractAddress: string | undefined, args?: Record) => - [ - { ...mockVaultQueryKeys.address(contractAddress)[0], method: 'preview_redeem', args }, - ] as const, - totalVaultCoinsIssued: (contractAddress: string | undefined, args?: Record) => - [ - { - ...mockVaultQueryKeys.address(contractAddress)[0], - method: 'total_vault_coins_issued', - args, - }, - ] as const, -} -export interface MockVaultReactQuery { - client: MockVaultQueryClient | undefined - options?: Omit< - UseQueryOptions, - "'queryKey' | 'queryFn' | 'initialData'" - > & { - initialData?: undefined - } -} -export interface MockVaultTotalVaultCoinsIssuedQuery - extends MockVaultReactQuery {} -export function useMockVaultTotalVaultCoinsIssuedQuery({ - client, - options, -}: MockVaultTotalVaultCoinsIssuedQuery) { - return useQuery( - mockVaultQueryKeys.totalVaultCoinsIssued(client?.contractAddress), - () => (client ? client.totalVaultCoinsIssued() : Promise.reject(new Error('Invalid client'))), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MockVaultPreviewRedeemQuery - extends MockVaultReactQuery { - args: { - amount: Uint128 - } -} -export function useMockVaultPreviewRedeemQuery({ - client, - args, - options, -}: MockVaultPreviewRedeemQuery) { - return useQuery( - mockVaultQueryKeys.previewRedeem(client?.contractAddress, args), - () => - client - ? client.previewRedeem({ - amount: args.amount, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MockVaultInfoQuery extends MockVaultReactQuery {} -export function useMockVaultInfoQuery({ - client, - options, -}: MockVaultInfoQuery) { - return useQuery( - mockVaultQueryKeys.info(client?.contractAddress), - () => (client ? client.info() : Promise.reject(new Error('Invalid client'))), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MockVaultForceWithdrawMutation { - client: MockVaultClient - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useMockVaultForceWithdrawMutation( - options?: Omit< - UseMutationOptions, - 'mutationFn' - >, -) { - return useMutation( - ({ client, args: { fee, memo, funds } = {} }) => client.forceWithdraw(fee, memo, funds), - options, - ) -} -export interface MockVaultWithdrawMutation { - client: MockVaultClient - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useMockVaultWithdrawMutation( - options?: Omit, 'mutationFn'>, -) { - return useMutation( - ({ client, args: { fee, memo, funds } = {} }) => client.withdraw(fee, memo, funds), - options, - ) -} -export interface MockVaultDepositMutation { - client: MockVaultClient - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useMockVaultDepositMutation( - options?: Omit, 'mutationFn'>, -) { - return useMutation( - ({ client, args: { fee, memo, funds } = {} }) => client.deposit(fee, memo, funds), - options, - ) -} diff --git a/types/generated/mock-vault/bundle.ts b/types/generated/mock-vault/bundle.ts deleted file mode 100644 index d681312e..00000000 --- a/types/generated/mock-vault/bundle.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import * as _16 from './MockVault.client' -import * as _17 from './MockVault.react-query' -import * as _15 from './MockVault.types' -export namespace contracts { - export const MockVault = { ..._15, ..._16, ..._17 } -} diff --git a/types/generated/swapper-base/bundle.ts b/types/generated/swapper-base/bundle.ts deleted file mode 100644 index ae771c7f..00000000 --- a/types/generated/swapper-base/bundle.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import * as _19 from './SwapperBase.client' -import * as _20 from './SwapperBase.react-query' -import * as _18 from './SwapperBase.types' -export namespace contracts { - export const SwapperBase = { ..._18, ..._19, ..._20 } -} diff --git a/types/query-keys-factory.ts b/types/query-keys-factory.ts index 523ad14a..e77f9096 100644 --- a/types/query-keys-factory.ts +++ b/types/query-keys-factory.ts @@ -5,4 +5,5 @@ export const queryKeys = { creditAccounts: (address: string) => ['creditAccounts', address], creditAccountsPositions: (accountId: string) => ['creditAccountPositions', accountId], tokenBalance: (address: string, denom: string) => ['tokenBalance', address, denom], + tokenPrices: () => ['tokenPrices'], } diff --git a/utils/contants.ts b/utils/contants.ts index 3ad00ac0..154e2950 100644 --- a/utils/contants.ts +++ b/utils/contants.ts @@ -9,5 +9,5 @@ export const hardcodedFee = { amount: '100000', }, ], - gas: '1500000', + gas: '2000000', } diff --git a/yarn.lock b/yarn.lock index e523e844..bcfc7b26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1422,6 +1422,11 @@ "@ethersproject/bytes" "^5.7.0" "@ethersproject/logger" "^5.7.0" +"@graphql-typed-document-node/core@^3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.1.1.tgz#076d78ce99822258cf813ecc1e7fa460fa74d052" + integrity sha512-NQ17ii0rK1b34VZonlmT2QMJFI70m0TRwbknO/ihlbatXyaktDhN/98vBiUU6kNBPljqGqyIrl2T4nY2RpFANg== + "@headlessui/react@^1.7.0": version "1.7.0" resolved "https://registry.npmjs.org/@headlessui/react/-/react-1.7.0.tgz" @@ -3083,6 +3088,13 @@ create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-fetch@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" + integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== + dependencies: + node-fetch "2.6.7" + cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" @@ -3708,6 +3720,11 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" +extract-files@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/extract-files/-/extract-files-9.0.0.tgz#8a7744f2437f81f5ed3250ed9f1550de902fe54a" + integrity sha512-CvdFfHkC95B4bBBk36hcEmvdR2awOdhhVUYH6S/zrVj3477zven/fJMYg7121h4T1xHZC+tetUpubpAhxwI7hQ== + fast-deep-equal@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" @@ -3827,6 +3844,15 @@ for-in@^1.0.2: resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz" integrity sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ== +form-data@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + form-data@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" @@ -4015,6 +4041,21 @@ grapheme-splitter@^1.0.4: resolved "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz" integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== +graphql-request@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-5.0.0.tgz#7504a807d0e11be11a3c448e900f0cc316aa18ef" + integrity sha512-SpVEnIo2J5k2+Zf76cUkdvIRaq5FMZvGQYnA4lUWYbc99m+fHh4CZYRRO/Ff4tCLQ613fzCm3SiDT64ubW5Gyw== + dependencies: + "@graphql-typed-document-node/core" "^3.1.1" + cross-fetch "^3.1.5" + extract-files "^9.0.0" + form-data "^3.0.0" + +graphql@^16.6.0: + version "16.6.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.6.0.tgz#c2dcffa4649db149f6282af726c8c83f1c7c5fdb" + integrity sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw== + has-bigints@^1.0.1, has-bigints@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz" @@ -4919,7 +4960,7 @@ node-dir@^0.1.17: dependencies: minimatch "^3.0.2" -node-fetch@^2.6.7: +node-fetch@2.6.7, node-fetch@^2.6.7: version "2.6.7" resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==