@myx-trade/sdk 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var ca=Object.defineProperty;var Ut=a=>{throw TypeError(a)};var et=(a,e)=>{for(var t in e)ca(a,t,{get:e[t],enumerable:!0})};var qt=(a,e,t)=>e.has(a)||Ut("Cannot "+t);var Gt=(a,e,t)=>(qt(a,e,"read from private field"),t?t.call(a):e.get(a)),Wt=(a,e,t)=>e.has(a)?Ut("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,t),zt=(a,e,t,n)=>(qt(a,e,"write to private field"),n?n.call(a,t):e.set(a,t),t);var Et={};et(Et,{claimBasePoolRebate:()=>Pn,claimBasePoolRebates:()=>Rn,deposit:()=>Sn,getLpPrice:()=>Bn,getRewards:()=>_n,previewUserWithdrawData:()=>vn,withdraw:()=>Nn,withdrawableLpAmount:()=>Fn});import{getContract as k}from"viem";var Vt=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"DifferentMarket",inputs:[{type:"bytes32",name:"fromPoolId"},{type:"bytes32",name:"toPoolId"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InsufficientQuoteIn",inputs:[{type:"uint256",name:"orderId"},{type:"uint256",name:"quoteIn"},{type:"uint256",name:"exchangeDelta"}]},{type:"error",name:"InvalidAmount",inputs:[{type:"uint256",name:"amount"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidLiquidityAmount",inputs:[]},{type:"error",name:"InvalidTpsl",inputs:[{type:"uint256",name:"orderId"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"NotReachedPrice",inputs:[{type:"uint256",name:"orderId"},{type:"uint256",name:"price"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"SamePoolMigration",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"SlippageExceeded",inputs:[{type:"uint256",name:"expected"},{type:"uint256",name:"actual"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"addTpsl",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"poolType"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"cancelTpsl",constant:!1,payable:!1,inputs:[{type:"uint256",name:"orderId"}],outputs:[]},{type:"function",name:"claimBasePoolRebate",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimBasePoolRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimBasePoolRebates",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimBasePoolRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebate",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebates",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"currentOrderId",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"depositBase",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"depositBase",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"depositQuote",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"depositQuote",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"executeTpsl",constant:!1,payable:!1,inputs:[{type:"uint256",name:"orderId"},{type:"uint256",name:"quoteInIfNecessary"},{type:"uint256",name:"minOut"}],outputs:[{type:"uint256",name:"baseOut"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"executeTpsl",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"uint256",name:"orderId"},{type:"uint256",name:"quoteInIfNecessary"},{type:"uint256",name:"minOut"}],outputs:[{type:"uint256",name:"baseOut"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getTpslData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"orderId"}],outputs:[{type:"tuple",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"poolType"},{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]},{type:"function",name:"getUserTpslOrderIds",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"migrateLiquidity",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"fromPoolId"},{type:"bytes32",name:"toPoolId"},{type:"uint256",name:"amount"},{type:"uint256",name:"minLpOut"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdrawBase",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"withdrawBase",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"withdrawQuote",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"withdrawQuote",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]}];import{createPublicClient as ga,fallback as ba,http as Yt}from"viem";var z=(r=>(r[r.LINEA_SEPOLIA=59141]="LINEA_SEPOLIA",r[r.LINEA_MAINNET=59144]="LINEA_MAINNET",r[r.ARB_TESTNET=421614]="ARB_TESTNET",r[r.ARB_MAINNET=42161]="ARB_MAINNET",r[r.BSC_TESTNET=97]="BSC_TESTNET",r[r.BSC_MAINNET=56]="BSC_MAINNET",r))(z||{});var fa=[421614,59141,97,42161,59144,56];function Te(a){return!!a&&fa.includes(a)}var G=10;var U={42161:130n,421614:130n,59144:130n,59141:130n,56:150n,97:150n};var $t={chainId:59141,chainInfo:{explorer:"https://sepolia.lineascan.build/",explorerOfTX:"https://sepolia.lineascan.build/tx/",publicJsonRPCUrl:["https://rpc.sepolia.linea.build","https://linea-sepolia.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"],label:"Linea Sepolia",logoUrl:"",faucetUrl:"",chainSymbol:"Linea",gasPriceRatio:1.3,gasLimitRatio:1.2,gasAmountRatio:2,gasFeeReservedForCollateral:(.525+1)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var Ht={chainId:421614,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://sepolia-rollup.arbitrum.io/rpc"],label:" Arbitrum Sepolia",chainSymbol:"Arb Sepolia",explorer:"https://sepolia.arbiscan.io/",explorerOfTX:"https://sepolia.arbiscan.io/tx/",faucetUrl:"https://bwarelabs.com/faucets/arbitrum-sepolia",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(.055+1)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var Qt={chainId:97,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://bsc-testnet-dataseed.bnbchain.org"],label:"BNB Chain Testnet",chainSymbol:"BNB Chain Testnet",explorer:"https://testnet.bscscan.com/",explorerOfTX:"https://testnet.bscscan.com/tx/",faucetUrl:"https://docs.bnbchain.org/bnb-smart-chain/developers/faucet/",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(5e-4+1)*G,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var Kt={chainId:59144,chainInfo:{label:"Linea Mainnet",explorer:"https://lineascan.build/",logoUrl:"",explorerOfTX:"https://lineascan.build/tx/",publicJsonRPCUrl:["https://rpc.linea.build/","https://linea.blockpi.network/v1/rpc/public","https://1rpc.io/linea","https://rpc.linea.build"],chainSymbol:"Linea",gasPriceRatio:1.3,gasLimitRatio:1.2,gasAmountRatio:2,gasFeeReservedForCollateral:(.525+.35)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var Jt={chainId:42161,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://arb1.arbitrum.io/rpc"],label:" Arbitrum One",chainSymbol:"Arbitrum One",explorer:"https://arbiscan.io/",explorerOfTX:"https://arbiscan.io/tx/",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(.055+.175)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var jt={chainId:56,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://bsc-dataseed.bnbchain.org"],label:"BNB Chain",chainSymbol:"BNB Chain",explorer:"https://bscscan.com/",explorerOfTX:"https://bscscan.com/tx/",faucetUrl:"https://docs.bnbchain.org/bnb-smart-chain/developers/faucet/",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(5e-4+1)*G,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var C={59141:$t.chainInfo,421614:Ht.chainInfo,97:Qt.chainInfo,59144:Kt.chainInfo,42161:Jt.chainInfo,56:jt.chainInfo};function ue(a){let e=C[a];if(!e)throw new Error(`Could not find information with chain id ${a}`);return e}var tt={};function Ia(a){if(!tt[a]){let e=ue(a),t=[...e.privateJsonRPCUrl?[e.privateJsonRPCUrl]:[],...Array.isArray(e.publicJsonRPCUrl)?[...e.publicJsonRPCUrl]:[]].filter(Boolean);if(t.length===0)throw new Error(`${a} has no jsonRPCUrl configured`);tt[a]={id:a,name:e.label||`Chain ${a}`,nativeCurrency:e.nativeCurrency,rpcUrls:{default:{http:t}}}}return tt[a]}var nt={};function c(a){if(!nt[a]){let e=ue(a),t=[...e.privateJsonRPCUrl?[e.privateJsonRPCUrl]:[],...Array.isArray(e.publicJsonRPCUrl)?[...e.publicJsonRPCUrl]:[]].filter(Boolean);if(t.length===0)throw new Error(`${a} has no jsonRPCUrl configured`);let n=t.length===1?Yt(t[0]):ba(t.map(s=>Yt(s)));nt[a]=ga({chain:Ia(a),transport:n})}return nt[a]}var Xt=null;function ve(a){Xt=a}async function M(a){let e=Xt;if(!e?.hasSigner())throw new Error("No signer: call auth({ signer }) or auth({ walletClient })");return e.getViemWalletClient(a)}var at=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"BaseFeeNotSoldOut",inputs:[]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidBaseToken",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"LPNotFullyMinted",inputs:[]},{type:"error",name:"MarketNotExist",inputs:[{type:"bytes32",name:"marketId"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"PoolDebtNotCleared",inputs:[]},{type:"error",name:"PoolExists",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotExist",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PositionNotEmpty",inputs:[]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"error",name:"UnexpectedPoolState",inputs:[]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"benchPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"checkPoolExists",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bool"}]},{type:"function",name:"deployPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"marketId"},{type:"address",name:"baseToken"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getMarketPool",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"address",name:"asset"}],outputs:[{type:"tuple",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"state"},{type:"bool",name:"compoundEnabled"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"},{type:"address",name:"poolVault"},{type:"address",name:"tradingVault"}]}]},{type:"function",name:"getPairToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"}]},{type:"function",name:"getPool",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"tuple",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"state"},{type:"bool",name:"compoundEnabled"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"},{type:"address",name:"poolVault"},{type:"address",name:"tradingVault"}]}]},{type:"function",name:"getPoolMarket",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bytes32",name:"marketId"},{type:"tuple",components:[{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"},{type:"uint128",name:"executionFee"},{type:"uint128",name:"maxExecutionFee"},{type:"uint128",name:"forwardFee"},{type:"uint128",name:"maxForwardFee"}]}]},{type:"function",name:"getPoolMarketExecutionFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"executionFee"}]},{type:"function",name:"getPoolMarketForwardFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"forwardFee"}]},{type:"function",name:"getPoolMarketId",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bytes32",name:"marketId"}]},{type:"function",name:"getPoolRiskTier",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint8"}]},{type:"function",name:"getPoolVault",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address"}]},{type:"function",name:"getPools",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32[]",name:"pools"}]},{type:"function",name:"getTradingVault",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isPoolAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"addr"}],outputs:[{type:"bool"}]},{type:"function",name:"perBenchPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"primePool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"referencePrice"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"reprimePool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"}]}],outputs:[]},{type:"function",name:"trenchPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bytes32",name:"oracleFeedId"},{type:"uint32",name:"oracleDecimals"},{type:"uint8",name:"oracleType"},{type:"uint8",name:"riskTier"}]}],outputs:[]},{type:"function",name:"updatePoolCompoundEnabled",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bool",name:"enabled"}]}],outputs:[]},{type:"function",name:"updatePoolRiskTiers",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"riskTier"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var q=[{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"},{internalType:"uint8",name:"decimals_",type:"uint8"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];var st=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InsufficientOutputAmount",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"PoolNotActive",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotExist",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeCastOverflowedUintToInt",inputs:[{type:"uint256",name:"value"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"QuotePoolProfitDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"uint256",name:"genesisAmount",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"EXCHANGE_RATE_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"POOL_TOKEN_DECIMALS",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"REBATE_INDEX_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimUserRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"rebateOut"}]},{type:"function",name:"claimUserRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256[]",name:"rebateOut"}]},{type:"function",name:"deposit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"}]},{type:"function",name:"distribute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amount"},{type:"uint256",name:"genesisAmount"},{type:"uint256",name:"price"}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"genesisRebateIndex"}]}]},{type:"function",name:"getPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getUserData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"index"},{type:"uint256",name:"accrued"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"pendingUserRebates",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewLpAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"quoteAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewQuoteAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewUserWithdrawData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"quoteAmountOut"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updatePool",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"oraclePrice"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdraw",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"},{type:"uint256",name:"rebateOut"}]},{type:"function",name:"withdrawableLpAmount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]}];var it=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ExceedMaxProfit",inputs:[]},{type:"error",name:"ExceedMinOutputAmount",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InsufficientOutputAmount",inputs:[]},{type:"error",name:"InsufficientReturnAmount",inputs:[{type:"uint256",name:"expected"},{type:"uint256",name:"received"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"PoolNotActive",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotCompoundable",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotExist",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeCastOverflowedUintToInt",inputs:[{type:"uint256",name:"value"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"BasePoolProfitDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:!0},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1},{type:"uint256",name:"rebateIndex",indexed:!1},{type:"uint256",name:"genesisRebateIndex",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolProfitExchanged",inputs:[{type:"bytes32",name:"poolId",indexed:!0},{type:"uint256",name:"baseIn",indexed:!1},{type:"uint256",name:"quoteOut",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"address",name:"recipient",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolRebateIndexUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:!0},{type:"uint256",name:"unexchangedProfits",indexed:!1},{type:"uint256",name:"oldIndex",indexed:!1},{type:"uint256",name:"newIndex",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"EXCHANGE_RATE_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"POOL_TOKEN_DECIMALS",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"REBATE_INDEX_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimUserRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"rebateOut"}]},{type:"function",name:"claimUserRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256[]",name:"rebateOut"}]},{type:"function",name:"deposit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"}]},{type:"function",name:"distribute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"},{type:"uint256",name:"genesisAmount"},{type:"uint256",name:"price"}],outputs:[]},{type:"function",name:"exchangeProfit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseIn"},{type:"uint256",name:"minQuoteOut"},{type:"address",name:"recipient"},{type:"bytes",name:"data"}],outputs:[{type:"uint256",name:"quoteOut"}]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeableProfit",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"baseIn"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"rebateIndex"},{type:"uint256",name:"genesisRebateIndex"},{type:"uint256",name:"exchangeableProfits"}]}]},{type:"function",name:"getPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getUserData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"index"},{type:"uint256",name:"genesisIndex"},{type:"uint256",name:"accrued"},{type:"uint256",name:"genesisAccrued"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"pendingUserRebates",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"rebates"},{type:"uint256",name:"genesisRebates"}]},{type:"function",name:"previewBaseAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewExchangeableProfit",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"baseIn"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"previewLpAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewUserWithdrawData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"baseAmountOut"},{type:"uint256",name:"rebateAmount"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updatePool",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"oraclePrice"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdraw",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"},{type:"uint256",name:"rebateOut"}]},{type:"function",name:"withdrawableLpAmount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]}];var rt=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ECDSAInvalidSignature",inputs:[]},{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{type:"uint256",name:"length"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{type:"bytes32",name:"s"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ExpiredFeeData",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidFeeRate",inputs:[]},{type:"error",name:"InvalidFeeTier",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"NoRebateToClaim",inputs:[]},{type:"error",name:"NotActiveBroker",inputs:[{type:"address",name:"broker"}]},{type:"error",name:"NotBrokerSigner",inputs:[{type:"address",name:"signer"}]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotOrderOwner",inputs:[]},{type:"error",name:"NotPositionOwner",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{type:"address",name:"owner"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{type:"address",name:"account"}]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"error",name:"UnsupportedAssetClass",inputs:[{type:"uint8",name:"assetClass"}]},{type:"error",name:"UnsupportedFeeTier",inputs:[{type:"uint8",name:"tier"}]},{type:"event",anonymous:!1,name:"BrokerStatusUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"bool",name:"isActive",indexed:!1}]},{type:"event",anonymous:!1,name:"EIP712DomainChanged",inputs:[]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"OwnershipTransferStarted",inputs:[{type:"address",name:"previousOwner",indexed:!0},{type:"address",name:"newOwner",indexed:!0}]},{type:"event",anonymous:!1,name:"OwnershipTransferred",inputs:[{type:"address",name:"previousOwner",indexed:!0},{type:"address",name:"newOwner",indexed:!0}]},{type:"event",anonymous:!1,name:"RebateClaimed",inputs:[{type:"address",name:"user",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"SignerUpdated",inputs:[{type:"address",name:"signer",indexed:!1},{type:"bool",name:"isSigner",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"UserFeeDataReset",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"signer",indexed:!1},{type:"uint256",name:"epoch",indexed:!1}]},{type:"event",anonymous:!1,name:"UserFeeDataUpdated",inputs:[{type:"address",name:"broker",indexed:!0},{type:"address",name:"signer",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint256",name:"epoch",indexed:!1},{type:"uint8",name:"tier",indexed:!1},{type:"address",name:"referrer",indexed:!1},{type:"uint32",name:"totalReferralRebatePct",indexed:!1},{type:"uint32",name:"referrerRebatePct",indexed:!1}]},{type:"function",name:"FEE_TYPEHASH",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"acceptOwnership",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"activeFeeTiers",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"activeSpecialFeeTierList",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"addressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"batchSetSpecialFeeTiers",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]}],outputs:[]},{type:"function",name:"batchUpdateFeeTiers",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"tuple",name:"addOnFeeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}]}],outputs:[]},{type:"function",name:"cancelOrder",constant:!1,payable:!1,inputs:[{type:"uint256",name:"orderId"}],outputs:[]},{type:"function",name:"cancelOrders",constant:!1,payable:!1,inputs:[{type:"uint256[]",name:"orderIds"}],outputs:[]},{type:"function",name:"claimRebate",constant:!1,payable:!1,inputs:[{type:"address",name:"token"}],outputs:[]},{type:"function",name:"claimRebates",constant:!1,payable:!1,inputs:[{type:"address[]",name:"tokens"}],outputs:[]},{type:"function",name:"currentFeeDataEpoch",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"domainSeparatorV4",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"eip712Domain",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes1",name:"fields"},{type:"string",name:"name"},{type:"string",name:"version"},{type:"uint256",name:"chainId"},{type:"address",name:"verifyingContract"},{type:"bytes32",name:"salt"},{type:"uint256[]",name:"extensions"}]},{type:"function",name:"getAddOnFeeTier",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"}],outputs:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]},{type:"function",name:"getBaseFeeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"}],outputs:[{type:"tuple",name:"baseFeeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getSpecialFeeTier",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"}],outputs:[{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]},{type:"function",name:"getUserFeeDataDigest",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"uint64",name:"nonce"},{type:"uint64",name:"deadline"},{type:"tuple",name:"feeData",components:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]}],outputs:[{type:"bytes32",name:"digest"}]},{type:"function",name:"getUserFeeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"baseTakerFeeRate"},{type:"uint32",name:"baseMakerFeeRate"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"_addressManager"},{type:"address",name:"owner"},{type:"string",name:"_brokerName"},{type:"address[]",name:"brokerSigners"},{type:"uint8[]",name:"assetClasses"},{type:"tuple[]",name:"baseFeeRates",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}],outputs:[]},{type:"function",name:"isActive",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bool"}]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"name",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"onBrokerFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"token"},{type:"uint256",name:"feeAmount"}],outputs:[{type:"uint256",name:"totalReferralRebate"},{type:"uint256",name:"referrerRebate"},{type:"address",name:"referrer"}]},{type:"function",name:"owner",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"pendingOwner",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"placeOrderWithPosition",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"bytes32",name:"positionId"},{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"tuple",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"placeOrderWithSalt",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"uint64",name:"userPositionSalt"},{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"tuple",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"placeOrdersWithPosition",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"bytes32[]",name:"positionIds"},{type:"tuple[]",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"placeOrdersWithSalt",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"uint64[]",name:"userPositionSalts"},{type:"tuple[]",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"renounceOwnership",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"resetAllUserFeeData",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"setSigner",constant:!1,payable:!1,inputs:[{type:"address",name:"signer"},{type:"bool",name:"isSigner"}],outputs:[]},{type:"function",name:"setSpecialFeeTier",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]}],outputs:[]},{type:"function",name:"setUserFeeData",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"uint64",name:"nonce"},{type:"uint64",name:"deadline"},{type:"tuple",name:"feeData",components:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]},{type:"bytes",name:"signature"}]}],outputs:[]},{type:"function",name:"setUserSpecialFeeTier",constant:!1,payable:!1,inputs:[{type:"address",name:"user"},{type:"uint8",name:"feeTier"}],outputs:[]},{type:"function",name:"supportedAssetClasses",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256[]"}]},{type:"function",name:"transferOwnership",constant:!1,payable:!1,inputs:[{type:"address",name:"newOwner"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateBaseFeeRates",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"bool",name:"isEnable"},{type:"tuple",name:"baseFeeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}]}],outputs:[]},{type:"function",name:"updateBrokerStatus",constant:!1,payable:!1,inputs:[{type:"bool",name:"active"}],outputs:[]},{type:"function",name:"updateFeeTier",constant:!1,payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"tuple",name:"feeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}],outputs:[]},{type:"function",name:"updateOrder",constant:!1,payable:!1,inputs:[{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"tuple",name:"tpsl",components:[{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}]}],outputs:[]},{type:"function",name:"updatePriceAndAdjustCollateral",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"bytes32",name:"positionId"},{type:"int256",name:"adjustAmount"}],outputs:[]},{type:"function",name:"updateUserFeeData",constant:!1,payable:!1,inputs:[{type:"address",name:"user"},{type:"tuple",name:"feeData",components:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"userFeeData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"userFeeDataEpoch"},{type:"address",name:"user"}],outputs:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]},{type:"function",name:"userNonces",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"}],outputs:[{type:"uint64",name:"nonce"}]},{type:"function",name:"userRebates",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"address",name:"token"}],outputs:[{type:"uint256",name:"rebateAmount"}]}];var ot=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"ERC20InsufficientAllowance",inputs:[{type:"address",name:"spender"},{type:"uint256",name:"allowance"},{type:"uint256",name:"needed"}]},{type:"error",name:"ERC20InsufficientBalance",inputs:[{type:"address",name:"sender"},{type:"uint256",name:"balance"},{type:"uint256",name:"needed"}]},{type:"error",name:"ERC20InvalidApprover",inputs:[{type:"address",name:"approver"}]},{type:"error",name:"ERC20InvalidReceiver",inputs:[{type:"address",name:"receiver"}]},{type:"error",name:"ERC20InvalidSender",inputs:[{type:"address",name:"sender"}]},{type:"error",name:"ERC20InvalidSpender",inputs:[{type:"address",name:"spender"}]},{type:"error",name:"InsufficientBalance",inputs:[{type:"address",name:"account"},{type:"uint256",name:"balance"},{type:"uint256",name:"needed"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"event",anonymous:!1,name:"Approval",inputs:[{type:"address",name:"owner",indexed:!0},{type:"address",name:"spender",indexed:!0},{type:"uint256",name:"value",indexed:!1}]},{type:"event",anonymous:!1,name:"GenesisShareBurned",inputs:[{type:"address",name:"account",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"GenesisShareMinted",inputs:[{type:"address",name:"account",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"Transfer",inputs:[{type:"address",name:"from",indexed:!0},{type:"address",name:"to",indexed:!0},{type:"uint256",name:"value",indexed:!1}]},{type:"function",name:"addressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"allowance",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"owner"},{type:"address",name:"spender"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",constant:!1,payable:!1,inputs:[{type:"address",name:"spender"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"uint256"}]},{type:"function",name:"burnFrom",constant:!1,payable:!1,inputs:[{type:"address",name:"from"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"decimals",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"_addressManager"},{type:"bytes32",name:"_poolId"},{type:"address",name:"_underlyingToken"},{type:"string",name:"name"},{type:"string",name:"symbol"}],outputs:[]},{type:"function",name:"mint",constant:!1,payable:!1,inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"name",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"poolId",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"symbol",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalGenesisShare",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"totalSupply",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",constant:!1,payable:!1,inputs:[{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",constant:!1,payable:!1,inputs:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"underlyingToken",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"userGenesisShare",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"uint256"}]}];var pt=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"InvalidQuoteTokenAddress",inputs:[]},{type:"error",name:"InvalidRatioParams",inputs:[]},{type:"error",name:"MarketAlreadyExisted",inputs:[]},{type:"error",name:"MarketNotExisted",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"ExecutionFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldExecutionFee",indexed:!1},{type:"uint256",name:"newExecutionFee",indexed:!1}]},{type:"event",anonymous:!1,name:"ForwardFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldForwardFee",indexed:!1},{type:"uint256",name:"newForwardFee",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"MaxExecutionFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldMaxExecutionFee",indexed:!1},{type:"uint256",name:"newMaxExecutionFee",indexed:!1}]},{type:"event",anonymous:!1,name:"MaxForwardFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldMaxForwardFee",indexed:!1},{type:"uint256",name:"newMaxForwardFee",indexed:!1}]},{type:"event",anonymous:!1,name:"OracleFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint64",name:"newOracleFeeUsd",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolPrimeThresholdUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint128",name:"newPoolPrimeThreshold",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveRatioUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint32",name:"newBaseReserveRatio",indexed:!1},{type:"uint32",name:"newQuoteReserveRatio",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"createMarket",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint64",name:"chainId"},{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"},{type:"uint128",name:"executionFee"},{type:"uint128",name:"maxExecutionFee"},{type:"uint128",name:"forwardFee"},{type:"uint128",name:"maxForwardFee"}]},{type:"tuple",name:"quoteParams",components:[{type:"address",name:"priceContract"},{type:"bool",name:"applyExchangeRate"},{type:"uint16",name:"minDeviationRatio"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExecutionFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExecutionFeeByToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"quoteToken"}],outputs:[{type:"uint256"}]},{type:"function",name:"getForwardFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getForwardFeeByToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"quoteToken"}],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getMarket",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"tuple",components:[{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"},{type:"uint128",name:"executionFee"},{type:"uint128",name:"maxExecutionFee"},{type:"uint128",name:"forwardFee"},{type:"uint128",name:"maxForwardFee"}]}]},{type:"function",name:"getMarketIds",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32[]"}]},{type:"function",name:"getOracleFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"marketExists",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"bool"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updateExecutionFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_executionFee"}],outputs:[]},{type:"function",name:"updateForwardFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_forwardFee"}],outputs:[]},{type:"function",name:"updateMarketQuoteConfiguration",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"tuple",name:"quoteParams",components:[{type:"address",name:"priceContract"},{type:"bool",name:"applyExchangeRate"},{type:"uint16",name:"minDeviationRatio"}]}],outputs:[]},{type:"function",name:"updateMaxExecutionFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_maxExecutionFee"}],outputs:[]},{type:"function",name:"updateMaxForwardFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_maxForwardFee"}],outputs:[]},{type:"function",name:"updateOracleFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint64",name:"_oracleFeeUsd"}],outputs:[]},{type:"function",name:"updatePoolPrimeThreshold",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_poolPrimeThreshold"}],outputs:[]},{type:"function",name:"updateReserveRatio",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint32",name:"_baseReserveRatio"},{type:"uint32",name:"_quoteReserveRatio"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var ut=[{type:"constructor",payable:!1,inputs:[{type:"address",name:"addressManager"}]},{type:"error",name:"PositionNotHealthy",inputs:[{type:"bytes32",name:"positionId"},{type:"uint256",name:"marginRatio"}]},{type:"error",name:"SafeCastOverflowedUintToInt",inputs:[{type:"uint256",name:"value"}]},{type:"function",name:"ADDRESS_MANAGER",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getAccountInfo",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"}],outputs:[{type:"tuple",name:"accountInfo",components:[{type:"uint256",name:"freeMargin"},{type:"uint256",name:"walletBalance"},{type:"uint256",name:"freeBaseAmount"},{type:"uint256",name:"baseProfit"},{type:"uint256",name:"quoteProfit"},{type:"uint256",name:"reservedAmount"},{type:"uint64",name:"releaseTime"}]}]},{type:"function",name:"getAvailableLiquiditySize",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"executePrice"}],outputs:[{type:"uint256"}]},{type:"function",name:"getBrokerFeeTiers",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"brokerAddress"},{type:"uint8[]",name:"assetClasses"},{type:"uint8[]",name:"riskTiers"},{type:"bool",name:"isMYXBroker"}],outputs:[{type:"tuple[]",name:"brokerFees",components:[{type:"uint8",name:"asset"},{type:"tuple[]",name:"riskTieredBrokerFees",components:[{type:"uint8",name:"riskTier"},{type:"tuple[]",name:"addOnFeeTiers",components:[{type:"uint8",name:"tier"},{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"}]},{type:"tuple[]",name:"baseFeeRate",components:[{type:"uint8",name:"assetClass"},{type:"uint32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]},{type:"tuple[]",name:"specialFeeTiers",components:[{type:"uint8",name:"tier"},{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"}]}]}]}]},{type:"function",name:"getExchangeables",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"uint256[]",name:"marketPrices"}],outputs:[{type:"tuple[]",name:"exchangeables",components:[{type:"uint256",name:"maxBaseIn"},{type:"uint256",name:"maxQuoteIn"},{type:"uint256",name:"maxBaseOut"},{type:"uint256",name:"maxQuoteOut"}]}]},{type:"function",name:"getLiquidationPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"positionId"},{type:"uint256",name:"marketPrice"},{type:"address",name:"broker"}],outputs:[{type:"uint256"}]},{type:"function",name:"getPoolInfo",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"marketPrice"}],outputs:[{type:"tuple",components:[{type:"tuple",name:"basePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"quotePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"reserveInfo",components:[{type:"uint256",name:"baseTotalAmount"},{type:"uint256",name:"baseReservedAmount"},{type:"uint256",name:"quoteTotalAmount"},{type:"uint256",name:"quoteReservedAmount"}]},{type:"tuple",name:"fundingInfo",components:[{type:"int256",name:"nextFundingRate"},{type:"int256",name:"lastFundingFeeTracker"},{type:"uint256",name:"nextEpochTime"}]},{type:"tuple",name:"oi",components:[{type:"int256",name:"tracker"},{type:"uint256",name:"longSize"},{type:"uint256",name:"shortSize"},{type:"uint256",name:"poolEntryPrice"}]},{type:"tuple",name:"liquidityInfo",components:[{type:"uint256",name:"windowCaps"},{type:"int256",name:"openInterest"}]}]}]},{type:"function",name:"getPoolInfos",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"uint256[]",name:"marketPrices"}],outputs:[{type:"tuple[]",components:[{type:"tuple",name:"basePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"quotePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"reserveInfo",components:[{type:"uint256",name:"baseTotalAmount"},{type:"uint256",name:"baseReservedAmount"},{type:"uint256",name:"quoteTotalAmount"},{type:"uint256",name:"quoteReservedAmount"}]},{type:"tuple",name:"fundingInfo",components:[{type:"int256",name:"nextFundingRate"},{type:"int256",name:"lastFundingFeeTracker"},{type:"uint256",name:"nextEpochTime"}]},{type:"tuple",name:"oi",components:[{type:"int256",name:"tracker"},{type:"uint256",name:"longSize"},{type:"uint256",name:"shortSize"},{type:"uint256",name:"poolEntryPrice"}]},{type:"tuple",name:"liquidityInfo",components:[{type:"uint256",name:"windowCaps"},{type:"int256",name:"openInterest"}]}]}]},{type:"function",name:"getPoolTokenPrices",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"uint256[]",name:"marketPrices"}],outputs:[{type:"tuple[]",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"basePoolTokenPrice"},{type:"uint256",name:"quotePoolTokenPrice"}]}]},{type:"function",name:"getPositionFees",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"positionId"},{type:"address",name:"broker"},{type:"uint256",name:"price"}],outputs:[{type:"int256",name:"netCollateral"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"tradingFee"},{type:"int256",name:"fundingFee"}]},{type:"function",name:"getSumProfitLock",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address[]",name:"respondents"}],outputs:[{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"},{type:"tuple[]",name:"infos",components:[{type:"address",name:"account"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}]}]},{type:"function",name:"getUserPositionInfos",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"bytes32[]",name:"poolIds"}],outputs:[{type:"tuple[]",name:"positions",components:[{type:"bytes32",name:"positionId"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"size"},{type:"uint256",name:"entryPrice"},{type:"int256",name:"fundingRateIndex"},{type:"uint256",name:"earlyClosePrice"},{type:"uint8",name:"direction"},{type:"uint8",name:"riskTier"},{type:"uint64",name:"lastUpdateTime"},{type:"uint256",name:"collateralAmount"}]}]}];var Ie=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ERC2771ForwarderExpiredRequest",inputs:[{type:"uint48",name:"deadline"}]},{type:"error",name:"ERC2771ForwarderInvalidSigner",inputs:[{type:"address",name:"signer"},{type:"address",name:"from"}]},{type:"error",name:"ERC2771ForwarderMismatchedValue",inputs:[{type:"uint256",name:"requestedValue"},{type:"uint256",name:"msgValue"}]},{type:"error",name:"ERC2771UntrustfulTarget",inputs:[{type:"address",name:"target"},{type:"address",name:"forwarder"}]},{type:"error",name:"ExceedsMaximumRelayFee",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InconsistentParamsLength",inputs:[]},{type:"error",name:"InsufficientBalance",inputs:[{type:"uint256",name:"balance"},{type:"uint256",name:"needed"}]},{type:"error",name:"InsufficientFeeAllowance",inputs:[{type:"address",name:"user"},{type:"uint256",name:"allowance"},{type:"uint256",name:"required"}]},{type:"error",name:"InsufficientFeeBalance",inputs:[{type:"address",name:"user"},{type:"uint256",name:"balance"},{type:"uint256",name:"required"}]},{type:"error",name:"InvalidAccountNonce",inputs:[{type:"address",name:"account"},{type:"uint256",name:"currentNonce"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"MismatchExecuteFee",inputs:[{type:"uint256",name:"balanceBefore"},{type:"uint256",name:"balanceAfter"},{type:"uint256",name:"expected"}]},{type:"error",name:"MismatchedSender",inputs:[{type:"address",name:"sender"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotAllowedTarget",inputs:[{type:"address",name:"target"}]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"OnlyRelayer",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"RelayerRegistered",inputs:[{type:"address",name:"relayer"}]},{type:"error",name:"RemoveRelayerFailed",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"AddAllowedTarget",inputs:[{type:"address",name:"target",indexed:!1}]},{type:"event",anonymous:!1,name:"ChargeForwardFee",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"feeToken",indexed:!1},{type:"uint256",name:"relayFee",indexed:!1}]},{type:"event",anonymous:!1,name:"EIP712DomainChanged",inputs:[]},{type:"event",anonymous:!1,name:"ERC20PermitFailed",inputs:[{type:"address",name:"token",indexed:!1},{type:"string",name:"reason",indexed:!1}]},{type:"event",anonymous:!1,name:"ERC20PermitLowLevelFailed",inputs:[{type:"bytes",name:"data",indexed:!1}]},{type:"event",anonymous:!1,name:"ExecutedForwardRequest",inputs:[{type:"address",name:"signer",indexed:!0},{type:"uint256",name:"nonce",indexed:!1},{type:"bool",name:"success",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"RemoveAllowedTarget",inputs:[{type:"address",name:"target",indexed:!1}]},{type:"event",anonymous:!1,name:"SetUserRelayer",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"relayer",indexed:!1},{type:"bool",name:"enable",indexed:!1}]},{type:"event",anonymous:!1,name:"UpdateAcquiescentFeeToken",inputs:[{type:"address",name:"sender",indexed:!1},{type:"address",name:"oldRelayGas",indexed:!1},{type:"address",name:"newRelayGas",indexed:!1}]},{type:"event",anonymous:!1,name:"UpdateEquilibriumGas",inputs:[{type:"address",name:"sender",indexed:!1},{type:"uint256",name:"oldRelayGas",indexed:!1},{type:"uint256",name:"newRelayGas",indexed:!1}]},{type:"event",anonymous:!1,name:"UpdateMaxRelayFee",inputs:[{type:"address",name:"sender",indexed:!1},{type:"uint256",name:"oldMaxRelayFee",indexed:!1},{type:"uint256",name:"newMaxRelayFee",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"addAllowedTarget",constant:!1,payable:!1,inputs:[{type:"address",name:"target"}],outputs:[]},{type:"function",name:"batchExecuteForwarder",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"forwardFeeToken"},{type:"tuple[]",name:"bundleParams",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]}],outputs:[]},{type:"function",name:"eip712Domain",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes1",name:"fields"},{type:"string",name:"name"},{type:"string",name:"version"},{type:"uint256",name:"chainId"},{type:"address",name:"verifyingContract"},{type:"bytes32",name:"salt"},{type:"uint256[]",name:"extensions"}]},{type:"function",name:"equilibriumGas",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"execute",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]},{type:"address"}],outputs:[]},{type:"function",name:"executeBatch",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]},{type:"address"},{type:"address"}],outputs:[]},{type:"function",name:"executeForwarder",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"forwardFeeToken"},{type:"tuple",name:"params",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]}],outputs:[]},{type:"function",name:"exitForwardMode",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getAllowedTargets",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address[]"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getDesignatedToken",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getEquilibriumGas",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getUserRelayers",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"address[]"}]},{type:"function",name:"inForwardMode",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bool"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"},{type:"uint256",name:"_equilibriumGas"}],outputs:[]},{type:"function",name:"isAllowedTargets",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"contractAddr"}],outputs:[{type:"bool"}]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"isUserRelayerEnabled",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"address",name:"relayer"}],outputs:[{type:"bool"}]},{type:"function",name:"nonces",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"originAccount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"relayer"}],outputs:[{type:"address",name:"account"}]},{type:"function",name:"permitAndApproveForwarder",constant:!1,payable:!1,inputs:[{type:"address",name:"relayer"},{type:"bool",name:"enable"},{type:"tuple[]",name:"permitParams",components:[{type:"address",name:"token"},{type:"address",name:"owner"},{type:"address",name:"spender"},{type:"uint256",name:"value"},{type:"uint256",name:"deadline"},{type:"uint8",name:"v"},{type:"bytes32",name:"r"},{type:"bytes32",name:"s"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"removeAllowedTarget",constant:!1,payable:!1,inputs:[{type:"address",name:"target"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateEquilibriumGas",constant:!1,payable:!1,inputs:[{type:"uint256",name:"_equilibriumGas"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"verify",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"tuple",name:"request",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]}],outputs:[{type:"bool"}]}];var dt=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"AlreadyClaimed",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"user"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidAmount",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"user"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"MerkleTreeVerificationFailed",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"user"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"ReimbursementValidity",inputs:[{type:"uint256",name:"caseId"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"TreeAlreadySet",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementClaimExpired",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementClaimed",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementInfoSet",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"bytes32",name:"merkleRoot",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"totalBaseAmount",indexed:!1},{type:"uint256",name:"totalQuoteAmount",indexed:!1},{type:"uint256",name:"claimedBaseAmount",indexed:!1},{type:"uint256",name:"claimedQuoteAmount",indexed:!1},{type:"uint256",name:"expireTime",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimExpiredCases",constant:!1,payable:!1,inputs:[{type:"uint256[]",name:"caseIds"},{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"claimReimbursement",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"},{type:"bytes32[]",name:"merkleProof"}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getReimbursementInfo",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[{type:"tuple",components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"setReimbursementInfo",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"tuple",name:"reimbursementInfo",components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]},{type:"bytes32[]",name:"zeroMerkleProof"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var xe=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"AlreadyVoted",inputs:[]},{type:"error",name:"BondNotReleased",inputs:[]},{type:"error",name:"CaseAppealNotFinished",inputs:[]},{type:"error",name:"CaseDeadlineNotReached",inputs:[]},{type:"error",name:"CaseDeadlineReached",inputs:[]},{type:"error",name:"CaseNotAccepted",inputs:[]},{type:"error",name:"CaseNotExist",inputs:[{type:"uint256",name:"caseId"}]},{type:"error",name:"CaseRespondentAppealed",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"respondent"}]},{type:"error",name:"ChainIdMismatch",inputs:[]},{type:"error",name:"DisputeNotAllowed",inputs:[]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidAccountNonce",inputs:[{type:"address",name:"account"},{type:"uint256",name:"currentNonce"}]},{type:"error",name:"InvalidContractAddress",inputs:[]},{type:"error",name:"InvalidFunctionSignature",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"InvalidPayloadLength",inputs:[{type:"uint256",name:"received"},{type:"uint256",name:"expected"}]},{type:"error",name:"InvalidPoolToken",inputs:[]},{type:"error",name:"InvalidProfitAmount",inputs:[]},{type:"error",name:"InvalidResponseVersion",inputs:[]},{type:"error",name:"InvalidSourceChain",inputs:[]},{type:"error",name:"NoChainResponse",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotCaseRespondent",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"respondent"}]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"NumberOfResponsesMismatch",inputs:[]},{type:"error",name:"OnlyRelayer",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"RequestTypeMismatch",inputs:[]},{type:"error",name:"RiskCloseNotCompleted",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"SignatureExpired",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"error",name:"UnexpectedCaseState",inputs:[]},{type:"error",name:"UnexpectedCaseType",inputs:[]},{type:"error",name:"UnexpectedNumberOfResults",inputs:[]},{type:"error",name:"UnsupportedQueryType",inputs:[{type:"uint8",name:"received"}]},{type:"error",name:"UntrustfulVoting",inputs:[]},{type:"error",name:"VerificationFailed",inputs:[]},{type:"error",name:"VersionMismatch",inputs:[]},{type:"error",name:"WrongQueryType",inputs:[{type:"uint8",name:"received"},{type:"uint8",name:"expected"}]},{type:"error",name:"ZeroQueries",inputs:[]},{type:"event",anonymous:!1,name:"AppealCanceled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"appealCaseId",indexed:!1},{type:"address",name:"complainant",indexed:!1},{type:"bool",name:"isMalicious",indexed:!1}]},{type:"event",anonymous:!1,name:"AppealFiled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"appealCaseId",indexed:!1},{type:"address",name:"respondent",indexed:!1},{type:"address",name:"appealToken",indexed:!1},{type:"uint256",name:"appealBond",indexed:!1},{type:"uint64",name:"appealDeadline",indexed:!1}]},{type:"event",anonymous:!1,name:"AppealResolved",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"appealCaseId",indexed:!1},{type:"uint8",name:"resolution",indexed:!1},{type:"address",name:"complainant",indexed:!1}]},{type:"event",anonymous:!1,name:"BondClaimed",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"CaseAppealsResolved",inputs:[{type:"uint256",name:"caseId",indexed:!1}]},{type:"event",anonymous:!1,name:"CaseRiskClosed",inputs:[{type:"uint256",name:"caseId",indexed:!1}]},{type:"event",anonymous:!1,name:"DisputeCanceled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"complainant",indexed:!1},{type:"bool",name:"isMalicious",indexed:!1}]},{type:"event",anonymous:!1,name:"DisputeConfigurationUpdated",inputs:[{type:"tuple",name:"newDisputeConfigration",indexed:!1,components:[{type:"address",name:"appealToken"},{type:"uint64",name:"disputeBondUsd"},{type:"uint64",name:"appealBondUsd"},{type:"uint64",name:"disputeThresholdUsd"},{type:"uint64",name:"caseDuration"},{type:"uint64",name:"voteDuration"},{type:"uint64",name:"resolveDuration"},{type:"uint32",name:"voteCountRate"},{type:"uint32",name:"effectiveVoteRate"}]}]},{type:"event",anonymous:!1,name:"DisputeFiled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"complainant",indexed:!1},{type:"address",name:"poolToken",indexed:!1},{type:"uint256",name:"disputeBond",indexed:!1},{type:"uint64",name:"caseDeadline",indexed:!1}]},{type:"event",anonymous:!1,name:"DisputeResolved",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint8",name:"resolution",indexed:!1},{type:"uint64",name:"appealDeadline",indexed:!1}]},{type:"event",anonymous:!1,name:"ForfeitBondsClaimed",inputs:[{type:"address",name:"receiver",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementProcessed",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"tuple",name:"reimbursementInfo",indexed:!1,components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"Voted",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"voter",indexed:!1},{type:"uint8",name:"voteOption",indexed:!1}]},{type:"event",anonymous:!1,name:"VotingOpened",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"evidenceId",indexed:!1},{type:"uint64",name:"voteDeadline",indexed:!1},{type:"address[]",name:"respondents",indexed:!1}]},{type:"event",anonymous:!1,name:"WormholeConfigurationUpdated",inputs:[{type:"tuple",name:"newWormholeConfiguration",indexed:!1,components:[{type:"address",name:"wormhole"},{type:"address",name:"staker"},{type:"bytes4",name:"selector"}]}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"appeal",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"canRiskControlClose",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[{type:"bool"}]},{type:"function",name:"cancelAppeal",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"appealCaseId"},{type:"bool",name:"isMalicious"}],outputs:[]},{type:"function",name:"cancelDispute",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"bool",name:"isMalicious"}],outputs:[]},{type:"function",name:"caseIdSequencer",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"checkRiskControlCloseCompleted",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"claimBond",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"claimForfeitBonds",constant:!1,payable:!1,inputs:[{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"fileDispute",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32",name:"poolId"},{type:"address",name:"poolToken"}],outputs:[]},{type:"function",name:"fileDisputeFromStaker",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"bytes",name:"response"},{type:"tuple[]",name:"guardianSignatures",components:[{type:"bytes32",name:"r"},{type:"bytes32",name:"s"},{type:"uint8",name:"v"},{type:"uint8",name:"guardianIndex"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getDisputeConfiguration",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"tuple",components:[{type:"address",name:"appealToken"},{type:"uint64",name:"disputeBondUsd"},{type:"uint64",name:"appealBondUsd"},{type:"uint64",name:"disputeThresholdUsd"},{type:"uint64",name:"caseDuration"},{type:"uint64",name:"voteDuration"},{type:"uint64",name:"resolveDuration"},{type:"uint32",name:"voteCountRate"},{type:"uint32",name:"effectiveVoteRate"}]}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isCaseRespondents",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"account"}],outputs:[{type:"bool"}]},{type:"function",name:"nonces",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"openVoting",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"evidenceId"},{type:"address[]",name:"respondents"}],outputs:[]},{type:"function",name:"processReimbursement",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"tuple",name:"reimbursementInfo",components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]},{type:"bytes32[]",name:"zeroMerkleProof"}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"resolveCaseAppeals",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"bytes",name:"response"},{type:"tuple[]",name:"guardianSignatures",components:[{type:"bytes32",name:"r"},{type:"bytes32",name:"s"},{type:"uint8",name:"v"},{type:"uint8",name:"guardianIndex"}]}],outputs:[]},{type:"function",name:"resolveDispute",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"bytes",name:"response"},{type:"tuple[]",name:"guardianSignatures",components:[{type:"bytes32",name:"r"},{type:"bytes32",name:"s"},{type:"uint8",name:"v"},{type:"uint8",name:"guardianIndex"}]}],outputs:[]},{type:"function",name:"updateDisputeConfiguration",constant:!1,payable:!1,inputs:[{type:"tuple",name:"disputeConfiguration",components:[{type:"address",name:"appealToken"},{type:"uint64",name:"disputeBondUsd"},{type:"uint64",name:"appealBondUsd"},{type:"uint64",name:"disputeThresholdUsd"},{type:"uint64",name:"caseDuration"},{type:"uint64",name:"voteDuration"},{type:"uint64",name:"resolveDuration"},{type:"uint32",name:"voteCountRate"},{type:"uint32",name:"effectiveVoteRate"}]}],outputs:[]},{type:"function",name:"updateWormholeConfiguration",constant:!1,payable:!1,inputs:[{type:"tuple",name:"wormholeConfiguration",components:[{type:"address",name:"wormhole"},{type:"address",name:"staker"},{type:"bytes4",name:"selector"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"vote",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"validator"},{type:"uint8",name:"voteOption"},{type:"uint256",name:"deadline"},{type:"uint8",name:"v"},{type:"bytes32",name:"r"},{type:"bytes32",name:"s"}],outputs:[]}];var Zt=[{type:"error",name:"AccountInsufficientFreeAmount",inputs:[]},{type:"error",name:"AccountInsufficientReservedAmount",inputs:[]},{type:"error",name:"AccountInsufficientTradableAmount",inputs:[{type:"uint256",name:"accountTradableAmount"},{type:"uint256",name:"requiredTradableAmount"}]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"DepositToAccount",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ExecuteCompensation",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"PayWithPrincipal",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"receiver",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"PayWithProfitFirst",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"receiver",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"usedFreeAmount",indexed:!1},{type:"uint256",name:"usedRestrictedAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReleaseForOrder",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReleaseProfit",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveForOrder",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"SettleToAccount",inputs:[{type:"address",name:"account",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"freeBase",indexed:!1},{type:"uint256",name:"profitBase",indexed:!1},{type:"uint256",name:"freeAmount",indexed:!1},{type:"uint256",name:"profitAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"WithdrawFromAccount",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"deposit",constant:!1,payable:!1,inputs:[{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"executeCompensation",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"reimbursement"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolWithdrawableBaseToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"baseAmount"}]},{type:"function",name:"getTradableAmount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"}],outputs:[{type:"bool"},{type:"uint256"},{type:"uint256"},{type:"uint256"}]},{type:"function",name:"getUserAsset",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"address",name:"token"}],outputs:[{type:"uint256",name:"amount"}]},{type:"function",name:"getUserAssets",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"tuple[]",components:[{type:"address",name:"asset"},{type:"uint256",name:"amount"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"payWithPrincipal",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"},{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"payWithProfitFirst",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"}],outputs:[{type:"uint256",name:"usedFreeAmount"},{type:"uint256",name:"usedRestrictedAmount"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"releaseForCancelOrder",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"address",name:"account"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"releaseFromProfitUnlock",constant:!1,payable:!1,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}],outputs:[]},{type:"function",name:"reserveForOrder",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"settlementDeposit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"positionId"},{type:"address",name:"account"},{type:"tuple",name:"pool",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"state"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"},{type:"uint16",name:"maxPriceDeviation"},{type:"bool",name:"compoundEnabled"},{type:"uint64",name:"windowCapUsd"},{type:"address",name:"poolVault"},{type:"address",name:"tradingVault"}]},{type:"uint256",name:"freeBaseAmount"},{type:"uint256",name:"freeQuoteAmount"},{type:"uint256",name:"receivedBaseAmount"},{type:"uint256",name:"receivedQuoteAmount"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateAndWithdraw",constant:!1,payable:!1,inputs:[{type:"address",name:"receiver"},{type:"bytes32",name:"poolId"},{type:"bool",name:"isQuoteToken"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var en={USDC:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",POOL_MANAGER:"0xB131655F326E82753b0e76c1ce853E257524f3a4",Account:"0x0dF5950d0D89d808acC8B712Ed5d5A96fe6A3830",POSITION_MANAGER:"0xE6A51b8FC1b0e2a7f6ab8a0a85Ec4ab5210dF4fB",ORDER_MANAGER:"0xBD72c9F021F1eEA52Ac5dA378C9ffA3612Bfb687",PYTH:"0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",ERC20:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",LIQUIDITY_ROUTER:"0x0fb875c10fe2fF981e467765E3daaE4355b180D0",BASE_POOL:"0xeC0b3C76cC1C47f9B29313c706c1F6FD8D1C023f",QUOTE_POOL:"0x608Bfd6B8Df0807aA6d1500B76a3eAb3C9DFd728",ORACLE:"0xDa5f18BFeC36A397ad9c4AFc82ddfAb1429C66Be",EIP7702Delegation:"0x56Db3d459c8b9386f5B9ddFd91C0ef149200Cfc4",MARKET_MANAGER:"0xa7C6eD2b34a281463bEeE30b3784f9bc4696e7f1",DATA_PROVIDER:"0xdf535EF442a99B1b2C9fBd0a52D7d612234d123c",ORACLE_RESERVE:"0xf8fC5a3E721f83a75A319313C1A5eAa1bbC838FE",FORWARDER:"0x64A5099C3382f7fdA44F9D329faa86C27dA3D375",TRADING_ROUTER:"0x1168c934cFBDADF425280e890B5f2d47ddE778BE",REIMBURSEMENT:"0x6bAac84Ec2B9586A0Da460CC04dFB69efBe85724",DISPUTE_COURT:"0x51fF606E074637A8C7DDD276B3794a8205739b42"};var tn={USDC:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",POOL_MANAGER:"0x05314a21Fc97B74f168730153b2B63A870D25dE5",Account:"0xAC0ca67fd6C7Ff9c80DE58420B840115b6d51c6e",POSITION_MANAGER:"0x1a8cC8391Ee19c3817de64a52904D0557f519bA5",ORDER_MANAGER:"0x3138f425f11f14fE33a180e9Bbf0661C8dc6d8AD",PYTH:"0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",ERC20:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",LIQUIDITY_ROUTER:"0xfb790ECE13Cd9e296b4a06ABF38D10431360c236",BASE_POOL:"0x1F767BEa83EDe5E0C18904f439C579f52c2c0F1b",QUOTE_POOL:"0x50ad7da312c58c6689bEF028954a366cb5b8ee13",ORACLE:"0x3e437094C5687Ed6eDb1883b0bd445Efa9103a55",EIP7702Delegation:"0xc68fdf81ca68B26fdB296645F42a734c12E63751",MARKET_MANAGER:"0x71b57CcB7539aB761fd5C5767362A207a295e337",DATA_PROVIDER:"0xd4FdE3cc72D29b71507823cA43Dd6fD520644E92",ORACLE_RESERVE:"0x4fC26Cf34e5d486BFF211315bf17D77d34130971",FORWARDER:"0x58fb1a663b08871A755734231C387E1d10ac2B10",TRADING_ROUTER:"0x89ba8EDBD63f577cAA1095F25Df0A44A226f28bc",REIMBURSEMENT:"0xDbCe02B080C68671EF6EcEc1a01A789441A3a564",DISPUTE_COURT:"0x47648D171925a69b3A334898AaaE6e7cc41B1735"};var nn={USDC:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",POOL_MANAGER:"0x85e869d98216221807A06636541Ec93C9c0a4B0c",Account:"0xA2c5f49a8722408CDa79460CcEd5B97aDcA4cD56",POSITION_MANAGER:"0x68fE700557Fc766DF9b9959E11fd9DacA3f2ccdA",ORDER_MANAGER:"0xC2C479bfb9b6317D37d77C9A1867Af15a457B39D",PYTH:"0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",ERC20:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",LIQUIDITY_ROUTER:"0xc5331ab0159379E6CfCC1f09b63360D0B9715D74",BASE_POOL:"0x8440a78E65F07D8013dd5B0640E0E713c8fd9893",QUOTE_POOL:"0x50F1F7A772672FE0637cF89AD3aFc093584eD040",ORACLE:"0x9F8e2296fa10d77897E7B252460d27b855eeD251",EIP7702Delegation:"0x9558a64E54de8294E7bcCBA62Ee7323c43473abb",MARKET_MANAGER:"0x3BEaaBc8ba2e117E5B66354F8F5D6dc97F71d434",DATA_PROVIDER:"0x7C672f90CCB8b3500F4285Bf22eBb3A98b4eFEB5",ORACLE_RESERVE:"0x27fd8356cE30Aae5440ce2B765beA5d2527efbAD",FORWARDER:"0xb7Bc467202C8C023ba064E368d979381BCfeD62E",TRADING_ROUTER:"0x2894Ea4ca2D177E6070Ad7b53Bf6C20C6BE83cd6",REIMBURSEMENT:"0x0C076Af7AC1861cf85a76eC8bdE4f67dbf23f2b2",DISPUTE_COURT:"0xbf9C0bbfd60e28906C5b1EB05875411A0Ba01435"};var an={POOL_MANAGER:"0xcf51a6895864c6D8E507fC31EF16b9011287c5f4",Account:"0x35054EfE58Bbdae792aeCaD7bC2e4939c169560f",POSITION_MANAGER:"0x689A0C7E46785584FF7636700ceF5d5e7c141F8D",ORDER_MANAGER:"0xa0B5E5AE9D3E214096C90DDeC04D39B27ED9B272",PYTH:"0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",ERC20:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",LIQUIDITY_ROUTER:"0x0AE31989318565620c03d35889a0B2536b8fba5C",BASE_POOL:"0xc9e3826c42183207B418116A16827C1605132c51",QUOTE_POOL:"0x9A9934D3b22103dE822d94A22A3177d728FE0e5a",ORACLE:"0x0dD8293765358cF7f2646D0B91bA59804E197FC6",EIP7702Delegation:"0x4686F8a0d44b056037b2A51c4342EE7FA8e0A48F",MARKET_MANAGER:"0xe99dAB65c5546D7C87850Bbc40C6a7BEd7328Efa",DATA_PROVIDER:"0x5b6Be9839552a49302d552aB3C223b60Adb8BF1D",ORACLE_RESERVE:"0xB3D5a67223905FE73a0749e7A03525838063C54C",USDC:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",FORWARDER:"0x6C40462A4d45BA4119af59Fb9e41b8eaC9293962",TRADING_ROUTER:"0x0000000000000000000000000000000000000000",REIMBURSEMENT:"0x0000000000000000000000000000000000000000",DISPUTE_COURT:"0x0000000000000000000000000000000000000000"};var sn={USDC:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",POOL_MANAGER:"0x4F917ef137b573D9790b87e3cF6dfb698cF00c9c",Account:"0xE58CC82F96c86f8F809A98BE14D9DC929d503e25",POSITION_MANAGER:"0x7A5000A1DDE26520BfC893c676a288F98F8a029c",ORDER_MANAGER:"0x343d7563eFb904375Fea81BcC4A3eCdDc0CDa8C9",PYTH:"0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",ERC20:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",LIQUIDITY_ROUTER:"0xe9F2E58562aD1D50AfB1eD92EAa6D367A6D0e552",BASE_POOL:"0x39506f97D1c1A91EAfD59368697E20dC1fE5eEDB",QUOTE_POOL:"0x80DAa474e7e2C9c86708e434B80636b92fb4e9EE",ORACLE:"0xB980765F0D5D3B482601F1a62Ec898619DA9c0C5",EIP7702Delegation:"0x9d43e7847f74E141E1A2B4C413D5F89520995551",MARKET_MANAGER:"0x624d1D5258b34d5C3F4f9CdCB7582F677643cdDC",DATA_PROVIDER:"0xb3c6b1448F04B3Eb9A5D83D6c32B0a10F3E7281B",ORACLE_RESERVE:"0x949e8a0284eA5509B47619e7667C3aA43B7c0336",FORWARDER:"0x73F9F9205E2F7E0Fb886afC3D2a53399C85383a5",TRADING_ROUTER:"0x0000000000000000000000000000000000000000",REIMBURSEMENT:"0x0000000000000000000000000000000000000000",DISPUTE_COURT:"0x0000000000000000000000000000000000000000"};var rn={USDC:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",POOL_MANAGER:"0x9E84a999e15CCdb2F64a5AF10939c25769dF6b07",Account:"0x42A1BC012CeC51Ebf3bbf79142bf2a912396FB0e",POSITION_MANAGER:"0x011a25Fe39b2f9033E49d1587CF24780242e40dA",ORDER_MANAGER:"0xfc30D3C858B72a9EDfE6679Fc3355039D276f811",PYTH:"0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",ERC20:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",LIQUIDITY_ROUTER:"0x0F4C6f18Fb136DD1eBd6Da3C5d86a86597CF79a3",BASE_POOL:"0x51B62554a76197d5DF2D5dC4D57FF54d40775938",QUOTE_POOL:"0x783Ed065a12e1C1D33c2a8d6408385C1843D3084",ORACLE:"0xaF26d69BC0A6f1DEf8AeB00B6DAD28398ba67a53",EIP7702Delegation:"0xc8558cD3905F273ff45B1dd6D10894445bFa622f",MARKET_MANAGER:"0x3b809daB550f9DD0DbE82567f6EA6137C174532c",DATA_PROVIDER:"0x4B5888025570934cC9D31807feBAAEDaC823Cb8e",ORACLE_RESERVE:"0x3011dA5822c1ECA7fcda64716779769D0089945D",FORWARDER:"0x2943a063ae2A772f4314FaA28E00De827A491Dd3",TRADING_ROUTER:"0xaA16801F36e49cDD4f87938032487C7E6cfbb389",REIMBURSEMENT:"0xBF72B69bA547D0bB7D1255B43Ff5D7f2615326dF",DISPUTE_COURT:"0xeD8B129a5919c45c7391AA73632eA691A471C672"};import Ma from"wretch";var Ee=Ma(),Da=(a,e)=>e?(e=JSON.parse(JSON.stringify(e)),a.includes("?")?a+"&"+new URLSearchParams(e).toString():a+"?"+new URLSearchParams(e).toString()):a,h={get:(a,e,t={})=>{let n=Da(a,e);return Ee.url(n).options(t).get().json()},post:(a,e,t={})=>Ee.url(a).options(t).post(e).json(),put:(a,e,t={})=>Ee.url(a).options(t).put(e).json(),delete:(a,e={})=>Ee.url(a).options(e).delete().json()};var Oa=(o=>(o[o.SUCCESS=9200]="SUCCESS",o[o.SUCCESS_ORIGIN=0]="SUCCESS_ORIGIN",o[o.IDENTITY_VERIFICATION_FAILED=9401]="IDENTITY_VERIFICATION_FAILED",o[o.PERMISSION_DENIED=9403]="PERMISSION_DENIED",o[o.NOT_EXIST=9404]="NOT_EXIST",o[o.REQUEST_LIMIT=9429]="REQUEST_LIMIT",o[o.SERVICE_ERROR=9500]="SERVICE_ERROR",o[o.MISS_REQUESTED_PARAMETER=9900]="MISS_REQUESTED_PARAMETER",o[o.INVALID_PARAMETER=9901]="INVALID_PARAMETER",o.NETWORK_ERROR="ERR_NETWORK",o))(Oa||{}),he=(i=>(i[i.Cook=0]="Cook",i[i.Primed=1]="Primed",i[i.Trench=2]="Trench",i[i.PreBench=3]="PreBench",i[i.Bench=4]="Bench",i))(he||{}),on=(t=>(t[t.Chainlink=1]="Chainlink",t[t.Pyth=2]="Pyth",t))(on||{}),pn=(u=>(u[u.Minute1=1]="Minute1",u[u.Minute5=5]="Minute5",u[u.Minute15=15]="Minute15",u[u.Minute30=30]="Minute30",u[u.Hour1=60]="Hour1",u[u.Hour4=240]="Hour4",u[u.Day1=1440]="Day1",u[u.Week1=10080]="Week1",u[u.Month1=40320]="Month1",u))(pn||{}),Fa=(n=>(n[n.Contract=1]="Contract",n[n.Cook=2]="Cook",n[n.Earn=3]="Earn",n))(Fa||{}),Na=(s=>(s[s.All=0]="All",s[s.Contract=1]="Contract",s[s.Cook=2]="Cook",s[s.Earn=3]="Earn",s))(Na||{}),_a=(t=>(t[t.BlueChips=1]="BlueChips",t[t.Alpha=2]="Alpha",t))(_a||{}),Ba=(n=>(n[n.BlueChips=1]="BlueChips",n[n.Alpha=2]="Alpha",n[n.Favorite=3]="Favorite",n))(Ba||{});var La=(s=>(s[s.Market=0]="Market",s[s.Limit=1]="Limit",s[s.Stop=2]="Stop",s[s.Conditional=3]="Conditional",s))(La||{}),Ua=(t=>(t[t.Increase=0]="Increase",t[t.Decrease=1]="Decrease",t))(Ua||{}),qa=(l=>(l[l.Increase=0]="Increase",l[l.Decrease=1]="Decrease",l[l.AddMargin=2]="AddMargin",l[l.RemoveMargin=3]="RemoveMargin",l[l.CancelOrder=4]="CancelOrder",l[l.ADL=5]="ADL",l[l.Liquidation=6]="Liquidation",l[l.MarketClose=7]="MarketClose",l[l.EarlyClose=8]="EarlyClose",l[l.AddTPSL=9]="AddTPSL",l[l.SecurityDeposit=10]="SecurityDeposit",l[l.TransferToWallet=11]="TransferToWallet",l[l.MarginAccountDeposit=12]="MarginAccountDeposit",l[l.ReferralReward=13]="ReferralReward",l[l.ReferralRewardClaim=14]="ReferralRewardClaim",l))(qa||{}),Ga=(n=>(n[n.Unknown=0]="Unknown",n[n.GTE=1]="GTE",n[n.LTE=2]="LTE",n))(Ga||{}),Wa=(t=>(t[t.Long=0]="Long",t[t.Short=1]="Short",t))(Wa||{}),za=(s=>(s[s.Cancelled=1]="Cancelled",s[s.Expired=2]="Expired",s[s.Successful=9]="Successful",s[s.PartialFilled=8]="PartialFilled",s))(za||{}),Va=(u=>(u[u.Market=1]="Market",u[u.Limit=2]="Limit",u[u.TP=3]="TP",u[u.SL=4]="SL",u[u.ADL=5]="ADL",u[u.ADLTrigger=6]="ADLTrigger",u[u.Liquidation=7]="Liquidation",u[u.EarlyClose=8]="EarlyClose",u[u.MarketClose=9]="MarketClose",u))(Va||{}),$a=(o=>(o[o.Open=0]="Open",o[o.PartialClose=1]="PartialClose",o[o.FullClose=2]="FullClose",o[o.Liquidation=3]="Liquidation",o[o.EarlyClose=4]="EarlyClose",o[o.MarketClose=5]="MarketClose",o[o.ADL=6]="ADL",o[o.TP=7]="TP",o[o.SL=8]="SL",o[o.Increase=9]="Increase",o))($a||{}),Ha=(n=>(n[n.MarginAccount=1]="MarginAccount",n[n.WalletAccount=2]="WalletAccount",n[n.ReferralReward=3]="ReferralReward",n))(Ha||{});var Qa=(s=>(s[s.EXECUTING=1]="EXECUTING",s[s.BROADCAST_FAILED=2]="BROADCAST_FAILED",s[s.TIMEOUT_CANCEL=3]="TIMEOUT_CANCEL",s[s.EXECUTED=9]="EXECUTED",s))(Qa||{});var ur=async()=>h.get(`${J()}/openapi/gateway/scan/market/list`);var J=()=>{let{isTestnet:a,isBetaMode:e}=Y?.getConfigManager()?.getConfig()||{};return e?"https://api-beta.myx.finance":a?"https://api-test.myx.cash":"https://api.myx.finance"},j=async(a,e=[])=>e.length?h.get(`${J()}/openapi/gateway/quote/price/oracles`,{chainId:a,poolIds:e.join(",")}):Promise.reject(new Error("Invalid pool id")),un=async(a,e)=>await h.get(`${J()}/openapi/gateway/scan/market/info?chainId=${a}&poolId=${e}`),dn=async(a,e,t)=>await h.get(`${J()}/openapi/gateway/scan/market/pool-order/open?chainId=${t}`,void 0,{headers:{myx_openapi_access_token:a,myx_openapi_account:e}}),cr=async({chainId:a,poolIds:e},t)=>h.get(`${J()}/openapi/gateway/quote/candle/tickers`,{chainId:a,poolIds:e.join(",")}),yr=async({...a})=>h.get(`${J()}/openapi/gateway/scan/market/base-details`,a),fr=async({...a})=>h.get(`${J()}/openapi/gateway/scan/market/detail`,a),mn=async()=>h.get(`${J()}/openapi/gateway/scan/market`);var Ae,mt=class mt{constructor(){this.version="1.0.4";Wt(this,Ae)}setConfigManager(e){zt(this,Ae,e)}getConfigManager(){return Gt(this,Ae)}setProvider(e){this.provider=e}getProvider(){return this.provider}static getInstance(){return this._instance||(this._instance=new mt),this._instance}async getMarkets(){try{let t=(await mn())?.data||[];return this.Markets=t,t}catch(e){throw e}}};Ae=new WeakMap;var Z=mt,ln=Z.getInstance(),Y=ln,Ka=async a=>{let e=ln.getConfigManager();if(!e?.hasSigner())throw new Error("No signer: call auth({ signer }) or auth({ walletClient })");return e.getViemWalletClient(a)};var cn={USDC:"0x55d398326f99059fF775485246999027B3197955",POOL_MANAGER:"0x04218C23f89cAA2E4395a7Bd94410057705D1184",Account:"0x269cdAd14cf2cD3c720BC16ef0321700CccaC574",POSITION_MANAGER:"0x04218C23f89cAA2E4395a7Bd94410057705D1184",ORDER_MANAGER:"0x8d38a857390E1586481cF8994F4feBc315D0249b",PYTH:"0x4D7E825f80bDf85e913E0DD2A2D54927e9dE1594",ERC20:"0x55d398326f99059fF775485246999027B3197955",LIQUIDITY_ROUTER:"0x637dB5906E51e6e73fF6EF059870cf70B1874aa5",BASE_POOL:"0x6a775E908629eFC6357b3d89E5528524a6f378Dd",QUOTE_POOL:"0x73b2dcfdc7dC78a7A51B778E93c09FC173923BcE",ORACLE:"0xAdD60e47D2C5e7d57B1e5a3F9d24dE43933b8A7A",EIP7702Delegation:"0x798860BbBC6e011C5508f92a102ee53a44cECfb7",MARKET_MANAGER:"0x98Af86B194ce82cac650C87F45e5B9f7A4A40AB2",DATA_PROVIDER:"0x96955bE362b35846c2E7b9B40fC961080DCBbA67",ORACLE_RESERVE:"0xBFE7b174F4013e9f6526030EB0c52b094A237E6E",FORWARDER:"0xD0894e09317F455dd698A706bb62D783e95aA7Ad",TRADING_ROUTER:"0xb0c56a233535971b8903497f98b90Cf53aE77A13",REIMBURSEMENT:"0x5EFB5E4C3807b6152157DbF4Ae75c31F0Cdec478",DISPUTE_COURT:"0xEaAf5b9184C48486a6Fb51f70E101087598a95C8"};var P=a=>{let{isBetaMode:e}=Y?.getConfigManager()?.getConfig()||{};switch(a){case 421614:return e?tn:en;case 59141:return e?an:nn;case 97:return e?rn:sn;case 56:return cn;default:return{}}};var se=(a,e)=>{let t=c(a);return k({address:e,abi:q,client:t})},ke=async(a,e)=>{let t=await M(a);return k({address:e,abi:q,client:t})},F=async a=>{let e=await M(a),[t]=await e.getAddresses();return t??void 0},D=async a=>{let e=P(a),t=await M(a);return k({address:e.LIQUIDITY_ROUTER,abi:Vt,client:t})},ie=(a,e=1)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.POOL_MANAGER,abi:at,client:n})):M(a).then(s=>k({address:t.POOL_MANAGER,abi:at,client:s}))};var X=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.QUOTE_POOL,abi:st,client:n})):M(a).then(s=>k({address:t.QUOTE_POOL,abi:st,client:s}))},H=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.BASE_POOL,abi:it,client:n})):M(a).then(s=>k({address:t.BASE_POOL,abi:it,client:s}))},L=async(a,e)=>{let t=await M(a);return k({address:e,abi:rt,client:t})};var de=(a,e)=>{let t=c(a);return k({address:e,abi:rt,client:t})};var yn=(a,e,t=0)=>{let n=t===0?c(a):null;return n?Promise.resolve(k({address:e,abi:ot,client:n})):M(a).then(s=>k({address:e,abi:ot,client:s}))},ee=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.MARKET_MANAGER,abi:pt,client:n})):M(a).then(s=>k({address:t.MARKET_MANAGER,abi:pt,client:s}))},me=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.DATA_PROVIDER,abi:ut,client:n})):M(a).then(s=>k({address:t.DATA_PROVIDER,abi:ut,client:s}))},lt=async a=>{let e=P(a),t=await M(a);return k({address:e.Account,abi:Zt,client:t})},le=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.FORWARDER,abi:Ie,client:n})):M(a).then(s=>k({address:t.FORWARDER,abi:Ie,client:s}))},fn=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.REIMBURSEMENT,abi:dt,client:n})):M(a).then(s=>k({address:t.REIMBURSEMENT,abi:dt,client:s}))},gn=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.DISPUTE_COURT,abi:xe,client:n})):M(a).then(s=>k({address:t.DISPUTE_COURT,abi:xe,client:s}))};var ce=null;function bn(a){ce=a}function Se(){return ce??{}}function ct(){}function In(...a){(ce?.log??ce?.info??ct)(...a)}function ye(...a){(ce?.warn??ct)(...a)}function I(...a){(ce?.error??ct)(...a)}var re=class{constructor(e){this.options={...e,logLevel:e?.logLevel??"info"}}get out(){return this.options.sink??Se()}debug(e,...t){this.options.logLevel!=="none"&&this.options.logLevel==="debug"&&(this.out.log??this.out.info)?.(`[MYX-SDK-DEBUG] ${e}`,...t)}info(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info")&&(this.out.log??this.out.info)?.(`[MYX-SDK-INFO] ${e}`,...t)}error(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info"||this.options.logLevel==="error")&&this.out.error?.(`[MYX-SDK-ERROR] ${e}`,...t)}warn(e,...t){this.options.logLevel!=="none"&&this.out.warn?.(`[MYX-SDK-WARN] ${e}`,...t)}};import{ErrorDecoder as Ja}from"ethers-decode-error";var oo=Ja.create();var S={1:"Invalid Chain",2:"Invalid Token Address",4001:"User Rejected",3:"Insufficient Balance",4:"Insufficient Amount Of Approved",4002:"Invalid Base Token Address",4003:"Invalid Slippage",4004:"Invalid Amount",4005:"Invalid Pool State",4006:"Invalid Params",4007:"Invalid Amount Withdrawable LP Amount"};function ja(a){let e=a;for(;e;){if(e.name==="UserRejectedRequestError")return!0;e=e.cause}return!1}async function b(a){let e=a?.shortMessage||a?.details||a?.message;return typeof a=="string"?{error:a}:ja(a)?{error:S[4001]}:{error:{code:a?.code||a?.name||"Unknow Error",message:e}}}var xn=async(a,e,t)=>{try{return await c(a).readContract({address:t,abi:q,functionName:"balanceOf",args:[e]})}catch(n){throw I(n),n}};import{maxUint256 as Ya,parseUnits as Xa}from"viem";var hn=async(a,e,t,n,s)=>{try{return await c(a).readContract({address:t,abi:q,functionName:"allowance",args:[e,n]})>=s}catch(i){throw i}};import{parseUnits as yt}from"viem";var E=30,_=18;var T=(a,e)=>BigInt(a)*yt(e.toString(),8)/BigInt(10**8),v=async a=>{try{let e=C[a],n=await c(a).getGasPrice();if(n==null)throw new Error("Network Error");return{gasPrice:T(n,e.gasPriceRatio)}}catch(e){throw e}},te=(a,e=.01)=>{let t=yt("1",8)-yt(e.toString(),8);return a*t/BigInt(10**8)};var An=async(a,e,t,n,s)=>{try{let i=C[a],r=await ke(a,t);if(!r.write)throw new Error("Wallet client required for write");let p=await r.estimateGas.approve([n,s]),d=T(p,i.gasLimitRatio),{gasPrice:u}=await v(a),o=await r.write.approve([n,s],{gasLimit:d,gasPrice:u});await c(a).waitForTransactionReceipt({hash:o})}catch(i){throw i}};var w=async a=>{if("chainId"in a&&!Te(a.chainId))throw new Error(S[1]);if("slippage"in a&&!(Number(a?.slippage)<=1&&Number(a?.slippage)>0))throw new Error(S[4003]);if("amount"in a&&(Number(a.amount)===Number.NaN||Number(a.amount)<0))throw new Error(S[4004]);let{tokenAddress:e,contractAddress:t,chainId:n,amount:s,decimals:i,account:r}=a;if(s&&n&&Number(i)>=0&&r){let p=Xa(s.toString(),Number(i));if(e){let d=await xn(n,r,e);if(!d||d<p)throw new Error(S[3])}t&&e&&(await hn(n,r,e,t,p)||await An(n,r,e,t,Ya))}};import{isNil as Za}from"lodash-es";var Cn=async(a,e)=>await Promise.all(e.map(async n=>{let{publishTime:s,vaa:i,oracleType:r,nativeFee:p,price:d,poolId:u}=n,o=Za(p)?1n:BigInt(p);return{poolId:u,price:d,value:o,publishTime:s,oracleType:r??2,vaa:i}})),fe=async(a,e)=>{if(!e||!e.length)return;let t=await j(a,e);return await Cn(a,t.data)},B=async(a,e)=>{if(!e)return;let n=(await j(a,[e]))?.data?.[0];if(!n)throw new Error(`Unable to get price for ${e} in the deposit`);return(await Cn(a,[n]))?.[0]};var Pn=async a=>{try{let{chainId:e,poolId:t}=a,n=C[e],s=await F(e);await w({account:s,chainId:e});let i=await fe(e,[t]);if(!i)return;let r=i.map(g=>g.value),p=i.map(g=>({poolId:t,oracleUpdateData:g?.vaa??"0",publishTime:g.publishTime,oracleType:g.oracleType})),d={prices:p,values:r,poolId:t,recipient:s},u=await D(e),o=await u.estimateGas.claimBasePoolRebate([p,t,s],{value:r[0]}),m=T(o,n.gasLimitRatio),{gasPrice:f}=await v(e);return await u.write.claimBasePoolRebate([p,t,s],{gasLimit:m,gasPrice:f,value:r[0]})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},Rn=async a=>{try{let{chainId:e,poolIds:t}=a;if(t.length===0)return;let n=C[e],s=await F(e);await w({account:s,chainId:e});let i=await fe(e,t);if(!i)return;let r=i.map(A=>({poolId:A.poolId,oracleUpdateData:A?.vaa??"0",publishTime:A.publishTime,oracleType:A.oracleType})),d=i.map(A=>A.value).reduce((A,R)=>R+A,0n),u={prices:r,poolIds:t,value:d,recipient:s},o=await D(e),m=await o.estimateGas.claimBasePoolRebates([r,t,s],{value:d}),f=T(m,n.gasLimitRatio),{gasPrice:y}=await v(e),g=await o.write.claimBasePoolRebates([r,t,s],{gasLimit:f,gasPrice:y,value:d});return await c(e).waitForTransactionReceipt({hash:g})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as kn}from"viem";import{parseUnits as wn}from"viem";var ft=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await H(a)).read.previewLpAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}},Tn=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await H(a)).read.previewBaseAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}},vn=async({chainId:a,account:e,poolId:t,amount:n=0})=>{try{if(!a||!e||!t)return;if(!n)return{baseAmountOut:0n,rebateAmount:0n};let s=C[a],i=18;await w({decimals:i,account:e,chainId:a,amount:Number(n)});let r=wn(n.toString(),i),d=(await j(a,[t])).data?.[0]?.price||"0",u=wn(d,30),m=await(await H(a)).read.previewUserWithdrawData([t,r,e,u]);return{baseAmountOut:m.baseAmountOut,rebateAmount:m.rebateAmount}}catch(s){throw typeof s=="string"?s:await b(s)}};var N=async(a,e)=>{try{return!a||!e?void 0:(await un(a,e)).data}catch(t){throw typeof t=="string"?t:await b(t)}};import{parseUnits as gt}from"viem";function En(a){return a.includes(".")?a.split(".")[1].length:0}var ge=(a=.01,e=[],t=18,n)=>{if(e.length===0)return[];if(e.filter(i=>i.amount&&i.triggerPrice&&i.triggerType).length===0)throw new Error(S[4006]);return e.map(i=>{let r=gt(i.amount.toString(),t),p=gt(i.triggerPrice.toString(),30),d=En(i.triggerPrice.toString()),u=gt(i.triggerPrice.toString(),d),o=te(r*u*BigInt(10**n)/BigInt(10**(d+t)),a);return{amount:r,triggerPrice:p,triggerType:BigInt(i.triggerType),minQuoteOut:o}})};var Sn=async a=>{try{let{poolId:e,chainId:t,amount:n,slippage:s=.01,tpsl:i=[]}=a;await w(a);let r=await N(t,e);if(!r)throw new Error(S[4006]);let p=r?.baseDecimals,d=r?.quoteDecimals,u=r?.baseToken,o=C[t],m=await F(t),y=P(t).BASE_POOL;await w({tokenAddress:u,contractAddress:y,decimals:p,account:m,chainId:t,amount:n});let g=!(Number(r?.state)===0||Number(r?.state)===1),l=[],A=kn(n.toString(),p),R=0n,O;if(g){let W=await B(t,e);if(!W)return;let la=kn(W.price,30);l.push({poolId:e,oracleUpdateData:W.vaa,publishTime:BigInt(W.publishTime),oracleType:W.oracleType}),O=await ft({chainId:t,poolId:e,amountIn:A,price:la}),R=W.value}else O=await ft({chainId:t,poolId:e,amountIn:A});let K=i.map(W=>({amount:n,triggerPrice:W.triggerPrice,triggerType:W.triggerType})),V=ge(s,K,p,d),ae={poolId:e,amountIn:A,minAmountOut:te(O,s),recipient:m,tpslParams:V},we=await D(t),Ye=await we.estimateGas.depositBase([l,ae],{value:R}),Xe=T(Ye,o.gasLimitRatio),{gasPrice:Ze}=await v(t),Lt=await we.write.depositBase([l,ae],{gasLimit:Xe,gasPrice:Ze,value:R});return await c(t).waitForTransactionReceipt({hash:Lt})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as vt}from"viem";import{parseUnits as ss}from"viem";var Pe=async({chainId:a,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(S[2]);let n=P(a),s=await ie(a,0),i=[t,e],r=await s.read.getMarketPool(i);return r.poolId==="0x0000000000000000000000000000000000000000000000000000000000000000"||!r.poolId?void 0:r.poolId}catch(n){throw I(n),typeof n=="string"?n:await b(n)}},It=async a=>{try{return await(await ie(a)).read.getPools()||[]}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},xt=async(a,e,t=0n)=>{try{let s=await(await me(a)).read.getPoolInfo([e,t]);return{quotePool:{poolToken:s.quotePool.poolToken,exchangeRate:s.quotePool.exchangeRate,poolTokenPrice:s.quotePool.poolTokenPrice,poolTokenSupply:s.quotePool.poolTokenSupply,totalDebt:s.quotePool.totalDebt,baseCollateral:s.quotePool.baseCollateral},basePool:{poolToken:s.basePool.poolToken,exchangeRate:s.basePool.exchangeRate,poolTokenPrice:s.basePool.poolTokenPrice,poolTokenSupply:s.basePool.poolTokenSupply,totalDebt:s.basePool.totalDebt,baseCollateral:s.basePool.baseCollateral},reserveInfo:{baseTotalAmount:s.reserveInfo.baseTotalAmount,baseReservedAmount:s.reserveInfo.baseReservedAmount,quoteTotalAmount:s.reserveInfo.quoteTotalAmount,quoteReservedAmount:s.reserveInfo.quoteReservedAmount},fundingInfo:{nextFundingRate:s.fundingInfo.nextFundingRate,lastFundingFeeTracker:s.fundingInfo.lastFundingFeeTracker,nextEpochTime:s.fundingInfo.nextEpochTime},ioTracker:{tracker:s.oi.tracker,longSize:s.oi.longSize,shortSize:s.oi.shortSize,poolEntryPrice:s.oi.poolEntryPrice},liquidityInfo:{windowCaps:s.liquidityInfo.windowCaps,openInterest:s.liquidityInfo.openInterest}}}catch(n){throw I(n),typeof n=="string"?n:await b(n)}};var ht=async({chainId:a,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(S[2]);let n=C[a],s=await ie(a),i={marketId:t,baseToken:e},r=await s.estimateGas.deployPool([i]),p=T(r,n.gasLimitRatio),{gasPrice:d}=await v(a),u=await s.write.deployPool([i],{gasLimit:p,gasPrice:d});if(await c(a).waitForTransactionReceipt({hash:u}))return await Pe({chainId:a,baseToken:e,marketId:t})}catch(n){throw typeof n=="string"?n:await b(n)}};var At=async(a,e,t)=>{try{return await(await yn(a,e)).read.userGenesisShare([t])}catch(n){throw I(n),typeof n=="string"?n:await b(n)}};var Ct=async a=>{try{let{chainId:e,poolId:t,poolType:n,slippage:s=.01,tpsl:i=[]}=a;await w(a);let r=await N(e,t);if(!r)throw new Error(S[4006]);let p=18,d=r.quoteDecimals,u=ge(s,i,p,d),o=C[e],m=await D(e),f={poolId:t,poolType:BigInt(n),tpslParams:u},y=await m.estimateGas.addTpsl([f]),g=T(y,o.gasLimitRatio),{gasPrice:l}=await v(e),A=await m.write.addTpsl([f],{gasLimit:g,gasPrice:l});return await c(e).waitForTransactionReceipt({hash:A})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};var Pt=async a=>{try{let{chainId:e,orderId:t}=a;await w(a);let n=C[e],s=await D(e),i=await s.estimateGas.cancelTpsl([t]),r=T(i,n.gasLimitRatio),{gasPrice:p}=await v(e),d=await s.write.cancelTpsl([t],{gasLimit:r,gasPrice:p});return await c(e).waitForTransactionReceipt({hash:d})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{getAddress as es,formatUnits as Mn}from"viem";async function ts(a){try{return(await fetch(a,{method:"HEAD"})).ok}catch{return!1}}var fu=async(a,e,t)=>{try{let n=c(a),s=e,[i,r,p,d]=await Promise.all([n.readContract({address:s,abi:q,functionName:"name"}),n.readContract({address:s,abi:q,functionName:"symbol"}),n.readContract({address:s,abi:q,functionName:"decimals"}),n.readContract({address:s,abi:q,functionName:"totalSupply"})]),u=es(s),o=`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${a}/assets/${u}/logo.png`,f=await ts(o)?o:"",y;if(t){let g=await n.readContract({address:s,abi:q,functionName:"balanceOf",args:[t]});y=Number(Mn(g,Number(p)))}return{address:e,name:i,symbol:r,decimals:Number(p),icon:f,totalSupply:Number(Mn(d,Number(p))),...t?{balance:y}:{}}}catch(n){throw I(n),n}};import{formatUnits as Ru,parseUnits as wu}from"viem";import{formatUnits as ns,parseUnits as as}from"viem";var Rt=async(a,e,t)=>{try{await w({chainId:a});let n=await N(a,e);if(!n)throw new Error(S[4006]);let s=await F(a),r=((Y?.Markets?.length?Y?.Markets:await Y.getMarkets())||[])?.find(l=>l.chainId===a&&l.marketId===t);if(!r)throw new Error("Invalid Market");let p=as(r.oracleFeeUsd.toString(),n.quoteDecimals);if(!p)throw new Error("Invalid Market");await w({tokenAddress:n.quoteToken,contractAddress:P(a).ORACLE_RESERVE,decimals:n.quoteDecimals,account:s,chainId:a,amount:Number(ns(p,n.quoteDecimals))});let d=C[a],u=await ie(a),o=await u.estimateGas.reprimePool([{poolId:e}]),m=T(o,d.gasLimitRatio),{gasPrice:f}=await v(a),y=await u.write.reprimePool([{poolId:e}],{gasLimit:m,gasPrice:f});return await c(a).waitForTransactionReceipt({hash:y})}catch(n){throw I(n),typeof n=="string"?n:await b(n)}};var wt=async(a,e)=>{try{let t=await Z.getInstance().getConfigManager()?.getAccessToken();if(!t)throw new Error("Failed to obtain accessToken");return(await dn(t,e,a)).data||[]}catch(t){throw I(t),t}};var Tt=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await X(a)).read.previewLpAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}},Dn=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await X(a)).read.previewQuoteAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}};var Me=async({amountIn:a,chainId:e,poolId:t,state:n,slippage:s,poolType:i,account:r})=>{let p=!(n===0||n===1),d=[],u=0n,o,m=i===0?Tn:Dn;if(p)try{let y=await B(e,t);if(y){let g=ss(y.price,30);d.push({poolId:t,oracleUpdateData:y.vaa,publishTime:BigInt(y.publishTime),oracleType:y.oracleType}),o=await m({chainId:e,poolId:t,amountIn:a,price:g}),u=y.value}}catch(y){console.error(y),o=await m({chainId:e,poolId:t,amountIn:a})}else o=await m({chainId:e,poolId:t,amountIn:a});let f={poolId:t,amountIn:a,minAmountOut:te(o,s),recipient:r};return{price:d,data:f,value:u}};var Fn=async a=>{try{let{chainId:e,poolId:t,price:n}=a,s=n,i=await H(e);if(typeof n>"u"||n===null)try{let p=await B(e,t);s=vt(p?.price||"0",30)}catch{s=vt("0",30)}return await i.read.withdrawableLpAmount([t,s||0n])}catch(e){throw typeof e=="string"?e:await b(e)}},Nn=async a=>{try{let{chainId:e,poolId:t,amount:n,slippage:s=.01}=a,i=await N(e,t),r=i?.basePoolToken,p=C[e],d=await F(e),u=18;await w({tokenAddress:r,decimals:u,account:d,chainId:e,amount:n});let o=vt(n.toString(),u),{price:m,data:f,value:y}=await Me({poolId:t,chainId:e,account:d,amountIn:o,slippage:s,poolType:0,state:i?.state}),g=await D(e),l=await g.estimateGas.withdrawBase([m,f],{value:y}),A=T(l,p.gasLimitRatio),{gasPrice:R}=await v(e),O=await g.write.withdrawBase([m,f],{gasLimit:A,gasPrice:R,value:y});return await c(e).waitForTransactionReceipt({hash:O})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as is}from"viem";var _n=async a=>{try{let{chainId:e,account:t,poolId:n}=a;if(!e||!t||!n)return;let s=C[e],i=0n,p=(await j(e,[n])).data?.[0]?.price||"0",d=is(p,30),o=await(await H(e)).read.pendingUserRebates([n,t,d]);return{rebates:o?.rebates,genesisRebates:o?.genesisRebates}}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as rs}from"viem";var Bn=async(a,e)=>{if(e)try{let t=await H(a),n=0n,s=await B(a,e);return s?.price&&(n=rs(s.price,30)),await t.read.getPoolTokenPrice([e,n])}catch(t){throw typeof t=="string"?t:await b(t)}};var St={};et(St,{claimQuotePoolRebate:()=>Vn,claimQuotePoolRebates:()=>$n,deposit:()=>Un,getLpPrice:()=>Hn,getRewards:()=>zn,transfer:()=>Wn,withdraw:()=>Gn,withdrawableLpAmount:()=>qn});import{parseUnits as Ln}from"viem";var Un=async a=>{try{let{poolId:e,chainId:t,amount:n,slippage:s=.01,tpsl:i=[]}=a;await w(a);let r=await N(t,e);if(!r)throw new Error(S[4006]);let p=C[t],d=await F(t),o=P(t).QUOTE_POOL,m=r.quoteToken,f=r?.quoteDecimals;await w({tokenAddress:m,contractAddress:o,decimals:f,account:d,chainId:t,amount:n});let y=Ln(n.toString(),f),g=!(Number(r?.state)===0||Number(r?.state)===1),l=[],A=0n,R;if(g){let $=await B(t,e);if(!$)return;let W=Ln($.price,30);l.push({poolId:e,oracleUpdateData:$.vaa,publishTime:BigInt($.publishTime),oracleType:$.oracleType}),R=await Tt({chainId:t,poolId:e,amountIn:y,price:W}),A=$.value}else R=await Tt({chainId:t,poolId:e,amountIn:y});let O=i.map($=>({amount:n,triggerPrice:$.triggerPrice,triggerType:$.triggerType})),K=ge(s,O,f,f),V={poolId:e,amountIn:y,minAmountOut:te(R,s),recipient:d,tpslParams:K},ae=await D(t),we=await ae.estimateGas.depositQuote([l,V],{value:A}),Ye=T(we,p.gasLimitRatio),{gasPrice:Xe}=await v(t),Ze=await ae.write.depositQuote([l,V],{gasLimit:Ye,gasPrice:Xe,value:A});return await c(t).waitForTransactionReceipt({hash:Ze})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as kt}from"viem";var qn=async a=>{try{let{chainId:e,poolId:t,price:n}=a,s=n,i=await X(e);if(typeof n>"u"||n===null)try{let p=await B(e,t);s=kt(p?.price||"0",30)}catch{s=kt("0",30)}return await i.read.withdrawableLpAmount([t,s||0n])}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},Gn=async a=>{try{let{chainId:e,poolId:t,amount:n,slippage:s=.01}=a,i=await N(e,t),r=i?.quotePoolToken,p=C[e],d=await F(e),u=18;await w({tokenAddress:r,decimals:u,account:d,chainId:e,amount:n});let o=kt(n.toString(),u),{price:m,data:f,value:y}=await Me({poolId:t,chainId:e,account:d,amountIn:o,slippage:s,poolType:1,state:i?.state}),g=await D(e),l=await g.estimateGas.withdrawQuote([m,f],{value:y}),A=T(l,p.gasLimitRatio),{gasPrice:R}=await v(e),O=await g.write.withdrawQuote([m,f],{gasLimit:A,gasPrice:R,value:y});return await c(e).waitForTransactionReceipt({hash:O})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as os}from"viem";var Wn=async(a,e,t,n)=>{try{let s=await N(a,e),i=await N(a,t);if(!i||!s)return null;if([3,4].includes(i.state))throw new Error(S[4005]);let r=await F(a),p=C[a],d=18;await w({chainId:a,amount:n,account:r,decimals:d,tokenAddress:s.quotePoolToken});let u={fromPoolId:e,toPoolId:t,minLpOut:0n,amount:os(n.toString(),d)},o=await D(a),m=await o.estimateGas.migrateLiquidity([u]),f=T(m,p.gasLimitRatio),{gasPrice:y}=await v(a),g=await o.write.migrateLiquidity([u],{gasLimit:f,gasPrice:y});return await c(a).waitForTransactionReceipt({hash:g})}catch(s){throw typeof s=="string"?s:await b(s)}};import{parseUnits as ps}from"viem";var zn=async a=>{try{let{chainId:e,account:t,poolId:n}=a;if(!e||!t||!n)return;let s=C[e],r=(await j(e,[n])).data?.[0]?.price||"0",p=ps(r,30);return await(await X(e)).read.pendingUserRebates([n,t,p])}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};var Vn=async a=>{try{let{chainId:e,poolId:t}=a,n=C[e],s=await F(e),i=18;await w({account:s,chainId:e});let r=await fe(e,[t]);if(!r)return;let p=r.map(l=>l.value),d=r.map(l=>({poolId:l.poolId,oracleUpdateData:l?.vaa??"0",publishTime:l.publishTime,oracleType:l.oracleType})),u={prices:d,values:p,poolId:t,recipient:s},o=await D(e),m=await o.estimateGas.claimQuotePoolRebate([d,t,s],{value:p[0]}),f=T(m,n.gasLimitRatio),{gasPrice:y}=await v(e);return await o.write.claimQuotePoolRebate([d,t,s],{gasLimit:f,gasPrice:y,value:p[0]})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},$n=async a=>{try{let{chainId:e,poolIds:t}=a;if(t.length===0)return;let n=C[e],s=await F(e),i=18;await w({account:s,chainId:e});let r=await fe(e,t);if(!r)return;let p=r.map(R=>({poolId:R.poolId,oracleUpdateData:R?.vaa??"0",publishTime:R.publishTime,oracleType:R.oracleType})),u=r.map(R=>R.value).reduce((R,O)=>O+R,0n),o={prices:p,value:u,poolIds:t,recipient:s},m=await D(e),f=await m.estimateGas.claimQuotePoolRebates([p,t,s],{value:u}),y=T(f,n.gasLimitRatio),{gasPrice:g}=await v(e),l=await m.write.claimQuotePoolRebates([p,t,s],{gasLimit:y,gasPrice:g,value:u});return await c(e).waitForTransactionReceipt({hash:l})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as us}from"viem";var Hn=async(a,e)=>{if(e)try{let t=await X(a),n=0n,s=await B(a,e);return s?.price&&(n=us(s.price,30)),await t.read.getPoolTokenPrice([e,n])}catch(t){throw I(t),typeof t=="string"?t:await b(t)}};var Mt={};et(Mt,{getMarket:()=>Qn,getOracleFee:()=>Kn});var Qn=async(a,e)=>{try{return await w({chainId:a}),e?await(await ee(a)).read.getMarket([e]):void 0}catch(t){throw I(t),typeof t=="string"?t:await b(t)}};var Kn=async(a,e)=>{try{return await w({chainId:a}),e?await(await ee(a)).read.getOracleFee([e]):void 0}catch(t){throw I(t),typeof t=="string"?t:await b(t)}};var ds={createPool:ht,getMarketPoolId:Pe,getMarketPools:It,getPoolInfo:xt,getUserGenesisShare:At,addTpSl:Ct,cancelTpSl:Pt,reprime:Rt,getPoolDetail:N,getOpenOrders:wt};import fs from"mitt";import{Hex as ms,MD5 as ls}from"crypto-es";var De=(a,e)=>ls(a,{outputLength:e||32}).toString(ms);var Oe=a=>{switch(a.request){case"signin":return De(a.request)}return De(JSON.stringify(a))},Re=a=>{let{topic:e,params:t}=a;switch(e){case"candle":return`${e}.${t.globalId}_${t.resolution}`;case"ticker":return`${e}.${t.globalId}`;case"ticker.*":case"order":case"position":return e;default:return De(JSON.stringify({topic:e,params:t}))}},jn=({type:a})=>a==="pong"||a==="signin"||a==="subv2"||a==="unsubv2"||a==="ping"||a==="pong",ys=a=>{switch(a){case"order":case"position":case"ticker.*":return a;default:let[e]=a.split(".");return e}},Yn=a=>{switch(ys(a.type)){case"ticker":{let[,t=""]=a.type.split(".");return{...a,type:Re({topic:"ticker",params:{globalId:parseInt(t)}}),globalId:parseInt(t)}}case"candle":{let[,t=""]=a.type.split("."),[n,s]=t.split("_");return{...a,type:Re({topic:"candle",params:{globalId:parseInt(n),resolution:s}}),globalId:parseInt(n),resolution:s}}}return a};var x=class extends Error{constructor(e,t){super(t),this.name=e}toJSON(){return{code:this.name,message:this.message}}toString(){return`[MYX-ERROR-${this.name}]: ${this.message}`}};import gs from"reconnecting-websocket";var Xn={url:"",initialReconnectDelay:1e3,maxReconnectDelay:3e4,reconnectMultiplier:1.5,maxReconnectAttempts:10,maxEnqueuedMessages:100,requestTimeout:1e4,heartbeatInterval:1e4,heartbeatMessage:"ping",noMessageTimeout:5e3,connectionTimeout:1e4},Fe=class{constructor(e){this.ws=null;this.subscriptions=new Map;this.waitingRequests=new Map;this.eventBus=fs();this.heartbeatIntervalId=null;this.isFirstConnection=!0;this.lastMessageTime=0;let t={...e,logLevel:e?.logLevel||"info"},{logLevel:n,...s}=t;this.config={...Xn,...s},this.logger=new re({logLevel:e?.logLevel}),this.logger.debug("WebSocketClient constructor",this.config)}connect(){return new Promise((e,t)=>{if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING){e();return}try{let n={maxReconnectionDelay:this.config.maxReconnectDelay,minReconnectionDelay:this.config.initialReconnectDelay,reconnectionDelayGrowFactor:this.config.reconnectMultiplier,maxRetries:this.config.maxReconnectAttempts,maxEnqueuedMessages:this.config.maxEnqueuedMessages,connectionTimeout:this.config.connectionTimeout};this.ws=new gs(this.config.url,this.config.protocols,n),this.setupEventListeners(e,t)}catch(n){t(n)}})}async onBeforeReSubscribe(){return this.config.onBeforeReSubscribe&&await this.config.onBeforeReSubscribe(),!0}setupEventListeners(e,t){this.ws&&(this.ws.onopen=async n=>{this.eventBus.emit("open",n),this.lastMessageTime=Date.now(),this.timeoutHeartbeat(),this.isFirstConnection||this.onBeforeReSubscribe().then(()=>this.resubscribeAll()),this.isFirstConnection=!1,e()},this.ws.onmessage=n=>{this.handleMessage(n)},this.ws.onclose=n=>{this.eventBus.emit("close",n),this.stopHeartbeatTimer()},this.ws.onerror=n=>{this.eventBus.emit("error",n),t(n)},this.ws.addEventListener("reconnecting",n=>{this.eventBus.emit("reconnecting",{detail:n.detail||0}),this.isFirstConnection=!1}),this.ws.addEventListener("maxreconnectattempts",()=>{this.eventBus.emit("maxreconnectattempts",void 0)}))}pong(e){this.send({request:"pong",args:e})}request(e){return new Promise((t,n)=>{let s=Oe(e);this.waitingRequests.has(s)?(this.waitingRequests.get(s)?.onSuccess.add(t),this.waitingRequests.get(s)?.onError.add(n)):this.waitingRequests.set(s,{onSuccess:new Set([t]),onError:new Set([n])}),this.send(e)})}subscribe(e,t){let n=Array.isArray(e)?e:[e],s=[],i=new Set;n.forEach(r=>{let p=Re(r);if(!i.has(p))if(i.add(p),this.subscriptions.has(p))this.subscriptions.get(p).callbacks.add(t);else{let d={id:p,topic:r.topic,callbacks:new Set([t])};this.subscriptions.set(p,d),s.push(p),this.logger.debug(`create new subscription: ${p}`)}}),s.length>0&&this.send({request:"subv2",args:s})}unsubscribe(e,t){if(!e)return;let n=Array.isArray(e)?e:[e],s=[],i=new Set;n.forEach(r=>{let p=Re(r);if(i.has(p))return;i.add(p);let d=this.subscriptions.get(p);d&&(d.callbacks.delete(t),this.logger.debug(`remove callback from subscription: ${p}`),d.callbacks.size===0&&(this.subscriptions.delete(p),s.push(p),this.logger.debug(`subscription ${p} has no callbacks, will unsubscribe`)))}),s.length>0&&this.send({request:"unsubv2",args:s})}send(e){let t=typeof e=="string"?e:JSON.stringify(e);if(!this.ws)throw new x("SOCKET_NOT_CONNECTED","WebSocket is not connected");this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING&&this.reconnect(),this.ws.send(t)}disconnect(){this.stopHeartbeatTimer(),this.ws&&(this.ws.close(),this.ws=null)}reconnect(){this.ws?this.ws.readyState!==WebSocket.CONNECTING&&this.ws.reconnect():this.connect().catch(e=>{this.logger.error(e)})}isConnected(){return this.ws?.readyState===WebSocket.OPEN}on(e,t){this.eventBus.on(e,t)}off(e,t){this.eventBus.off(e,t)}handleMessage(e){try{let t=JSON.parse(e.data);if(this.lastMessageTime=Date.now(),t.type==="ping"){queueMicrotask(()=>{this.pong(t.data)});return}if(jn(t)){this.handleAckMessage(t);return}this.handleSubscriptionMessage(t)}catch(t){this.logger.error(`Failed to parse WebSocket message: ${t}`)}}handleAckMessage(e){let t;switch(e.type){case"signin":t=Oe({request:e.type,args:""});break;default:t=Oe({request:e.type,args:e.data.data});break}let n=this.waitingRequests.get(t),s=e.data.code===9200;s?this.logger.debug(`AcK Message:${e.type} received`):(this.logger.error(`Ack Message:${e.type} received`,e),this.eventBus.emit("error",e)),n?.onError.size&&!s&&n.onError.forEach(i=>{i(new x("REQUEST_FAILED","Request failed"))}),n?.onSuccess.size&&s&&n.onSuccess.forEach(i=>{i(e.data)})}handleSubscriptionMessage(e){let t=Yn(e),n=t.type,s=this.subscriptions.get(n);s&&s.callbacks.forEach(i=>{try{i(t)}catch(r){this.logger.error(`Callback Error (${n}): ${r}`)}})}resubscribeAll(){if(this.subscriptions.size===0)return;this.logger.debug("resubscribe all...");let e=Array.from(this.subscriptions.values()).map(t=>t.id);e.length>0&&(this.send({request:"subv2",args:e}),this.logger.debug(`resubscribe ${e.length} topics`))}timeoutHeartbeat(){this.stopHeartbeatTimer(),Date.now()-this.lastMessageTime>(this.config.noMessageTimeout||Xn.noMessageTimeout)&&(this.logger.debug("no message timeout"),this.subscriptions.size>0?this.reconnect():this.ws?.close()),this.heartbeatIntervalId=setTimeout(()=>{this.timeoutHeartbeat()},this.config.heartbeatInterval)}stopHeartbeatTimer(){this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=null)}};var Zn=[56,59144,42161],ea=[59141,421614,97],ta=[97,421614];var Ne={TestNet:"wss://oapi-test.myx.cash/ws",MainNet:"wss://oapi.myx.finance/ws",BetaNet:"wss://oapi-beta.myx.finance/ws"};var _e=class{constructor(e,t){this.clientAuth=!1;this.prevUserAddress=null;this.configManager=e,this.logger=t;let n=Ne.MainNet;e.getConfig().isBetaMode?n=Ne.BetaNet:e.getConfig().isTestnet&&(n=Ne.TestNet),this.wsClient=new Fe({logLevel:this.configManager.getConfig()?.logLevel,url:n,...this.configManager.getConfig()?.socketConfig,onBeforeReSubscribe:()=>{if(this.clientAuth)return this.auth(!0).then(()=>{this.logger.debug("reconnect auth success")})}})}get isConnected(){return this.wsClient.isConnected()}connect(){this.wsClient.connect()}disconnect(){this.wsClient.disconnect()}reconnect(){this.wsClient.reconnect()}subscribeTickers(e,t){let n=Array.isArray(e)?e:[e];this.wsClient.subscribe(n.map(s=>({topic:"ticker",params:{globalId:s}})),t)}unsubscribeTickers(e,t){let n=Array.isArray(e)?e:[e];this.wsClient.unsubscribe(n.map(s=>({topic:"ticker",params:{globalId:s}})),t)}subscribeKline(e,t,n){this.logger.debug(`subscribe kline ${e} ${t}`),this.wsClient.subscribe({topic:"candle",params:{globalId:e,resolution:t}},n)}unsubscribeKline(e,t,n){this.logger.debug(`unsubscribe kline ${e} ${t}`),this.wsClient.unsubscribe({topic:"candle",params:{globalId:e,resolution:t}},n)}async getSdkAuthParams(){let e=this.configManager.getConfig();if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER");let t=await this.configManager.getSignerAddress(e.chainId);if(!t)throw new x("INVALID_SIGNER");return{userAddress:t}}async auth(e=!1){let{userAddress:t}=await this.getSdkAuthParams();if(t===this.prevUserAddress&&this.clientAuth&&!e)return Promise.resolve();this.logger.debug(`sdkaccount: ${t}`),await this.wsClient.request({request:"signin",args:`sdkaccount.${t}`}).then(()=>{this.logger.debug(`auth success ${t}`),this.clientAuth=!0,this.prevUserAddress=t})}async subscribePosition(e){this.logger.debug("subscribe position"),await this.auth(),this.wsClient.subscribe({topic:"position"},e)}unsubscribePosition(e){this.logger.debug("unsubscribe position"),this.wsClient.unsubscribe({topic:"position"},e)}async subscribeOrder(e){this.logger.debug("subscribe order"),await this.auth(),this.wsClient.subscribe({topic:"order"},e)}unsubscribeOrder(e){this.logger.debug("unsubscribe order"),this.wsClient.unsubscribe({topic:"order"},e)}on(e,t){this.wsClient.on(e,t)}off(e,t){this.wsClient.off(e,t)}};function bs(a){return typeof a.getAddresses=="function"&&typeof a.signMessage=="function"&&typeof a.sendTransaction=="function"}function Is(a){return typeof a.getAddress=="function"&&typeof a.signMessage=="function"&&typeof a.sendTransaction=="function"}function Dt(a){let e=a;return{async getAddress(){let[t]=await a.getAddresses();if(!t)throw new Error("WalletClient: no address");return t},async signMessage(t){let n=typeof t=="string"?t:{raw:t};return await a.signMessage({message:n})},async sendTransaction(t){let n=t.to;if(!n)throw new Error("sendTransaction: to is required");return{hash:await a.sendTransaction({to:n,data:t.data,value:t.value!=null?BigInt(t.value):void 0,gas:t.gasLimit!=null?BigInt(t.gasLimit):void 0,gasPrice:t.gasPrice!=null?BigInt(t.gasPrice):void 0,maxFeePerGas:t.maxFeePerGas!=null?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas!=null?BigInt(t.maxPriorityFeePerGas):void 0})}},...typeof e.signTypedData=="function"?{async signTypedData(t){return await e.signTypedData(t)}}:{}}}function na(a){let e=a;return{getAddress:()=>a.getAddress(),signMessage:t=>a.signMessage(t),async sendTransaction(t){return{hash:(await a.sendTransaction({...t,value:t.value!=null?BigInt(t.value):void 0,gasLimit:t.gasLimit!=null?BigInt(t.gasLimit):void 0})).hash}},...typeof e.signTypedData=="function"?{async signTypedData(t){return e.signTypedData(t.domain,t.types,t.message)}}:{}}}function Be(a){return bs(a)?Dt(a):Is(a)?na(a):a}import{createWalletClient as xs,custom as hs}from"viem";function aa(a){let e=ue(a),t=[...e.privateJsonRPCUrl?[e.privateJsonRPCUrl]:[],...Array.isArray(e.publicJsonRPCUrl)?[...e.publicJsonRPCUrl]:[]].filter(Boolean);if(t.length===0)throw new Error(`${a} has no jsonRPCUrl configured`);return t[0]}var Ot={};function As(a){if(!Ot[a]){let e=ue(a);Ot[a]={id:a,name:e.label||`Chain ${a}`,nativeCurrency:e.nativeCurrency,rpcUrls:{default:{http:[aa(a)]}}}}return Ot[a]}async function sa(a,e){let t=aa(e),n=As(e),i={address:await a.getAddress(),type:"local",async signMessage({message:p}){let d=typeof p=="string"?p:p.raw;return await a.signMessage(d)},async signTypedData(p){if(!a.signTypedData)throw new Error("ISigner.signTypedData required for this operation");return await a.signTypedData({domain:p.domain,types:p.types,primaryType:p.primaryType,message:p.message})},source:"custom"};return xs({account:i,chain:n,transport:hs({request:async p=>{if(p.method==="eth_sendTransaction"){let o=p.params?.[0]??{},{hash:m}=await a.sendTransaction({to:o.to,data:o.data,value:o.value!=null?BigInt(o.value):void 0,gasLimit:o.gas!=null?BigInt(o.gas):void 0,gasPrice:o.gasPrice!=null?BigInt(o.gasPrice):void 0,maxFeePerGas:o.maxFeePerGas!=null?BigInt(o.maxFeePerGas):void 0,maxPriorityFeePerGas:o.maxPriorityFeePerGas!=null?BigInt(o.maxPriorityFeePerGas):void 0});return m}let u=await(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p.method,params:p.params??[]})})).json();if(u.error)throw new Error(u.error.message);return u.result}})})}var Le=class{constructor(e){this._normalizedSigner=null;this._getAccessTokenQueue=[];this._isGettingAccessToken=!1;let t={isTestnet:!1,isBetaMode:!1,...e};this.validateConfig(t),this.config=t}clear(){this.accessToken=void 0,this.accessTokenExpiry=void 0,this._normalizedSigner=null,this.config={...this.config,signer:void 0,walletClient:void 0,getAccessToken:void 0}}hasSigner(){return!!(this.config.walletClient||this.config.signer!=null||this._normalizedSigner!=null)}async getSignerAddress(e){if(this.config.walletClient){let[t]=await this.config.walletClient.getAddresses();if(t)return t}if(this._normalizedSigner)return this._normalizedSigner.getAddress();throw new x("INVALID_SIGNER","Invalid signer")}async getViemWalletClient(e){if(this.config.walletClient)return this.config.walletClient;if(this._normalizedSigner)return await sa(this._normalizedSigner,e);throw new x("INVALID_SIGNER","Invalid signer: call auth({ signer }) or auth({ walletClient })")}updateClientChainId(e,t){this.config={...this.config,chainId:e,brokerAddress:t}}auth(e){this.clear(),this.config={...this.config,...e},e.signer!=null&&(this._normalizedSigner=Be(e.signer)),this.validateConfig(this.config)}validateConfig(e){let{isTestnet:t,isBetaMode:n,chainId:s}=e;if(t){if(!ea.includes(s))throw new x("INVALID_CHAIN_ID",`chainId ${s} is not in the range of TESTNET_CHAIN_IDS`)}else if(n){if(!ta.includes(s))throw new x("INVALID_CHAIN_ID",`chainId ${s} is not in the range of BETA_ENV_CHAIN_IDS`)}else if(!Zn.includes(s))throw new x("INVALID_CHAIN_ID",`chainId ${s} is not in the range of MAINNET_CHAIN_IDS`)}async getAccessToken(){return this.accessToken??null}async refreshAccessToken(e=!1){return new Promise((t,n)=>{this._getAccessTokenQueue.push({resolve:t,reject:n,forceRefresh:e}),this._processAccessTokenQueue()})}_processAccessTokenQueue(){if(this._isGettingAccessToken)return;this._isGettingAccessToken=!0;let e=this._getAccessTokenQueue.shift();e?this._refreshAccessToken(e.forceRefresh).then(e.resolve).catch(e.reject).finally(()=>{this._isGettingAccessToken=!1,this._getAccessTokenQueue.length>0&&this._processAccessTokenQueue()}):this._isGettingAccessToken=!1}async _refreshAccessToken(e=!1){if(!e&&this.isAccessTokenValid())return this._isGettingAccessToken=!1,this.accessToken;if(!this.config.getAccessToken)return ye("No getAccessToken method provided in config"),null;try{let t=await this.config.getAccessToken()??{accessToken:"",expireAt:0};if(t&&t.accessToken){let n=3600;if(t.expireAt){let s=Math.floor(Date.now()/1e3);n=t.expireAt-s,n<=0&&(ye("Received expired token, using default expiry"),n=3600)}return this.setAccessToken(t.accessToken,n),t.accessToken}else return ye("\u274C Received empty accessToken"),null}catch(t){return I("\u274C Failed to refresh accessToken:",t),null}}setAccessToken(e,t=3600){this.accessToken=e,this.accessTokenExpiry=Date.now()+t*1e3}getCurrentAccessToken(){return this.accessToken}isAccessTokenValid(){return!!this.accessToken}clearAccessToken(){this.accessToken=void 0,this.accessTokenExpiry=void 0}getConfig(){return this.config}};var Ue=class{constructor(e,t,n){this.configManager=e,this.utils=t,this.api=n}getMarkets(){return Promise.resolve([])}async getPoolLevelConfig(e,t){let n=this.configManager.getConfig();return(await this.api.getPoolLevelConfig({poolId:e,chainId:t})).data}async getKlineList({interval:e,...t}){let n=this.configManager.getConfig();return(await this.api.getKlineData({...t,interval:this.utils.transferKlineResolutionToInterval(e)})).data}async getKlineLatestBar({interval:e,...t}){let n=this.configManager.getConfig();return(await this.api.getKlineLatestBar({...t,interval:this.utils.transferKlineResolutionToInterval(e)})).data}async getTickerList(e){return(await this.api.getTickerData(e)).data}async searchMarketAuth(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.searchMarketAuth({address:t,...e,accessToken:n})).data}async searchMarket(e){return(await this.api.searchMarket(e)).data}async getFavoritesList(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.getFavoritesList({...e,address:t,accessToken:n})).data}async addFavorite(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.addFavorite({...e,address:t,accessToken:n})).data}async removeFavorite(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.removeFavorite({...e,address:t,accessToken:n})).data}async getBaseDetail(e){return(await this.api.getBaseDetail(e)).data}async getMarketDetail(e){return(await this.api.getMarketDetail(e)).data}async getPoolSymbolAll(){return(await this.api.getPoolSymbolAll()).data}};import{maxUint256 as Cs}from"viem";var qe=class{constructor(e,t,n,s,i,r){this.configManager=e,this.logger=t,this.utils=n,this.seamless=s,this.account=i,this.api=r}async listPositions(e,t){let n=await this.configManager.getAccessToken();try{return{code:0,data:(await this.api.getPositions({accessToken:n??"",address:e,positionId:t})).data}}catch(s){return this.logger.error("Error fetching positions:",s),{code:-1,message:"Failed to fetch positions"}}}async getPositionHistory(e,t){let n=await this.configManager.getAccessToken()??"";return{code:0,data:(await this.api.getPositionHistory({accessToken:n,...e,address:t})).data}}async adjustCollateral({poolId:e,positionId:t,adjustAmount:n,quoteToken:s,chainId:i,address:r}){let p=this.configManager.getConfig();try{let d=await this.utils.getOraclePrice(e,i);if(!d)throw new Error("Failed to get price data");let u={poolId:e,oracleType:d.oracleType,oracleUpdateData:d?.vaa??"0",publishTime:d.publishTime},o=!1;Number(n)>0&&(o=await this.utils.needsApproval(r,i,s,n,P(i).TRADING_ROUTER));let m=BigInt(0),f=BigInt(n)>0?BigInt(n):0n,y=await this.account.getAvailableMarginBalance({poolId:e,chainId:i,address:r}),g=y.code===0?y.data??0n:0n,l=BigInt(0);g<f&&(l=f-g,m=l);let A={token:s,amount:m.toString()};if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let R=await L(i,p.brokerAddress);if(o){let K=await this.utils.approveAuthorization({chainId:i,quoteAddress:s,amount:Cs.toString(),spenderAddress:P(i).TRADING_ROUTER});if(K.code!==0)throw new Error(K.message)}let O=await R.write.updatePriceAndAdjustCollateral([[u],A,t,n],{value:BigInt(d?.value??"1"),gas:BigInt(1e7)*U[i]/100n});return await c(i).waitForTransactionReceipt({hash:O}),{code:0,data:{hash:O},message:"Adjust collateral transaction submitted"}}catch(d){return{code:-1,message:d.message}}}};var Ps={IOC:0},oe=Ps.IOC;var Ge={MARKET:0,LIMIT:1,STOP:2,CONDITIONAL:3},Uc={NONE:0,GTE:1,LTE:2},pe={INCREASE:0,DECREASE:1},qc={LONG:0,SHORT:1},Gc={IOC:0},Wc={PENDING:0,PARTIAL:1,FILLED:2,CANCELLED:3,REJECTED:4,EXPIRED:5};import{maxUint256 as ia}from"viem";var We=class{constructor(e,t,n,s,i,r){this.configManager=e,this.logger=t,this.utils=n,this.seamless=s,this.account=i,this.api=r}async createIncreaseOrder(e,t,n){try{let s=this.configManager.getConfig(),i=await this.utils.getNetworkFee(n,e.chainId),r=BigInt(i);e.tpSize&&BigInt(e.tpSize)>0&&(r+=BigInt(i)),e.slSize&&BigInt(e.slSize)>0&&(r+=BigInt(i));let p=BigInt(e.collateralAmount)+BigInt(t),d=await this.account.getAvailableMarginBalance({poolId:e.poolId,chainId:e.chainId,address:e.address}),u=d.code===0?d.data??0n:0n,o=p+r,m=BigInt(0),f=o-u;f>BigInt(0)&&(m=f);let y={token:e.executionFeeToken,amount:m.toString()},g={user:e.address,poolId:e.poolId,orderType:e.orderType,triggerType:e.triggerType,operation:pe.INCREASE,direction:e.direction,collateralAmount:p.toString(),size:e.size,price:e.price,timeInForce:oe,postOnly:e.postOnly??!1,slippagePct:e.slippagePct??"0",leverage:e.leverage??0,tpSize:e.tpSize??"0",tpPrice:e.tpPrice??"0",slSize:e.slSize??"0",slPrice:e.slPrice??"0"},l=await this.utils.needsApproval(e.address,e.chainId,e.executionFeeToken,e.collateralAmount,P(e.chainId).TRADING_ROUTER);if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");if(l){let V=await this.utils.approveAuthorization({chainId:e.chainId,quoteAddress:e.executionFeeToken,amount:ia.toString(),spenderAddress:P(e.chainId).TRADING_ROUTER});if(V.code!==0)throw new Error(V.message)}let A=await L(e.chainId,this.configManager.getConfig().brokerAddress),R;if(e.positionId){this.logger.info("createIncreaseOrder nft position params--->",{...g,positionId:e.positionId});let V=await A.estimateGas.placeOrderWithPosition([e.positionId.toString(),{...y},g]);R=await A.write.placeOrderWithPosition([e.positionId.toString(),{...y},g],{gasLimit:V*U[e.chainId]/100n})}else{this.logger.info("createIncreaseOrder salt position params--->",{positionSalt:"1",data:g,depositData:y});let ae=await A.estimateGas.placeOrderWithSalt(["1",{...y},g]);R=await A.write.placeOrderWithSalt(["1",{...y},g],{gasLimit:ae*U[e.chainId]/100n})}let O=await c(e.chainId).waitForTransactionReceipt({hash:R});return{code:0,message:"create increase order success",data:{success:!0,transactionHash:R,blockNumber:O?.blockNumber,gasUsed:O?.gasUsed?.toString(),status:O?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:O}}}catch(s){return this.logger.error("Error placing order:",s),{code:-1,message:s?.message}}}async closeAllPositions(e,t){try{let n=this.configManager.getConfig(),s={token:"0x0000000000000000000000000000000000000000",amount:"0"},i=t.map(m=>m.positionId.toString()),r=t.map(m=>({user:m.address,poolId:m.poolId,orderType:m.orderType,triggerType:m.triggerType,operation:pe.DECREASE,direction:m.direction,collateralAmount:m.collateralAmount,size:m.size,price:m.price,timeInForce:oe,postOnly:m.postOnly,slippagePct:m.slippagePct,leverage:m.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0}));if(this.logger.info("closeAllPositions params--->",s,i,r),!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let p=await L(e,this.configManager.getConfig().brokerAddress),d=await p.estimateGas.placeOrdersWithPosition([s,i,r]),u=await p.write.placeOrdersWithPosition([s,i,r],{gasLimit:d*U[e]/100n}),o=await c(e).waitForTransactionReceipt({hash:u});return{code:0,message:"close all positions success",transactionHash:u,blockNumber:o?.blockNumber,gasUsed:o?.gasUsed?.toString(),status:o?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:o}}catch(n){return{code:-1,message:n?.message}}}async createDecreaseOrder(e){try{let t=this.configManager.getConfig(),n={user:e.address,poolId:e.poolId,orderType:e.orderType,triggerType:e.triggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:e.collateralAmount,size:e.size,price:e.price,timeInForce:oe,postOnly:e.postOnly,slippagePct:e.slippagePct,leverage:e.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0},s={token:"0x0000000000000000000000000000000000000000",amount:"0"};if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let i=await L(e.chainId,this.configManager.getConfig().brokerAddress),r;if(e.positionId){this.logger.info("createDecreaseOrder nft position params--->",[e.positionId,s,{data:n}]);let u=await i.estimateGas.placeOrderWithPosition([e.positionId.toString(),s,n]);r=await i.write.placeOrderWithPosition([e.positionId.toString(),s,n],{gasLimit:u*U[e.chainId]/100n})}else{this.logger.info("createDecreaseOrder salt position params--->",[1,s,{data:n}]);let o=await i.estimateGas.placeOrderWithSalt(["1",s,n]);r=await i.write.placeOrderWithSalt(["1",s,n],{gasLimit:o*U[e.chainId]/100n})}let p=await c(e.chainId).waitForTransactionReceipt({hash:r});return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:r,blockNumber:p?.blockNumber,gasUsed:p?.gasUsed?.toString(),status:p?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:p}}}catch(t){return{code:-1,message:t?.message}}}async createPositionTpSlOrder(e){try{let t=await L(e.chainId,this.configManager.getConfig().brokerAddress);try{if(e.tpSize!=="0"&&e.slSize!=="0"){let d=[{user:e.address,poolId:e.poolId,orderType:Ge.STOP,triggerType:e.tpTriggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:"0",size:e.tpSize??"0",price:e.tpPrice??"0",timeInForce:oe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},{user:e.address,poolId:e.poolId,orderType:Ge.STOP,triggerType:e.slTriggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:"0",size:e.slSize??"0",price:e.slPrice??"0",timeInForce:oe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"}],u={token:"0x0000000000000000000000000000000000000000",amount:"0"},o;if(e.positionId){let y=await t.estimateGas.placeOrdersWithPosition([u,[e.positionId.toString(),e.positionId.toString()],d]);o=await t.write.placeOrdersWithPosition([u,[e.positionId.toString(),e.positionId.toString()],d],{gasLimit:y*U[e.chainId]/100n})}else{this.logger.info("createPositionTpSlOrder salt position data--->",d);let y=1,g=await t.estimateGas.placeOrdersWithSalt([u,[y.toString(),y.toString()],d]);o=await t.write.placeOrdersWithSalt([u,[y.toString(),y.toString()],d],{gasLimit:g*U[e.chainId]/100n})}let m=await c(e.chainId).waitForTransactionReceipt({hash:o});return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:o,blockNumber:m?.blockNumber,gasUsed:m?.gasUsed?.toString(),status:m?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:m}}}let n={user:e.address,poolId:e.poolId,orderType:Ge.STOP,triggerType:e.tpSize!=="0"?e.tpTriggerType:e.slTriggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:"0",size:e.tpSize!=="0"?e.tpSize??"0":e.slSize??"0",price:e.tpPrice!=="0"?e.tpPrice??"0":e.slPrice??"0",timeInForce:oe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:0,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},s={token:"0x0000000000000000000000000000000000000000",amount:"0"},i;if(e.positionId){this.logger.info("createPositionTpOrSlOrder nft position data--->",n);let d=await t.estimateGas.placeOrderWithPosition([e.positionId.toString(),s,n]);i=await t.write.placeOrderWithPosition([e.positionId.toString(),s,n],{gasLimit:d*U[e.chainId]/100n})}else{this.logger.info("createPositionTpOrSlOrder salt position data--->",n);let d=1,u=await t.estimateGas.placeOrderWithSalt([d.toString(),s,n]);i=await t.write.placeOrderWithSalt([d.toString(),s,n],{gasLimit:u*U[e.chainId]/100n})}let r=await c(e.chainId).waitForTransactionReceipt({hash:i});return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:i,blockNumber:r?.blockNumber,gasUsed:r?.gasUsed?.toString(),status:r?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:r}}}catch(n){return{code:-1,message:n?.message}}}catch(t){return{code:-1,message:t?.message}}}async cancelAllOrders(e,t){try{if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=await(await L(t,this.configManager.getConfig().brokerAddress)).write.cancelOrders([e]);return await c(t).waitForTransactionReceipt({hash:s}),{code:0,message:"cancel all orders success"}}catch(n){return{code:-1,message:n?.message}}}async cancelOrder(e,t){try{if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=await(await L(t,this.configManager.getConfig().brokerAddress)).write.cancelOrder([e]);return await c(t).waitForTransactionReceipt({hash:s}),{code:0,message:"cancel order success"}}catch(n){return{code:-1,message:n?.message}}}async cancelOrders(e,t){try{if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=await(await L(t,this.configManager.getConfig().brokerAddress)).write.cancelOrders([e]);return await c(t).waitForTransactionReceipt({hash:s}),{code:0,message:"Orders canceled success"}}catch(n){return this.logger.error("Error canceling orders:",n),{code:-1,message:n?.message}}}async updateOrderTpSl(e,t,n,s,i,r){let p=this.configManager.getConfig(),d=await this.utils.getNetworkFee(i,n),u={orderId:e.orderId,size:e.size,price:e.price,tpsl:{tpSize:r?e.tpSize:"0",tpPrice:r?e.tpPrice:"0",slSize:r?e.slSize:"0",slPrice:r?e.slPrice:"0"}},o={token:t,amount:d.toString()};if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let m=await L(n,p.brokerAddress);this.logger.info("updateOrderTpSl params",u);try{if(await this.utils.needsApproval(s,n,e.executionFeeToken,d.toString(),P(n).TRADING_ROUTER)){let A=await this.utils.approveAuthorization({chainId:n,quoteAddress:e.executionFeeToken,amount:ia.toString(),spenderAddress:P(n).TRADING_ROUTER});if(A.code!==0)throw new Error(A.message)}let y=await m.estimateGas.updateOrder([o,u]),g=await m.write.updateOrder([o,u],{gasLimit:y*U[n]/100n}),l=await c(n).waitForTransactionReceipt({hash:g});return this.logger.info("updateOrderTpSl receipt",l),{code:0,data:l,message:"update order success"}}catch(f){return this.logger.error("Error updating order:",f),{code:-1,message:"Failed to update order"}}}async getOrders(e){let t=await this.configManager.getAccessToken();try{return{code:0,data:(await this.api.getOrders(t??"",e)).data}}catch(n){return this.logger.error("Error fetching orders:",n),{code:-1,message:"Failed to fetch orders"}}}async getOrderHistory(e,t){let n=await this.configManager.getAccessToken()??"";return{code:0,data:(await this.api.getHistoryOrders({accessToken:n,...e,address:t})).data}}};import{decodeEventLog as ws,maxUint256 as Ts}from"viem";var ra=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotAllowedIdentifier",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"BlockHeader",inputs:[{type:"uint256",name:"blockNumber",indexed:!1},{type:"uint256",name:"blockTimestamp",indexed:!1},{type:"uint256",name:"sequence",indexed:!1}]},{type:"event",anonymous:!1,name:"CollateralAccepted",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"quoteDebt",indexed:!1},{type:"uint256",name:"baseCollateral",indexed:!1},{type:"uint256",name:"quoteCollateral",indexed:!1},{type:"uint256",name:"totalQuoteDebt",indexed:!1},{type:"uint256",name:"totalBaseCollateral",indexed:!1}]},{type:"event",anonymous:!1,name:"CollateralAdjusted",inputs:[{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint256",name:"beforeCollateralAmount",indexed:!1},{type:"uint256",name:"afterCollateralAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"EnterDispute",inputs:[{type:"bytes32",name:"poolId",indexed:!1}]},{type:"event",anonymous:!1,name:"Exchanged",inputs:[{type:"address",name:"user",indexed:!1},{type:"address",name:"source",indexed:!1},{type:"address",name:"target",indexed:!1},{type:"uint256",name:"sourceAmount",indexed:!1},{type:"uint256",name:"targetAmount",indexed:!1},{type:"uint256",name:"price",indexed:!1}]},{type:"event",anonymous:!1,name:"ExecutionMatched",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256[]",name:"triggerOrderIds",indexed:!1},{type:"uint256[]",name:"matchedOrderIds",indexed:!1},{type:"uint8",name:"matchType",indexed:!1},{type:"uint256",name:"price",indexed:!1}]},{type:"event",anonymous:!1,name:"ExitDispute",inputs:[{type:"bytes32",name:"poolId",indexed:!1}]},{type:"event",anonymous:!1,name:"FeeDistributed",inputs:[{type:"address",name:"user",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"int32",name:"tradingFeeRate",indexed:!1},{type:"bool",name:"isMaker",indexed:!1},{type:"int256",name:"tradingFee",indexed:!1},{type:"uint256",name:"baseTradingFee",indexed:!1},{type:"uint256",name:"brokerTradingFee",indexed:!1},{type:"address",name:"broker",indexed:!1},{type:"uint256",name:"referralRebate",indexed:!1},{type:"uint256",name:"referrerRebate",indexed:!1},{type:"address",name:"referrer",indexed:!1},{type:"int256",name:"reserveFee",indexed:!1}]},{type:"event",anonymous:!1,name:"FundingRateUpdated",inputs:[{type:"uint64",name:"epochs",indexed:!1},{type:"uint64",name:"duration",indexed:!1},{type:"uint64",name:"previousEpochTime",indexed:!1},{type:"uint64",name:"lastEpochTime",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"int256",name:"fundingRate",indexed:!1},{type:"int256",name:"fundingRateTracker",indexed:!1},{type:"uint256",name:"price",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityLockUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint64",name:"windowAnchor",indexed:!1},{type:"uint256",name:"priceFloor",indexed:!1},{type:"uint256",name:"priceCeiling",indexed:!1},{type:"int256",name:"openInterest",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityMigrated",inputs:[{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"fromPoolId",indexed:!1},{type:"bytes32",name:"toPoolId",indexed:!1},{type:"uint256",name:"lpAmountIn",indexed:!1},{type:"uint256",name:"lpAmountOut",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityStopOrderCancelled",inputs:[{type:"uint256",name:"orderId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"string",name:"reason",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityStopOrderCreated",inputs:[{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint8",name:"poolType",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"uint256",name:"triggerPrice",indexed:!1},{type:"uint8",name:"triggerType",indexed:!1},{type:"uint256",name:"minQuoteOut",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityStopOrderExecuted",inputs:[{type:"uint256",name:"orderId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"executor",indexed:!1},{type:"uint256",name:"oraclePrice",indexed:!1},{type:"uint256",name:"poolTokenPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"MarketCreated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"address",name:"deployer",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint32",name:"baseReserveRatio",indexed:!1},{type:"uint32",name:"quoteReserveRatio",indexed:!1},{type:"uint64",name:"oracleFeeUsd",indexed:!1},{type:"uint64",name:"oracleRefundFeeUsd",indexed:!1},{type:"uint128",name:"poolPrimeThreshold",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderCancelled",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"string",name:"remark",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderFilled",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint8",name:"orderType",indexed:!1},{type:"uint256",name:"orderSize",indexed:!1},{type:"uint256",name:"fillSize",indexed:!1},{type:"uint256",name:"filledSize",indexed:!1},{type:"uint256",name:"orderPrice",indexed:!1},{type:"uint256",name:"fillPrice",indexed:!1},{type:"int256",name:"realizedPnl",indexed:!1},{type:"int256",name:"tradingFee",indexed:!1},{type:"int256",name:"fundingFee",indexed:!1},{type:"uint256",name:"executionFeeAmount",indexed:!1},{type:"address",name:"keeper",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderMarkedADL",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"available",indexed:!1},{type:"uint256",name:"requested",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderPlaced",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint8",name:"orderType",indexed:!1},{type:"uint8",name:"operation",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint8",name:"triggerType",indexed:!1},{type:"uint256",name:"collateralAmount",indexed:!1},{type:"uint256",name:"size",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint8",name:"tif",indexed:!1},{type:"bool",name:"postOnly",indexed:!1},{type:"uint16",name:"slippagePct",indexed:!1},{type:"uint256",name:"executionFeeAmount",indexed:!1},{type:"uint16",name:"userLeverage",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"size",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint256",name:"tpSize",indexed:!1},{type:"uint256",name:"tpPrice",indexed:!1},{type:"uint256",name:"slSize",indexed:!1},{type:"uint256",name:"slPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolActivated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint8",name:"oracleType",indexed:!1},{type:"bytes32",name:"oracleFeedId",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolDeactivated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"string",name:"remark",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolDeployed",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"deployer",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"address",name:"basePoolToken",indexed:!1},{type:"address",name:"quotePoolToken",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolDeposited",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"recipient",indexed:!1},{type:"address",name:"underlyingToken",indexed:!1},{type:"address",name:"poolToken",indexed:!1},{type:"uint256",name:"underlyingIn",indexed:!1},{type:"uint256",name:"poolTokenOut",indexed:!1},{type:"uint256",name:"oraclePrice",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1},{type:"uint256",name:"poolTokenPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolFundDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"profits",indexed:!1},{type:"uint256",name:"genesisProfits",indexed:!1},{type:"uint256",name:"basePoolAmount",indexed:!1},{type:"uint256",name:"quotePoolAmount",indexed:!1},{type:"uint256",name:"genesisBasePoolAmount",indexed:!1},{type:"uint256",name:"genesisQuotePoolAmount",indexed:!1},{type:"uint256",name:"exchangedBaseFromProfits",indexed:!1},{type:"uint256",name:"exchangedBaseAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolFundingFeeSettled",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"int256",name:"prevFundingRateTracker",indexed:!1},{type:"int256",name:"nextFundingRateTracker",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"fundingFee",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolPreDeactivated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"string",name:"remark",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolPrimed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolRebateClaimed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"recipient",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolRefunded",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"receiver",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolReprimed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"primer",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolSettlementRecorded",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"poolEntryPrice",indexed:!1},{type:"int256",name:"realizedPnl",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolWithdrawn",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"recipient",indexed:!1},{type:"address",name:"underlyingToken",indexed:!1},{type:"address",name:"poolToken",indexed:!1},{type:"uint256",name:"poolTokenIn",indexed:!1},{type:"uint256",name:"underlyingOut",indexed:!1},{type:"uint256",name:"rebateOut",indexed:!1},{type:"uint256",name:"oraclePrice",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1},{type:"uint256",name:"poolTokenPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionEarlyClosed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"executeSize",indexed:!1},{type:"uint256",name:"executePrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionForceClosed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"executePrice",indexed:!1},{type:"string",name:"reason",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionLiquidated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"liquidationSize",indexed:!1},{type:"uint256",name:"liquidationPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionNFTMinted",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"oldPositionId",indexed:!1},{type:"bytes32",name:"newPositionId",indexed:!1},{type:"uint256",name:"tokenId",indexed:!1},{type:"address",name:"owner",indexed:!1},{type:"address",name:"recipient",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionRiskControlDataMigrated",inputs:[{type:"bytes32",name:"from",indexed:!1},{type:"bytes32",name:"to",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionRiskControlDataUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"freeAmount",indexed:!1},{type:"uint256",name:"lockedAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionTransfer",inputs:[{type:"address",name:"from",indexed:!1},{type:"address",name:"to",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"owner",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"beforeSize",indexed:!1},{type:"uint256",name:"afterSize",indexed:!1},{type:"uint256",name:"beforeCollateralAmount",indexed:!1},{type:"uint256",name:"afterCollateralAmount",indexed:!1},{type:"uint256",name:"entryPrice",indexed:!1},{type:"int256",name:"fundingRateIndex",indexed:!1},{type:"uint8",name:"riskTier",indexed:!1},{type:"uint256",name:"earlyClosePrice",indexed:!1}]},{type:"event",anonymous:!1,name:"ReferralRebateClaimed",inputs:[{type:"address",name:"user",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveRebateCollected",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"address",name:"keeper",indexed:!1},{type:"uint256",name:"poolAmount",indexed:!1},{type:"uint256",name:"stakingAmount",indexed:!1},{type:"uint256",name:"keeperAmount",indexed:!1},{type:"uint256",name:"treasuryAmount",indexed:!1},{type:"uint256",name:"reservedAmount",indexed:!1},{type:"uint256",name:"ecoFundAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveRebateDisbursed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"address",name:"keeper",indexed:!1},{type:"uint256",name:"poolAmount",indexed:!1},{type:"uint256",name:"stakingAmount",indexed:!1},{type:"uint256",name:"keeperAmount",indexed:!1},{type:"uint256",name:"treasuryAmount",indexed:!1},{type:"uint256",name:"reservedAmount",indexed:!1},{type:"uint256",name:"ecoFundAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"TradingFeeTierUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"uint8",name:"feeType",indexed:!1},{type:"uint8",name:"tier",indexed:!1},{type:"uint32",name:"takerFeeRate",indexed:!1},{type:"int32",name:"makerFeeRate",indexed:!1},{type:"bool",name:"isEnabled",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"UserFeeDataUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"signer",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint8",name:"tier",indexed:!1},{type:"address",name:"referrer",indexed:!1},{type:"uint32",name:"totalReferralRebatePct",indexed:!1},{type:"uint32",name:"referrerRebatePct",indexed:!1}]},{type:"event",anonymous:!1,name:"UserSettlementRecorded",inputs:[{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"int256",name:"charge",indexed:!1},{type:"int256",name:"realizedPnl",indexed:!1},{type:"int256",name:"tradingFee",indexed:!1},{type:"int256",name:"fundingFee",indexed:!1}]},{type:"event",anonymous:!1,name:"UserSpecialFeeTierUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint8",name:"oldTier",indexed:!1},{type:"uint8",name:"newTier",indexed:!1}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"emitCollateralAccepted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"quoteDebt"},{type:"uint256",name:"baseCollateral"},{type:"uint256",name:"quoteCollateral"},{type:"uint256",name:"totalQuoteDebt"},{type:"uint256",name:"totalBaseCollateral"}]}],outputs:[]},{type:"function",name:"emitCollateralAdjusted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint8",name:"direction"},{type:"uint256",name:"beforeCollateralAmount"},{type:"uint256",name:"afterCollateralAmount"}]}],outputs:[]},{type:"function",name:"emitEnterDispute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[]},{type:"function",name:"emitExchanged",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"address",name:"source"},{type:"address",name:"target"},{type:"uint256",name:"sourceAmount"},{type:"uint256",name:"targetAmount"},{type:"uint256",name:"price"}]}],outputs:[]},{type:"function",name:"emitExecutionMatched",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256[]",name:"triggerOrderIds"},{type:"uint256[]",name:"matchedOrderIds"},{type:"uint8",name:"matchType"},{type:"uint256",name:"price"}]}],outputs:[]},{type:"function",name:"emitExitDispute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[]},{type:"function",name:"emitFundingRateUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint64",name:"epochs"},{type:"uint64",name:"duration"},{type:"uint64",name:"previousEpochTime"},{type:"uint64",name:"lastEpochTime"},{type:"bytes32",name:"poolId"},{type:"int256",name:"fundingRate"},{type:"int256",name:"fundingRateTracker"},{type:"uint256",name:"price"}]}],outputs:[]},{type:"function",name:"emitLiquidityLockUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint64",name:"windowAnchor"},{type:"uint256",name:"priceFloor"},{type:"uint256",name:"priceCeiling"},{type:"int256",name:"openInterest"}]}],outputs:[]},{type:"function",name:"emitLiquidityMigrated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"bytes32",name:"fromPoolId"},{type:"bytes32",name:"toPoolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"lpAmountOut"}]}],outputs:[]},{type:"function",name:"emitLiquidityStopOrderCancelled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"bytes32",name:"poolId"},{type:"string",name:"reason"}]}],outputs:[]},{type:"function",name:"emitLiquidityStopOrderCreated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"poolType"},{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}],outputs:[]},{type:"function",name:"emitLiquidityStopOrderExecuted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"bytes32",name:"poolId"},{type:"address",name:"executor"},{type:"uint256",name:"oraclePrice"},{type:"uint256",name:"poolTokenPrice"}]}],outputs:[]},{type:"function",name:"emitMarketCreated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"marketId"},{type:"address",name:"deployer"},{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint64",name:"oracleRefundFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"}]}],outputs:[]},{type:"function",name:"emitOrderCancelled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"emitOrderFilled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint8",name:"orderType"},{type:"uint256",name:"orderSize"},{type:"uint256",name:"fillSize"},{type:"uint256",name:"filledSize"},{type:"uint256",name:"orderPrice"},{type:"uint256",name:"fillPrice"},{type:"int256",name:"realizedPnl"},{type:"int256",name:"tradingFee"},{type:"int256",name:"fundingFee"},{type:"uint256",name:"executionFeeAmount"},{type:"address",name:"keeper"}]}],outputs:[]},{type:"function",name:"emitOrderMarkedADL",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"available"},{type:"uint256",name:"requested"}]}],outputs:[]},{type:"function",name:"emitOrderPlaced",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"tif"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint256",name:"executionFeeAmount"},{type:"uint16",name:"userLeverage"}]}],outputs:[]},{type:"function",name:"emitOrderUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"emitPoolActivated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"oracleType"},{type:"bytes32",name:"oracleFeedId"}]}],outputs:[]},{type:"function",name:"emitPoolDeactivated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"emitPoolDeployed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"deployer"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"}]}],outputs:[]},{type:"function",name:"emitPoolDeposited",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"},{type:"address",name:"underlyingToken"},{type:"address",name:"poolToken"},{type:"uint256",name:"underlyingIn"},{type:"uint256",name:"poolTokenOut"},{type:"uint256",name:"oraclePrice"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"}]}],outputs:[]},{type:"function",name:"emitPoolFundDistributed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"profits"},{type:"uint256",name:"genesisProfits"},{type:"uint256",name:"basePoolAmount"},{type:"uint256",name:"quotePoolAmount"},{type:"uint256",name:"genesisBasePoolAmount"},{type:"uint256",name:"genesisQuotePoolAmount"},{type:"uint256",name:"exchangedBaseFromProfits"},{type:"uint256",name:"exchangedBaseAmount"}]}],outputs:[]},{type:"function",name:"emitPoolFundingFeeSettled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"int256",name:"prevFundingRateTracker"},{type:"int256",name:"nextFundingRateTracker"},{type:"uint256",name:"price"},{type:"uint8",name:"direction"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"fundingFee"}]}],outputs:[]},{type:"function",name:"emitPoolPreDeactivated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"emitPoolPrimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}]}],outputs:[]},{type:"function",name:"emitPoolRebateClaimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"},{type:"uint256",name:"amount"}]}],outputs:[]},{type:"function",name:"emitPoolRefunded",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"receiver"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}]}],outputs:[]},{type:"function",name:"emitPoolReprimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"primer"},{type:"address",name:"token"},{type:"uint256",name:"amount"}]}],outputs:[]},{type:"function",name:"emitPoolSettlementRecorded",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"poolEntryPrice"},{type:"int256",name:"realizedPnl"}]}],outputs:[]},{type:"function",name:"emitPoolWithdrawn",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"},{type:"address",name:"underlyingToken"},{type:"address",name:"poolToken"},{type:"uint256",name:"poolTokenIn"},{type:"uint256",name:"underlyingOut"},{type:"uint256",name:"rebateOut"},{type:"uint256",name:"oraclePrice"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"}]}],outputs:[]},{type:"function",name:"emitPositionEarlyClosed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"executeSize"},{type:"uint256",name:"executePrice"}]}],outputs:[]},{type:"function",name:"emitPositionForceClosed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"executePrice"},{type:"string",name:"reason"}]}],outputs:[]},{type:"function",name:"emitPositionLiquidated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"liquidationSize"},{type:"uint256",name:"liquidationPrice"}]}],outputs:[]},{type:"function",name:"emitPositionNFTMinted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bytes32",name:"oldPositionId"},{type:"bytes32",name:"newPositionId"},{type:"uint256",name:"tokenId"},{type:"address",name:"owner"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"emitPositionRiskControlDataMigrated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"from"},{type:"bytes32",name:"to"}]}],outputs:[]},{type:"function",name:"emitPositionRiskControlDataUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"freeAmount"},{type:"uint256",name:"lockedAmount"}]}],outputs:[]},{type:"function",name:"emitPositionTransfer",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"bytes32",name:"positionId"}]}],outputs:[]},{type:"function",name:"emitPositionUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"owner"},{type:"bytes32",name:"positionId"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"direction"},{type:"uint256",name:"orderId"},{type:"uint256",name:"beforeSize"},{type:"uint256",name:"afterSize"},{type:"uint256",name:"beforeCollateralAmount"},{type:"uint256",name:"afterCollateralAmount"},{type:"uint256",name:"entryPrice"},{type:"int256",name:"fundingRateIndex"},{type:"uint8",name:"riskTier"},{type:"uint256",name:"earlyClosePrice"}]}],outputs:[]},{type:"function",name:"emitReferralRebateClaimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"address",name:"token"},{type:"uint256",name:"amount"}]}],outputs:[]},{type:"function",name:"emitReserveRebateCollected",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"token"},{type:"uint256",name:"amount"},{type:"address",name:"keeper"},{type:"uint256",name:"poolAmount"},{type:"uint256",name:"stakingAmount"},{type:"uint256",name:"keeperAmount"},{type:"uint256",name:"treasuryAmount"},{type:"uint256",name:"reservedAmount"},{type:"uint256",name:"ecoFundAmount"}]}],outputs:[]},{type:"function",name:"emitReserveRebateDisbursed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"token"},{type:"uint256",name:"amount"},{type:"address",name:"keeper"},{type:"uint256",name:"poolAmount"},{type:"uint256",name:"stakingAmount"},{type:"uint256",name:"keeperAmount"},{type:"uint256",name:"treasuryAmount"},{type:"uint256",name:"reservedAmount"},{type:"uint256",name:"ecoFundAmount"}]}],outputs:[]},{type:"function",name:"emitTradingFeeTierUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"uint8",name:"feeType"},{type:"uint8",name:"tier"},{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"},{type:"bool",name:"isEnabled"}]}],outputs:[]},{type:"function",name:"emitUserFeeDataUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"signer"},{type:"address",name:"user"},{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]}],outputs:[]},{type:"function",name:"emitUserFeeSettlementAndDistributed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"int256",name:"charge"},{type:"int256",name:"realizedPnl"},{type:"int256",name:"tradingFee"},{type:"int256",name:"fundingFee"},{type:"int32",name:"tradingFeeRate"},{type:"bool",name:"isMaker"},{type:"uint256",name:"baseTradingFee"},{type:"uint256",name:"brokerTradingFee"},{type:"address",name:"broker"},{type:"uint256",name:"referralRebate"},{type:"uint256",name:"referrerRebate"},{type:"address",name:"referrer"},{type:"int256",name:"reserveFee"}]}],outputs:[]},{type:"function",name:"emitUserSpecialFeeTierUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"uint8",name:"oldTier"},{type:"uint8",name:"newTier"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isBlockHeaderEmitted",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"blockNumber"}],outputs:[{type:"bool"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"registerContract",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"identifiers"}],outputs:[]},{type:"function",name:"sequencer",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var Ft={"0xfa52dfc0":"AccountInsufficientFreeAmount()","0xe2a1a260":"AccountInsufficientReservedAmount()","0xffd10028":"AccountInsufficientTradableAmount(uint256,uint256)","0x9996b315":"AddressEmptyCode(address)","0x4c9c8ce3":"ERC1967InvalidImplementation(address)","0xb398979f":"ERC1967NonPayable()","0xd6bda275":"FailedCall()","0xf92ee8a9":"InvalidInitialization()","0x44d3438f":"NotAddressManager()","0x3fc81f20":"NotDependencyManager()","0xd7e6bcf8":"NotInitializing()","0x507f487a":"NotProxyAdmin()","0xe03f6024":"PermissionDenied(address,address)","0x5274afe7":"SafeERC20FailedOperation(address)","0xe07c8dba":"UUPSUnauthorizedCallContext()","0xaa1d49a4":"UUPSUnsupportedProxiableUUID(bytes32)","0x24775e06":"SafeCastOverflowedUintToInt(uint256)","0xba767932":"ConvertAmountMismatch(uint256,uint256)","0xd93c0665":"EnforcedPause()","0x8dfc202b":"ExpectedPause()","0x059e2f49":"InRewindMode()","0x42301c23":"InsufficientOutputAmount()","0xcaa99aac":"MismatchExecuteFee(uint256,uint256,uint256)","0x8637dfc0":"NotInRewindMode()","0x4578ddb8":"OnlyRelayer()","0x1e4fbdf7":"OwnableInvalidOwner(address)","0x118cdaa7":"OwnableUnauthorizedAccount(address)","0x3ee5aeb5":"ReentrancyGuardReentrantCall()","0x90b8ec18":"TransferFailed()","0xbe1af266":"InternalOnly()","0x3385aa1f":"ExceedOrderSize(uint256)","0xb07e3bc4":"InsufficientCollateral(uint256,uint256)","0x613970e0":"InvalidParameter()","0x27d08510":"NotActiveBroker(address)","0xf6412b5a":"NotOrderOwner()","0x70d645e3":"NotPositionOwner()","0xe75316c6":"OrderNotExist(OrderId)","0xba01b06f":"PoolNotActive(PoolId)","0xddefae28":"AlreadyMinted()","0x64283d7b":"ERC721IncorrectOwner(address,uint256,address)","0x177e802f":"ERC721InsufficientApproval(address,uint256)","0xa9fbf51f":"ERC721InvalidApprover(address)","0x5b08ba18":"ERC721InvalidOperator(address)","0x89c62b64":"ERC721InvalidOwner(address)","0x64a0ae92":"ERC721InvalidReceiver(address)","0x73c6ac6e":"ERC721InvalidSender(address)","0x7e273289":"ERC721NonexistentToken(uint256)","0xb4762117":"ExceedMaxLeverage(PositionId)","0x29143a42":"ExceedPositionSize()","0x8ea9158f":"InvalidPosition(PositionId)","0xa5afd143":"PositionNotHealthy(PositionId,uint256)","0xba0d3752":"PositionNotInitialized(PositionId)","0xc20f35b7":"UnderflowOI()","0xf4d678b8":"InsufficientBalance()","0x6aee3c1a":"InsufficientRiskReserves()","0x2c5211c6":"InvalidAmount()","0x82cb17ef":"InvalidSplitConfig()","0xe921c36b":"AlreadyMigrated(PositionId,PositionId)","0xd34e366f":"ExceedBaseCollateral(uint256,uint256)","0xc7544914":"ExceedDebt(uint256,uint256)","0xe7aa687a":"ExceedExchangeable()","0x4b3c8f33":"ExceedMaxBaseProfit()","0xdc82bd68":"ExceedMinOutputAmount()","0xdb42144d":"InsufficientBalance(address,uint256,uint256)","0x5646203f":"InsufficientCollateral(PositionId,uint256)","0x9ac13039":"InsufficientPoolProfit()","0x14be833f":"InsufficientReturnAmount(uint256,uint256)","0x419ecd12":"MatchNotSupported()","0x4ec4fd74":"PoolFundingFeeNotPositive(int256,uint256,Direction)","0xba8f5df5":"PoolNotCompoundable(PoolId)","0xf645eedf":"ECDSAInvalidSignature()","0xfce698f7":"ECDSAInvalidSignatureLength(uint256)","0xd78bce0c":"ECDSAInvalidSignatureS(bytes32)","0x48834bee":"ExpiredFeeData()","0x56d69198":"InvalidFeeRate()","0x80577032":"NoRebateToClaim()","0x6e6b79b0":"NotBrokerSigner(address)","0xff70343d":"UnsupportedAssetClass(AssetClass)","0x185676be":"UnsupportedFeeTier(uint8)","0x60b25fe4":"BrokerAlreadyExists()","0x7eb4a674":"BrokerNotFound()","0x8c3b5bf0":"NotBrokerAdmin()","0x3733548a":"InvalidFeeTier()","0x192105d7":"InitializationFunctionReverted(address,bytes)","0x97c7f537":"ExcessiveSlippage()","0x700deaad":"InvalidADLPosition(OrderId,PositionId)","0xf64fa6a8":"InvalidOrder(OrderId)","0xd4944235":"NoADLNeeded(OrderId)","0xe079169e":"NotReachedPrice(OrderId,uint256,uint256,TriggerType)","0xc60eb335":"OnlyKeeper()","0xa8ce4432":"SafeCastOverflowedIntToUint(int256)","0x17229ec4":"NotMeetEarlyCloseCriteria(PositionId)","0x0dc149f0":"AlreadyInitialized()","0x7a5c919f":"InvalidRewindPrice()","0xc53f84e7":"PositionRemainsHealthy(PositionId)","0x1dab59cf":"InvalidOrderPair(OrderId,OrderId)","0x230e8e43":"PoolNotInPreBenchState(PoolId)","0x107dec14":"RiskCloseNotAllowed()","0x664431a8":"NotAllowedTarget(address)","0x03357c6c":"ExceedsMaximumRelayFee()","0x0d10f63b":"InconsistentParamsLength()","0x38802743":"InsufficientFeeAllowance(address,uint256,uint256)","0xd95b4ad5":"InsufficientFeeBalance(address,uint256,uint256)","0xa3972305":"MismatchedSender(address)","0xc3b80e86":"RelayerRegistered(address)","0xee0844a3":"RemoveRelayerFailed()","0xc583a8da":"IncorrectFee(uint256)","0x00bfc921":"InvalidPrice()","0x148cd0dd":"VerifyPriceFailed()","0xb12d13eb":"ETHTransferFailed()","0xa83325d4":"PoolOracleFeeCharged()","0x6b75f90d":"PoolOracleFeeNotCharged()","0x42a0e2a7":"PoolOracleFeeNotExisted()","0x8ee01e1c":"PoolOracleFeeNotSoldOut()","0x5e0a829b":"ETHTransferFailed(address,uint256)","0x4ba6536f":"GasLimitExceeded(address,uint256,uint256)","0xca1aae4b":"GasLimitNotSet(address)","0x3728b83d":"InvalidAmount(uint256)","0x3484727e":"BaseFeeNotSoldOut()","0x0251bde4":"LPNotFullyMinted()","0x1acb203e":"PositionNotEmpty()","0x2be7b24b":"UnexpectedPoolState()","0x759b3876":"UnhealthyAfterRiskTierApplied(PositionId)","0x7bd42a2e":"NotEmptyAddress()","0x6697b232":"AccessControlBadConfirmation()","0xe2517d3f":"AccessControlUnauthorizedAccount(address,bytes32)","0x7c9a1cf9":"AlreadyVoted()","0x796ea3a6":"BondNotReleased()","0x6511c20d":"BondZeroAmount()","0xf38e5973":"CaseAppealNotFinished()","0x1eaa4a59":"CaseDeadlineNotReached()","0xe6c67e3a":"CaseDeadlineReached()","0x0fc957b1":"CaseNotAccepted()","0x3ddb819d":"CaseNotExist(CaseId)","0x79eab18d":"CaseRespondentAppealed(CaseId,address)","0xa179f8c9":"ChainIdMismatch()","0x311c16d3":"DisputeNotAllowed()","0x752d88c0":"InvalidAccountNonce(address,uint256)","0xa710429d":"InvalidContractAddress()","0x8076dd8a":"InvalidFunctionSignature()","0xc37906a0":"InvalidPayloadLength(uint256,uint256)","0xdcdedda9":"InvalidPoolToken()","0x3471a3c2":"InvalidProfitAmount()","0x1d9617a0":"InvalidResponseVersion()","0x9284b197":"InvalidSourceChain()","0xb9021668":"NoChainResponse()","0xc546bca4":"NotCaseRespondent(CaseId,address)","0x84ae4a30":"NumberOfResponsesMismatch()","0x02164961":"RequestTypeMismatch()","0x4cf72652":"RiskCloseNotCompleted()","0x0819bdcd":"SignatureExpired()","0xc00ca938":"UnexpectedCaseState()","0x7935e939":"UnexpectedCaseType()","0x5e7bd6ec":"UnexpectedNumberOfResults()","0x51ee5853":"UnsupportedQueryType(uint8)","0x29ca666b":"UntrustfulVoting()","0x439cc0cd":"VerificationFailed()","0x714f5513":"VersionMismatch()","0x96b8e05b":"WrongQueryType(uint8,uint8)","0xbb6b170d":"ZeroQueries()","0xa9214540":"AlreadyClaimed(CaseId,address)","0xd4ac59c1":"InvalidAmount(CaseId,address)","0x7a6f5328":"MerkleTreeVerificationFailed(CaseId,address)","0x094a5cfe":"ReimbursementValidity(CaseId)","0x8b922563":"TreeAlreadySet()","0x7b27120a":"InDisputeMode()","0xb04111ef":"InsufficientFreeCollateral(PositionId,uint256)","0x12f1b11a":"InsufficientLockedCollateral(PositionId,uint256)","0x6dfcc650":"SafeCastOverflowedUintDowncast(uint8,uint256)","0xd24b47fb":"UserProfitFrozen()","0x1c151780":"ExceedMinOutput(uint256,uint256)","0xe1f0493d":"NotAllowedCaller(address)","0xfb8f41b2":"ERC20InsufficientAllowance(address,uint256,uint256)","0xe450d38c":"ERC20InsufficientBalance(address,uint256,uint256)","0xe602df05":"ERC20InvalidApprover(address)","0xec442f05":"ERC20InvalidReceiver(address)","0x96c6fd1e":"ERC20InvalidSender(address)","0x94280d62":"ERC20InvalidSpender(address)","0x62791302":"ERC2612ExpiredSignature(uint256)","0x4b800e46":"ERC2612InvalidSigner(address,address)","0xb3512b0c":"InvalidShortString()","0x305a27a9":"StringTooLong(string)","0xfd0f789d":"ExceedMaxPriceDeviation()","0x407b87e5":"ExchangeRateAlreadyApplied()","0x5c6c5686":"ExchangeRateAlreadyDisabled()","0x1ae17fcd":"InvalidDeviationRatio()","0x18b88897":"InvalidUpdateFee()","0xf76740e3":"PriceDeviationBelowMinimum()","0x49386283":"PriceDeviationThresholdReached()","0x19abf40e":"StalePrice()","0xe351cd13":"ExceedMaxExchangeableAmount()","0x15912a6f":"NotSupportVersion()","0xf1364a74":"ArrayEmpty()","0x15ed381d":"ExceedMaxProfit()","0x51aeee6c":"PoolNotExist(PoolId)","0x70f6c197":"InvalidQuoteTokenAddress()","0x0b8457f4":"InvalidRatioParams()","0x29dae146":"MarketAlreadyExisted()","0xf040b67a":"MarketNotExisted()","0x0e442a4a":"InvalidBaseToken()","0x24e219c7":"MarketNotExist(MarketId)","0xcc36f935":"PoolExists(PoolId)","0xe84c308d":"ExceedBaseReserved(uint256,uint256)","0x3e241751":"ExceedQuoteReserved(uint256,uint256)","0xde656889":"ExceedReservable(uint256,uint256,uint256)","0xd54d0fc4":"InsufficientLiquidity(uint256,uint256,uint256)","0x7e562a65":"InvalidDistributionAmount()","0x83c7580d":"ReservableNotEnough(uint256,uint256)","0x94eef58a":"ERC2771ForwarderExpiredRequest(uint48)","0xc845a056":"ERC2771ForwarderInvalidSigner(address,address)","0x70647f79":"ERC2771ForwarderMismatchedValue(uint256,uint256)","0xd2650cd1":"ERC2771UntrustfulTarget(address,address)","0xcf479181":"InsufficientBalance(uint256,uint256)","0x4c150d8f":"DifferentMarket(PoolId,PoolId)","0xaa98b06a":"InsufficientQuoteIn(uint256,uint256,uint256)","0x3e589bee":"InvalidLiquidityAmount()","0xaebd3617":"InvalidTpsl(uint256)","0x7fe81129":"SamePoolMigration(PoolId)","0x71c4efed":"SlippageExceeded(uint256,uint256)","0x62b9bc7b":"DesignatedTokenMismatch(address,address)","0x49465eb0":"NotForwardAllowedTarget(address)","0x301b6707":"ExecutionFeeNotCollected()","0xc6e8248a":"InsufficientSize()","0xd15b4fe2":"InvalidQuoteToken()","0xd8daec7c":"MarketNotInitialized()","0xcd4891b6":"NotInDisputeMode()","0x1ad308dc":"OrderExpired(OrderId)","0x486aa307":"PoolNotInitialized()"};var ze=class{constructor(e,t){this.configManager=e,this.logger=t}getOrderIdFromTransaction(e){if(!e||!e.logs)return null;for(let t=0;t<e.logs.length;t++){let n=e.logs[t];this.logger.info(`Log ${t}:`,{address:n.address,topics:n.topics,data:n.data});try{let s=ws({abi:ra,data:n.data??"0x",topics:n.topics??[]}),i=s.args;if(s.eventName==="OrderPlaced"&&i?.orderId!=null)return String(i.orderId)}catch{continue}}return null}async getApproveQuoteAmount(e,t,n,s){try{if(!n||typeof n=="string"&&!n.trim())throw new Error("getApproveQuoteAmount: tokenAddress is required (ERC20 contract address)");let i=s??P(t).Account,p=await se(t,n).read.allowance([e,i]);return{code:0,data:String(p)}}catch(i){throw this.logger.error("Error getting allowance:",i),typeof i=="string"?i:await b(i)}}async needsApproval(e,t,n,s,i){try{let p=(await this.getApproveQuoteAmount(e,t,n,i)).data,d=BigInt(p),u=BigInt(s);return d<u}catch(r){return this.logger.error("Error checking approval needs:",r),!0}}async approveAuthorization({chainId:e,quoteAddress:t,amount:n,spenderAddress:s}){try{let i=await ke(e,t),r=n??Ts,p=s??P(e).Account,d=await this.getGasPriceByRatio(),u=await i.write.approve([p,r],{gasPrice:d});return await c(e).waitForTransactionReceipt({hash:u}),{code:0,message:"Approval success"}}catch(i){return this.logger.error("Approval error:",i),{code:-1,message:i?.message}}}async getUserTradingFeeRate(e,t,n,s){let r=this.configManager.getConfig().brokerAddress;try{let p=de(n,r),d=s??await this.configManager.getSignerAddress(n),u=await p.read.getUserFeeRate([d,e,t]);return{code:0,data:{takerFeeRate:u[0].toString(),makerFeeRate:u[1].toString(),baseTakerFeeRate:u[2].toString(),baseMakerFeeRate:u[3].toString()}}}catch(p){return this.logger.error("Error getting user trading fee rate:",p),{code:-1,message:p?.message??"Unknown error"}}}async getNetworkFee(e,t){try{return(await(await ee(t,0)).read.getExecutionFee([e])).toString()}catch(n){return this.logger.error("Error getting network fee:",n),"0"}}async getOraclePrice(e,t){try{let n=await B(t,e);if(!n)throw new Error("Failed to get price data");return n}catch(n){throw this.logger.error("Error getting oracle price:",n),n}}async buildUpdatePriceParams(e,t){let n=await this.getOraclePrice(e,t);if(!n)throw new Error("Failed to get price data");return[{poolId:e,oracleUpdateData:n.vaa,publishTime:n.publishTime,oracleType:n.oracleType,value:n.value,price:n.price}]}transferKlineResolutionToInterval(e){switch(e){case"1m":return 1;case"5m":return 5;case"15m":return 15;case"30m":return 30;case"1h":return 60;case"4h":return 240;case"1d":return 1440;case"1w":return 10080;case"1M":return 40320;default:throw new x("PARAM_ERROR",`Invalid kline resolution: ${e}`)}}async getErrorMessage(e,t="Unknown error"){try{if(typeof e=="string")return e;if(e instanceof x)return e.message;let n=await b(e);return n?n.error:JSON.stringify(e)}catch(n){return n?.message??n?.toString()??t}}async getLiquidityInfo({chainId:e,poolId:t,marketPrice:n}){try{return{code:0,data:await(await me(e,0)).read.getPoolInfo([t,n])}}catch(s){return this.logger.error("Error getting pool info:",s),{code:-1,message:s?.message}}}formatErrorMessage(e){if(typeof e=="string")return e;if(e instanceof x)return e.message;if(e?.code==="ACTION_REJECTED"||e?.code===4001||e?.info?.error?.code===4001||typeof e?.message=="string"&&(e.message.toLowerCase().includes("user rejected")||e.message.toLowerCase().includes("denied")))return"User Rejected";let t=e?.data;if(!t&&e?.message&&typeof e.message=="string"){let n=e.message.match(/data=["'](0x[0-9a-fA-F]+)["']/i);n&&n[1]&&(t=n[1])}if(t){let n=typeof t=="string"&&t.startsWith("0x")?t.slice(0,10).toLowerCase():null;if(n){let s=Object.keys(Ft).find(i=>i.toLowerCase()===n);if(s)return Ft[s]}}return e?.reason?e.reason:e?.message?e.message:JSON.stringify(e)}async getGasPriceByRatio(){let e=this.configManager.getConfig().chainId;return(await v(e)).gasPrice}async getGasLimitByRatio(e){let t=this.configManager.getConfig().chainId,n=C[t];return T(e,n?.gasLimitRatio??1.3)}};import{maxUint256 as vs,zeroAddress as Es}from"viem";import oa from"dayjs";var Ve=class{constructor(e,t,n,s){this.configManager=e,this.logger=t,this.utils=n,this.client=s}async withRetry(e,t=3,n=300){let s;for(let i=0;i<t;i++)try{return await e()}catch(r){s=r,i<t-1&&await new Promise(p=>setTimeout(p,n))}throw s}async getTradeFlow(e,t){let n=await this.configManager.getAccessToken()??"";return{code:0,data:(await this.client.api.getTradeFlow({accessToken:n,...e,address:t})).data}}async getWalletQuoteTokenBalance({chainId:e,address:t,tokenAddress:n}){if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=se(e,n),i=await this.configManager.getSignerAddress(e);return{code:0,data:await s.read.balanceOf([t||i])}}async updateAndWithdraw(e,t,n,s,i){try{let p=await(await lt(i)).write.updateAndWithdraw([e,t,n,s]);return{code:0,data:await c(i).waitForTransactionReceipt({hash:p})}}catch(r){return{code:-1,message:r.message}}}async deposit({amount:e,tokenAddress:t,chainId:n}){let s=this.configManager.hasSigner()?await this.configManager.getSignerAddress(n):"",i=P(n);try{if(await this.utils.needsApproval(s,n,t,e,i.Account)){let o=await this.utils.approveAuthorization({chainId:n,quoteAddress:t,amount:vs.toString(),spenderAddress:i.Account});if(o.code!==0)throw new Error(o.message)}let d=await(await lt(n)).write.deposit([s,t,e]);return{code:0,data:await c(n).waitForTransactionReceipt({hash:d})}}catch(r){return{code:-1,message:r.message}}}async getAvailableMarginBalance({poolId:e,chainId:t,address:n}){try{let s=await this.getAccountInfo(t,n,e);if(s.code!==0)throw new x("REQUEST_FAILED","Failed to get account info");let i=await this.client.appeal.getAppealStatus(e,t,n),r=s.data,p=BigInt(r?.quoteProfit??0),d=BigInt(r?.freeMargin??0),u=BigInt(r?.lockedMargin??0),o=i?.code===0?i.data:null,m=o?.status===1?BigInt(o?.lockedMargin??0):0n;return{code:0,data:d+p-u-m}}catch(s){return{code:-1,message:s.message}}}async getAccountInfo(e,t,n){let s=await me(e);try{return{code:0,data:await s.read.getAccountInfo([n,t])}}catch(i){return{code:-1,message:i.message}}}async getAccountVipInfo(e,t){let n=this.configManager.getConfig(),s=de(e,n.brokerAddress),r=await c(e).getBlock({blockTag:"latest"}),p=Number(r?.timestamp??BigInt(oa().unix()))+300,d=await this.configManager.getAccessToken()??"";try{let u=await this.client.api.getCurrentEpoch({address:t,accessToken:d,broker:n.brokerAddress});if(u.code!==9200)throw new x("REQUEST_FAILED",u.msg??"Failed to get current epoch");let o=await s.read.userFeeData([u?.data??0,t]),m;try{m=await this.withRetry(()=>s.read.userNonces([t]))}catch{m=0n}return{code:0,data:{...o,nonce:m.toString(),deadline:p}}}catch(u){return{code:-1,message:u.message}}}async getAccountVipInfoByBackend(e,t,n,s){let i=await this.configManager.getAccessToken()??"";try{let r=await this.client.api.getAccountVipInfo({address:e,accessToken:i,chainId:t,deadline:n,nonce:s});if(r.code!==9200)throw new x("REQUEST_FAILED",r.msg??"Failed to get account vip info");return{code:0,data:r.data}}catch(r){return{code:-1,message:r.message}}}async setUserFeeData(e,t,n,s,i){let r=this.configManager.getConfig();if(n<oa().unix())throw new x("REQUEST_FAILED","Invalid deadline, please try again");let p={user:e,nonce:s.nonce,deadline:n,feeData:{tier:s.tier,referrer:s.referrer||Es,totalReferralRebatePct:s.totalReferralRebatePct,referrerRebatePct:s.referrerRebatePct},signature:i};try{let d=await L(t,r.brokerAddress),u=await d.read.userNonces([e]);if(parseInt(u.toString())+1!==parseInt(s.nonce.toString()))throw new x("REQUEST_FAILED","Invalid nonce, please try again");let o=await d.write.setUserFeeData([p]);return{code:0,data:await c(t).waitForTransactionReceipt({hash:o})}}catch(d){return{code:-1,message:d.message}}}};function ua(a,e){return`${encodeURIComponent(a)}=${encodeURIComponent(typeof e=="number"?e:`${e}`)}`}function ks(a,e){return ua(e,a[e])}function Ss(a,e){return a[e].map(n=>ua(e,n)).join("&")}function Ms(a){let e=a||{};return Object.keys(e).filter(n=>typeof e[n]<"u").map(n=>Array.isArray(e[n])?Ss(e,n):ks(e,n)).join("&")}function Nt(a){let e=Ms(a);return e?`?${e}`:""}import{merge as $e}from"lodash-es";var He=class{constructor(e){this.configManager=e}getHost(){let{isTestnet:e,isBetaMode:t}=this.configManager.getConfig();return t?"https://api-beta.myx.finance":e?"https://api-test.myx.cash":"https://api.myx.finance"}async buildAuthParams(){let e=this.configManager.getConfig();if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER");let t=await this.configManager.getAccessToken()??"",n=await this.configManager.getSignerAddress(e.chainId);if(!n)throw new x("INVALID_SIGNER");return{headers:{myx_openapi_access_token:t,myx_openapi_account:n}}}buildRequestPath(e){return e.startsWith("http")?e:this.getHost()+e}async get(e,t,{auth:n=!1,...s}={}){let i=n?await this.buildAuthParams():{};return h.get(this.buildRequestPath(e),t,$e(i,s))}async post(e,t,{auth:n=!1,...s}={}){let i=n?await this.buildAuthParams():{};return h.post(this.buildRequestPath(e),t,$e(i,s))}async put(e,t,{auth:n=!1,...s}={}){let i=n?await this.buildAuthParams():{};return h.put(this.buildRequestPath(e),t,$e(i,s))}async delete(e,{auth:t=!1,...n}={}){let s=t?await this.buildAuthParams():{};return h.delete(this.buildRequestPath(e),$e(s,n))}};var Qe=class extends He{constructor(e,t){super(e),this.logger=t}async getTradeFlow({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/trade/flow`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getPoolSymbolAll(){return h.get(`${this.getHost()}/openapi/gateway/scan/pools`)}async fetchForwarderGetApi(e){return await h.get(`${this.getHost()}/v2/agent/forwarder/get${Nt(e)}`)}async getPoolList(){return h.get(`${this.getHost()}/openapi/gateway/scan/market/list`)}async forwarderTxApi(e,t){return h.post(`${this.getHost()}/v2/agent/forwarder/tx-v2`,e,{headers:{"myx-chain-id":t.toString()}})}async getOraclePrice(e,t=[]){if(t.length)return h.get(`${this.getHost()}/openapi/gateway/quote/price/oracles`,{chainId:e,poolIds:t.join(",")});throw new Error("Invalid pool id")}async getPoolDetail(e,t){return await h.get(`${this.getHost()}/openapi/gateway/scan/market/info?chainId=${e}&poolId=${t}`)}async getPoolLevelConfig({poolId:e,chainId:t}){return h.get(`${this.getHost()}/openapi/gateway/risk/market_pool/level_config${Nt({poolId:e,chainId:t})}`)}async getPositions({accessToken:e,address:t,positionId:n}){return await h.get(`${this.getHost()}/openapi/gateway/scan/position/open`,{positionId:n},{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getOrders(e,t){return await h.get(`${this.getHost()}/openapi/gateway/scan/order/open`,void 0,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getPoolOpenOrders(e,t,n){return await h.get(`${this.getHost()}/openapi/gateway/scan/market/pool-order/open?chainId=${n}`,void 0,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getKlineData({chainId:e,poolId:t,endTime:n,limit:s,interval:i}){return h.get(`${this.getHost()}/openapi/gateway/quote/candles`,{chainId:e,poolId:t,endTime:n,limit:s,interval:i})}async getKlineLatestBar(e){return h.get(`${this.getHost()}/openapi/gateway/quote/candle/latest`,e)}async getTickerData({chainId:e,poolIds:t}){return h.get(`${this.getHost()}/openapi/gateway/quote/candle/tickers`,{chainId:e,poolIds:t.join(",")})}async getAllTickers(){return h.get(`${this.getHost()}/v2/mx-gateway/quote/candle/all_tickers`)}async searchMarketAuth({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/ac-search`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async searchMarket({...e}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/search`,e)}async addFavorite({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/add-favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async removeFavorite({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/cancel-favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getFavoritesList({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getBaseDetail({...e}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/base-details`,e)}async getMarketDetail({...e}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/detail`,e)}async getHistoryOrders({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/order/closed`,n,{headers:{myx_openapi_account:t,myx_openapi_access_token:e}})}async getPositionHistory({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/position/closed`,n,{headers:{myx_openapi_account:t,myx_openapi_access_token:e}})}async getMarketList(){return h.get(`${this.getHost()}/openapi/gateway/scan/market`)}async getAccountVipInfo({address:e,accessToken:t,chainId:n,deadline:s,nonce:i}){return h.get(`${this.getHost()}/openapi/gateway/vip/trade_config`,{chainId:n,deadline:s,nonce:i},{headers:{myx_openapi_account:e,myx_openapi_access_token:t}})}async getAppealList(e){return this.get("/openapi/gateway/scan/dispute/list",e,{auth:!0})}async getAppealDetail(e){return this.get("/openapi/gateway/scan/dispute/details",e,{auth:!0})}async uploadAppealEvidence(e){return this.get("/openapi/gateway/scan/dispute/upload/evidence",e,{auth:!0})}async getAppealReconsiderationList(e){return this.get("/openapi/gateway/scan/dispute/appeal/list",e,{auth:!0})}async getAppealReconsiderationDetail(e){return this.get("/openapi/gateway/scan/dispute/appeal/details",e,{auth:!0})}async getAppealReimbursementList(e){return this.get("/openapi/gateway/scan/reimbursement/list",e,{auth:!0})}async getAppealNodeVoteList(e){return this.get("/openapi/gateway/scan/node/vote-list",e)}async getAppealNodeVoteDetails(e){return this.get("/openapi/gateway/scan/node/vote-details",e)}async getIsVoteNode(e){return this.get("/openapi/gateway/scan/node/vote-node-check",e)}async postVoteSignature(e){return this.get("/openapi/gateway/scan/node/vote",e,{auth:!0})}async getPedingVoteCount(){return this.get("/openapi/gateway/scan/node/pending-vote-total",{},{auth:!0})}async getMyAppealCount(){return this.get("/openapi/gateway/scan/processing-total",{},{auth:!0})}async getWarmholeSign(e){return this.get("/openapi/gateway/scan/get-warmhole-sign",e,{auth:!0})}async getDisputeTotalCount(){return this.get("/openapi/gateway/scan/dispute/dispute-total",{},{auth:!0})}async getAppealTotalCount(){return this.get("/openapi/gateway/scan/dispute/appeal-total",{},{auth:!0})}async getReimbursementTotalCount(){return this.get("/openapi/gateway/scan/dispute/reimbursement-total",{},{auth:!0})}async getCurrentEpoch({address:e,accessToken:t,broker:n}){return h.get(`${this.getHost()}/openapi/gateway/scan/get-current-epoch`,{broker:n},{headers:{myx_openapi_account:e,myx_openapi_access_token:t}})}async getPoolAppealStatus({poolId:e,chainId:t,address:n,accessToken:s}){return h.get(`${this.getHost()}/openapi/gateway/scan/pool-id-dispute-state?poolId=${e}&chainId=${t}`,{},{headers:{myx_openapi_account:n,myx_openapi_access_token:s}})}};import{hexToBytes as Ds,toHex as ma,encodeFunctionData as Os,maxUint256 as _t}from"viem";import Fs from"dayjs";var da=async a=>{try{let e=await a.read.eip712Domain();return{name:e[1],version:e[2],chainId:BigInt(e[3]),verifyingContract:e[4]}}catch(e){throw new Error(`Error fetching EIP712 domain: ${e}`)}};var Ns={ForwardRequest:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"gas",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint48"},{name:"data",type:"bytes"}]},_s=2;function Bs(a){let e=Ds(a);if(e.length<65)throw new Error("Invalid signature length");let t=ma(e.slice(0,32)),n=ma(e.slice(32,64));return{v:e[64],r:t,s:n}}async function Ls(a,e,t,n,s,i,r,p){let d=se(e,t),u=await da(d),[o]=await a.getAddresses();if(!o)throw new x("INVALID_SIGNER","No account for signPermit");let m={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},f={owner:n,spender:s,value:i,nonce:r,deadline:p},y=await a.signTypedData({account:o,domain:{...u,chainId:u.chainId},types:m,primaryType:"Permit",message:f});return Bs(y)}var Ke=class{constructor(e,t,n,s,i){this.configManager=e,this.logger=t,this.utils=n,this.account=s,this.api=i}async onCheckRelayer(e,t,n,s){let r=await(await le(n)).read.isUserRelayerEnabled([e,t]),p=await this.utils.needsApproval(e,n,s,_t.toString(),P(n).TRADING_ROUTER);return r&&!p}async getUSDPermitParams(e,t,n){if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Signer is required for permit");let s=await M(t),i=P(t),[r]=await s.getAddresses();if(!r)throw new x("INVALID_SIGNER","No account");let p=se(t,n);try{let d=await p.read.nonces([r]),u=await Ls(s,t,n,r,i.TRADING_ROUTER,_t,d,e);return[{token:n,owner:r,spender:i.TRADING_ROUTER,value:_t.toString(),deadline:e.toString(),v:u.v,r:u.r,s:u.s}]}catch{throw new x("INVALID_PRIVATE_KEY","Invalid private key generated")}}async forwarderTx({from:e,to:t,value:n,gas:s,deadline:i,data:r,nonce:p,forwardFeeToken:d},u,o){let f=await(await le(u)).read.eip712Domain(),y={name:f[1],version:f[2],chainId:f[3],verifyingContract:f[4]},g=o??await M(u),[l]=await g.getAddresses();if(!l)throw new x("INVALID_SIGNER","Missing signer for forwarderTx");let A=await g.signTypedData({account:l,domain:y,types:Ns,primaryType:"ForwardRequest",message:{from:e,to:t,value:BigInt(n),gas:BigInt(s),nonce:BigInt(p),deadline:BigInt(i),data:r}});return await this.api.forwarderTxApi({from:e,to:t,value:n,gas:s,nonce:p,data:r,deadline:i,signature:A,forwardFeeToken:d},u)}async authorizeSeamlessAccount({approve:e,seamlessAddress:t,chainId:n,forwardFeeToken:s}){let i=this.configManager.hasSigner()?await this.configManager.getSignerAddress(n):"";if(e){let y=(await this.account.getWalletQuoteTokenBalance({chainId:n,address:i,tokenAddress:s})).data,l=await(await ee(n)).read.getForwardFeeByToken([s]),A=BigInt(l)*BigInt(_s);if(A>0&&A>BigInt(y))throw this.logger.debug("Insufficient balance"),new x("INSUFFICIENT_BALANCE","Insufficient balance")}let r=Fs().add(60,"minute").unix(),p=[];if(e)try{p=await this.getUSDPermitParams(r,n,s)}catch(f){this.logger.warn("Failed to get USD permit params, proceeding without permit:",f),p=[]}let d=await le(n,1),u=await(await le(n)).read.nonces([i]),o=Os({abi:Ie,functionName:"permitAndApproveForwarder",args:[t,e,p]}),m=await this.forwarderTx({from:i,to:d.address,value:"0",gas:"800000",nonce:u.toString(),data:o,deadline:r,forwardFeeToken:s},n);if(m.data?.txHash){for(let g=0;g<5;g++)try{if((await this.api.fetchForwarderGetApi({requestId:m.data.requestId})).data?.status===9)return{code:0,data:{seamlessAccount:t,authorized:e}};g<4&&await new Promise(A=>setTimeout(A,1e3))}catch(l){this.logger.error("Poll transaction from chain error:",l),g<4&&await new Promise(A=>setTimeout(A,1e3))}return{code:-1,data:null,message:"Transaction confirmation timeout, please check later"}}else return{code:-1,data:null,message:"Your request timed out, please try again"}}async getOriginSeamlessAccount(e,t){return{code:0,data:{masterAddress:await(await le(t)).read.originAccount([e])}}}};import{decodeEventLog as Us}from"viem";var be=class{constructor(e){this.client=e}getConfig(){return this.client.getConfigManager()?.getConfig()}getAddressConfig(){let t=this.getConfig()?.chainId;if(!t||!Te(t))throw new x("INVALID_CHAIN_ID","Invalid chain id");return P(t)}getBrokerContract(){let e=this.getConfig();if(!e?.brokerAddress)throw new x("INVALID_BROKER_ADDRESS","Invalid broker address");return de(e.chainId,e.brokerAddress)}get config(){return this.getConfig()}};var Je=class extends be{constructor(e,t){super(e),this.configManager=t}getDisputeCourtContract(e=!0){return gn(this.config.chainId,e?1:0)}getReimbursementContract(e=!0){return fn(this.config.chainId,e?1:0)}getCaseIdFromReceiptLogs(e,t){let n=t==="DisputeFiled"?"caseId":"appealCaseId";for(let s of e.logs)try{let i=Us({abi:xe,data:s.data,topics:s.topics});if(i.eventName===t&&i.args&&n in i.args)return i.args[n]}catch{continue}return null}async submitAppeal(e,t,n){let s=this.configManager.hasSigner()?await this.configManager.getSignerAddress(this.config.chainId):"",i=await this.client.utils.needsApproval(s,this.config.chainId,t,n,this.getAddressConfig().DISPUTE_COURT);this.client.logger.debug("need-approve",i),i&&await this.client.utils.approveAuthorization({chainId:this.config.chainId,quoteAddress:t,spenderAddress:this.getAddressConfig().DISPUTE_COURT});let r=await this.getDisputeCourtContract(),p=await this.client.utils.buildUpdatePriceParams(e,this.config.chainId),d=BigInt(p[0].value.toString()||"1"),u=await r.estimateGas.fileDispute([p,e,t],{value:d}),o=await this.client.utils.getGasLimitByRatio(u),m=await this.client.utils.getGasPriceByRatio(),f=await r.write.fileDispute([p,e,t],{value:d,gasLimit:o,gasPrice:m}),y=await c(this.config.chainId).waitForTransactionReceipt({hash:f}),g=this.getCaseIdFromReceiptLogs(y,"DisputeFiled");if(g==null)throw new x("TRANSACTION_FAILED","DisputeFiledLog not found");return{transaction:y,caseId:g}}async voteForAppeal({caseId:e,validator:t,isFor:n,deadline:s,v:i,r,s:p}){let d=await this.getDisputeCourtContract(),u=await d.estimateGas.vote([e,t,n?1:0,s,i,r,p]),o=await this.client.utils.getGasLimitByRatio(u),m=await this.client.utils.getGasPriceByRatio(),f=await d.write.vote([e,t,n?1:0,s,i,r,p],{gasLimit:o,gasPrice:m});return await c(this.config.chainId).waitForTransactionReceipt({hash:f})}async claimAppealMargin(e){let t=await this.getDisputeCourtContract(),n=await t.estimateGas.claimBond([e]),s=await this.client.utils.getGasLimitByRatio(n),i=await this.client.utils.getGasPriceByRatio(),r=await t.write.claimBond([e],{gasLimit:s,gasPrice:i});return c(this.config.chainId).waitForTransactionReceipt({hash:r})}async claimReimbursement(e,t,n,s){let i=await this.getReimbursementContract(),r=await i.estimateGas.claimReimbursement([e,t,n,s]),p=await this.client.utils.getGasLimitByRatio(r),d=await this.client.utils.getGasPriceByRatio(),u=await i.write.claimReimbursement([e,t,n,s],{gasLimit:p,gasPrice:d});return c(this.config.chainId).waitForTransactionReceipt({hash:u})}async getDisputeConfiguration(){return(await this.getDisputeCourtContract(!1)).read.getDisputeConfiguration()}async submitAppealByVoteNode(e,t,n){let s=await this.getDisputeCourtContract(),i=await this.client.utils.getGasPriceByRatio(),r=await this.client.utils.getGasLimitByRatio(await s.estimateGas.fileDisputeFromStaker([e,t,n])),p=await s.write.fileDisputeFromStaker([e,t,n],{gasLimit:r,gasPrice:i}),d=await c(this.config.chainId).waitForTransactionReceipt({hash:p}),u=this.getCaseIdFromReceiptLogs(d,"DisputeFiled");if(u==null)throw new x("TRANSACTION_FAILED","DisputeFiledLog not found");return{tx:d,caseId:u}}async appealReconsideration(e,t,n){let s=await this.getDisputeCourtContract(),i=this.configManager.hasSigner()?await this.configManager.getSignerAddress(this.config.chainId):"",r=this.getAddressConfig().DISPUTE_COURT;if(await this.client.utils.needsApproval(i,this.config.chainId,t,n,r)){let g=await this.client.utils.approveAuthorization({chainId:this.config.chainId,quoteAddress:t,spenderAddress:r});if(g.code!==0)throw new x("TRANSACTION_FAILED",g.message)}let d=await s.estimateGas.appeal([e]),u=await this.client.utils.getGasLimitByRatio(d),o=await this.client.utils.getGasPriceByRatio(),m=await s.write.appeal([e],{gasLimit:u,gasPrice:o}),f=await c(this.config.chainId).waitForTransactionReceipt({hash:m}),y=this.getCaseIdFromReceiptLogs(f,"AppealFiled");if(y==null)throw new x("TRANSACTION_FAILED","AppealFiledLog not found");return{tx:f,appealCaseId:y,caseId:e}}async getAppealList(e){return this.client.api.getAppealList(e)}async getAppealDetail(e){return this.client.api.getAppealDetail(e)}async uploadAppealEvidence(e){return this.client.api.uploadAppealEvidence(e)}async getAppealReconsiderationList(e){return this.client.api.getAppealReconsiderationList(e)}async getAppealReconsiderationDetail(e){return this.client.api.getAppealReconsiderationDetail(e)}async getAppealReimbursementList(e){return this.client.api.getAppealReimbursementList(e)}async getAppealNodeVoteList(e){return this.client.api.getAppealNodeVoteList(e)}async getAppealNodeVoteDetail(e){return this.client.api.getAppealNodeVoteDetails(e)}async getIsVoteNode(e){return this.client.api.getIsVoteNode(e)}async postVoteSignature(e){return this.client.api.postVoteSignature(e)}async getPedingVoteCount(){return this.client.api.getPedingVoteCount()}async getMyAppealCount(){return this.client.api.getMyAppealCount()}async getWarmholeSign(e){return this.client.api.getWarmholeSign(e)}async getDisputeTotalCount(){return this.client.api.getDisputeTotalCount()}async getAppealTotalCount(){return this.client.api.getAppealTotalCount()}async getReimbursementTotalCount(){return this.client.api.getReimbursementTotalCount()}async getAppealStatus(e,t,n){return this.client.api.getPoolAppealStatus({poolId:e,chainId:t,address:n,accessToken:await this.configManager.getAccessToken()??""})}};var je=class extends be{constructor(e){super(e)}async claimRebate(e){let t=this.getConfig(),n=await L(this.config.chainId,t.brokerAddress),s=await n.estimateGas.claimRebate([e]),i=await this.client.utils.getGasLimitByRatio(s),r=await this.client.utils.getGasPriceByRatio(),p=await n.write.claimRebate([e],{gasPrice:r,gasLimit:i});return c(this.config.chainId).waitForTransactionReceipt({hash:p})}};var qs=(d=>(d[d.UnderReview=1]="UnderReview",d[d.InitialVote=2]="InitialVote",d[d.PublicNotice=3]="PublicNotice",d[d.UnderReconsideration=4]="UnderReconsideration",d[d.Won=5]="Won",d[d.Failed=6]="Failed",d[d.PlatformRuling=7]="PlatformRuling",d[d.PlatformRevoked=8]="PlatformRevoked",d))(qs||{}),Gs=(o=>(o[o.InitialVoting=1]="InitialVoting",o[o.PublicNotice=2]="PublicNotice",o[o.UnderReconsideration=3]="UnderReconsideration",o[o.Won=5]="Won",o[o.Failed=4]="Failed",o[o.PlatformRuling=6]="PlatformRuling",o[o.PlatformRevoked=7]="PlatformRevoked",o[o.ReconsiderationVoting=8]="ReconsiderationVoting",o[o.AppealRevert=9]="AppealRevert",o[o.NotAppealFailed=10]="NotAppealFailed",o))(Gs||{}),Ws=(s=>(s[s.UnderReview=1]="UnderReview",s[s.PublicNotice=2]="PublicNotice",s[s.UnderReconsideration=3]="UnderReconsideration",s[s.Completed=4]="Completed",s))(Ws||{}),zs=(t=>(t[t.ElectionNode=0]="ElectionNode",t[t.OfficialNode=1]="OfficialNode",t))(zs||{}),Vs=(t=>(t[t.Reject=0]="Reject",t[t.Support=1]="Support",t))(Vs||{}),$s=(t=>(t[t.UnClaimed=0]="UnClaimed",t[t.Claimed=1]="Claimed",t))($s||{}),Hs=(t=>(t[t.NotVoted=0]="NotVoted",t[t.Voted=1]="Voted",t))(Hs||{}),Qs=(t=>(t[t.Appeal=1]="Appeal",t[t.Reconsideration=2]="Reconsideration",t))(Qs||{}),Ks=(n=>(n[n.NoVote=0]="NoVote",n[n.Supported=1]="Supported",n[n.Rejected=2]="Rejected",n))(Ks||{}),Js=(t=>(t[t.Yes=1]="Yes",t[t.No=0]="No",t))(Js||{}),pa=(t=>(t[t.None=0]="None",t[t.isAppealing=1]="isAppealing",t))(pa||{});var Bt=class{getConfigManager(){return this.configManager}constructor(e){this.configManager=new Le(e),this.logger=new re({logLevel:e.logLevel});let t=Z.getInstance();t.setConfigManager(this.configManager),ve(this.configManager),t.getMarkets().then(),this.utils=new ze(this.configManager,this.logger),this.api=new Qe(this.configManager,this.logger),this.account=new Ve(this.configManager,this.logger,this.utils,this),this.seamless=new Ke(this.configManager,this.logger,this.utils,this.account,this.api),this.markets=new Ue(this.configManager,this.utils,this.api),this.position=new qe(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.order=new We(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.subscription=new _e(this.configManager,this.logger),this.appeal=new Je(this,this.configManager),this.referrals=new je(this)}auth(e){this.configManager.auth(e)}updateClientChainId(e,t){this.configManager.updateClientChainId(e,t)}close(){this.configManager.clear(),this.subscription.disconnect()}async getAccessToken(){return await this.configManager.getAccessToken()}async refreshAccessToken(e=!1){return await this.configManager.refreshAccessToken(e)}};var Sf="1.0.4";export{Qs as AppealCaseTypeEnum,$s as AppealClaimStatusEnum,Ks as AppealNodeStateEnum,Hs as AppealNodeVotedStateEnum,Gs as AppealReconsiderationType,Ws as AppealStage,pa as AppealStatus,qs as AppealType,_ as COMMON_LP_AMOUNT_DECIMALS,E as COMMON_PRICE_DECIMALS,z as ChainId,$a as CloseTypeEnum,qc as Direction,Wa as DirectionEnum,Oa as ErrorCode,Va as ExecTypeEnum,Qa as ForwarderGetStatus,pn as HttpKlineIntervalEnum,Js as IsVoteNodeEnum,re as Logger,_a as MarketCapType,he as MarketPoolState,Fa as MarketType,Z as MxSDK,Bt as MyxClient,zs as NodeTypeEnum,Ua as OperationEnum,pe as OperationType,on as OracleType,Wc as OrderStatus,za as OrderStatusEnum,Ge as OrderType,La as OrderTypeEnum,Sf as SDK_VERSION,Ba as SearchSecondTypeEnum,Na as SearchTypeEnum,Gc as TimeInForce,Ha as TradeFlowAccountTypeEnum,qa as TradeFlowTypeEnum,Uc as TriggerType,Ga as TriggerTypeEnum,Vs as VoteTypeEnum,An as approve,Et as base,te as bigintAmountSlipperCalculator,v as bigintTradingGasPriceWithRatio,T as bigintTradingGasToRatioCalculator,Ru as formatUnits,Dt as fromViemWalletClient,hn as getAllowanceApproved,xn as getBalanceOf,yr as getBaseDetail,J as getBaseUrlByEnv,fr as getMarketDetail,mn as getMarketList,j as getOraclePrice,un as getPoolDetail,ur as getPoolList,dn as getPoolOpenOrders,B as getPriceData,fe as getPricesData,c as getPublicClient,Se as getSdkLogSink,cr as getTickerData,fu as getTokenInfo,M as getWalletClient,Ka as getWalletProvider,Mt as market,Be as normalizeSigner,wu as parseUnits,ds as pool,St as quote,I as sdkError,In as sdkLog,ye as sdkWarn,ve as setConfigManagerForViem,bn as setSdkLogSink};
1
+ var ca=Object.defineProperty;var Ut=a=>{throw TypeError(a)};var et=(a,e)=>{for(var t in e)ca(a,t,{get:e[t],enumerable:!0})};var qt=(a,e,t)=>e.has(a)||Ut("Cannot "+t);var Gt=(a,e,t)=>(qt(a,e,"read from private field"),t?t.call(a):e.get(a)),Wt=(a,e,t)=>e.has(a)?Ut("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,t),zt=(a,e,t,n)=>(qt(a,e,"write to private field"),n?n.call(a,t):e.set(a,t),t);var Et={};et(Et,{claimBasePoolRebate:()=>Pn,claimBasePoolRebates:()=>Rn,deposit:()=>Sn,getLpPrice:()=>Bn,getRewards:()=>_n,previewUserWithdrawData:()=>vn,withdraw:()=>Nn,withdrawableLpAmount:()=>Fn});import{getContract as k}from"viem";var Vt=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"DifferentMarket",inputs:[{type:"bytes32",name:"fromPoolId"},{type:"bytes32",name:"toPoolId"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InsufficientQuoteIn",inputs:[{type:"uint256",name:"orderId"},{type:"uint256",name:"quoteIn"},{type:"uint256",name:"exchangeDelta"}]},{type:"error",name:"InvalidAmount",inputs:[{type:"uint256",name:"amount"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidLiquidityAmount",inputs:[]},{type:"error",name:"InvalidTpsl",inputs:[{type:"uint256",name:"orderId"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"NotReachedPrice",inputs:[{type:"uint256",name:"orderId"},{type:"uint256",name:"price"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"SamePoolMigration",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"SlippageExceeded",inputs:[{type:"uint256",name:"expected"},{type:"uint256",name:"actual"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"addTpsl",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"poolType"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"cancelTpsl",constant:!1,payable:!1,inputs:[{type:"uint256",name:"orderId"}],outputs:[]},{type:"function",name:"claimBasePoolRebate",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimBasePoolRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimBasePoolRebates",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimBasePoolRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebate",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebates",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"currentOrderId",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"depositBase",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"depositBase",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"depositQuote",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"depositQuote",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"},{type:"tuple[]",name:"tpslParams",components:[{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]}],outputs:[]},{type:"function",name:"executeTpsl",constant:!1,payable:!1,inputs:[{type:"uint256",name:"orderId"},{type:"uint256",name:"quoteInIfNecessary"},{type:"uint256",name:"minOut"}],outputs:[{type:"uint256",name:"baseOut"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"executeTpsl",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"uint256",name:"orderId"},{type:"uint256",name:"quoteInIfNecessary"},{type:"uint256",name:"minOut"}],outputs:[{type:"uint256",name:"baseOut"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getTpslData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"orderId"}],outputs:[{type:"tuple",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"poolType"},{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}]},{type:"function",name:"getUserTpslOrderIds",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"migrateLiquidity",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"fromPoolId"},{type:"bytes32",name:"toPoolId"},{type:"uint256",name:"amount"},{type:"uint256",name:"minLpOut"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdrawBase",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"withdrawBase",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"withdrawQuote",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"withdrawQuote",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"recipient"}]}],outputs:[]}];import{createPublicClient as ga,fallback as ba,http as Yt}from"viem";var z=(r=>(r[r.LINEA_SEPOLIA=59141]="LINEA_SEPOLIA",r[r.LINEA_MAINNET=59144]="LINEA_MAINNET",r[r.ARB_TESTNET=421614]="ARB_TESTNET",r[r.ARB_MAINNET=42161]="ARB_MAINNET",r[r.BSC_TESTNET=97]="BSC_TESTNET",r[r.BSC_MAINNET=56]="BSC_MAINNET",r))(z||{});var fa=[421614,59141,97,42161,59144,56];function Te(a){return!!a&&fa.includes(a)}var G=10;var U={42161:130n,421614:130n,59144:130n,59141:130n,56:150n,97:150n};var $t={chainId:59141,chainInfo:{explorer:"https://sepolia.lineascan.build/",explorerOfTX:"https://sepolia.lineascan.build/tx/",publicJsonRPCUrl:["https://rpc.sepolia.linea.build","https://linea-sepolia.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"],label:"Linea Sepolia",logoUrl:"",faucetUrl:"",chainSymbol:"Linea",gasPriceRatio:1.3,gasLimitRatio:1.2,gasAmountRatio:2,gasFeeReservedForCollateral:(.525+1)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var Ht={chainId:421614,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://sepolia-rollup.arbitrum.io/rpc"],label:" Arbitrum Sepolia",chainSymbol:"Arb Sepolia",explorer:"https://sepolia.arbiscan.io/",explorerOfTX:"https://sepolia.arbiscan.io/tx/",faucetUrl:"https://bwarelabs.com/faucets/arbitrum-sepolia",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(.055+1)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var Qt={chainId:97,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://bsc-testnet-dataseed.bnbchain.org"],label:"BNB Chain Testnet",chainSymbol:"BNB Chain Testnet",explorer:"https://testnet.bscscan.com/",explorerOfTX:"https://testnet.bscscan.com/tx/",faucetUrl:"https://docs.bnbchain.org/bnb-smart-chain/developers/faucet/",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(5e-4+1)*G,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var Kt={chainId:59144,chainInfo:{label:"Linea Mainnet",explorer:"https://lineascan.build/",logoUrl:"",explorerOfTX:"https://lineascan.build/tx/",publicJsonRPCUrl:["https://rpc.linea.build/","https://linea.blockpi.network/v1/rpc/public","https://1rpc.io/linea","https://rpc.linea.build"],chainSymbol:"Linea",gasPriceRatio:1.3,gasLimitRatio:1.2,gasAmountRatio:2,gasFeeReservedForCollateral:(.525+.35)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var Jt={chainId:42161,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://arb1.arbitrum.io/rpc"],label:" Arbitrum One",chainSymbol:"Arbitrum One",explorer:"https://arbiscan.io/",explorerOfTX:"https://arbiscan.io/tx/",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(.055+.175)*G,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var jt={chainId:56,chainInfo:{privateJsonRPCUrl:"",publicJsonRPCUrl:["https://bsc-dataseed.bnbchain.org"],label:"BNB Chain",chainSymbol:"BNB Chain",explorer:"https://bscscan.com/",explorerOfTX:"https://bscscan.com/tx/",faucetUrl:"https://docs.bnbchain.org/bnb-smart-chain/developers/faucet/",logoUrl:"",gasPriceRatio:1.5,gasLimitRatio:1.3,gasAmountRatio:2,gasFeeReservedForCollateral:(5e-4+1)*G,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var C={59141:$t.chainInfo,421614:Ht.chainInfo,97:Qt.chainInfo,59144:Kt.chainInfo,42161:Jt.chainInfo,56:jt.chainInfo};function ue(a){let e=C[a];if(!e)throw new Error(`Could not find information with chain id ${a}`);return e}var tt={};function Ia(a){if(!tt[a]){let e=ue(a),t=[...e.privateJsonRPCUrl?[e.privateJsonRPCUrl]:[],...Array.isArray(e.publicJsonRPCUrl)?[...e.publicJsonRPCUrl]:[]].filter(Boolean);if(t.length===0)throw new Error(`${a} has no jsonRPCUrl configured`);tt[a]={id:a,name:e.label||`Chain ${a}`,nativeCurrency:e.nativeCurrency,rpcUrls:{default:{http:t}}}}return tt[a]}var nt={};function c(a){if(!nt[a]){let e=ue(a),t=[...e.privateJsonRPCUrl?[e.privateJsonRPCUrl]:[],...Array.isArray(e.publicJsonRPCUrl)?[...e.publicJsonRPCUrl]:[]].filter(Boolean);if(t.length===0)throw new Error(`${a} has no jsonRPCUrl configured`);let n=t.length===1?Yt(t[0]):ba(t.map(s=>Yt(s)));nt[a]=ga({chain:Ia(a),transport:n})}return nt[a]}var Xt=null;function ve(a){Xt=a}async function M(a){let e=Xt;if(!e?.hasSigner())throw new Error("No signer: call auth({ signer }) or auth({ walletClient })");return e.getViemWalletClient(a)}var at=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"BaseFeeNotSoldOut",inputs:[]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidBaseToken",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"LPNotFullyMinted",inputs:[]},{type:"error",name:"MarketNotExist",inputs:[{type:"bytes32",name:"marketId"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"PoolDebtNotCleared",inputs:[]},{type:"error",name:"PoolExists",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotExist",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PositionNotEmpty",inputs:[]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"error",name:"UnexpectedPoolState",inputs:[]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"benchPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"checkPoolExists",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bool"}]},{type:"function",name:"deployPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"marketId"},{type:"address",name:"baseToken"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getMarketPool",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"address",name:"asset"}],outputs:[{type:"tuple",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"state"},{type:"bool",name:"compoundEnabled"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"},{type:"address",name:"poolVault"},{type:"address",name:"tradingVault"}]}]},{type:"function",name:"getPairToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"}]},{type:"function",name:"getPool",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"tuple",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"state"},{type:"bool",name:"compoundEnabled"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"},{type:"address",name:"poolVault"},{type:"address",name:"tradingVault"}]}]},{type:"function",name:"getPoolMarket",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bytes32",name:"marketId"},{type:"tuple",components:[{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"},{type:"uint128",name:"executionFee"},{type:"uint128",name:"maxExecutionFee"},{type:"uint128",name:"forwardFee"},{type:"uint128",name:"maxForwardFee"}]}]},{type:"function",name:"getPoolMarketExecutionFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"executionFee"}]},{type:"function",name:"getPoolMarketForwardFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"forwardFee"}]},{type:"function",name:"getPoolMarketId",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bytes32",name:"marketId"}]},{type:"function",name:"getPoolRiskTier",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint8"}]},{type:"function",name:"getPoolVault",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address"}]},{type:"function",name:"getPools",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32[]",name:"pools"}]},{type:"function",name:"getTradingVault",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isPoolAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"addr"}],outputs:[{type:"bool"}]},{type:"function",name:"perBenchPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"primePool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"referencePrice"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"reprimePool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"}]}],outputs:[]},{type:"function",name:"trenchPool",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bytes32",name:"oracleFeedId"},{type:"uint32",name:"oracleDecimals"},{type:"uint8",name:"oracleType"},{type:"uint8",name:"riskTier"}]}],outputs:[]},{type:"function",name:"updatePoolCompoundEnabled",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bool",name:"enabled"}]}],outputs:[]},{type:"function",name:"updatePoolRiskTiers",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"riskTier"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var q=[{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"},{internalType:"uint8",name:"decimals_",type:"uint8"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];var st=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InsufficientOutputAmount",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"PoolNotActive",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotExist",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeCastOverflowedUintToInt",inputs:[{type:"uint256",name:"value"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"QuotePoolProfitDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"uint256",name:"genesisAmount",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"EXCHANGE_RATE_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"POOL_TOKEN_DECIMALS",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"REBATE_INDEX_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimUserRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"rebateOut"}]},{type:"function",name:"claimUserRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256[]",name:"rebateOut"}]},{type:"function",name:"deposit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"}]},{type:"function",name:"distribute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amount"},{type:"uint256",name:"genesisAmount"},{type:"uint256",name:"price"}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"genesisRebateIndex"}]}]},{type:"function",name:"getPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getUserData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"index"},{type:"uint256",name:"accrued"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"pendingUserRebates",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewLpAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"quoteAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewQuoteAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewUserWithdrawData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"quoteAmountOut"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updatePool",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"oraclePrice"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdraw",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"},{type:"uint256",name:"rebateOut"}]},{type:"function",name:"withdrawableLpAmount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]}];var it=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ExceedMaxProfit",inputs:[]},{type:"error",name:"ExceedMinOutputAmount",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InsufficientOutputAmount",inputs:[]},{type:"error",name:"InsufficientReturnAmount",inputs:[{type:"uint256",name:"expected"},{type:"uint256",name:"received"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"PoolNotActive",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotCompoundable",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"PoolNotExist",inputs:[{type:"bytes32",name:"poolId"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeCastOverflowedUintToInt",inputs:[{type:"uint256",name:"value"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"BasePoolProfitDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:!0},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1},{type:"uint256",name:"rebateIndex",indexed:!1},{type:"uint256",name:"genesisRebateIndex",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolProfitExchanged",inputs:[{type:"bytes32",name:"poolId",indexed:!0},{type:"uint256",name:"baseIn",indexed:!1},{type:"uint256",name:"quoteOut",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"address",name:"recipient",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolRebateIndexUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:!0},{type:"uint256",name:"unexchangedProfits",indexed:!1},{type:"uint256",name:"oldIndex",indexed:!1},{type:"uint256",name:"newIndex",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"EXCHANGE_RATE_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"POOL_TOKEN_DECIMALS",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"REBATE_INDEX_PRECISION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimUserRebate",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"rebateOut"}]},{type:"function",name:"claimUserRebates",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256[]",name:"rebateOut"}]},{type:"function",name:"deposit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"}]},{type:"function",name:"distribute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"},{type:"uint256",name:"genesisAmount"},{type:"uint256",name:"price"}],outputs:[]},{type:"function",name:"exchangeProfit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseIn"},{type:"uint256",name:"minQuoteOut"},{type:"address",name:"recipient"},{type:"bytes",name:"data"}],outputs:[{type:"uint256",name:"quoteOut"}]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeableProfit",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"baseIn"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"rebateIndex"},{type:"uint256",name:"genesisRebateIndex"},{type:"uint256",name:"exchangeableProfits"}]}]},{type:"function",name:"getPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getUserData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"index"},{type:"uint256",name:"genesisIndex"},{type:"uint256",name:"accrued"},{type:"uint256",name:"genesisAccrued"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"pendingUserRebates",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"rebates"},{type:"uint256",name:"genesisRebates"}]},{type:"function",name:"previewBaseAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewExchangeableProfit",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"baseIn"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"previewLpAmountOut",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewPoolTokenPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewUserWithdrawData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"baseAmountOut"},{type:"uint256",name:"rebateAmount"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updatePool",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"oraclePrice"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdraw",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amountIn"},{type:"uint256",name:"minAmountOut"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"amountOut"},{type:"uint256",name:"rebateOut"}]},{type:"function",name:"withdrawableLpAmount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]}];var rt=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ECDSAInvalidSignature",inputs:[]},{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{type:"uint256",name:"length"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{type:"bytes32",name:"s"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ExpiredFeeData",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidFeeRate",inputs:[]},{type:"error",name:"InvalidFeeTier",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"NoRebateToClaim",inputs:[]},{type:"error",name:"NotActiveBroker",inputs:[{type:"address",name:"broker"}]},{type:"error",name:"NotBrokerSigner",inputs:[{type:"address",name:"signer"}]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotOrderOwner",inputs:[]},{type:"error",name:"NotPositionOwner",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{type:"address",name:"owner"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{type:"address",name:"account"}]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"error",name:"UnsupportedAssetClass",inputs:[{type:"uint8",name:"assetClass"}]},{type:"error",name:"UnsupportedFeeTier",inputs:[{type:"uint8",name:"tier"}]},{type:"event",anonymous:!1,name:"BrokerStatusUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"bool",name:"isActive",indexed:!1}]},{type:"event",anonymous:!1,name:"EIP712DomainChanged",inputs:[]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"OwnershipTransferStarted",inputs:[{type:"address",name:"previousOwner",indexed:!0},{type:"address",name:"newOwner",indexed:!0}]},{type:"event",anonymous:!1,name:"OwnershipTransferred",inputs:[{type:"address",name:"previousOwner",indexed:!0},{type:"address",name:"newOwner",indexed:!0}]},{type:"event",anonymous:!1,name:"RebateClaimed",inputs:[{type:"address",name:"user",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"SignerUpdated",inputs:[{type:"address",name:"signer",indexed:!1},{type:"bool",name:"isSigner",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"UserFeeDataReset",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"signer",indexed:!1},{type:"uint256",name:"epoch",indexed:!1}]},{type:"event",anonymous:!1,name:"UserFeeDataUpdated",inputs:[{type:"address",name:"broker",indexed:!0},{type:"address",name:"signer",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint256",name:"epoch",indexed:!1},{type:"uint8",name:"tier",indexed:!1},{type:"address",name:"referrer",indexed:!1},{type:"uint32",name:"totalReferralRebatePct",indexed:!1},{type:"uint32",name:"referrerRebatePct",indexed:!1}]},{type:"function",name:"FEE_TYPEHASH",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"acceptOwnership",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"activeFeeTiers",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"activeSpecialFeeTierList",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"addressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"batchSetSpecialFeeTiers",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]}],outputs:[]},{type:"function",name:"batchUpdateFeeTiers",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"tuple",name:"addOnFeeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}]}],outputs:[]},{type:"function",name:"cancelOrder",constant:!1,payable:!1,inputs:[{type:"uint256",name:"orderId"}],outputs:[]},{type:"function",name:"cancelOrders",constant:!1,payable:!1,inputs:[{type:"uint256[]",name:"orderIds"}],outputs:[]},{type:"function",name:"claimRebate",constant:!1,payable:!1,inputs:[{type:"address",name:"token"}],outputs:[]},{type:"function",name:"claimRebates",constant:!1,payable:!1,inputs:[{type:"address[]",name:"tokens"}],outputs:[]},{type:"function",name:"currentFeeDataEpoch",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"domainSeparatorV4",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"eip712Domain",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes1",name:"fields"},{type:"string",name:"name"},{type:"string",name:"version"},{type:"uint256",name:"chainId"},{type:"address",name:"verifyingContract"},{type:"bytes32",name:"salt"},{type:"uint256[]",name:"extensions"}]},{type:"function",name:"getAddOnFeeTier",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"}],outputs:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]},{type:"function",name:"getBaseFeeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"}],outputs:[{type:"tuple",name:"baseFeeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getSpecialFeeTier",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"}],outputs:[{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]},{type:"function",name:"getUserFeeDataDigest",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"uint64",name:"nonce"},{type:"uint64",name:"deadline"},{type:"tuple",name:"feeData",components:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]}],outputs:[{type:"bytes32",name:"digest"}]},{type:"function",name:"getUserFeeRate",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"baseTakerFeeRate"},{type:"uint32",name:"baseMakerFeeRate"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"_addressManager"},{type:"address",name:"owner"},{type:"string",name:"_brokerName"},{type:"address[]",name:"brokerSigners"},{type:"uint8[]",name:"assetClasses"},{type:"tuple[]",name:"baseFeeRates",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}],outputs:[]},{type:"function",name:"isActive",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bool"}]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"name",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"onBrokerFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"token"},{type:"uint256",name:"feeAmount"}],outputs:[{type:"uint256",name:"totalReferralRebate"},{type:"uint256",name:"referrerRebate"},{type:"address",name:"referrer"}]},{type:"function",name:"owner",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"pendingOwner",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"placeOrderWithPosition",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"bytes32",name:"positionId"},{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"tuple",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"placeOrderWithSalt",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"uint64",name:"userPositionSalt"},{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"tuple",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"placeOrdersWithPosition",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"bytes32[]",name:"positionIds"},{type:"tuple[]",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"placeOrdersWithSalt",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"uint64[]",name:"userPositionSalts"},{type:"tuple[]",name:"orderParams",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"triggerType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"timeInForce"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint16",name:"leverage"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"renounceOwnership",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"resetAllUserFeeData",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"setSigner",constant:!1,payable:!1,inputs:[{type:"address",name:"signer"},{type:"bool",name:"isSigner"}],outputs:[]},{type:"function",name:"setSpecialFeeTier",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"int32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]}],outputs:[]},{type:"function",name:"setUserFeeData",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"uint64",name:"nonce"},{type:"uint64",name:"deadline"},{type:"tuple",name:"feeData",components:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]},{type:"bytes",name:"signature"}]}],outputs:[]},{type:"function",name:"setUserSpecialFeeTier",constant:!1,payable:!1,inputs:[{type:"address",name:"user"},{type:"uint8",name:"feeTier"}],outputs:[]},{type:"function",name:"supportedAssetClasses",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256[]"}]},{type:"function",name:"transferOwnership",constant:!1,payable:!1,inputs:[{type:"address",name:"newOwner"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateBaseFeeRates",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"uint8",name:"assetClass"},{type:"bool",name:"isEnable"},{type:"tuple",name:"baseFeeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}]}],outputs:[]},{type:"function",name:"updateBrokerStatus",constant:!1,payable:!1,inputs:[{type:"bool",name:"active"}],outputs:[]},{type:"function",name:"updateFeeTier",constant:!1,payable:!1,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"feeTier"},{type:"tuple",name:"feeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}],outputs:[]},{type:"function",name:"updateOrder",constant:!1,payable:!1,inputs:[{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"tuple",name:"tpsl",components:[{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}]}],outputs:[]},{type:"function",name:"updatePriceAndAdjustCollateral",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"tuple",name:"depositParams",components:[{type:"address",name:"token"},{type:"uint256",name:"amount"}]},{type:"bytes32",name:"positionId"},{type:"int256",name:"adjustAmount"}],outputs:[]},{type:"function",name:"updateUserFeeData",constant:!1,payable:!1,inputs:[{type:"address",name:"user"},{type:"tuple",name:"feeData",components:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"userFeeData",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"userFeeDataEpoch"},{type:"address",name:"user"}],outputs:[{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]},{type:"function",name:"userNonces",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"}],outputs:[{type:"uint64",name:"nonce"}]},{type:"function",name:"userRebates",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"address",name:"token"}],outputs:[{type:"uint256",name:"rebateAmount"}]}];var ot=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"ERC20InsufficientAllowance",inputs:[{type:"address",name:"spender"},{type:"uint256",name:"allowance"},{type:"uint256",name:"needed"}]},{type:"error",name:"ERC20InsufficientBalance",inputs:[{type:"address",name:"sender"},{type:"uint256",name:"balance"},{type:"uint256",name:"needed"}]},{type:"error",name:"ERC20InvalidApprover",inputs:[{type:"address",name:"approver"}]},{type:"error",name:"ERC20InvalidReceiver",inputs:[{type:"address",name:"receiver"}]},{type:"error",name:"ERC20InvalidSender",inputs:[{type:"address",name:"sender"}]},{type:"error",name:"ERC20InvalidSpender",inputs:[{type:"address",name:"spender"}]},{type:"error",name:"InsufficientBalance",inputs:[{type:"address",name:"account"},{type:"uint256",name:"balance"},{type:"uint256",name:"needed"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"event",anonymous:!1,name:"Approval",inputs:[{type:"address",name:"owner",indexed:!0},{type:"address",name:"spender",indexed:!0},{type:"uint256",name:"value",indexed:!1}]},{type:"event",anonymous:!1,name:"GenesisShareBurned",inputs:[{type:"address",name:"account",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"GenesisShareMinted",inputs:[{type:"address",name:"account",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"Transfer",inputs:[{type:"address",name:"from",indexed:!0},{type:"address",name:"to",indexed:!0},{type:"uint256",name:"value",indexed:!1}]},{type:"function",name:"addressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"allowance",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"owner"},{type:"address",name:"spender"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",constant:!1,payable:!1,inputs:[{type:"address",name:"spender"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"uint256"}]},{type:"function",name:"burnFrom",constant:!1,payable:!1,inputs:[{type:"address",name:"from"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"decimals",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"_addressManager"},{type:"bytes32",name:"_poolId"},{type:"address",name:"_underlyingToken"},{type:"string",name:"name"},{type:"string",name:"symbol"}],outputs:[]},{type:"function",name:"mint",constant:!1,payable:!1,inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"name",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"poolId",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"symbol",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalGenesisShare",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"totalSupply",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",constant:!1,payable:!1,inputs:[{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",constant:!1,payable:!1,inputs:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"underlyingToken",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"userGenesisShare",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"uint256"}]}];var pt=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"InvalidQuoteTokenAddress",inputs:[]},{type:"error",name:"InvalidRatioParams",inputs:[]},{type:"error",name:"MarketAlreadyExisted",inputs:[]},{type:"error",name:"MarketNotExisted",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"ExecutionFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldExecutionFee",indexed:!1},{type:"uint256",name:"newExecutionFee",indexed:!1}]},{type:"event",anonymous:!1,name:"ForwardFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldForwardFee",indexed:!1},{type:"uint256",name:"newForwardFee",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"MaxExecutionFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldMaxExecutionFee",indexed:!1},{type:"uint256",name:"newMaxExecutionFee",indexed:!1}]},{type:"event",anonymous:!1,name:"MaxForwardFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint256",name:"oldMaxForwardFee",indexed:!1},{type:"uint256",name:"newMaxForwardFee",indexed:!1}]},{type:"event",anonymous:!1,name:"OracleFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint64",name:"newOracleFeeUsd",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolPrimeThresholdUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint128",name:"newPoolPrimeThreshold",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveRatioUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"uint32",name:"newBaseReserveRatio",indexed:!1},{type:"uint32",name:"newQuoteReserveRatio",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"createMarket",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint64",name:"chainId"},{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"},{type:"uint128",name:"executionFee"},{type:"uint128",name:"maxExecutionFee"},{type:"uint128",name:"forwardFee"},{type:"uint128",name:"maxForwardFee"}]},{type:"tuple",name:"quoteParams",components:[{type:"address",name:"priceContract"},{type:"bool",name:"applyExchangeRate"},{type:"uint16",name:"minDeviationRatio"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExecutionFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExecutionFeeByToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"quoteToken"}],outputs:[{type:"uint256"}]},{type:"function",name:"getForwardFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getForwardFeeByToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"quoteToken"}],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getMarket",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"tuple",components:[{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"},{type:"uint128",name:"executionFee"},{type:"uint128",name:"maxExecutionFee"},{type:"uint128",name:"forwardFee"},{type:"uint128",name:"maxForwardFee"}]}]},{type:"function",name:"getMarketIds",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32[]"}]},{type:"function",name:"getOracleFee",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"marketExists",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"bool"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updateExecutionFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_executionFee"}],outputs:[]},{type:"function",name:"updateForwardFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_forwardFee"}],outputs:[]},{type:"function",name:"updateMarketQuoteConfiguration",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"tuple",name:"quoteParams",components:[{type:"address",name:"priceContract"},{type:"bool",name:"applyExchangeRate"},{type:"uint16",name:"minDeviationRatio"}]}],outputs:[]},{type:"function",name:"updateMaxExecutionFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_maxExecutionFee"}],outputs:[]},{type:"function",name:"updateMaxForwardFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_maxForwardFee"}],outputs:[]},{type:"function",name:"updateOracleFee",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint64",name:"_oracleFeeUsd"}],outputs:[]},{type:"function",name:"updatePoolPrimeThreshold",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_poolPrimeThreshold"}],outputs:[]},{type:"function",name:"updateReserveRatio",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"marketId"},{type:"uint32",name:"_baseReserveRatio"},{type:"uint32",name:"_quoteReserveRatio"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var ut=[{type:"constructor",payable:!1,inputs:[{type:"address",name:"addressManager"}]},{type:"error",name:"PositionNotHealthy",inputs:[{type:"bytes32",name:"positionId"},{type:"uint256",name:"marginRatio"}]},{type:"error",name:"SafeCastOverflowedUintToInt",inputs:[{type:"uint256",name:"value"}]},{type:"function",name:"ADDRESS_MANAGER",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getAccountInfo",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"}],outputs:[{type:"tuple",name:"accountInfo",components:[{type:"uint256",name:"freeMargin"},{type:"uint256",name:"walletBalance"},{type:"uint256",name:"freeBaseAmount"},{type:"uint256",name:"baseProfit"},{type:"uint256",name:"quoteProfit"},{type:"uint256",name:"reservedAmount"},{type:"uint64",name:"releaseTime"}]}]},{type:"function",name:"getAvailableLiquiditySize",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint256",name:"executePrice"}],outputs:[{type:"uint256"}]},{type:"function",name:"getBrokerFeeTiers",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"brokerAddress"},{type:"uint8[]",name:"assetClasses"},{type:"uint8[]",name:"riskTiers"},{type:"bool",name:"isMYXBroker"}],outputs:[{type:"tuple[]",name:"brokerFees",components:[{type:"uint8",name:"asset"},{type:"tuple[]",name:"riskTieredBrokerFees",components:[{type:"uint8",name:"riskTier"},{type:"tuple[]",name:"addOnFeeTiers",components:[{type:"uint8",name:"tier"},{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"}]},{type:"tuple[]",name:"baseFeeRate",components:[{type:"uint8",name:"assetClass"},{type:"uint32",name:"makerFeeRate"},{type:"uint32",name:"takerFeeRate"}]},{type:"tuple[]",name:"specialFeeTiers",components:[{type:"uint8",name:"tier"},{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"}]}]}]}]},{type:"function",name:"getExchangeables",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"uint256[]",name:"marketPrices"}],outputs:[{type:"tuple[]",name:"exchangeables",components:[{type:"uint256",name:"maxBaseIn"},{type:"uint256",name:"maxQuoteIn"},{type:"uint256",name:"maxBaseOut"},{type:"uint256",name:"maxQuoteOut"}]}]},{type:"function",name:"getLiquidationPrice",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"positionId"},{type:"uint256",name:"marketPrice"},{type:"address",name:"broker"}],outputs:[{type:"uint256"}]},{type:"function",name:"getPoolInfo",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"marketPrice"}],outputs:[{type:"tuple",components:[{type:"tuple",name:"basePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"quotePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"reserveInfo",components:[{type:"uint256",name:"baseTotalAmount"},{type:"uint256",name:"baseReservedAmount"},{type:"uint256",name:"quoteTotalAmount"},{type:"uint256",name:"quoteReservedAmount"}]},{type:"tuple",name:"fundingInfo",components:[{type:"int256",name:"nextFundingRate"},{type:"int256",name:"lastFundingFeeTracker"},{type:"uint256",name:"nextEpochTime"}]},{type:"tuple",name:"oi",components:[{type:"int256",name:"tracker"},{type:"uint256",name:"longSize"},{type:"uint256",name:"shortSize"},{type:"uint256",name:"poolEntryPrice"}]},{type:"tuple",name:"liquidityInfo",components:[{type:"uint256",name:"windowCaps"},{type:"int256",name:"openInterest"}]}]}]},{type:"function",name:"getPoolInfos",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"uint256[]",name:"marketPrices"}],outputs:[{type:"tuple[]",components:[{type:"tuple",name:"basePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"quotePool",components:[{type:"address",name:"poolToken"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"},{type:"uint256",name:"poolTokenSupply"},{type:"uint256",name:"totalDebt"},{type:"uint256",name:"baseCollateral"}]},{type:"tuple",name:"reserveInfo",components:[{type:"uint256",name:"baseTotalAmount"},{type:"uint256",name:"baseReservedAmount"},{type:"uint256",name:"quoteTotalAmount"},{type:"uint256",name:"quoteReservedAmount"}]},{type:"tuple",name:"fundingInfo",components:[{type:"int256",name:"nextFundingRate"},{type:"int256",name:"lastFundingFeeTracker"},{type:"uint256",name:"nextEpochTime"}]},{type:"tuple",name:"oi",components:[{type:"int256",name:"tracker"},{type:"uint256",name:"longSize"},{type:"uint256",name:"shortSize"},{type:"uint256",name:"poolEntryPrice"}]},{type:"tuple",name:"liquidityInfo",components:[{type:"uint256",name:"windowCaps"},{type:"int256",name:"openInterest"}]}]}]},{type:"function",name:"getPoolTokenPrices",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"uint256[]",name:"marketPrices"}],outputs:[{type:"tuple[]",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"basePoolTokenPrice"},{type:"uint256",name:"quotePoolTokenPrice"}]}]},{type:"function",name:"getPositionFees",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"positionId"},{type:"address",name:"broker"},{type:"uint256",name:"price"}],outputs:[{type:"int256",name:"netCollateral"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"tradingFee"},{type:"int256",name:"fundingFee"}]},{type:"function",name:"getSumProfitLock",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address[]",name:"respondents"}],outputs:[{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"},{type:"tuple[]",name:"infos",components:[{type:"address",name:"account"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}]}]},{type:"function",name:"getUserPositionInfos",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"user"},{type:"bytes32[]",name:"poolIds"}],outputs:[{type:"tuple[]",name:"positions",components:[{type:"bytes32",name:"positionId"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"size"},{type:"uint256",name:"entryPrice"},{type:"int256",name:"fundingRateIndex"},{type:"uint256",name:"earlyClosePrice"},{type:"uint8",name:"direction"},{type:"uint8",name:"riskTier"},{type:"uint64",name:"lastUpdateTime"},{type:"uint256",name:"collateralAmount"}]}]}];var Ie=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ERC2771ForwarderExpiredRequest",inputs:[{type:"uint48",name:"deadline"}]},{type:"error",name:"ERC2771ForwarderInvalidSigner",inputs:[{type:"address",name:"signer"},{type:"address",name:"from"}]},{type:"error",name:"ERC2771ForwarderMismatchedValue",inputs:[{type:"uint256",name:"requestedValue"},{type:"uint256",name:"msgValue"}]},{type:"error",name:"ERC2771UntrustfulTarget",inputs:[{type:"address",name:"target"},{type:"address",name:"forwarder"}]},{type:"error",name:"ExceedsMaximumRelayFee",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InconsistentParamsLength",inputs:[]},{type:"error",name:"InsufficientBalance",inputs:[{type:"uint256",name:"balance"},{type:"uint256",name:"needed"}]},{type:"error",name:"InsufficientFeeAllowance",inputs:[{type:"address",name:"user"},{type:"uint256",name:"allowance"},{type:"uint256",name:"required"}]},{type:"error",name:"InsufficientFeeBalance",inputs:[{type:"address",name:"user"},{type:"uint256",name:"balance"},{type:"uint256",name:"required"}]},{type:"error",name:"InvalidAccountNonce",inputs:[{type:"address",name:"account"},{type:"uint256",name:"currentNonce"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"MismatchExecuteFee",inputs:[{type:"uint256",name:"balanceBefore"},{type:"uint256",name:"balanceAfter"},{type:"uint256",name:"expected"}]},{type:"error",name:"MismatchedSender",inputs:[{type:"address",name:"sender"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotAllowedTarget",inputs:[{type:"address",name:"target"}]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"OnlyRelayer",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"RelayerRegistered",inputs:[{type:"address",name:"relayer"}]},{type:"error",name:"RemoveRelayerFailed",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"AddAllowedTarget",inputs:[{type:"address",name:"target",indexed:!1}]},{type:"event",anonymous:!1,name:"ChargeForwardFee",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"feeToken",indexed:!1},{type:"uint256",name:"relayFee",indexed:!1}]},{type:"event",anonymous:!1,name:"EIP712DomainChanged",inputs:[]},{type:"event",anonymous:!1,name:"ERC20PermitFailed",inputs:[{type:"address",name:"token",indexed:!1},{type:"string",name:"reason",indexed:!1}]},{type:"event",anonymous:!1,name:"ERC20PermitLowLevelFailed",inputs:[{type:"bytes",name:"data",indexed:!1}]},{type:"event",anonymous:!1,name:"ExecutedForwardRequest",inputs:[{type:"address",name:"signer",indexed:!0},{type:"uint256",name:"nonce",indexed:!1},{type:"bool",name:"success",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"RemoveAllowedTarget",inputs:[{type:"address",name:"target",indexed:!1}]},{type:"event",anonymous:!1,name:"SetUserRelayer",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"relayer",indexed:!1},{type:"bool",name:"enable",indexed:!1}]},{type:"event",anonymous:!1,name:"UpdateAcquiescentFeeToken",inputs:[{type:"address",name:"sender",indexed:!1},{type:"address",name:"oldRelayGas",indexed:!1},{type:"address",name:"newRelayGas",indexed:!1}]},{type:"event",anonymous:!1,name:"UpdateEquilibriumGas",inputs:[{type:"address",name:"sender",indexed:!1},{type:"uint256",name:"oldRelayGas",indexed:!1},{type:"uint256",name:"newRelayGas",indexed:!1}]},{type:"event",anonymous:!1,name:"UpdateMaxRelayFee",inputs:[{type:"address",name:"sender",indexed:!1},{type:"uint256",name:"oldMaxRelayFee",indexed:!1},{type:"uint256",name:"newMaxRelayFee",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"addAllowedTarget",constant:!1,payable:!1,inputs:[{type:"address",name:"target"}],outputs:[]},{type:"function",name:"batchExecuteForwarder",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"forwardFeeToken"},{type:"tuple[]",name:"bundleParams",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]}],outputs:[]},{type:"function",name:"eip712Domain",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes1",name:"fields"},{type:"string",name:"name"},{type:"string",name:"version"},{type:"uint256",name:"chainId"},{type:"address",name:"verifyingContract"},{type:"bytes32",name:"salt"},{type:"uint256[]",name:"extensions"}]},{type:"function",name:"equilibriumGas",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"execute",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]},{type:"address"}],outputs:[]},{type:"function",name:"executeBatch",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]},{type:"address"},{type:"address"}],outputs:[]},{type:"function",name:"executeForwarder",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"forwardFeeToken"},{type:"tuple",name:"params",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]}],outputs:[]},{type:"function",name:"exitForwardMode",constant:!1,payable:!1,inputs:[],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getAllowedTargets",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address[]"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getDesignatedToken",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getEquilibriumGas",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getUserRelayers",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"address[]"}]},{type:"function",name:"inForwardMode",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bool"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"},{type:"uint256",name:"_equilibriumGas"}],outputs:[]},{type:"function",name:"isAllowedTargets",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"contractAddr"}],outputs:[{type:"bool"}]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"isUserRelayerEnabled",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"address",name:"relayer"}],outputs:[{type:"bool"}]},{type:"function",name:"nonces",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"originAccount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"relayer"}],outputs:[{type:"address",name:"account"}]},{type:"function",name:"permitAndApproveForwarder",constant:!1,payable:!1,inputs:[{type:"address",name:"relayer"},{type:"bool",name:"enable"},{type:"tuple[]",name:"permitParams",components:[{type:"address",name:"token"},{type:"address",name:"owner"},{type:"address",name:"spender"},{type:"uint256",name:"value"},{type:"uint256",name:"deadline"},{type:"uint8",name:"v"},{type:"bytes32",name:"r"},{type:"bytes32",name:"s"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"removeAllowedTarget",constant:!1,payable:!1,inputs:[{type:"address",name:"target"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateEquilibriumGas",constant:!1,payable:!1,inputs:[{type:"uint256",name:"_equilibriumGas"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"verify",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"tuple",name:"request",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"},{type:"uint256",name:"gas"},{type:"uint48",name:"deadline"},{type:"bytes",name:"data"},{type:"bytes",name:"signature"}]}],outputs:[{type:"bool"}]}];var dt=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"AlreadyClaimed",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"user"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidAmount",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"user"}]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"MerkleTreeVerificationFailed",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"user"}]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"ReimbursementValidity",inputs:[{type:"uint256",name:"caseId"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"TreeAlreadySet",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementClaimExpired",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementClaimed",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementInfoSet",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"bytes32",name:"merkleRoot",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"totalBaseAmount",indexed:!1},{type:"uint256",name:"totalQuoteAmount",indexed:!1},{type:"uint256",name:"claimedBaseAmount",indexed:!1},{type:"uint256",name:"claimedQuoteAmount",indexed:!1},{type:"uint256",name:"expireTime",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimExpiredCases",constant:!1,payable:!1,inputs:[{type:"uint256[]",name:"caseIds"},{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"claimReimbursement",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"},{type:"bytes32[]",name:"merkleProof"}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getReimbursementInfo",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[{type:"tuple",components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"setReimbursementInfo",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"tuple",name:"reimbursementInfo",components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]},{type:"bytes32[]",name:"zeroMerkleProof"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var xe=[{type:"constructor",payable:!1,inputs:[]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"AlreadyVoted",inputs:[]},{type:"error",name:"BondNotReleased",inputs:[]},{type:"error",name:"CaseAppealNotFinished",inputs:[]},{type:"error",name:"CaseDeadlineNotReached",inputs:[]},{type:"error",name:"CaseDeadlineReached",inputs:[]},{type:"error",name:"CaseNotAccepted",inputs:[]},{type:"error",name:"CaseNotExist",inputs:[{type:"uint256",name:"caseId"}]},{type:"error",name:"CaseRespondentAppealed",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"respondent"}]},{type:"error",name:"ChainIdMismatch",inputs:[]},{type:"error",name:"DisputeNotAllowed",inputs:[]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidAccountNonce",inputs:[{type:"address",name:"account"},{type:"uint256",name:"currentNonce"}]},{type:"error",name:"InvalidContractAddress",inputs:[]},{type:"error",name:"InvalidFunctionSignature",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParameter",inputs:[]},{type:"error",name:"InvalidPayloadLength",inputs:[{type:"uint256",name:"received"},{type:"uint256",name:"expected"}]},{type:"error",name:"InvalidPoolToken",inputs:[]},{type:"error",name:"InvalidProfitAmount",inputs:[]},{type:"error",name:"InvalidResponseVersion",inputs:[]},{type:"error",name:"InvalidSourceChain",inputs:[]},{type:"error",name:"NoChainResponse",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotCaseRespondent",inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"respondent"}]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"NumberOfResponsesMismatch",inputs:[]},{type:"error",name:"OnlyRelayer",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"RequestTypeMismatch",inputs:[]},{type:"error",name:"RiskCloseNotCompleted",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"SignatureExpired",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"error",name:"UnexpectedCaseState",inputs:[]},{type:"error",name:"UnexpectedCaseType",inputs:[]},{type:"error",name:"UnexpectedNumberOfResults",inputs:[]},{type:"error",name:"UnsupportedQueryType",inputs:[{type:"uint8",name:"received"}]},{type:"error",name:"UntrustfulVoting",inputs:[]},{type:"error",name:"VerificationFailed",inputs:[]},{type:"error",name:"VersionMismatch",inputs:[]},{type:"error",name:"WrongQueryType",inputs:[{type:"uint8",name:"received"},{type:"uint8",name:"expected"}]},{type:"error",name:"ZeroQueries",inputs:[]},{type:"event",anonymous:!1,name:"AppealCanceled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"appealCaseId",indexed:!1},{type:"address",name:"complainant",indexed:!1},{type:"bool",name:"isMalicious",indexed:!1}]},{type:"event",anonymous:!1,name:"AppealFiled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"appealCaseId",indexed:!1},{type:"address",name:"respondent",indexed:!1},{type:"address",name:"appealToken",indexed:!1},{type:"uint256",name:"appealBond",indexed:!1},{type:"uint64",name:"appealDeadline",indexed:!1}]},{type:"event",anonymous:!1,name:"AppealResolved",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"appealCaseId",indexed:!1},{type:"uint8",name:"resolution",indexed:!1},{type:"address",name:"complainant",indexed:!1}]},{type:"event",anonymous:!1,name:"BondClaimed",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"CaseAppealsResolved",inputs:[{type:"uint256",name:"caseId",indexed:!1}]},{type:"event",anonymous:!1,name:"CaseRiskClosed",inputs:[{type:"uint256",name:"caseId",indexed:!1}]},{type:"event",anonymous:!1,name:"DisputeCanceled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"complainant",indexed:!1},{type:"bool",name:"isMalicious",indexed:!1}]},{type:"event",anonymous:!1,name:"DisputeConfigurationUpdated",inputs:[{type:"tuple",name:"newDisputeConfigration",indexed:!1,components:[{type:"address",name:"appealToken"},{type:"uint64",name:"disputeBondUsd"},{type:"uint64",name:"appealBondUsd"},{type:"uint64",name:"disputeThresholdUsd"},{type:"uint64",name:"caseDuration"},{type:"uint64",name:"voteDuration"},{type:"uint64",name:"resolveDuration"},{type:"uint32",name:"voteCountRate"},{type:"uint32",name:"effectiveVoteRate"}]}]},{type:"event",anonymous:!1,name:"DisputeFiled",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"complainant",indexed:!1},{type:"address",name:"poolToken",indexed:!1},{type:"uint256",name:"disputeBond",indexed:!1},{type:"uint64",name:"caseDeadline",indexed:!1}]},{type:"event",anonymous:!1,name:"DisputeResolved",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint8",name:"resolution",indexed:!1},{type:"uint64",name:"appealDeadline",indexed:!1}]},{type:"event",anonymous:!1,name:"ForfeitBondsClaimed",inputs:[{type:"address",name:"receiver",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"ReimbursementProcessed",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"tuple",name:"reimbursementInfo",indexed:!1,components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"Voted",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"address",name:"voter",indexed:!1},{type:"uint8",name:"voteOption",indexed:!1}]},{type:"event",anonymous:!1,name:"VotingOpened",inputs:[{type:"uint256",name:"caseId",indexed:!1},{type:"uint256",name:"evidenceId",indexed:!1},{type:"uint64",name:"voteDeadline",indexed:!1},{type:"address[]",name:"respondents",indexed:!1}]},{type:"event",anonymous:!1,name:"WormholeConfigurationUpdated",inputs:[{type:"tuple",name:"newWormholeConfiguration",indexed:!1,components:[{type:"address",name:"wormhole"},{type:"address",name:"staker"},{type:"bytes4",name:"selector"}]}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"appeal",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"canRiskControlClose",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[{type:"bool"}]},{type:"function",name:"cancelAppeal",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"appealCaseId"},{type:"bool",name:"isMalicious"}],outputs:[]},{type:"function",name:"cancelDispute",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"bool",name:"isMalicious"}],outputs:[]},{type:"function",name:"caseIdSequencer",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"checkRiskControlCloseCompleted",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"claimBond",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"claimForfeitBonds",constant:!1,payable:!1,inputs:[{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"fileDispute",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"prices",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"oracleType"},{type:"uint64",name:"publishTime"},{type:"bytes",name:"oracleUpdateData"}]},{type:"bytes32",name:"poolId"},{type:"address",name:"poolToken"}],outputs:[]},{type:"function",name:"fileDisputeFromStaker",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"bytes",name:"response"},{type:"tuple[]",name:"guardianSignatures",components:[{type:"bytes32",name:"r"},{type:"bytes32",name:"s"},{type:"uint8",name:"v"},{type:"uint8",name:"guardianIndex"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getDisputeConfiguration",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"tuple",components:[{type:"address",name:"appealToken"},{type:"uint64",name:"disputeBondUsd"},{type:"uint64",name:"appealBondUsd"},{type:"uint64",name:"disputeThresholdUsd"},{type:"uint64",name:"caseDuration"},{type:"uint64",name:"voteDuration"},{type:"uint64",name:"resolveDuration"},{type:"uint32",name:"voteCountRate"},{type:"uint32",name:"effectiveVoteRate"}]}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isCaseRespondents",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"account"}],outputs:[{type:"bool"}]},{type:"function",name:"nonces",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"openVoting",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"evidenceId"},{type:"address[]",name:"respondents"}],outputs:[]},{type:"function",name:"processReimbursement",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"tuple",name:"reimbursementInfo",components:[{type:"bytes32",name:"merkleRoot"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"totalBaseAmount"},{type:"uint256",name:"totalQuoteAmount"},{type:"uint256",name:"claimedBaseAmount"},{type:"uint256",name:"claimedQuoteAmount"},{type:"uint256",name:"expireTime"}]},{type:"bytes32[]",name:"zeroMerkleProof"}],outputs:[]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"resolveCaseAppeals",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"bytes",name:"response"},{type:"tuple[]",name:"guardianSignatures",components:[{type:"bytes32",name:"r"},{type:"bytes32",name:"s"},{type:"uint8",name:"v"},{type:"uint8",name:"guardianIndex"}]}],outputs:[]},{type:"function",name:"resolveDispute",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"bytes",name:"response"},{type:"tuple[]",name:"guardianSignatures",components:[{type:"bytes32",name:"r"},{type:"bytes32",name:"s"},{type:"uint8",name:"v"},{type:"uint8",name:"guardianIndex"}]}],outputs:[]},{type:"function",name:"updateDisputeConfiguration",constant:!1,payable:!1,inputs:[{type:"tuple",name:"disputeConfiguration",components:[{type:"address",name:"appealToken"},{type:"uint64",name:"disputeBondUsd"},{type:"uint64",name:"appealBondUsd"},{type:"uint64",name:"disputeThresholdUsd"},{type:"uint64",name:"caseDuration"},{type:"uint64",name:"voteDuration"},{type:"uint64",name:"resolveDuration"},{type:"uint32",name:"voteCountRate"},{type:"uint32",name:"effectiveVoteRate"}]}],outputs:[]},{type:"function",name:"updateWormholeConfiguration",constant:!1,payable:!1,inputs:[{type:"tuple",name:"wormholeConfiguration",components:[{type:"address",name:"wormhole"},{type:"address",name:"staker"},{type:"bytes4",name:"selector"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"vote",constant:!1,payable:!1,inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"validator"},{type:"uint8",name:"voteOption"},{type:"uint256",name:"deadline"},{type:"uint8",name:"v"},{type:"bytes32",name:"r"},{type:"bytes32",name:"s"}],outputs:[]}];var Zt=[{type:"error",name:"AccountInsufficientFreeAmount",inputs:[]},{type:"error",name:"AccountInsufficientReservedAmount",inputs:[]},{type:"error",name:"AccountInsufficientTradableAmount",inputs:[{type:"uint256",name:"accountTradableAmount"},{type:"uint256",name:"requiredTradableAmount"}]},{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"PermissionDenied",inputs:[{type:"address",name:"caller"},{type:"address",name:"target"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{type:"address",name:"token"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"DepositToAccount",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ExecuteCompensation",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"PayWithPrincipal",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"receiver",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"PayWithProfitFirst",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"receiver",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"usedFreeAmount",indexed:!1},{type:"uint256",name:"usedRestrictedAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReleaseForOrder",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReleaseProfit",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveForOrder",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"SettleToAccount",inputs:[{type:"address",name:"account",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"freeBase",indexed:!1},{type:"uint256",name:"profitBase",indexed:!1},{type:"uint256",name:"freeAmount",indexed:!1},{type:"uint256",name:"profitAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"WithdrawFromAccount",inputs:[{type:"address",name:"account",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:!1,payable:!1,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"deposit",constant:!1,payable:!1,inputs:[{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"executeCompensation",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"reimbursement"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolWithdrawableBaseToken",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"baseAmount"}]},{type:"function",name:"getTradableAmount",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"}],outputs:[{type:"bool"},{type:"uint256"},{type:"uint256"},{type:"uint256"}]},{type:"function",name:"getUserAsset",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"},{type:"address",name:"token"}],outputs:[{type:"uint256",name:"amount"}]},{type:"function",name:"getUserAssets",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"account"}],outputs:[{type:"tuple[]",components:[{type:"address",name:"asset"},{type:"uint256",name:"amount"}]}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isTrustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"payWithPrincipal",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"},{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"payWithProfitFirst",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"}],outputs:[{type:"uint256",name:"usedFreeAmount"},{type:"uint256",name:"usedRestrictedAmount"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"releaseForCancelOrder",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"address",name:"account"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"releaseFromProfitUnlock",constant:!1,payable:!1,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}],outputs:[]},{type:"function",name:"reserveForOrder",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"settlementDeposit",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"positionId"},{type:"address",name:"account"},{type:"tuple",name:"pool",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"riskTier"},{type:"uint8",name:"state"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"},{type:"uint16",name:"maxPriceDeviation"},{type:"bool",name:"compoundEnabled"},{type:"uint64",name:"windowCapUsd"},{type:"address",name:"poolVault"},{type:"address",name:"tradingVault"}]},{type:"uint256",name:"freeBaseAmount"},{type:"uint256",name:"freeQuoteAmount"},{type:"uint256",name:"receivedBaseAmount"},{type:"uint256",name:"receivedQuoteAmount"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateAndWithdraw",constant:!1,payable:!1,inputs:[{type:"address",name:"receiver"},{type:"bytes32",name:"poolId"},{type:"bool",name:"isQuoteToken"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var en={USDC:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",POOL_MANAGER:"0xB131655F326E82753b0e76c1ce853E257524f3a4",Account:"0x0dF5950d0D89d808acC8B712Ed5d5A96fe6A3830",POSITION_MANAGER:"0xE6A51b8FC1b0e2a7f6ab8a0a85Ec4ab5210dF4fB",ORDER_MANAGER:"0xBD72c9F021F1eEA52Ac5dA378C9ffA3612Bfb687",PYTH:"0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",ERC20:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",LIQUIDITY_ROUTER:"0x0fb875c10fe2fF981e467765E3daaE4355b180D0",BASE_POOL:"0xeC0b3C76cC1C47f9B29313c706c1F6FD8D1C023f",QUOTE_POOL:"0x608Bfd6B8Df0807aA6d1500B76a3eAb3C9DFd728",ORACLE:"0xDa5f18BFeC36A397ad9c4AFc82ddfAb1429C66Be",EIP7702Delegation:"0x56Db3d459c8b9386f5B9ddFd91C0ef149200Cfc4",MARKET_MANAGER:"0xa7C6eD2b34a281463bEeE30b3784f9bc4696e7f1",DATA_PROVIDER:"0xdf535EF442a99B1b2C9fBd0a52D7d612234d123c",ORACLE_RESERVE:"0xf8fC5a3E721f83a75A319313C1A5eAa1bbC838FE",FORWARDER:"0x64A5099C3382f7fdA44F9D329faa86C27dA3D375",TRADING_ROUTER:"0x1168c934cFBDADF425280e890B5f2d47ddE778BE",REIMBURSEMENT:"0x6bAac84Ec2B9586A0Da460CC04dFB69efBe85724",DISPUTE_COURT:"0x51fF606E074637A8C7DDD276B3794a8205739b42"};var tn={USDC:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",POOL_MANAGER:"0x05314a21Fc97B74f168730153b2B63A870D25dE5",Account:"0xAC0ca67fd6C7Ff9c80DE58420B840115b6d51c6e",POSITION_MANAGER:"0x1a8cC8391Ee19c3817de64a52904D0557f519bA5",ORDER_MANAGER:"0x3138f425f11f14fE33a180e9Bbf0661C8dc6d8AD",PYTH:"0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",ERC20:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",LIQUIDITY_ROUTER:"0xfb790ECE13Cd9e296b4a06ABF38D10431360c236",BASE_POOL:"0x1F767BEa83EDe5E0C18904f439C579f52c2c0F1b",QUOTE_POOL:"0x50ad7da312c58c6689bEF028954a366cb5b8ee13",ORACLE:"0x3e437094C5687Ed6eDb1883b0bd445Efa9103a55",EIP7702Delegation:"0xc68fdf81ca68B26fdB296645F42a734c12E63751",MARKET_MANAGER:"0x71b57CcB7539aB761fd5C5767362A207a295e337",DATA_PROVIDER:"0xd4FdE3cc72D29b71507823cA43Dd6fD520644E92",ORACLE_RESERVE:"0x4fC26Cf34e5d486BFF211315bf17D77d34130971",FORWARDER:"0x58fb1a663b08871A755734231C387E1d10ac2B10",TRADING_ROUTER:"0x89ba8EDBD63f577cAA1095F25Df0A44A226f28bc",REIMBURSEMENT:"0xDbCe02B080C68671EF6EcEc1a01A789441A3a564",DISPUTE_COURT:"0x47648D171925a69b3A334898AaaE6e7cc41B1735"};var nn={USDC:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",POOL_MANAGER:"0x85e869d98216221807A06636541Ec93C9c0a4B0c",Account:"0xA2c5f49a8722408CDa79460CcEd5B97aDcA4cD56",POSITION_MANAGER:"0x68fE700557Fc766DF9b9959E11fd9DacA3f2ccdA",ORDER_MANAGER:"0xC2C479bfb9b6317D37d77C9A1867Af15a457B39D",PYTH:"0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",ERC20:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",LIQUIDITY_ROUTER:"0xc5331ab0159379E6CfCC1f09b63360D0B9715D74",BASE_POOL:"0x8440a78E65F07D8013dd5B0640E0E713c8fd9893",QUOTE_POOL:"0x50F1F7A772672FE0637cF89AD3aFc093584eD040",ORACLE:"0x9F8e2296fa10d77897E7B252460d27b855eeD251",EIP7702Delegation:"0x9558a64E54de8294E7bcCBA62Ee7323c43473abb",MARKET_MANAGER:"0x3BEaaBc8ba2e117E5B66354F8F5D6dc97F71d434",DATA_PROVIDER:"0x7C672f90CCB8b3500F4285Bf22eBb3A98b4eFEB5",ORACLE_RESERVE:"0x27fd8356cE30Aae5440ce2B765beA5d2527efbAD",FORWARDER:"0xb7Bc467202C8C023ba064E368d979381BCfeD62E",TRADING_ROUTER:"0x2894Ea4ca2D177E6070Ad7b53Bf6C20C6BE83cd6",REIMBURSEMENT:"0x0C076Af7AC1861cf85a76eC8bdE4f67dbf23f2b2",DISPUTE_COURT:"0xbf9C0bbfd60e28906C5b1EB05875411A0Ba01435"};var an={POOL_MANAGER:"0xcf51a6895864c6D8E507fC31EF16b9011287c5f4",Account:"0x35054EfE58Bbdae792aeCaD7bC2e4939c169560f",POSITION_MANAGER:"0x689A0C7E46785584FF7636700ceF5d5e7c141F8D",ORDER_MANAGER:"0xa0B5E5AE9D3E214096C90DDeC04D39B27ED9B272",PYTH:"0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",ERC20:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",LIQUIDITY_ROUTER:"0x0AE31989318565620c03d35889a0B2536b8fba5C",BASE_POOL:"0xc9e3826c42183207B418116A16827C1605132c51",QUOTE_POOL:"0x9A9934D3b22103dE822d94A22A3177d728FE0e5a",ORACLE:"0x0dD8293765358cF7f2646D0B91bA59804E197FC6",EIP7702Delegation:"0x4686F8a0d44b056037b2A51c4342EE7FA8e0A48F",MARKET_MANAGER:"0xe99dAB65c5546D7C87850Bbc40C6a7BEd7328Efa",DATA_PROVIDER:"0x5b6Be9839552a49302d552aB3C223b60Adb8BF1D",ORACLE_RESERVE:"0xB3D5a67223905FE73a0749e7A03525838063C54C",USDC:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",FORWARDER:"0x6C40462A4d45BA4119af59Fb9e41b8eaC9293962",TRADING_ROUTER:"0x0000000000000000000000000000000000000000",REIMBURSEMENT:"0x0000000000000000000000000000000000000000",DISPUTE_COURT:"0x0000000000000000000000000000000000000000"};var sn={USDC:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",POOL_MANAGER:"0x4F917ef137b573D9790b87e3cF6dfb698cF00c9c",Account:"0xE58CC82F96c86f8F809A98BE14D9DC929d503e25",POSITION_MANAGER:"0x7A5000A1DDE26520BfC893c676a288F98F8a029c",ORDER_MANAGER:"0x343d7563eFb904375Fea81BcC4A3eCdDc0CDa8C9",PYTH:"0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",ERC20:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",LIQUIDITY_ROUTER:"0xe9F2E58562aD1D50AfB1eD92EAa6D367A6D0e552",BASE_POOL:"0x39506f97D1c1A91EAfD59368697E20dC1fE5eEDB",QUOTE_POOL:"0x80DAa474e7e2C9c86708e434B80636b92fb4e9EE",ORACLE:"0xB980765F0D5D3B482601F1a62Ec898619DA9c0C5",EIP7702Delegation:"0x9d43e7847f74E141E1A2B4C413D5F89520995551",MARKET_MANAGER:"0x624d1D5258b34d5C3F4f9CdCB7582F677643cdDC",DATA_PROVIDER:"0xb3c6b1448F04B3Eb9A5D83D6c32B0a10F3E7281B",ORACLE_RESERVE:"0x949e8a0284eA5509B47619e7667C3aA43B7c0336",FORWARDER:"0x73F9F9205E2F7E0Fb886afC3D2a53399C85383a5",TRADING_ROUTER:"0x0000000000000000000000000000000000000000",REIMBURSEMENT:"0x0000000000000000000000000000000000000000",DISPUTE_COURT:"0x0000000000000000000000000000000000000000"};var rn={USDC:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",POOL_MANAGER:"0x9E84a999e15CCdb2F64a5AF10939c25769dF6b07",Account:"0x42A1BC012CeC51Ebf3bbf79142bf2a912396FB0e",POSITION_MANAGER:"0x011a25Fe39b2f9033E49d1587CF24780242e40dA",ORDER_MANAGER:"0xfc30D3C858B72a9EDfE6679Fc3355039D276f811",PYTH:"0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",ERC20:"0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",LIQUIDITY_ROUTER:"0x0F4C6f18Fb136DD1eBd6Da3C5d86a86597CF79a3",BASE_POOL:"0x51B62554a76197d5DF2D5dC4D57FF54d40775938",QUOTE_POOL:"0x783Ed065a12e1C1D33c2a8d6408385C1843D3084",ORACLE:"0xaF26d69BC0A6f1DEf8AeB00B6DAD28398ba67a53",EIP7702Delegation:"0xc8558cD3905F273ff45B1dd6D10894445bFa622f",MARKET_MANAGER:"0x3b809daB550f9DD0DbE82567f6EA6137C174532c",DATA_PROVIDER:"0x4B5888025570934cC9D31807feBAAEDaC823Cb8e",ORACLE_RESERVE:"0x3011dA5822c1ECA7fcda64716779769D0089945D",FORWARDER:"0x2943a063ae2A772f4314FaA28E00De827A491Dd3",TRADING_ROUTER:"0xaA16801F36e49cDD4f87938032487C7E6cfbb389",REIMBURSEMENT:"0xBF72B69bA547D0bB7D1255B43Ff5D7f2615326dF",DISPUTE_COURT:"0xeD8B129a5919c45c7391AA73632eA691A471C672"};import Ma from"wretch";var Ee=Ma(),Da=(a,e)=>e?(e=JSON.parse(JSON.stringify(e)),a.includes("?")?a+"&"+new URLSearchParams(e).toString():a+"?"+new URLSearchParams(e).toString()):a,h={get:(a,e,t={})=>{let n=Da(a,e);return Ee.url(n).options(t).get().json()},post:(a,e,t={})=>Ee.url(a).options(t).post(e).json(),put:(a,e,t={})=>Ee.url(a).options(t).put(e).json(),delete:(a,e={})=>Ee.url(a).options(e).delete().json()};var Oa=(o=>(o[o.SUCCESS=9200]="SUCCESS",o[o.SUCCESS_ORIGIN=0]="SUCCESS_ORIGIN",o[o.IDENTITY_VERIFICATION_FAILED=9401]="IDENTITY_VERIFICATION_FAILED",o[o.PERMISSION_DENIED=9403]="PERMISSION_DENIED",o[o.NOT_EXIST=9404]="NOT_EXIST",o[o.REQUEST_LIMIT=9429]="REQUEST_LIMIT",o[o.SERVICE_ERROR=9500]="SERVICE_ERROR",o[o.MISS_REQUESTED_PARAMETER=9900]="MISS_REQUESTED_PARAMETER",o[o.INVALID_PARAMETER=9901]="INVALID_PARAMETER",o.NETWORK_ERROR="ERR_NETWORK",o))(Oa||{}),he=(i=>(i[i.Cook=0]="Cook",i[i.Primed=1]="Primed",i[i.Trench=2]="Trench",i[i.PreBench=3]="PreBench",i[i.Bench=4]="Bench",i))(he||{}),on=(t=>(t[t.Chainlink=1]="Chainlink",t[t.Pyth=2]="Pyth",t))(on||{}),pn=(u=>(u[u.Minute1=1]="Minute1",u[u.Minute5=5]="Minute5",u[u.Minute15=15]="Minute15",u[u.Minute30=30]="Minute30",u[u.Hour1=60]="Hour1",u[u.Hour4=240]="Hour4",u[u.Day1=1440]="Day1",u[u.Week1=10080]="Week1",u[u.Month1=40320]="Month1",u))(pn||{}),Fa=(n=>(n[n.Contract=1]="Contract",n[n.Cook=2]="Cook",n[n.Earn=3]="Earn",n))(Fa||{}),Na=(s=>(s[s.All=0]="All",s[s.Contract=1]="Contract",s[s.Cook=2]="Cook",s[s.Earn=3]="Earn",s))(Na||{}),_a=(t=>(t[t.BlueChips=1]="BlueChips",t[t.Alpha=2]="Alpha",t))(_a||{}),Ba=(n=>(n[n.BlueChips=1]="BlueChips",n[n.Alpha=2]="Alpha",n[n.Favorite=3]="Favorite",n))(Ba||{});var La=(s=>(s[s.Market=0]="Market",s[s.Limit=1]="Limit",s[s.Stop=2]="Stop",s[s.Conditional=3]="Conditional",s))(La||{}),Ua=(t=>(t[t.Increase=0]="Increase",t[t.Decrease=1]="Decrease",t))(Ua||{}),qa=(l=>(l[l.Increase=0]="Increase",l[l.Decrease=1]="Decrease",l[l.AddMargin=2]="AddMargin",l[l.RemoveMargin=3]="RemoveMargin",l[l.CancelOrder=4]="CancelOrder",l[l.ADL=5]="ADL",l[l.Liquidation=6]="Liquidation",l[l.MarketClose=7]="MarketClose",l[l.EarlyClose=8]="EarlyClose",l[l.AddTPSL=9]="AddTPSL",l[l.SecurityDeposit=10]="SecurityDeposit",l[l.TransferToWallet=11]="TransferToWallet",l[l.MarginAccountDeposit=12]="MarginAccountDeposit",l[l.ReferralReward=13]="ReferralReward",l[l.ReferralRewardClaim=14]="ReferralRewardClaim",l))(qa||{}),Ga=(n=>(n[n.Unknown=0]="Unknown",n[n.GTE=1]="GTE",n[n.LTE=2]="LTE",n))(Ga||{}),Wa=(t=>(t[t.Long=0]="Long",t[t.Short=1]="Short",t))(Wa||{}),za=(s=>(s[s.Cancelled=1]="Cancelled",s[s.Expired=2]="Expired",s[s.Successful=9]="Successful",s[s.PartialFilled=8]="PartialFilled",s))(za||{}),Va=(u=>(u[u.Market=1]="Market",u[u.Limit=2]="Limit",u[u.TP=3]="TP",u[u.SL=4]="SL",u[u.ADL=5]="ADL",u[u.ADLTrigger=6]="ADLTrigger",u[u.Liquidation=7]="Liquidation",u[u.EarlyClose=8]="EarlyClose",u[u.MarketClose=9]="MarketClose",u))(Va||{}),$a=(o=>(o[o.Open=0]="Open",o[o.PartialClose=1]="PartialClose",o[o.FullClose=2]="FullClose",o[o.Liquidation=3]="Liquidation",o[o.EarlyClose=4]="EarlyClose",o[o.MarketClose=5]="MarketClose",o[o.ADL=6]="ADL",o[o.TP=7]="TP",o[o.SL=8]="SL",o[o.Increase=9]="Increase",o))($a||{}),Ha=(n=>(n[n.MarginAccount=1]="MarginAccount",n[n.WalletAccount=2]="WalletAccount",n[n.ReferralReward=3]="ReferralReward",n))(Ha||{});var Qa=(s=>(s[s.EXECUTING=1]="EXECUTING",s[s.BROADCAST_FAILED=2]="BROADCAST_FAILED",s[s.TIMEOUT_CANCEL=3]="TIMEOUT_CANCEL",s[s.EXECUTED=9]="EXECUTED",s))(Qa||{});var ur=async()=>h.get(`${J()}/openapi/gateway/scan/market/list`);var J=()=>{let{isTestnet:a,isBetaMode:e}=Y?.getConfigManager()?.getConfig()||{};return e?"https://api-beta.myx.finance":a?"https://api-test.myx.cash":"https://api.myx.finance"},j=async(a,e=[])=>e.length?h.get(`${J()}/openapi/gateway/quote/price/oracles`,{chainId:a,poolIds:e.join(",")}):Promise.reject(new Error("Invalid pool id")),un=async(a,e)=>await h.get(`${J()}/openapi/gateway/scan/market/info?chainId=${a}&poolId=${e}`),dn=async(a,e,t)=>await h.get(`${J()}/openapi/gateway/scan/market/pool-order/open?chainId=${t}`,void 0,{headers:{myx_openapi_access_token:a,myx_openapi_account:e}}),cr=async({chainId:a,poolIds:e},t)=>h.get(`${J()}/openapi/gateway/quote/candle/tickers`,{chainId:a,poolIds:e.join(",")}),yr=async({...a})=>h.get(`${J()}/openapi/gateway/scan/market/base-details`,a),fr=async({...a})=>h.get(`${J()}/openapi/gateway/scan/market/detail`,a),mn=async()=>h.get(`${J()}/openapi/gateway/scan/market`);var Ae,mt=class mt{constructor(){this.version="1.0.5";Wt(this,Ae)}setConfigManager(e){zt(this,Ae,e)}getConfigManager(){return Gt(this,Ae)}setProvider(e){this.provider=e}getProvider(){return this.provider}static getInstance(){return this._instance||(this._instance=new mt),this._instance}async getMarkets(){try{let t=(await mn())?.data||[];return this.Markets=t,t}catch(e){throw e}}};Ae=new WeakMap;var Z=mt,ln=Z.getInstance(),Y=ln,Ka=async a=>{let e=ln.getConfigManager();if(!e?.hasSigner())throw new Error("No signer: call auth({ signer }) or auth({ walletClient })");return e.getViemWalletClient(a)};var cn={USDC:"0x55d398326f99059fF775485246999027B3197955",POOL_MANAGER:"0x04218C23f89cAA2E4395a7Bd94410057705D1184",Account:"0x269cdAd14cf2cD3c720BC16ef0321700CccaC574",POSITION_MANAGER:"0x04218C23f89cAA2E4395a7Bd94410057705D1184",ORDER_MANAGER:"0x8d38a857390E1586481cF8994F4feBc315D0249b",PYTH:"0x4D7E825f80bDf85e913E0DD2A2D54927e9dE1594",ERC20:"0x55d398326f99059fF775485246999027B3197955",LIQUIDITY_ROUTER:"0x637dB5906E51e6e73fF6EF059870cf70B1874aa5",BASE_POOL:"0x6a775E908629eFC6357b3d89E5528524a6f378Dd",QUOTE_POOL:"0x73b2dcfdc7dC78a7A51B778E93c09FC173923BcE",ORACLE:"0xAdD60e47D2C5e7d57B1e5a3F9d24dE43933b8A7A",EIP7702Delegation:"0x798860BbBC6e011C5508f92a102ee53a44cECfb7",MARKET_MANAGER:"0x98Af86B194ce82cac650C87F45e5B9f7A4A40AB2",DATA_PROVIDER:"0x96955bE362b35846c2E7b9B40fC961080DCBbA67",ORACLE_RESERVE:"0xBFE7b174F4013e9f6526030EB0c52b094A237E6E",FORWARDER:"0xD0894e09317F455dd698A706bb62D783e95aA7Ad",TRADING_ROUTER:"0xb0c56a233535971b8903497f98b90Cf53aE77A13",REIMBURSEMENT:"0x5EFB5E4C3807b6152157DbF4Ae75c31F0Cdec478",DISPUTE_COURT:"0xEaAf5b9184C48486a6Fb51f70E101087598a95C8"};var P=a=>{let{isBetaMode:e}=Y?.getConfigManager()?.getConfig()||{};switch(a){case 421614:return e?tn:en;case 59141:return e?an:nn;case 97:return e?rn:sn;case 56:return cn;default:return{}}};var se=(a,e)=>{let t=c(a);return k({address:e,abi:q,client:t})},ke=async(a,e)=>{let t=await M(a);return k({address:e,abi:q,client:t})},F=async a=>{let e=await M(a),[t]=await e.getAddresses();return t??void 0},D=async a=>{let e=P(a),t=await M(a);return k({address:e.LIQUIDITY_ROUTER,abi:Vt,client:t})},ie=(a,e=1)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.POOL_MANAGER,abi:at,client:n})):M(a).then(s=>k({address:t.POOL_MANAGER,abi:at,client:s}))};var X=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.QUOTE_POOL,abi:st,client:n})):M(a).then(s=>k({address:t.QUOTE_POOL,abi:st,client:s}))},H=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.BASE_POOL,abi:it,client:n})):M(a).then(s=>k({address:t.BASE_POOL,abi:it,client:s}))},L=async(a,e)=>{let t=await M(a);return k({address:e,abi:rt,client:t})};var de=(a,e)=>{let t=c(a);return k({address:e,abi:rt,client:t})};var yn=(a,e,t=0)=>{let n=t===0?c(a):null;return n?Promise.resolve(k({address:e,abi:ot,client:n})):M(a).then(s=>k({address:e,abi:ot,client:s}))},ee=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.MARKET_MANAGER,abi:pt,client:n})):M(a).then(s=>k({address:t.MARKET_MANAGER,abi:pt,client:s}))},me=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.DATA_PROVIDER,abi:ut,client:n})):M(a).then(s=>k({address:t.DATA_PROVIDER,abi:ut,client:s}))},lt=async a=>{let e=P(a),t=await M(a);return k({address:e.Account,abi:Zt,client:t})},le=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.FORWARDER,abi:Ie,client:n})):M(a).then(s=>k({address:t.FORWARDER,abi:Ie,client:s}))},fn=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.REIMBURSEMENT,abi:dt,client:n})):M(a).then(s=>k({address:t.REIMBURSEMENT,abi:dt,client:s}))},gn=(a,e=0)=>{let t=P(a),n=e===0?c(a):null;return n?Promise.resolve(k({address:t.DISPUTE_COURT,abi:xe,client:n})):M(a).then(s=>k({address:t.DISPUTE_COURT,abi:xe,client:s}))};var ce=null;function bn(a){ce=a}function Se(){return ce??{}}function ct(){}function In(...a){(ce?.log??ce?.info??ct)(...a)}function ye(...a){(ce?.warn??ct)(...a)}function I(...a){(ce?.error??ct)(...a)}var re=class{constructor(e){this.options={...e,logLevel:e?.logLevel??"info"}}get out(){return this.options.sink??Se()}debug(e,...t){this.options.logLevel!=="none"&&this.options.logLevel==="debug"&&(this.out.log??this.out.info)?.(`[MYX-SDK-DEBUG] ${e}`,...t)}info(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info")&&(this.out.log??this.out.info)?.(`[MYX-SDK-INFO] ${e}`,...t)}error(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info"||this.options.logLevel==="error")&&this.out.error?.(`[MYX-SDK-ERROR] ${e}`,...t)}warn(e,...t){this.options.logLevel!=="none"&&this.out.warn?.(`[MYX-SDK-WARN] ${e}`,...t)}};import{ErrorDecoder as Ja}from"ethers-decode-error";var oo=Ja.create();var S={1:"Invalid Chain",2:"Invalid Token Address",4001:"User Rejected",3:"Insufficient Balance",4:"Insufficient Amount Of Approved",4002:"Invalid Base Token Address",4003:"Invalid Slippage",4004:"Invalid Amount",4005:"Invalid Pool State",4006:"Invalid Params",4007:"Invalid Amount Withdrawable LP Amount"};function ja(a){let e=a;for(;e;){if(e.name==="UserRejectedRequestError")return!0;e=e.cause}return!1}async function b(a){let e=a?.shortMessage||a?.details||a?.message;return typeof a=="string"?{error:a}:ja(a)?{error:S[4001]}:{error:{code:a?.code||a?.name||"Unknow Error",message:e}}}var xn=async(a,e,t)=>{try{return await c(a).readContract({address:t,abi:q,functionName:"balanceOf",args:[e]})}catch(n){throw I(n),n}};import{maxUint256 as Ya,parseUnits as Xa}from"viem";var hn=async(a,e,t,n,s)=>{try{return await c(a).readContract({address:t,abi:q,functionName:"allowance",args:[e,n]})>=s}catch(i){throw i}};import{parseUnits as yt}from"viem";var E=30,_=18;var T=(a,e)=>BigInt(a)*yt(e.toString(),8)/BigInt(10**8),v=async a=>{try{let e=C[a],n=await c(a).getGasPrice();if(n==null)throw new Error("Network Error");return{gasPrice:T(n,e.gasPriceRatio)}}catch(e){throw e}},te=(a,e=.01)=>{let t=yt("1",8)-yt(e.toString(),8);return a*t/BigInt(10**8)};var An=async(a,e,t,n,s)=>{try{let i=C[a],r=await ke(a,t);if(!r.write)throw new Error("Wallet client required for write");let p=await r.estimateGas.approve([n,s]),d=T(p,i.gasLimitRatio),{gasPrice:u}=await v(a),o=await r.write.approve([n,s],{gasLimit:d,gasPrice:u});await c(a).waitForTransactionReceipt({hash:o})}catch(i){throw i}};var w=async a=>{if("chainId"in a&&!Te(a.chainId))throw new Error(S[1]);if("slippage"in a&&!(Number(a?.slippage)<=1&&Number(a?.slippage)>0))throw new Error(S[4003]);if("amount"in a&&(Number(a.amount)===Number.NaN||Number(a.amount)<0))throw new Error(S[4004]);let{tokenAddress:e,contractAddress:t,chainId:n,amount:s,decimals:i,account:r}=a;if(s&&n&&Number(i)>=0&&r){let p=Xa(s.toString(),Number(i));if(e){let d=await xn(n,r,e);if(!d||d<p)throw new Error(S[3])}t&&e&&(await hn(n,r,e,t,p)||await An(n,r,e,t,Ya))}};import{isNil as Za}from"lodash-es";var Cn=async(a,e)=>await Promise.all(e.map(async n=>{let{publishTime:s,vaa:i,oracleType:r,nativeFee:p,price:d,poolId:u}=n,o=Za(p)?1n:BigInt(p);return{poolId:u,price:d,value:o,publishTime:s,oracleType:r??2,vaa:i}})),fe=async(a,e)=>{if(!e||!e.length)return;let t=await j(a,e);return await Cn(a,t.data)},B=async(a,e)=>{if(!e)return;let n=(await j(a,[e]))?.data?.[0];if(!n)throw new Error(`Unable to get price for ${e} in the deposit`);return(await Cn(a,[n]))?.[0]};var Pn=async a=>{try{let{chainId:e,poolId:t}=a,n=C[e],s=await F(e);await w({account:s,chainId:e});let i=await fe(e,[t]);if(!i)return;let r=i.map(g=>g.value),p=i.map(g=>({poolId:t,oracleUpdateData:g?.vaa??"0",publishTime:g.publishTime,oracleType:g.oracleType})),d={prices:p,values:r,poolId:t,recipient:s},u=await D(e),o=await u.estimateGas.claimBasePoolRebate([p,t,s],{value:r[0]}),m=T(o,n.gasLimitRatio),{gasPrice:f}=await v(e);return await u.write.claimBasePoolRebate([p,t,s],{gasLimit:m,gasPrice:f,value:r[0]})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},Rn=async a=>{try{let{chainId:e,poolIds:t}=a;if(t.length===0)return;let n=C[e],s=await F(e);await w({account:s,chainId:e});let i=await fe(e,t);if(!i)return;let r=i.map(A=>({poolId:A.poolId,oracleUpdateData:A?.vaa??"0",publishTime:A.publishTime,oracleType:A.oracleType})),d=i.map(A=>A.value).reduce((A,R)=>R+A,0n),u={prices:r,poolIds:t,value:d,recipient:s},o=await D(e),m=await o.estimateGas.claimBasePoolRebates([r,t,s],{value:d}),f=T(m,n.gasLimitRatio),{gasPrice:y}=await v(e),g=await o.write.claimBasePoolRebates([r,t,s],{gasLimit:f,gasPrice:y,value:d});return await c(e).waitForTransactionReceipt({hash:g})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as kn}from"viem";import{parseUnits as wn}from"viem";var ft=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await H(a)).read.previewLpAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}},Tn=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await H(a)).read.previewBaseAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}},vn=async({chainId:a,account:e,poolId:t,amount:n=0})=>{try{if(!a||!e||!t)return;if(!n)return{baseAmountOut:0n,rebateAmount:0n};let s=C[a],i=18;await w({decimals:i,account:e,chainId:a,amount:Number(n)});let r=wn(n.toString(),i),d=(await j(a,[t])).data?.[0]?.price||"0",u=wn(d,30),m=await(await H(a)).read.previewUserWithdrawData([t,r,e,u]);return{baseAmountOut:m.baseAmountOut,rebateAmount:m.rebateAmount}}catch(s){throw typeof s=="string"?s:await b(s)}};var N=async(a,e)=>{try{return!a||!e?void 0:(await un(a,e)).data}catch(t){throw typeof t=="string"?t:await b(t)}};import{parseUnits as gt}from"viem";function En(a){return a.includes(".")?a.split(".")[1].length:0}var ge=(a=.01,e=[],t=18,n)=>{if(e.length===0)return[];if(e.filter(i=>i.amount&&i.triggerPrice&&i.triggerType).length===0)throw new Error(S[4006]);return e.map(i=>{let r=gt(i.amount.toString(),t),p=gt(i.triggerPrice.toString(),30),d=En(i.triggerPrice.toString()),u=gt(i.triggerPrice.toString(),d),o=te(r*u*BigInt(10**n)/BigInt(10**(d+t)),a);return{amount:r,triggerPrice:p,triggerType:BigInt(i.triggerType),minQuoteOut:o}})};var Sn=async a=>{try{let{poolId:e,chainId:t,amount:n,slippage:s=.01,tpsl:i=[]}=a;await w(a);let r=await N(t,e);if(!r)throw new Error(S[4006]);let p=r?.baseDecimals,d=r?.quoteDecimals,u=r?.baseToken,o=C[t],m=await F(t),y=P(t).BASE_POOL;await w({tokenAddress:u,contractAddress:y,decimals:p,account:m,chainId:t,amount:n});let g=!(Number(r?.state)===0||Number(r?.state)===1),l=[],A=kn(n.toString(),p),R=0n,O;if(g){let W=await B(t,e);if(!W)return;let la=kn(W.price,30);l.push({poolId:e,oracleType:W.oracleType,publishTime:BigInt(W.publishTime),oracleUpdateData:W.vaa}),O=await ft({chainId:t,poolId:e,amountIn:A,price:la}),R=W.value}else O=await ft({chainId:t,poolId:e,amountIn:A});let K=i.map(W=>({amount:n,triggerPrice:W.triggerPrice,triggerType:W.triggerType})),V=ge(s,K,p,d),ae={poolId:e,amountIn:A,minAmountOut:te(O,s),recipient:m,tpslParams:V},we=await D(t),Ye=await we.estimateGas.depositBase([l,ae],{value:R}),Xe=T(Ye,o.gasLimitRatio),{gasPrice:Ze}=await v(t),Lt=await we.write.depositBase([l,ae],{gasLimit:Xe,gasPrice:Ze,value:R});return await c(t).waitForTransactionReceipt({hash:Lt})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as vt}from"viem";import{parseUnits as ss}from"viem";var Pe=async({chainId:a,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(S[2]);let n=P(a),s=await ie(a,0),i=[t,e],r=await s.read.getMarketPool(i);return r.poolId==="0x0000000000000000000000000000000000000000000000000000000000000000"||!r.poolId?void 0:r.poolId}catch(n){throw I(n),typeof n=="string"?n:await b(n)}},It=async a=>{try{return await(await ie(a)).read.getPools()||[]}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},xt=async(a,e,t=0n)=>{try{let s=await(await me(a)).read.getPoolInfo([e,t]);return{quotePool:{poolToken:s.quotePool.poolToken,exchangeRate:s.quotePool.exchangeRate,poolTokenPrice:s.quotePool.poolTokenPrice,poolTokenSupply:s.quotePool.poolTokenSupply,totalDebt:s.quotePool.totalDebt,baseCollateral:s.quotePool.baseCollateral},basePool:{poolToken:s.basePool.poolToken,exchangeRate:s.basePool.exchangeRate,poolTokenPrice:s.basePool.poolTokenPrice,poolTokenSupply:s.basePool.poolTokenSupply,totalDebt:s.basePool.totalDebt,baseCollateral:s.basePool.baseCollateral},reserveInfo:{baseTotalAmount:s.reserveInfo.baseTotalAmount,baseReservedAmount:s.reserveInfo.baseReservedAmount,quoteTotalAmount:s.reserveInfo.quoteTotalAmount,quoteReservedAmount:s.reserveInfo.quoteReservedAmount},fundingInfo:{nextFundingRate:s.fundingInfo.nextFundingRate,lastFundingFeeTracker:s.fundingInfo.lastFundingFeeTracker,nextEpochTime:s.fundingInfo.nextEpochTime},ioTracker:{tracker:s.oi.tracker,longSize:s.oi.longSize,shortSize:s.oi.shortSize,poolEntryPrice:s.oi.poolEntryPrice},liquidityInfo:{windowCaps:s.liquidityInfo.windowCaps,openInterest:s.liquidityInfo.openInterest}}}catch(n){throw I(n),typeof n=="string"?n:await b(n)}};var ht=async({chainId:a,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(S[2]);let n=C[a],s=await ie(a),i={marketId:t,baseToken:e},r=await s.estimateGas.deployPool([i]),p=T(r,n.gasLimitRatio),{gasPrice:d}=await v(a),u=await s.write.deployPool([i],{gasLimit:p,gasPrice:d});if(await c(a).waitForTransactionReceipt({hash:u}))return await Pe({chainId:a,baseToken:e,marketId:t})}catch(n){throw typeof n=="string"?n:await b(n)}};var At=async(a,e,t)=>{try{return await(await yn(a,e)).read.userGenesisShare([t])}catch(n){throw I(n),typeof n=="string"?n:await b(n)}};var Ct=async a=>{try{let{chainId:e,poolId:t,poolType:n,slippage:s=.01,tpsl:i=[]}=a;await w(a);let r=await N(e,t);if(!r)throw new Error(S[4006]);let p=18,d=r.quoteDecimals,u=ge(s,i,p,d),o=C[e],m=await D(e),f={poolId:t,poolType:BigInt(n),tpslParams:u},y=await m.estimateGas.addTpsl([f]),g=T(y,o.gasLimitRatio),{gasPrice:l}=await v(e),A=await m.write.addTpsl([f],{gasLimit:g,gasPrice:l});return await c(e).waitForTransactionReceipt({hash:A})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};var Pt=async a=>{try{let{chainId:e,orderId:t}=a;await w(a);let n=C[e],s=await D(e),i=await s.estimateGas.cancelTpsl([t]),r=T(i,n.gasLimitRatio),{gasPrice:p}=await v(e),d=await s.write.cancelTpsl([t],{gasLimit:r,gasPrice:p});return await c(e).waitForTransactionReceipt({hash:d})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{getAddress as es,formatUnits as Mn}from"viem";async function ts(a){try{return(await fetch(a,{method:"HEAD"})).ok}catch{return!1}}var fu=async(a,e,t)=>{try{let n=c(a),s=e,[i,r,p,d]=await Promise.all([n.readContract({address:s,abi:q,functionName:"name"}),n.readContract({address:s,abi:q,functionName:"symbol"}),n.readContract({address:s,abi:q,functionName:"decimals"}),n.readContract({address:s,abi:q,functionName:"totalSupply"})]),u=es(s),o=`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${a}/assets/${u}/logo.png`,f=await ts(o)?o:"",y;if(t){let g=await n.readContract({address:s,abi:q,functionName:"balanceOf",args:[t]});y=Number(Mn(g,Number(p)))}return{address:e,name:i,symbol:r,decimals:Number(p),icon:f,totalSupply:Number(Mn(d,Number(p))),...t?{balance:y}:{}}}catch(n){throw I(n),n}};import{formatUnits as Ru,parseUnits as wu}from"viem";import{formatUnits as ns,parseUnits as as}from"viem";var Rt=async(a,e,t)=>{try{await w({chainId:a});let n=await N(a,e);if(!n)throw new Error(S[4006]);let s=await F(a),r=((Y?.Markets?.length?Y?.Markets:await Y.getMarkets())||[])?.find(l=>l.chainId===a&&l.marketId===t);if(!r)throw new Error("Invalid Market");let p=as(r.oracleFeeUsd.toString(),n.quoteDecimals);if(!p)throw new Error("Invalid Market");await w({tokenAddress:n.quoteToken,contractAddress:P(a).ORACLE_RESERVE,decimals:n.quoteDecimals,account:s,chainId:a,amount:Number(ns(p,n.quoteDecimals))});let d=C[a],u=await ie(a),o=await u.estimateGas.reprimePool([{poolId:e}]),m=T(o,d.gasLimitRatio),{gasPrice:f}=await v(a),y=await u.write.reprimePool([{poolId:e}],{gasLimit:m,gasPrice:f});return await c(a).waitForTransactionReceipt({hash:y})}catch(n){throw I(n),typeof n=="string"?n:await b(n)}};var wt=async(a,e)=>{try{let t=await Z.getInstance().getConfigManager()?.getAccessToken();if(!t)throw new Error("Failed to obtain accessToken");return(await dn(t,e,a)).data||[]}catch(t){throw I(t),t}};var Tt=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await X(a)).read.previewLpAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}},Dn=async({chainId:a,amountIn:e,poolId:t,price:n=0n})=>{try{let s=C[a];return await(await X(a)).read.previewQuoteAmountOut([t,e,n])}catch(s){throw I(s),typeof s=="string"?s:await b(s)}};var Me=async({amountIn:a,chainId:e,poolId:t,state:n,slippage:s,poolType:i,account:r})=>{let p=!(n===0||n===1),d=[],u=0n,o,m=i===0?Tn:Dn;if(p)try{let y=await B(e,t);if(y){let g=ss(y.price,30);d.push({poolId:t,oracleUpdateData:y.vaa,publishTime:BigInt(y.publishTime),oracleType:y.oracleType}),o=await m({chainId:e,poolId:t,amountIn:a,price:g}),u=y.value}}catch(y){console.error(y),o=await m({chainId:e,poolId:t,amountIn:a})}else o=await m({chainId:e,poolId:t,amountIn:a});let f={poolId:t,amountIn:a,minAmountOut:te(o,s),recipient:r};return{price:d,data:f,value:u}};var Fn=async a=>{try{let{chainId:e,poolId:t,price:n}=a,s=n,i=await H(e);if(typeof n>"u"||n===null)try{let p=await B(e,t);s=vt(p?.price||"0",30)}catch{s=vt("0",30)}return await i.read.withdrawableLpAmount([t,s||0n])}catch(e){throw typeof e=="string"?e:await b(e)}},Nn=async a=>{try{let{chainId:e,poolId:t,amount:n,slippage:s=.01}=a,i=await N(e,t),r=i?.basePoolToken,p=C[e],d=await F(e),u=18;await w({tokenAddress:r,decimals:u,account:d,chainId:e,amount:n});let o=vt(n.toString(),u),{price:m,data:f,value:y}=await Me({poolId:t,chainId:e,account:d,amountIn:o,slippage:s,poolType:0,state:i?.state}),g=await D(e),l=await g.estimateGas.withdrawBase([m,f],{value:y}),A=T(l,p.gasLimitRatio),{gasPrice:R}=await v(e),O=await g.write.withdrawBase([m,f],{gasLimit:A,gasPrice:R,value:y});return await c(e).waitForTransactionReceipt({hash:O})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as is}from"viem";var _n=async a=>{try{let{chainId:e,account:t,poolId:n}=a;if(!e||!t||!n)return;let s=C[e],i=0n,p=(await j(e,[n])).data?.[0]?.price||"0",d=is(p,30),o=await(await H(e)).read.pendingUserRebates([n,t,d]);return{rebates:o?.rebates,genesisRebates:o?.genesisRebates}}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as rs}from"viem";var Bn=async(a,e)=>{if(e)try{let t=await H(a),n=0n,s=await B(a,e);return s?.price&&(n=rs(s.price,30)),await t.read.getPoolTokenPrice([e,n])}catch(t){throw typeof t=="string"?t:await b(t)}};var St={};et(St,{claimQuotePoolRebate:()=>Vn,claimQuotePoolRebates:()=>$n,deposit:()=>Un,getLpPrice:()=>Hn,getRewards:()=>zn,transfer:()=>Wn,withdraw:()=>Gn,withdrawableLpAmount:()=>qn});import{parseUnits as Ln}from"viem";var Un=async a=>{try{let{poolId:e,chainId:t,amount:n,slippage:s=.01,tpsl:i=[]}=a;await w(a);let r=await N(t,e);if(!r)throw new Error(S[4006]);let p=C[t],d=await F(t),o=P(t).QUOTE_POOL,m=r.quoteToken,f=r?.quoteDecimals;await w({tokenAddress:m,contractAddress:o,decimals:f,account:d,chainId:t,amount:n});let y=Ln(n.toString(),f),g=!(Number(r?.state)===0||Number(r?.state)===1),l=[],A=0n,R;if(g){let $=await B(t,e);if(!$)return;let W=Ln($.price,30);l.push({poolId:e,oracleType:$.oracleType,publishTime:BigInt($.publishTime),oracleUpdateData:$.vaa}),R=await Tt({chainId:t,poolId:e,amountIn:y,price:W}),A=$.value}else R=await Tt({chainId:t,poolId:e,amountIn:y});let O=i.map($=>({amount:n,triggerPrice:$.triggerPrice,triggerType:$.triggerType})),K=ge(s,O,f,f),V={poolId:e,amountIn:y,minAmountOut:te(R,s),recipient:d,tpslParams:K},ae=await D(t),we=await ae.estimateGas.depositQuote([l,V],{value:A}),Ye=T(we,p.gasLimitRatio),{gasPrice:Xe}=await v(t),Ze=await ae.write.depositQuote([l,V],{gasLimit:Ye,gasPrice:Xe,value:A});return await c(t).waitForTransactionReceipt({hash:Ze})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as kt}from"viem";var qn=async a=>{try{let{chainId:e,poolId:t,price:n}=a,s=n,i=await X(e);if(typeof n>"u"||n===null)try{let p=await B(e,t);s=kt(p?.price||"0",30)}catch{s=kt("0",30)}return await i.read.withdrawableLpAmount([t,s||0n])}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},Gn=async a=>{try{let{chainId:e,poolId:t,amount:n,slippage:s=.01}=a,i=await N(e,t),r=i?.quotePoolToken,p=C[e],d=await F(e),u=18;await w({tokenAddress:r,decimals:u,account:d,chainId:e,amount:n});let o=kt(n.toString(),u),{price:m,data:f,value:y}=await Me({poolId:t,chainId:e,account:d,amountIn:o,slippage:s,poolType:1,state:i?.state}),g=await D(e),l=await g.estimateGas.withdrawQuote([m,f],{value:y}),A=T(l,p.gasLimitRatio),{gasPrice:R}=await v(e),O=await g.write.withdrawQuote([m,f],{gasLimit:A,gasPrice:R,value:y});return await c(e).waitForTransactionReceipt({hash:O})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as os}from"viem";var Wn=async(a,e,t,n)=>{try{let s=await N(a,e),i=await N(a,t);if(!i||!s)return null;if([3,4].includes(i.state))throw new Error(S[4005]);let r=await F(a),p=C[a],d=18;await w({chainId:a,amount:n,account:r,decimals:d,tokenAddress:s.quotePoolToken});let u={fromPoolId:e,toPoolId:t,minLpOut:0n,amount:os(n.toString(),d)},o=await D(a),m=await o.estimateGas.migrateLiquidity([u]),f=T(m,p.gasLimitRatio),{gasPrice:y}=await v(a),g=await o.write.migrateLiquidity([u],{gasLimit:f,gasPrice:y});return await c(a).waitForTransactionReceipt({hash:g})}catch(s){throw typeof s=="string"?s:await b(s)}};import{parseUnits as ps}from"viem";var zn=async a=>{try{let{chainId:e,account:t,poolId:n}=a;if(!e||!t||!n)return;let s=C[e],r=(await j(e,[n])).data?.[0]?.price||"0",p=ps(r,30);return await(await X(e)).read.pendingUserRebates([n,t,p])}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};var Vn=async a=>{try{let{chainId:e,poolId:t}=a,n=C[e],s=await F(e),i=18;await w({account:s,chainId:e});let r=await fe(e,[t]);if(!r)return;let p=r.map(l=>l.value),d=r.map(l=>({poolId:l.poolId,oracleUpdateData:l?.vaa??"0",publishTime:l.publishTime,oracleType:l.oracleType})),u={prices:d,values:p,poolId:t,recipient:s},o=await D(e),m=await o.estimateGas.claimQuotePoolRebate([d,t,s],{value:p[0]}),f=T(m,n.gasLimitRatio),{gasPrice:y}=await v(e);return await o.write.claimQuotePoolRebate([d,t,s],{gasLimit:f,gasPrice:y,value:p[0]})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}},$n=async a=>{try{let{chainId:e,poolIds:t}=a;if(t.length===0)return;let n=C[e],s=await F(e),i=18;await w({account:s,chainId:e});let r=await fe(e,t);if(!r)return;let p=r.map(R=>({poolId:R.poolId,oracleUpdateData:R?.vaa??"0",publishTime:R.publishTime,oracleType:R.oracleType})),u=r.map(R=>R.value).reduce((R,O)=>O+R,0n),o={prices:p,value:u,poolIds:t,recipient:s},m=await D(e),f=await m.estimateGas.claimQuotePoolRebates([p,t,s],{value:u}),y=T(f,n.gasLimitRatio),{gasPrice:g}=await v(e),l=await m.write.claimQuotePoolRebates([p,t,s],{gasLimit:y,gasPrice:g,value:u});return await c(e).waitForTransactionReceipt({hash:l})}catch(e){throw I(e),typeof e=="string"?e:await b(e)}};import{parseUnits as us}from"viem";var Hn=async(a,e)=>{if(e)try{let t=await X(a),n=0n,s=await B(a,e);return s?.price&&(n=us(s.price,30)),await t.read.getPoolTokenPrice([e,n])}catch(t){throw I(t),typeof t=="string"?t:await b(t)}};var Mt={};et(Mt,{getMarket:()=>Qn,getOracleFee:()=>Kn});var Qn=async(a,e)=>{try{return await w({chainId:a}),e?await(await ee(a)).read.getMarket([e]):void 0}catch(t){throw I(t),typeof t=="string"?t:await b(t)}};var Kn=async(a,e)=>{try{return await w({chainId:a}),e?await(await ee(a)).read.getOracleFee([e]):void 0}catch(t){throw I(t),typeof t=="string"?t:await b(t)}};var ds={createPool:ht,getMarketPoolId:Pe,getMarketPools:It,getPoolInfo:xt,getUserGenesisShare:At,addTpSl:Ct,cancelTpSl:Pt,reprime:Rt,getPoolDetail:N,getOpenOrders:wt};import fs from"mitt";import{Hex as ms,MD5 as ls}from"crypto-es";var De=(a,e)=>ls(a,{outputLength:e||32}).toString(ms);var Oe=a=>{switch(a.request){case"signin":return De(a.request)}return De(JSON.stringify(a))},Re=a=>{let{topic:e,params:t}=a;switch(e){case"candle":return`${e}.${t.globalId}_${t.resolution}`;case"ticker":return`${e}.${t.globalId}`;case"ticker.*":case"order":case"position":return e;default:return De(JSON.stringify({topic:e,params:t}))}},jn=({type:a})=>a==="pong"||a==="signin"||a==="subv2"||a==="unsubv2"||a==="ping"||a==="pong",ys=a=>{switch(a){case"order":case"position":case"ticker.*":return a;default:let[e]=a.split(".");return e}},Yn=a=>{switch(ys(a.type)){case"ticker":{let[,t=""]=a.type.split(".");return{...a,type:Re({topic:"ticker",params:{globalId:parseInt(t)}}),globalId:parseInt(t)}}case"candle":{let[,t=""]=a.type.split("."),[n,s]=t.split("_");return{...a,type:Re({topic:"candle",params:{globalId:parseInt(n),resolution:s}}),globalId:parseInt(n),resolution:s}}}return a};var x=class extends Error{constructor(e,t){super(t),this.name=e}toJSON(){return{code:this.name,message:this.message}}toString(){return`[MYX-ERROR-${this.name}]: ${this.message}`}};import gs from"reconnecting-websocket";var Xn={url:"",initialReconnectDelay:1e3,maxReconnectDelay:3e4,reconnectMultiplier:1.5,maxReconnectAttempts:10,maxEnqueuedMessages:100,requestTimeout:1e4,heartbeatInterval:1e4,heartbeatMessage:"ping",noMessageTimeout:5e3,connectionTimeout:1e4},Fe=class{constructor(e){this.ws=null;this.subscriptions=new Map;this.waitingRequests=new Map;this.eventBus=fs();this.heartbeatIntervalId=null;this.isFirstConnection=!0;this.lastMessageTime=0;let t={...e,logLevel:e?.logLevel||"info"},{logLevel:n,...s}=t;this.config={...Xn,...s},this.logger=new re({logLevel:e?.logLevel}),this.logger.debug("WebSocketClient constructor",this.config)}connect(){return new Promise((e,t)=>{if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING){e();return}try{let n={maxReconnectionDelay:this.config.maxReconnectDelay,minReconnectionDelay:this.config.initialReconnectDelay,reconnectionDelayGrowFactor:this.config.reconnectMultiplier,maxRetries:this.config.maxReconnectAttempts,maxEnqueuedMessages:this.config.maxEnqueuedMessages,connectionTimeout:this.config.connectionTimeout};this.ws=new gs(this.config.url,this.config.protocols,n),this.setupEventListeners(e,t)}catch(n){t(n)}})}async onBeforeReSubscribe(){return this.config.onBeforeReSubscribe&&await this.config.onBeforeReSubscribe(),!0}setupEventListeners(e,t){this.ws&&(this.ws.onopen=async n=>{this.eventBus.emit("open",n),this.lastMessageTime=Date.now(),this.timeoutHeartbeat(),this.isFirstConnection||this.onBeforeReSubscribe().then(()=>this.resubscribeAll()),this.isFirstConnection=!1,e()},this.ws.onmessage=n=>{this.handleMessage(n)},this.ws.onclose=n=>{this.eventBus.emit("close",n),this.stopHeartbeatTimer()},this.ws.onerror=n=>{this.eventBus.emit("error",n),t(n)},this.ws.addEventListener("reconnecting",n=>{this.eventBus.emit("reconnecting",{detail:n.detail||0}),this.isFirstConnection=!1}),this.ws.addEventListener("maxreconnectattempts",()=>{this.eventBus.emit("maxreconnectattempts",void 0)}))}pong(e){this.send({request:"pong",args:e})}request(e){return new Promise((t,n)=>{let s=Oe(e);this.waitingRequests.has(s)?(this.waitingRequests.get(s)?.onSuccess.add(t),this.waitingRequests.get(s)?.onError.add(n)):this.waitingRequests.set(s,{onSuccess:new Set([t]),onError:new Set([n])}),this.send(e)})}subscribe(e,t){let n=Array.isArray(e)?e:[e],s=[],i=new Set;n.forEach(r=>{let p=Re(r);if(!i.has(p))if(i.add(p),this.subscriptions.has(p))this.subscriptions.get(p).callbacks.add(t);else{let d={id:p,topic:r.topic,callbacks:new Set([t])};this.subscriptions.set(p,d),s.push(p),this.logger.debug(`create new subscription: ${p}`)}}),s.length>0&&this.send({request:"subv2",args:s})}unsubscribe(e,t){if(!e)return;let n=Array.isArray(e)?e:[e],s=[],i=new Set;n.forEach(r=>{let p=Re(r);if(i.has(p))return;i.add(p);let d=this.subscriptions.get(p);d&&(d.callbacks.delete(t),this.logger.debug(`remove callback from subscription: ${p}`),d.callbacks.size===0&&(this.subscriptions.delete(p),s.push(p),this.logger.debug(`subscription ${p} has no callbacks, will unsubscribe`)))}),s.length>0&&this.send({request:"unsubv2",args:s})}send(e){let t=typeof e=="string"?e:JSON.stringify(e);if(!this.ws)throw new x("SOCKET_NOT_CONNECTED","WebSocket is not connected");this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING&&this.reconnect(),this.ws.send(t)}disconnect(){this.stopHeartbeatTimer(),this.ws&&(this.ws.close(),this.ws=null)}reconnect(){this.ws?this.ws.readyState!==WebSocket.CONNECTING&&this.ws.reconnect():this.connect().catch(e=>{this.logger.error(e)})}isConnected(){return this.ws?.readyState===WebSocket.OPEN}on(e,t){this.eventBus.on(e,t)}off(e,t){this.eventBus.off(e,t)}handleMessage(e){try{let t=JSON.parse(e.data);if(this.lastMessageTime=Date.now(),t.type==="ping"){queueMicrotask(()=>{this.pong(t.data)});return}if(jn(t)){this.handleAckMessage(t);return}this.handleSubscriptionMessage(t)}catch(t){this.logger.error(`Failed to parse WebSocket message: ${t}`)}}handleAckMessage(e){let t;switch(e.type){case"signin":t=Oe({request:e.type,args:""});break;default:t=Oe({request:e.type,args:e.data.data});break}let n=this.waitingRequests.get(t),s=e.data.code===9200;s?this.logger.debug(`AcK Message:${e.type} received`):(this.logger.error(`Ack Message:${e.type} received`,e),this.eventBus.emit("error",e)),n?.onError.size&&!s&&n.onError.forEach(i=>{i(new x("REQUEST_FAILED","Request failed"))}),n?.onSuccess.size&&s&&n.onSuccess.forEach(i=>{i(e.data)})}handleSubscriptionMessage(e){let t=Yn(e),n=t.type,s=this.subscriptions.get(n);s&&s.callbacks.forEach(i=>{try{i(t)}catch(r){this.logger.error(`Callback Error (${n}): ${r}`)}})}resubscribeAll(){if(this.subscriptions.size===0)return;this.logger.debug("resubscribe all...");let e=Array.from(this.subscriptions.values()).map(t=>t.id);e.length>0&&(this.send({request:"subv2",args:e}),this.logger.debug(`resubscribe ${e.length} topics`))}timeoutHeartbeat(){this.stopHeartbeatTimer(),Date.now()-this.lastMessageTime>(this.config.noMessageTimeout||Xn.noMessageTimeout)&&(this.logger.debug("no message timeout"),this.subscriptions.size>0?this.reconnect():this.ws?.close()),this.heartbeatIntervalId=setTimeout(()=>{this.timeoutHeartbeat()},this.config.heartbeatInterval)}stopHeartbeatTimer(){this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=null)}};var Zn=[56,59144,42161],ea=[59141,421614,97],ta=[97,421614];var Ne={TestNet:"wss://oapi-test.myx.cash/ws",MainNet:"wss://oapi.myx.finance/ws",BetaNet:"wss://oapi-beta.myx.finance/ws"};var _e=class{constructor(e,t){this.clientAuth=!1;this.prevUserAddress=null;this.configManager=e,this.logger=t;let n=Ne.MainNet;e.getConfig().isBetaMode?n=Ne.BetaNet:e.getConfig().isTestnet&&(n=Ne.TestNet),this.wsClient=new Fe({logLevel:this.configManager.getConfig()?.logLevel,url:n,...this.configManager.getConfig()?.socketConfig,onBeforeReSubscribe:()=>{if(this.clientAuth)return this.auth(!0).then(()=>{this.logger.debug("reconnect auth success")})}})}get isConnected(){return this.wsClient.isConnected()}connect(){this.wsClient.connect()}disconnect(){this.wsClient.disconnect()}reconnect(){this.wsClient.reconnect()}subscribeTickers(e,t){let n=Array.isArray(e)?e:[e];this.wsClient.subscribe(n.map(s=>({topic:"ticker",params:{globalId:s}})),t)}unsubscribeTickers(e,t){let n=Array.isArray(e)?e:[e];this.wsClient.unsubscribe(n.map(s=>({topic:"ticker",params:{globalId:s}})),t)}subscribeKline(e,t,n){this.logger.debug(`subscribe kline ${e} ${t}`),this.wsClient.subscribe({topic:"candle",params:{globalId:e,resolution:t}},n)}unsubscribeKline(e,t,n){this.logger.debug(`unsubscribe kline ${e} ${t}`),this.wsClient.unsubscribe({topic:"candle",params:{globalId:e,resolution:t}},n)}async getSdkAuthParams(){let e=this.configManager.getConfig();if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER");let t=await this.configManager.getSignerAddress(e.chainId);if(!t)throw new x("INVALID_SIGNER");return{userAddress:t}}async auth(e=!1){let{userAddress:t}=await this.getSdkAuthParams();if(t===this.prevUserAddress&&this.clientAuth&&!e)return Promise.resolve();this.logger.debug(`sdkaccount: ${t}`),await this.wsClient.request({request:"signin",args:`sdkaccount.${t}`}).then(()=>{this.logger.debug(`auth success ${t}`),this.clientAuth=!0,this.prevUserAddress=t})}async subscribePosition(e){this.logger.debug("subscribe position"),await this.auth(),this.wsClient.subscribe({topic:"position"},e)}unsubscribePosition(e){this.logger.debug("unsubscribe position"),this.wsClient.unsubscribe({topic:"position"},e)}async subscribeOrder(e){this.logger.debug("subscribe order"),await this.auth(),this.wsClient.subscribe({topic:"order"},e)}unsubscribeOrder(e){this.logger.debug("unsubscribe order"),this.wsClient.unsubscribe({topic:"order"},e)}on(e,t){this.wsClient.on(e,t)}off(e,t){this.wsClient.off(e,t)}};function bs(a){return typeof a.getAddresses=="function"&&typeof a.signMessage=="function"&&typeof a.sendTransaction=="function"}function Is(a){return typeof a.getAddress=="function"&&typeof a.signMessage=="function"&&typeof a.sendTransaction=="function"}function Dt(a){let e=a;return{async getAddress(){let[t]=await a.getAddresses();if(!t)throw new Error("WalletClient: no address");return t},async signMessage(t){let n=typeof t=="string"?t:{raw:t};return await a.signMessage({message:n})},async sendTransaction(t){let n=t.to;if(!n)throw new Error("sendTransaction: to is required");return{hash:await a.sendTransaction({to:n,data:t.data,value:t.value!=null?BigInt(t.value):void 0,gas:t.gasLimit!=null?BigInt(t.gasLimit):void 0,gasPrice:t.gasPrice!=null?BigInt(t.gasPrice):void 0,maxFeePerGas:t.maxFeePerGas!=null?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas!=null?BigInt(t.maxPriorityFeePerGas):void 0})}},...typeof e.signTypedData=="function"?{async signTypedData(t){return await e.signTypedData(t)}}:{}}}function na(a){let e=a;return{getAddress:()=>a.getAddress(),signMessage:t=>a.signMessage(t),async sendTransaction(t){return{hash:(await a.sendTransaction({...t,value:t.value!=null?BigInt(t.value):void 0,gasLimit:t.gasLimit!=null?BigInt(t.gasLimit):void 0})).hash}},...typeof e.signTypedData=="function"?{async signTypedData(t){return e.signTypedData(t.domain,t.types,t.message)}}:{}}}function Be(a){return bs(a)?Dt(a):Is(a)?na(a):a}import{createWalletClient as xs,custom as hs}from"viem";function aa(a){let e=ue(a),t=[...e.privateJsonRPCUrl?[e.privateJsonRPCUrl]:[],...Array.isArray(e.publicJsonRPCUrl)?[...e.publicJsonRPCUrl]:[]].filter(Boolean);if(t.length===0)throw new Error(`${a} has no jsonRPCUrl configured`);return t[0]}var Ot={};function As(a){if(!Ot[a]){let e=ue(a);Ot[a]={id:a,name:e.label||`Chain ${a}`,nativeCurrency:e.nativeCurrency,rpcUrls:{default:{http:[aa(a)]}}}}return Ot[a]}async function sa(a,e){let t=aa(e),n=As(e),i={address:await a.getAddress(),type:"local",async signMessage({message:p}){let d=typeof p=="string"?p:p.raw;return await a.signMessage(d)},async signTypedData(p){if(!a.signTypedData)throw new Error("ISigner.signTypedData required for this operation");return await a.signTypedData({domain:p.domain,types:p.types,primaryType:p.primaryType,message:p.message})},source:"custom"};return xs({account:i,chain:n,transport:hs({request:async p=>{if(p.method==="eth_sendTransaction"){let o=p.params?.[0]??{},{hash:m}=await a.sendTransaction({to:o.to,data:o.data,value:o.value!=null?BigInt(o.value):void 0,gasLimit:o.gas!=null?BigInt(o.gas):void 0,gasPrice:o.gasPrice!=null?BigInt(o.gasPrice):void 0,maxFeePerGas:o.maxFeePerGas!=null?BigInt(o.maxFeePerGas):void 0,maxPriorityFeePerGas:o.maxPriorityFeePerGas!=null?BigInt(o.maxPriorityFeePerGas):void 0});return m}let u=await(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p.method,params:p.params??[]})})).json();if(u.error)throw new Error(u.error.message);return u.result}})})}var Le=class{constructor(e){this._normalizedSigner=null;this._getAccessTokenQueue=[];this._isGettingAccessToken=!1;let t={isTestnet:!1,isBetaMode:!1,...e};this.validateConfig(t),this.config=t}clear(){this.accessToken=void 0,this.accessTokenExpiry=void 0,this._normalizedSigner=null,this.config={...this.config,signer:void 0,walletClient:void 0,getAccessToken:void 0}}hasSigner(){return!!(this.config.walletClient||this.config.signer!=null||this._normalizedSigner!=null)}async getSignerAddress(e){if(this.config.walletClient){let[t]=await this.config.walletClient.getAddresses();if(t)return t}if(this._normalizedSigner)return this._normalizedSigner.getAddress();throw new x("INVALID_SIGNER","Invalid signer")}async getViemWalletClient(e){if(this.config.walletClient)return this.config.walletClient;if(this._normalizedSigner)return await sa(this._normalizedSigner,e);throw new x("INVALID_SIGNER","Invalid signer: call auth({ signer }) or auth({ walletClient })")}updateClientChainId(e,t){this.config={...this.config,chainId:e,brokerAddress:t}}auth(e){this.clear(),this.config={...this.config,...e},e.signer!=null&&(this._normalizedSigner=Be(e.signer)),this.validateConfig(this.config)}validateConfig(e){let{isTestnet:t,isBetaMode:n,chainId:s}=e;if(t){if(!ea.includes(s))throw new x("INVALID_CHAIN_ID",`chainId ${s} is not in the range of TESTNET_CHAIN_IDS`)}else if(n){if(!ta.includes(s))throw new x("INVALID_CHAIN_ID",`chainId ${s} is not in the range of BETA_ENV_CHAIN_IDS`)}else if(!Zn.includes(s))throw new x("INVALID_CHAIN_ID",`chainId ${s} is not in the range of MAINNET_CHAIN_IDS`)}async getAccessToken(){return this.accessToken??null}async refreshAccessToken(e=!1){return new Promise((t,n)=>{this._getAccessTokenQueue.push({resolve:t,reject:n,forceRefresh:e}),this._processAccessTokenQueue()})}_processAccessTokenQueue(){if(this._isGettingAccessToken)return;this._isGettingAccessToken=!0;let e=this._getAccessTokenQueue.shift();e?this._refreshAccessToken(e.forceRefresh).then(e.resolve).catch(e.reject).finally(()=>{this._isGettingAccessToken=!1,this._getAccessTokenQueue.length>0&&this._processAccessTokenQueue()}):this._isGettingAccessToken=!1}async _refreshAccessToken(e=!1){if(!e&&this.isAccessTokenValid())return this._isGettingAccessToken=!1,this.accessToken;if(!this.config.getAccessToken)return ye("No getAccessToken method provided in config"),null;try{let t=await this.config.getAccessToken()??{accessToken:"",expireAt:0};if(t&&t.accessToken){let n=3600;if(t.expireAt){let s=Math.floor(Date.now()/1e3);n=t.expireAt-s,n<=0&&(ye("Received expired token, using default expiry"),n=3600)}return this.setAccessToken(t.accessToken,n),t.accessToken}else return ye("\u274C Received empty accessToken"),null}catch(t){return I("\u274C Failed to refresh accessToken:",t),null}}setAccessToken(e,t=3600){this.accessToken=e,this.accessTokenExpiry=Date.now()+t*1e3}getCurrentAccessToken(){return this.accessToken}isAccessTokenValid(){return!!this.accessToken}clearAccessToken(){this.accessToken=void 0,this.accessTokenExpiry=void 0}getConfig(){return this.config}};var Ue=class{constructor(e,t,n){this.configManager=e,this.utils=t,this.api=n}getMarkets(){return Promise.resolve([])}async getPoolLevelConfig(e,t){let n=this.configManager.getConfig();return(await this.api.getPoolLevelConfig({poolId:e,chainId:t})).data}async getKlineList({interval:e,...t}){let n=this.configManager.getConfig();return(await this.api.getKlineData({...t,interval:this.utils.transferKlineResolutionToInterval(e)})).data}async getKlineLatestBar({interval:e,...t}){let n=this.configManager.getConfig();return(await this.api.getKlineLatestBar({...t,interval:this.utils.transferKlineResolutionToInterval(e)})).data}async getTickerList(e){return(await this.api.getTickerData(e)).data}async searchMarketAuth(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.searchMarketAuth({address:t,...e,accessToken:n})).data}async searchMarket(e){return(await this.api.searchMarket(e)).data}async getFavoritesList(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.getFavoritesList({...e,address:t,accessToken:n})).data}async addFavorite(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.addFavorite({...e,address:t,accessToken:n})).data}async removeFavorite(e,t){let n=await this.configManager.getAccessToken()??"";return(await this.api.removeFavorite({...e,address:t,accessToken:n})).data}async getBaseDetail(e){return(await this.api.getBaseDetail(e)).data}async getMarketDetail(e){return(await this.api.getMarketDetail(e)).data}async getPoolSymbolAll(){return(await this.api.getPoolSymbolAll()).data}};import{maxUint256 as Cs}from"viem";var qe=class{constructor(e,t,n,s,i,r){this.configManager=e,this.logger=t,this.utils=n,this.seamless=s,this.account=i,this.api=r}async listPositions(e,t){let n=await this.configManager.getAccessToken();try{return{code:0,data:(await this.api.getPositions({accessToken:n??"",address:e,positionId:t})).data}}catch(s){return this.logger.error("Error fetching positions:",s),{code:-1,message:"Failed to fetch positions"}}}async getPositionHistory(e,t){let n=await this.configManager.getAccessToken()??"";return{code:0,data:(await this.api.getPositionHistory({accessToken:n,...e,address:t})).data}}async adjustCollateral({poolId:e,positionId:t,adjustAmount:n,quoteToken:s,chainId:i,address:r}){let p=this.configManager.getConfig();try{let d=await this.utils.getOraclePrice(e,i);if(!d)throw new Error("Failed to get price data");let u={poolId:e,oracleType:d.oracleType,oracleUpdateData:d?.vaa??"0",publishTime:d.publishTime},o=!1;Number(n)>0&&(o=await this.utils.needsApproval(r,i,s,n,P(i).TRADING_ROUTER));let m=BigInt(0),f=BigInt(n)>0?BigInt(n):0n,y=await this.account.getAvailableMarginBalance({poolId:e,chainId:i,address:r}),g=y.code===0?y.data??0n:0n,l=BigInt(0);g<f&&(l=f-g,m=l);let A={token:s,amount:m.toString()};if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let R=await L(i,p.brokerAddress);if(o){let K=await this.utils.approveAuthorization({chainId:i,quoteAddress:s,amount:Cs.toString(),spenderAddress:P(i).TRADING_ROUTER});if(K.code!==0)throw new Error(K.message)}let O=await R.write.updatePriceAndAdjustCollateral([[u],A,t,n],{value:BigInt(d?.value??"1"),gas:BigInt(1e7)*U[i]/100n});return await c(i).waitForTransactionReceipt({hash:O}),{code:0,data:{hash:O},message:"Adjust collateral transaction submitted"}}catch(d){return{code:-1,message:d.message}}}};var Ps={IOC:0},oe=Ps.IOC;var Ge={MARKET:0,LIMIT:1,STOP:2,CONDITIONAL:3},Lc={NONE:0,GTE:1,LTE:2},pe={INCREASE:0,DECREASE:1},Uc={LONG:0,SHORT:1},qc={IOC:0},Gc={PENDING:0,PARTIAL:1,FILLED:2,CANCELLED:3,REJECTED:4,EXPIRED:5};import{maxUint256 as ia}from"viem";var We=class{constructor(e,t,n,s,i,r){this.configManager=e,this.logger=t,this.utils=n,this.seamless=s,this.account=i,this.api=r}async createIncreaseOrder(e,t,n){try{let s=this.configManager.getConfig(),i=await this.utils.getNetworkFee(n,e.chainId),r=BigInt(i);e.tpSize&&BigInt(e.tpSize)>0&&(r+=BigInt(i)),e.slSize&&BigInt(e.slSize)>0&&(r+=BigInt(i));let p=BigInt(e.collateralAmount)+BigInt(t),d=await this.account.getAvailableMarginBalance({poolId:e.poolId,chainId:e.chainId,address:e.address}),u=d.code===0?d.data??0n:0n,o=p+r,m=BigInt(0),f=o-u;f>BigInt(0)&&(m=f);let y={token:e.executionFeeToken,amount:m.toString()},g={user:e.address,poolId:e.poolId,orderType:e.orderType,triggerType:e.triggerType,operation:pe.INCREASE,direction:e.direction,collateralAmount:p.toString(),size:e.size,price:e.price,timeInForce:oe,postOnly:e.postOnly??!1,slippagePct:e.slippagePct??"0",leverage:e.leverage??0,tpSize:e.tpSize??"0",tpPrice:e.tpPrice??"0",slSize:e.slSize??"0",slPrice:e.slPrice??"0"},l=await this.utils.needsApproval(e.address,e.chainId,e.executionFeeToken,e.collateralAmount,P(e.chainId).TRADING_ROUTER);if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");if(l){let V=await this.utils.approveAuthorization({chainId:e.chainId,quoteAddress:e.executionFeeToken,amount:ia.toString(),spenderAddress:P(e.chainId).TRADING_ROUTER});if(V.code!==0)throw new Error(V.message)}let A=await L(e.chainId,this.configManager.getConfig().brokerAddress),R;if(e.positionId){this.logger.info("createIncreaseOrder nft position params--->",{...g,positionId:e.positionId});let V=await A.estimateGas.placeOrderWithPosition([e.positionId.toString(),{...y},g]);R=await A.write.placeOrderWithPosition([e.positionId.toString(),{...y},g],{gasLimit:V*U[e.chainId]/100n})}else{this.logger.info("createIncreaseOrder salt position params--->",{positionSalt:"1",data:g,depositData:y});let ae=await A.estimateGas.placeOrderWithSalt(["1",{...y},g]);R=await A.write.placeOrderWithSalt(["1",{...y},g],{gasLimit:ae*U[e.chainId]/100n})}let O=await c(e.chainId).waitForTransactionReceipt({hash:R});return{code:0,message:"create increase order success",data:{success:!0,transactionHash:R,blockNumber:O?.blockNumber,gasUsed:O?.gasUsed?.toString(),status:O?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:O}}}catch(s){return this.logger.error("Error placing order:",s),{code:-1,message:s?.message}}}async closeAllPositions(e,t){try{let n=this.configManager.getConfig(),s={token:"0x0000000000000000000000000000000000000000",amount:"0"},i=t.map(m=>m.positionId.toString()),r=t.map(m=>({user:m.address,poolId:m.poolId,orderType:m.orderType,triggerType:m.triggerType,operation:pe.DECREASE,direction:m.direction,collateralAmount:m.collateralAmount,size:m.size,price:m.price,timeInForce:oe,postOnly:m.postOnly,slippagePct:m.slippagePct,leverage:m.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0}));if(this.logger.info("closeAllPositions params--->",s,i,r),!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let p=await L(e,this.configManager.getConfig().brokerAddress),d=await p.estimateGas.placeOrdersWithPosition([s,i,r]),u=await p.write.placeOrdersWithPosition([s,i,r],{gasLimit:d*U[e]/100n}),o=await c(e).waitForTransactionReceipt({hash:u});return{code:0,message:"close all positions success",transactionHash:u,blockNumber:o?.blockNumber,gasUsed:o?.gasUsed?.toString(),status:o?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:o}}catch(n){return{code:-1,message:n?.message}}}async createDecreaseOrder(e){try{let t=this.configManager.getConfig(),n={user:e.address,poolId:e.poolId,orderType:e.orderType,triggerType:e.triggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:e.collateralAmount,size:e.size,price:e.price,timeInForce:oe,postOnly:e.postOnly,slippagePct:e.slippagePct,leverage:e.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0},s={token:"0x0000000000000000000000000000000000000000",amount:"0"};if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let i=await L(e.chainId,this.configManager.getConfig().brokerAddress),r;if(e.positionId){this.logger.info("createDecreaseOrder nft position params--->",[e.positionId,s,{data:n}]);let u=await i.estimateGas.placeOrderWithPosition([e.positionId.toString(),s,n]);r=await i.write.placeOrderWithPosition([e.positionId.toString(),s,n],{gasLimit:u*U[e.chainId]/100n})}else{this.logger.info("createDecreaseOrder salt position params--->",[1,s,{data:n}]);let o=await i.estimateGas.placeOrderWithSalt(["1",s,n]);r=await i.write.placeOrderWithSalt(["1",s,n],{gasLimit:o*U[e.chainId]/100n})}let p=await c(e.chainId).waitForTransactionReceipt({hash:r});return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:r,blockNumber:p?.blockNumber,gasUsed:p?.gasUsed?.toString(),status:p?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:p}}}catch(t){return{code:-1,message:t?.message}}}async createPositionTpSlOrder(e){try{let t=await L(e.chainId,this.configManager.getConfig().brokerAddress);try{if(e.tpSize!=="0"&&e.slSize!=="0"){let d=[{user:e.address,poolId:e.poolId,orderType:Ge.STOP,triggerType:e.tpTriggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:"0",size:e.tpSize??"0",price:e.tpPrice??"0",timeInForce:oe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},{user:e.address,poolId:e.poolId,orderType:Ge.STOP,triggerType:e.slTriggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:"0",size:e.slSize??"0",price:e.slPrice??"0",timeInForce:oe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"}],u={token:"0x0000000000000000000000000000000000000000",amount:"0"},o;if(e.positionId){let y=await t.estimateGas.placeOrdersWithPosition([u,[e.positionId.toString(),e.positionId.toString()],d]);o=await t.write.placeOrdersWithPosition([u,[e.positionId.toString(),e.positionId.toString()],d],{gasLimit:y*U[e.chainId]/100n})}else{this.logger.info("createPositionTpSlOrder salt position data--->",d);let y=1,g=await t.estimateGas.placeOrdersWithSalt([u,[y.toString(),y.toString()],d]);o=await t.write.placeOrdersWithSalt([u,[y.toString(),y.toString()],d],{gasLimit:g*U[e.chainId]/100n})}let m=await c(e.chainId).waitForTransactionReceipt({hash:o});return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:o,blockNumber:m?.blockNumber,gasUsed:m?.gasUsed?.toString(),status:m?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:m}}}let n={user:e.address,poolId:e.poolId,orderType:Ge.STOP,triggerType:e.tpSize!=="0"?e.tpTriggerType:e.slTriggerType,operation:pe.DECREASE,direction:e.direction,collateralAmount:"0",size:e.tpSize!=="0"?e.tpSize??"0":e.slSize??"0",price:e.tpPrice!=="0"?e.tpPrice??"0":e.slPrice??"0",timeInForce:oe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:0,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},s={token:"0x0000000000000000000000000000000000000000",amount:"0"},i;if(e.positionId){this.logger.info("createPositionTpOrSlOrder nft position data--->",n);let d=await t.estimateGas.placeOrderWithPosition([e.positionId.toString(),s,n]);i=await t.write.placeOrderWithPosition([e.positionId.toString(),s,n],{gasLimit:d*U[e.chainId]/100n})}else{this.logger.info("createPositionTpOrSlOrder salt position data--->",n);let d=1,u=await t.estimateGas.placeOrderWithSalt([d.toString(),s,n]);i=await t.write.placeOrderWithSalt([d.toString(),s,n],{gasLimit:u*U[e.chainId]/100n})}let r=await c(e.chainId).waitForTransactionReceipt({hash:i});return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:i,blockNumber:r?.blockNumber,gasUsed:r?.gasUsed?.toString(),status:r?.status==="success"?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:r}}}catch(n){return{code:-1,message:n?.message}}}catch(t){return{code:-1,message:t?.message}}}async cancelAllOrders(e,t){try{if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=await(await L(t,this.configManager.getConfig().brokerAddress)).write.cancelOrders([e]);return await c(t).waitForTransactionReceipt({hash:s}),{code:0,message:"cancel all orders success"}}catch(n){return{code:-1,message:n?.message}}}async cancelOrder(e,t){try{if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=await(await L(t,this.configManager.getConfig().brokerAddress)).write.cancelOrder([e]);return await c(t).waitForTransactionReceipt({hash:s}),{code:0,message:"cancel order success"}}catch(n){return{code:-1,message:n?.message}}}async cancelOrders(e,t){try{if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=await(await L(t,this.configManager.getConfig().brokerAddress)).write.cancelOrders([e]);return await c(t).waitForTransactionReceipt({hash:s}),{code:0,message:"Orders canceled success"}}catch(n){return this.logger.error("Error canceling orders:",n),{code:-1,message:n?.message}}}async updateOrderTpSl(e,t,n,s,i,r){let p=this.configManager.getConfig(),d=await this.utils.getNetworkFee(i,n),u={orderId:e.orderId,size:e.size,price:e.price,tpsl:{tpSize:r?e.tpSize:"0",tpPrice:r?e.tpPrice:"0",slSize:r?e.slSize:"0",slPrice:r?e.slPrice:"0"}},o={token:t,amount:d.toString()};if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let m=await L(n,p.brokerAddress);this.logger.info("updateOrderTpSl params",u);try{if(await this.utils.needsApproval(s,n,e.executionFeeToken,d.toString(),P(n).TRADING_ROUTER)){let A=await this.utils.approveAuthorization({chainId:n,quoteAddress:e.executionFeeToken,amount:ia.toString(),spenderAddress:P(n).TRADING_ROUTER});if(A.code!==0)throw new Error(A.message)}let y=await m.estimateGas.updateOrder([o,u]),g=await m.write.updateOrder([o,u],{gasLimit:y*U[n]/100n}),l=await c(n).waitForTransactionReceipt({hash:g});return this.logger.info("updateOrderTpSl receipt",l),{code:0,data:l,message:"update order success"}}catch(f){return this.logger.error("Error updating order:",f),{code:-1,message:"Failed to update order"}}}async getOrders(e){let t=await this.configManager.getAccessToken();try{return{code:0,data:(await this.api.getOrders(t??"",e)).data}}catch(n){return this.logger.error("Error fetching orders:",n),{code:-1,message:"Failed to fetch orders"}}}async getOrderHistory(e,t){let n=await this.configManager.getAccessToken()??"";return{code:0,data:(await this.api.getHistoryOrders({accessToken:n,...e,address:t})).data}}};import{decodeEventLog as ws,maxUint256 as Ts}from"viem";var ra=[{type:"error",name:"AddressEmptyCode",inputs:[{type:"address",name:"target"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{type:"address",name:"implementation"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotAddressManager",inputs:[]},{type:"error",name:"NotAllowedIdentifier",inputs:[]},{type:"error",name:"NotDependencyManager",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotProxyAdmin",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{type:"bytes32",name:"slot"}]},{type:"event",anonymous:!1,name:"BlockHeader",inputs:[{type:"uint256",name:"blockNumber",indexed:!1},{type:"uint256",name:"blockTimestamp",indexed:!1},{type:"uint256",name:"sequence",indexed:!1}]},{type:"event",anonymous:!1,name:"CollateralAccepted",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"quoteDebt",indexed:!1},{type:"uint256",name:"baseCollateral",indexed:!1},{type:"uint256",name:"quoteCollateral",indexed:!1},{type:"uint256",name:"totalQuoteDebt",indexed:!1},{type:"uint256",name:"totalBaseCollateral",indexed:!1}]},{type:"event",anonymous:!1,name:"CollateralAdjusted",inputs:[{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint256",name:"beforeCollateralAmount",indexed:!1},{type:"uint256",name:"afterCollateralAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"EnterDispute",inputs:[{type:"bytes32",name:"poolId",indexed:!1}]},{type:"event",anonymous:!1,name:"Exchanged",inputs:[{type:"address",name:"user",indexed:!1},{type:"address",name:"source",indexed:!1},{type:"address",name:"target",indexed:!1},{type:"uint256",name:"sourceAmount",indexed:!1},{type:"uint256",name:"targetAmount",indexed:!1},{type:"uint256",name:"price",indexed:!1}]},{type:"event",anonymous:!1,name:"ExecutionMatched",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256[]",name:"triggerOrderIds",indexed:!1},{type:"uint256[]",name:"matchedOrderIds",indexed:!1},{type:"uint8",name:"matchType",indexed:!1},{type:"uint256",name:"price",indexed:!1}]},{type:"event",anonymous:!1,name:"ExitDispute",inputs:[{type:"bytes32",name:"poolId",indexed:!1}]},{type:"event",anonymous:!1,name:"FeeDistributed",inputs:[{type:"address",name:"user",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"int32",name:"tradingFeeRate",indexed:!1},{type:"bool",name:"isMaker",indexed:!1},{type:"int256",name:"tradingFee",indexed:!1},{type:"uint256",name:"baseTradingFee",indexed:!1},{type:"uint256",name:"brokerTradingFee",indexed:!1},{type:"address",name:"broker",indexed:!1},{type:"uint256",name:"referralRebate",indexed:!1},{type:"uint256",name:"referrerRebate",indexed:!1},{type:"address",name:"referrer",indexed:!1},{type:"int256",name:"reserveFee",indexed:!1}]},{type:"event",anonymous:!1,name:"FundingRateUpdated",inputs:[{type:"uint64",name:"epochs",indexed:!1},{type:"uint64",name:"duration",indexed:!1},{type:"uint64",name:"previousEpochTime",indexed:!1},{type:"uint64",name:"lastEpochTime",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"int256",name:"fundingRate",indexed:!1},{type:"int256",name:"fundingRateTracker",indexed:!1},{type:"uint256",name:"price",indexed:!1}]},{type:"event",anonymous:!1,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityLockUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint64",name:"windowAnchor",indexed:!1},{type:"uint256",name:"priceFloor",indexed:!1},{type:"uint256",name:"priceCeiling",indexed:!1},{type:"int256",name:"openInterest",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityMigrated",inputs:[{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"fromPoolId",indexed:!1},{type:"bytes32",name:"toPoolId",indexed:!1},{type:"uint256",name:"lpAmountIn",indexed:!1},{type:"uint256",name:"lpAmountOut",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityStopOrderCancelled",inputs:[{type:"uint256",name:"orderId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"string",name:"reason",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityStopOrderCreated",inputs:[{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint8",name:"poolType",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"uint256",name:"triggerPrice",indexed:!1},{type:"uint8",name:"triggerType",indexed:!1},{type:"uint256",name:"minQuoteOut",indexed:!1}]},{type:"event",anonymous:!1,name:"LiquidityStopOrderExecuted",inputs:[{type:"uint256",name:"orderId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"executor",indexed:!1},{type:"uint256",name:"oraclePrice",indexed:!1},{type:"uint256",name:"poolTokenPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"MarketCreated",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"address",name:"deployer",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint32",name:"baseReserveRatio",indexed:!1},{type:"uint32",name:"quoteReserveRatio",indexed:!1},{type:"uint64",name:"oracleFeeUsd",indexed:!1},{type:"uint64",name:"oracleRefundFeeUsd",indexed:!1},{type:"uint128",name:"poolPrimeThreshold",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderCancelled",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"string",name:"remark",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderFilled",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint8",name:"orderType",indexed:!1},{type:"uint256",name:"orderSize",indexed:!1},{type:"uint256",name:"fillSize",indexed:!1},{type:"uint256",name:"filledSize",indexed:!1},{type:"uint256",name:"orderPrice",indexed:!1},{type:"uint256",name:"fillPrice",indexed:!1},{type:"int256",name:"realizedPnl",indexed:!1},{type:"int256",name:"tradingFee",indexed:!1},{type:"int256",name:"fundingFee",indexed:!1},{type:"uint256",name:"executionFeeAmount",indexed:!1},{type:"address",name:"keeper",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderMarkedADL",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"available",indexed:!1},{type:"uint256",name:"requested",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderPlaced",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint8",name:"orderType",indexed:!1},{type:"uint8",name:"operation",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint8",name:"triggerType",indexed:!1},{type:"uint256",name:"collateralAmount",indexed:!1},{type:"uint256",name:"size",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint8",name:"tif",indexed:!1},{type:"bool",name:"postOnly",indexed:!1},{type:"uint16",name:"slippagePct",indexed:!1},{type:"uint256",name:"executionFeeAmount",indexed:!1},{type:"uint16",name:"userLeverage",indexed:!1}]},{type:"event",anonymous:!1,name:"OrderUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"size",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint256",name:"tpSize",indexed:!1},{type:"uint256",name:"tpPrice",indexed:!1},{type:"uint256",name:"slSize",indexed:!1},{type:"uint256",name:"slPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolActivated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint8",name:"oracleType",indexed:!1},{type:"bytes32",name:"oracleFeedId",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolDeactivated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"string",name:"remark",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolDeployed",inputs:[{type:"bytes32",name:"marketId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"deployer",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"address",name:"basePoolToken",indexed:!1},{type:"address",name:"quotePoolToken",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolDeposited",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"recipient",indexed:!1},{type:"address",name:"underlyingToken",indexed:!1},{type:"address",name:"poolToken",indexed:!1},{type:"uint256",name:"underlyingIn",indexed:!1},{type:"uint256",name:"poolTokenOut",indexed:!1},{type:"uint256",name:"oraclePrice",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1},{type:"uint256",name:"poolTokenPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolFundDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"profits",indexed:!1},{type:"uint256",name:"genesisProfits",indexed:!1},{type:"uint256",name:"basePoolAmount",indexed:!1},{type:"uint256",name:"quotePoolAmount",indexed:!1},{type:"uint256",name:"genesisBasePoolAmount",indexed:!1},{type:"uint256",name:"genesisQuotePoolAmount",indexed:!1},{type:"uint256",name:"exchangedBaseFromProfits",indexed:!1},{type:"uint256",name:"exchangedBaseAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolFundingFeeSettled",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"int256",name:"prevFundingRateTracker",indexed:!1},{type:"int256",name:"nextFundingRateTracker",indexed:!1},{type:"uint256",name:"price",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"fundingFee",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolPreDeactivated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"string",name:"remark",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolPrimed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolRebateClaimed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"recipient",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolRefunded",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"receiver",indexed:!1},{type:"address",name:"baseToken",indexed:!1},{type:"address",name:"quoteToken",indexed:!1},{type:"uint256",name:"baseAmount",indexed:!1},{type:"uint256",name:"quoteAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolReprimed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"primer",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolSettlementRecorded",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"poolEntryPrice",indexed:!1},{type:"int256",name:"realizedPnl",indexed:!1}]},{type:"event",anonymous:!1,name:"PoolWithdrawn",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"address",name:"recipient",indexed:!1},{type:"address",name:"underlyingToken",indexed:!1},{type:"address",name:"poolToken",indexed:!1},{type:"uint256",name:"poolTokenIn",indexed:!1},{type:"uint256",name:"underlyingOut",indexed:!1},{type:"uint256",name:"rebateOut",indexed:!1},{type:"uint256",name:"oraclePrice",indexed:!1},{type:"uint256",name:"exchangeRate",indexed:!1},{type:"uint256",name:"poolTokenPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionEarlyClosed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"executeSize",indexed:!1},{type:"uint256",name:"executePrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionForceClosed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"executePrice",indexed:!1},{type:"string",name:"reason",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionLiquidated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"positionSize",indexed:!1},{type:"uint256",name:"liquidationSize",indexed:!1},{type:"uint256",name:"liquidationPrice",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionNFTMinted",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"oldPositionId",indexed:!1},{type:"bytes32",name:"newPositionId",indexed:!1},{type:"uint256",name:"tokenId",indexed:!1},{type:"address",name:"owner",indexed:!1},{type:"address",name:"recipient",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionRiskControlDataMigrated",inputs:[{type:"bytes32",name:"from",indexed:!1},{type:"bytes32",name:"to",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionRiskControlDataUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"uint256",name:"freeAmount",indexed:!1},{type:"uint256",name:"lockedAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionTransfer",inputs:[{type:"address",name:"from",indexed:!1},{type:"address",name:"to",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1}]},{type:"event",anonymous:!1,name:"PositionUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"owner",indexed:!1},{type:"bytes32",name:"positionId",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint8",name:"direction",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"uint256",name:"beforeSize",indexed:!1},{type:"uint256",name:"afterSize",indexed:!1},{type:"uint256",name:"beforeCollateralAmount",indexed:!1},{type:"uint256",name:"afterCollateralAmount",indexed:!1},{type:"uint256",name:"entryPrice",indexed:!1},{type:"int256",name:"fundingRateIndex",indexed:!1},{type:"uint8",name:"riskTier",indexed:!1},{type:"uint256",name:"earlyClosePrice",indexed:!1}]},{type:"event",anonymous:!1,name:"ReferralRebateClaimed",inputs:[{type:"address",name:"user",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveRebateCollected",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"address",name:"keeper",indexed:!1},{type:"uint256",name:"poolAmount",indexed:!1},{type:"uint256",name:"stakingAmount",indexed:!1},{type:"uint256",name:"keeperAmount",indexed:!1},{type:"uint256",name:"treasuryAmount",indexed:!1},{type:"uint256",name:"reservedAmount",indexed:!1},{type:"uint256",name:"ecoFundAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"ReserveRebateDisbursed",inputs:[{type:"bytes32",name:"poolId",indexed:!1},{type:"address",name:"token",indexed:!1},{type:"uint256",name:"amount",indexed:!1},{type:"address",name:"keeper",indexed:!1},{type:"uint256",name:"poolAmount",indexed:!1},{type:"uint256",name:"stakingAmount",indexed:!1},{type:"uint256",name:"keeperAmount",indexed:!1},{type:"uint256",name:"treasuryAmount",indexed:!1},{type:"uint256",name:"reservedAmount",indexed:!1},{type:"uint256",name:"ecoFundAmount",indexed:!1}]},{type:"event",anonymous:!1,name:"TradingFeeTierUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"uint8",name:"feeType",indexed:!1},{type:"uint8",name:"tier",indexed:!1},{type:"uint32",name:"takerFeeRate",indexed:!1},{type:"int32",name:"makerFeeRate",indexed:!1},{type:"bool",name:"isEnabled",indexed:!1}]},{type:"event",anonymous:!1,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:!0}]},{type:"event",anonymous:!1,name:"UserFeeDataUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"signer",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint8",name:"tier",indexed:!1},{type:"address",name:"referrer",indexed:!1},{type:"uint32",name:"totalReferralRebatePct",indexed:!1},{type:"uint32",name:"referrerRebatePct",indexed:!1}]},{type:"event",anonymous:!1,name:"UserSettlementRecorded",inputs:[{type:"address",name:"user",indexed:!1},{type:"bytes32",name:"poolId",indexed:!1},{type:"uint256",name:"orderId",indexed:!1},{type:"int256",name:"charge",indexed:!1},{type:"int256",name:"realizedPnl",indexed:!1},{type:"int256",name:"tradingFee",indexed:!1},{type:"int256",name:"fundingFee",indexed:!1}]},{type:"event",anonymous:!1,name:"UserSpecialFeeTierUpdated",inputs:[{type:"address",name:"broker",indexed:!1},{type:"address",name:"user",indexed:!1},{type:"uint8",name:"oldTier",indexed:!1},{type:"uint8",name:"newTier",indexed:!1}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"emitCollateralAccepted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"quoteDebt"},{type:"uint256",name:"baseCollateral"},{type:"uint256",name:"quoteCollateral"},{type:"uint256",name:"totalQuoteDebt"},{type:"uint256",name:"totalBaseCollateral"}]}],outputs:[]},{type:"function",name:"emitCollateralAdjusted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint8",name:"direction"},{type:"uint256",name:"beforeCollateralAmount"},{type:"uint256",name:"afterCollateralAmount"}]}],outputs:[]},{type:"function",name:"emitEnterDispute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[]},{type:"function",name:"emitExchanged",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"address",name:"source"},{type:"address",name:"target"},{type:"uint256",name:"sourceAmount"},{type:"uint256",name:"targetAmount"},{type:"uint256",name:"price"}]}],outputs:[]},{type:"function",name:"emitExecutionMatched",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256[]",name:"triggerOrderIds"},{type:"uint256[]",name:"matchedOrderIds"},{type:"uint8",name:"matchType"},{type:"uint256",name:"price"}]}],outputs:[]},{type:"function",name:"emitExitDispute",constant:!1,payable:!1,inputs:[{type:"bytes32",name:"poolId"}],outputs:[]},{type:"function",name:"emitFundingRateUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint64",name:"epochs"},{type:"uint64",name:"duration"},{type:"uint64",name:"previousEpochTime"},{type:"uint64",name:"lastEpochTime"},{type:"bytes32",name:"poolId"},{type:"int256",name:"fundingRate"},{type:"int256",name:"fundingRateTracker"},{type:"uint256",name:"price"}]}],outputs:[]},{type:"function",name:"emitLiquidityLockUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint64",name:"windowAnchor"},{type:"uint256",name:"priceFloor"},{type:"uint256",name:"priceCeiling"},{type:"int256",name:"openInterest"}]}],outputs:[]},{type:"function",name:"emitLiquidityMigrated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"bytes32",name:"fromPoolId"},{type:"bytes32",name:"toPoolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"lpAmountOut"}]}],outputs:[]},{type:"function",name:"emitLiquidityStopOrderCancelled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"bytes32",name:"poolId"},{type:"string",name:"reason"}]}],outputs:[]},{type:"function",name:"emitLiquidityStopOrderCreated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"poolType"},{type:"uint256",name:"amount"},{type:"uint256",name:"triggerPrice"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"minQuoteOut"}]}],outputs:[]},{type:"function",name:"emitLiquidityStopOrderExecuted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"bytes32",name:"poolId"},{type:"address",name:"executor"},{type:"uint256",name:"oraclePrice"},{type:"uint256",name:"poolTokenPrice"}]}],outputs:[]},{type:"function",name:"emitMarketCreated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"marketId"},{type:"address",name:"deployer"},{type:"address",name:"quoteToken"},{type:"uint32",name:"baseReserveRatio"},{type:"uint32",name:"quoteReserveRatio"},{type:"uint64",name:"oracleFeeUsd"},{type:"uint64",name:"oracleRefundFeeUsd"},{type:"uint128",name:"poolPrimeThreshold"}]}],outputs:[]},{type:"function",name:"emitOrderCancelled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"emitOrderFilled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint8",name:"orderType"},{type:"uint256",name:"orderSize"},{type:"uint256",name:"fillSize"},{type:"uint256",name:"filledSize"},{type:"uint256",name:"orderPrice"},{type:"uint256",name:"fillPrice"},{type:"int256",name:"realizedPnl"},{type:"int256",name:"tradingFee"},{type:"int256",name:"fundingFee"},{type:"uint256",name:"executionFeeAmount"},{type:"address",name:"keeper"}]}],outputs:[]},{type:"function",name:"emitOrderMarkedADL",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"available"},{type:"uint256",name:"requested"}]}],outputs:[]},{type:"function",name:"emitOrderPlaced",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint8",name:"orderType"},{type:"uint8",name:"operation"},{type:"uint8",name:"direction"},{type:"uint8",name:"triggerType"},{type:"uint256",name:"collateralAmount"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint8",name:"tif"},{type:"bool",name:"postOnly"},{type:"uint16",name:"slippagePct"},{type:"uint256",name:"executionFeeAmount"},{type:"uint16",name:"userLeverage"}]}],outputs:[]},{type:"function",name:"emitOrderUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"size"},{type:"uint256",name:"price"},{type:"uint256",name:"tpSize"},{type:"uint256",name:"tpPrice"},{type:"uint256",name:"slSize"},{type:"uint256",name:"slPrice"}]}],outputs:[]},{type:"function",name:"emitPoolActivated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint8",name:"oracleType"},{type:"bytes32",name:"oracleFeedId"}]}],outputs:[]},{type:"function",name:"emitPoolDeactivated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"emitPoolDeployed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"marketId"},{type:"bytes32",name:"poolId"},{type:"address",name:"deployer"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"address",name:"basePoolToken"},{type:"address",name:"quotePoolToken"}]}],outputs:[]},{type:"function",name:"emitPoolDeposited",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"},{type:"address",name:"underlyingToken"},{type:"address",name:"poolToken"},{type:"uint256",name:"underlyingIn"},{type:"uint256",name:"poolTokenOut"},{type:"uint256",name:"oraclePrice"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"}]}],outputs:[]},{type:"function",name:"emitPoolFundDistributed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"profits"},{type:"uint256",name:"genesisProfits"},{type:"uint256",name:"basePoolAmount"},{type:"uint256",name:"quotePoolAmount"},{type:"uint256",name:"genesisBasePoolAmount"},{type:"uint256",name:"genesisQuotePoolAmount"},{type:"uint256",name:"exchangedBaseFromProfits"},{type:"uint256",name:"exchangedBaseAmount"}]}],outputs:[]},{type:"function",name:"emitPoolFundingFeeSettled",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"int256",name:"prevFundingRateTracker"},{type:"int256",name:"nextFundingRateTracker"},{type:"uint256",name:"price"},{type:"uint8",name:"direction"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"fundingFee"}]}],outputs:[]},{type:"function",name:"emitPoolPreDeactivated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"emitPoolPrimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}]}],outputs:[]},{type:"function",name:"emitPoolRebateClaimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"},{type:"uint256",name:"amount"}]}],outputs:[]},{type:"function",name:"emitPoolRefunded",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"receiver"},{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}]}],outputs:[]},{type:"function",name:"emitPoolReprimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"primer"},{type:"address",name:"token"},{type:"uint256",name:"amount"}]}],outputs:[]},{type:"function",name:"emitPoolSettlementRecorded",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"poolEntryPrice"},{type:"int256",name:"realizedPnl"}]}],outputs:[]},{type:"function",name:"emitPoolWithdrawn",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"},{type:"address",name:"underlyingToken"},{type:"address",name:"poolToken"},{type:"uint256",name:"poolTokenIn"},{type:"uint256",name:"underlyingOut"},{type:"uint256",name:"rebateOut"},{type:"uint256",name:"oraclePrice"},{type:"uint256",name:"exchangeRate"},{type:"uint256",name:"poolTokenPrice"}]}],outputs:[]},{type:"function",name:"emitPositionEarlyClosed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"executeSize"},{type:"uint256",name:"executePrice"}]}],outputs:[]},{type:"function",name:"emitPositionForceClosed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"executePrice"},{type:"string",name:"reason"}]}],outputs:[]},{type:"function",name:"emitPositionLiquidated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"orderId"},{type:"uint256",name:"positionSize"},{type:"uint256",name:"liquidationSize"},{type:"uint256",name:"liquidationPrice"}]}],outputs:[]},{type:"function",name:"emitPositionNFTMinted",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bytes32",name:"oldPositionId"},{type:"bytes32",name:"newPositionId"},{type:"uint256",name:"tokenId"},{type:"address",name:"owner"},{type:"address",name:"recipient"}]}],outputs:[]},{type:"function",name:"emitPositionRiskControlDataMigrated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"from"},{type:"bytes32",name:"to"}]}],outputs:[]},{type:"function",name:"emitPositionRiskControlDataUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bytes32",name:"positionId"},{type:"uint256",name:"freeAmount"},{type:"uint256",name:"lockedAmount"}]}],outputs:[]},{type:"function",name:"emitPositionTransfer",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"bytes32",name:"positionId"}]}],outputs:[]},{type:"function",name:"emitPositionUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"owner"},{type:"bytes32",name:"positionId"},{type:"bytes32",name:"poolId"},{type:"uint8",name:"direction"},{type:"uint256",name:"orderId"},{type:"uint256",name:"beforeSize"},{type:"uint256",name:"afterSize"},{type:"uint256",name:"beforeCollateralAmount"},{type:"uint256",name:"afterCollateralAmount"},{type:"uint256",name:"entryPrice"},{type:"int256",name:"fundingRateIndex"},{type:"uint8",name:"riskTier"},{type:"uint256",name:"earlyClosePrice"}]}],outputs:[]},{type:"function",name:"emitReferralRebateClaimed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"address",name:"token"},{type:"uint256",name:"amount"}]}],outputs:[]},{type:"function",name:"emitReserveRebateCollected",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"token"},{type:"uint256",name:"amount"},{type:"address",name:"keeper"},{type:"uint256",name:"poolAmount"},{type:"uint256",name:"stakingAmount"},{type:"uint256",name:"keeperAmount"},{type:"uint256",name:"treasuryAmount"},{type:"uint256",name:"reservedAmount"},{type:"uint256",name:"ecoFundAmount"}]}],outputs:[]},{type:"function",name:"emitReserveRebateDisbursed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"address",name:"token"},{type:"uint256",name:"amount"},{type:"address",name:"keeper"},{type:"uint256",name:"poolAmount"},{type:"uint256",name:"stakingAmount"},{type:"uint256",name:"keeperAmount"},{type:"uint256",name:"treasuryAmount"},{type:"uint256",name:"reservedAmount"},{type:"uint256",name:"ecoFundAmount"}]}],outputs:[]},{type:"function",name:"emitTradingFeeTierUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"uint8",name:"feeType"},{type:"uint8",name:"tier"},{type:"uint32",name:"takerFeeRate"},{type:"int32",name:"makerFeeRate"},{type:"bool",name:"isEnabled"}]}],outputs:[]},{type:"function",name:"emitUserFeeDataUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"signer"},{type:"address",name:"user"},{type:"uint8",name:"tier"},{type:"address",name:"referrer"},{type:"uint32",name:"totalReferralRebatePct"},{type:"uint32",name:"referrerRebatePct"}]}],outputs:[]},{type:"function",name:"emitUserFeeSettlementAndDistributed",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"int256",name:"charge"},{type:"int256",name:"realizedPnl"},{type:"int256",name:"tradingFee"},{type:"int256",name:"fundingFee"},{type:"int32",name:"tradingFeeRate"},{type:"bool",name:"isMaker"},{type:"uint256",name:"baseTradingFee"},{type:"uint256",name:"brokerTradingFee"},{type:"address",name:"broker"},{type:"uint256",name:"referralRebate"},{type:"uint256",name:"referrerRebate"},{type:"address",name:"referrer"},{type:"int256",name:"reserveFee"}]}],outputs:[]},{type:"function",name:"emitUserSpecialFeeTierUpdated",constant:!1,payable:!1,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"broker"},{type:"address",name:"user"},{type:"uint8",name:"oldTier"},{type:"uint8",name:"newTier"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:!1,payable:!1,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isBlockHeaderEmitted",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"uint256",name:"blockNumber"}],outputs:[{type:"bool"}]},{type:"function",name:"proxiableUUID",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"registerContract",constant:!1,payable:!1,inputs:[{type:"bytes32[]",name:"identifiers"}],outputs:[]},{type:"function",name:"sequencer",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"upgradeTo",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var Ft={"0xfa52dfc0":"AccountInsufficientFreeAmount()","0xe2a1a260":"AccountInsufficientReservedAmount()","0xffd10028":"AccountInsufficientTradableAmount(uint256,uint256)","0x9996b315":"AddressEmptyCode(address)","0x4c9c8ce3":"ERC1967InvalidImplementation(address)","0xb398979f":"ERC1967NonPayable()","0xd6bda275":"FailedCall()","0xf92ee8a9":"InvalidInitialization()","0x44d3438f":"NotAddressManager()","0x3fc81f20":"NotDependencyManager()","0xd7e6bcf8":"NotInitializing()","0x507f487a":"NotProxyAdmin()","0xe03f6024":"PermissionDenied(address,address)","0x5274afe7":"SafeERC20FailedOperation(address)","0xe07c8dba":"UUPSUnauthorizedCallContext()","0xaa1d49a4":"UUPSUnsupportedProxiableUUID(bytes32)","0x24775e06":"SafeCastOverflowedUintToInt(uint256)","0xba767932":"ConvertAmountMismatch(uint256,uint256)","0xd93c0665":"EnforcedPause()","0x8dfc202b":"ExpectedPause()","0x059e2f49":"InRewindMode()","0x42301c23":"InsufficientOutputAmount()","0xcaa99aac":"MismatchExecuteFee(uint256,uint256,uint256)","0x8637dfc0":"NotInRewindMode()","0x4578ddb8":"OnlyRelayer()","0x1e4fbdf7":"OwnableInvalidOwner(address)","0x118cdaa7":"OwnableUnauthorizedAccount(address)","0x3ee5aeb5":"ReentrancyGuardReentrantCall()","0x90b8ec18":"TransferFailed()","0xbe1af266":"InternalOnly()","0x3385aa1f":"ExceedOrderSize(uint256)","0xb07e3bc4":"InsufficientCollateral(uint256,uint256)","0x613970e0":"InvalidParameter()","0x27d08510":"NotActiveBroker(address)","0xf6412b5a":"NotOrderOwner()","0x70d645e3":"NotPositionOwner()","0xe75316c6":"OrderNotExist(OrderId)","0xba01b06f":"PoolNotActive(PoolId)","0xddefae28":"AlreadyMinted()","0x64283d7b":"ERC721IncorrectOwner(address,uint256,address)","0x177e802f":"ERC721InsufficientApproval(address,uint256)","0xa9fbf51f":"ERC721InvalidApprover(address)","0x5b08ba18":"ERC721InvalidOperator(address)","0x89c62b64":"ERC721InvalidOwner(address)","0x64a0ae92":"ERC721InvalidReceiver(address)","0x73c6ac6e":"ERC721InvalidSender(address)","0x7e273289":"ERC721NonexistentToken(uint256)","0xb4762117":"ExceedMaxLeverage(PositionId)","0x29143a42":"ExceedPositionSize()","0x8ea9158f":"InvalidPosition(PositionId)","0xa5afd143":"PositionNotHealthy(PositionId,uint256)","0xba0d3752":"PositionNotInitialized(PositionId)","0xc20f35b7":"UnderflowOI()","0xf4d678b8":"InsufficientBalance()","0x6aee3c1a":"InsufficientRiskReserves()","0x2c5211c6":"InvalidAmount()","0x82cb17ef":"InvalidSplitConfig()","0xe921c36b":"AlreadyMigrated(PositionId,PositionId)","0xd34e366f":"ExceedBaseCollateral(uint256,uint256)","0xc7544914":"ExceedDebt(uint256,uint256)","0xe7aa687a":"ExceedExchangeable()","0x4b3c8f33":"ExceedMaxBaseProfit()","0xdc82bd68":"ExceedMinOutputAmount()","0xdb42144d":"InsufficientBalance(address,uint256,uint256)","0x5646203f":"InsufficientCollateral(PositionId,uint256)","0x9ac13039":"InsufficientPoolProfit()","0x14be833f":"InsufficientReturnAmount(uint256,uint256)","0x419ecd12":"MatchNotSupported()","0x4ec4fd74":"PoolFundingFeeNotPositive(int256,uint256,Direction)","0xba8f5df5":"PoolNotCompoundable(PoolId)","0xf645eedf":"ECDSAInvalidSignature()","0xfce698f7":"ECDSAInvalidSignatureLength(uint256)","0xd78bce0c":"ECDSAInvalidSignatureS(bytes32)","0x48834bee":"ExpiredFeeData()","0x56d69198":"InvalidFeeRate()","0x80577032":"NoRebateToClaim()","0x6e6b79b0":"NotBrokerSigner(address)","0xff70343d":"UnsupportedAssetClass(AssetClass)","0x185676be":"UnsupportedFeeTier(uint8)","0x60b25fe4":"BrokerAlreadyExists()","0x7eb4a674":"BrokerNotFound()","0x8c3b5bf0":"NotBrokerAdmin()","0x3733548a":"InvalidFeeTier()","0x192105d7":"InitializationFunctionReverted(address,bytes)","0x97c7f537":"ExcessiveSlippage()","0x700deaad":"InvalidADLPosition(OrderId,PositionId)","0xf64fa6a8":"InvalidOrder(OrderId)","0xd4944235":"NoADLNeeded(OrderId)","0xe079169e":"NotReachedPrice(OrderId,uint256,uint256,TriggerType)","0xc60eb335":"OnlyKeeper()","0xa8ce4432":"SafeCastOverflowedIntToUint(int256)","0x17229ec4":"NotMeetEarlyCloseCriteria(PositionId)","0x0dc149f0":"AlreadyInitialized()","0x7a5c919f":"InvalidRewindPrice()","0xc53f84e7":"PositionRemainsHealthy(PositionId)","0x1dab59cf":"InvalidOrderPair(OrderId,OrderId)","0x230e8e43":"PoolNotInPreBenchState(PoolId)","0x107dec14":"RiskCloseNotAllowed()","0x664431a8":"NotAllowedTarget(address)","0x03357c6c":"ExceedsMaximumRelayFee()","0x0d10f63b":"InconsistentParamsLength()","0x38802743":"InsufficientFeeAllowance(address,uint256,uint256)","0xd95b4ad5":"InsufficientFeeBalance(address,uint256,uint256)","0xa3972305":"MismatchedSender(address)","0xc3b80e86":"RelayerRegistered(address)","0xee0844a3":"RemoveRelayerFailed()","0xc583a8da":"IncorrectFee(uint256)","0x00bfc921":"InvalidPrice()","0x148cd0dd":"VerifyPriceFailed()","0xb12d13eb":"ETHTransferFailed()","0xa83325d4":"PoolOracleFeeCharged()","0x6b75f90d":"PoolOracleFeeNotCharged()","0x42a0e2a7":"PoolOracleFeeNotExisted()","0x8ee01e1c":"PoolOracleFeeNotSoldOut()","0x5e0a829b":"ETHTransferFailed(address,uint256)","0x4ba6536f":"GasLimitExceeded(address,uint256,uint256)","0xca1aae4b":"GasLimitNotSet(address)","0x3728b83d":"InvalidAmount(uint256)","0x3484727e":"BaseFeeNotSoldOut()","0x0251bde4":"LPNotFullyMinted()","0x1acb203e":"PositionNotEmpty()","0x2be7b24b":"UnexpectedPoolState()","0x759b3876":"UnhealthyAfterRiskTierApplied(PositionId)","0x7bd42a2e":"NotEmptyAddress()","0x6697b232":"AccessControlBadConfirmation()","0xe2517d3f":"AccessControlUnauthorizedAccount(address,bytes32)","0x7c9a1cf9":"AlreadyVoted()","0x796ea3a6":"BondNotReleased()","0x6511c20d":"BondZeroAmount()","0xf38e5973":"CaseAppealNotFinished()","0x1eaa4a59":"CaseDeadlineNotReached()","0xe6c67e3a":"CaseDeadlineReached()","0x0fc957b1":"CaseNotAccepted()","0x3ddb819d":"CaseNotExist(CaseId)","0x79eab18d":"CaseRespondentAppealed(CaseId,address)","0xa179f8c9":"ChainIdMismatch()","0x311c16d3":"DisputeNotAllowed()","0x752d88c0":"InvalidAccountNonce(address,uint256)","0xa710429d":"InvalidContractAddress()","0x8076dd8a":"InvalidFunctionSignature()","0xc37906a0":"InvalidPayloadLength(uint256,uint256)","0xdcdedda9":"InvalidPoolToken()","0x3471a3c2":"InvalidProfitAmount()","0x1d9617a0":"InvalidResponseVersion()","0x9284b197":"InvalidSourceChain()","0xb9021668":"NoChainResponse()","0xc546bca4":"NotCaseRespondent(CaseId,address)","0x84ae4a30":"NumberOfResponsesMismatch()","0x02164961":"RequestTypeMismatch()","0x4cf72652":"RiskCloseNotCompleted()","0x0819bdcd":"SignatureExpired()","0xc00ca938":"UnexpectedCaseState()","0x7935e939":"UnexpectedCaseType()","0x5e7bd6ec":"UnexpectedNumberOfResults()","0x51ee5853":"UnsupportedQueryType(uint8)","0x29ca666b":"UntrustfulVoting()","0x439cc0cd":"VerificationFailed()","0x714f5513":"VersionMismatch()","0x96b8e05b":"WrongQueryType(uint8,uint8)","0xbb6b170d":"ZeroQueries()","0xa9214540":"AlreadyClaimed(CaseId,address)","0xd4ac59c1":"InvalidAmount(CaseId,address)","0x7a6f5328":"MerkleTreeVerificationFailed(CaseId,address)","0x094a5cfe":"ReimbursementValidity(CaseId)","0x8b922563":"TreeAlreadySet()","0x7b27120a":"InDisputeMode()","0xb04111ef":"InsufficientFreeCollateral(PositionId,uint256)","0x12f1b11a":"InsufficientLockedCollateral(PositionId,uint256)","0x6dfcc650":"SafeCastOverflowedUintDowncast(uint8,uint256)","0xd24b47fb":"UserProfitFrozen()","0x1c151780":"ExceedMinOutput(uint256,uint256)","0xe1f0493d":"NotAllowedCaller(address)","0xfb8f41b2":"ERC20InsufficientAllowance(address,uint256,uint256)","0xe450d38c":"ERC20InsufficientBalance(address,uint256,uint256)","0xe602df05":"ERC20InvalidApprover(address)","0xec442f05":"ERC20InvalidReceiver(address)","0x96c6fd1e":"ERC20InvalidSender(address)","0x94280d62":"ERC20InvalidSpender(address)","0x62791302":"ERC2612ExpiredSignature(uint256)","0x4b800e46":"ERC2612InvalidSigner(address,address)","0xb3512b0c":"InvalidShortString()","0x305a27a9":"StringTooLong(string)","0xfd0f789d":"ExceedMaxPriceDeviation()","0x407b87e5":"ExchangeRateAlreadyApplied()","0x5c6c5686":"ExchangeRateAlreadyDisabled()","0x1ae17fcd":"InvalidDeviationRatio()","0x18b88897":"InvalidUpdateFee()","0xf76740e3":"PriceDeviationBelowMinimum()","0x49386283":"PriceDeviationThresholdReached()","0x19abf40e":"StalePrice()","0xe351cd13":"ExceedMaxExchangeableAmount()","0x15912a6f":"NotSupportVersion()","0xf1364a74":"ArrayEmpty()","0x15ed381d":"ExceedMaxProfit()","0x51aeee6c":"PoolNotExist(PoolId)","0x70f6c197":"InvalidQuoteTokenAddress()","0x0b8457f4":"InvalidRatioParams()","0x29dae146":"MarketAlreadyExisted()","0xf040b67a":"MarketNotExisted()","0x0e442a4a":"InvalidBaseToken()","0x24e219c7":"MarketNotExist(MarketId)","0xcc36f935":"PoolExists(PoolId)","0xe84c308d":"ExceedBaseReserved(uint256,uint256)","0x3e241751":"ExceedQuoteReserved(uint256,uint256)","0xde656889":"ExceedReservable(uint256,uint256,uint256)","0xd54d0fc4":"InsufficientLiquidity(uint256,uint256,uint256)","0x7e562a65":"InvalidDistributionAmount()","0x83c7580d":"ReservableNotEnough(uint256,uint256)","0x94eef58a":"ERC2771ForwarderExpiredRequest(uint48)","0xc845a056":"ERC2771ForwarderInvalidSigner(address,address)","0x70647f79":"ERC2771ForwarderMismatchedValue(uint256,uint256)","0xd2650cd1":"ERC2771UntrustfulTarget(address,address)","0xcf479181":"InsufficientBalance(uint256,uint256)","0x4c150d8f":"DifferentMarket(PoolId,PoolId)","0xaa98b06a":"InsufficientQuoteIn(uint256,uint256,uint256)","0x3e589bee":"InvalidLiquidityAmount()","0xaebd3617":"InvalidTpsl(uint256)","0x7fe81129":"SamePoolMigration(PoolId)","0x71c4efed":"SlippageExceeded(uint256,uint256)","0x62b9bc7b":"DesignatedTokenMismatch(address,address)","0x49465eb0":"NotForwardAllowedTarget(address)","0x301b6707":"ExecutionFeeNotCollected()","0xc6e8248a":"InsufficientSize()","0xd15b4fe2":"InvalidQuoteToken()","0xd8daec7c":"MarketNotInitialized()","0xcd4891b6":"NotInDisputeMode()","0x1ad308dc":"OrderExpired(OrderId)","0x486aa307":"PoolNotInitialized()"};var ze=class{constructor(e,t){this.configManager=e,this.logger=t}getOrderIdFromTransaction(e){if(!e||!e.logs)return null;for(let t=0;t<e.logs.length;t++){let n=e.logs[t];this.logger.info(`Log ${t}:`,{address:n.address,topics:n.topics,data:n.data});try{let s=ws({abi:ra,data:n.data??"0x",topics:n.topics??[]}),i=s.args;if(s.eventName==="OrderPlaced"&&i?.orderId!=null)return String(i.orderId)}catch{continue}}return null}async getApproveQuoteAmount(e,t,n,s){try{if(!n||typeof n=="string"&&!n.trim())throw new Error("getApproveQuoteAmount: tokenAddress is required (ERC20 contract address)");let i=s??P(t).Account,p=await se(t,n).read.allowance([e,i]);return{code:0,data:String(p)}}catch(i){throw this.logger.error("Error getting allowance:",i),typeof i=="string"?i:await b(i)}}async needsApproval(e,t,n,s,i){try{let p=(await this.getApproveQuoteAmount(e,t,n,i)).data,d=BigInt(p),u=BigInt(s);return d<u}catch(r){return this.logger.error("Error checking approval needs:",r),!0}}async approveAuthorization({chainId:e,quoteAddress:t,amount:n,spenderAddress:s}){try{let i=await ke(e,t),r=n??Ts,p=s??P(e).Account,d=await this.getGasPriceByRatio(),u=await i.write.approve([p,r],{gasPrice:d});return await c(e).waitForTransactionReceipt({hash:u}),{code:0,message:"Approval success"}}catch(i){return this.logger.error("Approval error:",i),{code:-1,message:i?.message}}}async getUserTradingFeeRate(e,t,n,s){let r=this.configManager.getConfig().brokerAddress;try{let p=de(n,r),d=s??await this.configManager.getSignerAddress(n),u=await p.read.getUserFeeRate([d,e,t]);return{code:0,data:{takerFeeRate:u[0].toString(),makerFeeRate:u[1].toString(),baseTakerFeeRate:u[2].toString(),baseMakerFeeRate:u[3].toString()}}}catch(p){return this.logger.error("Error getting user trading fee rate:",p),{code:-1,message:p?.message??"Unknown error"}}}async getNetworkFee(e,t){try{return(await(await ee(t,0)).read.getExecutionFee([e])).toString()}catch(n){return this.logger.error("Error getting network fee:",n),"0"}}async getOraclePrice(e,t){try{let n=await B(t,e);if(!n)throw new Error("Failed to get price data");return n}catch(n){throw this.logger.error("Error getting oracle price:",n),n}}async buildUpdatePriceParams(e,t){let n=await this.getOraclePrice(e,t);if(!n)throw new Error("Failed to get price data");return[{poolId:e,oracleUpdateData:n.vaa,publishTime:n.publishTime,oracleType:n.oracleType,value:n.value,price:n.price}]}transferKlineResolutionToInterval(e){switch(e){case"1m":return 1;case"5m":return 5;case"15m":return 15;case"30m":return 30;case"1h":return 60;case"4h":return 240;case"1d":return 1440;case"1w":return 10080;case"1M":return 40320;default:throw new x("PARAM_ERROR",`Invalid kline resolution: ${e}`)}}async getErrorMessage(e,t="Unknown error"){try{if(typeof e=="string")return e;if(e instanceof x)return e.message;let n=await b(e);return n?n.error:JSON.stringify(e)}catch(n){return n?.message??n?.toString()??t}}async getLiquidityInfo({chainId:e,poolId:t,marketPrice:n}){try{return{code:0,data:await(await me(e,0)).read.getPoolInfo([t,n])}}catch(s){return this.logger.error("Error getting pool info:",s),{code:-1,message:s?.message}}}formatErrorMessage(e){if(typeof e=="string")return e;if(e instanceof x)return e.message;if(e?.code==="ACTION_REJECTED"||e?.code===4001||e?.info?.error?.code===4001||typeof e?.message=="string"&&(e.message.toLowerCase().includes("user rejected")||e.message.toLowerCase().includes("denied")))return"User Rejected";let t=e?.data;if(!t&&e?.message&&typeof e.message=="string"){let n=e.message.match(/data=["'](0x[0-9a-fA-F]+)["']/i);n&&n[1]&&(t=n[1])}if(t){let n=typeof t=="string"&&t.startsWith("0x")?t.slice(0,10).toLowerCase():null;if(n){let s=Object.keys(Ft).find(i=>i.toLowerCase()===n);if(s)return Ft[s]}}return e?.reason?e.reason:e?.message?e.message:JSON.stringify(e)}async getGasPriceByRatio(){let e=this.configManager.getConfig().chainId;return(await v(e)).gasPrice}async getGasLimitByRatio(e){let t=this.configManager.getConfig().chainId,n=C[t];return T(e,n?.gasLimitRatio??1.3)}};import{maxUint256 as vs,zeroAddress as Es}from"viem";import oa from"dayjs";var Ve=class{constructor(e,t,n,s){this.configManager=e,this.logger=t,this.utils=n,this.client=s}async withRetry(e,t=3,n=300){let s;for(let i=0;i<t;i++)try{return await e()}catch(r){s=r,i<t-1&&await new Promise(p=>setTimeout(p,n))}throw s}async getTradeFlow(e,t){let n=await this.configManager.getAccessToken()??"";return{code:0,data:(await this.client.api.getTradeFlow({accessToken:n,...e,address:t})).data}}async getWalletQuoteTokenBalance({chainId:e,address:t,tokenAddress:n}){if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Invalid signer");let s=se(e,n),i=await this.configManager.getSignerAddress(e);return{code:0,data:await s.read.balanceOf([t||i])}}async updateAndWithdraw(e,t,n,s,i){try{let p=await(await lt(i)).write.updateAndWithdraw([e,t,n,s]);return{code:0,data:await c(i).waitForTransactionReceipt({hash:p})}}catch(r){return{code:-1,message:r.message}}}async deposit({amount:e,tokenAddress:t,chainId:n}){let s=this.configManager.hasSigner()?await this.configManager.getSignerAddress(n):"",i=P(n);try{if(await this.utils.needsApproval(s,n,t,e,i.Account)){let o=await this.utils.approveAuthorization({chainId:n,quoteAddress:t,amount:vs.toString(),spenderAddress:i.Account});if(o.code!==0)throw new Error(o.message)}let d=await(await lt(n)).write.deposit([s,t,e]);return{code:0,data:await c(n).waitForTransactionReceipt({hash:d})}}catch(r){return{code:-1,message:r.message}}}async getAvailableMarginBalance({poolId:e,chainId:t,address:n}){try{let s=await this.getAccountInfo(t,n,e);if(s.code!==0)throw new x("REQUEST_FAILED","Failed to get account info");let i=await this.client.appeal.getAppealStatus(e,t,n),r=s.data,p=BigInt(r?.quoteProfit??0),d=BigInt(r?.freeMargin??0),u=BigInt(r?.lockedMargin??0),o=i?.code===0?i.data:null,m=o?.status===1?BigInt(o?.lockedMargin??0):0n;return{code:0,data:d+p-u-m}}catch(s){return{code:-1,message:s.message}}}async getAccountInfo(e,t,n){let s=await me(e);try{return{code:0,data:await s.read.getAccountInfo([n,t])}}catch(i){return{code:-1,message:i.message}}}async getAccountVipInfo(e,t){let n=this.configManager.getConfig(),s=de(e,n.brokerAddress),r=await c(e).getBlock({blockTag:"latest"}),p=Number(r?.timestamp??BigInt(oa().unix()))+300,d=await this.configManager.getAccessToken()??"";try{let u=await this.client.api.getCurrentEpoch({address:t,accessToken:d,broker:n.brokerAddress});if(u.code!==9200)throw new x("REQUEST_FAILED",u.msg??"Failed to get current epoch");let o=await s.read.userFeeData([u?.data??0,t]),m;try{m=await this.withRetry(()=>s.read.userNonces([t]))}catch{m=0n}return{code:0,data:{...o,nonce:m.toString(),deadline:p}}}catch(u){return{code:-1,message:u.message}}}async getAccountVipInfoByBackend(e,t,n,s){let i=await this.configManager.getAccessToken()??"";try{let r=await this.client.api.getAccountVipInfo({address:e,accessToken:i,chainId:t,deadline:n,nonce:s});if(r.code!==9200)throw new x("REQUEST_FAILED",r.msg??"Failed to get account vip info");return{code:0,data:r.data}}catch(r){return{code:-1,message:r.message}}}async setUserFeeData(e,t,n,s,i){let r=this.configManager.getConfig();if(n<oa().unix())throw new x("REQUEST_FAILED","Invalid deadline, please try again");let p={user:e,nonce:s.nonce,deadline:n,feeData:{tier:s.tier,referrer:s.referrer||Es,totalReferralRebatePct:s.totalReferralRebatePct,referrerRebatePct:s.referrerRebatePct},signature:i};try{let d=await L(t,r.brokerAddress),u=await d.read.userNonces([e]);if(parseInt(u.toString())+1!==parseInt(s.nonce.toString()))throw new x("REQUEST_FAILED","Invalid nonce, please try again");let o=await d.write.setUserFeeData([p]);return{code:0,data:await c(t).waitForTransactionReceipt({hash:o})}}catch(d){return{code:-1,message:d.message}}}};function ua(a,e){return`${encodeURIComponent(a)}=${encodeURIComponent(typeof e=="number"?e:`${e}`)}`}function ks(a,e){return ua(e,a[e])}function Ss(a,e){return a[e].map(n=>ua(e,n)).join("&")}function Ms(a){let e=a||{};return Object.keys(e).filter(n=>typeof e[n]<"u").map(n=>Array.isArray(e[n])?Ss(e,n):ks(e,n)).join("&")}function Nt(a){let e=Ms(a);return e?`?${e}`:""}import{merge as $e}from"lodash-es";var He=class{constructor(e){this.configManager=e}getHost(){let{isTestnet:e,isBetaMode:t}=this.configManager.getConfig();return t?"https://api-beta.myx.finance":e?"https://api-test.myx.cash":"https://api.myx.finance"}async buildAuthParams(){let e=this.configManager.getConfig();if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER");let t=await this.configManager.getAccessToken()??"",n=await this.configManager.getSignerAddress(e.chainId);if(!n)throw new x("INVALID_SIGNER");return{headers:{myx_openapi_access_token:t,myx_openapi_account:n}}}buildRequestPath(e){return e.startsWith("http")?e:this.getHost()+e}async get(e,t,{auth:n=!1,...s}={}){let i=n?await this.buildAuthParams():{};return h.get(this.buildRequestPath(e),t,$e(i,s))}async post(e,t,{auth:n=!1,...s}={}){let i=n?await this.buildAuthParams():{};return h.post(this.buildRequestPath(e),t,$e(i,s))}async put(e,t,{auth:n=!1,...s}={}){let i=n?await this.buildAuthParams():{};return h.put(this.buildRequestPath(e),t,$e(i,s))}async delete(e,{auth:t=!1,...n}={}){let s=t?await this.buildAuthParams():{};return h.delete(this.buildRequestPath(e),$e(s,n))}};var Qe=class extends He{constructor(e,t){super(e),this.logger=t}async getTradeFlow({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/trade/flow`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getPoolSymbolAll(){return h.get(`${this.getHost()}/openapi/gateway/scan/pools`)}async fetchForwarderGetApi(e){return await h.get(`${this.getHost()}/v2/agent/forwarder/get${Nt(e)}`)}async getPoolList(){return h.get(`${this.getHost()}/openapi/gateway/scan/market/list`)}async forwarderTxApi(e,t){return h.post(`${this.getHost()}/v2/agent/forwarder/tx-v2`,e,{headers:{"myx-chain-id":t.toString()}})}async getOraclePrice(e,t=[]){if(t.length)return h.get(`${this.getHost()}/openapi/gateway/quote/price/oracles`,{chainId:e,poolIds:t.join(",")});throw new Error("Invalid pool id")}async getPoolDetail(e,t){return await h.get(`${this.getHost()}/openapi/gateway/scan/market/info?chainId=${e}&poolId=${t}`)}async getPoolLevelConfig({poolId:e,chainId:t}){return h.get(`${this.getHost()}/openapi/gateway/risk/market_pool/level_config${Nt({poolId:e,chainId:t})}`)}async getPositions({accessToken:e,address:t,positionId:n}){return await h.get(`${this.getHost()}/openapi/gateway/scan/position/open`,{positionId:n},{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getOrders(e,t){return await h.get(`${this.getHost()}/openapi/gateway/scan/order/open`,void 0,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getPoolOpenOrders(e,t,n){return await h.get(`${this.getHost()}/openapi/gateway/scan/market/pool-order/open?chainId=${n}`,void 0,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getKlineData({chainId:e,poolId:t,endTime:n,limit:s,interval:i}){return h.get(`${this.getHost()}/openapi/gateway/quote/candles`,{chainId:e,poolId:t,endTime:n,limit:s,interval:i})}async getKlineLatestBar(e){return h.get(`${this.getHost()}/openapi/gateway/quote/candle/latest`,e)}async getTickerData({chainId:e,poolIds:t}){return h.get(`${this.getHost()}/openapi/gateway/quote/candle/tickers`,{chainId:e,poolIds:t.join(",")})}async getAllTickers(){return h.get(`${this.getHost()}/v2/mx-gateway/quote/candle/all_tickers`)}async searchMarketAuth({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/ac-search`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async searchMarket({...e}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/search`,e)}async addFavorite({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/add-favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async removeFavorite({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/cancel-favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getFavoritesList({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getBaseDetail({...e}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/base-details`,e)}async getMarketDetail({...e}){return h.get(`${this.getHost()}/openapi/gateway/scan/market/detail`,e)}async getHistoryOrders({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/order/closed`,n,{headers:{myx_openapi_account:t,myx_openapi_access_token:e}})}async getPositionHistory({accessToken:e,address:t,...n}){return h.get(`${this.getHost()}/openapi/gateway/scan/position/closed`,n,{headers:{myx_openapi_account:t,myx_openapi_access_token:e}})}async getMarketList(){return h.get(`${this.getHost()}/openapi/gateway/scan/market`)}async getAccountVipInfo({address:e,accessToken:t,chainId:n,deadline:s,nonce:i}){return h.get(`${this.getHost()}/openapi/gateway/vip/trade_config`,{chainId:n,deadline:s,nonce:i},{headers:{myx_openapi_account:e,myx_openapi_access_token:t}})}async getAppealList(e){return this.get("/openapi/gateway/scan/dispute/list",e,{auth:!0})}async getAppealDetail(e){return this.get("/openapi/gateway/scan/dispute/details",e,{auth:!0})}async uploadAppealEvidence(e){return this.get("/openapi/gateway/scan/dispute/upload/evidence",e,{auth:!0})}async getAppealReconsiderationList(e){return this.get("/openapi/gateway/scan/dispute/appeal/list",e,{auth:!0})}async getAppealReconsiderationDetail(e){return this.get("/openapi/gateway/scan/dispute/appeal/details",e,{auth:!0})}async getAppealReimbursementList(e){return this.get("/openapi/gateway/scan/reimbursement/list",e,{auth:!0})}async getAppealNodeVoteList(e){return this.get("/openapi/gateway/scan/node/vote-list",e)}async getAppealNodeVoteDetails(e){return this.get("/openapi/gateway/scan/node/vote-details",e)}async getIsVoteNode(e){return this.get("/openapi/gateway/scan/node/vote-node-check",e)}async postVoteSignature(e){return this.get("/openapi/gateway/scan/node/vote",e,{auth:!0})}async getPedingVoteCount(){return this.get("/openapi/gateway/scan/node/pending-vote-total",{},{auth:!0})}async getMyAppealCount(){return this.get("/openapi/gateway/scan/processing-total",{},{auth:!0})}async getWarmholeSign(e){return this.get("/openapi/gateway/scan/get-warmhole-sign",e,{auth:!0})}async getDisputeTotalCount(){return this.get("/openapi/gateway/scan/dispute/dispute-total",{},{auth:!0})}async getAppealTotalCount(){return this.get("/openapi/gateway/scan/dispute/appeal-total",{},{auth:!0})}async getReimbursementTotalCount(){return this.get("/openapi/gateway/scan/dispute/reimbursement-total",{},{auth:!0})}async getCurrentEpoch({address:e,accessToken:t,broker:n}){return h.get(`${this.getHost()}/openapi/gateway/scan/get-current-epoch`,{broker:n},{headers:{myx_openapi_account:e,myx_openapi_access_token:t}})}async getPoolAppealStatus({poolId:e,chainId:t,address:n,accessToken:s}){return h.get(`${this.getHost()}/openapi/gateway/scan/pool-id-dispute-state?poolId=${e}&chainId=${t}`,{},{headers:{myx_openapi_account:n,myx_openapi_access_token:s}})}};import{hexToBytes as Ds,toHex as ma,encodeFunctionData as Os,maxUint256 as _t}from"viem";import Fs from"dayjs";var da=async a=>{try{let e=await a.read.eip712Domain();return{name:e[1],version:e[2],chainId:BigInt(e[3]),verifyingContract:e[4]}}catch(e){throw new Error(`Error fetching EIP712 domain: ${e}`)}};var Ns={ForwardRequest:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"gas",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint48"},{name:"data",type:"bytes"}]},_s=2;function Bs(a){let e=Ds(a);if(e.length<65)throw new Error("Invalid signature length");let t=ma(e.slice(0,32)),n=ma(e.slice(32,64));return{v:e[64],r:t,s:n}}async function Ls(a,e,t,n,s,i,r,p){let d=se(e,t),u=await da(d),[o]=await a.getAddresses();if(!o)throw new x("INVALID_SIGNER","No account for signPermit");let m={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},f={owner:n,spender:s,value:i,nonce:r,deadline:p},y=await a.signTypedData({account:o,domain:{...u,chainId:u.chainId},types:m,primaryType:"Permit",message:f});return Bs(y)}var Ke=class{constructor(e,t,n,s,i){this.configManager=e,this.logger=t,this.utils=n,this.account=s,this.api=i}async onCheckRelayer(e,t,n,s){let r=await(await le(n)).read.isUserRelayerEnabled([e,t]),p=await this.utils.needsApproval(e,n,s,_t.toString(),P(n).TRADING_ROUTER);return r&&!p}async getUSDPermitParams(e,t,n){if(!this.configManager.hasSigner())throw new x("INVALID_SIGNER","Signer is required for permit");let s=await M(t),i=P(t),[r]=await s.getAddresses();if(!r)throw new x("INVALID_SIGNER","No account");let p=se(t,n);try{let d=await p.read.nonces([r]),u=await Ls(s,t,n,r,i.TRADING_ROUTER,_t,d,e);return[{token:n,owner:r,spender:i.TRADING_ROUTER,value:_t.toString(),deadline:e.toString(),v:u.v,r:u.r,s:u.s}]}catch{throw new x("INVALID_PRIVATE_KEY","Invalid private key generated")}}async forwarderTx({from:e,to:t,value:n,gas:s,deadline:i,data:r,nonce:p,forwardFeeToken:d},u,o){let f=await(await le(u)).read.eip712Domain(),y={name:f[1],version:f[2],chainId:f[3],verifyingContract:f[4]},g=o??await M(u),[l]=await g.getAddresses();if(!l)throw new x("INVALID_SIGNER","Missing signer for forwarderTx");let A=await g.signTypedData({account:l,domain:y,types:Ns,primaryType:"ForwardRequest",message:{from:e,to:t,value:BigInt(n),gas:BigInt(s),nonce:BigInt(p),deadline:BigInt(i),data:r}});return await this.api.forwarderTxApi({from:e,to:t,value:n,gas:s,nonce:p,data:r,deadline:i,signature:A,forwardFeeToken:d},u)}async authorizeSeamlessAccount({approve:e,seamlessAddress:t,chainId:n,forwardFeeToken:s}){let i=this.configManager.hasSigner()?await this.configManager.getSignerAddress(n):"";if(e){let y=(await this.account.getWalletQuoteTokenBalance({chainId:n,address:i,tokenAddress:s})).data,l=await(await ee(n)).read.getForwardFeeByToken([s]),A=BigInt(l)*BigInt(_s);if(A>0&&A>BigInt(y))throw this.logger.debug("Insufficient balance"),new x("INSUFFICIENT_BALANCE","Insufficient balance")}let r=Fs().add(60,"minute").unix(),p=[];if(e)try{p=await this.getUSDPermitParams(r,n,s)}catch(f){this.logger.warn("Failed to get USD permit params, proceeding without permit:",f),p=[]}let d=await le(n,1),u=await(await le(n)).read.nonces([i]),o=Os({abi:Ie,functionName:"permitAndApproveForwarder",args:[t,e,p]}),m=await this.forwarderTx({from:i,to:d.address,value:"0",gas:"800000",nonce:u.toString(),data:o,deadline:r,forwardFeeToken:s},n);if(m.data?.txHash){for(let g=0;g<5;g++)try{if((await this.api.fetchForwarderGetApi({requestId:m.data.requestId})).data?.status===9)return{code:0,data:{seamlessAccount:t,authorized:e}};g<4&&await new Promise(A=>setTimeout(A,1e3))}catch(l){this.logger.error("Poll transaction from chain error:",l),g<4&&await new Promise(A=>setTimeout(A,1e3))}return{code:-1,data:null,message:"Transaction confirmation timeout, please check later"}}else return{code:-1,data:null,message:"Your request timed out, please try again"}}async getOriginSeamlessAccount(e,t){return{code:0,data:{masterAddress:await(await le(t)).read.originAccount([e])}}}};import{decodeEventLog as Us}from"viem";var be=class{constructor(e){this.client=e}getConfig(){return this.client.getConfigManager()?.getConfig()}getAddressConfig(){let t=this.getConfig()?.chainId;if(!t||!Te(t))throw new x("INVALID_CHAIN_ID","Invalid chain id");return P(t)}getBrokerContract(){let e=this.getConfig();if(!e?.brokerAddress)throw new x("INVALID_BROKER_ADDRESS","Invalid broker address");return de(e.chainId,e.brokerAddress)}get config(){return this.getConfig()}};var Je=class extends be{constructor(e,t){super(e),this.configManager=t}getDisputeCourtContract(e=!0){return gn(this.config.chainId,e?1:0)}getReimbursementContract(e=!0){return fn(this.config.chainId,e?1:0)}getCaseIdFromReceiptLogs(e,t){let n=t==="DisputeFiled"?"caseId":"appealCaseId";for(let s of e.logs)try{let i=Us({abi:xe,data:s.data,topics:s.topics});if(i.eventName===t&&i.args&&n in i.args)return i.args[n]}catch{continue}return null}async submitAppeal(e,t,n){let s=this.configManager.hasSigner()?await this.configManager.getSignerAddress(this.config.chainId):"",i=await this.client.utils.needsApproval(s,this.config.chainId,t,n,this.getAddressConfig().DISPUTE_COURT);this.client.logger.debug("need-approve",i),i&&await this.client.utils.approveAuthorization({chainId:this.config.chainId,quoteAddress:t,spenderAddress:this.getAddressConfig().DISPUTE_COURT});let r=await this.getDisputeCourtContract(),p=await this.client.utils.buildUpdatePriceParams(e,this.config.chainId),d=BigInt(p[0].value.toString()||"1"),u=await r.estimateGas.fileDispute([p,e,t],{value:d}),o=await this.client.utils.getGasLimitByRatio(u),m=await this.client.utils.getGasPriceByRatio(),f=await r.write.fileDispute([p,e,t],{value:d,gasLimit:o,gasPrice:m}),y=await c(this.config.chainId).waitForTransactionReceipt({hash:f}),g=this.getCaseIdFromReceiptLogs(y,"DisputeFiled");if(g==null)throw new x("TRANSACTION_FAILED","DisputeFiledLog not found");return{transaction:y,caseId:g}}async voteForAppeal({caseId:e,validator:t,isFor:n,deadline:s,v:i,r,s:p}){let d=await this.getDisputeCourtContract(),u=await d.estimateGas.vote([e,t,n?1:0,s,i,r,p]),o=await this.client.utils.getGasLimitByRatio(u),m=await this.client.utils.getGasPriceByRatio(),f=await d.write.vote([e,t,n?1:0,s,i,r,p],{gasLimit:o,gasPrice:m});return await c(this.config.chainId).waitForTransactionReceipt({hash:f})}async claimAppealMargin(e){let t=await this.getDisputeCourtContract(),n=await t.estimateGas.claimBond([e]),s=await this.client.utils.getGasLimitByRatio(n),i=await this.client.utils.getGasPriceByRatio(),r=await t.write.claimBond([e],{gasLimit:s,gasPrice:i});return c(this.config.chainId).waitForTransactionReceipt({hash:r})}async claimReimbursement(e,t,n,s){let i=await this.getReimbursementContract(),r=await i.estimateGas.claimReimbursement([e,t,n,s]),p=await this.client.utils.getGasLimitByRatio(r),d=await this.client.utils.getGasPriceByRatio(),u=await i.write.claimReimbursement([e,t,n,s],{gasLimit:p,gasPrice:d});return c(this.config.chainId).waitForTransactionReceipt({hash:u})}async getDisputeConfiguration(){return(await this.getDisputeCourtContract(!1)).read.getDisputeConfiguration()}async submitAppealByVoteNode(e,t,n){let s=await this.getDisputeCourtContract(),i=await this.client.utils.getGasPriceByRatio(),r=await this.client.utils.getGasLimitByRatio(await s.estimateGas.fileDisputeFromStaker([e,t,n])),p=await s.write.fileDisputeFromStaker([e,t,n],{gasLimit:r,gasPrice:i}),d=await c(this.config.chainId).waitForTransactionReceipt({hash:p}),u=this.getCaseIdFromReceiptLogs(d,"DisputeFiled");if(u==null)throw new x("TRANSACTION_FAILED","DisputeFiledLog not found");return{tx:d,caseId:u}}async appealReconsideration(e,t,n){let s=await this.getDisputeCourtContract(),i=this.configManager.hasSigner()?await this.configManager.getSignerAddress(this.config.chainId):"",r=this.getAddressConfig().DISPUTE_COURT;if(await this.client.utils.needsApproval(i,this.config.chainId,t,n,r)){let g=await this.client.utils.approveAuthorization({chainId:this.config.chainId,quoteAddress:t,spenderAddress:r});if(g.code!==0)throw new x("TRANSACTION_FAILED",g.message)}let d=await s.estimateGas.appeal([e]),u=await this.client.utils.getGasLimitByRatio(d),o=await this.client.utils.getGasPriceByRatio(),m=await s.write.appeal([e],{gasLimit:u,gasPrice:o}),f=await c(this.config.chainId).waitForTransactionReceipt({hash:m}),y=this.getCaseIdFromReceiptLogs(f,"AppealFiled");if(y==null)throw new x("TRANSACTION_FAILED","AppealFiledLog not found");return{tx:f,appealCaseId:y,caseId:e}}async getAppealList(e){return this.client.api.getAppealList(e)}async getAppealDetail(e){return this.client.api.getAppealDetail(e)}async uploadAppealEvidence(e){return this.client.api.uploadAppealEvidence(e)}async getAppealReconsiderationList(e){return this.client.api.getAppealReconsiderationList(e)}async getAppealReconsiderationDetail(e){return this.client.api.getAppealReconsiderationDetail(e)}async getAppealReimbursementList(e){return this.client.api.getAppealReimbursementList(e)}async getAppealNodeVoteList(e){return this.client.api.getAppealNodeVoteList(e)}async getAppealNodeVoteDetail(e){return this.client.api.getAppealNodeVoteDetails(e)}async getIsVoteNode(e){return this.client.api.getIsVoteNode(e)}async postVoteSignature(e){return this.client.api.postVoteSignature(e)}async getPedingVoteCount(){return this.client.api.getPedingVoteCount()}async getMyAppealCount(){return this.client.api.getMyAppealCount()}async getWarmholeSign(e){return this.client.api.getWarmholeSign(e)}async getDisputeTotalCount(){return this.client.api.getDisputeTotalCount()}async getAppealTotalCount(){return this.client.api.getAppealTotalCount()}async getReimbursementTotalCount(){return this.client.api.getReimbursementTotalCount()}async getAppealStatus(e,t,n){return this.client.api.getPoolAppealStatus({poolId:e,chainId:t,address:n,accessToken:await this.configManager.getAccessToken()??""})}};var je=class extends be{constructor(e){super(e)}async claimRebate(e){let t=this.getConfig(),n=await L(this.config.chainId,t.brokerAddress),s=await n.estimateGas.claimRebate([e]),i=await this.client.utils.getGasLimitByRatio(s),r=await this.client.utils.getGasPriceByRatio(),p=await n.write.claimRebate([e],{gasPrice:r,gasLimit:i});return c(this.config.chainId).waitForTransactionReceipt({hash:p})}};var qs=(d=>(d[d.UnderReview=1]="UnderReview",d[d.InitialVote=2]="InitialVote",d[d.PublicNotice=3]="PublicNotice",d[d.UnderReconsideration=4]="UnderReconsideration",d[d.Won=5]="Won",d[d.Failed=6]="Failed",d[d.PlatformRuling=7]="PlatformRuling",d[d.PlatformRevoked=8]="PlatformRevoked",d))(qs||{}),Gs=(o=>(o[o.InitialVoting=1]="InitialVoting",o[o.PublicNotice=2]="PublicNotice",o[o.UnderReconsideration=3]="UnderReconsideration",o[o.Won=5]="Won",o[o.Failed=4]="Failed",o[o.PlatformRuling=6]="PlatformRuling",o[o.PlatformRevoked=7]="PlatformRevoked",o[o.ReconsiderationVoting=8]="ReconsiderationVoting",o[o.AppealRevert=9]="AppealRevert",o[o.NotAppealFailed=10]="NotAppealFailed",o))(Gs||{}),Ws=(s=>(s[s.UnderReview=1]="UnderReview",s[s.PublicNotice=2]="PublicNotice",s[s.UnderReconsideration=3]="UnderReconsideration",s[s.Completed=4]="Completed",s))(Ws||{}),zs=(t=>(t[t.ElectionNode=0]="ElectionNode",t[t.OfficialNode=1]="OfficialNode",t))(zs||{}),Vs=(t=>(t[t.Reject=0]="Reject",t[t.Support=1]="Support",t))(Vs||{}),$s=(t=>(t[t.UnClaimed=0]="UnClaimed",t[t.Claimed=1]="Claimed",t))($s||{}),Hs=(t=>(t[t.NotVoted=0]="NotVoted",t[t.Voted=1]="Voted",t))(Hs||{}),Qs=(t=>(t[t.Appeal=1]="Appeal",t[t.Reconsideration=2]="Reconsideration",t))(Qs||{}),Ks=(n=>(n[n.NoVote=0]="NoVote",n[n.Supported=1]="Supported",n[n.Rejected=2]="Rejected",n))(Ks||{}),Js=(t=>(t[t.Yes=1]="Yes",t[t.No=0]="No",t))(Js||{}),pa=(t=>(t[t.None=0]="None",t[t.isAppealing=1]="isAppealing",t))(pa||{});var Bt=class{getConfigManager(){return this.configManager}constructor(e){this.configManager=new Le(e),this.logger=new re({logLevel:e.logLevel});let t=Z.getInstance();t.setConfigManager(this.configManager),ve(this.configManager),t.getMarkets().then(),this.utils=new ze(this.configManager,this.logger),this.api=new Qe(this.configManager,this.logger),this.account=new Ve(this.configManager,this.logger,this.utils,this),this.seamless=new Ke(this.configManager,this.logger,this.utils,this.account,this.api),this.markets=new Ue(this.configManager,this.utils,this.api),this.position=new qe(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.order=new We(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.subscription=new _e(this.configManager,this.logger),this.appeal=new Je(this,this.configManager),this.referrals=new je(this)}auth(e){this.configManager.auth(e)}updateClientChainId(e,t){this.configManager.updateClientChainId(e,t)}close(){this.configManager.clear(),this.subscription.disconnect()}async getAccessToken(){return await this.configManager.getAccessToken()}async refreshAccessToken(e=!1){return await this.configManager.refreshAccessToken(e)}};var kf="1.0.5";export{Qs as AppealCaseTypeEnum,$s as AppealClaimStatusEnum,Ks as AppealNodeStateEnum,Hs as AppealNodeVotedStateEnum,Gs as AppealReconsiderationType,Ws as AppealStage,pa as AppealStatus,qs as AppealType,_ as COMMON_LP_AMOUNT_DECIMALS,E as COMMON_PRICE_DECIMALS,z as ChainId,$a as CloseTypeEnum,Uc as Direction,Wa as DirectionEnum,Oa as ErrorCode,Va as ExecTypeEnum,Qa as ForwarderGetStatus,pn as HttpKlineIntervalEnum,Js as IsVoteNodeEnum,re as Logger,_a as MarketCapType,he as MarketPoolState,Fa as MarketType,Z as MxSDK,Bt as MyxClient,zs as NodeTypeEnum,Ua as OperationEnum,pe as OperationType,on as OracleType,Gc as OrderStatus,za as OrderStatusEnum,Ge as OrderType,La as OrderTypeEnum,kf as SDK_VERSION,Ba as SearchSecondTypeEnum,Na as SearchTypeEnum,qc as TimeInForce,Ha as TradeFlowAccountTypeEnum,qa as TradeFlowTypeEnum,Lc as TriggerType,Ga as TriggerTypeEnum,Vs as VoteTypeEnum,An as approve,Et as base,te as bigintAmountSlipperCalculator,v as bigintTradingGasPriceWithRatio,T as bigintTradingGasToRatioCalculator,Ru as formatUnits,Dt as fromViemWalletClient,hn as getAllowanceApproved,xn as getBalanceOf,yr as getBaseDetail,J as getBaseUrlByEnv,fr as getMarketDetail,mn as getMarketList,j as getOraclePrice,un as getPoolDetail,ur as getPoolList,dn as getPoolOpenOrders,B as getPriceData,fe as getPricesData,c as getPublicClient,Se as getSdkLogSink,cr as getTickerData,fu as getTokenInfo,M as getWalletClient,Ka as getWalletProvider,Mt as market,Be as normalizeSigner,wu as parseUnits,ds as pool,St as quote,I as sdkError,In as sdkLog,ye as sdkWarn,ve as setConfigManagerForViem,bn as setSdkLogSink};
2
2
  //# sourceMappingURL=index.mjs.map