Perp queries (#711)

* update assets config and chains

* make clients dynamic

* feat: formatted ChainSelect

* fix infinite rerender on trade page

* feat: added NTRN icon

* fix: fixed ChainInfoID

* fix: fixed autoLendEnabled for NTRN

* fix: fixed the navigation and dependencies

* fix: fixed the pricefeed id

* fix: fixed the header menu

* fix: fixed the trading charts

* fix: fixed the healthbars

* fix: fixed naming of pion-1

* feast: updated xdefi image

* env: updated contracts

* make localStorage chain agnostic

* fix: made the selected chain persistant

* fix: fixed the wallet providers

* fix: updated auto connect

* fix: fixed auto connecting

* fix: added ChainSelect to focusMode

* store raw strings in localstorage

* 🔥 remnove tests

* update caching keys + disconnect wallet on change chain

* update contract types and add perps asset select overlay

* fix build + add perps positions to accounts

---------

Co-authored-by: Linkie Link <linkielink.dev@gmail.com>
This commit is contained in:
Bob van der Helm 2024-01-04 12:13:09 +01:00 committed by GitHub
parent 2197dc917a
commit a2b6acbccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 3898 additions and 290 deletions

View File

@ -29,6 +29,7 @@ export default async function getAccount(
lends: accountPosition.lends.map((lend) => new BNCoin(lend)),
deposits: accountPosition.deposits.map((deposit) => new BNCoin(deposit)),
vaults: depositedVaults,
perps: accountPosition.perps,
kind: accountKind,
}
}

View File

@ -5,7 +5,6 @@ export default async function getICNS(
chainConfig: ChainConfig,
address?: string,
): Promise<ICNSResult | undefined> {
// TODO: Make this also work for different chains?
if (!address || chainConfig.id !== ChainInfoID.Osmosis1) return
try {
const icnsQueryClient = await getICNSQueryClient(chainConfig)

View File

@ -3,39 +3,35 @@ import { useState } from 'react'
import Button from 'components/Button'
import Card from 'components/Card'
import { DirectionSelect } from 'components/DirectionSelect'
import { ChevronDown } from 'components/Icons'
import { LeverageButtons } from 'components/Perps/Module/LeverageButtons'
import { Or } from 'components/Perps/Module/Or'
import RangeInput from 'components/RangeInput'
import { Spacer } from 'components/Spacer'
import Text from 'components/Text'
import AssetSelectorPerps from 'components/Trade/TradeModule/AssetSelector/AssetSelectorPerps'
import AssetAmountInput from 'components/Trade/TradeModule/SwapForm/AssetAmountInput'
import OrderTypeSelector from 'components/Trade/TradeModule/SwapForm/OrderTypeSelector'
import { AvailableOrderType } from 'components/Trade/TradeModule/SwapForm/OrderTypeSelector/types'
import { BN_ZERO } from 'constants/math'
import useBaseAsset from 'hooks/assets/useBasetAsset'
import usePerpsAsset from 'hooks/perps/usePerpsAsset'
export function PerpsModule() {
const [selectedOrderType, setSelectedOrderType] = useState<AvailableOrderType>('Market')
const [selectedOrderDirection, setSelectedOrderDirection] = useState<OrderDirection>('long')
const baseAsset = useBaseAsset()
const { perpsAsset } = usePerpsAsset()
if (!perpsAsset) return null
return (
<Card
contentClassName='px-4 gap-5 flex flex-col'
title={
<div className='flex items-center justify-between py-4 pl-4 pr-2 bg-white/10'>
<Text>
ETH<span className='text-white/60'>/USD</span>
</Text>
<Button color='quaternary' variant='transparent' rightIcon={<ChevronDown />}>
All Markets
</Button>
</div>
}
title={<AssetSelectorPerps asset={perpsAsset} />}
className='mb-4'
>
<OrderTypeSelector selected={selectedOrderType} onChange={setSelectedOrderType} />
<DirectionSelect
direction={selectedOrderDirection}
onChangeDirection={setSelectedOrderDirection}

View File

@ -2,12 +2,15 @@ import React from 'react'
import TradeChart from 'components/Trade/TradeChart'
import useAllAssets from 'hooks/assets/useAllAssets'
import usePerpsAsset from 'hooks/perps/usePerpsAsset'
export function PerpsChart() {
const assets = useAllAssets()
const { perpsAsset } = usePerpsAsset()
return (
<div className='h-full'>
<TradeChart buyAsset={assets[0]} sellAsset={assets[1]} />
<TradeChart buyAsset={perpsAsset} sellAsset={assets[1]} />
</div>
)
}

View File

@ -15,8 +15,10 @@ export function PerpsInfo() {
const { data: market } = usePerpsMarket()
const assetPrice = usePrice(market?.asset.denom || '')
const items = useMemo(
() => [
const items = useMemo(() => {
if (!market) return []
return [
...(!assetPrice.isZero()
? [<DisplayCurrency key='price' coin={BNCoin.fromDenomAndBigNumber('usd', assetPrice)} />]
: [<Loading key='price' className='w-14 h-4' />]),
@ -45,9 +47,8 @@ export function PerpsInfo() {
)
}
/>,
],
[assetPrice, market],
)
]
}, [assetPrice, market])
return (
<Card contentClassName='bg-white/10 py-3.5 px-4'>

View File

@ -41,6 +41,7 @@ export default function PortfolioSummary() {
lends: [],
debts: [],
vaults: [],
perps: [],
kind: 'default',
} as Account,
)

View File

@ -5,9 +5,9 @@ import DisplayCurrency from 'components/DisplayCurrency'
import { FormattedNumber } from 'components/FormattedNumber'
import Loading from 'components/Loading'
import Text from 'components/Text'
import { disabledFeatures, enabledFeatures, overrides } from 'components/Trade/TradeChart/constants'
import { DataFeed, PAIR_SEPARATOR } from 'components/Trade/TradeChart/DataFeed'
import PoweredByPyth from 'components/Trade/TradeChart/PoweredByPyth'
import { disabledFeatures, enabledFeatures, overrides } from 'components/Trade/TradeChart/constants'
import { BN_ZERO } from 'constants/math'
import useAllAssets from 'hooks/assets/useAllAssets'
import useBaseAsset from 'hooks/assets/useBasetAsset'

View File

@ -15,7 +15,7 @@ import { byDenom } from 'utils/array'
import { sortAssetsOrPairs } from 'utils/assets'
interface Props {
type: 'buy' | 'sell'
type: 'buy' | 'sell' | 'perps'
assets: Asset[]
isOpen: boolean
toggleOpen: () => void
@ -42,13 +42,15 @@ export default function AssetList(props: Props) {
return (
<section>
<button
className='flex items-center justify-between w-full p-4 bg-black/20'
onClick={toggleOpen}
>
<Text>{type === 'buy' ? 'Buy asset' : 'Sell asset'}</Text>
<ChevronDown className={classNames(isOpen && '-rotate-180', 'w-4')} />
</button>
{type !== 'perps' && (
<button
className='flex items-center justify-between w-full p-4 bg-black/20'
onClick={toggleOpen}
>
<Text>{type === 'buy' ? 'Buy asset' : 'Sell asset'}</Text>
<ChevronDown className={classNames(isOpen && '-rotate-180', 'w-4')} />
</button>
)}
{isOpen &&
(sortedAssets.length === 0 ? (
<Text size='xs' className='p-4'>

View File

@ -0,0 +1,33 @@
import Button from 'components/Button'
import Divider from 'components/Divider'
interface StablesFilterProps {
onFilter: (stables: Asset[]) => void
selectedStables: Asset[]
stables: Asset[]
}
export default function StablesFilter(props: StablesFilterProps) {
const { stables, selectedStables, onFilter } = props
const isAllSelected = selectedStables.length > 1
return (
<>
<Divider />
<div className='flex items-center w-full gap-2 p-2'>
{stables.map((stable) => {
const isCurrent = !isAllSelected && selectedStables[0].denom === stable.denom
return (
<Button
key={stable.symbol}
onClick={() => onFilter([stable])}
text={stable.symbol}
color={isCurrent ? 'secondary' : 'quaternary'}
variant='transparent'
className={isCurrent ? '!text-white !bg-white/10 border-white' : ''}
/>
)
})}
</div>
</>
)
}

View File

@ -1,6 +1,5 @@
import { useCallback, useMemo, useState } from 'react'
import Button from 'components/Button'
import EscButton from 'components/Button/EscButton'
import Divider from 'components/Divider'
import Overlay from 'components/Overlay'
@ -11,50 +10,22 @@ import PairsList from 'components/Trade/TradeModule/AssetSelector/PairsList'
import useAllAssets from 'hooks/assets/useAllAssets'
import useFilteredAssets from 'hooks/useFilteredAssets'
import StablesFilter from './StablesFilter'
interface Props {
state: OverlayState
buyAsset: Asset
sellAsset: Asset
buyAssets: Asset[]
onChangeBuyAsset?: (asset: Asset) => void
onChangeSellAsset?: (asset: Asset) => void
onChangeTradingPair?: (tradingPair: TradingPair) => void
onChangeState: (state: OverlayState) => void
}
interface StablesFilterProps {
stables: Asset[]
selectedStables: Asset[]
onFilter: (stables: Asset[]) => void
}
function StablesFilter(props: StablesFilterProps) {
const { stables, selectedStables, onFilter } = props
const isAllSelected = selectedStables.length > 1
return (
<>
<Divider />
<div className='flex items-center w-full gap-2 p-2'>
{stables.map((stable) => {
const isCurrent = !isAllSelected && selectedStables[0].denom === stable.denom
return (
<Button
key={stable.symbol}
onClick={() => onFilter([stable])}
text={stable.symbol}
color={isCurrent ? 'secondary' : 'quaternary'}
variant='transparent'
className={isCurrent ? '!text-white !bg-white/10 border-white' : ''}
/>
)
})}
</div>
</>
)
type: 'pair' | 'single' | 'perps'
}
export default function AssetOverlay(props: Props) {
const isPairSelector = !!props.onChangeTradingPair
const { assets, searchString, onChangeSearch } = useFilteredAssets()
const { assets, searchString, onChangeSearch } = useFilteredAssets(props.buyAssets)
const allAssets = useAllAssets()
const stableAssets = useMemo(() => allAssets.filter((asset) => asset.isStable), [allAssets])
const handleClose = useCallback(() => props.onChangeState('closed'), [props])
@ -63,8 +34,10 @@ export default function AssetOverlay(props: Props) {
const buyAssets = useMemo(
() =>
isPairSelector ? assets : assets.filter((asset) => asset.denom !== props.sellAsset.denom),
[assets, props.sellAsset, isPairSelector],
props.type === 'pair'
? assets
: assets.filter((asset) => asset.denom !== props.sellAsset.denom),
[assets, props.sellAsset, props.type],
)
const sellAssets = useMemo(
@ -111,10 +84,10 @@ export default function AssetOverlay(props: Props) {
setShow={handleClose}
>
<div className='flex justify-between p-4 overflow-hidden'>
<Text>{isPairSelector ? 'Select a market' : 'Select asset'}</Text>
<Text>{props.type !== 'single' ? 'Select a market' : 'Select asset'}</Text>
<EscButton onClick={handleClose} enableKeyPress />
</div>
{isPairSelector && (
{props.type === 'pair' && (
<StablesFilter
stables={stableAssets}
selectedStables={selectedStables}
@ -132,7 +105,17 @@ export default function AssetOverlay(props: Props) {
/>
</div>
<Divider />
{isPairSelector ? (
{props.type === 'perps' && (
<AssetList
assets={props.buyAssets}
type='perps'
onChangeAsset={onChangeBuyAsset}
isOpen
toggleOpen={() => {}}
/>
)}
{props.type === 'pair' && (
<PairsList
assets={buyAssets}
stables={selectedStables}
@ -140,7 +123,9 @@ export default function AssetOverlay(props: Props) {
toggleOpen={handleToggle}
onChangeAssetPair={onChangeAssetPair}
/>
) : (
)}
{props.type === 'single' && (
<>
<AssetList
type='buy'

View File

@ -13,17 +13,17 @@ import useStore from 'store'
interface Props {
buyAsset: Asset
sellAsset: Asset
assets: Asset[]
}
export default function AssetSelectorPair(props: Props) {
const chainConfig = useChainConfig()
const [tradingPairSimple, setTradingPairSimple] = useLocalStorage<Settings['tradingPairSimple']>(
const [_, setTradingPairSimple] = useLocalStorage<Settings['tradingPairSimple']>(
chainConfig.id + '/' + LocalStorageKeys.TRADING_PAIR_SIMPLE,
DEFAULT_SETTINGS.tradingPairSimple,
)
const { buyAsset, sellAsset } = props
const assetOverlayState = useStore((s) => s.assetOverlayState)
const onChangeTradingPair = useCallback(
(tradingPair: TradingPair) => {
setTradingPairSimple(tradingPair)
@ -57,6 +57,8 @@ export default function AssetSelectorPair(props: Props) {
buyAsset={buyAsset}
sellAsset={sellAsset}
onChangeTradingPair={onChangeTradingPair}
buyAssets={props.assets}
type='pair'
/>
</>
)

View File

@ -0,0 +1,59 @@
import { useCallback } from 'react'
import Button from 'components/Button'
import { ChevronDown } from 'components/Icons'
import Text from 'components/Text'
import AssetOverlay from 'components/Trade/TradeModule/AssetSelector/AssetOverlay'
import usePerpsEnabledAssets from 'hooks/assets/usePerpsEnabledAssets'
import usePerpsAsset from 'hooks/perps/usePerpsAsset'
import useStore from 'store'
interface Props {
asset: Asset
}
export default function AssetSelectorPerps(props: Props) {
const assetOverlayState = useStore((s) => s.assetOverlayState)
const { perpsAsset, updatePerpsAsset } = usePerpsAsset()
const perpAssets = usePerpsEnabledAssets()
const onChangePerpsAsset = useCallback(
(asset: Asset) => {
updatePerpsAsset(asset.denom)
},
[updatePerpsAsset],
)
const handleChangeState = useCallback(() => {
useStore.setState({ assetOverlayState: 'closed' })
}, [])
return (
<>
<Button
color='quaternary'
variant='transparent'
onClick={() => useStore.setState({ assetOverlayState: 'pair' })}
className='flex items-center justify-between w-full py-5 bg-white/5'
>
<Text size='sm' className='text-white/60'>
<span className='text-white'>{perpsAsset.symbol}</span>/USD
</Text>
<div className='flex items-center gap-2'>
<Text>All markets</Text>
<ChevronDown className='w-3 h-3' />
</div>
</Button>
<AssetOverlay
buyAssets={perpAssets}
state={assetOverlayState}
onChangeState={handleChangeState}
buyAsset={props.asset}
sellAsset={props.asset}
onChangeBuyAsset={onChangePerpsAsset}
type='perps'
/>
</>
)
}

View File

@ -6,7 +6,9 @@ import AssetButton from 'components/Trade/TradeModule/AssetSelector/AssetButton'
import AssetOverlay from 'components/Trade/TradeModule/AssetSelector/AssetOverlay'
import { DEFAULT_SETTINGS } from 'constants/defaultSettings'
import { LocalStorageKeys } from 'constants/localStorageKeys'
import useMarketEnabledAssets from 'hooks/assets/useMarketEnabledAssets'
import useLocalStorage from 'hooks/localStorage/useLocalStorage'
import useChainConfig from 'hooks/useChainConfig'
import useStore from 'store'
interface Props {
@ -15,30 +17,33 @@ interface Props {
}
export default function AssetSelectorSingle(props: Props) {
const [tradingPairAdvanced, settradingPairAdvanced] = useLocalStorage<
Settings['tradingPairAdvanced']
>(LocalStorageKeys.TRADING_PAIR_ADVANCED, DEFAULT_SETTINGS.tradingPairAdvanced)
const chainConfig = useChainConfig()
const [_, setTradingPairAdvanced] = useLocalStorage<Settings['tradingPairAdvanced']>(
chainConfig.id + '/' + LocalStorageKeys.TRADING_PAIR_ADVANCED,
DEFAULT_SETTINGS.tradingPairAdvanced,
)
const { buyAsset, sellAsset } = props
const assetOverlayState = useStore((s) => s.assetOverlayState)
const allAssets = useMarketEnabledAssets()
const handleSwapAssets = useCallback(() => {
settradingPairAdvanced({ buy: sellAsset.denom, sell: buyAsset.denom })
}, [settradingPairAdvanced, sellAsset, buyAsset])
setTradingPairAdvanced({ buy: sellAsset.denom, sell: buyAsset.denom })
}, [setTradingPairAdvanced, sellAsset, buyAsset])
const handleChangeBuyAsset = useCallback(
(asset: Asset) => {
settradingPairAdvanced({ buy: asset.denom, sell: sellAsset.denom })
setTradingPairAdvanced({ buy: asset.denom, sell: sellAsset.denom })
useStore.setState({ assetOverlayState: 'sell' })
},
[settradingPairAdvanced, sellAsset],
[setTradingPairAdvanced, sellAsset],
)
const handleChangeSellAsset = useCallback(
(asset: Asset) => {
settradingPairAdvanced({ buy: buyAsset.denom, sell: asset.denom })
setTradingPairAdvanced({ buy: buyAsset.denom, sell: asset.denom })
useStore.setState({ assetOverlayState: 'closed' })
},
[settradingPairAdvanced, buyAsset],
[setTradingPairAdvanced, buyAsset],
)
const handleChangeState = useCallback((state: OverlayState) => {
@ -69,6 +74,8 @@ export default function AssetSelectorSingle(props: Props) {
sellAsset={sellAsset}
onChangeBuyAsset={handleChangeBuyAsset}
onChangeSellAsset={handleChangeSellAsset}
buyAssets={allAssets}
type='single'
/>
</div>
)

View File

@ -62,7 +62,8 @@ export default function TradeSummary(props: Props) {
const [slippage] = useLocalStorage<number>(LocalStorageKeys.SLIPPAGE, DEFAULT_SETTINGS.slippage)
const assets = useAllAssets()
const sellAssetPrice = usePrice(sellAsset.denom)
const swapFee = useSwapFee(route.map((r) => r.pool_id))
// FIXME: ⛓️ Swap fee needs to be chainagnostic!
const swapFee = useSwapFee([])
const [showSummary, setShowSummary] = useToggle()
const { liquidationPrice, isUpdatingLiquidationPrice } = useLiquidationPrice(
props.liquidationPrice,

View File

@ -19,6 +19,7 @@ import TradeSummary from 'components/Trade/TradeModule/SwapForm/TradeSummary'
import { DEFAULT_SETTINGS } from 'constants/defaultSettings'
import { LocalStorageKeys } from 'constants/localStorageKeys'
import { BN_ZERO } from 'constants/math'
import useMarketEnabledAssets from 'hooks/assets/useMarketEnabledAssets'
import useLocalStorage from 'hooks/localStorage/useLocalStorage'
import useMarketAssets from 'hooks/markets/useMarketAssets'
import useMarketBorrowings from 'hooks/markets/useMarketBorrowings'
@ -82,6 +83,7 @@ export default function SwapForm(props: Props) {
const throttledEstimateExactIn = useMemo(() => asyncThrottle(estimateExactIn, 250), [])
const { computeLiquidationPrice } = useHealthComputer(updatedAccount)
const chainConfig = useChainConfig()
const assets = useMarketEnabledAssets()
const depositCapReachedCoins: BNCoin[] = useMemo(() => {
const outputMarketAsset = marketAssets.find(byDenom(outputAsset.denom))
@ -340,7 +342,7 @@ export default function SwapForm(props: Props) {
{isAdvanced ? (
<AssetSelectorSingle buyAsset={outputAsset} sellAsset={inputAsset} />
) : (
<AssetSelectorPair buyAsset={buyAsset} sellAsset={sellAsset} />
<AssetSelectorPair buyAsset={buyAsset} sellAsset={sellAsset} assets={assets} />
)}
<Divider />
<MarginToggle

View File

@ -9,9 +9,13 @@ import { ChainInfoID } from 'types/enums/wallet'
const Pion1: ChainConfig = {
assets: [
{ ...NTRN, denom: 'untrn' },
{ ...NTRN, denom: 'untrn', isPerpsEnabled: true },
{ ...USDCaxl, denom: 'ibc/F91EA2C0A23697A1048E08C2F787E3A58AC6F706A1CD2257A504925158CFC0F3' },
{ ...ATOM, denom: 'ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9' },
{
...ATOM,
denom: 'ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9',
isPerpsEnabled: true,
},
USDollar,
],
id: ChainInfoID.Pion1,
@ -33,7 +37,7 @@ const Pion1: ChainConfig = {
swap: 'https://testnet-neutron.astroport.fi/swap',
pyth: 'https://hermes.pyth.network/api',
pythCandles: 'https://benchmarks.pyth.network',
pools: '', //TODO: Implement this
pools: '', //TODO: ⛓️ Implement this
explorer: 'https://testnet.mintscan.io/neutron-testnet',
aprs: {
vaults: 'https://api.marsprotocol.io/v1/vaults/neutron',
@ -58,7 +62,7 @@ const Pion1: ChainConfig = {
features: ['ibc-transfer', 'ibc-go'],
gasPrice: '0.025untrn',
hls: false,
perps: false,
perps: true,
farm: false,
}

View File

@ -118,6 +118,7 @@ const Osmosis1: ChainConfig = {
swapper: 'osmo1wee0z8c7tcawyl647eapqs4a88q8jpa7ddy6nn2nrs7t47p2zhxswetwla',
params: 'osmo1nlmdxt9ctql2jr47qd4fpgzg84cjswxyw6q99u4y4u4q6c2f5ksq7ysent',
pyth: 'osmo13ge29x4e2s63a8ytz2px8gurtyznmue4a69n5275692v3qn3ks8q7cwck7',
perps: '',
},
defaultCurrency: {
coinDenom: 'OSMO',

View File

@ -5,6 +5,7 @@ export const EMPTY_ACCOUNT: Account = {
deposits: [],
lends: [],
vaults: [],
perps: [],
}
export const EMPTY_ACCOUNT_HLS: Account = {

View File

@ -1,7 +1,8 @@
import { ORACLE_DENOM } from 'constants/oracle'
import useStore from 'store'
// TODO: This does not work -> Needs to be inside a hook. Does not retrigger when changed
// This does not retrigger when chains are switched. Assets might not be present on the new chain, but
// This scenario is still caught.
const enabledMarketAssets = useStore
.getState()
.chainConfig.assets.filter((asset) => asset.isEnabled && asset.isMarket)
@ -19,4 +20,5 @@ export const DEFAULT_SETTINGS: Settings = {
slippage: 0.02,
tutorial: true,
migrationBanner: true,
perpsAsset: '',
}

View File

@ -14,4 +14,5 @@ export enum LocalStorageKeys {
MIGRATION_BANNER = 'migrationBanner',
HLS_INFORMATION = 'hlsInformation',
CURRENT_CHAIN_ID = 'currentChainId',
PERPS_ASSET = 'perpsAsset',
}

View File

@ -0,0 +1,7 @@
import useStore from 'store'
export default function usePerpsEnabledAssets() {
const assets = useStore((s) => s.chainConfig.assets)
return assets.filter((asset) => asset.isPerpsEnabled)
}

View File

@ -0,0 +1,36 @@
import { useCallback, useMemo } from 'react'
import { useSearchParams } from 'react-router-dom'
import { DEFAULT_SETTINGS } from 'constants/defaultSettings'
import { LocalStorageKeys } from 'constants/localStorageKeys'
import usePerpsEnabledAssets from 'hooks/assets/usePerpsEnabledAssets'
import useLocalStorage from 'hooks/localStorage/useLocalStorage'
import useChainConfig from 'hooks/useChainConfig'
export default function usePerpsAsset() {
const chainConfig = useChainConfig()
const [searchParams] = useSearchParams()
const perpsAssets = usePerpsEnabledAssets()
const perpsAssetInParams = searchParams.get('perpsMarket')
const [perpsAssetInLocalStorage, setPerpsAssetInLocalStorage] = useLocalStorage<
Settings['perpsAsset']
>(chainConfig.id + '/' + LocalStorageKeys.PERPS_ASSET, DEFAULT_SETTINGS.perpsAsset)
const updatePerpsAsset = useCallback(
(denom: string) => {
setPerpsAssetInLocalStorage(denom)
},
[setPerpsAssetInLocalStorage],
)
return {
perpsAsset: useMemo(
() =>
perpsAssets.find(
(asset) => asset.denom === (perpsAssetInParams || perpsAssetInLocalStorage),
) ?? perpsAssets[0],
[perpsAssetInLocalStorage, perpsAssetInParams, perpsAssets],
),
updatePerpsAsset,
}
}

View File

@ -0,0 +1,14 @@
import useSWR from 'swr'
import useChainConfig from 'hooks/useChainConfig'
import useClients from 'hooks/useClients'
export default function usePerpsConfig() {
const chainConfig = useChainConfig()
const clients = useClients()
return useSWR(clients && `chains/${chainConfig.id}/perps/config`, () => getPerpsConfig(clients!))
}
async function getPerpsConfig(clients: ContractClients) {
return clients.perps.config()
}

View File

@ -1,39 +1,29 @@
import { useSearchParams } from 'react-router-dom'
import useSWR from 'swr'
import useAsset from 'hooks/assets/useAsset'
import useBaseAsset from 'hooks/assets/useBasetAsset'
import { BN_ZERO } from 'constants/math'
import usePerpsAsset from 'hooks/perps/usePerpsAsset'
import useChainConfig from 'hooks/useChainConfig'
import useClients from 'hooks/useClients'
import { BN } from 'utils/helpers'
export default function usePerpsMarket() {
const chainConfig = useChainConfig()
const [searchParams] = useSearchParams()
const baseAsset = useBaseAsset()
const perpsMarket = searchParams.get('perpsMarket') || baseAsset.symbol
const { perpsAsset } = usePerpsAsset()
const clients = useClients()
const asset = useAsset(perpsMarket)
return useSWR(
`chains/${chainConfig.id}/perpsMarket/${perpsMarket}`,
async () => {
await delay(3000)
if (!asset) return null
return {
asset,
fundingRate: BN(0.001432),
openInterest: {
long: BN(92901203),
short: BN(129891203),
},
} as PerpsMarket
},
{
fallbackData: null,
},
return useSWR(clients && perpsAsset && `chains/${chainConfig.id}/perps/${perpsAsset.denom}`, () =>
getPerpsMarket(clients!, perpsAsset!),
)
}
function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms))
async function getPerpsMarket(clients: ContractClients, asset: Asset) {
const denomState = await clients.perps.perpDenomState({ denom: asset.denom })
return {
fundingRate: BN(denomState.rate.abs),
asset: asset,
openInterest: {
long: BN_ZERO,
short: BN_ZERO,
},
} as PerpsMarket
}

View File

@ -0,0 +1,15 @@
import useSWR from 'swr'
import useChainConfig from 'hooks/useChainConfig'
import useClients from 'hooks/useClients'
import iterateContractQuery from 'utils/iterateContractQuery'
export default function usePerpsParams() {
const chainConfig = useChainConfig()
const clients = useClients()
return useSWR(clients && `chains/${chainConfig.id}/perps/params`, () => getPerpsParams(clients!))
}
async function getPerpsParams(clients: ContractClients) {
return iterateContractQuery(clients.params.allPerpParams, undefined, [])
}

View File

@ -0,0 +1,16 @@
import useSWR from 'swr'
import useChainConfig from 'hooks/useChainConfig'
import useClients from 'hooks/useClients'
export default function usePerpsVaultState() {
const chainConfig = useChainConfig()
const clients = useClients()
return useSWR(clients && `chains/${chainConfig.id}/perps/vault-state`, () =>
getPerpsVaultState(clients!),
)
}
async function getPerpsVaultState(clients: ContractClients) {
return clients.perps.vaultState()
}

42
src/hooks/useClients.ts Normal file
View File

@ -0,0 +1,42 @@
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import useSWR from 'swr'
import useChainConfig from 'hooks/useChainConfig'
import { MarsAccountNftQueryClient } from 'types/generated/mars-account-nft/MarsAccountNft.client'
import { MarsCreditManagerQueryClient } from 'types/generated/mars-credit-manager/MarsCreditManager.client'
import { MarsIncentivesQueryClient } from 'types/generated/mars-incentives/MarsIncentives.client'
import { MarsOracleOsmosisQueryClient } from 'types/generated/mars-oracle-osmosis/MarsOracleOsmosis.client'
import { MarsParamsQueryClient } from 'types/generated/mars-params/MarsParams.client'
import { MarsPerpsQueryClient } from 'types/generated/mars-perps/MarsPerps.client'
import { MarsRedBankQueryClient } from 'types/generated/mars-red-bank/MarsRedBank.client'
import { MarsSwapperOsmosisQueryClient } from 'types/generated/mars-swapper-osmosis/MarsSwapperOsmosis.client'
export default function useClients() {
const chainConfig = useChainConfig()
const swr = useSWR(
`chains/${chainConfig.id}/clients`,
async () => {
const client = await CosmWasmClient.connect(chainConfig.endpoints.rpc)
return {
creditManager: new MarsCreditManagerQueryClient(
client,
chainConfig.contracts.creditManager,
),
accountNft: new MarsAccountNftQueryClient(client, chainConfig.contracts.accountNft),
oracle: new MarsOracleOsmosisQueryClient(client, chainConfig.contracts.oracle),
params: new MarsParamsQueryClient(client, chainConfig.contracts.params),
redBank: new MarsRedBankQueryClient(client, chainConfig.contracts.redBank),
swapper: new MarsSwapperOsmosisQueryClient(client, chainConfig.contracts.swapper),
incentives: new MarsIncentivesQueryClient(client, chainConfig.contracts.incentives),
perps: new MarsPerpsQueryClient(client, chainConfig.contracts.perps),
} as ContractClients
},
{
keepPreviousData: false,
},
)
return swr.data
}

View File

@ -1,21 +1,17 @@
import { useCallback, useMemo, useState } from 'react'
import useAssets from 'hooks/useAssets'
export default function useFilteredAssets() {
export default function useFilteredAssets(assets: Asset[]) {
const [searchString, setSearchString] = useState('')
const allAssets = useAssets()
const assets = useMemo(
const filteredAssets = useMemo(
() =>
allAssets.filter(
assets.filter(
(asset) =>
asset.denom.toLocaleLowerCase().includes(searchString.toLowerCase()) ||
asset.symbol.toLocaleLowerCase().includes(searchString.toLowerCase()) ||
asset.name.toLocaleLowerCase().includes(searchString.toLowerCase()),
),
[searchString, allAssets],
[searchString, assets],
)
const onChangeSearch = useCallback(
@ -25,5 +21,5 @@ export default function useFilteredAssets() {
[setSearchString],
)
return { assets, searchString, onChangeSearch }
return { assets: filteredAssets, searchString, onChangeSearch }
}

View File

@ -31,7 +31,6 @@ export default function TradePage() {
const enabledMarketAssets = useMarketEnabledAssets()
const assetOverlayState = useStore((s) => s.assetOverlayState)
const buyAsset = useMemo(
() =>
enabledMarketAssets.find(

View File

@ -1,8 +1,8 @@
import React from 'react'
import { BrowserRouter } from 'react-router-dom'
import { WalletConnectProvider } from 'components/Wallet/WalletConnectProvider'
import Routes from 'components/Routes'
import { WalletConnectProvider } from 'components/Wallet/WalletConnectProvider'
export default function Router() {
return (

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -11,6 +11,7 @@ import {
Uint128,
InstantiateMsg,
ExecuteMsg,
MigrateV1ToV2,
Binary,
Expiration,
Timestamp,
@ -306,6 +307,12 @@ export interface MarsAccountNftInterface extends MarsAccountNftReadOnlyInterface
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
migrate: (
migrateV1ToV2: MigrateV1ToV2,
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
transferNft: (
{
recipient,
@ -403,6 +410,7 @@ export class MarsAccountNftClient
this.updateConfig = this.updateConfig.bind(this)
this.mint = this.mint.bind(this)
this.burn = this.burn.bind(this)
this.migrate = this.migrate.bind(this)
this.transferNft = this.transferNft.bind(this)
this.sendNft = this.sendNft.bind(this)
this.approve = this.approve.bind(this)
@ -481,6 +489,23 @@ export class MarsAccountNftClient
_funds,
)
}
migrate = async (
migrateV1ToV2: MigrateV1ToV2,
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
migrate: migrateV1ToV2,
},
fee,
memo,
_funds,
)
}
transferNft = async (
{
recipient,

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -12,6 +12,7 @@ import {
Uint128,
InstantiateMsg,
ExecuteMsg,
MigrateV1ToV2,
Binary,
Expiration,
Timestamp,
@ -526,6 +527,26 @@ export function useMarsAccountNftTransferNftMutation(
options,
)
}
export interface MarsAccountNftMigrateMutation {
client: MarsAccountNftClient
msg: MigrateV1ToV2
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsAccountNftMigrateMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsAccountNftMigrateMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsAccountNftMigrateMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.migrate(msg, fee, memo, funds),
options,
)
}
export interface MarsAccountNftBurnMutation {
client: MarsAccountNftClient
msg: {

View File

@ -1,12 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 interface InstantiateMsg {
credit_manager_contract?: string | null
health_contract?: string | null
max_value_for_burn: Uint128
minter: string
@ -29,6 +30,9 @@ export type ExecuteMsg =
token_id: string
}
}
| {
migrate: MigrateV1ToV2
}
| {
transfer_nft: {
recipient: string
@ -69,6 +73,11 @@ export type ExecuteMsg =
| {
update_ownership: Action
}
export type MigrateV1ToV2 = {
burn_empty_accounts: {
limit?: number | null
}
}
export type Binary = string
export type Expiration =
| {
@ -92,6 +101,7 @@ export type Action =
| 'accept_ownership'
| 'renounce_ownership'
export interface NftConfigUpdates {
credit_manager_contract_addr?: string | null
health_contract_addr?: string | null
max_value_for_burn?: Uint128 | null
}
@ -197,6 +207,7 @@ export interface ApprovalsResponse {
approvals: Approval[]
}
export interface NftConfigBaseForString {
credit_manager_contract_addr?: string | null
health_contract_addr?: string | null
max_value_for_burn: Uint128
}

View File

@ -1,14 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _0 from './MarsAccountNft.types'
import * as _1 from './MarsAccountNft.client'
import * as _2 from './MarsAccountNft.message-composer'
import * as _3 from './MarsAccountNft.react-query'
import * as _2 from './MarsAccountNft.react-query'
export namespace contracts {
export const MarsAccountNft = { ..._0, ..._1, ..._2, ..._3 }
export const MarsAccountNft = { ..._0, ..._1, ..._2 }
}

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -25,7 +25,12 @@ import {
LiquidateRequestForVaultBaseForString,
VaultPositionType,
AccountNftBaseForString,
PerpsBaseForString,
OwnerUpdate,
Action2,
Expiration,
Timestamp,
Uint64,
CallbackMsg,
Addr,
HealthState,
@ -33,6 +38,7 @@ import {
ChangeExpected,
Coin,
ActionCoin,
SignedDecimal,
VaultBaseForString,
ConfigUpdates,
NftConfigUpdates,
@ -59,8 +65,13 @@ import {
OwnerResponse,
RewardsCollector,
ArrayOfCoin,
PnL,
Positions,
DebtAmount,
PerpPosition,
PositionPnl,
PnlCoins,
PnlValues,
VaultPositionValue,
CoinValue,
VaultUtilizationResponse,
@ -338,7 +349,7 @@ export interface MarsCreditManagerInterface extends MarsCreditManagerReadOnlyInt
ownership,
}: {
config?: NftConfigUpdates
ownership?: Action
ownership?: Action2
},
fee?: number | StdFee | 'auto',
memo?: string,
@ -484,7 +495,7 @@ export class MarsCreditManagerClient
ownership,
}: {
config?: NftConfigUpdates
ownership?: Action
ownership?: Action2
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -26,7 +26,12 @@ import {
LiquidateRequestForVaultBaseForString,
VaultPositionType,
AccountNftBaseForString,
PerpsBaseForString,
OwnerUpdate,
Action2,
Expiration,
Timestamp,
Uint64,
CallbackMsg,
Addr,
HealthState,
@ -34,6 +39,7 @@ import {
ChangeExpected,
Coin,
ActionCoin,
SignedDecimal,
VaultBaseForString,
ConfigUpdates,
NftConfigUpdates,
@ -60,8 +66,13 @@ import {
OwnerResponse,
RewardsCollector,
ArrayOfCoin,
PnL,
Positions,
DebtAmount,
PerpPosition,
PositionPnl,
PnlCoins,
PnlValues,
VaultPositionValue,
CoinValue,
VaultUtilizationResponse,
@ -478,7 +489,7 @@ export interface MarsCreditManagerUpdateNftConfigMutation {
client: MarsCreditManagerClient
msg: {
config?: NftConfigUpdates
ownership?: Action
ownership?: Action2
}
args?: {
fee?: number | StdFee | 'auto'

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -52,7 +52,7 @@ export type ExecuteMsg =
| {
update_nft_config: {
config?: NftConfigUpdates | null
ownership?: Action | null
ownership?: Action2 | null
}
}
| {
@ -84,6 +84,17 @@ export type Action =
recipient_account_id?: string | null
}
}
| {
open_perp: {
denom: string
size: SignedDecimal
}
}
| {
close_perp: {
denom: string
}
}
| {
enter_vault: {
coin: ActionCoin
@ -158,6 +169,7 @@ export type LiquidateRequestForVaultBaseForString =
}
export type VaultPositionType = 'u_n_l_o_c_k_e_d' | 'l_o_c_k_e_d' | 'u_n_l_o_c_k_i_n_g'
export type AccountNftBaseForString = string
export type PerpsBaseForString = string
export type OwnerUpdate =
| {
propose_new_owner: {
@ -173,6 +185,27 @@ export type OwnerUpdate =
}
}
| 'clear_emergency_owner'
export type Action2 =
| {
transfer_ownership: {
expiry?: Expiration | null
new_owner: string
}
}
| 'accept_ownership'
| 'renounce_ownership'
export type Expiration =
| {
at_height: number
}
| {
at_time: Timestamp
}
| {
never: {}
}
export type Timestamp = Uint64
export type Uint64 = string
export type CallbackMsg =
| {
withdraw: {
@ -229,6 +262,19 @@ export type CallbackMsg =
denoms: string[]
}
}
| {
open_perp: {
account_id: string
denom: string
size: SignedDecimal
}
}
| {
close_perp: {
account_id: string
denom: string
}
}
| {
enter_vault: {
account_id: string
@ -360,6 +406,11 @@ export interface ActionCoin {
amount: ActionAmount
denom: string
}
export interface SignedDecimal {
abs: Decimal
negative: boolean
[k: string]: unknown
}
export interface VaultBaseForString {
address: string
}
@ -370,6 +421,8 @@ export interface ConfigUpdates {
max_slippage?: Decimal | null
max_unlocking_positions?: Uint128 | null
oracle?: OracleBaseForString | null
params?: ParamsBaseForString | null
perps?: PerpsBaseForString | null
red_bank?: RedBankUnchecked | null
rewards_collector?: string | null
swapper?: SwapperBaseForString | null
@ -510,6 +563,7 @@ export interface ConfigResponse {
oracle: string
ownership: OwnerResponse
params: string
perps: string
red_bank: string
rewards_collector?: RewardsCollector | null
swapper: string
@ -527,11 +581,20 @@ export interface RewardsCollector {
address: string
}
export type ArrayOfCoin = Coin[]
export type PnL =
| 'break_even'
| {
profit: Coin
}
| {
loss: Coin
}
export interface Positions {
account_id: string
debts: DebtAmount[]
deposits: Coin[]
lends: Coin[]
perps: PerpPosition[]
vaults: VaultPosition[]
}
export interface DebtAmount {
@ -539,6 +602,29 @@ export interface DebtAmount {
denom: string
shares: Uint128
}
export interface PerpPosition {
base_denom: string
closing_fee_rate: Decimal
current_price: Decimal
denom: string
entry_price: Decimal
pnl: PositionPnl
size: SignedDecimal
}
export interface PositionPnl {
coins: PnlCoins
values: PnlValues
}
export interface PnlCoins {
closing_fee: Coin
pnl: PnL
}
export interface PnlValues {
accrued_funding: SignedDecimal
closing_fee: SignedDecimal
pnl: SignedDecimal
price_pnl: SignedDecimal
}
export interface VaultPositionValue {
base_coin: CoinValue
vault_coin: CoinValue

View File

@ -1,14 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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'
import * as _6 from './MarsCreditManager.types'
import * as _7 from './MarsCreditManager.client'
import * as _8 from './MarsCreditManager.react-query'
export namespace contracts {
export const MarsCreditManager = { ..._4, ..._5, ..._6, ..._7 }
export const MarsCreditManager = { ..._6, ..._7, ..._8 }
}

View File

@ -1,32 +1,32 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate'
import { StdFee } from '@cosmjs/amino'
import {
ActiveEmission,
Addr,
ArrayOfActiveEmission,
ArrayOfCoin,
ArrayOfEmissionResponse,
ArrayOfIncentiveStateResponse,
ArrayOfWhitelistEntry,
Coin,
ConfigResponse,
Decimal,
EmissionResponse,
ExecuteMsg,
IncentiveStateResponse,
InstantiateMsg,
OwnerUpdate,
QueryMsg,
ExecuteMsg,
Uint128,
Addr,
OwnerUpdate,
MigrateV1ToV2,
WhitelistEntry,
QueryMsg,
ArrayOfActiveEmission,
ActiveEmission,
ConfigResponse,
ArrayOfEmissionResponse,
EmissionResponse,
Decimal,
IncentiveStateResponse,
ArrayOfIncentiveStateResponse,
ArrayOfCoin,
Coin,
ArrayOfWhitelistEntry,
} from './MarsIncentives.types'
export interface MarsIncentivesReadOnlyInterface {
contractAddress: string
@ -302,6 +302,12 @@ export interface MarsIncentivesInterface extends MarsIncentivesReadOnlyInterface
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
migrate: (
migrateV1ToV2: MigrateV1ToV2,
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
}
export class MarsIncentivesClient
extends MarsIncentivesQueryClient
@ -322,6 +328,7 @@ export class MarsIncentivesClient
this.claimRewards = this.claimRewards.bind(this)
this.updateConfig = this.updateConfig.bind(this)
this.updateOwner = this.updateOwner.bind(this)
this.migrate = this.migrate.bind(this)
}
updateWhitelist = async (
@ -495,4 +502,21 @@ export class MarsIncentivesClient
_funds,
)
}
migrate = async (
migrateV1ToV2: MigrateV1ToV2,
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
migrate: migrateV1ToV2,
},
fee,
memo,
_funds,
)
}
}

View File

@ -1,35 +1,35 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query'
import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query'
import { ExecuteResult } from '@cosmjs/cosmwasm-stargate'
import { StdFee } from '@cosmjs/amino'
import {
ActiveEmission,
Addr,
ArrayOfActiveEmission,
ArrayOfCoin,
ArrayOfEmissionResponse,
ArrayOfIncentiveStateResponse,
ArrayOfWhitelistEntry,
Coin,
ConfigResponse,
Decimal,
EmissionResponse,
ExecuteMsg,
IncentiveStateResponse,
InstantiateMsg,
OwnerUpdate,
QueryMsg,
ExecuteMsg,
Uint128,
Addr,
OwnerUpdate,
MigrateV1ToV2,
WhitelistEntry,
QueryMsg,
ArrayOfActiveEmission,
ActiveEmission,
ConfigResponse,
ArrayOfEmissionResponse,
EmissionResponse,
Decimal,
IncentiveStateResponse,
ArrayOfIncentiveStateResponse,
ArrayOfCoin,
Coin,
ArrayOfWhitelistEntry,
} from './MarsIncentives.types'
import { MarsIncentivesClient, MarsIncentivesQueryClient } from './MarsIncentives.client'
import { MarsIncentivesQueryClient, MarsIncentivesClient } from './MarsIncentives.client'
export const marsIncentivesQueryKeys = {
contract: [
{
@ -260,6 +260,26 @@ export function useMarsIncentivesActiveEmissionsQuery<TData = ArrayOfActiveEmiss
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsIncentivesMigrateMutation {
client: MarsIncentivesClient
msg: MigrateV1ToV2
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsIncentivesMigrateMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsIncentivesMigrateMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsIncentivesMigrateMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.migrate(msg, fee, memo, funds),
options,
)
}
export interface MarsIncentivesUpdateOwnerMutation {
client: MarsIncentivesClient
msg: OwnerUpdate

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -8,6 +8,7 @@
export interface InstantiateMsg {
address_provider: string
epoch_duration: number
mars_denom: string
max_whitelisted_denoms: number
owner: string
}
@ -53,6 +54,9 @@ export type ExecuteMsg =
| {
update_owner: OwnerUpdate
}
| {
migrate: MigrateV1ToV2
}
export type Uint128 = string
export type Addr = string
export type OwnerUpdate =
@ -70,6 +74,15 @@ export type OwnerUpdate =
}
}
| 'clear_emergency_owner'
export type MigrateV1ToV2 =
| {
users_indexes_and_rewards: {
limit: number
}
}
| {
clear_v1_state: {}
}
export interface WhitelistEntry {
denom: string
min_emission_rate: Uint128
@ -134,6 +147,7 @@ export interface ConfigResponse {
max_whitelisted_denoms: number
owner?: string | null
proposed_new_owner?: string | null
whitelist_count: number
}
export type ArrayOfEmissionResponse = EmissionResponse[]
export interface EmissionResponse {

View File

@ -1,13 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _3 from './MarsIncentives.types'
import * as _4 from './MarsIncentives.client'
import * as _5 from './MarsIncentives.react-query'
import * as _9 from './MarsIncentives.types'
import * as _10 from './MarsIncentives.client'
import * as _11 from './MarsIncentives.react-query'
export namespace contracts {
export const MarsIncentives = { ..._3, ..._4, ..._5 }
export const MarsIncentives = { ..._9, ..._10, ..._11 }
}

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -20,6 +20,7 @@ import {
GeometricTwap,
RedemptionRateForString,
QueryMsg,
ActionKind,
ConfigResponse,
PriceResponse,
PriceSourceResponseForString,
@ -37,11 +38,13 @@ export interface MarsOracleOsmosisReadOnlyInterface {
limit?: number
startAfter?: string
}) => Promise<ArrayOfPriceSourceResponseForString>
price: ({ denom }: { denom: string }) => Promise<PriceResponse>
price: ({ denom, kind }: { denom: string; kind?: ActionKind }) => Promise<PriceResponse>
prices: ({
kind,
limit,
startAfter,
}: {
kind?: ActionKind
limit?: number
startAfter?: string
}) => Promise<ArrayOfPriceResponse>
@ -86,22 +89,26 @@ export class MarsOracleOsmosisQueryClient implements MarsOracleOsmosisReadOnlyIn
},
})
}
price = async ({ denom }: { denom: string }): Promise<PriceResponse> => {
price = async ({ denom, kind }: { denom: string; kind?: ActionKind }): Promise<PriceResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
price: {
denom,
kind,
},
})
}
prices = async ({
kind,
limit,
startAfter,
}: {
kind?: ActionKind
limit?: number
startAfter?: string
}): Promise<ArrayOfPriceResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
prices: {
kind,
limit,
start_after: startAfter,
},

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -21,6 +21,7 @@ import {
GeometricTwap,
RedemptionRateForString,
QueryMsg,
ActionKind,
ConfigResponse,
PriceResponse,
PriceSourceResponseForString,
@ -67,6 +68,7 @@ export interface MarsOracleOsmosisReactQuery<TResponse, TData = TResponse> {
export interface MarsOracleOsmosisPricesQuery<TData>
extends MarsOracleOsmosisReactQuery<ArrayOfPriceResponse, TData> {
args: {
kind?: ActionKind
limit?: number
startAfter?: string
}
@ -81,6 +83,7 @@ export function useMarsOracleOsmosisPricesQuery<TData = ArrayOfPriceResponse>({
() =>
client
? client.prices({
kind: args.kind,
limit: args.limit,
startAfter: args.startAfter,
})
@ -92,6 +95,7 @@ export interface MarsOracleOsmosisPriceQuery<TData>
extends MarsOracleOsmosisReactQuery<PriceResponse, TData> {
args: {
denom: string
kind?: ActionKind
}
}
export function useMarsOracleOsmosisPriceQuery<TData = PriceResponse>({
@ -105,6 +109,7 @@ export function useMarsOracleOsmosisPriceQuery<TData = PriceResponse>({
client
? client.price({
denom: args.denom,
kind: args.kind,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -40,13 +40,11 @@ export type OsmosisPriceSourceForString =
| {
fixed: {
price: Decimal
[k: string]: unknown
}
}
| {
spot: {
pool_id: number
[k: string]: unknown
}
}
| {
@ -54,7 +52,6 @@ export type OsmosisPriceSourceForString =
downtime_detector?: DowntimeDetector | null
pool_id: number
window_size: number
[k: string]: unknown
}
}
| {
@ -62,13 +59,11 @@ export type OsmosisPriceSourceForString =
downtime_detector?: DowntimeDetector | null
pool_id: number
window_size: number
[k: string]: unknown
}
}
| {
xyk_liquidity_token: {
pool_id: number
[k: string]: unknown
}
}
| {
@ -77,16 +72,16 @@ export type OsmosisPriceSourceForString =
pool_id: number
transitive_denom: string
window_size: number
[k: string]: unknown
}
}
| {
pyth: {
contract_addr: string
denom_decimals: number
max_confidence: Decimal
max_deviation: Decimal
max_staleness: number
price_feed_id: Identifier
[k: string]: unknown
}
}
| {
@ -94,36 +89,35 @@ export type OsmosisPriceSourceForString =
geometric_twap: GeometricTwap
redemption_rate: RedemptionRateForString
transitive_denom: string
[k: string]: unknown
}
}
export type Decimal = string
export type Downtime =
| 'duration30s'
| 'duration1m'
| 'duration2m'
| 'duration3m'
| 'duration4m'
| 'duration5m'
| 'duration10m'
| 'duration20m'
| 'duration30m'
| 'duration40m'
| 'duration50m'
| 'duration1h'
| 'duration15h'
| 'duration2h'
| 'duration25h'
| 'duration3h'
| 'duration4h'
| 'duration5h'
| 'duration6h'
| 'duration9h'
| 'duration12h'
| 'duration18h'
| 'duration24h'
| 'duration36h'
| 'duration48h'
| 'Duration30s'
| 'Duration1m'
| 'Duration2m'
| 'Duration3m'
| 'Duration4m'
| 'Duration5m'
| 'Duration10m'
| 'Duration20m'
| 'Duration30m'
| 'Duration40m'
| 'Duration50m'
| 'Duration1h'
| 'Duration15h'
| 'Duration2h'
| 'Duration25h'
| 'Duration3h'
| 'Duration4h'
| 'Duration5h'
| 'Duration6h'
| 'Duration9h'
| 'Duration12h'
| 'Duration18h'
| 'Duration24h'
| 'Duration36h'
| 'Duration48h'
export type Identifier = string
export type OwnerUpdate =
| {
@ -143,18 +137,15 @@ export type OwnerUpdate =
export interface DowntimeDetector {
downtime: Downtime
recovery: number
[k: string]: unknown
}
export interface GeometricTwap {
downtime_detector?: DowntimeDetector | null
pool_id: number
window_size: number
[k: string]: unknown
}
export interface RedemptionRateForString {
contract_addr: string
max_staleness: number
[k: string]: unknown
}
export type QueryMsg =
| {
@ -174,14 +165,17 @@ export type QueryMsg =
| {
price: {
denom: string
kind?: ActionKind | null
}
}
| {
prices: {
kind?: ActionKind | null
limit?: number | null
start_after?: string | null
}
}
export type ActionKind = 'default' | 'liquidation'
export interface ConfigResponse {
base_denom: string
owner?: string | null

View File

@ -1,13 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _6 from './MarsOracleOsmosis.types'
import * as _7 from './MarsOracleOsmosis.client'
import * as _8 from './MarsOracleOsmosis.react-query'
import * as _15 from './MarsOracleOsmosis.types'
import * as _16 from './MarsOracleOsmosis.client'
import * as _17 from './MarsOracleOsmosis.react-query'
export namespace contracts {
export const MarsOracleOsmosis = { ..._6, ..._7, ..._8 }
export const MarsOracleOsmosis = { ..._15, ..._16, ..._17 }
}

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -16,6 +16,7 @@ import {
HlsAssetTypeForString,
Uint128,
VaultConfigUpdate,
PerpParamsUpdate,
EmergencyUpdate,
CmEmergencyUpdate,
RedBankEmergencyUpdate,
@ -26,6 +27,7 @@ import {
RedBankSettings,
VaultConfigBaseForString,
Coin,
PerpParams,
QueryMsg,
HlsAssetTypeForAddr,
Addr,
@ -33,14 +35,17 @@ import {
AssetParamsBaseForAddr,
CmSettingsForAddr,
HlsParamsBaseForAddr,
ArrayOfPerpParams,
ArrayOfVaultConfigBaseForAddr,
VaultConfigBaseForAddr,
ConfigResponse,
OwnerResponse,
TotalDepositResponse,
} from './MarsParams.types'
export interface MarsParamsReadOnlyInterface {
contractAddress: string
owner: () => Promise<OwnerResponse>
config: () => Promise<ConfigResponse>
assetParams: ({ denom }: { denom: string }) => Promise<AssetParamsBaseForAddr>
allAssetParams: ({
limit,
@ -57,6 +62,14 @@ export interface MarsParamsReadOnlyInterface {
limit?: number
startAfter?: string
}) => Promise<ArrayOfVaultConfigBaseForAddr>
perpParams: ({ denom }: { denom: string }) => Promise<PerpParams>
allPerpParams: ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string
}) => Promise<ArrayOfPerpParams>
targetHealthFactor: () => Promise<Decimal>
totalDeposit: ({ denom }: { denom: string }) => Promise<TotalDepositResponse>
}
@ -68,10 +81,13 @@ export class MarsParamsQueryClient implements MarsParamsReadOnlyInterface {
this.client = client
this.contractAddress = contractAddress
this.owner = this.owner.bind(this)
this.config = this.config.bind(this)
this.assetParams = this.assetParams.bind(this)
this.allAssetParams = this.allAssetParams.bind(this)
this.vaultConfig = this.vaultConfig.bind(this)
this.allVaultConfigs = this.allVaultConfigs.bind(this)
this.perpParams = this.perpParams.bind(this)
this.allPerpParams = this.allPerpParams.bind(this)
this.targetHealthFactor = this.targetHealthFactor.bind(this)
this.totalDeposit = this.totalDeposit.bind(this)
}
@ -81,6 +97,11 @@ export class MarsParamsQueryClient implements MarsParamsReadOnlyInterface {
owner: {},
})
}
config = async (): Promise<ConfigResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
config: {},
})
}
assetParams = async ({ denom }: { denom: string }): Promise<AssetParamsBaseForAddr> => {
return this.client.queryContractSmart(this.contractAddress, {
asset_params: {
@ -123,6 +144,27 @@ export class MarsParamsQueryClient implements MarsParamsReadOnlyInterface {
},
})
}
perpParams = async ({ denom }: { denom: string }): Promise<PerpParams> => {
return this.client.queryContractSmart(this.contractAddress, {
perp_params: {
denom,
},
})
}
allPerpParams = async ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string
}): Promise<ArrayOfPerpParams> => {
return this.client.queryContractSmart(this.contractAddress, {
all_perp_params: {
limit,
start_after: startAfter,
},
})
}
targetHealthFactor = async (): Promise<Decimal> => {
return this.client.queryContractSmart(this.contractAddress, {
target_health_factor: {},
@ -145,6 +187,16 @@ export interface MarsParamsInterface extends MarsParamsReadOnlyInterface {
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
updateConfig: (
{
addressProvider,
}: {
addressProvider?: string
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
updateTargetHealthFactor: (
fee?: number | StdFee | 'auto',
memo?: string,
@ -162,6 +214,12 @@ export interface MarsParamsInterface extends MarsParamsReadOnlyInterface {
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
updatePerpParams: (
perpParamsUpdate: PerpParamsUpdate,
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
emergencyUpdate: (
emergencyUpdate: EmergencyUpdate,
fee?: number | StdFee | 'auto',
@ -180,9 +238,11 @@ export class MarsParamsClient extends MarsParamsQueryClient implements MarsParam
this.sender = sender
this.contractAddress = contractAddress
this.updateOwner = this.updateOwner.bind(this)
this.updateConfig = this.updateConfig.bind(this)
this.updateTargetHealthFactor = this.updateTargetHealthFactor.bind(this)
this.updateAssetParams = this.updateAssetParams.bind(this)
this.updateVaultConfig = this.updateVaultConfig.bind(this)
this.updatePerpParams = this.updatePerpParams.bind(this)
this.emergencyUpdate = this.emergencyUpdate.bind(this)
}
@ -203,6 +263,29 @@ export class MarsParamsClient extends MarsParamsQueryClient implements MarsParam
_funds,
)
}
updateConfig = async (
{
addressProvider,
}: {
addressProvider?: string
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
update_config: {
address_provider: addressProvider,
},
},
fee,
memo,
_funds,
)
}
updateTargetHealthFactor = async (
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
@ -253,6 +336,23 @@ export class MarsParamsClient extends MarsParamsQueryClient implements MarsParam
_funds,
)
}
updatePerpParams = async (
perpParamsUpdate: PerpParamsUpdate,
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
update_perp_params: perpParamsUpdate,
},
fee,
memo,
_funds,
)
}
emergencyUpdate = async (
emergencyUpdate: EmergencyUpdate,
fee: number | StdFee | 'auto' = 'auto',

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -17,6 +17,7 @@ import {
HlsAssetTypeForString,
Uint128,
VaultConfigUpdate,
PerpParamsUpdate,
EmergencyUpdate,
CmEmergencyUpdate,
RedBankEmergencyUpdate,
@ -27,6 +28,7 @@ import {
RedBankSettings,
VaultConfigBaseForString,
Coin,
PerpParams,
QueryMsg,
HlsAssetTypeForAddr,
Addr,
@ -34,8 +36,10 @@ import {
AssetParamsBaseForAddr,
CmSettingsForAddr,
HlsParamsBaseForAddr,
ArrayOfPerpParams,
ArrayOfVaultConfigBaseForAddr,
VaultConfigBaseForAddr,
ConfigResponse,
OwnerResponse,
TotalDepositResponse,
} from './MarsParams.types'
@ -50,6 +54,8 @@ export const marsParamsQueryKeys = {
[{ ...marsParamsQueryKeys.contract[0], address: contractAddress }] as const,
owner: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsParamsQueryKeys.address(contractAddress)[0], method: 'owner', args }] as const,
config: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsParamsQueryKeys.address(contractAddress)[0], method: 'config', args }] as const,
assetParams: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsParamsQueryKeys.address(contractAddress)[0], method: 'asset_params', args }] as const,
allAssetParams: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
@ -62,6 +68,12 @@ export const marsParamsQueryKeys = {
[
{ ...marsParamsQueryKeys.address(contractAddress)[0], method: 'all_vault_configs', args },
] as const,
perpParams: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsParamsQueryKeys.address(contractAddress)[0], method: 'perp_params', args }] as const,
allPerpParams: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsParamsQueryKeys.address(contractAddress)[0], method: 'all_perp_params', args },
] as const,
targetHealthFactor: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsParamsQueryKeys.address(contractAddress)[0], method: 'target_health_factor', args },
@ -114,6 +126,51 @@ export function useMarsParamsTargetHealthFactorQuery<TData = Decimal>({
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsParamsAllPerpParamsQuery<TData>
extends MarsParamsReactQuery<ArrayOfPerpParams, TData> {
args: {
limit?: number
startAfter?: string
}
}
export function useMarsParamsAllPerpParamsQuery<TData = ArrayOfPerpParams>({
client,
args,
options,
}: MarsParamsAllPerpParamsQuery<TData>) {
return useQuery<ArrayOfPerpParams, Error, TData>(
marsParamsQueryKeys.allPerpParams(client?.contractAddress, args),
() =>
client
? client.allPerpParams({
limit: args.limit,
startAfter: args.startAfter,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsParamsPerpParamsQuery<TData> extends MarsParamsReactQuery<PerpParams, TData> {
args: {
denom: string
}
}
export function useMarsParamsPerpParamsQuery<TData = PerpParams>({
client,
args,
options,
}: MarsParamsPerpParamsQuery<TData>) {
return useQuery<PerpParams, Error, TData>(
marsParamsQueryKeys.perpParams(client?.contractAddress, args),
() =>
client
? client.perpParams({
denom: args.denom,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsParamsAllVaultConfigsQuery<TData>
extends MarsParamsReactQuery<ArrayOfVaultConfigBaseForAddr, TData> {
args: {
@ -206,6 +263,17 @@ export function useMarsParamsAssetParamsQuery<TData = AssetParamsBaseForAddr>({
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsParamsConfigQuery<TData> extends MarsParamsReactQuery<ConfigResponse, TData> {}
export function useMarsParamsConfigQuery<TData = ConfigResponse>({
client,
options,
}: MarsParamsConfigQuery<TData>) {
return useQuery<ConfigResponse, Error, TData>(
marsParamsQueryKeys.config(client?.contractAddress),
() => (client ? client.config() : Promise.reject(new Error('Invalid client'))),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsParamsOwnerQuery<TData> extends MarsParamsReactQuery<OwnerResponse, TData> {}
export function useMarsParamsOwnerQuery<TData = OwnerResponse>({
client,
@ -238,6 +306,27 @@ export function useMarsParamsEmergencyUpdateMutation(
options,
)
}
export interface MarsParamsUpdatePerpParamsMutation {
client: MarsParamsClient
msg: PerpParamsUpdate
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsParamsUpdatePerpParamsMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsParamsUpdatePerpParamsMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsParamsUpdatePerpParamsMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) =>
client.updatePerpParams(msg, fee, memo, funds),
options,
)
}
export interface MarsParamsUpdateVaultConfigMutation {
client: MarsParamsClient
msg: VaultConfigUpdate
@ -300,6 +389,29 @@ export function useMarsParamsUpdateTargetHealthFactorMutation(
options,
)
}
export interface MarsParamsUpdateConfigMutation {
client: MarsParamsClient
msg: {
addressProvider?: string
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsParamsUpdateConfigMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsParamsUpdateConfigMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsParamsUpdateConfigMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) =>
client.updateConfig(msg, fee, memo, funds),
options,
)
}
export interface MarsParamsUpdateOwnerMutation {
client: MarsParamsClient
msg: OwnerUpdate

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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,6 +15,11 @@ export type ExecuteMsg =
| {
update_owner: OwnerUpdate
}
| {
update_config: {
address_provider?: string | null
}
}
| {
update_target_health_factor: Decimal
}
@ -24,6 +29,9 @@ export type ExecuteMsg =
| {
update_vault_config: VaultConfigUpdate
}
| {
update_perp_params: PerpParamsUpdate
}
| {
emergency_update: EmergencyUpdate
}
@ -64,6 +72,11 @@ export type VaultConfigUpdate = {
config: VaultConfigBaseForString
}
}
export type PerpParamsUpdate = {
add_or_update: {
params: PerpParams
}
}
export type EmergencyUpdate =
| {
credit_manager: CmEmergencyUpdate
@ -126,10 +139,18 @@ export interface Coin {
denom: string
[k: string]: unknown
}
export interface PerpParams {
denom: string
max_long_oi: Uint128
max_short_oi: Uint128
}
export type QueryMsg =
| {
owner: {}
}
| {
config: {}
}
| {
asset_params: {
denom: string
@ -152,6 +173,17 @@ export type QueryMsg =
start_after?: string | null
}
}
| {
perp_params: {
denom: string
}
}
| {
all_perp_params: {
limit?: number | null
start_after?: string | null
}
}
| {
target_health_factor: {}
}
@ -192,6 +224,7 @@ export interface HlsParamsBaseForAddr {
liquidation_threshold: Decimal
max_loan_to_value: Decimal
}
export type ArrayOfPerpParams = PerpParams[]
export type ArrayOfVaultConfigBaseForAddr = VaultConfigBaseForAddr[]
export interface VaultConfigBaseForAddr {
addr: Addr
@ -201,6 +234,9 @@ export interface VaultConfigBaseForAddr {
max_loan_to_value: Decimal
whitelisted: boolean
}
export interface ConfigResponse {
address_provider: string
}
export interface OwnerResponse {
abolished: boolean
emergency_owner?: string | null

View File

@ -1,14 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _24 from './MarsParams.types'
import * as _25 from './MarsParams.client'
import * as _26 from './MarsParams.message-composer'
import * as _27 from './MarsParams.react-query'
import * as _21 from './MarsParams.types'
import * as _22 from './MarsParams.client'
import * as _23 from './MarsParams.react-query'
export namespace contracts {
export const MarsParams = { ..._24, ..._25, ..._26, ..._27 }
export const MarsParams = { ..._21, ..._22, ..._23 }
}

View File

@ -0,0 +1,529 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 {
Uint128,
OracleBaseForString,
InstantiateMsg,
ExecuteMsg,
OwnerUpdate,
Decimal,
SignedDecimal,
QueryMsg,
ConfigForString,
DenomStateResponse,
Funding,
ArrayOfDenomStateResponse,
DepositResponse,
ArrayOfDepositResponse,
OwnerResponse,
PerpDenomState,
PnlValues,
PnL,
PositionResponse,
PerpPosition,
Coin,
ArrayOfPositionResponse,
PositionsByAccountResponse,
ArrayOfUnlockState,
UnlockState,
VaultState,
} from './MarsPerps.types'
export interface MarsPerpsReadOnlyInterface {
contractAddress: string
owner: () => Promise<OwnerResponse>
config: () => Promise<ConfigForString>
vaultState: () => Promise<VaultState>
denomState: ({ denom }: { denom: string }) => Promise<DenomStateResponse>
perpDenomState: ({ denom }: { denom: string }) => Promise<PerpDenomState>
denomStates: ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string
}) => Promise<ArrayOfDenomStateResponse>
deposit: ({ depositor }: { depositor: string }) => Promise<DepositResponse>
deposits: ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string
}) => Promise<ArrayOfDepositResponse>
unlocks: ({ depositor }: { depositor: string }) => Promise<ArrayOfUnlockState>
position: ({
accountId,
denom,
}: {
accountId: string
denom: string
}) => Promise<PositionResponse>
positions: ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string[][]
}) => Promise<ArrayOfPositionResponse>
positionsByAccount: ({ accountId }: { accountId: string }) => Promise<PositionsByAccountResponse>
totalPnl: () => Promise<SignedDecimal>
}
export class MarsPerpsQueryClient implements MarsPerpsReadOnlyInterface {
client: CosmWasmClient
contractAddress: string
constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client
this.contractAddress = contractAddress
this.owner = this.owner.bind(this)
this.config = this.config.bind(this)
this.vaultState = this.vaultState.bind(this)
this.denomState = this.denomState.bind(this)
this.perpDenomState = this.perpDenomState.bind(this)
this.denomStates = this.denomStates.bind(this)
this.deposit = this.deposit.bind(this)
this.deposits = this.deposits.bind(this)
this.unlocks = this.unlocks.bind(this)
this.position = this.position.bind(this)
this.positions = this.positions.bind(this)
this.positionsByAccount = this.positionsByAccount.bind(this)
this.totalPnl = this.totalPnl.bind(this)
}
owner = async (): Promise<OwnerResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
owner: {},
})
}
config = async (): Promise<ConfigForString> => {
return this.client.queryContractSmart(this.contractAddress, {
config: {},
})
}
vaultState = async (): Promise<VaultState> => {
return this.client.queryContractSmart(this.contractAddress, {
vault_state: {},
})
}
denomState = async ({ denom }: { denom: string }): Promise<DenomStateResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
denom_state: {
denom,
},
})
}
perpDenomState = async ({ denom }: { denom: string }): Promise<PerpDenomState> => {
return this.client.queryContractSmart(this.contractAddress, {
perp_denom_state: {
denom,
},
})
}
denomStates = async ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string
}): Promise<ArrayOfDenomStateResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
denom_states: {
limit,
start_after: startAfter,
},
})
}
deposit = async ({ depositor }: { depositor: string }): Promise<DepositResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
deposit: {
depositor,
},
})
}
deposits = async ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string
}): Promise<ArrayOfDepositResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
deposits: {
limit,
start_after: startAfter,
},
})
}
unlocks = async ({ depositor }: { depositor: string }): Promise<ArrayOfUnlockState> => {
return this.client.queryContractSmart(this.contractAddress, {
unlocks: {
depositor,
},
})
}
position = async ({
accountId,
denom,
}: {
accountId: string
denom: string
}): Promise<PositionResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
position: {
account_id: accountId,
denom,
},
})
}
positions = async ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string[][]
}): Promise<ArrayOfPositionResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
positions: {
limit,
start_after: startAfter,
},
})
}
positionsByAccount = async ({
accountId,
}: {
accountId: string
}): Promise<PositionsByAccountResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
positions_by_account: {
account_id: accountId,
},
})
}
totalPnl = async (): Promise<SignedDecimal> => {
return this.client.queryContractSmart(this.contractAddress, {
total_pnl: {},
})
}
}
export interface MarsPerpsInterface extends MarsPerpsReadOnlyInterface {
contractAddress: string
sender: string
updateOwner: (
ownerUpdate: OwnerUpdate,
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
initDenom: (
{
denom,
maxFundingVelocity,
skewScale,
}: {
denom: string
maxFundingVelocity: Decimal
skewScale: Decimal
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
enableDenom: (
{
denom,
}: {
denom: string
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
disableDenom: (
{
denom,
}: {
denom: string
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
deposit: (
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
unlock: (
{
shares,
}: {
shares: Uint128
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
withdraw: (
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
openPosition: (
{
accountId,
denom,
size,
}: {
accountId: string
denom: string
size: SignedDecimal
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
closePosition: (
{
accountId,
denom,
}: {
accountId: string
denom: string
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
}
export class MarsPerpsClient extends MarsPerpsQueryClient implements MarsPerpsInterface {
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.updateOwner = this.updateOwner.bind(this)
this.initDenom = this.initDenom.bind(this)
this.enableDenom = this.enableDenom.bind(this)
this.disableDenom = this.disableDenom.bind(this)
this.deposit = this.deposit.bind(this)
this.unlock = this.unlock.bind(this)
this.withdraw = this.withdraw.bind(this)
this.openPosition = this.openPosition.bind(this)
this.closePosition = this.closePosition.bind(this)
}
updateOwner = async (
ownerUpdate: OwnerUpdate,
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
update_owner: ownerUpdate,
},
fee,
memo,
_funds,
)
}
initDenom = async (
{
denom,
maxFundingVelocity,
skewScale,
}: {
denom: string
maxFundingVelocity: Decimal
skewScale: Decimal
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
init_denom: {
denom,
max_funding_velocity: maxFundingVelocity,
skew_scale: skewScale,
},
},
fee,
memo,
_funds,
)
}
enableDenom = async (
{
denom,
}: {
denom: string
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
enable_denom: {
denom,
},
},
fee,
memo,
_funds,
)
}
disableDenom = async (
{
denom,
}: {
denom: string
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
disable_denom: {
denom,
},
},
fee,
memo,
_funds,
)
}
deposit = async (
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
deposit: {},
},
fee,
memo,
_funds,
)
}
unlock = async (
{
shares,
}: {
shares: Uint128
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
unlock: {
shares,
},
},
fee,
memo,
_funds,
)
}
withdraw = async (
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
withdraw: {},
},
fee,
memo,
_funds,
)
}
openPosition = async (
{
accountId,
denom,
size,
}: {
accountId: string
denom: string
size: SignedDecimal
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
open_position: {
account_id: accountId,
denom,
size,
},
},
fee,
memo,
_funds,
)
}
closePosition = async (
{
accountId,
denom,
}: {
accountId: string
denom: string
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
close_position: {
account_id: accountId,
denom,
},
},
fee,
memo,
_funds,
)
}
}

View File

@ -0,0 +1,525 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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,
OracleBaseForString,
InstantiateMsg,
ExecuteMsg,
OwnerUpdate,
Decimal,
SignedDecimal,
QueryMsg,
ConfigForString,
DenomStateResponse,
Funding,
ArrayOfDenomStateResponse,
DepositResponse,
ArrayOfDepositResponse,
OwnerResponse,
PerpDenomState,
PnlValues,
PnL,
PositionResponse,
PerpPosition,
Coin,
ArrayOfPositionResponse,
PositionsByAccountResponse,
ArrayOfUnlockState,
UnlockState,
VaultState,
} from './MarsPerps.types'
import { MarsPerpsQueryClient, MarsPerpsClient } from './MarsPerps.client'
export const marsPerpsQueryKeys = {
contract: [
{
contract: 'marsPerps',
},
] as const,
address: (contractAddress: string | undefined) =>
[{ ...marsPerpsQueryKeys.contract[0], address: contractAddress }] as const,
owner: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'owner', args }] as const,
config: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'config', args }] as const,
vaultState: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'vault_state', args }] as const,
denomState: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'denom_state', args }] as const,
perpDenomState: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'perp_denom_state', args },
] as const,
denomStates: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'denom_states', args }] as const,
deposit: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'deposit', args }] as const,
deposits: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'deposits', args }] as const,
unlocks: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'unlocks', args }] as const,
position: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'position', args }] as const,
positions: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'positions', args }] as const,
positionsByAccount: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'positions_by_account', args },
] as const,
totalPnl: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsPerpsQueryKeys.address(contractAddress)[0], method: 'total_pnl', args }] as const,
}
export interface MarsPerpsReactQuery<TResponse, TData = TResponse> {
client: MarsPerpsQueryClient | undefined
options?: Omit<
UseQueryOptions<TResponse, Error, TData>,
"'queryKey' | 'queryFn' | 'initialData'"
> & {
initialData?: undefined
}
}
export interface MarsPerpsTotalPnlQuery<TData> extends MarsPerpsReactQuery<SignedDecimal, TData> {}
export function useMarsPerpsTotalPnlQuery<TData = SignedDecimal>({
client,
options,
}: MarsPerpsTotalPnlQuery<TData>) {
return useQuery<SignedDecimal, Error, TData>(
marsPerpsQueryKeys.totalPnl(client?.contractAddress),
() => (client ? client.totalPnl() : Promise.reject(new Error('Invalid client'))),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsPositionsByAccountQuery<TData>
extends MarsPerpsReactQuery<PositionsByAccountResponse, TData> {
args: {
accountId: string
}
}
export function useMarsPerpsPositionsByAccountQuery<TData = PositionsByAccountResponse>({
client,
args,
options,
}: MarsPerpsPositionsByAccountQuery<TData>) {
return useQuery<PositionsByAccountResponse, Error, TData>(
marsPerpsQueryKeys.positionsByAccount(client?.contractAddress, args),
() =>
client
? client.positionsByAccount({
accountId: args.accountId,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsPositionsQuery<TData>
extends MarsPerpsReactQuery<ArrayOfPositionResponse, TData> {
args: {
limit?: number
startAfter?: string[][]
}
}
export function useMarsPerpsPositionsQuery<TData = ArrayOfPositionResponse>({
client,
args,
options,
}: MarsPerpsPositionsQuery<TData>) {
return useQuery<ArrayOfPositionResponse, Error, TData>(
marsPerpsQueryKeys.positions(client?.contractAddress, args),
() =>
client
? client.positions({
limit: args.limit,
startAfter: args.startAfter,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsPositionQuery<TData>
extends MarsPerpsReactQuery<PositionResponse, TData> {
args: {
accountId: string
denom: string
}
}
export function useMarsPerpsPositionQuery<TData = PositionResponse>({
client,
args,
options,
}: MarsPerpsPositionQuery<TData>) {
return useQuery<PositionResponse, Error, TData>(
marsPerpsQueryKeys.position(client?.contractAddress, args),
() =>
client
? client.position({
accountId: args.accountId,
denom: args.denom,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsUnlocksQuery<TData>
extends MarsPerpsReactQuery<ArrayOfUnlockState, TData> {
args: {
depositor: string
}
}
export function useMarsPerpsUnlocksQuery<TData = ArrayOfUnlockState>({
client,
args,
options,
}: MarsPerpsUnlocksQuery<TData>) {
return useQuery<ArrayOfUnlockState, Error, TData>(
marsPerpsQueryKeys.unlocks(client?.contractAddress, args),
() =>
client
? client.unlocks({
depositor: args.depositor,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsDepositsQuery<TData>
extends MarsPerpsReactQuery<ArrayOfDepositResponse, TData> {
args: {
limit?: number
startAfter?: string
}
}
export function useMarsPerpsDepositsQuery<TData = ArrayOfDepositResponse>({
client,
args,
options,
}: MarsPerpsDepositsQuery<TData>) {
return useQuery<ArrayOfDepositResponse, Error, TData>(
marsPerpsQueryKeys.deposits(client?.contractAddress, args),
() =>
client
? client.deposits({
limit: args.limit,
startAfter: args.startAfter,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsDepositQuery<TData> extends MarsPerpsReactQuery<DepositResponse, TData> {
args: {
depositor: string
}
}
export function useMarsPerpsDepositQuery<TData = DepositResponse>({
client,
args,
options,
}: MarsPerpsDepositQuery<TData>) {
return useQuery<DepositResponse, Error, TData>(
marsPerpsQueryKeys.deposit(client?.contractAddress, args),
() =>
client
? client.deposit({
depositor: args.depositor,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsDenomStatesQuery<TData>
extends MarsPerpsReactQuery<ArrayOfDenomStateResponse, TData> {
args: {
limit?: number
startAfter?: string
}
}
export function useMarsPerpsDenomStatesQuery<TData = ArrayOfDenomStateResponse>({
client,
args,
options,
}: MarsPerpsDenomStatesQuery<TData>) {
return useQuery<ArrayOfDenomStateResponse, Error, TData>(
marsPerpsQueryKeys.denomStates(client?.contractAddress, args),
() =>
client
? client.denomStates({
limit: args.limit,
startAfter: args.startAfter,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsPerpDenomStateQuery<TData>
extends MarsPerpsReactQuery<PerpDenomState, TData> {
args: {
denom: string
}
}
export function useMarsPerpsPerpDenomStateQuery<TData = PerpDenomState>({
client,
args,
options,
}: MarsPerpsPerpDenomStateQuery<TData>) {
return useQuery<PerpDenomState, Error, TData>(
marsPerpsQueryKeys.perpDenomState(client?.contractAddress, args),
() =>
client
? client.perpDenomState({
denom: args.denom,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsDenomStateQuery<TData>
extends MarsPerpsReactQuery<DenomStateResponse, TData> {
args: {
denom: string
}
}
export function useMarsPerpsDenomStateQuery<TData = DenomStateResponse>({
client,
args,
options,
}: MarsPerpsDenomStateQuery<TData>) {
return useQuery<DenomStateResponse, Error, TData>(
marsPerpsQueryKeys.denomState(client?.contractAddress, args),
() =>
client
? client.denomState({
denom: args.denom,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsVaultStateQuery<TData> extends MarsPerpsReactQuery<VaultState, TData> {}
export function useMarsPerpsVaultStateQuery<TData = VaultState>({
client,
options,
}: MarsPerpsVaultStateQuery<TData>) {
return useQuery<VaultState, Error, TData>(
marsPerpsQueryKeys.vaultState(client?.contractAddress),
() => (client ? client.vaultState() : Promise.reject(new Error('Invalid client'))),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsConfigQuery<TData> extends MarsPerpsReactQuery<ConfigForString, TData> {}
export function useMarsPerpsConfigQuery<TData = ConfigForString>({
client,
options,
}: MarsPerpsConfigQuery<TData>) {
return useQuery<ConfigForString, Error, TData>(
marsPerpsQueryKeys.config(client?.contractAddress),
() => (client ? client.config() : Promise.reject(new Error('Invalid client'))),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsOwnerQuery<TData> extends MarsPerpsReactQuery<OwnerResponse, TData> {}
export function useMarsPerpsOwnerQuery<TData = OwnerResponse>({
client,
options,
}: MarsPerpsOwnerQuery<TData>) {
return useQuery<OwnerResponse, Error, TData>(
marsPerpsQueryKeys.owner(client?.contractAddress),
() => (client ? client.owner() : Promise.reject(new Error('Invalid client'))),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsPerpsClosePositionMutation {
client: MarsPerpsClient
msg: {
accountId: string
denom: string
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsClosePositionMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsPerpsClosePositionMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsClosePositionMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) =>
client.closePosition(msg, fee, memo, funds),
options,
)
}
export interface MarsPerpsOpenPositionMutation {
client: MarsPerpsClient
msg: {
accountId: string
denom: string
size: SignedDecimal
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsOpenPositionMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsPerpsOpenPositionMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsOpenPositionMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) =>
client.openPosition(msg, fee, memo, funds),
options,
)
}
export interface MarsPerpsWithdrawMutation {
client: MarsPerpsClient
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsWithdrawMutation(
options?: Omit<UseMutationOptions<ExecuteResult, Error, MarsPerpsWithdrawMutation>, 'mutationFn'>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsWithdrawMutation>(
({ client, args: { fee, memo, funds } = {} }) => client.withdraw(fee, memo, funds),
options,
)
}
export interface MarsPerpsUnlockMutation {
client: MarsPerpsClient
msg: {
shares: Uint128
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsUnlockMutation(
options?: Omit<UseMutationOptions<ExecuteResult, Error, MarsPerpsUnlockMutation>, 'mutationFn'>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsUnlockMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.unlock(msg, fee, memo, funds),
options,
)
}
export interface MarsPerpsDepositMutation {
client: MarsPerpsClient
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsDepositMutation(
options?: Omit<UseMutationOptions<ExecuteResult, Error, MarsPerpsDepositMutation>, 'mutationFn'>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsDepositMutation>(
({ client, args: { fee, memo, funds } = {} }) => client.deposit(fee, memo, funds),
options,
)
}
export interface MarsPerpsDisableDenomMutation {
client: MarsPerpsClient
msg: {
denom: string
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsDisableDenomMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsPerpsDisableDenomMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsDisableDenomMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) =>
client.disableDenom(msg, fee, memo, funds),
options,
)
}
export interface MarsPerpsEnableDenomMutation {
client: MarsPerpsClient
msg: {
denom: string
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsEnableDenomMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsPerpsEnableDenomMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsEnableDenomMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.enableDenom(msg, fee, memo, funds),
options,
)
}
export interface MarsPerpsInitDenomMutation {
client: MarsPerpsClient
msg: {
denom: string
maxFundingVelocity: Decimal
skewScale: Decimal
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsInitDenomMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsPerpsInitDenomMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsInitDenomMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.initDenom(msg, fee, memo, funds),
options,
)
}
export interface MarsPerpsUpdateOwnerMutation {
client: MarsPerpsClient
msg: OwnerUpdate
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsPerpsUpdateOwnerMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsPerpsUpdateOwnerMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsPerpsUpdateOwnerMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.updateOwner(msg, fee, memo, funds),
options,
)
}

View File

@ -0,0 +1,238 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 OracleBaseForString = string
export interface InstantiateMsg {
base_denom: string
cooldown_period: number
credit_manager: string
min_position_value: Uint128
oracle: OracleBaseForString
}
export type ExecuteMsg =
| {
update_owner: OwnerUpdate
}
| {
init_denom: {
denom: string
max_funding_velocity: Decimal
skew_scale: Decimal
}
}
| {
enable_denom: {
denom: string
}
}
| {
disable_denom: {
denom: string
}
}
| {
deposit: {}
}
| {
unlock: {
shares: Uint128
}
}
| {
withdraw: {}
}
| {
open_position: {
account_id: string
denom: string
size: SignedDecimal
}
}
| {
close_position: {
account_id: string
denom: string
}
}
export type OwnerUpdate =
| {
propose_new_owner: {
proposed: string
}
}
| 'clear_proposed'
| 'accept_proposed'
| 'abolish_owner_role'
| {
set_emergency_owner: {
emergency_owner: string
}
}
| 'clear_emergency_owner'
export type Decimal = string
export interface SignedDecimal {
abs: Decimal
negative: boolean
[k: string]: unknown
}
export type QueryMsg =
| {
owner: {}
}
| {
config: {}
}
| {
vault_state: {}
}
| {
denom_state: {
denom: string
}
}
| {
perp_denom_state: {
denom: string
}
}
| {
denom_states: {
limit?: number | null
start_after?: string | null
}
}
| {
deposit: {
depositor: string
}
}
| {
deposits: {
limit?: number | null
start_after?: string | null
}
}
| {
unlocks: {
depositor: string
}
}
| {
position: {
account_id: string
denom: string
}
}
| {
positions: {
limit?: number | null
start_after?: [string, string] | null
}
}
| {
positions_by_account: {
account_id: string
}
}
| {
total_pnl: {}
}
export interface ConfigForString {
base_denom: string
cooldown_period: number
credit_manager: string
min_position_value: Uint128
oracle: OracleBaseForString
}
export interface DenomStateResponse {
denom: string
enabled: boolean
funding: Funding
last_updated: number
total_cost_base: SignedDecimal
total_size: SignedDecimal
}
export interface Funding {
accumulated_size_weighted_by_index: SignedDecimal
constant_factor: SignedDecimal
index: SignedDecimal
max_funding_velocity: Decimal
rate: SignedDecimal
skew_scale: Decimal
}
export type ArrayOfDenomStateResponse = DenomStateResponse[]
export interface DepositResponse {
amount: Uint128
depositor: string
shares: Uint128
}
export type ArrayOfDepositResponse = DepositResponse[]
export interface OwnerResponse {
abolished: boolean
emergency_owner?: string | null
initialized: boolean
owner?: string | null
proposed?: string | null
}
export interface PerpDenomState {
constant_factor: SignedDecimal
denom: string
enabled: boolean
index: SignedDecimal
pnl_values: PnlValues
rate: SignedDecimal
total_cost_base: SignedDecimal
total_size: SignedDecimal
}
export interface PnlValues {
accrued_funding: SignedDecimal
pnl: SignedDecimal
unrealized_pnl: SignedDecimal
}
export type PnL =
| 'break_even'
| {
profit: Coin
}
| {
loss: Coin
}
export interface PositionResponse {
account_id: string
position: PerpPosition
}
export interface PerpPosition {
base_denom: string
closing_fee_rate: Decimal
current_price: Decimal
denom: string
entry_price: Decimal
pnl: PnL
size: SignedDecimal
unrealised_funding_accrued: SignedDecimal
}
export interface Coin {
amount: Uint128
denom: string
[k: string]: unknown
}
export type ArrayOfPositionResponse = PositionResponse[]
export interface PositionsByAccountResponse {
account_id: string
positions: PerpPosition[]
}
export type ArrayOfUnlockState = UnlockState[]
export interface UnlockState {
amount: Uint128
cooldown_end: number
created_at: number
}
export interface VaultState {
total_liquidity: Uint128
total_shares: Uint128
}

View File

@ -0,0 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _24 from './MarsPerps.types'
import * as _25 from './MarsPerps.client'
import * as _26 from './MarsPerps.react-query'
export namespace contracts {
export const MarsPerps = { ..._24, ..._25, ..._26 }
}

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -8,12 +8,13 @@
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate'
import { Coin, StdFee } from '@cosmjs/amino'
import {
Decimal,
InstantiateMsg,
CreateOrUpdateConfig,
ExecuteMsg,
OwnerUpdate,
Decimal,
Uint128,
MigrateV1ToV2,
InitOrUpdateAssetParams,
InterestRateModel,
QueryMsg,
@ -24,6 +25,8 @@ import {
ArrayOfUncollateralizedLoanLimitResponse,
UserCollateralResponse,
ArrayOfUserCollateralResponse,
PaginationResponseForUserCollateralResponse,
Metadata,
UserDebtResponse,
ArrayOfUserDebtResponse,
UserHealthStatus,
@ -67,22 +70,50 @@ export interface MarsRedBankReadOnlyInterface {
user: string
}) => Promise<ArrayOfUserDebtResponse>
userCollateral: ({
accountId,
denom,
user,
}: {
accountId?: string
denom: string
user: string
}) => Promise<UserCollateralResponse>
userCollaterals: ({
accountId,
limit,
startAfter,
user,
}: {
accountId?: string
limit?: number
startAfter?: string
user: string
}) => Promise<ArrayOfUserCollateralResponse>
userPosition: ({ user }: { user: string }) => Promise<UserPositionResponse>
userCollateralsV2: ({
accountId,
limit,
startAfter,
user,
}: {
accountId?: string
limit?: number
startAfter?: string
user: string
}) => Promise<PaginationResponseForUserCollateralResponse>
userPosition: ({
accountId,
user,
}: {
accountId?: string
user: string
}) => Promise<UserPositionResponse>
userPositionLiquidationPricing: ({
accountId,
user,
}: {
accountId?: string
user: string
}) => Promise<UserPositionResponse>
scaledLiquidityAmount: ({ amount, denom }: { amount: Uint128; denom: string }) => Promise<Uint128>
scaledDebtAmount: ({ amount, denom }: { amount: Uint128; denom: string }) => Promise<Uint128>
underlyingLiquidityAmount: ({
@ -116,7 +147,9 @@ export class MarsRedBankQueryClient implements MarsRedBankReadOnlyInterface {
this.userDebts = this.userDebts.bind(this)
this.userCollateral = this.userCollateral.bind(this)
this.userCollaterals = this.userCollaterals.bind(this)
this.userCollateralsV2 = this.userCollateralsV2.bind(this)
this.userPosition = this.userPosition.bind(this)
this.userPositionLiquidationPricing = this.userPositionLiquidationPricing.bind(this)
this.scaledLiquidityAmount = this.scaledLiquidityAmount.bind(this)
this.scaledDebtAmount = this.scaledDebtAmount.bind(this)
this.underlyingLiquidityAmount = this.underlyingLiquidityAmount.bind(this)
@ -212,39 +245,86 @@ export class MarsRedBankQueryClient implements MarsRedBankReadOnlyInterface {
})
}
userCollateral = async ({
accountId,
denom,
user,
}: {
accountId?: string
denom: string
user: string
}): Promise<UserCollateralResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
user_collateral: {
account_id: accountId,
denom,
user,
},
})
}
userCollaterals = async ({
accountId,
limit,
startAfter,
user,
}: {
accountId?: string
limit?: number
startAfter?: string
user: string
}): Promise<ArrayOfUserCollateralResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
user_collaterals: {
account_id: accountId,
limit,
start_after: startAfter,
user,
},
})
}
userPosition = async ({ user }: { user: string }): Promise<UserPositionResponse> => {
userCollateralsV2 = async ({
accountId,
limit,
startAfter,
user,
}: {
accountId?: string
limit?: number
startAfter?: string
user: string
}): Promise<PaginationResponseForUserCollateralResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
user_collaterals_v2: {
account_id: accountId,
limit,
start_after: startAfter,
user,
},
})
}
userPosition = async ({
accountId,
user,
}: {
accountId?: string
user: string
}): Promise<UserPositionResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
user_position: {
account_id: accountId,
user,
},
})
}
userPositionLiquidationPricing = async ({
accountId,
user,
}: {
accountId?: string
user: string
}): Promise<UserPositionResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
user_position_liquidation_pricing: {
account_id: accountId,
user,
},
})
@ -365,8 +445,10 @@ export interface MarsRedBankInterface extends MarsRedBankReadOnlyInterface {
) => Promise<ExecuteResult>
deposit: (
{
accountId,
onBehalfOf,
}: {
accountId?: string
onBehalfOf?: string
},
fee?: number | StdFee | 'auto',
@ -375,12 +457,16 @@ export interface MarsRedBankInterface extends MarsRedBankReadOnlyInterface {
) => Promise<ExecuteResult>
withdraw: (
{
accountId,
amount,
denom,
liquidationRelated,
recipient,
}: {
accountId?: string
amount?: Uint128
denom: string
liquidationRelated?: boolean
recipient?: string
},
fee?: number | StdFee | 'auto',
@ -437,6 +523,12 @@ export interface MarsRedBankInterface extends MarsRedBankReadOnlyInterface {
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
migrate: (
migrateV1ToV2: MigrateV1ToV2,
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
}
export class MarsRedBankClient extends MarsRedBankQueryClient implements MarsRedBankInterface {
client: SigningCosmWasmClient
@ -459,6 +551,7 @@ export class MarsRedBankClient extends MarsRedBankQueryClient implements MarsRed
this.repay = this.repay.bind(this)
this.liquidate = this.liquidate.bind(this)
this.updateAssetCollateralStatus = this.updateAssetCollateralStatus.bind(this)
this.migrate = this.migrate.bind(this)
}
updateOwner = async (
@ -584,8 +677,10 @@ export class MarsRedBankClient extends MarsRedBankQueryClient implements MarsRed
}
deposit = async (
{
accountId,
onBehalfOf,
}: {
accountId?: string
onBehalfOf?: string
},
fee: number | StdFee | 'auto' = 'auto',
@ -597,6 +692,7 @@ export class MarsRedBankClient extends MarsRedBankQueryClient implements MarsRed
this.contractAddress,
{
deposit: {
account_id: accountId,
on_behalf_of: onBehalfOf,
},
},
@ -607,12 +703,16 @@ export class MarsRedBankClient extends MarsRedBankQueryClient implements MarsRed
}
withdraw = async (
{
accountId,
amount,
denom,
liquidationRelated,
recipient,
}: {
accountId?: string
amount?: Uint128
denom: string
liquidationRelated?: boolean
recipient?: string
},
fee: number | StdFee | 'auto' = 'auto',
@ -624,8 +724,10 @@ export class MarsRedBankClient extends MarsRedBankQueryClient implements MarsRed
this.contractAddress,
{
withdraw: {
account_id: accountId,
amount,
denom,
liquidation_related: liquidationRelated,
recipient,
},
},
@ -741,4 +843,21 @@ export class MarsRedBankClient extends MarsRedBankQueryClient implements MarsRed
_funds,
)
}
migrate = async (
migrateV1ToV2: MigrateV1ToV2,
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
migrate: migrateV1ToV2,
},
fee,
memo,
_funds,
)
}
}

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -9,12 +9,13 @@ import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tan
import { ExecuteResult } from '@cosmjs/cosmwasm-stargate'
import { StdFee, Coin } from '@cosmjs/amino'
import {
Decimal,
InstantiateMsg,
CreateOrUpdateConfig,
ExecuteMsg,
OwnerUpdate,
Decimal,
Uint128,
MigrateV1ToV2,
InitOrUpdateAssetParams,
InterestRateModel,
QueryMsg,
@ -25,6 +26,8 @@ import {
ArrayOfUncollateralizedLoanLimitResponse,
UserCollateralResponse,
ArrayOfUserCollateralResponse,
PaginationResponseForUserCollateralResponse,
Metadata,
UserDebtResponse,
ArrayOfUserDebtResponse,
UserHealthStatus,
@ -79,10 +82,25 @@ export const marsRedBankQueryKeys = {
[
{ ...marsRedBankQueryKeys.address(contractAddress)[0], method: 'user_collaterals', args },
] as const,
userCollateralsV2: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsRedBankQueryKeys.address(contractAddress)[0], method: 'user_collaterals_v2', args },
] as const,
userPosition: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsRedBankQueryKeys.address(contractAddress)[0], method: 'user_position', args },
] as const,
userPositionLiquidationPricing: (
contractAddress: string | undefined,
args?: Record<string, unknown>,
) =>
[
{
...marsRedBankQueryKeys.address(contractAddress)[0],
method: 'user_position_liquidation_pricing',
args,
},
] as const,
scaledLiquidityAmount: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{
@ -220,9 +238,34 @@ export function useMarsRedBankScaledLiquidityAmountQuery<TData = Uint128>({
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsRedBankUserPositionLiquidationPricingQuery<TData>
extends MarsRedBankReactQuery<UserPositionResponse, TData> {
args: {
accountId?: string
user: string
}
}
export function useMarsRedBankUserPositionLiquidationPricingQuery<TData = UserPositionResponse>({
client,
args,
options,
}: MarsRedBankUserPositionLiquidationPricingQuery<TData>) {
return useQuery<UserPositionResponse, Error, TData>(
marsRedBankQueryKeys.userPositionLiquidationPricing(client?.contractAddress, args),
() =>
client
? client.userPositionLiquidationPricing({
accountId: args.accountId,
user: args.user,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsRedBankUserPositionQuery<TData>
extends MarsRedBankReactQuery<UserPositionResponse, TData> {
args: {
accountId?: string
user: string
}
}
@ -236,6 +279,33 @@ export function useMarsRedBankUserPositionQuery<TData = UserPositionResponse>({
() =>
client
? client.userPosition({
accountId: args.accountId,
user: args.user,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsRedBankUserCollateralsV2Query<TData>
extends MarsRedBankReactQuery<PaginationResponseForUserCollateralResponse, TData> {
args: {
accountId?: string
limit?: number
startAfter?: string
user: string
}
}
export function useMarsRedBankUserCollateralsV2Query<
TData = PaginationResponseForUserCollateralResponse,
>({ client, args, options }: MarsRedBankUserCollateralsV2Query<TData>) {
return useQuery<PaginationResponseForUserCollateralResponse, Error, TData>(
marsRedBankQueryKeys.userCollateralsV2(client?.contractAddress, args),
() =>
client
? client.userCollateralsV2({
accountId: args.accountId,
limit: args.limit,
startAfter: args.startAfter,
user: args.user,
})
: Promise.reject(new Error('Invalid client')),
@ -245,6 +315,7 @@ export function useMarsRedBankUserPositionQuery<TData = UserPositionResponse>({
export interface MarsRedBankUserCollateralsQuery<TData>
extends MarsRedBankReactQuery<ArrayOfUserCollateralResponse, TData> {
args: {
accountId?: string
limit?: number
startAfter?: string
user: string
@ -260,6 +331,7 @@ export function useMarsRedBankUserCollateralsQuery<TData = ArrayOfUserCollateral
() =>
client
? client.userCollaterals({
accountId: args.accountId,
limit: args.limit,
startAfter: args.startAfter,
user: args.user,
@ -271,6 +343,7 @@ export function useMarsRedBankUserCollateralsQuery<TData = ArrayOfUserCollateral
export interface MarsRedBankUserCollateralQuery<TData>
extends MarsRedBankReactQuery<UserCollateralResponse, TData> {
args: {
accountId?: string
denom: string
user: string
}
@ -285,6 +358,7 @@ export function useMarsRedBankUserCollateralQuery<TData = UserCollateralResponse
() =>
client
? client.userCollateral({
accountId: args.accountId,
denom: args.denom,
user: args.user,
})
@ -445,6 +519,26 @@ export function useMarsRedBankConfigQuery<TData = ConfigResponse>({
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsRedBankMigrateMutation {
client: MarsRedBankClient
msg: MigrateV1ToV2
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsRedBankMigrateMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsRedBankMigrateMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsRedBankMigrateMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.migrate(msg, fee, memo, funds),
options,
)
}
export interface MarsRedBankUpdateAssetCollateralStatusMutation {
client: MarsRedBankClient
msg: {
@ -536,8 +630,10 @@ export function useMarsRedBankBorrowMutation(
export interface MarsRedBankWithdrawMutation {
client: MarsRedBankClient
msg: {
accountId?: string
amount?: Uint128
denom: string
liquidationRelated?: boolean
recipient?: string
}
args?: {
@ -560,6 +656,7 @@ export function useMarsRedBankWithdrawMutation(
export interface MarsRedBankDepositMutation {
client: MarsRedBankClient
msg: {
accountId?: string
onBehalfOf?: string
}
args?: {

View File

@ -1,18 +1,16 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 {
config: CreateOrUpdateConfig
owner: string
}
export interface CreateOrUpdateConfig {
address_provider?: string | null
close_factor?: Decimal | null
}
export type ExecuteMsg =
| {
@ -44,13 +42,16 @@ export type ExecuteMsg =
}
| {
deposit: {
account_id?: string | null
on_behalf_of?: string | null
}
}
| {
withdraw: {
account_id?: string | null
amount?: Uint128 | null
denom: string
liquidation_related?: boolean | null
recipient?: string | null
}
}
@ -79,6 +80,9 @@ export type ExecuteMsg =
enable: boolean
}
}
| {
migrate: MigrateV1ToV2
}
export type OwnerUpdate =
| {
propose_new_owner: {
@ -94,15 +98,19 @@ export type OwnerUpdate =
}
}
| 'clear_emergency_owner'
export type Decimal = string
export type Uint128 = string
export type MigrateV1ToV2 =
| {
collaterals: {
limit: number
}
}
| {
clear_v1_state: {}
}
export interface InitOrUpdateAssetParams {
borrow_enabled?: boolean | null
deposit_cap?: Uint128 | null
deposit_enabled?: boolean | 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 {
@ -154,12 +162,22 @@ export type QueryMsg =
}
| {
user_collateral: {
account_id?: string | null
denom: string
user: string
}
}
| {
user_collaterals: {
account_id?: string | null
limit?: number | null
start_after?: string | null
user: string
}
}
| {
user_collaterals_v2: {
account_id?: string | null
limit?: number | null
start_after?: string | null
user: string
@ -167,6 +185,13 @@ export type QueryMsg =
}
| {
user_position: {
account_id?: string | null
user: string
}
}
| {
user_position_liquidation_pricing: {
account_id?: string | null
user: string
}
}
@ -196,27 +221,19 @@ export type QueryMsg =
}
export interface ConfigResponse {
address_provider: string
close_factor: Decimal
emergency_owner?: string | null
owner?: string | null
proposed_new_owner?: string | null
}
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[]
@ -232,6 +249,13 @@ export interface UserCollateralResponse {
enabled: boolean
}
export type ArrayOfUserCollateralResponse = UserCollateralResponse[]
export interface PaginationResponseForUserCollateralResponse {
data: UserCollateralResponse[]
metadata: Metadata
}
export interface Metadata {
has_more: boolean
}
export interface UserDebtResponse {
amount: Uint128
amount_scaled: Uint128

View File

@ -1,13 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 './MarsRedBank.types'
import * as _13 from './MarsRedBank.client'
import * as _14 from './MarsRedBank.react-query'
import * as _27 from './MarsRedBank.types'
import * as _28 from './MarsRedBank.client'
import * as _29 from './MarsRedBank.react-query'
export namespace contracts {
export const MarsRedBank = { ..._12, ..._13, ..._14 }
export const MarsRedBank = { ..._27, ..._28, ..._29 }
}

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -11,6 +11,7 @@ import {
Decimal,
Uint128,
AccountKind,
PnL,
VaultPositionAmount,
VaultAmount,
VaultAmount1,
@ -25,6 +26,11 @@ import {
Positions,
DebtAmount,
Coin,
PerpPosition,
PositionPnl,
PnlCoins,
PnlValues,
SignedDecimal,
VaultPosition,
LockingVaultAmount,
VaultUnlockingPosition,

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -11,6 +11,7 @@ import {
Decimal,
Uint128,
AccountKind,
PnL,
VaultPositionAmount,
VaultAmount,
VaultAmount1,
@ -25,6 +26,11 @@ import {
Positions,
DebtAmount,
Coin,
PerpPosition,
PositionPnl,
PnlCoins,
PnlValues,
SignedDecimal,
VaultPosition,
LockingVaultAmount,
VaultUnlockingPosition,

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -20,6 +20,14 @@ export type Addr = string
export type Decimal = string
export type Uint128 = string
export type AccountKind = 'default' | 'high_levered_strategy'
export type PnL =
| 'break_even'
| {
profit: Coin
}
| {
loss: Coin
}
export type VaultPositionAmount =
| {
unlocked: VaultAmount
@ -78,6 +86,7 @@ export interface Positions {
debts: DebtAmount[]
deposits: Coin[]
lends: Coin[]
perps: PerpPosition[]
vaults: VaultPosition[]
}
export interface DebtAmount {
@ -90,6 +99,34 @@ export interface Coin {
denom: string
[k: string]: unknown
}
export interface PerpPosition {
base_denom: string
closing_fee_rate: Decimal
current_price: Decimal
denom: string
entry_price: Decimal
pnl: PositionPnl
size: SignedDecimal
}
export interface PositionPnl {
coins: PnlCoins
values: PnlValues
}
export interface PnlCoins {
closing_fee: Coin
pnl: PnL
}
export interface PnlValues {
accrued_funding: SignedDecimal
closing_fee: SignedDecimal
pnl: SignedDecimal
price_pnl: SignedDecimal
}
export interface SignedDecimal {
abs: Decimal
negative: boolean
[k: string]: unknown
}
export interface VaultPosition {
amount: VaultPositionAmount
vault: VaultBaseForAddr

View File

@ -1,14 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _32 from './MarsRoverHealthComputer.types'
import * as _33 from './MarsRoverHealthComputer.client'
import * as _34 from './MarsRoverHealthComputer.message-composer'
import * as _35 from './MarsRoverHealthComputer.react-query'
import * as _36 from './MarsRoverHealthComputer.types'
import * as _37 from './MarsRoverHealthComputer.client'
import * as _38 from './MarsRoverHealthComputer.react-query'
export namespace contracts {
export const MarsRoverHealthComputer = { ..._32, ..._33, ..._34, ..._35 }
export const MarsRoverHealthComputer = { ..._36, ..._37, ..._38 }
}

View File

@ -0,0 +1,289 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 {
InstantiateMsg,
ExecuteMsg,
OwnerUpdate,
SwapOperation,
AssetInfo,
Addr,
Uint128,
Decimal,
AstroportRoute,
Coin,
QueryMsg,
EstimateExactInSwapResponse,
OwnerResponse,
RouteResponseForEmpty,
Empty,
ArrayOfRouteResponseForEmpty,
} from './MarsSwapperAstroport.types'
export interface MarsSwapperAstroportReadOnlyInterface {
contractAddress: string
owner: () => Promise<OwnerResponse>
route: ({
denomIn,
denomOut,
}: {
denomIn: string
denomOut: string
}) => Promise<RouteResponseForEmpty>
routes: ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string[][]
}) => Promise<ArrayOfRouteResponseForEmpty>
estimateExactInSwap: ({
coinIn,
denomOut,
}: {
coinIn: Coin
denomOut: string
}) => Promise<EstimateExactInSwapResponse>
}
export class MarsSwapperAstroportQueryClient implements MarsSwapperAstroportReadOnlyInterface {
client: CosmWasmClient
contractAddress: string
constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client
this.contractAddress = contractAddress
this.owner = this.owner.bind(this)
this.route = this.route.bind(this)
this.routes = this.routes.bind(this)
this.estimateExactInSwap = this.estimateExactInSwap.bind(this)
}
owner = async (): Promise<OwnerResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
owner: {},
})
}
route = async ({
denomIn,
denomOut,
}: {
denomIn: string
denomOut: string
}): Promise<RouteResponseForEmpty> => {
return this.client.queryContractSmart(this.contractAddress, {
route: {
denom_in: denomIn,
denom_out: denomOut,
},
})
}
routes = async ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string[][]
}): Promise<ArrayOfRouteResponseForEmpty> => {
return this.client.queryContractSmart(this.contractAddress, {
routes: {
limit,
start_after: startAfter,
},
})
}
estimateExactInSwap = async ({
coinIn,
denomOut,
}: {
coinIn: Coin
denomOut: string
}): Promise<EstimateExactInSwapResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
estimate_exact_in_swap: {
coin_in: coinIn,
denom_out: denomOut,
},
})
}
}
export interface MarsSwapperAstroportInterface extends MarsSwapperAstroportReadOnlyInterface {
contractAddress: string
sender: string
updateOwner: (
ownerUpdate: OwnerUpdate,
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
setRoute: (
{
denomIn,
denomOut,
route,
}: {
denomIn: string
denomOut: string
route: AstroportRoute
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
swapExactIn: (
{
coinIn,
denomOut,
slippage,
}: {
coinIn: Coin
denomOut: string
slippage: Decimal
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
transferResult: (
{
denomIn,
denomOut,
recipient,
}: {
denomIn: string
denomOut: string
recipient: Addr
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
}
export class MarsSwapperAstroportClient
extends MarsSwapperAstroportQueryClient
implements MarsSwapperAstroportInterface
{
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.updateOwner = this.updateOwner.bind(this)
this.setRoute = this.setRoute.bind(this)
this.swapExactIn = this.swapExactIn.bind(this)
this.transferResult = this.transferResult.bind(this)
}
updateOwner = async (
ownerUpdate: OwnerUpdate,
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
update_owner: ownerUpdate,
},
fee,
memo,
_funds,
)
}
setRoute = async (
{
denomIn,
denomOut,
route,
}: {
denomIn: string
denomOut: string
route: AstroportRoute
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
set_route: {
denom_in: denomIn,
denom_out: denomOut,
route,
},
},
fee,
memo,
_funds,
)
}
swapExactIn = async (
{
coinIn,
denomOut,
slippage,
}: {
coinIn: Coin
denomOut: string
slippage: Decimal
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
swap_exact_in: {
coin_in: coinIn,
denom_out: denomOut,
slippage,
},
},
fee,
memo,
_funds,
)
}
transferResult = async (
{
denomIn,
denomOut,
recipient,
}: {
denomIn: string
denomOut: string
recipient: Addr
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
transfer_result: {
denom_in: denomIn,
denom_out: denomOut,
recipient,
},
},
fee,
memo,
_funds,
)
}
}

View File

@ -0,0 +1,245 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 {
InstantiateMsg,
ExecuteMsg,
OwnerUpdate,
SwapOperation,
AssetInfo,
Addr,
Uint128,
Decimal,
AstroportRoute,
Coin,
QueryMsg,
EstimateExactInSwapResponse,
OwnerResponse,
RouteResponseForEmpty,
Empty,
ArrayOfRouteResponseForEmpty,
} from './MarsSwapperAstroport.types'
import {
MarsSwapperAstroportQueryClient,
MarsSwapperAstroportClient,
} from './MarsSwapperAstroport.client'
export const marsSwapperAstroportQueryKeys = {
contract: [
{
contract: 'marsSwapperAstroport',
},
] as const,
address: (contractAddress: string | undefined) =>
[{ ...marsSwapperAstroportQueryKeys.contract[0], address: contractAddress }] as const,
owner: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsSwapperAstroportQueryKeys.address(contractAddress)[0], method: 'owner', args },
] as const,
route: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsSwapperAstroportQueryKeys.address(contractAddress)[0], method: 'route', args },
] as const,
routes: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{ ...marsSwapperAstroportQueryKeys.address(contractAddress)[0], method: 'routes', args },
] as const,
estimateExactInSwap: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{
...marsSwapperAstroportQueryKeys.address(contractAddress)[0],
method: 'estimate_exact_in_swap',
args,
},
] as const,
}
export interface MarsSwapperAstroportReactQuery<TResponse, TData = TResponse> {
client: MarsSwapperAstroportQueryClient | undefined
options?: Omit<
UseQueryOptions<TResponse, Error, TData>,
"'queryKey' | 'queryFn' | 'initialData'"
> & {
initialData?: undefined
}
}
export interface MarsSwapperAstroportEstimateExactInSwapQuery<TData>
extends MarsSwapperAstroportReactQuery<EstimateExactInSwapResponse, TData> {
args: {
coinIn: Coin
denomOut: string
}
}
export function useMarsSwapperAstroportEstimateExactInSwapQuery<
TData = EstimateExactInSwapResponse,
>({ client, args, options }: MarsSwapperAstroportEstimateExactInSwapQuery<TData>) {
return useQuery<EstimateExactInSwapResponse, Error, TData>(
marsSwapperAstroportQueryKeys.estimateExactInSwap(client?.contractAddress, args),
() =>
client
? client.estimateExactInSwap({
coinIn: args.coinIn,
denomOut: args.denomOut,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperAstroportRoutesQuery<TData>
extends MarsSwapperAstroportReactQuery<ArrayOfRouteResponseForEmpty, TData> {
args: {
limit?: number
startAfter?: string[][]
}
}
export function useMarsSwapperAstroportRoutesQuery<TData = ArrayOfRouteResponseForEmpty>({
client,
args,
options,
}: MarsSwapperAstroportRoutesQuery<TData>) {
return useQuery<ArrayOfRouteResponseForEmpty, Error, TData>(
marsSwapperAstroportQueryKeys.routes(client?.contractAddress, args),
() =>
client
? client.routes({
limit: args.limit,
startAfter: args.startAfter,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperAstroportRouteQuery<TData>
extends MarsSwapperAstroportReactQuery<RouteResponseForEmpty, TData> {
args: {
denomIn: string
denomOut: string
}
}
export function useMarsSwapperAstroportRouteQuery<TData = RouteResponseForEmpty>({
client,
args,
options,
}: MarsSwapperAstroportRouteQuery<TData>) {
return useQuery<RouteResponseForEmpty, Error, TData>(
marsSwapperAstroportQueryKeys.route(client?.contractAddress, args),
() =>
client
? client.route({
denomIn: args.denomIn,
denomOut: args.denomOut,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperAstroportOwnerQuery<TData>
extends MarsSwapperAstroportReactQuery<OwnerResponse, TData> {}
export function useMarsSwapperAstroportOwnerQuery<TData = OwnerResponse>({
client,
options,
}: MarsSwapperAstroportOwnerQuery<TData>) {
return useQuery<OwnerResponse, Error, TData>(
marsSwapperAstroportQueryKeys.owner(client?.contractAddress),
() => (client ? client.owner() : Promise.reject(new Error('Invalid client'))),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperAstroportTransferResultMutation {
client: MarsSwapperAstroportClient
msg: {
denomIn: string
denomOut: string
recipient: Addr
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperAstroportTransferResultMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperAstroportTransferResultMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperAstroportTransferResultMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) =>
client.transferResult(msg, fee, memo, funds),
options,
)
}
export interface MarsSwapperAstroportSwapExactInMutation {
client: MarsSwapperAstroportClient
msg: {
coinIn: Coin
denomOut: string
slippage: Decimal
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperAstroportSwapExactInMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperAstroportSwapExactInMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperAstroportSwapExactInMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.swapExactIn(msg, fee, memo, funds),
options,
)
}
export interface MarsSwapperAstroportSetRouteMutation {
client: MarsSwapperAstroportClient
msg: {
denomIn: string
denomOut: string
route: AstroportRoute
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperAstroportSetRouteMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperAstroportSetRouteMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperAstroportSetRouteMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.setRoute(msg, fee, memo, funds),
options,
)
}
export interface MarsSwapperAstroportUpdateOwnerMutation {
client: MarsSwapperAstroportClient
msg: OwnerUpdate
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperAstroportUpdateOwnerMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperAstroportUpdateOwnerMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperAstroportUpdateOwnerMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.updateOwner(msg, fee, memo, funds),
options,
)
}

View File

@ -0,0 +1,129 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 interface InstantiateMsg {
owner: string
}
export type ExecuteMsg =
| {
update_owner: OwnerUpdate
}
| {
set_route: {
denom_in: string
denom_out: string
route: AstroportRoute
}
}
| {
swap_exact_in: {
coin_in: Coin
denom_out: string
slippage: Decimal
}
}
| {
transfer_result: {
denom_in: string
denom_out: string
recipient: Addr
}
}
export type OwnerUpdate =
| {
propose_new_owner: {
proposed: string
}
}
| 'clear_proposed'
| 'accept_proposed'
| 'abolish_owner_role'
| {
set_emergency_owner: {
emergency_owner: string
}
}
| 'clear_emergency_owner'
export type SwapOperation =
| {
native_swap: {
ask_denom: string
offer_denom: string
}
}
| {
astro_swap: {
ask_asset_info: AssetInfo
offer_asset_info: AssetInfo
}
}
export type AssetInfo =
| {
token: {
contract_addr: Addr
}
}
| {
native_token: {
denom: string
}
}
export type Addr = string
export type Uint128 = string
export type Decimal = string
export interface AstroportRoute {
factory: string
operations: SwapOperation[]
oracle: string
router: string
}
export interface Coin {
amount: Uint128
denom: string
[k: string]: unknown
}
export type QueryMsg =
| {
owner: {}
}
| {
route: {
denom_in: string
denom_out: string
}
}
| {
routes: {
limit?: number | null
start_after?: [string, string] | null
}
}
| {
estimate_exact_in_swap: {
coin_in: Coin
denom_out: string
}
}
export interface EstimateExactInSwapResponse {
amount: Uint128
}
export interface OwnerResponse {
abolished: boolean
emergency_owner?: string | null
initialized: boolean
owner?: string | null
proposed?: string | null
}
export interface RouteResponseForEmpty {
denom_in: string
denom_out: string
route: Empty
}
export interface Empty {
[k: string]: unknown
}
export type ArrayOfRouteResponseForEmpty = RouteResponseForEmpty[]

View File

@ -0,0 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _39 from './MarsSwapperAstroport.types'
import * as _40 from './MarsSwapperAstroport.client'
import * as _41 from './MarsSwapperAstroport.react-query'
export namespace contracts {
export const MarsSwapperAstroport = { ..._39, ..._40, ..._41 }
}

View File

@ -0,0 +1,286 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 {
InstantiateMsg,
ExecuteMsg,
OwnerUpdate,
Uint128,
Decimal,
Addr,
Empty,
Coin,
QueryMsg,
EstimateExactInSwapResponse,
OwnerResponse,
RouteResponseForEmpty,
ArrayOfRouteResponseForEmpty,
} from './MarsSwapperBase.types'
export interface MarsSwapperBaseReadOnlyInterface {
contractAddress: string
owner: () => Promise<OwnerResponse>
route: ({
denomIn,
denomOut,
}: {
denomIn: string
denomOut: string
}) => Promise<RouteResponseForEmpty>
routes: ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string[][]
}) => Promise<ArrayOfRouteResponseForEmpty>
estimateExactInSwap: ({
coinIn,
denomOut,
}: {
coinIn: Coin
denomOut: string
}) => Promise<EstimateExactInSwapResponse>
}
export class MarsSwapperBaseQueryClient implements MarsSwapperBaseReadOnlyInterface {
client: CosmWasmClient
contractAddress: string
constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client
this.contractAddress = contractAddress
this.owner = this.owner.bind(this)
this.route = this.route.bind(this)
this.routes = this.routes.bind(this)
this.estimateExactInSwap = this.estimateExactInSwap.bind(this)
}
owner = async (): Promise<OwnerResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
owner: {},
})
}
route = async ({
denomIn,
denomOut,
}: {
denomIn: string
denomOut: string
}): Promise<RouteResponseForEmpty> => {
return this.client.queryContractSmart(this.contractAddress, {
route: {
denom_in: denomIn,
denom_out: denomOut,
},
})
}
routes = async ({
limit,
startAfter,
}: {
limit?: number
startAfter?: string[][]
}): Promise<ArrayOfRouteResponseForEmpty> => {
return this.client.queryContractSmart(this.contractAddress, {
routes: {
limit,
start_after: startAfter,
},
})
}
estimateExactInSwap = async ({
coinIn,
denomOut,
}: {
coinIn: Coin
denomOut: string
}): Promise<EstimateExactInSwapResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
estimate_exact_in_swap: {
coin_in: coinIn,
denom_out: denomOut,
},
})
}
}
export interface MarsSwapperBaseInterface extends MarsSwapperBaseReadOnlyInterface {
contractAddress: string
sender: string
updateOwner: (
ownerUpdate: OwnerUpdate,
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
setRoute: (
{
denomIn,
denomOut,
route,
}: {
denomIn: string
denomOut: string
route: Empty
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
swapExactIn: (
{
coinIn,
denomOut,
slippage,
}: {
coinIn: Coin
denomOut: string
slippage: Decimal
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
transferResult: (
{
denomIn,
denomOut,
recipient,
}: {
denomIn: string
denomOut: string
recipient: Addr
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[],
) => Promise<ExecuteResult>
}
export class MarsSwapperBaseClient
extends MarsSwapperBaseQueryClient
implements MarsSwapperBaseInterface
{
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.updateOwner = this.updateOwner.bind(this)
this.setRoute = this.setRoute.bind(this)
this.swapExactIn = this.swapExactIn.bind(this)
this.transferResult = this.transferResult.bind(this)
}
updateOwner = async (
ownerUpdate: OwnerUpdate,
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
update_owner: ownerUpdate,
},
fee,
memo,
_funds,
)
}
setRoute = async (
{
denomIn,
denomOut,
route,
}: {
denomIn: string
denomOut: string
route: Empty
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
set_route: {
denom_in: denomIn,
denom_out: denomOut,
route,
},
},
fee,
memo,
_funds,
)
}
swapExactIn = async (
{
coinIn,
denomOut,
slippage,
}: {
coinIn: Coin
denomOut: string
slippage: Decimal
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
swap_exact_in: {
coin_in: coinIn,
denom_out: denomOut,
slippage,
},
},
fee,
memo,
_funds,
)
}
transferResult = async (
{
denomIn,
denomOut,
recipient,
}: {
denomIn: string
denomOut: string
recipient: Addr
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[],
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
transfer_result: {
denom_in: denomIn,
denom_out: denomOut,
recipient,
},
},
fee,
memo,
_funds,
)
}
}

View File

@ -0,0 +1,235 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 {
InstantiateMsg,
ExecuteMsg,
OwnerUpdate,
Uint128,
Decimal,
Addr,
Empty,
Coin,
QueryMsg,
EstimateExactInSwapResponse,
OwnerResponse,
RouteResponseForEmpty,
ArrayOfRouteResponseForEmpty,
} from './MarsSwapperBase.types'
import { MarsSwapperBaseQueryClient, MarsSwapperBaseClient } from './MarsSwapperBase.client'
export const marsSwapperBaseQueryKeys = {
contract: [
{
contract: 'marsSwapperBase',
},
] as const,
address: (contractAddress: string | undefined) =>
[{ ...marsSwapperBaseQueryKeys.contract[0], address: contractAddress }] as const,
owner: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsSwapperBaseQueryKeys.address(contractAddress)[0], method: 'owner', args }] as const,
route: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsSwapperBaseQueryKeys.address(contractAddress)[0], method: 'route', args }] as const,
routes: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[{ ...marsSwapperBaseQueryKeys.address(contractAddress)[0], method: 'routes', args }] as const,
estimateExactInSwap: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
[
{
...marsSwapperBaseQueryKeys.address(contractAddress)[0],
method: 'estimate_exact_in_swap',
args,
},
] as const,
}
export interface MarsSwapperBaseReactQuery<TResponse, TData = TResponse> {
client: MarsSwapperBaseQueryClient | undefined
options?: Omit<
UseQueryOptions<TResponse, Error, TData>,
"'queryKey' | 'queryFn' | 'initialData'"
> & {
initialData?: undefined
}
}
export interface MarsSwapperBaseEstimateExactInSwapQuery<TData>
extends MarsSwapperBaseReactQuery<EstimateExactInSwapResponse, TData> {
args: {
coinIn: Coin
denomOut: string
}
}
export function useMarsSwapperBaseEstimateExactInSwapQuery<TData = EstimateExactInSwapResponse>({
client,
args,
options,
}: MarsSwapperBaseEstimateExactInSwapQuery<TData>) {
return useQuery<EstimateExactInSwapResponse, Error, TData>(
marsSwapperBaseQueryKeys.estimateExactInSwap(client?.contractAddress, args),
() =>
client
? client.estimateExactInSwap({
coinIn: args.coinIn,
denomOut: args.denomOut,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperBaseRoutesQuery<TData>
extends MarsSwapperBaseReactQuery<ArrayOfRouteResponseForEmpty, TData> {
args: {
limit?: number
startAfter?: string[][]
}
}
export function useMarsSwapperBaseRoutesQuery<TData = ArrayOfRouteResponseForEmpty>({
client,
args,
options,
}: MarsSwapperBaseRoutesQuery<TData>) {
return useQuery<ArrayOfRouteResponseForEmpty, Error, TData>(
marsSwapperBaseQueryKeys.routes(client?.contractAddress, args),
() =>
client
? client.routes({
limit: args.limit,
startAfter: args.startAfter,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperBaseRouteQuery<TData>
extends MarsSwapperBaseReactQuery<RouteResponseForEmpty, TData> {
args: {
denomIn: string
denomOut: string
}
}
export function useMarsSwapperBaseRouteQuery<TData = RouteResponseForEmpty>({
client,
args,
options,
}: MarsSwapperBaseRouteQuery<TData>) {
return useQuery<RouteResponseForEmpty, Error, TData>(
marsSwapperBaseQueryKeys.route(client?.contractAddress, args),
() =>
client
? client.route({
denomIn: args.denomIn,
denomOut: args.denomOut,
})
: Promise.reject(new Error('Invalid client')),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperBaseOwnerQuery<TData>
extends MarsSwapperBaseReactQuery<OwnerResponse, TData> {}
export function useMarsSwapperBaseOwnerQuery<TData = OwnerResponse>({
client,
options,
}: MarsSwapperBaseOwnerQuery<TData>) {
return useQuery<OwnerResponse, Error, TData>(
marsSwapperBaseQueryKeys.owner(client?.contractAddress),
() => (client ? client.owner() : Promise.reject(new Error('Invalid client'))),
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
)
}
export interface MarsSwapperBaseTransferResultMutation {
client: MarsSwapperBaseClient
msg: {
denomIn: string
denomOut: string
recipient: Addr
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperBaseTransferResultMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperBaseTransferResultMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperBaseTransferResultMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) =>
client.transferResult(msg, fee, memo, funds),
options,
)
}
export interface MarsSwapperBaseSwapExactInMutation {
client: MarsSwapperBaseClient
msg: {
coinIn: Coin
denomOut: string
slippage: Decimal
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperBaseSwapExactInMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperBaseSwapExactInMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperBaseSwapExactInMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.swapExactIn(msg, fee, memo, funds),
options,
)
}
export interface MarsSwapperBaseSetRouteMutation {
client: MarsSwapperBaseClient
msg: {
denomIn: string
denomOut: string
route: Empty
}
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperBaseSetRouteMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperBaseSetRouteMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperBaseSetRouteMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.setRoute(msg, fee, memo, funds),
options,
)
}
export interface MarsSwapperBaseUpdateOwnerMutation {
client: MarsSwapperBaseClient
msg: OwnerUpdate
args?: {
fee?: number | StdFee | 'auto'
memo?: string
funds?: Coin[]
}
}
export function useMarsSwapperBaseUpdateOwnerMutation(
options?: Omit<
UseMutationOptions<ExecuteResult, Error, MarsSwapperBaseUpdateOwnerMutation>,
'mutationFn'
>,
) {
return useMutation<ExecuteResult, Error, MarsSwapperBaseUpdateOwnerMutation>(
({ client, msg, args: { fee, memo, funds } = {} }) => client.updateOwner(msg, fee, memo, funds),
options,
)
}

View File

@ -0,0 +1,99 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 interface InstantiateMsg {
owner: string
}
export type ExecuteMsg =
| {
update_owner: OwnerUpdate
}
| {
set_route: {
denom_in: string
denom_out: string
route: Empty
}
}
| {
swap_exact_in: {
coin_in: Coin
denom_out: string
slippage: Decimal
}
}
| {
transfer_result: {
denom_in: string
denom_out: string
recipient: Addr
}
}
export type OwnerUpdate =
| {
propose_new_owner: {
proposed: string
}
}
| 'clear_proposed'
| 'accept_proposed'
| 'abolish_owner_role'
| {
set_emergency_owner: {
emergency_owner: string
}
}
| 'clear_emergency_owner'
export type Uint128 = string
export type Decimal = string
export type Addr = string
export interface Empty {
[k: string]: unknown
}
export interface Coin {
amount: Uint128
denom: string
[k: string]: unknown
}
export type QueryMsg =
| {
owner: {}
}
| {
route: {
denom_in: string
denom_out: string
}
}
| {
routes: {
limit?: number | null
start_after?: [string, string] | null
}
}
| {
estimate_exact_in_swap: {
coin_in: Coin
denom_out: string
}
}
export interface EstimateExactInSwapResponse {
amount: Uint128
}
export interface OwnerResponse {
abolished: boolean
emergency_owner?: string | null
initialized: boolean
owner?: string | null
proposed?: string | null
}
export interface RouteResponseForEmpty {
denom_in: string
denom_out: string
route: Empty
}
export type ArrayOfRouteResponseForEmpty = RouteResponseForEmpty[]

View File

@ -0,0 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _42 from './MarsSwapperBase.types'
import * as _43 from './MarsSwapperBase.client'
import * as _44 from './MarsSwapperBase.react-query'
export namespace contracts {
export const MarsSwapperBase = { ..._42, ..._43, ..._44 }
}

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
@ -55,7 +55,6 @@ export type Addr = string
export interface SwapAmountInRoute {
pool_id: number
token_out_denom: string
[k: string]: unknown
}
export interface Coin {
amount: Uint128

View File

@ -1,13 +1,13 @@
// @ts-nocheck
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.30.1.
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* 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 _21 from './MarsSwapperOsmosis.types'
import * as _22 from './MarsSwapperOsmosis.client'
import * as _23 from './MarsSwapperOsmosis.react-query'
import * as _45 from './MarsSwapperOsmosis.types'
import * as _46 from './MarsSwapperOsmosis.client'
import * as _47 from './MarsSwapperOsmosis.react-query'
export namespace contracts {
export const MarsSwapperOsmosis = { ..._21, ..._22, ..._23 }
export const MarsSwapperOsmosis = { ..._45, ..._46, ..._47 }
}

View File

@ -4,6 +4,7 @@ interface Account extends AccountChange {
debts: BNCoin[]
lends: BNCoin[]
vaults: DepositedVault[]
perps: PerpPosition[]
kind: AccountKind
}

View File

@ -1,6 +1,7 @@
interface Asset extends AssetMetaData {
denom: string
poolId?: number
isPerpsEnabled?: boolean
}
interface AssetMetaData {

View File

@ -9,7 +9,7 @@ interface ChainConfig {
params: string
creditManager: string
accountNft: string
perps?: string
perps: string
pyth: string
}
defaultCurrency: {
@ -48,3 +48,14 @@ interface ChainConfig {
perps: boolean
farm: boolean
}
interface ContractClients {
accountNft: import('types/generated/mars-account-nft/MarsAccountNft.client').MarsAccountNftQueryClient
creditManager: import('types/generated/mars-credit-manager/MarsCreditManager.client').MarsCreditManagerQueryClient
incentives: import('types/generated/mars-incentives/MarsIncentives.client').MarsIncentivesQueryClient
oracle: import('types/generated/mars-oracle-osmosis/MarsOracleOsmosis.client').MarsOracleOsmosisQueryClient
params: import('types/generated/mars-params/MarsParams.client').MarsParamsQueryClient
perps: import('types/generated/mars-perps/MarsPerps.client').MarsPerpsQueryClient
redBank: import('types/generated/mars-red-bank/MarsRedBank.client').MarsRedBankQueryClient
swapper: import('types/generated/mars-swapper-osmosis/MarsSwapperOsmosis.client').MarsSwapperOsmosisQueryClient
}

View File

@ -18,7 +18,6 @@ interface ToastObjectOptions extends HandleResponseProps {
interface ToastObject {
response: Promise<BroadcastResult>
options: ToastObjectOptions
swapOptions?: {
coinIn: BNCoin
denomOut: string

View File

@ -4,6 +4,7 @@ interface Settings {
reduceMotion: boolean
tradingPairSimple: TradingPair
tradingPairAdvanced: TradingPair
perpsAsset: string
enableAutoLendGlobal: boolean
slippage: number
tutorial: boolean

View File

@ -185,6 +185,8 @@ export function convertAccountToPositions(account: Account): Positions {
amount: lend.amount.toString(),
denom: lend.denom,
})),
// TODO: 📈 Add correct type mapping
perps: account.perps,
vaults: account.vaults.map(
(vault) =>
({
@ -242,6 +244,8 @@ export function cloneAccount(account: Account): Account {
unlocked: vault.values.unlocked,
},
})),
// TODO: 📈Add correct type mapping
perps: account.perps,
}
}