diff --git a/src/components/Account/AccountBalancesTable.tsx b/src/components/Account/AccountBalancesTable.tsx index 8f36e039..fee8e7fe 100644 --- a/src/components/Account/AccountBalancesTable.tsx +++ b/src/components/Account/AccountBalancesTable.tsx @@ -117,7 +117,7 @@ export default function AccountBalancesTable(props: Props) { denom: row.original.denom, amount: row.original.amount.toString(), }) - return + return }, }, { @@ -131,7 +131,7 @@ export default function AccountBalancesTable(props: Props) { ) return ( - + {header.column.getCanSort() ? { asc: , diff --git a/src/components/Modals/BorrowModal.tsx b/src/components/Modals/BorrowModal.tsx index 74073973..9dcf8cc7 100644 --- a/src/components/Modals/BorrowModal.tsx +++ b/src/components/Modals/BorrowModal.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react' +import BigNumber from 'bignumber.js' import AccountSummary from 'components/Account/AccountSummary' import AssetImage from 'components/AssetImage' @@ -20,7 +21,6 @@ import { hardcodedFee } from 'utils/constants' import { formatPercent, formatValue } from 'utils/formatters' import { BN } from 'utils/helpers' import useHealthComputer from 'hooks/useHealthComputer' -import { BorrowTarget } from 'types/enums/borrowTarget' import { BN_ZERO } from 'constants/math' function getDebtAmount(modal: BorrowModal | null) { @@ -112,12 +112,12 @@ function BorrowModal(props: Props) { return } - computeMaxBorrowAmount( + const maxBorrowAmount = computeMaxBorrowAmount( asset.denom, - borrowToWallet ? BorrowTarget.Wallet : BorrowTarget.Deposit, - ).then((maxBorrowAmount) => { - setMax(BN(Math.min(maxBorrowAmount, modal?.marketData?.liquidity?.amount.toNumber() || 0))) - }) + borrowToWallet ? 'wallet' : 'deposit', + ) + + setMax(BigNumber.min(maxBorrowAmount, modal?.marketData?.liquidity?.amount || 0)) }, [isRepay, modal, asset.denom, computeMaxBorrowAmount, borrowToWallet]) useEffect(() => { diff --git a/src/components/Trade/TradeModule/SwapForm/index.tsx b/src/components/Trade/TradeModule/SwapForm/index.tsx index b4a2c900..2ae88627 100644 --- a/src/components/Trade/TradeModule/SwapForm/index.tsx +++ b/src/components/Trade/TradeModule/SwapForm/index.tsx @@ -19,6 +19,7 @@ import { AvailableOrderType } from 'components/Trade/TradeModule/SwapForm/OrderT import TradeSummary from 'components/Trade/TradeModule/SwapForm/TradeSummary' import { BNCoin } from 'types/classes/BNCoin' import estimateExactIn from 'api/swap/estimateExactIn' +import useHealthComputer from 'hooks/useHealthComputer' interface Props { buyAsset: Asset @@ -31,6 +32,7 @@ export default function SwapForm(props: Props) { const { data: prices } = usePrices() const swap = useStore((s) => s.swap) const [slippage] = useLocalStorage(SLIPPAGE_KEY, DEFAULT_SETTINGS.slippage) + const { computeMaxSwapAmount } = useHealthComputer(account) const [isMarginChecked, setMarginChecked] = useState(false) const [buyAssetAmount, setBuyAssetAmount] = useState(BN_ZERO) @@ -40,9 +42,9 @@ export default function SwapForm(props: Props) { const [selectedOrderType, setSelectedOrderType] = useState('Market') const [isTransactionExecuting, setTransactionExecuting] = useState(false) - const accountSellAssetDeposit = useMemo( - () => account?.deposits.find(byDenom(sellAsset.denom))?.amount || BN_ZERO, - [account, sellAsset.denom], + const maxSellAssetAmount = useMemo( + () => computeMaxSwapAmount(sellAsset.denom, buyAsset.denom, 'default'), + [computeMaxSwapAmount, sellAsset.denom, buyAsset.denom], ) const [buyAssetValue, sellAssetValue] = useMemo(() => { @@ -71,10 +73,10 @@ export default function SwapForm(props: Props) { useEffect(() => { estimateExactIn( - { denom: sellAsset.denom, amount: accountSellAssetDeposit }, + { denom: sellAsset.denom, amount: maxSellAssetAmount.toString() }, buyAsset.denom, ).then(setMaxBuyableAmountEstimation) - }, [accountSellAssetDeposit, buyAsset.denom, sellAsset.denom]) + }, [maxSellAssetAmount, buyAsset.denom, sellAsset.denom]) useEffect(() => { if (focusedInput === 'sell') { @@ -149,15 +151,15 @@ export default function SwapForm(props: Props) { s.baseCurrency) const [health, setHealth] = useState(0) - const positions = useMemo(() => convertAccountToPositions(account), [account]) + const positions: Positions | null = useMemo(() => { + if (!account) return null + return convertAccountToPositions(account) + }, [account]) const baseCurrencyPrice = useMemo( () => prices.find((price) => price.denom === baseCurrency.denom)?.amount || 0, [prices, baseCurrency.denom], ) - const vaultPositionValues = useMemo( - () => - account.vaults.reduce((prev, curr) => { - const baseCoinPrice = prices.find((price) => price.denom === curr.denoms.lp)?.amount || 0 - prev[curr.address] = { - base_coin: { - amount: '0', // Not used by healthcomputer - denom: curr.denoms.lp, - value: curr.amounts.unlocking.times(baseCoinPrice).integerValue().toString(), - }, - vault_coin: { - amount: '0', // Not used by healthcomputer - denom: curr.denoms.vault, - value: curr.values.primary - .div(baseCurrencyPrice) - .plus(curr.values.secondary.div(baseCurrencyPrice)) - .integerValue() - .toString(), - }, - } - return prev - }, {} as { [key: string]: VaultPositionValue }), - [account.vaults, prices, baseCurrencyPrice], - ) + const vaultPositionValues = useMemo(() => { + if (!account?.vaults) return null + return account.vaults.reduce((prev, curr) => { + const baseCoinPrice = prices.find((price) => price.denom === curr.denoms.lp)?.amount || 0 + prev[curr.address] = { + base_coin: { + amount: '0', // Not used by healthcomputer + denom: curr.denoms.lp, + value: curr.amounts.unlocking.times(baseCoinPrice).integerValue().toString(), + }, + vault_coin: { + amount: '0', // Not used by healthcomputer + denom: curr.denoms.vault, + value: curr.values.primary + .div(baseCurrencyPrice) + .plus(curr.values.secondary.div(baseCurrencyPrice)) + .integerValue() + .toString(), + }, + } + return prev + }, {} as { [key: string]: VaultPositionValue }) + }, [account?.vaults, prices, baseCurrencyPrice]) const priceData = useMemo(() => { const baseCurrencyPrice = @@ -132,27 +141,31 @@ export default function useHealthComputer(account: Account) { const computeMaxBorrowAmount = useCallback( (denom: string, target: BorrowTarget) => { - async function callMaxBorrowWasmFn(denom: string): Promise { - if (!healthComputer) return 0 - return await max_borrow_estimate_js(healthComputer, denom, target) - } - - return callMaxBorrowWasmFn(denom) + if (!healthComputer) return BN_ZERO + return BN(max_borrow_estimate_js(healthComputer, denom, target)) }, [healthComputer], ) const computeMaxWithdrawAmount = useCallback( (denom: string) => { - async function callMaxWithdrawWasmFn(denom: string): Promise { - if (!healthComputer) return 0 - return await max_withdraw_estimate_js(healthComputer, denom) - } - - return callMaxWithdrawWasmFn(denom) + if (!healthComputer) return BN_ZERO + return BN(max_withdraw_estimate_js(healthComputer, denom)) }, [healthComputer], ) - return { health, computeMaxBorrowAmount, computeMaxWithdrawAmount } + const computeMaxSwapAmount = useCallback( + (from: string, to: string, kind: SwapKind) => { + if (!healthComputer) return BN_ZERO + try { + return BN(max_swap_estimate_js(healthComputer, from, to, kind)) + } catch { + return BN_ZERO + } + }, + [healthComputer], + ) + + return { health, computeMaxBorrowAmount, computeMaxWithdrawAmount, computeMaxSwapAmount } } diff --git a/src/types/enums/borrowTarget.ts b/src/types/enums/borrowTarget.ts deleted file mode 100644 index 4e1b74f9..00000000 --- a/src/types/enums/borrowTarget.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum BorrowTarget { - Deposit = 'deposit', - Wallet = 'wallet', -} diff --git a/src/utils/health_computer/index.d.ts b/src/utils/health_computer/index.d.ts index ff9825e7..7ed56334 100644 --- a/src/utils/health_computer/index.d.ts +++ b/src/utils/health_computer/index.d.ts @@ -1,31 +1,78 @@ /* tslint:disable */ /* eslint-disable */ /** - * @param {any} health_computer - * @returns {any} + * @param {HealthComputer} c + * @returns {HealthValuesResponse} */ -export function compute_health_js(health_computer: any): any +export function compute_health_js(c: HealthComputer): HealthValuesResponse /** - * @param {any} health_computer - * @param {any} withdraw_denom - * @returns {any} + * @param {HealthComputer} c + * @param {string} withdraw_denom + * @returns {string} */ -export function max_withdraw_estimate_js(health_computer: any, withdraw_denom: any): any +export function max_withdraw_estimate_js(c: HealthComputer, withdraw_denom: string): string /** - * @param {any} health_computer - * @param {any} borrow_denom - * @param {any} target - * @returns {any} + * @param {HealthComputer} c + * @param {string} borrow_denom + * @param {BorrowTarget} target + * @returns {string} */ -export function max_borrow_estimate_js(health_computer: any, borrow_denom: any, target: any): any +export function max_borrow_estimate_js( + c: HealthComputer, + borrow_denom: string, + target: BorrowTarget, +): string +/** + * @param {HealthComputer} c + * @param {string} from_denom + * @param {string} to_denom + * @param {SwapKind} kind + * @returns {string} + */ +export function max_swap_estimate_js( + c: HealthComputer, + from_denom: string, + to_denom: string, + kind: SwapKind, +): string +export interface HealthComputer { + kind: AccountKind + positions: Positions + denoms_data: DenomsData + vaults_data: VaultsData +} + +export interface HealthValuesResponse { + total_debt_value: Uint128 + total_collateral_value: Uint128 + max_ltv_adjusted_collateral: Uint128 + liquidation_threshold_adjusted_collateral: Uint128 + max_ltv_health_factor: Decimal | null + liquidation_health_factor: Decimal | null + liquidatable: boolean + above_max_ltv: boolean +} + +export type SwapKind = 'default' | 'margin' + +export type BorrowTarget = 'deposit' | 'wallet' | { vault: { address: Addr } } export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module export interface InitOutput { readonly memory: WebAssembly.Memory readonly compute_health_js: (a: number) => number - readonly max_withdraw_estimate_js: (a: number, b: number) => number - readonly max_borrow_estimate_js: (a: number, b: number, c: number) => number + readonly max_withdraw_estimate_js: (a: number, b: number, c: number, d: number) => void + readonly max_borrow_estimate_js: (a: number, b: number, c: number, d: number, e: number) => void + readonly max_swap_estimate_js: ( + a: number, + b: number, + c: number, + d: number, + e: number, + f: number, + g: number, + ) => void readonly allocate: (a: number) => number readonly deallocate: (a: number) => void readonly requires_stargate: () => void @@ -33,6 +80,7 @@ export interface InitOutput { readonly interface_version_8: () => void readonly __wbindgen_malloc: (a: number, b: number) => number readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number + readonly __wbindgen_add_to_stack_pointer: (a: number) => number readonly __wbindgen_free: (a: number, b: number, c: number) => void readonly __wbindgen_exn_store: (a: number) => void } diff --git a/src/utils/health_computer/index.js b/src/utils/health_computer/index.js index 39ba4919..07bd035f 100644 --- a/src/utils/health_computer/index.js +++ b/src/utils/health_computer/index.js @@ -10,6 +10,15 @@ function getObject(idx) { let heap_next = heap.length +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1) + const idx = heap_next + heap_next = heap[idx] + + heap[idx] = obj + return idx +} + function dropObject(idx) { if (idx < 132) return heap[idx] = heap_next @@ -125,133 +134,90 @@ function getStringFromWasm0(ptr, len) { ptr = ptr >>> 0 return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)) } - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1) - const idx = heap_next - heap_next = heap[idx] - - heap[idx] = obj - return idx -} - -let cachedFloat64Memory0 = null - -function getFloat64Memory0() { - if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { - cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer) - } - return cachedFloat64Memory0 -} - -let cachedBigInt64Memory0 = null - -function getBigInt64Memory0() { - if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) { - cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer) - } - return cachedBigInt64Memory0 -} - -function debugString(val) { - // primitive types - const type = typeof val - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}` - } - if (type == 'string') { - return `"${val}"` - } - if (type == 'symbol') { - const description = val.description - if (description == null) { - return 'Symbol' - } else { - return `Symbol(${description})` - } - } - if (type == 'function') { - const name = val.name - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})` - } else { - return 'Function' - } - } - // objects - if (Array.isArray(val)) { - const length = val.length - let debug = '[' - if (length > 0) { - debug += debugString(val[0]) - } - for (let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]) - } - debug += ']' - return debug - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)) - let className - if (builtInMatches.length > 1) { - className = builtInMatches[1] - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val) - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')' - } catch (_) { - return 'Object' - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}` - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className -} /** - * @param {any} health_computer - * @returns {any} + * @param {HealthComputer} c + * @returns {HealthValuesResponse} */ -export function compute_health_js(health_computer) { - const ret = wasm.compute_health_js(addHeapObject(health_computer)) +export function compute_health_js(c) { + const ret = wasm.compute_health_js(addHeapObject(c)) return takeObject(ret) } /** - * @param {any} health_computer - * @param {any} withdraw_denom - * @returns {any} + * @param {HealthComputer} c + * @param {string} withdraw_denom + * @returns {string} */ -export function max_withdraw_estimate_js(health_computer, withdraw_denom) { - const ret = wasm.max_withdraw_estimate_js( - addHeapObject(health_computer), - addHeapObject(withdraw_denom), - ) - return takeObject(ret) +export function max_withdraw_estimate_js(c, withdraw_denom) { + let deferred2_0 + let deferred2_1 + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) + const ptr0 = passStringToWasm0(withdraw_denom, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc) + const len0 = WASM_VECTOR_LEN + wasm.max_withdraw_estimate_js(retptr, addHeapObject(c), ptr0, len0) + var r0 = getInt32Memory0()[retptr / 4 + 0] + var r1 = getInt32Memory0()[retptr / 4 + 1] + deferred2_0 = r0 + deferred2_1 = r1 + return getStringFromWasm0(r0, r1) + } finally { + wasm.__wbindgen_add_to_stack_pointer(16) + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1) + } } /** - * @param {any} health_computer - * @param {any} borrow_denom - * @param {any} target - * @returns {any} + * @param {HealthComputer} c + * @param {string} borrow_denom + * @param {BorrowTarget} target + * @returns {string} */ -export function max_borrow_estimate_js(health_computer, borrow_denom, target) { - const ret = wasm.max_borrow_estimate_js( - addHeapObject(health_computer), - addHeapObject(borrow_denom), - addHeapObject(target), - ) - return takeObject(ret) +export function max_borrow_estimate_js(c, borrow_denom, target) { + let deferred2_0 + let deferred2_1 + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) + const ptr0 = passStringToWasm0(borrow_denom, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc) + const len0 = WASM_VECTOR_LEN + wasm.max_borrow_estimate_js(retptr, addHeapObject(c), ptr0, len0, addHeapObject(target)) + var r0 = getInt32Memory0()[retptr / 4 + 0] + var r1 = getInt32Memory0()[retptr / 4 + 1] + deferred2_0 = r0 + deferred2_1 = r1 + return getStringFromWasm0(r0, r1) + } finally { + wasm.__wbindgen_add_to_stack_pointer(16) + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1) + } +} + +/** + * @param {HealthComputer} c + * @param {string} from_denom + * @param {string} to_denom + * @param {SwapKind} kind + * @returns {string} + */ +export function max_swap_estimate_js(c, from_denom, to_denom, kind) { + let deferred3_0 + let deferred3_1 + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) + const ptr0 = passStringToWasm0(from_denom, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc) + const len0 = WASM_VECTOR_LEN + const ptr1 = passStringToWasm0(to_denom, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc) + const len1 = WASM_VECTOR_LEN + wasm.max_swap_estimate_js(retptr, addHeapObject(c), ptr0, len0, ptr1, len1, addHeapObject(kind)) + var r0 = getInt32Memory0()[retptr / 4 + 0] + var r1 = getInt32Memory0()[retptr / 4 + 1] + deferred3_0 = r0 + deferred3_1 = r1 + return getStringFromWasm0(r0, r1) + } finally { + wasm.__wbindgen_add_to_stack_pointer(16) + wasm.__wbindgen_free(deferred3_0, deferred3_1, 1) + } } function handleError(f, args) { @@ -295,21 +261,16 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {} imports.wbg = {} - imports.wbg.__wbindgen_object_drop_ref = function (arg0) { - takeObject(arg0) - } - imports.wbg.__wbindgen_is_object = function (arg0) { - const val = getObject(arg0) - const ret = typeof val === 'object' && val !== null - return ret + imports.wbg.__wbindgen_object_clone_ref = function (arg0) { + const ret = getObject(arg0) + return addHeapObject(ret) } imports.wbg.__wbindgen_is_undefined = function (arg0) { const ret = getObject(arg0) === undefined return ret } - imports.wbg.__wbindgen_in = function (arg0, arg1) { - const ret = getObject(arg0) in getObject(arg1) - return ret + imports.wbg.__wbindgen_object_drop_ref = function (arg0) { + takeObject(arg0) } imports.wbg.__wbindgen_string_get = function (arg0, arg1) { const obj = getObject(arg1) @@ -321,195 +282,21 @@ function __wbg_get_imports() { getInt32Memory0()[arg0 / 4 + 1] = len1 getInt32Memory0()[arg0 / 4 + 0] = ptr1 } - imports.wbg.__wbindgen_error_new = function (arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)) - return addHeapObject(ret) + imports.wbg.__wbg_parse_670c19d4e984792e = function () { + return handleError(function (arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)) + return addHeapObject(ret) + }, arguments) } - imports.wbg.__wbindgen_is_string = function (arg0) { - const ret = typeof getObject(arg0) === 'string' - return ret - } - imports.wbg.__wbindgen_boolean_get = function (arg0) { - const v = getObject(arg0) - const ret = typeof v === 'boolean' ? (v ? 1 : 0) : 2 - return ret - } - imports.wbg.__wbindgen_is_bigint = function (arg0) { - const ret = typeof getObject(arg0) === 'bigint' - return ret - } - imports.wbg.__wbindgen_bigint_from_u64 = function (arg0) { - const ret = BigInt.asUintN(64, arg0) - return addHeapObject(ret) - } - imports.wbg.__wbindgen_jsval_eq = function (arg0, arg1) { - const ret = getObject(arg0) === getObject(arg1) - return ret - } - imports.wbg.__wbg_new_abda76e883ba8a5f = function () { - const ret = new Error() - return addHeapObject(ret) - } - imports.wbg.__wbg_stack_658279fe44541cf6 = function (arg0, arg1) { - const ret = getObject(arg1).stack - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc) - const len1 = WASM_VECTOR_LEN - getInt32Memory0()[arg0 / 4 + 1] = len1 - getInt32Memory0()[arg0 / 4 + 0] = ptr1 - } - imports.wbg.__wbg_error_f851667af71bcfc6 = function (arg0, arg1) { - let deferred0_0 - let deferred0_1 - try { - deferred0_0 = arg0 - deferred0_1 = arg1 - console.error(getStringFromWasm0(arg0, arg1)) - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1) - } - } - imports.wbg.__wbindgen_jsval_loose_eq = function (arg0, arg1) { - const ret = getObject(arg0) == getObject(arg1) - return ret - } - imports.wbg.__wbindgen_number_get = function (arg0, arg1) { - const obj = getObject(arg1) - const ret = typeof obj === 'number' ? obj : undefined - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret) - } - imports.wbg.__wbindgen_object_clone_ref = function (arg0) { - const ret = getObject(arg0) - return addHeapObject(ret) - } - imports.wbg.__wbindgen_string_new = function (arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1) - return addHeapObject(ret) - } - imports.wbg.__wbg_getwithrefkey_5e6d9547403deab8 = function (arg0, arg1) { - const ret = getObject(arg0)[getObject(arg1)] - return addHeapObject(ret) - } - imports.wbg.__wbg_set_841ac57cff3d672b = function (arg0, arg1, arg2) { - getObject(arg0)[takeObject(arg1)] = takeObject(arg2) - } - imports.wbg.__wbg_get_44be0491f933a435 = function (arg0, arg1) { - const ret = getObject(arg0)[arg1 >>> 0] - return addHeapObject(ret) - } - imports.wbg.__wbg_length_fff51ee6522a1a18 = function (arg0) { - const ret = getObject(arg0).length - return ret - } - imports.wbg.__wbindgen_is_function = function (arg0) { - const ret = typeof getObject(arg0) === 'function' - return ret - } - imports.wbg.__wbg_next_526fc47e980da008 = function (arg0) { - const ret = getObject(arg0).next - return addHeapObject(ret) - } - imports.wbg.__wbg_next_ddb3312ca1c4e32a = function () { + imports.wbg.__wbg_stringify_e25465938f3f611f = function () { return handleError(function (arg0) { - const ret = getObject(arg0).next() + const ret = JSON.stringify(getObject(arg0)) return addHeapObject(ret) }, arguments) } - imports.wbg.__wbg_done_5c1f01fb660d73b5 = function (arg0) { - const ret = getObject(arg0).done - return ret - } - imports.wbg.__wbg_value_1695675138684bd5 = function (arg0) { - const ret = getObject(arg0).value - return addHeapObject(ret) - } - imports.wbg.__wbg_iterator_97f0c81209c6c35a = function () { - const ret = Symbol.iterator - return addHeapObject(ret) - } - imports.wbg.__wbg_get_97b561fb56f034b5 = function () { - return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)) - return addHeapObject(ret) - }, arguments) - } - imports.wbg.__wbg_call_cb65541d95d71282 = function () { - return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)) - return addHeapObject(ret) - }, arguments) - } - imports.wbg.__wbg_new_b51585de1b234aff = function () { - const ret = new Object() - return addHeapObject(ret) - } - imports.wbg.__wbg_isArray_4c24b343cb13cfb1 = function (arg0) { - const ret = Array.isArray(getObject(arg0)) - return ret - } - imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function (arg0) { - let result - try { - result = getObject(arg0) instanceof ArrayBuffer - } catch { - result = false - } - const ret = result - return ret - } - imports.wbg.__wbg_isSafeInteger_bb8e18dd21c97288 = function (arg0) { - const ret = Number.isSafeInteger(getObject(arg0)) - return ret - } - imports.wbg.__wbg_entries_e51f29c7bba0c054 = function (arg0) { - const ret = Object.entries(getObject(arg0)) - return addHeapObject(ret) - } - imports.wbg.__wbg_buffer_085ec1f694018c4f = function (arg0) { - const ret = getObject(arg0).buffer - return addHeapObject(ret) - } - imports.wbg.__wbg_new_8125e318e6245eed = function (arg0) { - const ret = new Uint8Array(getObject(arg0)) - return addHeapObject(ret) - } - imports.wbg.__wbg_set_5cf90238115182c3 = function (arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0) - } - imports.wbg.__wbg_length_72e2208bbc0efc61 = function (arg0) { - const ret = getObject(arg0).length - return ret - } - imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function (arg0) { - let result - try { - result = getObject(arg0) instanceof Uint8Array - } catch { - result = false - } - const ret = result - return ret - } - imports.wbg.__wbindgen_bigint_get_as_i64 = function (arg0, arg1) { - const v = getObject(arg1) - const ret = typeof v === 'bigint' ? v : undefined - getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret) - } - imports.wbg.__wbindgen_debug_string = function (arg0, arg1) { - const ret = debugString(getObject(arg1)) - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc) - const len1 = WASM_VECTOR_LEN - getInt32Memory0()[arg0 / 4 + 1] = len1 - getInt32Memory0()[arg0 / 4 + 0] = ptr1 - } imports.wbg.__wbindgen_throw = function (arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)) } - imports.wbg.__wbindgen_memory = function () { - const ret = wasm.memory - return addHeapObject(ret) - } return imports } @@ -519,8 +306,6 @@ function __wbg_init_memory(imports, maybe_memory) {} function __wbg_finalize_init(instance, module) { wasm = instance.exports __wbg_init.__wbindgen_wasm_module = module - cachedBigInt64Memory0 = null - cachedFloat64Memory0 = null cachedInt32Memory0 = null cachedUint8Memory0 = null diff --git a/src/utils/health_computer/index_bg.wasm b/src/utils/health_computer/index_bg.wasm index da908522..b2901832 100644 Binary files a/src/utils/health_computer/index_bg.wasm and b/src/utils/health_computer/index_bg.wasm differ diff --git a/src/utils/health_computer/index_bg.wasm.d.ts b/src/utils/health_computer/index_bg.wasm.d.ts index d1cdc713..5c9170b3 100644 --- a/src/utils/health_computer/index_bg.wasm.d.ts +++ b/src/utils/health_computer/index_bg.wasm.d.ts @@ -2,8 +2,17 @@ /* eslint-disable */ export const memory: WebAssembly.Memory export function compute_health_js(a: number): number -export function max_withdraw_estimate_js(a: number, b: number): number -export function max_borrow_estimate_js(a: number, b: number, c: number): number +export function max_withdraw_estimate_js(a: number, b: number, c: number, d: number): void +export function max_borrow_estimate_js(a: number, b: number, c: number, d: number, e: number): void +export function max_swap_estimate_js( + a: number, + b: number, + c: number, + d: number, + e: number, + f: number, + g: number, +): void export function allocate(a: number): number export function deallocate(a: number): void export function requires_stargate(): void @@ -11,5 +20,6 @@ export function requires_iterator(): void export function interface_version_8(): void export function __wbindgen_malloc(a: number, b: number): number export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number +export function __wbindgen_add_to_stack_pointer(a: number): number export function __wbindgen_free(a: number, b: number, c: number): void export function __wbindgen_exn_store(a: number): void