Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thorswap-lib/swapkit-entities

Package Overview
Dependencies
Maintainers
3
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thorswap-lib/swapkit-entities - npm Package Compare versions

Comparing version 0.0.0-nightly-20231130150356 to 0.0.0-nightly-20240208140027

dist/index.cjs.map

197

dist/index.d.ts

@@ -1,2 +0,2 @@

import type { Chain, MemoType } from '@thorswap-lib/types';
import type { Chain } from '@swapkit/types';
import type { BigNumber } from 'bignumber.js';

@@ -108,3 +108,12 @@

export declare const BN_FORMAT: BigNumber.Format;
export declare const BN_FORMAT: {
prefix: string;
decimalSeparator: string;
groupSeparator: string;
groupSize: number;
secondaryGroupSize: number;
fractionGroupSeparator: string;
fractionGroupSize: number;
suffix: string;
};

@@ -119,161 +128,8 @@ export declare const EMPTY_FORMAT: BigNumber.Format;

export declare const getAssetShare: ({
liquidityUnits,
poolUnits,
assetDepth,
}: ShareParams<{
assetDepth: string;
}>) => Amount;
export declare const getAssetType: (
chain: Chain,
ticker: string,
isSynth?: boolean,
) =>
| 'Synth'
| 'Native'
| 'GAIA'
| 'BEP2'
| 'BEP20'
| 'ERC20'
| 'AVAX'
| 'POLYGON'
| 'ARBITRUM'
| 'OPTIMISM';
export declare const getAsymmetricAssetShare: ({
liquidityUnits,
poolUnits,
assetDepth,
}: ShareParams<{
assetDepth: string;
}>) => Amount;
export declare const getAsymmetricAssetWithdrawAmount: ({
percent,
assetDepth,
liquidityUnits,
poolUnits,
}: ShareParams<{
percent: number;
assetDepth: string;
}>) => Amount;
/**
* Ref: https://gitlab.com/thorchain/thornode/-/issues/657
* share = (s * A * (2 * T^2 - 2 * T * s + s^2))/T^3
* s = stakeUnits for member (after factoring in withdrawBasisPoints)
* T = totalPoolUnits for pool
* A = assetDepth to be withdrawn
*
* Formula:
* share = (s * A * (2 * T^2 - 2 * T * s + s^2))/T^3
* (part1 * (part2 - part3 + part4)) / part5
*/
export declare const getAsymmetricRuneShare: ({
liquidityUnits,
poolUnits,
runeDepth,
}: ShareParams<{
runeDepth: string;
}>) => Amount;
export declare const getAsymmetricRuneWithdrawAmount: ({
percent,
runeDepth,
liquidityUnits,
poolUnits,
}: ShareParams<{
percent: number;
runeDepth: string;
}>) => Amount;
export declare const getEstimatedPoolShare: ({
runeDepth,
poolUnits,
assetDepth,
liquidityUnits,
runeAmount,
assetAmount,
}: ShareParams<{
runeAmount: string;
assetAmount: string;
runeDepth: string;
assetDepth: string;
}>) => number;
export declare const getLiquiditySlippage: ({
runeAmount,
assetAmount,
runeDepth,
assetDepth,
}: PoolParams) => number;
export declare const getMemoFor: <T extends MemoType>(
memoType: T,
options: MemoOptions<T>,
) => string;
export declare const getMinAmountByChain: (chain: Chain) => AssetAmount;
export declare const getNetworkName: (chain: Chain, ticker: string) => string;
export declare const getRuneShare: ({
liquidityUnits,
poolUnits,
runeDepth,
}: ShareParams<{
runeDepth: string;
}>) => Amount;
export declare const getSignatureAssetFor: (signature: Signature, synth?: boolean) => AssetEntity;
export declare const getSymmetricWithdraw: ({
liquidityUnits,
poolUnits,
runeDepth,
assetDepth,
percent,
}: ShareParams<{
runeDepth: string;
assetDepth: string;
percent: number;
}>) => {
assetAmount: Amount;
runeAmount: Amount;
};
export declare const getTHORNameCost: (year: number) => number;
export declare const isGasAsset: (asset: AssetEntity) => boolean;
export declare type MemoOptions<T extends MemoType> = {
[MemoType.BOND]: WithAddress;
[MemoType.LEAVE]: WithAddress;
[MemoType.CLOSE_LOAN]: WithAddress<{
asset: string;
minAmount?: string;
}>;
[MemoType.OPEN_LOAN]: WithAddress<{
asset: string;
minAmount?: string;
}>;
[MemoType.UNBOND]: WithAddress<{
unbondAmount: number;
}>;
[MemoType.DEPOSIT]: WithChain<{
symbol: string;
address?: string;
singleSide?: boolean;
}>;
[MemoType.WITHDRAW]: WithChain<{
ticker: string;
symbol: string;
basisPoints: number;
targetAssetString?: string;
singleSide?: boolean;
}>;
[MemoType.THORNAME_REGISTER]: Omit<ThornameRegisterParam, 'preferredAsset' | 'expiryBlock'>;
}[T];
export declare class Pool {

@@ -311,9 +167,2 @@ readonly asset: AssetEntity;

declare type PoolParams<T = {}> = T & {
runeAmount: string;
assetAmount: string;
runeDepth: string;
assetDepth: string;
};
export declare class Price extends Amount {

@@ -352,28 +201,4 @@ readonly baseAsset: AssetEntity;

declare type ShareParams<T = {}> = T & {
liquidityUnits: string;
poolUnits: string;
};
declare type Signature = Chain | 'USD' | 'ETH_THOR' | 'ETH_VTHOR';
export declare type ThornameRegisterParam = {
name: string;
chain: string;
address: string;
owner?: string;
preferredAsset?: string;
expiryBlock?: string;
};
export declare const validateTHORName: (name: string) => boolean;
declare type WithAddress<T = {}> = T & {
address: string;
};
declare type WithChain<T = {}> = T & {
chain: Chain;
};
export {};

@@ -1,58 +0,734 @@

var q = Object.defineProperty;
var W = (t, s, e) => s in t ? q(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
var A = (t, s, e) => (W(t, typeof s != "symbol" ? s + "" : s, e), e);
import { BigNumber as S } from "bignumber.js";
var I = /* @__PURE__ */ ((t) => (t.THOR = "THOR", t.RUNE = "RUNE", t.ATOM = "ATOM", t.MUON = "MUON", t.USDC = "USDC", t))(I || {}), a = /* @__PURE__ */ ((t) => (t.INVALID_INPUT_PARAMETERS = "1000", t.UNKNOWN_PROVIDERS = "1001", t.CANNOT_FIND_INBOUND_ADDRESS = "1002", t.NO_INBOUND_ADDRESSES = "1003", t.CHAIN_HALTED_OR_UNSUPPORTED = "1004", t.MISSING_INPUT_PARAMETER = "1005", t.INVALID_TYPE_GENERIC = "1100", t.INVALID_NUMBER_STRING = "1101", t.INVALID_NUMBER = "1102", t.INVALID_BOOLEAN = "1103", t.INVALID_OBJECT = "1104", t.INVALID_ARRAY = "1105", t.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", t.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", t.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", t.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", t.AFF_ADDRESS_TOO_LONG = "2004", t.AFF_BPS_INTEGER_0_100 = "2005", t.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", t.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", t.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", t.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", t.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", t.SOURCE_ADDRESS_SMART_CONTRACT = "2011", t.INVALID_PROVIDER = "2100", t.MISSING_CROSS_CHAIN_PROVIDER = "2101", t.MISSING_AVAX_PROVIDER = "2102", t.MISSING_BSC_PROVIDER = "2103", t.MISSING_ETH_PROVIDER = "2104", t.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", t.MISSING_ARB_PROVIDER = "2106", t.INVALID_CHAIN = "2200", t.INVALID_ASSET = "2201", t.INVALID_ASSET_IDENTIFIER = "2202", t.UNSUPPORTED_CHAIN = "2204", t.UNSUPPORTED_ASSET = "2203", t.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", t.INVALID_SOURCE_ADDRESS = "2300", t.INVALID_DESTINATION_ADDRESS = "2301", t.THORNODE_QUOTE_GENERIC_ERROR = "3000", t.NOT_ENOUGH_SYNTH_BALANCE = "3001", t.SYNTH_MINTING_CAP_REACHED = "3002", t.INVALID_QUOTE_MODE = "4000", t.NO_QUOTES = "4001", t.SERVICE_UNAVAILABLE_GENERIC = "5000", t.MISSING_GAS_DATA_GENERIC = "5100", t.MISSING_TOKEN_INFO_GENERIC = "5200", t.CANT_FIND_TOKEN_LIST = "5201", t.NO_PRICE = "5202", t.PRICE_IS_STALE = "5203", t.ADDRESS_NOT_WHITELISTED = "6000", t.ADDRESS_ALREADY_CLAIMED = "6001", t.TEMPORARY_ERROR = "9999", t))(a || {});
a.INVALID_INPUT_PARAMETERS + "", a.UNKNOWN_PROVIDERS + "", a.CANNOT_FIND_INBOUND_ADDRESS + "", a.NO_INBOUND_ADDRESSES + "", a.CHAIN_HALTED_OR_UNSUPPORTED + "", a.MISSING_INPUT_PARAMETER + "", a.INVALID_TYPE_GENERIC + "", a.INVALID_NUMBER_STRING + "", a.INVALID_NUMBER + "", a.INVALID_BOOLEAN + "", a.INVALID_OBJECT + "", a.INVALID_ARRAY + "", a.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", a.SELL_BUY_ASSETS_ARE_THE_SAME + "", a.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", a.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", a.AFF_ADDRESS_TOO_LONG + "", a.AFF_BPS_INTEGER_0_100 + "", a.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", a.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", a.PREFERRED_PROFVIDER_NOT_SUPPORTED + "", a.DESTINATION_ADDRESS_SMART_CONTRACT + "", a.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", a.INVALID_PROVIDER + "", a.MISSING_CROSS_CHAIN_PROVIDER + "", a.MISSING_AVAX_PROVIDER + "", a.MISSING_BSC_PROVIDER + "", a.MISSING_ETH_PROVIDER + "", a.MISSING_ARB_PROVIDER + "", a.INVALID_PROVIDER_FOR_SWAP_OUT + "", a.INVALID_CHAIN + "", a.INVALID_ASSET + "", a.UNSUPPORTED_CHAIN + "", a.UNSUPPORTED_ASSET + "", a.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", a.THORNODE_QUOTE_GENERIC_ERROR + "", a.INVALID_SOURCE_ADDRESS + "", a.INVALID_DESTINATION_ADDRESS + "", a.NOT_ENOUGH_SYNTH_BALANCE + "", a.SYNTH_MINTING_CAP_REACHED + "", a.INVALID_QUOTE_MODE + "", a.NO_QUOTES + "", a.SERVICE_UNAVAILABLE_GENERIC + "", a.MISSING_GAS_DATA_GENERIC + "", a.MISSING_TOKEN_INFO_GENERIC + "", a.CANT_FIND_TOKEN_LIST + "", a.NO_PRICE + "", a.PRICE_IS_STALE + "", a.ADDRESS_NOT_WHITELISTED + "", a.ADDRESS_ALREADY_CLAIMED + "";
var r = /* @__PURE__ */ ((t) => (t.Arbitrum = "ARB", t.Avalanche = "AVAX", t.Binance = "BNB", t.BinanceSmartChain = "BSC", t.Bitcoin = "BTC", t.BitcoinCash = "BCH", t.Cosmos = "GAIA", t.Dogecoin = "DOGE", t.Ethereum = "ETH", t.Litecoin = "LTC", t.Optimism = "OP", t.Polygon = "MATIC", t.THORChain = "THOR", t))(r || {}), m = /* @__PURE__ */ ((t) => (t[t.ARB = 18] = "ARB", t[t.AVAX = 18] = "AVAX", t[t.BCH = 8] = "BCH", t[t.BNB = 8] = "BNB", t[t.BSC = 18] = "BSC", t[t.BTC = 8] = "BTC", t[t.DOGE = 8] = "DOGE", t[t.ETH = 18] = "ETH", t[t.GAIA = 6] = "GAIA", t[t.LTC = 8] = "LTC", t[t.MATIC = 18] = "MATIC", t[t.OP = 18] = "OP", t[t.THOR = 8] = "THOR", t))(m || {}), w = /* @__PURE__ */ ((t) => (t.Arbitrum = "42161", t.ArbitrumHex = "0xa4b1", t.Avalanche = "43114", t.AvalancheHex = "0xa86a", t.Binance = "Binance-Chain-Tigris", t.BinanceHex = "", t.BinanceSmartChain = "56", t.BinanceSmartChainHex = "0x38", t.Bitcoin = "bitcoin", t.BitcoinHex = "", t.BitcoinCash = "bitcoincash", t.BitcoinCashHex = "", t.Cosmos = "cosmoshub-4", t.CosmosHex = "", t.Dogecoin = "dogecoin", t.DogecoinHex = "", t.Ethereum = "1", t.EthereumHex = "0x1", t.Litecoin = "litecoin", t.LitecoinHex = "", t.Optimism = "10", t.OptimismHex = "0xa", t.Polygon = "137", t.PolygonHex = "0x89", t.THORChain = "thorchain-mainnet-v1", t.THORChainHex = "", t.THORChainStagenet = "thorchain-stagenet-v2", t))(w || {}), g = /* @__PURE__ */ ((t) => (t.Arbitrum = "https://arb1.arbitrum.io/rpc", t.Avalanche = "https://node-router.thorswap.net/avalanche-c", t.Binance = "", t.BinanceSmartChain = "https://bsc-dataseed.binance.org", t.Bitcoin = "https://node-router.thorswap.net/bitcoin", t.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", t.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", t.Dogecoin = "https://node-router.thorswap.net/dogecoin", t.Ethereum = "https://node-router.thorswap.net/ethereum", t.Litecoin = "https://node-router.thorswap.net/litecoin", t.Optimism = "https://mainnet.optimism.io", t.Polygon = "https://polygon-rpc.com", t.THORChain = "https://rpc.thorswap.net", t.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", t))(g || {});
const P = Object.values(r), Y = Object.keys(r), M = P.reduce(
var Fe = Object.defineProperty;
var Ge = (t, s, f) => s in t ? Fe(t, s, { enumerable: !0, configurable: !0, writable: !0, value: f }) : t[s] = f;
var P = (t, s, f) => (Ge(t, typeof s != "symbol" ? s + "" : s, f), f);
var R = /* @__PURE__ */ ((t) => (t.INVALID_INPUT_PARAMETERS = "1000", t.UNKNOWN_PROVIDERS = "1001", t.CANNOT_FIND_INBOUND_ADDRESS = "1002", t.NO_INBOUND_ADDRESSES = "1003", t.CHAIN_HALTED_OR_UNSUPPORTED = "1004", t.MISSING_INPUT_PARAMETER = "1005", t.INVALID_TYPE_GENERIC = "1100", t.INVALID_NUMBER_STRING = "1101", t.INVALID_NUMBER = "1102", t.INVALID_BOOLEAN = "1103", t.INVALID_OBJECT = "1104", t.INVALID_ARRAY = "1105", t.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", t.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", t.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", t.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", t.AFF_ADDRESS_TOO_LONG = "2004", t.AFF_BPS_INTEGER_MAX_500 = "2005", t.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", t.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", t.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", t.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", t.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", t.SOURCE_ADDRESS_SMART_CONTRACT = "2011", t.INVALID_PROVIDER = "2100", t.MISSING_CROSS_CHAIN_PROVIDER = "2101", t.MISSING_AVAX_PROVIDER = "2102", t.MISSING_BSC_PROVIDER = "2103", t.MISSING_ETH_PROVIDER = "2104", t.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", t.MISSING_ARB_PROVIDER = "2106", t.INVALID_CHAIN = "2200", t.INVALID_ASSET = "2201", t.INVALID_ASSET_IDENTIFIER = "2202", t.UNSUPPORTED_CHAIN = "2204", t.UNSUPPORTED_ASSET = "2203", t.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", t.INVALID_SOURCE_ADDRESS = "2300", t.INVALID_DESTINATION_ADDRESS = "2301", t.THORNODE_QUOTE_GENERIC_ERROR = "3000", t.NOT_ENOUGH_SYNTH_BALANCE = "3001", t.SYNTH_MINTING_CAP_REACHED = "3002", t.INVALID_QUOTE_MODE = "4000", t.NO_QUOTES = "4001", t.SERVICE_UNAVAILABLE_GENERIC = "5000", t.MISSING_GAS_DATA_GENERIC = "5100", t.MISSING_TOKEN_INFO_GENERIC = "5200", t.CANT_FIND_TOKEN_LIST = "5201", t.NO_PRICE = "5202", t.PRICE_IS_STALE = "5203", t.ADDRESS_NOT_WHITELISTED = "6000", t.ADDRESS_ALREADY_CLAIMED = "6001", t.TEMPORARY_ERROR = "9999", t))(R || {});
R.INVALID_INPUT_PARAMETERS + "", R.UNKNOWN_PROVIDERS + "", R.CANNOT_FIND_INBOUND_ADDRESS + "", R.NO_INBOUND_ADDRESSES + "", R.CHAIN_HALTED_OR_UNSUPPORTED + "", R.MISSING_INPUT_PARAMETER + "", R.INVALID_TYPE_GENERIC + "", R.INVALID_NUMBER_STRING + "", R.INVALID_NUMBER + "", R.INVALID_BOOLEAN + "", R.INVALID_OBJECT + "", R.INVALID_ARRAY + "", R.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", R.SELL_BUY_ASSETS_ARE_THE_SAME + "", R.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", R.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", R.AFF_ADDRESS_TOO_LONG + "", R.AFF_BPS_INTEGER_MAX_500 + "", R.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", R.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", R.PREFERRED_PROVIDER_NOT_SUPPORTED + "", R.SOURCE_ADDRESS_SMART_CONTRACT + "", R.DESTINATION_ADDRESS_SMART_CONTRACT + "", R.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", R.INVALID_PROVIDER + "", R.MISSING_CROSS_CHAIN_PROVIDER + "", R.MISSING_AVAX_PROVIDER + "", R.MISSING_BSC_PROVIDER + "", R.MISSING_ETH_PROVIDER + "", R.MISSING_ARB_PROVIDER + "", R.INVALID_PROVIDER_FOR_SWAP_OUT + "", R.INVALID_CHAIN + "", R.INVALID_ASSET + "", R.UNSUPPORTED_CHAIN + "", R.UNSUPPORTED_ASSET + "", R.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", R.THORNODE_QUOTE_GENERIC_ERROR + "", R.INVALID_SOURCE_ADDRESS + "", R.INVALID_DESTINATION_ADDRESS + "", R.NOT_ENOUGH_SYNTH_BALANCE + "", R.SYNTH_MINTING_CAP_REACHED + "", R.INVALID_QUOTE_MODE + "", R.NO_QUOTES + "", R.SERVICE_UNAVAILABLE_GENERIC + "", R.MISSING_GAS_DATA_GENERIC + "", R.MISSING_TOKEN_INFO_GENERIC + "", R.CANT_FIND_TOKEN_LIST + "", R.NO_PRICE + "", R.PRICE_IS_STALE + "", R.ADDRESS_NOT_WHITELISTED + "", R.ADDRESS_ALREADY_CLAIMED + "";
var D = /* @__PURE__ */ ((t) => (t.Arbitrum = "ARB", t.Avalanche = "AVAX", t.Binance = "BNB", t.BinanceSmartChain = "BSC", t.Bitcoin = "BTC", t.BitcoinCash = "BCH", t.Cosmos = "GAIA", t.Dogecoin = "DOGE", t.Ethereum = "ETH", t.Kujira = "KUJI", t.Litecoin = "LTC", t.Maya = "MAYA", t.Optimism = "OP", t.Polkadot = "DOT", t.Chainflip = "FLIP", t.Polygon = "MATIC", t.THORChain = "THOR", t))(D || {}), j = /* @__PURE__ */ ((t) => (t[t.ARB = 18] = "ARB", t[t.AVAX = 18] = "AVAX", t[t.BCH = 8] = "BCH", t[t.BNB = 8] = "BNB", t[t.BSC = 18] = "BSC", t[t.BTC = 8] = "BTC", t[t.DASH = 8] = "DASH", t[t.DOGE = 8] = "DOGE", t[t.DOT = 10] = "DOT", t[t.ETH = 18] = "ETH", t[t.FLIP = 18] = "FLIP", t[t.GAIA = 6] = "GAIA", t[t.KUJI = 6] = "KUJI", t[t.LTC = 8] = "LTC", t[t.MATIC = 18] = "MATIC", t[t.MAYA = 10] = "MAYA", t[t.OP = 18] = "OP", t[t.THOR = 8] = "THOR", t))(j || {}), Ce = /* @__PURE__ */ ((t) => (t.Arbitrum = "42161", t.ArbitrumHex = "0xa4b1", t.Avalanche = "43114", t.AvalancheHex = "0xa86a", t.Binance = "Binance-Chain-Tigris", t.BinanceSmartChain = "56", t.BinanceSmartChainHex = "0x38", t.Bitcoin = "bitcoin", t.BitcoinCash = "bitcoincash", t.Chainflip = "chainflip", t.Cosmos = "cosmoshub-4", t.Dogecoin = "dogecoin", t.Kujira = "kaiyo-1", t.Ethereum = "1", t.EthereumHex = "0x1", t.Litecoin = "litecoin", t.Maya = "mayachain-mainnet-v1", t.MayaStagenet = "mayachain-stagenet-v1", t.Optimism = "10", t.OptimismHex = "0xa", t.Polkadot = "polkadot", t.Polygon = "137", t.PolygonHex = "0x89", t.THORChain = "thorchain-mainnet-v1", t.THORChainStagenet = "thorchain-stagenet-v2", t))(Ce || {}), ve = /* @__PURE__ */ ((t) => (t.Arbitrum = "https://arb1.arbitrum.io/rpc", t.Avalanche = "https://node-router.thorswap.net/avalanche-c", t.Binance = "", t.BinanceSmartChain = "https://bsc-dataseed.binance.org", t.Bitcoin = "https://node-router.thorswap.net/bitcoin", t.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", t.Chainflip = "wss://mainnet-archive.chainflip.io", t.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", t.Kujira = "https://rpc-kujira.synergynodes.com/", t.Dogecoin = "https://node-router.thorswap.net/dogecoin", t.Ethereum = "https://node-router.thorswap.net/ethereum", t.Litecoin = "https://node-router.thorswap.net/litecoin", t.Maya = "https://tendermint.mayachain.info", t.MayaStagenet = "https://stagenet.tendermint.mayachain.info", t.Optimism = "https://mainnet.optimism.io", t.Polkadot = "wss://rpc.polkadot.io", t.Polygon = "https://polygon-rpc.com", t.THORChain = "https://rpc.thorswap.net", t.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", t))(ve || {});
const Oe = Object.values(D), Ve = Object.keys(D), Be = Oe.reduce(
(t, s) => {
const e = Y.find((i) => r[i] === s);
return e && (t[s] = e), t;
const f = Ve.find((S) => D[S] === s);
return f && (t[s] = f), t;
},
{}
);
P.reduce(
(t, s) => (t[s] = w[M[s]], t),
Oe.reduce(
(t, s) => (t[s] = Ce[Be[s]], t),
{}
);
P.reduce(
(t, s) => (t[s] = g[M[s]], t),
Oe.reduce(
(t, s) => (t[s] = ve[Be[s]], t),
{}
);
P.reduce(
(t, s) => (t[s] = w[`${M[s]}Hex`], t),
Oe.reduce(
(t, s) => {
const f = `${Be[s]}Hex`;
return t[s] = Ce[f], t;
},
{}
);
var O = /* @__PURE__ */ ((t) => (t.BOND = "BOND", t.DEPOSIT = "+", t.LEAVE = "LEAVE", t.THORNAME_REGISTER = "~", t.UNBOND = "UNBOND", t.WITHDRAW = "-", t.OPEN_LOAN = "$+", t.CLOSE_LOAN = "$-", t))(O || {});
const k = (t, s, e = !1) => {
if (e)
return "Synth";
switch (t) {
case r.Bitcoin:
case r.BitcoinCash:
case r.Dogecoin:
case r.Litecoin:
case r.THORChain:
return "Native";
case r.Cosmos:
return s === "ATOM" ? "Native" : "GAIA";
case r.Binance:
return s === r.Binance ? "Native" : "BEP2";
case r.BinanceSmartChain:
return s === r.Binance ? "Native" : "BEP20";
case r.Ethereum:
return s === r.Ethereum ? "Native" : "ERC20";
case r.Avalanche:
return s === r.Avalanche ? "Native" : "AVAX";
case r.Polygon:
return s === r.Polygon ? "Native" : "POLYGON";
case r.Arbitrum:
return [r.Ethereum, r.Arbitrum].includes(s) ? "Native" : "ARBITRUM";
case r.Optimism:
return [r.Ethereum, r.Optimism].includes(s) ? "Native" : "OPTIMISM";
default:
return t;
var ye = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, De = Math.ceil, W = Math.floor, k = "[BigNumber Error] ", Le = k + "Number primitive has more than 15 significant digits: ", z = 1e14, T = 14, we = 9007199254740991, Ue = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], ie = 1e7, x = 1e9;
function He(t) {
var s, f, S, E = _.prototype = { constructor: _, toString: null, valueOf: null }, m = new _(1), p = 20, C = 4, w = -7, G = 21, ne = -1e7, K = 1e7, se = !1, le = 1, te = 0, Ie = {
prefix: "",
groupSize: 3,
secondaryGroupSize: 0,
groupSeparator: ",",
decimalSeparator: ".",
fractionGroupSize: 0,
fractionGroupSeparator: " ",
// non-breaking space
suffix: ""
}, oe = "0123456789abcdefghijklmnopqrstuvwxyz", Re = !0;
function _(e, i) {
var r, l, o, c, A, n, a, h, u = this;
if (!(u instanceof _))
return new _(e, i);
if (i == null) {
if (e && e._isBigNumber === !0) {
u.s = e.s, !e.c || e.e > K ? u.c = u.e = null : e.e < ne ? u.c = [u.e = 0] : (u.e = e.e, u.c = e.c.slice());
return;
}
if ((n = typeof e == "number") && e * 0 == 0) {
if (u.s = 1 / e < 0 ? (e = -e, -1) : 1, e === ~~e) {
for (c = 0, A = e; A >= 10; A /= 10, c++)
;
c > K ? u.c = u.e = null : (u.e = c, u.c = [e]);
return;
}
h = String(e);
} else {
if (!ye.test(h = String(e)))
return S(u, h, n);
u.s = h.charCodeAt(0) == 45 ? (h = h.slice(1), -1) : 1;
}
(c = h.indexOf(".")) > -1 && (h = h.replace(".", "")), (A = h.search(/e/i)) > 0 ? (c < 0 && (c = A), c += +h.slice(A + 1), h = h.substring(0, A)) : c < 0 && (c = h.length);
} else {
if (M(i, 2, oe.length, "Base"), i == 10 && Re)
return u = new _(e), $(u, p + u.e + 1, C);
if (h = String(e), n = typeof e == "number") {
if (e * 0 != 0)
return S(u, h, n, i);
if (u.s = 1 / e < 0 ? (h = h.slice(1), -1) : 1, _.DEBUG && h.replace(/^0\.0*|\./, "").length > 15)
throw Error(Le + e);
} else
u.s = h.charCodeAt(0) === 45 ? (h = h.slice(1), -1) : 1;
for (r = oe.slice(0, i), c = A = 0, a = h.length; A < a; A++)
if (r.indexOf(l = h.charAt(A)) < 0) {
if (l == ".") {
if (A > c) {
c = a;
continue;
}
} else if (!o && (h == h.toUpperCase() && (h = h.toLowerCase()) || h == h.toLowerCase() && (h = h.toUpperCase()))) {
o = !0, A = -1, c = 0;
continue;
}
return S(u, String(e), n, i);
}
n = !1, h = f(h, i, 10, u.s), (c = h.indexOf(".")) > -1 ? h = h.replace(".", "") : c = h.length;
}
for (A = 0; h.charCodeAt(A) === 48; A++)
;
for (a = h.length; h.charCodeAt(--a) === 48; )
;
if (h = h.slice(A, ++a)) {
if (a -= A, n && _.DEBUG && a > 15 && (e > we || e !== W(e)))
throw Error(Le + u.s * e);
if ((c = c - A - 1) > K)
u.c = u.e = null;
else if (c < ne)
u.c = [u.e = 0];
else {
if (u.e = c, u.c = [], A = (c + 1) % T, c < 0 && (A += T), A < a) {
for (A && u.c.push(+h.slice(0, A)), a -= T; A < a; )
u.c.push(+h.slice(A, A += T));
A = T - (h = h.slice(A)).length;
} else
A -= a;
for (; A--; h += "0")
;
u.c.push(+h);
}
} else
u.c = [u.e = 0];
}
}, l = {
_.clone = He, _.ROUND_UP = 0, _.ROUND_DOWN = 1, _.ROUND_CEIL = 2, _.ROUND_FLOOR = 3, _.ROUND_HALF_UP = 4, _.ROUND_HALF_DOWN = 5, _.ROUND_HALF_EVEN = 6, _.ROUND_HALF_CEIL = 7, _.ROUND_HALF_FLOOR = 8, _.EUCLID = 9, _.config = _.set = function(e) {
var i, r;
if (e != null)
if (typeof e == "object") {
if (e.hasOwnProperty(i = "DECIMAL_PLACES") && (r = e[i], M(r, 0, x, i), p = r), e.hasOwnProperty(i = "ROUNDING_MODE") && (r = e[i], M(r, 0, 8, i), C = r), e.hasOwnProperty(i = "EXPONENTIAL_AT") && (r = e[i], r && r.pop ? (M(r[0], -x, 0, i), M(r[1], 0, x, i), w = r[0], G = r[1]) : (M(r, -x, x, i), w = -(G = r < 0 ? -r : r))), e.hasOwnProperty(i = "RANGE"))
if (r = e[i], r && r.pop)
M(r[0], -x, -1, i), M(r[1], 1, x, i), ne = r[0], K = r[1];
else if (M(r, -x, x, i), r)
ne = -(K = r < 0 ? -r : r);
else
throw Error(k + i + " cannot be zero: " + r);
if (e.hasOwnProperty(i = "CRYPTO"))
if (r = e[i], r === !!r)
if (r)
if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
se = r;
else
throw se = !r, Error(k + "crypto unavailable");
else
se = r;
else
throw Error(k + i + " not true or false: " + r);
if (e.hasOwnProperty(i = "MODULO_MODE") && (r = e[i], M(r, 0, 9, i), le = r), e.hasOwnProperty(i = "POW_PRECISION") && (r = e[i], M(r, 0, x, i), te = r), e.hasOwnProperty(i = "FORMAT"))
if (r = e[i], typeof r == "object")
Ie = r;
else
throw Error(k + i + " not an object: " + r);
if (e.hasOwnProperty(i = "ALPHABET"))
if (r = e[i], typeof r == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(r))
Re = r.slice(0, 10) == "0123456789", oe = r;
else
throw Error(k + i + " invalid: " + r);
} else
throw Error(k + "Object expected: " + e);
return {
DECIMAL_PLACES: p,
ROUNDING_MODE: C,
EXPONENTIAL_AT: [w, G],
RANGE: [ne, K],
CRYPTO: se,
MODULO_MODE: le,
POW_PRECISION: te,
FORMAT: Ie,
ALPHABET: oe
};
}, _.isBigNumber = function(e) {
if (!e || e._isBigNumber !== !0)
return !1;
if (!_.DEBUG)
return !0;
var i, r, l = e.c, o = e.e, c = e.s;
e:
if ({}.toString.call(l) == "[object Array]") {
if ((c === 1 || c === -1) && o >= -x && o <= x && o === W(o)) {
if (l[0] === 0) {
if (o === 0 && l.length === 1)
return !0;
break e;
}
if (i = (o + 1) % T, i < 1 && (i += T), String(l[0]).length == i) {
for (i = 0; i < l.length; i++)
if (r = l[i], r < 0 || r >= z || r !== W(r))
break e;
if (r !== 0)
return !0;
}
}
} else if (l === null && o === null && (c === null || c === 1 || c === -1))
return !0;
throw Error(k + "Invalid BigNumber: " + e);
}, _.maximum = _.max = function() {
return Me(arguments, -1);
}, _.minimum = _.min = function() {
return Me(arguments, 1);
}, _.random = function() {
var e = 9007199254740992, i = Math.random() * e & 2097151 ? function() {
return W(Math.random() * e);
} : function() {
return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
};
return function(r) {
var l, o, c, A, n, a = 0, h = [], u = new _(m);
if (r == null ? r = p : M(r, 0, x), A = De(r / T), se)
if (crypto.getRandomValues) {
for (l = crypto.getRandomValues(new Uint32Array(A *= 2)); a < A; )
n = l[a] * 131072 + (l[a + 1] >>> 11), n >= 9e15 ? (o = crypto.getRandomValues(new Uint32Array(2)), l[a] = o[0], l[a + 1] = o[1]) : (h.push(n % 1e14), a += 2);
a = A / 2;
} else if (crypto.randomBytes) {
for (l = crypto.randomBytes(A *= 7); a < A; )
n = (l[a] & 31) * 281474976710656 + l[a + 1] * 1099511627776 + l[a + 2] * 4294967296 + l[a + 3] * 16777216 + (l[a + 4] << 16) + (l[a + 5] << 8) + l[a + 6], n >= 9e15 ? crypto.randomBytes(7).copy(l, a) : (h.push(n % 1e14), a += 7);
a = A / 7;
} else
throw se = !1, Error(k + "crypto unavailable");
if (!se)
for (; a < A; )
n = i(), n < 9e15 && (h[a++] = n % 1e14);
for (A = h[--a], r %= T, A && r && (n = Ue[T - r], h[a] = W(A / n) * n); h[a] === 0; h.pop(), a--)
;
if (a < 0)
h = [c = 0];
else {
for (c = -1; h[0] === 0; h.splice(0, 1), c -= T)
;
for (a = 1, n = h[0]; n >= 10; n /= 10, a++)
;
a < T && (c -= T - a);
}
return u.e = c, u.c = h, u;
};
}(), _.sum = function() {
for (var e = 1, i = arguments, r = new _(i[0]); e < i.length; )
r = r.plus(i[e++]);
return r;
}, f = /* @__PURE__ */ function() {
var e = "0123456789";
function i(r, l, o, c) {
for (var A, n = [0], a, h = 0, u = r.length; h < u; ) {
for (a = n.length; a--; n[a] *= l)
;
for (n[0] += c.indexOf(r.charAt(h++)), A = 0; A < n.length; A++)
n[A] > o - 1 && (n[A + 1] == null && (n[A + 1] = 0), n[A + 1] += n[A] / o | 0, n[A] %= o);
}
return n.reverse();
}
return function(r, l, o, c, A) {
var n, a, h, u, N, O, I, g, L = r.indexOf("."), H = p, U = C;
for (L >= 0 && (u = te, te = 0, r = r.replace(".", ""), g = new _(l), O = g.pow(r.length - L), te = u, g.c = i(
ee(Y(O.c), O.e, "0"),
10,
o,
e
), g.e = g.c.length), I = i(r, l, o, A ? (n = oe, e) : (n = e, oe)), h = u = I.length; I[--u] == 0; I.pop())
;
if (!I[0])
return n.charAt(0);
if (L < 0 ? --h : (O.c = I, O.e = h, O.s = c, O = s(O, g, H, U, o), I = O.c, N = O.r, h = O.e), a = h + H + 1, L = I[a], u = o / 2, N = N || a < 0 || I[a + 1] != null, N = U < 4 ? (L != null || N) && (U == 0 || U == (O.s < 0 ? 3 : 2)) : L > u || L == u && (U == 4 || N || U == 6 && I[a - 1] & 1 || U == (O.s < 0 ? 8 : 7)), a < 1 || !I[0])
r = N ? ee(n.charAt(1), -H, n.charAt(0)) : n.charAt(0);
else {
if (I.length = a, N)
for (--o; ++I[--a] > o; )
I[a] = 0, a || (++h, I = [1].concat(I));
for (u = I.length; !I[--u]; )
;
for (L = 0, r = ""; L <= u; r += n.charAt(I[L++]))
;
r = ee(r, h, n.charAt(0));
}
return r;
};
}(), s = /* @__PURE__ */ function() {
function e(l, o, c) {
var A, n, a, h, u = 0, N = l.length, O = o % ie, I = o / ie | 0;
for (l = l.slice(); N--; )
a = l[N] % ie, h = l[N] / ie | 0, A = I * a + h * O, n = O * a + A % ie * ie + u, u = (n / c | 0) + (A / ie | 0) + I * h, l[N] = n % c;
return u && (l = [u].concat(l)), l;
}
function i(l, o, c, A) {
var n, a;
if (c != A)
a = c > A ? 1 : -1;
else
for (n = a = 0; n < c; n++)
if (l[n] != o[n]) {
a = l[n] > o[n] ? 1 : -1;
break;
}
return a;
}
function r(l, o, c, A) {
for (var n = 0; c--; )
l[c] -= n, n = l[c] < o[c] ? 1 : 0, l[c] = n * A + l[c] - o[c];
for (; !l[0] && l.length > 1; l.splice(0, 1))
;
}
return function(l, o, c, A, n) {
var a, h, u, N, O, I, g, L, H, U, B, V, Ee, pe, de, J, he, q = l.s == o.s ? 1 : -1, y = l.c, v = o.c;
if (!y || !y[0] || !v || !v[0])
return new _(
// Return NaN if either NaN, or both Infinity or 0.
!l.s || !o.s || (y ? v && y[0] == v[0] : !v) ? NaN : (
// Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
y && y[0] == 0 || !v ? q * 0 : q / 0
)
);
for (L = new _(q), H = L.c = [], h = l.e - o.e, q = c + h + 1, n || (n = z, h = X(l.e / T) - X(o.e / T), q = q / T | 0), u = 0; v[u] == (y[u] || 0); u++)
;
if (v[u] > (y[u] || 0) && h--, q < 0)
H.push(1), N = !0;
else {
for (pe = y.length, J = v.length, u = 0, q += 2, O = W(n / (v[0] + 1)), O > 1 && (v = e(v, O, n), y = e(y, O, n), J = v.length, pe = y.length), Ee = J, U = y.slice(0, J), B = U.length; B < J; U[B++] = 0)
;
he = v.slice(), he = [0].concat(he), de = v[0], v[1] >= n / 2 && de++;
do {
if (O = 0, a = i(v, U, J, B), a < 0) {
if (V = U[0], J != B && (V = V * n + (U[1] || 0)), O = W(V / de), O > 1)
for (O >= n && (O = n - 1), I = e(v, O, n), g = I.length, B = U.length; i(I, U, g, B) == 1; )
O--, r(I, J < g ? he : v, g, n), g = I.length, a = 1;
else
O == 0 && (a = O = 1), I = v.slice(), g = I.length;
if (g < B && (I = [0].concat(I)), r(U, I, B, n), B = U.length, a == -1)
for (; i(v, U, J, B) < 1; )
O++, r(U, J < B ? he : v, B, n), B = U.length;
} else
a === 0 && (O++, U = [0]);
H[u++] = O, U[0] ? U[B++] = y[Ee] || 0 : (U = [y[Ee]], B = 1);
} while ((Ee++ < pe || U[0] != null) && q--);
N = U[0] != null, H[0] || H.splice(0, 1);
}
if (n == z) {
for (u = 1, q = H[0]; q >= 10; q /= 10, u++)
;
$(L, c + (L.e = u + h * T - 1) + 1, A, N);
} else
L.e = h, L.r = +N;
return L;
};
}();
function me(e, i, r, l) {
var o, c, A, n, a;
if (r == null ? r = C : M(r, 0, 8), !e.c)
return e.toString();
if (o = e.c[0], A = e.e, i == null)
a = Y(e.c), a = l == 1 || l == 2 && (A <= w || A >= G) ? Se(a, A) : ee(a, A, "0");
else if (e = $(new _(e), i, r), c = e.e, a = Y(e.c), n = a.length, l == 1 || l == 2 && (i <= c || c <= w)) {
for (; n < i; a += "0", n++)
;
a = Se(a, c);
} else if (i -= A, a = ee(a, c, "0"), c + 1 > n) {
if (--i > 0)
for (a += "."; i--; a += "0")
;
} else if (i += c - n, i > 0)
for (c + 1 == n && (a += "."); i--; a += "0")
;
return e.s < 0 && o ? "-" + a : a;
}
function Me(e, i) {
for (var r, l, o = 1, c = new _(e[0]); o < e.length; o++)
l = new _(e[o]), (!l.s || (r = ae(c, l)) === i || r === 0 && c.s === i) && (c = l);
return c;
}
function Te(e, i, r) {
for (var l = 1, o = i.length; !i[--o]; i.pop())
;
for (o = i[0]; o >= 10; o /= 10, l++)
;
return (r = l + r * T - 1) > K ? e.c = e.e = null : r < ne ? e.c = [e.e = 0] : (e.e = r, e.c = i), e;
}
S = /* @__PURE__ */ function() {
var e = /^(-?)0([xbo])(?=\w[\w.]*$)/i, i = /^([^.]+)\.$/, r = /^\.([^.]+)$/, l = /^-?(Infinity|NaN)$/, o = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
return function(c, A, n, a) {
var h, u = n ? A : A.replace(o, "");
if (l.test(u))
c.s = isNaN(u) ? null : u < 0 ? -1 : 1;
else {
if (!n && (u = u.replace(e, function(N, O, I) {
return h = (I = I.toLowerCase()) == "x" ? 16 : I == "b" ? 2 : 8, !a || a == h ? O : N;
}), a && (h = a, u = u.replace(i, "$1").replace(r, "0.$1")), A != u))
return new _(u, h);
if (_.DEBUG)
throw Error(k + "Not a" + (a ? " base " + a : "") + " number: " + A);
c.s = null;
}
c.c = c.e = null;
};
}();
function $(e, i, r, l) {
var o, c, A, n, a, h, u, N = e.c, O = Ue;
if (N) {
e: {
for (o = 1, n = N[0]; n >= 10; n /= 10, o++)
;
if (c = i - o, c < 0)
c += T, A = i, a = N[h = 0], u = W(a / O[o - A - 1] % 10);
else if (h = De((c + 1) / T), h >= N.length)
if (l) {
for (; N.length <= h; N.push(0))
;
a = u = 0, o = 1, c %= T, A = c - T + 1;
} else
break e;
else {
for (a = n = N[h], o = 1; n >= 10; n /= 10, o++)
;
c %= T, A = c - T + o, u = A < 0 ? 0 : W(a / O[o - A - 1] % 10);
}
if (l = l || i < 0 || // Are there any non-zero digits after the rounding digit?
// The expression n % pows10[d - j - 1] returns all digits of n to the right
// of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
N[h + 1] != null || (A < 0 ? a : a % O[o - A - 1]), l = r < 4 ? (u || l) && (r == 0 || r == (e.s < 0 ? 3 : 2)) : u > 5 || u == 5 && (r == 4 || l || r == 6 && // Check whether the digit to the left of the rounding digit is odd.
(c > 0 ? A > 0 ? a / O[o - A] : 0 : N[h - 1]) % 10 & 1 || r == (e.s < 0 ? 8 : 7)), i < 1 || !N[0])
return N.length = 0, l ? (i -= e.e + 1, N[0] = O[(T - i % T) % T], e.e = -i || 0) : N[0] = e.e = 0, e;
if (c == 0 ? (N.length = h, n = 1, h--) : (N.length = h + 1, n = O[T - c], N[h] = A > 0 ? W(a / O[o - A] % O[A]) * n : 0), l)
for (; ; )
if (h == 0) {
for (c = 1, A = N[0]; A >= 10; A /= 10, c++)
;
for (A = N[0] += n, n = 1; A >= 10; A /= 10, n++)
;
c != n && (e.e++, N[0] == z && (N[0] = 1));
break;
} else {
if (N[h] += n, N[h] != z)
break;
N[h--] = 0, n = 1;
}
for (c = N.length; N[--c] === 0; N.pop())
;
}
e.e > K ? e.c = e.e = null : e.e < ne && (e.c = [e.e = 0]);
}
return e;
}
function Z(e) {
var i, r = e.e;
return r === null ? e.toString() : (i = Y(e.c), i = r <= w || r >= G ? Se(i, r) : ee(i, r, "0"), e.s < 0 ? "-" + i : i);
}
return E.absoluteValue = E.abs = function() {
var e = new _(this);
return e.s < 0 && (e.s = 1), e;
}, E.comparedTo = function(e, i) {
return ae(this, new _(e, i));
}, E.decimalPlaces = E.dp = function(e, i) {
var r, l, o, c = this;
if (e != null)
return M(e, 0, x), i == null ? i = C : M(i, 0, 8), $(new _(c), e + c.e + 1, i);
if (!(r = c.c))
return null;
if (l = ((o = r.length - 1) - X(this.e / T)) * T, o = r[o])
for (; o % 10 == 0; o /= 10, l--)
;
return l < 0 && (l = 0), l;
}, E.dividedBy = E.div = function(e, i) {
return s(this, new _(e, i), p, C);
}, E.dividedToIntegerBy = E.idiv = function(e, i) {
return s(this, new _(e, i), 0, 1);
}, E.exponentiatedBy = E.pow = function(e, i) {
var r, l, o, c, A, n, a, h, u, N = this;
if (e = new _(e), e.c && !e.isInteger())
throw Error(k + "Exponent not an integer: " + Z(e));
if (i != null && (i = new _(i)), n = e.e > 14, !N.c || !N.c[0] || N.c[0] == 1 && !N.e && N.c.length == 1 || !e.c || !e.c[0])
return u = new _(Math.pow(+Z(N), n ? e.s * (2 - Ne(e)) : +Z(e))), i ? u.mod(i) : u;
if (a = e.s < 0, i) {
if (i.c ? !i.c[0] : !i.s)
return new _(NaN);
l = !a && N.isInteger() && i.isInteger(), l && (N = N.mod(i));
} else {
if (e.e > 9 && (N.e > 0 || N.e < -1 || (N.e == 0 ? N.c[0] > 1 || n && N.c[1] >= 24e7 : N.c[0] < 8e13 || n && N.c[0] <= 9999975e7)))
return c = N.s < 0 && Ne(e) ? -0 : 0, N.e > -1 && (c = 1 / c), new _(a ? 1 / c : c);
te && (c = De(te / T + 2));
}
for (n ? (r = new _(0.5), a && (e.s = 1), h = Ne(e)) : (o = Math.abs(+Z(e)), h = o % 2), u = new _(m); ; ) {
if (h) {
if (u = u.times(N), !u.c)
break;
c ? u.c.length > c && (u.c.length = c) : l && (u = u.mod(i));
}
if (o) {
if (o = W(o / 2), o === 0)
break;
h = o % 2;
} else if (e = e.times(r), $(e, e.e + 1, 1), e.e > 14)
h = Ne(e);
else {
if (o = +Z(e), o === 0)
break;
h = o % 2;
}
N = N.times(N), c ? N.c && N.c.length > c && (N.c.length = c) : l && (N = N.mod(i));
}
return l ? u : (a && (u = m.div(u)), i ? u.mod(i) : c ? $(u, te, C, A) : u);
}, E.integerValue = function(e) {
var i = new _(this);
return e == null ? e = C : M(e, 0, 8), $(i, i.e + 1, e);
}, E.isEqualTo = E.eq = function(e, i) {
return ae(this, new _(e, i)) === 0;
}, E.isFinite = function() {
return !!this.c;
}, E.isGreaterThan = E.gt = function(e, i) {
return ae(this, new _(e, i)) > 0;
}, E.isGreaterThanOrEqualTo = E.gte = function(e, i) {
return (i = ae(this, new _(e, i))) === 1 || i === 0;
}, E.isInteger = function() {
return !!this.c && X(this.e / T) > this.c.length - 2;
}, E.isLessThan = E.lt = function(e, i) {
return ae(this, new _(e, i)) < 0;
}, E.isLessThanOrEqualTo = E.lte = function(e, i) {
return (i = ae(this, new _(e, i))) === -1 || i === 0;
}, E.isNaN = function() {
return !this.s;
}, E.isNegative = function() {
return this.s < 0;
}, E.isPositive = function() {
return this.s > 0;
}, E.isZero = function() {
return !!this.c && this.c[0] == 0;
}, E.minus = function(e, i) {
var r, l, o, c, A = this, n = A.s;
if (e = new _(e, i), i = e.s, !n || !i)
return new _(NaN);
if (n != i)
return e.s = -i, A.plus(e);
var a = A.e / T, h = e.e / T, u = A.c, N = e.c;
if (!a || !h) {
if (!u || !N)
return u ? (e.s = -i, e) : new _(N ? A : NaN);
if (!u[0] || !N[0])
return N[0] ? (e.s = -i, e) : new _(u[0] ? A : (
// IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
C == 3 ? -0 : 0
));
}
if (a = X(a), h = X(h), u = u.slice(), n = a - h) {
for ((c = n < 0) ? (n = -n, o = u) : (h = a, o = N), o.reverse(), i = n; i--; o.push(0))
;
o.reverse();
} else
for (l = (c = (n = u.length) < (i = N.length)) ? n : i, n = i = 0; i < l; i++)
if (u[i] != N[i]) {
c = u[i] < N[i];
break;
}
if (c && (o = u, u = N, N = o, e.s = -e.s), i = (l = N.length) - (r = u.length), i > 0)
for (; i--; u[r++] = 0)
;
for (i = z - 1; l > n; ) {
if (u[--l] < N[l]) {
for (r = l; r && !u[--r]; u[r] = i)
;
--u[r], u[l] += z;
}
u[l] -= N[l];
}
for (; u[0] == 0; u.splice(0, 1), --h)
;
return u[0] ? Te(e, u, h) : (e.s = C == 3 ? -1 : 1, e.c = [e.e = 0], e);
}, E.modulo = E.mod = function(e, i) {
var r, l, o = this;
return e = new _(e, i), !o.c || !e.s || e.c && !e.c[0] ? new _(NaN) : !e.c || o.c && !o.c[0] ? new _(o) : (le == 9 ? (l = e.s, e.s = 1, r = s(o, e, 0, 3), e.s = l, r.s *= l) : r = s(o, e, 0, le), e = o.minus(r.times(e)), !e.c[0] && le == 1 && (e.s = o.s), e);
}, E.multipliedBy = E.times = function(e, i) {
var r, l, o, c, A, n, a, h, u, N, O, I, g, L, H, U = this, B = U.c, V = (e = new _(e, i)).c;
if (!B || !V || !B[0] || !V[0])
return !U.s || !e.s || B && !B[0] && !V || V && !V[0] && !B ? e.c = e.e = e.s = null : (e.s *= U.s, !B || !V ? e.c = e.e = null : (e.c = [0], e.e = 0)), e;
for (l = X(U.e / T) + X(e.e / T), e.s *= U.s, a = B.length, N = V.length, a < N && (g = B, B = V, V = g, o = a, a = N, N = o), o = a + N, g = []; o--; g.push(0))
;
for (L = z, H = ie, o = N; --o >= 0; ) {
for (r = 0, O = V[o] % H, I = V[o] / H | 0, A = a, c = o + A; c > o; )
h = B[--A] % H, u = B[A] / H | 0, n = I * h + u * O, h = O * h + n % H * H + g[c] + r, r = (h / L | 0) + (n / H | 0) + I * u, g[c--] = h % L;
g[c] = r;
}
return r ? ++l : g.splice(0, 1), Te(e, g, l);
}, E.negated = function() {
var e = new _(this);
return e.s = -e.s || null, e;
}, E.plus = function(e, i) {
var r, l = this, o = l.s;
if (e = new _(e, i), i = e.s, !o || !i)
return new _(NaN);
if (o != i)
return e.s = -i, l.minus(e);
var c = l.e / T, A = e.e / T, n = l.c, a = e.c;
if (!c || !A) {
if (!n || !a)
return new _(o / 0);
if (!n[0] || !a[0])
return a[0] ? e : new _(n[0] ? l : o * 0);
}
if (c = X(c), A = X(A), n = n.slice(), o = c - A) {
for (o > 0 ? (A = c, r = a) : (o = -o, r = n), r.reverse(); o--; r.push(0))
;
r.reverse();
}
for (o = n.length, i = a.length, o - i < 0 && (r = a, a = n, n = r, i = o), o = 0; i; )
o = (n[--i] = n[i] + a[i] + o) / z | 0, n[i] = z === n[i] ? 0 : n[i] % z;
return o && (n = [o].concat(n), ++A), Te(e, n, A);
}, E.precision = E.sd = function(e, i) {
var r, l, o, c = this;
if (e != null && e !== !!e)
return M(e, 1, x), i == null ? i = C : M(i, 0, 8), $(new _(c), e, i);
if (!(r = c.c))
return null;
if (o = r.length - 1, l = o * T + 1, o = r[o]) {
for (; o % 10 == 0; o /= 10, l--)
;
for (o = r[0]; o >= 10; o /= 10, l++)
;
}
return e && c.e + 1 > l && (l = c.e + 1), l;
}, E.shiftedBy = function(e) {
return M(e, -we, we), this.times("1e" + e);
}, E.squareRoot = E.sqrt = function() {
var e, i, r, l, o, c = this, A = c.c, n = c.s, a = c.e, h = p + 4, u = new _("0.5");
if (n !== 1 || !A || !A[0])
return new _(!n || n < 0 && (!A || A[0]) ? NaN : A ? c : 1 / 0);
if (n = Math.sqrt(+Z(c)), n == 0 || n == 1 / 0 ? (i = Y(A), (i.length + a) % 2 == 0 && (i += "0"), n = Math.sqrt(+i), a = X((a + 1) / 2) - (a < 0 || a % 2), n == 1 / 0 ? i = "5e" + a : (i = n.toExponential(), i = i.slice(0, i.indexOf("e") + 1) + a), r = new _(i)) : r = new _(n + ""), r.c[0]) {
for (a = r.e, n = a + h, n < 3 && (n = 0); ; )
if (o = r, r = u.times(o.plus(s(c, o, h, 1))), Y(o.c).slice(0, n) === (i = Y(r.c)).slice(0, n))
if (r.e < a && --n, i = i.slice(n - 3, n + 1), i == "9999" || !l && i == "4999") {
if (!l && ($(o, o.e + p + 2, 0), o.times(o).eq(c))) {
r = o;
break;
}
h += 4, n += 4, l = 1;
} else {
(!+i || !+i.slice(1) && i.charAt(0) == "5") && ($(r, r.e + p + 2, 1), e = !r.times(r).eq(c));
break;
}
}
return $(r, r.e + p + 1, C, e);
}, E.toExponential = function(e, i) {
return e != null && (M(e, 0, x), e++), me(this, e, i, 1);
}, E.toFixed = function(e, i) {
return e != null && (M(e, 0, x), e = e + this.e + 1), me(this, e, i);
}, E.toFormat = function(e, i, r) {
var l, o = this;
if (r == null)
e != null && i && typeof i == "object" ? (r = i, i = null) : e && typeof e == "object" ? (r = e, e = i = null) : r = Ie;
else if (typeof r != "object")
throw Error(k + "Argument not an object: " + r);
if (l = o.toFixed(e, i), o.c) {
var c, A = l.split("."), n = +r.groupSize, a = +r.secondaryGroupSize, h = r.groupSeparator || "", u = A[0], N = A[1], O = o.s < 0, I = O ? u.slice(1) : u, g = I.length;
if (a && (c = n, n = a, a = c, g -= c), n > 0 && g > 0) {
for (c = g % n || n, u = I.substr(0, c); c < g; c += n)
u += h + I.substr(c, n);
a > 0 && (u += h + I.slice(c)), O && (u = "-" + u);
}
l = N ? u + (r.decimalSeparator || "") + ((a = +r.fractionGroupSize) ? N.replace(
new RegExp("\\d{" + a + "}\\B", "g"),
"$&" + (r.fractionGroupSeparator || "")
) : N) : u;
}
return (r.prefix || "") + l + (r.suffix || "");
}, E.toFraction = function(e) {
var i, r, l, o, c, A, n, a, h, u, N, O, I = this, g = I.c;
if (e != null && (n = new _(e), !n.isInteger() && (n.c || n.s !== 1) || n.lt(m)))
throw Error(k + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + Z(n));
if (!g)
return new _(I);
for (i = new _(m), h = r = new _(m), l = a = new _(m), O = Y(g), c = i.e = O.length - I.e - 1, i.c[0] = Ue[(A = c % T) < 0 ? T + A : A], e = !e || n.comparedTo(i) > 0 ? c > 0 ? i : h : n, A = K, K = 1 / 0, n = new _(O), a.c[0] = 0; u = s(n, i, 0, 1), o = r.plus(u.times(l)), o.comparedTo(e) != 1; )
r = l, l = o, h = a.plus(u.times(o = h)), a = o, i = n.minus(u.times(o = i)), n = o;
return o = s(e.minus(r), l, 0, 1), a = a.plus(o.times(h)), r = r.plus(o.times(l)), a.s = h.s = I.s, c = c * 2, N = s(h, l, c, C).minus(I).abs().comparedTo(
s(a, r, c, C).minus(I).abs()
) < 1 ? [h, l] : [a, r], K = A, N;
}, E.toNumber = function() {
return +Z(this);
}, E.toPrecision = function(e, i) {
return e != null && M(e, 1, x), me(this, e, i, 2);
}, E.toString = function(e) {
var i, r = this, l = r.s, o = r.e;
return o === null ? l ? (i = "Infinity", l < 0 && (i = "-" + i)) : i = "NaN" : (e == null ? i = o <= w || o >= G ? Se(Y(r.c), o) : ee(Y(r.c), o, "0") : e === 10 && Re ? (r = $(new _(r), p + o + 1, C), i = ee(Y(r.c), r.e, "0")) : (M(e, 2, oe.length, "Base"), i = f(ee(Y(r.c), o, "0"), 10, e, l, !0)), l < 0 && r.c[0] && (i = "-" + i)), i;
}, E.valueOf = E.toJSON = function() {
return Z(this);
}, E._isBigNumber = !0, E[Symbol.toStringTag] = "BigNumber", E[Symbol.for("nodejs.util.inspect.custom")] = E.valueOf, t != null && _.set(t), _;
}
function X(t) {
var s = t | 0;
return t > 0 || t === s ? s : s - 1;
}
function Y(t) {
for (var s, f, S = 1, E = t.length, m = t[0] + ""; S < E; ) {
for (s = t[S++] + "", f = T - s.length; f--; s = "0" + s)
;
m += s;
}
for (E = m.length; m.charCodeAt(--E) === 48; )
;
return m.slice(0, E + 1 || 1);
}
function ae(t, s) {
var f, S, E = t.c, m = s.c, p = t.s, C = s.s, w = t.e, G = s.e;
if (!p || !C)
return null;
if (f = E && !E[0], S = m && !m[0], f || S)
return f ? S ? 0 : -C : p;
if (p != C)
return p;
if (f = p < 0, S = w == G, !E || !m)
return S ? 0 : !E ^ f ? 1 : -1;
if (!S)
return w > G ^ f ? 1 : -1;
for (C = (w = E.length) < (G = m.length) ? w : G, p = 0; p < C; p++)
if (E[p] != m[p])
return E[p] > m[p] ^ f ? 1 : -1;
return w == G ? 0 : w > G ^ f ? 1 : -1;
}
function M(t, s, f, S) {
if (t < s || t > f || t !== W(t))
throw Error(k + (S || "Argument") + (typeof t == "number" ? t < s || t > f ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(t));
}
function Ne(t) {
var s = t.c.length - 1;
return X(t.e / T) == s && t.c[s] % 2 != 0;
}
function Se(t, s) {
return (t.length > 1 ? t.charAt(0) + "." + t.slice(1) : t) + (s < 0 ? "e" : "e+") + s;
}
function ee(t, s, f) {
var S, E;
if (s < 0) {
for (E = f + "."; ++s; E += f)
;
t = E + t;
} else if (S = t.length, ++s > S) {
for (E = f, s -= S; --s; E += f)
;
t += E;
} else
s < S && (t = t.slice(0, s) + "." + t.slice(s));
return t;
}
var F = He(), _e = /* @__PURE__ */ ((t) => (t[t.ROUND_DOWN = 0] = "ROUND_DOWN", t[t.ROUND_HALF_UP = 1] = "ROUND_HALF_UP", t[t.ROUND_UP = 2] = "ROUND_UP", t))(_e || {}), re = /* @__PURE__ */ ((t) => (t[t.BASE_AMOUNT = 0] = "BASE_AMOUNT", t[t.ASSET_AMOUNT = 1] = "ASSET_AMOUNT", t))(re || {});
const ge = {
0: F.ROUND_DOWN,
1: F.ROUND_HALF_UP,
2: F.ROUND_UP
}, ke = {
groupSeparator: "",
decimalSeparator: "."
}, ce = {
prefix: "",

@@ -67,39 +743,30 @@ decimalSeparator: ".",

};
var p = /* @__PURE__ */ ((t) => (t[t.ROUND_DOWN = 0] = "ROUND_DOWN", t[t.ROUND_HALF_UP = 1] = "ROUND_HALF_UP", t[t.ROUND_UP = 2] = "ROUND_UP", t))(p || {}), _ = /* @__PURE__ */ ((t) => (t[t.BASE_AMOUNT = 0] = "BASE_AMOUNT", t[t.ASSET_AMOUNT = 1] = "ASSET_AMOUNT", t))(_ || {});
const L = {
0: S.ROUND_DOWN,
1: S.ROUND_HALF_UP,
2: S.ROUND_UP
}, Q = {
groupSeparator: "",
decimalSeparator: "."
};
class o {
constructor(s, e = 0, i) {
A(this, "assetAmount");
A(this, "baseAmount");
A(this, "decimal");
this.decimal = i;
const n = 10 ** i;
e === 0 ? (this.baseAmount = new S(s), this.assetAmount = this.baseAmount.dividedBy(n)) : (this.assetAmount = new S(s), this.baseAmount = this.assetAmount.multipliedBy(n)), this.baseAmount = new S(this.baseAmount.integerValue(S.ROUND_DOWN));
class d {
constructor(s, f = 0, S) {
P(this, "assetAmount");
P(this, "baseAmount");
P(this, "decimal");
this.decimal = S;
const E = 10 ** S;
f === 0 ? (this.baseAmount = new F(s), this.assetAmount = this.baseAmount.dividedBy(E)) : (this.assetAmount = new F(s), this.baseAmount = this.assetAmount.multipliedBy(E)), this.baseAmount = new F(this.baseAmount.integerValue(F.ROUND_DOWN));
}
static fromMidgard(s) {
return new o(s || 0, 0, m.THOR);
return new d(s || 0, 0, j.THOR);
}
static fromBaseAmount(s, e) {
return new o(s, 0, e);
static fromBaseAmount(s, f) {
return new d(s, 0, f);
}
static fromAssetAmount(s, e) {
return new o(s, 1, e);
static fromAssetAmount(s, f) {
return new d(s, 1, f);
}
static fromNormalAmount(s) {
return new o(s || 0, 1, 1);
return new d(s || 0, 1, 1);
}
static sorter(s, e) {
if (s.decimal !== e.decimal)
static sorter(s, f) {
if (s.decimal !== f.decimal)
throw new Error("Decimal must be same");
return s.assetAmount.minus(e.assetAmount).toNumber();
return s.assetAmount.minus(f.assetAmount).toNumber();
}
add(s) {
return new o(
return new d(
this.assetAmount.plus(s.assetAmount),

@@ -111,3 +778,3 @@ 1,

sub(s) {
return new o(
return new d(
this.assetAmount.minus(s.assetAmount),

@@ -119,34 +786,34 @@ 1,

mul(s) {
return s instanceof o ? new o(
return s instanceof d ? new d(
this.assetAmount.multipliedBy(s.assetAmount),
1,
this.decimal
) : new o(this.assetAmount.multipliedBy(s), 1, this.decimal);
) : new d(this.assetAmount.multipliedBy(s), 1, this.decimal);
}
div(s) {
return s instanceof o ? new o(
return s instanceof d ? new d(
this.assetAmount.dividedBy(s.assetAmount),
1,
this.decimal
) : new o(this.assetAmount.dividedBy(s), 1, this.decimal);
) : new d(this.assetAmount.dividedBy(s), 1, this.decimal);
}
gte(s) {
return s instanceof o ? this.assetAmount.isGreaterThanOrEqualTo(s.assetAmount) : this.assetAmount.isGreaterThanOrEqualTo(s);
return s instanceof d ? this.assetAmount.isGreaterThanOrEqualTo(s.assetAmount) : this.assetAmount.isGreaterThanOrEqualTo(s);
}
gt(s) {
return s instanceof o ? this.assetAmount.isGreaterThan(s.assetAmount) : this.assetAmount.isGreaterThan(s);
return s instanceof d ? this.assetAmount.isGreaterThan(s.assetAmount) : this.assetAmount.isGreaterThan(s);
}
lte(s) {
return s instanceof o ? this.assetAmount.isLessThanOrEqualTo(s.assetAmount) : this.assetAmount.isLessThanOrEqualTo(s);
return s instanceof d ? this.assetAmount.isLessThanOrEqualTo(s.assetAmount) : this.assetAmount.isLessThanOrEqualTo(s);
}
lt(s) {
return s instanceof o ? this.assetAmount.isLessThan(s.assetAmount) : this.assetAmount.isLessThan(s);
return s instanceof d ? this.assetAmount.isLessThan(s.assetAmount) : this.assetAmount.isLessThan(s);
}
eq(s) {
return s instanceof o ? this.assetAmount.isEqualTo(s.assetAmount) : this.assetAmount.isEqualTo(s);
return s instanceof d ? this.assetAmount.isEqualTo(s.assetAmount) : this.assetAmount.isEqualTo(s);
}
toSignificant(s = 8, e = 8, i = l, n = 0) {
return this.toSignificantBigNumber(s, i, n).decimalPlaces(e).toFormat();
toSignificant(s = 8, f = 8, S = ce, E = 0) {
return this.toSignificantBigNumber(s, S, E).decimalPlaces(f).toFormat();
}
toFixedDecimal(s = 8, e = Q, i = 0) {
toFixedDecimal(s = 8, f = ke, S = 0) {
if (!Number.isInteger(s))

@@ -156,25 +823,25 @@ throw new Error(`${s} is not an integer.`);

throw new Error(`${s} is not positive.`);
return S.config({ FORMAT: e }), new S(this.assetAmount.toFixed(s, L[i])).toFormat();
return F.config({ FORMAT: f }), new F(this.assetAmount.toFixed(s, ge[S])).toFormat();
}
toFixed(s = 8, e = l, i = 0) {
return this.toFixedDecimal(s, e, i);
toFixed(s = 8, f = ce, S = 0) {
return this.toFixedDecimal(s, f, S);
}
toAbbreviate(s = 2) {
let e = this.assetAmount.toNumber();
const i = ["", "K", "M", "B", "T", "Q", "Q", "s"];
let n = 0;
for (; e >= 1e3; )
e /= 1e3, n++;
return `${e.toFixed(s)}${n > 0 ? ` ${i[n]}` : ""}`;
let f = this.assetAmount.toNumber();
const S = ["", "K", "M", "B", "T", "Q", "Q", "s"];
let E = 0;
for (; f >= 1e3; )
f /= 1e3, E++;
return `${f.toFixed(s)}${E > 0 ? ` ${S[E]}` : ""}`;
}
toMidgard() {
return new o(
new S(
this.baseAmount.dividedBy(10 ** this.decimal).multipliedBy(10 ** m.THOR).toFixed()
return new d(
new F(
this.baseAmount.dividedBy(10 ** this.decimal).multipliedBy(10 ** j.THOR).toFixed()
),
0,
m.THOR
j.THOR
);
}
toSignificantBigNumber(s = 8, e = l, i = 0) {
toSignificantBigNumber(s = 8, f = ce, S = 0) {
if (!Number.isInteger(s))

@@ -184,133 +851,27 @@ throw new Error(`${s} is not an integer.`);

throw new Error(`${s} is not positive.`);
return S.config({ FORMAT: e }), new S(this.assetAmount.toPrecision(s, L[i]));
return F.config({ FORMAT: f }), new F(this.assetAmount.toPrecision(s, ge[S]));
}
}
const rt = (t, s = 8, e = 0) => (S.config({ FORMAT: l }), new S(t.toFixed(s, L[e])).toFormat()), K = ({
liquidityUnits: t,
poolUnits: s,
runeDepth: e
}) => o.fromBaseAmount(e, m.THOR).mul(t).div(s), X = ({
liquidityUnits: t,
poolUnits: s,
assetDepth: e
}) => o.fromBaseAmount(e, m.THOR).mul(t).div(s), j = ({
liquidityUnits: t,
poolUnits: s,
runeDepth: e
}) => {
const i = o.fromMidgard(t), n = o.fromBaseAmount(s, m.THOR), c = o.fromBaseAmount(e, m.THOR), E = i.mul(c), h = n.mul(n).mul(2), u = n.mul(i).mul(2), N = i.mul(i), T = n.mul(n).mul(n);
return E.mul(h.sub(u).add(N)).div(T);
}, z = ({
liquidityUnits: t,
poolUnits: s,
assetDepth: e
}) => {
const i = o.fromMidgard(t), n = o.fromBaseAmount(s, m.THOR), c = o.fromBaseAmount(e, m.THOR), E = i.mul(c), h = n.mul(n).mul(2), u = n.mul(i).mul(2), N = i.mul(i), T = E.mul(h.sub(u).add(N)), U = n.mul(n).mul(n);
return T.div(U);
}, ot = ({
percent: t,
runeDepth: s,
liquidityUnits: e,
poolUnits: i
}) => j({ runeDepth: s, liquidityUnits: e, poolUnits: i }).mul(t), at = ({
percent: t,
assetDepth: s,
liquidityUnits: e,
poolUnits: i
}) => z({ assetDepth: s, liquidityUnits: e, poolUnits: i }).mul(t), ct = ({
liquidityUnits: t,
poolUnits: s,
runeDepth: e,
assetDepth: i,
percent: n
}) => ({
assetAmount: X({ liquidityUnits: t, poolUnits: s, assetDepth: i }).mul(n),
runeAmount: K({ liquidityUnits: t, poolUnits: s, runeDepth: e }).mul(n)
}), ut = ({
runeDepth: t,
poolUnits: s,
assetDepth: e,
liquidityUnits: i,
runeAmount: n,
assetAmount: c
}) => {
const E = o.fromBaseAmount(t, m.THOR), h = o.fromBaseAmount(e, m.THOR), u = o.fromBaseAmount(s, m.THOR), N = o.fromBaseAmount(n, m.THOR), T = o.fromBaseAmount(c, m.THOR), U = N.mul(h), C = T.mul(E), F = N.mul(T), G = E.mul(h), $ = u.mul(U.add(C.add(F.mul(2)))), y = U.add(C.add(G.mul(2))), v = $.div(y), H = o.fromMidgard(i).add(v);
if (v.assetAmount.toNumber() === 0)
return H.div(u).assetAmount.toNumber();
const x = u.add(H);
return H.div(x).assetAmount.toNumber();
}, At = ({
runeAmount: t,
assetAmount: s,
runeDepth: e,
assetDepth: i
}) => {
const n = o.fromBaseAmount(e, m.THOR), c = o.fromBaseAmount(i, m.THOR), E = o.fromBaseAmount(s, m.THOR), h = o.fromBaseAmount(t, m.THOR), u = E.mul(n).sub(c.mul(h)), N = c.mul(h).add(n.mul(c));
return u.div(N).assetAmount.absoluteValue().toNumber();
}, J = ({
symbol: t,
ticker: s,
chain: e
}) => e === "ETH" && s !== "ETH" ? `${s}-${t.slice(-3)}` : t, mt = (t, s) => {
switch (t) {
case O.LEAVE:
case O.BOND: {
const { address: e } = s;
return `${t}:${e}`;
}
case O.UNBOND: {
const { address: e, unbondAmount: i } = s;
return `${t}:${e}:${i * 10 ** 8}`;
}
case O.THORNAME_REGISTER: {
const { name: e, chain: i, address: n, owner: c } = s;
return `${t}:${e}:${i}:${n}${c ? `:${c}` : ""}`;
}
case O.DEPOSIT: {
const { chain: e, symbol: i, address: n, singleSide: c } = s;
return c ? `${t}:${e}/${i}::t:0` : `${t}:${e}.${i}:${n || ""}:t:0`;
}
case O.WITHDRAW: {
const { chain: e, ticker: i, symbol: n, basisPoints: c, targetAssetString: E, singleSide: h } = s, u = !h && E ? `:${E}` : "", N = J({ chain: e, symbol: n, ticker: i });
return `${t}:${e}${h ? "/" : "."}${N}:${c}${u}`;
}
case O.OPEN_LOAN:
case O.CLOSE_LOAN: {
const { asset: e, address: i } = s;
return `${t}:${e}:${i}`;
}
default:
return "";
}
}, Z = (t, s) => t === r.Bitcoin ? "Bitcoin" : t === r.Dogecoin ? "Dogecoin" : t === r.Litecoin ? "Litecoin" : t === r.BitcoinCash ? "Bitcoin Cash" : t === r.Ethereum && s === "ETH" ? "Ethereum" : s, Et = (t) => {
if (t < 0)
throw new Error("Invalid number of year");
return 10 + t;
}, ht = (t) => {
if (t.length > 30)
return !1;
const s = /^[a-zA-Z0-9+_-]+$/g;
return !!t.match(s);
}, B = class B {
constructor(s, e, i = !1, n) {
A(this, "chain");
A(this, "symbol");
A(this, "ticker");
A(this, "type");
A(this, "network");
A(this, "name");
A(this, "decimal");
A(this, "isSynth", !1);
A(this, "L1Chain");
A(this, "setDecimal", (s) => {
this.decimal = s || m[this.chain] || m.THOR;
const We = (t, s = 8, f = 0) => (F.config({ FORMAT: ce }), new F(t.toFixed(s, ge[f])).toFormat()), fe = class fe {
constructor(s, f, S = !1, E) {
P(this, "chain");
P(this, "symbol");
P(this, "ticker");
P(this, "type");
P(this, "network");
P(this, "name");
P(this, "decimal");
P(this, "isSynth", !1);
P(this, "L1Chain");
P(this, "setDecimal", (s) => {
this.decimal = s || j[this.chain] || j.THOR;
});
this.chain = s, this.symbol = e.toUpperCase(), this.ticker = n || e.toUpperCase().split("-")[0], this.type = k(s, this.ticker, i), this.name = i ? `Synth ${this.ticker}` : this.ticker, this.network = Z(s, this.ticker), this.decimal = i ? m.THOR : m[s], this.isSynth = i, this.L1Chain = i ? r.THORChain : s;
this.chain = s, this.symbol = f.toUpperCase(), this.ticker = E || f.toUpperCase().split("-")[0], this.type = "Broken - MIGRATION", this.name = S ? `Synth ${this.ticker}` : this.ticker, this.network = "Broken - MIGRATION", this.decimal = S ? j.THOR : j[s], this.isSynth = S, this.L1Chain = S ? D.THORChain : s;
}
static fromAssetString(s) {
var u;
var w;
if (!s)
return null;
const e = s.includes("/"), [i, ...n] = s.split(e ? "/" : "."), c = n.join("."), E = (u = c == null ? void 0 : c.split("-")) == null ? void 0 : u[0];
return i && c && E ? new B(i, c, e) : null;
const f = s.includes("/"), [S, ...E] = s.split(f ? "/" : "."), m = E.join("."), p = (w = m == null ? void 0 : m.split("-")) == null ? void 0 : w[0];
return S && m && p ? new fe(S, m, f) : null;
}

@@ -321,3 +882,3 @@ getAssetObj() {

return {
chain: r.THORChain,
chain: D.THORChain,
symbol: s,

@@ -348,3 +909,3 @@ ticker: s

isRUNE() {
return this.eq(b(r.THORChain));
return this.eq(Pe(D.THORChain));
}

@@ -355,3 +916,3 @@ identifier() {

toSynth() {
return this.isSynth ? this : new B(r.THORChain, `${this.chain}/${this.symbol}`, !0);
return this.isSynth ? this : new fe(D.THORChain, `${this.chain}/${this.symbol}`, !0);
}

@@ -364,104 +925,104 @@ };

*/
A(B, "decodeFromURL", (s) => {
var i, n, c;
let e = s.toUpperCase();
return e.startsWith("THOR.") && ((i = e.split("THOR.")) == null ? void 0 : i[1]) !== "RUNE" && (e = (c = (n = e.split("THOR.")) == null ? void 0 : n[1]) == null ? void 0 : c.replace(".", "/")), B.fromAssetString(e);
P(fe, "decodeFromURL", (s) => {
var S, E, m;
let f = s.toUpperCase();
return f.startsWith("THOR.") && ((S = f.split("THOR.")) == null ? void 0 : S[1]) !== "RUNE" && (f = (m = (E = f.split("THOR.")) == null ? void 0 : E[1]) == null ? void 0 : m.replace(".", "/")), fe.fromAssetString(f);
});
let R = B;
const tt = "THOR-0xa5f2211B9b8170F694421f2046281775E8468044", st = "VTHOR-0x815C23eCA83261b6Ec689b60Cc4a58b54BC24D8D", d = {}, b = (t, s = !1) => {
if (d[t])
return d[t];
let b = fe;
const be = "THOR-0xa5f2211B9b8170F694421f2046281775E8468044", $e = "VTHOR-0x815C23eCA83261b6Ec689b60Cc4a58b54BC24D8D", Q = {}, Pe = (t, s = !1) => {
if (Q[t])
return Q[t];
switch (t) {
case r.Avalanche:
case r.Binance:
case r.Bitcoin:
case r.BitcoinCash:
case r.Dogecoin:
case r.Ethereum:
case r.Litecoin: {
const e = new R(t, t, s);
return d[t] = e, e;
case D.Avalanche:
case D.Binance:
case D.Bitcoin:
case D.BitcoinCash:
case D.Dogecoin:
case D.Ethereum:
case D.Litecoin: {
const f = new b(t, t, s);
return Q[t] = f, f;
}
case r.Optimism:
case r.Arbitrum: {
const e = new R(t, r.Ethereum, s);
return e.setDecimal(18), d[t] = e, e;
case D.Optimism:
case D.Arbitrum: {
const f = new b(t, D.Ethereum, s);
return f.setDecimal(18), Q[t] = f, f;
}
case r.BinanceSmartChain: {
const e = new R(t, r.Binance, s);
return e.setDecimal(18), d[t] = e, e;
case D.BinanceSmartChain: {
const f = new b(t, D.Binance, s);
return f.setDecimal(18), Q[t] = f, f;
}
case r.Polygon: {
const e = new R(t, t, s);
return e.setDecimal(18), d[t] = e, e;
case D.Polygon: {
const f = new b(t, t, s);
return f.setDecimal(18), Q[t] = f, f;
}
case r.Cosmos: {
const e = new R(t, I.ATOM, s, I.ATOM);
return d[t] = e, e;
case D.Cosmos: {
const f = new b(t, "ATOM", s, "ATOM");
return Q[t] = f, f;
}
case r.THORChain: {
const e = new R(r.THORChain, I.RUNE, s, I.RUNE);
return d[t] = e, e;
case D.THORChain: {
const f = new b(D.THORChain, "RUNE", s, "RUNE");
return Q[t] = f, f;
}
case "USD": {
const e = new R(r.THORChain, "USD-USD", s, "USD-USD");
return d[t] = e, e;
const f = new b(D.THORChain, "USD-USD", s, "USD-USD");
return Q[t] = f, f;
}
case "ETH_THOR": {
const e = new R(r.Ethereum, tt, s);
return e.setDecimal(18), d[t] = e, e;
const f = new b(D.Ethereum, be, s);
return f.setDecimal(18), Q[t] = f, f;
}
case "ETH_VTHOR": {
const e = new R(r.Ethereum, st, s);
return e.setDecimal(18), d[t] = e, e;
const f = new b(D.Ethereum, $e, s);
return f.setDecimal(18), Q[t] = f, f;
}
default:
return new R(r.THORChain, I.RUNE, s, I.RUNE);
return new b(D.THORChain, "RUNE", s, "RUNE");
}
}, St = (t) => t.eq(b(t.chain)), f = (t, s) => s.find((e) => t.shallowEq(e.asset));
class et extends o {
}, Xe = (t) => t.eq(Pe(t.chain)), Ae = (t, s) => s.find((f) => t.shallowEq(f.asset));
class qe extends d {
constructor({
baseAsset: e,
quoteAsset: i,
unitPrice: n,
pools: c,
priceAmount: E
baseAsset: f,
quoteAsset: S,
unitPrice: E,
pools: m,
priceAmount: p
}) {
const h = o.fromAssetAmount(
E ? E.assetAmount : 1,
e.decimal
const C = d.fromAssetAmount(
p ? p.assetAmount : 1,
f.decimal
);
super(h.assetAmount, _.ASSET_AMOUNT, e.decimal);
A(this, "baseAsset");
A(this, "quoteAsset");
A(this, "unitPrice");
A(this, "price");
A(this, "amount");
if (this.amount = h, this.baseAsset = e, this.quoteAsset = i, n !== void 0)
this.unitPrice = n, this.price = h.assetAmount.multipliedBy(n);
super(C.assetAmount, re.ASSET_AMOUNT, f.decimal);
P(this, "baseAsset");
P(this, "quoteAsset");
P(this, "unitPrice");
P(this, "price");
P(this, "amount");
if (this.amount = C, this.baseAsset = f, this.quoteAsset = S, E !== void 0)
this.unitPrice = E, this.price = C.assetAmount.multipliedBy(E);
else {
if (!c)
if (!m)
throw new Error("Pools must be provided if unitPrice omitted");
if (this.unitPrice = new S(0), i)
if (e.isRUNE() && !i.isRUNE()) {
const u = f(i, c);
u && (this.unitPrice = u.runePriceInAsset.assetAmount);
} else if (!e.isRUNE() && i.isRUNE()) {
const u = f(e, c);
u && (this.unitPrice = u.assetPriceInRune.assetAmount);
} else if (!e.isRUNE() && !i.isRUNE()) {
const u = f(e, c), N = f(i, c);
u && N && (this.unitPrice = u.assetPriceInRune.div(
N.assetPriceInRune
if (this.unitPrice = new F(0), S)
if (f.isRUNE() && !S.isRUNE()) {
const w = Ae(S, m);
w && (this.unitPrice = w.runePriceInAsset.assetAmount);
} else if (!f.isRUNE() && S.isRUNE()) {
const w = Ae(f, m);
w && (this.unitPrice = w.assetPriceInRune.assetAmount);
} else if (!f.isRUNE() && !S.isRUNE()) {
const w = Ae(f, m), G = Ae(S, m);
w && G && (this.unitPrice = w.assetPriceInRune.div(
G.assetPriceInRune
).assetAmount);
} else
this.unitPrice = new S(1);
else if (e.isRUNE()) {
const u = c == null ? void 0 : c[0];
u && (this.unitPrice = u.runePriceInAsset.mul(u.assetUSDPrice).assetAmount);
this.unitPrice = new F(1);
else if (f.isRUNE()) {
const w = m == null ? void 0 : m[0];
w && (this.unitPrice = w.runePriceInAsset.mul(w.assetUSDPrice).assetAmount);
} else {
const u = f(e, c);
u && (this.unitPrice = u.assetUSDPrice.assetAmount);
const w = Ae(f, m);
w && (this.unitPrice = w.assetUSDPrice.assetAmount);
}
this.price = this.unitPrice.multipliedBy(h.assetAmount);
this.price = this.unitPrice.multipliedBy(C.assetAmount);
}

@@ -473,107 +1034,107 @@ }

invert() {
return new S(1).dividedBy(this.raw());
return new F(1).dividedBy(this.raw());
}
toCurrencyFormat(e = 8, i = !0) {
var E;
const n = i ? this.toAbbreviateRaw(e) : this.toFixedRaw(e);
return !this.quoteAsset || this.quoteAsset.ticker === "USD" ? `$${n}` : `${n} ${(E = this.quoteAsset) == null ? void 0 : E.ticker}`;
toCurrencyFormat(f = 8, S = !0) {
var p;
const E = S ? this.toAbbreviateRaw(f) : this.toFixedRaw(f);
return !this.quoteAsset || this.quoteAsset.ticker === "USD" ? `$${E}` : `${E} ${(p = this.quoteAsset) == null ? void 0 : p.ticker}`;
}
toAbbreviateRaw(e = 2) {
return o.fromAssetAmount(this.price, 8).toAbbreviate(e);
toAbbreviateRaw(f = 2) {
return d.fromAssetAmount(this.price, 8).toAbbreviate(f);
}
toFixedRaw(e = 8, i = l, n = p.ROUND_DOWN) {
return o.fromAssetAmount(this.price, 8).toFixed(e, i, n);
toFixedRaw(f = 8, S = ce, E = _e.ROUND_DOWN) {
return d.fromAssetAmount(this.price, 8).toFixed(f, S, E);
}
toFixedInverted(e = 8, i = l, n = p.ROUND_DOWN) {
return o.fromAssetAmount(this.invert(), 8).toFixed(e, i, n);
toFixedInverted(f = 8, S = ce, E = _e.ROUND_DOWN) {
return d.fromAssetAmount(this.invert(), 8).toFixed(f, S, E);
}
}
class D extends o {
constructor(e, i) {
super(i.assetAmount, _.ASSET_AMOUNT, i.decimal);
A(this, "asset");
A(this, "amount");
this.asset = e, this.amount = new o(i.assetAmount, _.ASSET_AMOUNT, i.decimal);
class ue extends d {
constructor(f, S) {
super(S.assetAmount, re.ASSET_AMOUNT, S.decimal);
P(this, "asset");
P(this, "amount");
this.asset = f, this.amount = new d(S.assetAmount, re.ASSET_AMOUNT, S.decimal);
}
add(e) {
if (!this.asset.shallowEq(e.asset))
add(f) {
if (!this.asset.shallowEq(f.asset))
throw new Error("asset must be same");
return new D(this.asset, this.amount.add(e.amount));
return new ue(this.asset, this.amount.add(f.amount));
}
sub(e) {
if (!this.asset.shallowEq(e.asset))
sub(f) {
if (!this.asset.shallowEq(f.asset))
throw new Error("asset must be same");
return new D(this.asset, this.amount.sub(e.amount));
return new ue(this.asset, this.amount.sub(f.amount));
}
mul(e) {
let i;
return e instanceof o ? i = new o(
this.assetAmount.multipliedBy(e.assetAmount),
_.ASSET_AMOUNT,
mul(f) {
let S;
return f instanceof d ? S = new d(
this.assetAmount.multipliedBy(f.assetAmount),
re.ASSET_AMOUNT,
this.decimal
) : i = new o(
this.assetAmount.multipliedBy(e),
_.ASSET_AMOUNT,
) : S = new d(
this.assetAmount.multipliedBy(f),
re.ASSET_AMOUNT,
this.decimal
), new D(this.asset, i);
), new ue(this.asset, S);
}
div(e) {
let i;
return e instanceof o ? i = new o(
this.assetAmount.dividedBy(e.assetAmount),
_.ASSET_AMOUNT,
div(f) {
let S;
return f instanceof d ? S = new d(
this.assetAmount.dividedBy(f.assetAmount),
re.ASSET_AMOUNT,
this.decimal
) : i = new o(this.assetAmount.dividedBy(e), _.ASSET_AMOUNT, this.decimal), new D(this.asset, i);
) : S = new d(this.assetAmount.dividedBy(f), re.ASSET_AMOUNT, this.decimal), new ue(this.asset, S);
}
toCurrencyFormat({
significantDigits: e,
format: i,
rounding: n
significantDigits: f,
format: S,
rounding: E
} = {
significantDigits: 6,
format: l,
rounding: p.ROUND_DOWN
}, c = !1) {
const E = super.toSignificant(e, 8, i, n);
return c ? `${this.asset.ticker} ${E}` : `${E} ${this.asset.ticker}`;
format: ce,
rounding: _e.ROUND_DOWN
}, m = !1) {
const p = super.toSignificant(f, 8, S, E);
return m ? `${this.asset.ticker} ${p}` : `${p} ${this.asset.ticker}`;
}
totalPriceIn(e, i) {
return new et({
totalPriceIn(f, S) {
return new qe({
baseAsset: this.asset,
quoteAsset: e,
pools: i,
priceAmount: o.fromAssetAmount(this.assetAmount, this.decimal)
quoteAsset: f,
pools: S,
priceAmount: d.fromAssetAmount(this.assetAmount, this.decimal)
});
}
}
const Nt = (t) => {
const s = b(t), e = [r.Bitcoin, r.Litecoin, r.BitcoinCash].includes(t) ? (
const Ke = (t) => {
const s = Pe(t), f = [D.Bitcoin, D.Litecoin, D.BitcoinCash].includes(t) ? (
// 10001 satoshi
10001
) : [r.Dogecoin].includes(t) ? (
) : [D.Dogecoin].includes(t) ? (
// 1 DOGE
100000001
) : [r.Avalanche, r.Ethereum, r.BinanceSmartChain].includes(t) ? (
) : [D.Avalanche, D.Ethereum, D.BinanceSmartChain].includes(t) ? (
// 10 gwei
10 * 10 ** 9
) : t === r.THORChain ? (
) : t === D.THORChain ? (
// 0 RUNE
0
) : 1;
return new D(s, o.fromBaseAmount(e, s.decimal));
return new ue(s, d.fromBaseAmount(f, s.decimal));
};
class V {
constructor(s, e, i, n) {
A(this, "asset");
A(this, "runeDepth");
A(this, "assetDepth");
A(this, "assetUSDPrice");
A(this, "detail");
this.asset = s, this.runeDepth = e, this.assetDepth = i, this.detail = n, this.assetUSDPrice = o.fromAssetAmount(n.assetPriceUSD, m.THOR);
class xe {
constructor(s, f, S, E) {
P(this, "asset");
P(this, "runeDepth");
P(this, "assetDepth");
P(this, "assetUSDPrice");
P(this, "detail");
this.asset = s, this.runeDepth = f, this.assetDepth = S, this.detail = E, this.assetUSDPrice = d.fromAssetAmount(E.assetPriceUSD, j.THOR);
}
static fromPoolData(s) {
const { asset: e, runeDepth: i, assetDepth: n } = s, c = R.fromAssetString(e);
if (c && i && n) {
const E = o.fromBaseAmount(i, m.THOR), h = o.fromBaseAmount(n, m.THOR);
return new V(c, E, h, s);
const { asset: f, runeDepth: S, assetDepth: E } = s, m = b.fromAssetString(f);
if (m && S && E) {
const p = d.fromBaseAmount(S, j.THOR), C = d.fromBaseAmount(E, j.THOR);
return new xe(m, p, C, s);
}

@@ -590,29 +1151,16 @@ return null;

export {
o as Amount,
_ as AmountType,
D as AssetAmount,
R as AssetEntity,
l as BN_FORMAT,
Q as EMPTY_FORMAT,
V as Pool,
et as Price,
p as Rounding,
rt as formatBigNumber,
X as getAssetShare,
k as getAssetType,
z as getAsymmetricAssetShare,
at as getAsymmetricAssetWithdrawAmount,
j as getAsymmetricRuneShare,
ot as getAsymmetricRuneWithdrawAmount,
ut as getEstimatedPoolShare,
At as getLiquiditySlippage,
mt as getMemoFor,
Nt as getMinAmountByChain,
Z as getNetworkName,
K as getRuneShare,
b as getSignatureAssetFor,
ct as getSymmetricWithdraw,
Et as getTHORNameCost,
St as isGasAsset,
ht as validateTHORName
d as Amount,
re as AmountType,
ue as AssetAmount,
b as AssetEntity,
ce as BN_FORMAT,
ke as EMPTY_FORMAT,
xe as Pool,
qe as Price,
_e as Rounding,
We as formatBigNumber,
Ke as getMinAmountByChain,
Pe as getSignatureAssetFor,
Xe as isGasAsset
};
//# sourceMappingURL=index.es.js.map
{
"author": "thorswap",
"author": "swapkit-oss-team",
"dependencies": {
"bignumber.js": "9.1.2",
"tiny-invariant": "1.3.1",
"@thorswap-lib/types": "0.0.0-nightly-20231130150356"
"@swapkit/types": "0.0.0-nightly-20240208140027"
},
"description": "THORSwap Lib swapkit-entities",
"description": "SwapKit Lib swapkit-entities",
"devDependencies": {
"@vitest/coverage-istanbul": "0.34.3",
"bignumber.js": "9.1.2",
"vite": "4.4.9",
"vitest": "0.34.3",
"@internal/config": "0.0.0-nightly-20231130150356"
"@vitest/coverage-istanbul": "1.2.1",
"vite": "5.0.12",
"vitest": "1.2.1",
"@internal/config": "0.0.0-nightly-20240208140027"
},
"eslintConfig": {
"extends": "../../../internal/eslint-config-thorswap"
"extends": "../../../internal/eslint-config"
},

@@ -30,24 +30,21 @@ "exports": {

"homepage": "https://github.com/thorswap/SwapKit",
"license": "MIT",
"license": "Apache-2.0",
"main": "./dist/index.cjs",
"module": "./dist/index.es.js",
"name": "@thorswap-lib/swapkit-entities",
"peerDependencies": {
"bignumber.js": "^9.1.2"
"react-native": "./src/index.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/thorswap/SwapKit.git"
},
"publishConfig": {
"access": "public"
},
"react-native": "./src/index.ts",
"repository": "https://github.com/thorswap/SwapKit.git",
"type": "module",
"types": "./dist/index.d.ts",
"version": "0.0.0-nightly-20231130150356",
"version": "0.0.0-nightly-20240208140027",
"scripts": {
"build": "vite build",
"clean": "rm -rf dist .turbo node_modules",
"clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
"lint": "eslint ./ --ext .ts,.tsx --fix; tsc --noEmit",
"test": "vitest --run",
"test:coverage": "vitest run --coverage"
"test": "echo 'vitest --run'",
"test:coverage": "echo 'vitest run --coverage'"
}
}

@@ -1,6 +0,4 @@

import { BaseDecimal } from '@thorswap-lib/types';
import { BaseDecimal } from '@swapkit/types';
import { BigNumber } from 'bignumber.js';
import { BN_FORMAT } from '../helpers/asset.ts';
export enum Rounding {

@@ -28,2 +26,13 @@ ROUND_DOWN,

export const BN_FORMAT = {
prefix: '',
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3,
secondaryGroupSize: 0,
fractionGroupSeparator: ' ',
fractionGroupSize: 0,
suffix: '',
};
export class Amount {

@@ -30,0 +39,0 @@ public readonly assetAmount: BigNumber;

@@ -1,5 +0,3 @@

import { AssetSymbol, BaseDecimal, Chain } from '@thorswap-lib/types';
import { BaseDecimal, Chain } from '@swapkit/types';
import { getAssetType, getNetworkName } from '../helpers/index.ts';
/**

@@ -56,5 +54,5 @@ * L1 asset format:

this.ticker = ticker || symbol.toUpperCase().split('-')[0];
this.type = getAssetType(chain, this.ticker, isSynth);
this.type = 'Broken - MIGRATION';
this.name = isSynth ? `Synth ${this.ticker}` : this.ticker;
this.network = getNetworkName(chain, this.ticker);
this.network = 'Broken - MIGRATION';
this.decimal = isSynth ? BaseDecimal.THOR : BaseDecimal[chain];

@@ -136,4 +134,3 @@ this.isSynth = isSynth;

// @ts-expect-error initialized in getSignatureAssetFor
const cachedSignatureAssets: Record<Signature, AssetEntity> = {};
const cachedSignatureAssets = {} as Record<Signature, AssetEntity>;
export const getSignatureAssetFor = (signature: Signature, synth: boolean = false) => {

@@ -182,3 +179,3 @@ if (cachedSignatureAssets[signature]) return cachedSignatureAssets[signature];

case Chain.Cosmos: {
const asset = new AssetEntity(signature, AssetSymbol.ATOM, synth, AssetSymbol.ATOM);
const asset = new AssetEntity(signature, 'ATOM', synth, 'ATOM');

@@ -190,3 +187,3 @@ cachedSignatureAssets[signature] = asset;

case Chain.THORChain: {
const asset = new AssetEntity(Chain.THORChain, AssetSymbol.RUNE, synth, AssetSymbol.RUNE);
const asset = new AssetEntity(Chain.THORChain, 'RUNE', synth, 'RUNE');

@@ -221,3 +218,3 @@ cachedSignatureAssets[signature] = asset;

default: {
return new AssetEntity(Chain.THORChain, AssetSymbol.RUNE, synth, AssetSymbol.RUNE);
return new AssetEntity(Chain.THORChain, 'RUNE', synth, 'RUNE');
}

@@ -224,0 +221,0 @@ }

@@ -1,7 +0,5 @@

import { Chain } from '@thorswap-lib/types';
import { Chain } from '@swapkit/types';
import type { BigNumber } from 'bignumber.js';
import { BN_FORMAT } from '../helpers/asset.ts';
import { Amount, AmountType, Rounding } from './amount.ts';
import { Amount, AmountType, BN_FORMAT, Rounding } from './amount.ts';
import type { AssetEntity } from './asset.ts';

@@ -112,13 +110,13 @@ import { getSignatureAssetFor } from './asset.ts';

: [Chain.Dogecoin].includes(chain)
? // 1 DOGE
100000001
: [Chain.Avalanche, Chain.Ethereum, Chain.BinanceSmartChain].includes(chain)
? // 10 gwei
10 * 10 ** 9
: chain === Chain.THORChain
? // 0 RUNE
0
: 1;
? // 1 DOGE
100000001
: [Chain.Avalanche, Chain.Ethereum, Chain.BinanceSmartChain].includes(chain)
? // 10 gwei
10 * 10 ** 9
: chain === Chain.THORChain
? // 0 RUNE
0
: 1;
return new AssetAmount(asset, Amount.fromBaseAmount(minAmount, asset.decimal));
};

@@ -1,2 +0,2 @@

import { BaseDecimal } from '@thorswap-lib/types';
import { BaseDecimal } from '@swapkit/types';

@@ -3,0 +3,0 @@ import { Amount } from './amount.ts';

import { BigNumber } from 'bignumber.js';
import { BN_FORMAT } from '../helpers/asset.ts';
import { Amount, AmountType, Rounding } from './amount.ts';
import { Amount, AmountType, BN_FORMAT, Rounding } from './amount.ts';
import type { AssetEntity as Asset, AssetEntity } from './asset.ts';

@@ -7,0 +5,0 @@ import type { Pool } from './pool.ts';

@@ -6,2 +6,1 @@ export * from './entities/amount.ts';

export * from './entities/price.ts';
export * from './helpers/index.ts';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc