[HC] update wasm files and types (#360)
This commit is contained in:
parent
1af857fcb0
commit
2d6ef1a4a0
@ -85,19 +85,7 @@ export default function useHealthComputer(account?: Account) {
|
||||
() =>
|
||||
assetParams.reduce(
|
||||
(prev, curr) => {
|
||||
const params: AssetParamsBaseForAddr = {
|
||||
...curr,
|
||||
// The following overrides are required as testnet is 'broken' and new contracts are not updated yet
|
||||
// These overrides are not used by the healthcomputer internally, so they're not important anyways.
|
||||
protocol_liquidation_fee: '1',
|
||||
liquidation_bonus: {
|
||||
max_lb: '1',
|
||||
min_lb: '1',
|
||||
slope: '1',
|
||||
starting_lb: '1',
|
||||
},
|
||||
}
|
||||
prev[params.denom] = params
|
||||
prev[curr.denom] = curr
|
||||
|
||||
return prev
|
||||
},
|
||||
@ -144,12 +132,8 @@ export default function useHealthComputer(account?: Account) {
|
||||
}, [priceData, denomsData, vaultConfigsData, vaultPositionValues, positions])
|
||||
|
||||
useEffect(() => {
|
||||
async function computeHealthWasm() {
|
||||
if (!healthComputer) return
|
||||
setHealth(Number((await compute_health_js(healthComputer)).max_ltv_health_factor) || 0)
|
||||
}
|
||||
// TODO: Health computer throwing error. Should be aligned with new contracts: https://delphilabs.atlassian.net/browse/MP-3238
|
||||
// computeHealthWasm()
|
||||
if (!healthComputer) return
|
||||
setHealth(Number(compute_health_js(healthComputer).max_ltv_health_factor) || 0)
|
||||
}, [healthComputer])
|
||||
|
||||
const computeMaxBorrowAmount = useCallback(
|
||||
|
@ -0,0 +1,175 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
|
||||
*/
|
||||
|
||||
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate'
|
||||
import { Coin, StdFee } from '@cosmjs/amino'
|
||||
import {
|
||||
InstantiateMsg,
|
||||
ExecuteMsg,
|
||||
OwnerUpdate,
|
||||
QueryMsg,
|
||||
ActionKind,
|
||||
AccountKind,
|
||||
ConfigResponse,
|
||||
OwnerResponse,
|
||||
HealthState,
|
||||
Decimal,
|
||||
Uint128,
|
||||
HealthValuesResponse,
|
||||
} from './MarsRoverHealthTypes.types'
|
||||
export interface MarsRoverHealthTypesReadOnlyInterface {
|
||||
contractAddress: string
|
||||
healthValues: ({
|
||||
accountId,
|
||||
action,
|
||||
kind,
|
||||
}: {
|
||||
accountId: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}) => Promise<HealthValuesResponse>
|
||||
healthState: ({
|
||||
accountId,
|
||||
action,
|
||||
kind,
|
||||
}: {
|
||||
accountId: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}) => Promise<HealthState>
|
||||
config: () => Promise<ConfigResponse>
|
||||
}
|
||||
export class MarsRoverHealthTypesQueryClient implements MarsRoverHealthTypesReadOnlyInterface {
|
||||
client: CosmWasmClient
|
||||
contractAddress: string
|
||||
|
||||
constructor(client: CosmWasmClient, contractAddress: string) {
|
||||
this.client = client
|
||||
this.contractAddress = contractAddress
|
||||
this.healthValues = this.healthValues.bind(this)
|
||||
this.healthState = this.healthState.bind(this)
|
||||
this.config = this.config.bind(this)
|
||||
}
|
||||
|
||||
healthValues = async ({
|
||||
accountId,
|
||||
action,
|
||||
kind,
|
||||
}: {
|
||||
accountId: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}): Promise<HealthValuesResponse> => {
|
||||
return this.client.queryContractSmart(this.contractAddress, {
|
||||
health_values: {
|
||||
account_id: accountId,
|
||||
action,
|
||||
kind,
|
||||
},
|
||||
})
|
||||
}
|
||||
healthState = async ({
|
||||
accountId,
|
||||
action,
|
||||
kind,
|
||||
}: {
|
||||
accountId: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}): Promise<HealthState> => {
|
||||
return this.client.queryContractSmart(this.contractAddress, {
|
||||
health_state: {
|
||||
account_id: accountId,
|
||||
action,
|
||||
kind,
|
||||
},
|
||||
})
|
||||
}
|
||||
config = async (): Promise<ConfigResponse> => {
|
||||
return this.client.queryContractSmart(this.contractAddress, {
|
||||
config: {},
|
||||
})
|
||||
}
|
||||
}
|
||||
export interface MarsRoverHealthTypesInterface extends MarsRoverHealthTypesReadOnlyInterface {
|
||||
contractAddress: string
|
||||
sender: string
|
||||
updateOwner: (
|
||||
ownerUpdate: OwnerUpdate,
|
||||
fee?: number | StdFee | 'auto',
|
||||
memo?: string,
|
||||
_funds?: Coin[],
|
||||
) => Promise<ExecuteResult>
|
||||
updateConfig: (
|
||||
{
|
||||
creditManager,
|
||||
}: {
|
||||
creditManager: string
|
||||
},
|
||||
fee?: number | StdFee | 'auto',
|
||||
memo?: string,
|
||||
_funds?: Coin[],
|
||||
) => Promise<ExecuteResult>
|
||||
}
|
||||
export class MarsRoverHealthTypesClient
|
||||
extends MarsRoverHealthTypesQueryClient
|
||||
implements MarsRoverHealthTypesInterface
|
||||
{
|
||||
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.updateConfig = this.updateConfig.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,
|
||||
)
|
||||
}
|
||||
updateConfig = async (
|
||||
{
|
||||
creditManager,
|
||||
}: {
|
||||
creditManager: string
|
||||
},
|
||||
fee: number | StdFee | 'auto' = 'auto',
|
||||
memo?: string,
|
||||
_funds?: Coin[],
|
||||
): Promise<ExecuteResult> => {
|
||||
return await this.client.execute(
|
||||
this.sender,
|
||||
this.contractAddress,
|
||||
{
|
||||
update_config: {
|
||||
credit_manager: creditManager,
|
||||
},
|
||||
},
|
||||
fee,
|
||||
memo,
|
||||
_funds,
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
|
||||
*/
|
||||
|
||||
import { Coin } from '@cosmjs/amino'
|
||||
import { MsgExecuteContractEncodeObject } from '@cosmjs/cosmwasm-stargate'
|
||||
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx'
|
||||
import { toUtf8 } from '@cosmjs/encoding'
|
||||
import {
|
||||
InstantiateMsg,
|
||||
ExecuteMsg,
|
||||
OwnerUpdate,
|
||||
QueryMsg,
|
||||
ActionKind,
|
||||
AccountKind,
|
||||
ConfigResponse,
|
||||
OwnerResponse,
|
||||
HealthState,
|
||||
Decimal,
|
||||
Uint128,
|
||||
HealthValuesResponse,
|
||||
} from './MarsRoverHealthTypes.types'
|
||||
export interface MarsRoverHealthTypesMessage {
|
||||
contractAddress: string
|
||||
sender: string
|
||||
updateOwner: (ownerUpdate: OwnerUpdate, _funds?: Coin[]) => MsgExecuteContractEncodeObject
|
||||
updateConfig: (
|
||||
{
|
||||
creditManager,
|
||||
}: {
|
||||
creditManager: string
|
||||
},
|
||||
_funds?: Coin[],
|
||||
) => MsgExecuteContractEncodeObject
|
||||
}
|
||||
export class MarsRoverHealthTypesMessageComposer implements MarsRoverHealthTypesMessage {
|
||||
sender: string
|
||||
contractAddress: string
|
||||
|
||||
constructor(sender: string, contractAddress: string) {
|
||||
this.sender = sender
|
||||
this.contractAddress = contractAddress
|
||||
this.updateOwner = this.updateOwner.bind(this)
|
||||
this.updateConfig = this.updateConfig.bind(this)
|
||||
}
|
||||
|
||||
updateOwner = (ownerUpdate: OwnerUpdate, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
|
||||
return {
|
||||
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
|
||||
value: MsgExecuteContract.fromPartial({
|
||||
sender: this.sender,
|
||||
contract: this.contractAddress,
|
||||
msg: toUtf8(
|
||||
JSON.stringify({
|
||||
update_owner: ownerUpdate,
|
||||
}),
|
||||
),
|
||||
funds: _funds,
|
||||
}),
|
||||
}
|
||||
}
|
||||
updateConfig = (
|
||||
{
|
||||
creditManager,
|
||||
}: {
|
||||
creditManager: string
|
||||
},
|
||||
_funds?: Coin[],
|
||||
): MsgExecuteContractEncodeObject => {
|
||||
return {
|
||||
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
|
||||
value: MsgExecuteContract.fromPartial({
|
||||
sender: this.sender,
|
||||
contract: this.contractAddress,
|
||||
msg: toUtf8(
|
||||
JSON.stringify({
|
||||
update_config: {
|
||||
credit_manager: creditManager,
|
||||
},
|
||||
}),
|
||||
),
|
||||
funds: _funds,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
|
||||
*/
|
||||
|
||||
import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query'
|
||||
import { ExecuteResult } from '@cosmjs/cosmwasm-stargate'
|
||||
import { StdFee, Coin } from '@cosmjs/amino'
|
||||
import {
|
||||
InstantiateMsg,
|
||||
ExecuteMsg,
|
||||
OwnerUpdate,
|
||||
QueryMsg,
|
||||
ActionKind,
|
||||
AccountKind,
|
||||
ConfigResponse,
|
||||
OwnerResponse,
|
||||
HealthState,
|
||||
Decimal,
|
||||
Uint128,
|
||||
HealthValuesResponse,
|
||||
} from './MarsRoverHealthTypes.types'
|
||||
import {
|
||||
MarsRoverHealthTypesQueryClient,
|
||||
MarsRoverHealthTypesClient,
|
||||
} from './MarsRoverHealthTypes.client'
|
||||
export const marsRoverHealthTypesQueryKeys = {
|
||||
contract: [
|
||||
{
|
||||
contract: 'marsRoverHealthTypes',
|
||||
},
|
||||
] as const,
|
||||
address: (contractAddress: string | undefined) =>
|
||||
[{ ...marsRoverHealthTypesQueryKeys.contract[0], address: contractAddress }] as const,
|
||||
healthValues: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
|
||||
[
|
||||
{
|
||||
...marsRoverHealthTypesQueryKeys.address(contractAddress)[0],
|
||||
method: 'health_values',
|
||||
args,
|
||||
},
|
||||
] as const,
|
||||
healthState: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
|
||||
[
|
||||
{
|
||||
...marsRoverHealthTypesQueryKeys.address(contractAddress)[0],
|
||||
method: 'health_state',
|
||||
args,
|
||||
},
|
||||
] as const,
|
||||
config: (contractAddress: string | undefined, args?: Record<string, unknown>) =>
|
||||
[
|
||||
{ ...marsRoverHealthTypesQueryKeys.address(contractAddress)[0], method: 'config', args },
|
||||
] as const,
|
||||
}
|
||||
export interface MarsRoverHealthTypesReactQuery<TResponse, TData = TResponse> {
|
||||
client: MarsRoverHealthTypesQueryClient | undefined
|
||||
options?: Omit<
|
||||
UseQueryOptions<TResponse, Error, TData>,
|
||||
"'queryKey' | 'queryFn' | 'initialData'"
|
||||
> & {
|
||||
initialData?: undefined
|
||||
}
|
||||
}
|
||||
export interface MarsRoverHealthTypesConfigQuery<TData>
|
||||
extends MarsRoverHealthTypesReactQuery<ConfigResponse, TData> {}
|
||||
export function useMarsRoverHealthTypesConfigQuery<TData = ConfigResponse>({
|
||||
client,
|
||||
options,
|
||||
}: MarsRoverHealthTypesConfigQuery<TData>) {
|
||||
return useQuery<ConfigResponse, Error, TData>(
|
||||
marsRoverHealthTypesQueryKeys.config(client?.contractAddress),
|
||||
() => (client ? client.config() : Promise.reject(new Error('Invalid client'))),
|
||||
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
|
||||
)
|
||||
}
|
||||
export interface MarsRoverHealthTypesHealthStateQuery<TData>
|
||||
extends MarsRoverHealthTypesReactQuery<HealthState, TData> {
|
||||
args: {
|
||||
accountId: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}
|
||||
}
|
||||
export function useMarsRoverHealthTypesHealthStateQuery<TData = HealthState>({
|
||||
client,
|
||||
args,
|
||||
options,
|
||||
}: MarsRoverHealthTypesHealthStateQuery<TData>) {
|
||||
return useQuery<HealthState, Error, TData>(
|
||||
marsRoverHealthTypesQueryKeys.healthState(client?.contractAddress, args),
|
||||
() =>
|
||||
client
|
||||
? client.healthState({
|
||||
accountId: args.accountId,
|
||||
action: args.action,
|
||||
kind: args.kind,
|
||||
})
|
||||
: Promise.reject(new Error('Invalid client')),
|
||||
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
|
||||
)
|
||||
}
|
||||
export interface MarsRoverHealthTypesHealthValuesQuery<TData>
|
||||
extends MarsRoverHealthTypesReactQuery<HealthValuesResponse, TData> {
|
||||
args: {
|
||||
accountId: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}
|
||||
}
|
||||
export function useMarsRoverHealthTypesHealthValuesQuery<TData = HealthValuesResponse>({
|
||||
client,
|
||||
args,
|
||||
options,
|
||||
}: MarsRoverHealthTypesHealthValuesQuery<TData>) {
|
||||
return useQuery<HealthValuesResponse, Error, TData>(
|
||||
marsRoverHealthTypesQueryKeys.healthValues(client?.contractAddress, args),
|
||||
() =>
|
||||
client
|
||||
? client.healthValues({
|
||||
accountId: args.accountId,
|
||||
action: args.action,
|
||||
kind: args.kind,
|
||||
})
|
||||
: Promise.reject(new Error('Invalid client')),
|
||||
{ ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
|
||||
)
|
||||
}
|
||||
export interface MarsRoverHealthTypesUpdateConfigMutation {
|
||||
client: MarsRoverHealthTypesClient
|
||||
msg: {
|
||||
creditManager: string
|
||||
}
|
||||
args?: {
|
||||
fee?: number | StdFee | 'auto'
|
||||
memo?: string
|
||||
funds?: Coin[]
|
||||
}
|
||||
}
|
||||
export function useMarsRoverHealthTypesUpdateConfigMutation(
|
||||
options?: Omit<
|
||||
UseMutationOptions<ExecuteResult, Error, MarsRoverHealthTypesUpdateConfigMutation>,
|
||||
'mutationFn'
|
||||
>,
|
||||
) {
|
||||
return useMutation<ExecuteResult, Error, MarsRoverHealthTypesUpdateConfigMutation>(
|
||||
({ client, msg, args: { fee, memo, funds } = {} }) =>
|
||||
client.updateConfig(msg, fee, memo, funds),
|
||||
options,
|
||||
)
|
||||
}
|
||||
export interface MarsRoverHealthTypesUpdateOwnerMutation {
|
||||
client: MarsRoverHealthTypesClient
|
||||
msg: OwnerUpdate
|
||||
args?: {
|
||||
fee?: number | StdFee | 'auto'
|
||||
memo?: string
|
||||
funds?: Coin[]
|
||||
}
|
||||
}
|
||||
export function useMarsRoverHealthTypesUpdateOwnerMutation(
|
||||
options?: Omit<
|
||||
UseMutationOptions<ExecuteResult, Error, MarsRoverHealthTypesUpdateOwnerMutation>,
|
||||
'mutationFn'
|
||||
>,
|
||||
) {
|
||||
return useMutation<ExecuteResult, Error, MarsRoverHealthTypesUpdateOwnerMutation>(
|
||||
({ client, msg, args: { fee, memo, funds } = {} }) => client.updateOwner(msg, fee, memo, funds),
|
||||
options,
|
||||
)
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
|
||||
*/
|
||||
|
||||
export interface InstantiateMsg {
|
||||
owner: string
|
||||
}
|
||||
export type ExecuteMsg =
|
||||
| {
|
||||
update_owner: OwnerUpdate
|
||||
}
|
||||
| {
|
||||
update_config: {
|
||||
credit_manager: 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 QueryMsg =
|
||||
| {
|
||||
health_values: {
|
||||
account_id: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}
|
||||
}
|
||||
| {
|
||||
health_state: {
|
||||
account_id: string
|
||||
action: ActionKind
|
||||
kind: AccountKind
|
||||
}
|
||||
}
|
||||
| {
|
||||
config: {}
|
||||
}
|
||||
export type ActionKind = 'default' | 'liquidation'
|
||||
export type AccountKind = 'default' | 'high_levered_strategy'
|
||||
export interface ConfigResponse {
|
||||
credit_manager?: string | null
|
||||
owner_response: OwnerResponse
|
||||
}
|
||||
export interface OwnerResponse {
|
||||
abolished: boolean
|
||||
emergency_owner?: string | null
|
||||
initialized: boolean
|
||||
owner?: string | null
|
||||
proposed?: string | null
|
||||
}
|
||||
export type HealthState =
|
||||
| 'healthy'
|
||||
| {
|
||||
unhealthy: {
|
||||
max_ltv_health_factor: Decimal
|
||||
}
|
||||
}
|
||||
export type Decimal = string
|
||||
export type Uint128 = string
|
||||
export interface HealthValuesResponse {
|
||||
above_max_ltv: boolean
|
||||
liquidatable: boolean
|
||||
liquidation_health_factor?: Decimal | null
|
||||
liquidation_threshold_adjusted_collateral: Uint128
|
||||
max_ltv_adjusted_collateral: Uint128
|
||||
max_ltv_health_factor?: Decimal | null
|
||||
total_collateral_value: Uint128
|
||||
total_debt_value: Uint128
|
||||
}
|
14
src/types/generated/mars-rover-health-types/bundle.ts
Normal file
14
src/types/generated/mars-rover-health-types/bundle.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
|
||||
*/
|
||||
|
||||
import * as _36 from './MarsRoverHealthTypes.types'
|
||||
import * as _37 from './MarsRoverHealthTypes.client'
|
||||
import * as _38 from './MarsRoverHealthTypes.message-composer'
|
||||
import * as _39 from './MarsRoverHealthTypes.react-query'
|
||||
export namespace contracts {
|
||||
export const MarsRoverHealthTypes = { ..._36, ..._37, ..._38, ..._39 }
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user