@myx-trade/sdk 0.1.267-beta.78 → 0.1.267-beta.79
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.js +43 -2
- package/dist/index.mjs +43 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"use strict";var is=Object.create;var Ge=Object.defineProperty;var rs=Object.getOwnPropertyDescriptor;var os=Object.getOwnPropertyNames;var ps=Object.getPrototypeOf,us=Object.prototype.hasOwnProperty;var Qt=s=>{throw TypeError(s)};var ke=(s,e)=>{for(var t in e)Ge(s,t,{get:e[t],enumerable:!0})},Kt=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of os(e))!us.call(s,a)&&a!==t&&Ge(s,a,{get:()=>e[a],enumerable:!(n=rs(e,a))||n.enumerable});return s};var ne=(s,e,t)=>(t=s!=null?is(ps(s)):{},Kt(e||!s||!s.__esModule?Ge(t,"default",{value:s,enumerable:!0}):t,s)),ds=s=>Kt(Ge({},"__esModule",{value:!0}),s);var $t=(s,e,t)=>e.has(s)||Qt("Cannot "+t);var Jt=(s,e,t)=>($t(s,e,"read from private field"),t?t.call(s):e.get(s)),jt=(s,e,t)=>e.has(s)?Qt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),Yt=(s,e,t,n)=>($t(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);var ii={};ke(ii,{AppealCaseTypeEnum:()=>ts,AppealClaimStatusEnum:()=>Za,AppealNodeStateEnum:()=>ns,AppealNodeVotedStateEnum:()=>es,AppealReconsiderationType:()=>Ja,AppealStage:()=>ja,AppealType:()=>$a,COMMON_LP_AMOUNT_DECIMALS:()=>U,COMMON_PRICE_DECIMALS:()=>S,ChainId:()=>K,CloseTypeEnum:()=>Rn,Direction:()=>Vs,DirectionEnum:()=>wn,ErrorCode:()=>mn,ExecTypeEnum:()=>Pn,ForwarderGetStatus:()=>vn,HttpKlineIntervalEnum:()=>Pt,IsVoteNodeEnum:()=>as,MarketCapType:()=>gn,MarketPoolState:()=>fe,MarketType:()=>yn,MxSDK:()=>ue,MyxClient:()=>wt,NodeTypeEnum:()=>Ya,OperationEnum:()=>hn,OperationType:()=>ye,OracleType:()=>Ct,OrderStatus:()=>Qs,OrderStatusEnum:()=>Cn,OrderType:()=>Le,OrderTypeEnum:()=>In,SearchSecondTypeEnum:()=>bn,SearchTypeEnum:()=>fn,TimeInForce:()=>Hs,TradeFlowAccountTypeEnum:()=>Tn,TradeFlowTypeEnum:()=>xn,TriggerType:()=>Ws,TriggerTypeEnum:()=>An,VoteTypeEnum:()=>Xa,approve:()=>Mt,base:()=>_t,bigintAmountSlipperCalculator:()=>te,bigintTradingGasPriceWithRatio:()=>R,bigintTradingGasToRatioCalculator:()=>P,formatUnits:()=>at.formatUnits,getAllowanceApproved:()=>St,getBalanceOf:()=>kt,getBaseDetail:()=>As,getBaseUrlByEnv:()=>ae,getMarketDetail:()=>ws,getMarketList:()=>vt,getOraclePrice:()=>se,getPoolDetail:()=>Rt,getPoolList:()=>hs,getPoolOpenOrders:()=>Tt,getPriceData:()=>G,getPricesData:()=>he,getTickerData:()=>xs,getTokenInfo:()=>Us,market:()=>zt,parseUnits:()=>at.parseUnits,pool:()=>qt,quote:()=>Gt});module.exports=ds(ii);var _t={};ke(_t,{claimBasePoolRebate:()=>Yn,claimBasePoolRebates:()=>Xn,deposit:()=>ta,getLpPrice:()=>oa,getRewards:()=>ia,previewUserWithdrawData:()=>Zn,withdraw:()=>aa,withdrawableLpAmount:()=>na});var Xt=[{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:[]}];var ie=require("ethers");var tn=require("ethers"),nn=require("lodash-es"),Zt="0x0000000000000000000000000000000000000000",Se=class Se{constructor(e){((0,nn.isUndefined)(e)||Number(e)===0)&&(e=Zt.toString()),this._addr=(0,tn.getAddress)(e)}toString(){return this._addr.toString()}format(){return en(this._addr.toString(),!0)}unmaskFormat(){return en(this._addr.toString(),!1)}static from(e){return new Se(e)}isEqualTo(e){return!!e&&this.toString().toLowerCase()===e.toString().toLowerCase()}};Se.ZERO_ADDRESS=new Se(Zt);var qe=Se,en=(s,e=!0)=>e?`${s.slice(0,6).toLowerCase()}...${s.slice(-4).toLowerCase()}`:s.toLowerCase();var K=(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))(K||{});var ls=[421614,59141,97,42161,59144,56];function ze(s){return!!s&&ls.includes(s)}var j=10;var H={42161:130n,421614:130n,59144:130n,59141:130n,56:150n,97:150n};var an={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)*j,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var sn={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)*j,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var rn={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)*j,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var on={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)*j,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var pn={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)*j,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var un={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)*j,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var C={59141:an.chainInfo,421614:sn.chainInfo,97:rn.chainInfo,59144:on.chainInfo,42161:pn.chainInfo,56:un.chainInfo};function dn(s){let e=C[s];if(!e)throw new Error(`Could not find information with chain id ${s}`);return e}var Ve=require("@ethersproject/providers"),ms=6e4,ys=1;function fs(s){return new Promise(e=>setTimeout(e,s))}function gs(s){s.length===0&&console.error("no networks provided");let e;for(let t=0;t<s.length;t++){let n=s[t];if(n||console.error("network not defined"),!e){e=n;continue}e.name.toLowerCase()===n.name.toLowerCase()&&e.chainId===n.chainId&&(e.ensAddress?.toLowerCase()===n.ensAddress?.toLowerCase()||e.ensAddress==null&&n.ensAddress==null)||console.error("provider mismatch")}return e||console.error("no networks defined"),e}var We=class extends Ve.BaseProvider{constructor(t,n,a){super(n);this.currentProviderIndex=0;this.firstRotationTimestamp=0;this.maxRetries=0;this.retries=0;this.lastError="";this.providers=t.map(i=>new Ve.StaticJsonRpcProvider(i,n)),this.maxRetries=a?.maxRetries||ys,this.fallForwardDelay=a?.fallFowardDelay||ms}async fallForwardRotation(){let n=Date.now()-this.firstRotationTimestamp;n<this.fallForwardDelay&&(await fs(this.fallForwardDelay-n),this.currentProviderIndex=0)}rotateUrl(t){if(t===this.currentProviderIndex)if(this.currentProviderIndex===0)this.currentProviderIndex+=1,this.firstRotationTimestamp=Date.now(),this.fallForwardRotation();else if(this.currentProviderIndex===this.providers.length-1){if(this.retries+=1,this.retries>this.maxRetries)throw this.retries=0,new Error(`RotationProvider exceeded max number of retries. Last error: ${this.lastError}`);this.currentProviderIndex=0}else this.currentProviderIndex+=1}async detectNetwork(){let t=await Promise.all(this.providers.map(n=>n.getNetwork()));return gs(t)}async perform(t,n){let a=this.currentProviderIndex;try{return await this.providers[a].perform(t,n)}catch(i){return console.error(i.message),this.lastError=i.message,this.emit("debug",{action:"perform",provider:this.providers[a]}),await this.rotateUrl(a),this.perform(t,n)}}};var cn={name:"@myx-trade/sdk",version:"0.1.267-beta.78",private:!1,publishConfig:{access:"public"},description:"MYX Trade SDK for trading operations",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{import:"./dist/index.mjs",require:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist"],scripts:{build:"tsup src/index.ts --format cjs,esm --dts --minify",dev:"tsup src/index.ts --format cjs,esm --dts --watch",clean:"rm -rf dist",prebuild:"npm run clean","gen:abi":"typechain --target ethers-v6 --out-dir ./src/abi/types './src/abi/**/*.json'",prepublishOnly:"npm run build",prepare:"pnpm gen:abi","custom-publish":"tsx scripts/customPublish.ts","type-check":"echo 'Skipping type-check for @myx-trade/sdk'"},keywords:["trading","sdk","myx","finance"],author:"",license:"ISC",packageManager:"pnpm@10.12.4",devDependencies:{"@typechain/ethers-v6":"^0.5.1","@types/crypto-js":"^4.2.2","@types/lodash-es":"^4.17.12","@types/node":"^24.3.0","@types/react":"^18.2.0","@types/react-dom":"^18.2.0","@vitejs/plugin-react":"^4.3.0",tsup:"^8.0.0",tsx:"^4.21.0",typechain:"^8.3.2",typescript:"^5.3.0"},dependencies:{"@ethersproject/bytes":"^5.8.0","@ethersproject/providers":"^5.8.0","@types/ws":"^8.18.1","crypto-js":"^4.2.0",dayjs:"^1.11.13",ethers:"^6.15.0","ethers-decode-error":"^2.1.3",inquirer:"^13.2.0","lodash-es":"^4.17.21",mitt:"^3.0.1","reconnecting-websocket":"^4.4.0",viem:"^2.36.0",wretch:"^2.11.0",ws:"^8.18.3"}};var ln=ne(require("wretch")),He=(0,ln.default)(),Is=(s,e)=>e?(e=JSON.parse(JSON.stringify(e)),s.includes("?")?s+"&"+new URLSearchParams(e).toString():s+"?"+new URLSearchParams(e).toString()):s,w={get:(s,e,t={})=>{let n=Is(s,e);return He.url(n).options(t).get().json()},post:(s,e,t={})=>He.url(s).options(t).post(e).json(),put:(s,e,t={})=>He.url(s).options(t).put(e).json(),delete:(s,e={})=>He.url(s).options(e).delete().json()};var mn=(d=>(d[d.SUCCESS=9200]="SUCCESS",d[d.SUCCESS_ORIGIN=0]="SUCCESS_ORIGIN",d[d.IDENTITY_VERIFICATION_FAILED=9401]="IDENTITY_VERIFICATION_FAILED",d[d.PERMISSION_DENIED=9403]="PERMISSION_DENIED",d[d.NOT_EXIST=9404]="NOT_EXIST",d[d.REQUEST_LIMIT=9429]="REQUEST_LIMIT",d[d.SERVICE_ERROR=9500]="SERVICE_ERROR",d[d.MISS_REQUESTED_PARAMETER=9900]="MISS_REQUESTED_PARAMETER",d[d.INVALID_PARAMETER=9901]="INVALID_PARAMETER",d.NETWORK_ERROR="ERR_NETWORK",d))(mn||{}),fe=(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))(fe||{}),Ct=(t=>(t[t.Chainlink=1]="Chainlink",t[t.Pyth=2]="Pyth",t))(Ct||{}),Pt=(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))(Pt||{}),yn=(n=>(n[n.Contract=1]="Contract",n[n.Cook=2]="Cook",n[n.Earn=3]="Earn",n))(yn||{}),fn=(a=>(a[a.All=0]="All",a[a.Contract=1]="Contract",a[a.Cook=2]="Cook",a[a.Earn=3]="Earn",a))(fn||{}),gn=(t=>(t[t.BlueChips=1]="BlueChips",t[t.Alpha=2]="Alpha",t))(gn||{}),bn=(n=>(n[n.BlueChips=1]="BlueChips",n[n.Alpha=2]="Alpha",n[n.Favorite=3]="Favorite",n))(bn||{});var In=(a=>(a[a.Market=0]="Market",a[a.Limit=1]="Limit",a[a.Stop=2]="Stop",a[a.Conditional=3]="Conditional",a))(In||{}),hn=(t=>(t[t.Increase=0]="Increase",t[t.Decrease=1]="Decrease",t))(hn||{}),xn=(c=>(c[c.Increase=0]="Increase",c[c.Decrease=1]="Decrease",c[c.AddMargin=2]="AddMargin",c[c.RemoveMargin=3]="RemoveMargin",c[c.CancelOrder=4]="CancelOrder",c[c.ADL=5]="ADL",c[c.Liquidation=6]="Liquidation",c[c.MarketClose=7]="MarketClose",c[c.EarlyClose=8]="EarlyClose",c[c.AddTPSL=9]="AddTPSL",c[c.SecurityDeposit=10]="SecurityDeposit",c[c.TransferToWallet=11]="TransferToWallet",c[c.MarginAccountDeposit=12]="MarginAccountDeposit",c[c.ReferralReward=13]="ReferralReward",c[c.ReferralRewardClaim=14]="ReferralRewardClaim",c))(xn||{}),An=(n=>(n[n.Unknown=0]="Unknown",n[n.GTE=1]="GTE",n[n.LTE=2]="LTE",n))(An||{}),wn=(t=>(t[t.Long=0]="Long",t[t.Short=1]="Short",t))(wn||{}),Cn=(a=>(a[a.Cancelled=1]="Cancelled",a[a.Expired=2]="Expired",a[a.Successful=9]="Successful",a[a.PartialFilled=8]="PartialFilled",a))(Cn||{}),Pn=(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))(Pn||{}),Rn=(d=>(d[d.Open=0]="Open",d[d.PartialClose=1]="PartialClose",d[d.FullClose=2]="FullClose",d[d.Liquidation=3]="Liquidation",d[d.EarlyClose=4]="EarlyClose",d[d.MarketClose=5]="MarketClose",d[d.ADL=6]="ADL",d[d.TP=7]="TP",d[d.SL=8]="SL",d[d.Increase=9]="Increase",d))(Rn||{}),Tn=(n=>(n[n.MarginAccount=1]="MarginAccount",n[n.WalletAccount=2]="WalletAccount",n[n.ReferralReward=3]="ReferralReward",n))(Tn||{});var vn=(a=>(a[a.EXECUTING=1]="EXECUTING",a[a.BROADCAST_FAILED=2]="BROADCAST_FAILED",a[a.TIMEOUT_CANCEL=3]="TIMEOUT_CANCEL",a[a.EXECUTED=9]="EXECUTED",a))(vn||{});var hs=async()=>w.get(`${ae()}/openapi/gateway/scan/market/list`);var ae=()=>{let{isTestnet:s,isBetaMode:e}=pe?.getConfigManager()?.getConfig()||{};return e?"https://api-beta.myx.finance":s?"https://api-test.myx.cash":"https://api.myx.finance"},se=async(s,e=[])=>e.length?w.get(`${ae()}/openapi/gateway/quote/price/oracles`,{chainId:s,poolIds:e.join(",")}):Promise.reject(new Error("Invalid pool id")),Rt=async(s,e)=>await w.get(`${ae()}/openapi/gateway/scan/market/info?chainId=${s}&poolId=${e}`),Tt=async(s,e,t)=>await w.get(`${ae()}/openapi/gateway/scan/market/pool-order/open?chainId=${t}`,void 0,{headers:{myx_openapi_access_token:s,myx_openapi_account:e}}),xs=async({chainId:s,poolIds:e},t)=>w.get(`${ae()}/openapi/gateway/quote/candle/tickers`,{chainId:s,poolIds:e.join(",")}),As=async({...s})=>w.get(`${ae()}/openapi/gateway/scan/market/base-details`,s),ws=async({...s})=>w.get(`${ae()}/openapi/gateway/scan/market/detail`,s),vt=async()=>w.get(`${ae()}/openapi/gateway/scan/market`);function B(s,e,t){if(qe.from(s).isEqualTo(ie.ZeroAddress))throw new Error(`Invalid 'address' parameter '${s}'.`);return new ie.Contract(s,e,t)}var E=s=>{let e=dn(s),t=[];if(e.privateJsonRPCUrl&&t.push(e.privateJsonRPCUrl),e.publicJsonRPCUrl.length>0&&e.publicJsonRPCUrl.map(n=>t.push(n)),t.length===0)throw new Error(`${s} has no jsonRPCUrl configured`);return t.length===1?new ie.JsonRpcProvider(t[0],s,{staticNetwork:!0}):new We(t,s)},Me,Et=class Et{constructor(){this.version=cn.version;jt(this,Me);console.log(this.version)}setConfigManager(e){Yt(this,Me,e)}getConfigManager(){return Jt(this,Me)}setProvider(e){this.provider=e}getProvider(){return this.provider}static getInstance(){return this._instance||(this._instance=new Et),this._instance}async getMarkets(){try{let t=(await vt())?.data||[];return this.Markets=t,t}catch(e){throw e}}};Me=new WeakMap;var ue=Et,Qe=ue.getInstance();typeof window<"u"?window.MxSDK=Qe:typeof globalThis<"u"&&(globalThis.MxSDK=Qe);var pe=Qe,Cs=async s=>{try{let e=Qe.getConfigManager()?.getConfig()?.walletClient,t=new ie.BrowserProvider(e?.transport);if(!t)throw new Error("missing provider");return t}catch(e){return console.error("Error getting wallet provider:",e),ie.ethers.getDefaultProvider("mainnet")}},W=async s=>(await Cs(s))?.getSigner?.();var En=[{type:"constructor",payable:!1,inputs:[]},{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:"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:"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:"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:"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:"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:"uint64",name:"oracleRefundFeeUsd"},{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:"uint16",name:"maxPriceDeviation"},{type:"uint8",name:"riskTier"},{type:"uint64",name:"windowCapUsd"}]}],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:"updatePoolPriceDeviations",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint16",name:"maxPriceDeviation"}]}],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:"updatePoolWindowCaps",constant:!1,payable:!1,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint64",name:"windowCapUsd"}]}],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 ge=[{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 kn=[{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 Sn=[{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 ee=[{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 Mn=[{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 be=[{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 Ke=[{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 $e=[{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:"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",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"}]},{type:"address",name:"masterAccount"}],outputs:[]},{type:"function",name:"executeBatch",constant:!1,stateMutability:"payable",payable:!0,inputs:[{type:"tuple[]",name:"requests",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",name:"masterAccount"},{type:"address",name:"refundReceiver"}],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 Dn=[{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 On=[{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 Fn={USDC:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",POOL_MANAGER:"0xf268D9FeD3Bd56fd9aBdb4FeEb993338613678A8",Account:"0x396a6aDb17903f4b0ED3EA55F18391C403fa3Bb4",POSITION_MANAGER:"0x89d1091Ef4aB71d688a86f3D92112715905d7B8A",ORDER_MANAGER:"0x5948bc0E0c72a7B7a90eb8f5a1951bDB0ef0f68D",PYTH:"0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",ERC20:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",LIQUIDITY_ROUTER:"0x5E16C0699de2Ee5D69a620AB38AE2c81A29a58df",BASE_POOL:"0xDb41D850e9b30fc0417F488D1aB64fdc1d0DdFdc",QUOTE_POOL:"0xF0784c1023C051Bf1D5b8470A896c536039B06B9",ORACLE:"0xb3C295769d86fc321bA70a7C43EAfa10322CC66F",EIP7702Delegation:"0xe3D34CbDfC221e064510Cfa82EFF99172651BeB9",MARKET_MANAGER:"0xB3EEc5C2eEc049b4eD4C528Dcd9a97680E3edFb7",DATA_PROVIDER:"0xeA2be692Da76Bf6851f3cBf9750075e10E9085cB",ORACLE_RESERVE:"0x247e3A9d6E9CF6D619c7D0A0eE11B7CD966FA3aa",FORWARDER:"0x065Adb8183c114c3a61d75c89051ecE6C1C9A6fB",TRADING_ROUTER:"0x6A2aF0be0629B424a6A7EfEf54a3b50a99bC1a29",REIMBURSEMENT:"0x2C294a480006703B1A4F6493eA3B1dAC7A84454b",DISPUTE_COURT:"0x09F56485B5FB01C6C27bB81f54605F4d55d7d10B"};var Nn={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 _n={USDC:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",POOL_MANAGER:"0x784808c123B778BacB2c08782837BC083e6C5cF0",Account:"0xB219526B2DC7Aa25Eb78A8Bd5e0AeaC9880f26Ca",POSITION_MANAGER:"0xca570536de1398d855507bA62c01B0dF3ecf8FE9",ORDER_MANAGER:"0x679859C80e58e5026018401bED798C574c844560",PYTH:"0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",ERC20:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",LIQUIDITY_ROUTER:"0xf1395643D77DD839E4b8d3Bb122fd0275Cf07631",BASE_POOL:"0x31b093BBADbb2A3Bcd7E433E8Ed5bcdD76fFAFFe",QUOTE_POOL:"0xFF8A6797E2063A7a4cd1468eB7cC0db9798C753f",ORACLE:"0x0074441b86da2aE6818304B586fCf619c68C4204",EIP7702Delegation:"0x7629731046b2498b4C00B8a2208e538E706E5bfc",MARKET_MANAGER:"0x170F95d91B27d8bc7afA85B06d8B129BA34f405F",DATA_PROVIDER:"0x8873C5828fe1A903221971817b17dc67903544d6",ORACLE_RESERVE:"0xDc9321c19b02cefe57fFB2C1F70014a478D06ddF",FORWARDER:"0x2AC73d767D2c3e44741410c3E41988a05bCf9C86",TRADING_ROUTER:"0x5976abbC616520968b12EeB4b11AFa8490281453",REIMBURSEMENT:"0x257BF8df1CF76762985F3cf19c7cd1D6Adb67Bc7",DISPUTE_COURT:"0x02495c66dfb2ECeF5ebb7339a997EBb7D73DFdbf"};var Bn={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 Ln={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 Un={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"};var Gn={USDC:"0x55d398326f99059fF775485246999027B3197955",POOL_MANAGER:"0x13F2130c2F3bfd612BBCBF35FB9E467dd32bAF3A",Account:"0xa32D0550F127fCFF0FA13D21523c5d4a2b86595D",POSITION_MANAGER:"0x93062Ec7Ef0aCf73c877A1d816A6CECc736d018e",ORDER_MANAGER:"0x9438d539e169b72FC2bEC819D4165ABe488921CD",PYTH:"0x4D7E825f80bDf85e913E0DD2A2D54927e9dE1594",ERC20:"0x55d398326f99059fF775485246999027B3197955",LIQUIDITY_ROUTER:"0x06d76c78B56D361de01A8903deA8aCEFFe6251d6",BASE_POOL:"0x59E365A627C5A1CE459e8e3489C97Ab2BEd56FEa",QUOTE_POOL:"0xB1E6df749A602892FafB27bb39Fd4F044527121E",ORACLE:"0xcb0F698f8FC931d97520a61296D0cA05688B8836",EIP7702Delegation:"0xF27e4C5bb5328453C37eD000170a3e16D6C68689",MARKET_MANAGER:"0x7fbEAd5ef0cDb301fe0e5555819f1d99F8a08468",DATA_PROVIDER:"0xD689523Ed33479DC9b5A43bC65568b9240c8D612",ORACLE_RESERVE:"0xaBde34Cb13ab013292576F3C5a0919B65C59CE80",FORWARDER:"0x54aE996239e9ca5d37a8933Df752144279aE266c",TRADING_ROUTER:"0xb2aDa5ebc0641fb81c182C1eF4E4bee0dc0Fef98",REIMBURSEMENT:"0xdE1aB9C84DFB0C2e6965889bDE152bEdD97E305a",DISPUTE_COURT:"0xc35EA4657211315de5270d7d882Ea7161F653368"};var x=s=>{let{isBetaMode:e}=pe?.getConfigManager()?.getConfig()||{};switch(s){case 421614:return e?Nn:Fn;case 59141:return e?Bn:_n;case 97:return e?Un:Ln;case 56:return Gn;default:return{}}};var De=s=>s===421614?"0x7e248ec1721639413a280d9e82e2862cae2e6e28":s===59141?"":s===97?"0xe944d7c0f7005a76e898ee3b9ec10479eba9cc02":s===56?"0x8bfc51e1928e91e47c6734983ac018b2fc0adf4e":"";var qn=async(s,e)=>{let t=E(s);return B(e,ge,t)},zn=async(s,e)=>{let t=await W(s);return B(e,ge,t)},L=async s=>await(await W(s))?.getAddress()??void 0,N=async s=>{let t=x(s).LIQUIDITY_ROUTER,n=await W(s);return B(t,Xt,n)},Ie=async(s,e=1)=>{let n=x(s).POOL_MANAGER,a=e===0?E(s):await W(s);return B(n,En,a)};var de=async(s,e=0)=>{let n=x(s).QUOTE_POOL,a=e===0?E(s):await W(s);return B(n,kn,a)},re=async(s,e=0)=>{let n=x(s).BASE_POOL,a=e===0?E(s):await W(s);return B(n,Sn,a)},ce=async(s,e)=>{let t=e,n=await W(s);return B(t,ee,n)},Y=async(s,e)=>B(s,ee,e),Wn=async(s,e)=>{let t=e,n=E(s);return B(t,ee,n)};var Vn=async(s,e,t=0)=>{let n=e,a=t===0?E(s):await W(s);return B(n,Mn,a)},Je=async(s,e=0)=>{let t=x(s),n=t.MARKET_MANAGER;console.log(t.MARKET_MANAGER);let a=e===0?E(s):await W(s);return B(n,be,a)},je=async(s,e=0)=>{let n=x(s).DATA_PROVIDER,a=e===0?E(s):await W(s);return B(n,Ke,a)},F=async(s,e=0)=>{let n=x(s).FORWARDER,a=e===0?E(s):await W(s);return B(n,$e,a)},Hn=async(s,e=0)=>{let n=x(s).REIMBURSEMENT,a=e===0?E(s):await W(s);return B(n,Dn,a)},Qn=async(s,e=0)=>{let n=x(s).DISPUTE_COURT,a=e===0?E(s):await W(s);return B(n,On,a)};var Oe=require("ethers-decode-error");var we={"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 Ns=Oe.ErrorDecoder.create();var M={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 _s(s){return s?.code===4001}async function I(s){if(_s(s))return{error:M[4001]};let e=await Ns.decode(s);if(console.log(e),e.type===Oe.ErrorType.UserRejectError||e.name==="ACTION_REJECTED")return{error:M[4001]};if(e.type===Oe.ErrorType.CustomError){let t=Object.keys(we).find(n=>n.toLowerCase()===e.selector.toLowerCase());return t?{error:{code:t,message:we[t]}}:{error:{code:s?.code,message:s?.reason||e.reason||s.message}}}return{error:{code:e.type,message:e.reason}}}var Kn=require("ethers");var kt=async(s,e,t)=>{try{let n=E(s),i=new Kn.ethers.Interface(ge).encodeFunctionData("balanceOf",[e]),r={to:t,data:i},p=await n.call(r);return BigInt(p)}catch(n){throw console.error(n),n}};var Ye=require("ethers");var $n=require("ethers");var St=async(s,e,t,n,a)=>{try{let i=E(s),p=new $n.ethers.Interface(ge).encodeFunctionData("allowance",[e,n]),o={to:t,data:p},u=await i.call(o);return BigInt(u)>=a}catch(i){throw i}};var Mt=async(s,e,t,n,a)=>{try{await(await(await zn(s,t)).approve(n,a))?.wait()}catch(i){throw i}};var v=async s=>{if("chainId"in s&&!ze(s.chainId))throw new Error(M[1]);if("slippage"in s&&!(Number(s?.slippage)<=1&&Number(s?.slippage)>0))throw new Error(M[4003]);if("amount"in s&&(Number(s.amount)===Number.NaN||Number(s.amount)<0))throw new Error(M[4004]);let{tokenAddress:e,contractAddress:t,chainId:n,amount:a,decimals:i,account:r}=s;if(a&&n&&i&&r){let p=(0,Ye.parseUnits)(a.toString(),i);if(e){let o=await kt(n,r,e);if(!o||o<p)throw new Error(M[3])}t&&e&&(await St(n,r,e,t,p)||await Mt(n,r,e,t,Ye.MaxUint256))}};var Xe=require("ethers");var S=30,U=18;var P=(s,e)=>BigInt(s)*(0,Xe.parseUnits)(e.toString(),8)/BigInt(10**8),R=async s=>{try{let e=C[s],t=E(s),{gasPrice:n}=await t.getFeeData();if(!n)throw new Error("Network Error");return{gasPrice:P(BigInt(n),e.gasPriceRatio)}}catch(e){throw e}},te=(s,e=.01)=>{let t=(0,Xe.parseUnits)("1",8)-(0,Xe.parseUnits)(e.toString(),8);return s*t/BigInt(10**8)};var Jn=require("lodash-es"),jn=async(s,e)=>await Promise.all(e.map(async n=>{let{publishTime:a,vaa:i,oracleType:r,nativeFee:p,price:o,poolId:u}=n,d=(0,Jn.isNil)(p)?1n:BigInt(p);return{poolId:u,price:o,value:d,publishTime:a,oracleType:r??2,vaa:i}})),he=async(s,e)=>{if(!e||!e.length)return;let t=await se(s,e);return await jn(s,t.data)},G=async(s,e)=>{if(!e)return;let n=(await se(s,[e]))?.data?.[0];if(!n)throw new Error(`Unable to get price for ${e} in the deposit`);return(await jn(s,[n]))?.[0]};var Yn=async s=>{try{let{chainId:e,poolId:t}=s,n=C[e],a=await L(e);await v({account:a,chainId:e});let i=await he(e,[t]);if(!i)return;let r=i.map(f=>f.value),p=i.map(f=>({poolId:t,oracleUpdateData:f?.vaa??"0",publishTime:f.publishTime,oracleType:f.oracleType})),o={prices:p,values:r,poolId:t,recipient:a},u=await N(e),d=await u["claimBasePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"].estimateGas(p,t,a,{value:r[0]}),y=P(d,n.gasLimitRatio),{gasPrice:m}=await R(e);return await u["claimBasePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"](p,t,a,{gasLimit:y,gasPrice:m,value:r[0]})}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}},Xn=async s=>{try{let{chainId:e,poolIds:t}=s;if(t.length===0)return;let n=C[e],a=await L(e);await v({account:a,chainId:e});let i=await he(e,t);if(!i)return;let r=i.map(c=>({poolId:c.poolId,oracleUpdateData:c?.vaa??"0",publishTime:c.publishTime,oracleType:c.oracleType})),o=i.map(c=>c.value).reduce((c,b)=>b+c,0n),u={prices:r,poolIds:t,value:o,recipient:a},d=await N(e),y=await d["claimBasePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"].estimateGas(r,t,a,{value:o}),m=P(y,n.gasLimitRatio),{gasPrice:l}=await R(e);return await d["claimBasePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"](r,t,a,{gasLimit:m,gasPrice:l,value:o})}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var Nt=require("ethers");var Dt=require("ethers");var Ot=async({chainId:s,amountIn:e,poolId:t,price:n=0n})=>{try{let a=C[s],i=await re(s),r=await i.previewLpAmountOut.estimateGas(t,e,n),p=P(r,a.gasLimitRatio),{gasPrice:o}=await R(s);return await i.previewLpAmountOut(t,e,n,{gasLimit:p,gasPrice:o})}catch(a){throw console.error(a),typeof a=="string"?a:await I(a)}},Ft=async({chainId:s,amountIn:e,poolId:t,price:n=0n})=>{try{let a=C[s],i=await re(s),r=await i.previewBaseAmountOut.estimateGas(t,e,n),p=P(r,a.gasLimitRatio),{gasPrice:o}=await R(s);return await i.previewBaseAmountOut(t,e,n,{gasLimit:p,gasPrice:o})}catch(a){throw console.error(a),typeof a=="string"?a:await I(a)}},Zn=async({chainId:s,account:e,poolId:t,amount:n=0})=>{try{if(!s||!e||!t)return;if(!n)return{baseAmountOut:0n,rebateAmount:0n};let a=C[s],i=18;await v({decimals:i,account:e,chainId:s,amount:Number(n)});let r=(0,Dt.parseUnits)(n.toString(),i),o=(await se(s,[t])).data?.[0]?.price||"0",u=(0,Dt.parseUnits)(o,30),d=await re(s),y=await d.previewUserWithdrawData.estimateGas(t,r,e,u),m=P(y,a.gasLimitRatio),{gasPrice:l}=await R(s),f=await d.previewUserWithdrawData(t,r,e,u,{gasLimit:m,gasPrice:l}),{baseAmountOut:c,rebateAmount:b}=f;return{baseAmountOut:c,rebateAmount:b}}catch(a){throw console.error(a),typeof a=="string"?a:await I(a)}};var q=async(s,e)=>{try{return!s||!e?void 0:(await Rt(s,e)).data}catch(t){throw typeof t=="string"?t:await I(t)}};var Ze=require("ethers");function ea(s){return s.includes(".")?s.split(".")[1].length:0}var Ce=(s=.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(M[4006]);return e.map(i=>{let r=(0,Ze.parseUnits)(i.amount.toString(),t),p=(0,Ze.parseUnits)(i.triggerPrice.toString(),30),o=ea(i.triggerPrice.toString()),u=(0,Ze.parseUnits)(i.triggerPrice.toString(),o),d=te(r*u*BigInt(10**n)/BigInt(10**(o+t)),s);return{amount:r,triggerPrice:p,triggerType:BigInt(i.triggerType),minQuoteOut:d}})};var ta=async s=>{try{let{poolId:e,chainId:t,amount:n,slippage:a=.01,tpsl:i=[]}=s;await v(s);let r=await q(t,e);if(!r)throw new Error(M[4006]);let p=r?.baseDecimals,o=r?.quoteDecimals,u=r?.baseToken,d=C[t],y=await L(t),l=x(t).BASE_POOL;await v({tokenAddress:u,contractAddress:l,decimals:p,account:y,chainId:t,amount:n});let f=!(Number(r?.state)===0||Number(r?.state)===1),c=[],b=(0,Nt.parseUnits)(n.toString(),p),h=0n,A;if(f){let Q=await G(t,e);if(!Q)return;let ss=(0,Nt.parseUnits)(Q.price,30);c.push({poolId:e,oracleUpdateData:Q.vaa,publishTime:Q.publishTime,oracleType:Q.oracleType}),A=await Ot({chainId:t,poolId:e,amountIn:b,price:ss}),h=Q.value}else A=await Ot({chainId:t,poolId:e,amountIn:b});let T=i.map(Q=>({amount:n,triggerPrice:Q.triggerPrice,triggerType:Q.triggerType})),$=Ce(a,T,p,o),O={poolId:e,amountIn:b,minAmountOut:te(A,a),recipient:y,tpslParams:$},k=await N(t),V=await k["depositBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(c,O,{value:h}),J=P(V,d.gasLimitRatio),{gasPrice:Ae}=await R(t);return await k["depositBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"](c,O,{gasLimit:J,gasPrice:Ae,value:h})}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var Ne=require("ethers");var na=async s=>{try{let{chainId:e,poolId:t,price:n}=s,a=n,i=await re(e);if(typeof n>"u"||n===null)try{let o=await G(e,t);a=(0,Ne.parseUnits)(o?.price||"0",30)}catch{a=(0,Ne.parseUnits)("0",30)}let r={poolId:t,price:a||0n},p=await i.withdrawableLpAmount(t,a||0n);return console.log(`base pool withdrawableLpAmount: ${p}`),p}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}},aa=async s=>{try{let{chainId:e,poolId:t,amount:n,slippage:a=.01}=s,i=await q(e,t),r=i?.basePoolToken,p=C[e],o=await L(e),u=18;await v({tokenAddress:r,decimals:u,account:o,chainId:e,amount:n});let d=(0,Ne.parseUnits)(n.toString(),u),y=!(Number(i?.state)===0||Number(i?.state)===1),m=[],l=0n,f;if(y){let k=await G(e,t);if(!k)return;let V=(0,Ne.parseUnits)(k.price,30);m.push({poolId:t,oracleUpdateData:k.vaa,publishTime:k.publishTime,oracleType:k.oracleType}),f=await Ft({chainId:e,poolId:t,amountIn:d,price:V}),l=k.value}else f=await Ft({chainId:e,poolId:t,amountIn:d});let c={poolId:t,amountIn:d,minAmountOut:te(f,a),recipient:o},b=await N(e),h=await b["withdrawBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"].estimateGas(m,c,{value:l}),A=P(h,p.gasLimitRatio),{gasPrice:T}=await R(e);return await(await b["withdrawBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"](m,c,{gasLimit:A,gasPrice:T,value:l}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var sa=require("ethers");var ia=async s=>{try{let{chainId:e,account:t,poolId:n}=s;if(!e||!t||!n)return;let a=C[e],i=0n,p=(await se(e,[n])).data?.[0]?.price||"0",o=(0,sa.parseUnits)(p,30),u=await re(e),d=await u.pendingUserRebates.estimateGas(n,t,o),y=P(d,a.gasLimitRatio),{gasPrice:m}=await R(e),l=await u.pendingUserRebates(n,t,o,{gasLimit:y,gasPrice:m});return console.log("pendingUserRebates base result:",{rebates:l?.rebates,genesisRebates:l?.genesisRebates}),{rebates:l?.rebates,genesisRebates:l?.genesisRebates}}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var ra=require("ethers");var oa=async(s,e)=>{if(e)try{let t=await re(s),n=0n,a=await G(s,e);return a?.price&&(n=(0,ra.parseUnits)(a.price,30)),await t.getPoolTokenPrice(e,n)}catch(t){throw console.error(t),typeof t=="string"?t:await I(t)}};var Gt={};ke(Gt,{claimQuotePoolRebate:()=>fa,claimQuotePoolRebates:()=>ga,deposit:()=>pa,getLpPrice:()=>Ia,getRewards:()=>ya,transfer:()=>la,withdraw:()=>da,withdrawableLpAmount:()=>ua});var Ut=require("ethers");var Bt=async({chainId:s,amountIn:e,poolId:t,price:n=0n})=>{try{let a=C[s],i=await de(s),r=await i.previewLpAmountOut.estimateGas(t,e,n),p=P(r,a.gasLimitRatio),{gasPrice:o}=await R(s);return await i.previewLpAmountOut(t,e,n,{gasLimit:p,gasPrice:o})}catch(a){throw console.error(a),typeof a=="string"?a:await I(a)}},Lt=async({chainId:s,amountIn:e,poolId:t,price:n=0n})=>{try{let a=C[s],i=await de(s),r=await i.previewQuoteAmountOut.estimateGas(t,e,n),p=P(r,a.gasLimitRatio),{gasPrice:o}=await R(s);return await i.previewQuoteAmountOut(t,e,n,{gasLimit:p,gasPrice:o})}catch(a){throw console.error(a),typeof a=="string"?a:await I(a)}};var pa=async s=>{try{let{poolId:e,chainId:t,amount:n,slippage:a=.01,tpsl:i=[]}=s;await v(s);let r=await q(t,e);if(!r)throw new Error(M[4006]);let p=C[t],o=await L(t),d=x(t).QUOTE_POOL,y=r.quoteToken,m=r?.quoteDecimals;await v({tokenAddress:y,contractAddress:d,decimals:m,account:o,chainId:t,amount:n});let l=(0,Ut.parseUnits)(n.toString(),m),f=!(Number(r?.state)===0||Number(r?.state)===1),c=[],b=0n,h;if(f){let z=await G(t,e);if(!z)return;let Q=(0,Ut.parseUnits)(z.price,30);c.push({poolId:e,oracleUpdateData:z.vaa,publishTime:z.publishTime,oracleType:z.oracleType}),h=await Bt({chainId:t,poolId:e,amountIn:l,price:Q}),b=z.value}else h=await Bt({chainId:t,poolId:e,amountIn:l});let A=i.map(z=>({amount:n,triggerPrice:z.triggerPrice,triggerType:z.triggerType})),T=Ce(a,A,m,m),$={poolId:e,amountIn:l,minAmountOut:te(h,a),recipient:o,tpslParams:T},O=await N(t),k=await O["depositQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(c,$,{value:b}),V=P(k,p.gasLimitRatio),{gasPrice:J}=await R(t);return await O["depositQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"](c,$,{gasLimit:V,gasPrice:J,value:b})}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var _e=require("ethers");var ua=async s=>{try{let{chainId:e,poolId:t,price:n}=s,a=n,i=await de(e);if(typeof n>"u"||n===null)try{let o=await G(e,t);a=(0,_e.parseUnits)(o?.price||"0",30)}catch{a=(0,_e.parseUnits)("0",30)}let r={poolId:t,price:a||0n},p=await i.withdrawableLpAmount(t,a||0n);return console.log(`quote pool withdrawableLpAmount: ${p}`),p}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}},da=async s=>{try{let{chainId:e,poolId:t,amount:n,slippage:a=.01}=s,i=await q(e,t),r=i?.quotePoolToken,p=C[e],o=await L(e),u=18;await v({tokenAddress:r,decimals:u,account:o,chainId:e,amount:n});let d=(0,_e.parseUnits)(n.toString(),u),y=!(Number(i?.state)===0||Number(i?.state)===1),m=[],l=0n,f;if(y){let k=await G(e,t);if(!k)return;let V=(0,_e.parseUnits)(k.price,30);m.push({poolId:t,oracleUpdateData:k.vaa,publishTime:k.publishTime,oracleType:k.oracleType}),f=await Lt({chainId:e,poolId:t,amountIn:d,price:V}),l=k.value}else f=await Lt({chainId:e,poolId:t,amountIn:d});let c={poolId:t,amountIn:d,minAmountOut:te(f,a),recipient:o},b=await N(e),h=await b["withdrawQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"].estimateGas(m,c,{value:l}),A=P(h,p.gasLimitRatio),{gasPrice:T}=await R(e);return await(await b["withdrawQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"](m,c,{gasLimit:A,gasPrice:T,value:l}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var ca=require("ethers");var la=async(s,e,t,n)=>{try{let a=await q(s,e),i=await q(s,t);if(!i||!a)return null;if([3,4].includes(i.state))throw new Error(M[4005]);let r=await L(s),p=C[s],o=18;await v({chainId:s,amount:n,account:r,decimals:o,tokenAddress:a.quotePoolToken});let u={fromPoolId:e,toPoolId:t,minLpOut:0n,amount:(0,ca.parseUnits)(n.toString(),o)},d=await N(s),y=await d.migrateLiquidity.estimateGas(u),m=P(y,p.gasLimitRatio),{gasPrice:l}=await R(s);return await d.migrateLiquidity(u,{gasLimit:m,gasPrice:l})}catch(a){throw typeof a=="string"?a:await I(a)}};var ma=require("ethers");var ya=async s=>{try{let{chainId:e,account:t,poolId:n}=s;if(!e||!t||!n)return;let a=C[e],r=(await se(e,[n])).data?.[0]?.price||"0",p=(0,ma.parseUnits)(r,30),o=await de(e),u=await o.pendingUserRebates.estimateGas(n,t,p),d=P(u,a.gasLimitRatio),{gasPrice:y}=await R(e),m=await o.pendingUserRebates(n,t,p,{gasLimit:d,gasPrice:y});return console.log("pendingUserRebates quote result:",m),m}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var fa=async s=>{try{let{chainId:e,poolId:t}=s,n=C[e],a=await L(e),i=18;await v({account:a,chainId:e});let r=await he(e,[t]);if(!r)return;let p=r.map(c=>c.value),o=r.map(c=>({poolId:c.poolId,oracleUpdateData:c?.vaa??"0",publishTime:c.publishTime,oracleType:c.oracleType})),u={prices:o,values:p,poolId:t,recipient:a},d=await N(e),y=await d["claimQuotePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"].estimateGas(o,t,a,{value:p[0]}),m=P(y,n.gasLimitRatio),{gasPrice:l}=await R(e);return await d["claimQuotePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"](o,t,a,{gasLimit:m,gasPrice:l,value:p[0]})}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}},ga=async s=>{try{let{chainId:e,poolIds:t}=s;if(t.length===0)return;let n=C[e],a=await L(e),i=18;await v({account:a,chainId:e});let r=await he(e,t);if(!r)return;let p=r.map(b=>({poolId:b.poolId,oracleUpdateData:b?.vaa??"0",publishTime:b.publishTime,oracleType:b.oracleType})),u=r.map(b=>b.value).reduce((b,h)=>h+b,0n),d={prices:p,value:u,poolIds:t,recipient:a},y=await N(e),m=await y["claimQuotePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"].estimateGas(p,t,a,{value:u}),l=P(m,n.gasLimitRatio),{gasPrice:f}=await R(e);return await y["claimQuotePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"](p,t,a,{gasLimit:l,gasPrice:f,value:u})}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var ba=require("ethers");var Ia=async(s,e)=>{if(e)try{let t=await de(s),n=0n,a=await G(s,e);return a?.price&&(n=(0,ba.parseUnits)(a.price,30)),await t.getPoolTokenPrice(e,n)}catch(t){throw console.error(t),typeof t=="string"?t:await I(t)}};var qt={};ke(qt,{PoolType:()=>va,TriggerType:()=>Ea,addTpSl:()=>Ca,cancelTpSl:()=>Pa,createPool:()=>Aa,getMarketPoolId:()=>et,getMarketPools:()=>ha,getOpenOrders:()=>Ta,getPoolDetail:()=>q,getPoolInfo:()=>xa,getUserGenesisShare:()=>wa,reprime:()=>Ra});var et=async({chainId:s,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(M[2]);let n=C[s],i=x(s).POOL_MANAGER,r=await Ie(s,0),p=[t,e],o=await r.getMarketPool(t,e);return o.poolId==="0x0000000000000000000000000000000000000000000000000000000000000000"||!o.poolId?void 0:o.poolId}catch(n){throw console.error(n),typeof n=="string"?n:await I(n)}},ha=async s=>{try{let t=await(await Ie(s)).getPools();return console.log(t),t||[]}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}},xa=async(s,e,t=0n)=>{try{let a=await(await je(s)).getPoolInfo(e,t);return{quotePool:{poolToken:a.quotePool.poolToken,exchangeRate:a.quotePool.exchangeRate,poolTokenPrice:a.quotePool.poolTokenPrice,poolTokenSupply:a.quotePool.poolTokenSupply,totalDebt:a.quotePool.totalDebt,baseCollateral:a.quotePool.baseCollateral},basePool:{poolToken:a.basePool.poolToken,exchangeRate:a.basePool.exchangeRate,poolTokenPrice:a.basePool.poolTokenPrice,poolTokenSupply:a.basePool.poolTokenSupply,totalDebt:a.basePool.totalDebt,baseCollateral:a.basePool.baseCollateral},reserveInfo:{baseTotalAmount:a.reserveInfo.baseTotalAmount,baseReservedAmount:a.reserveInfo.baseReservedAmount,quoteTotalAmount:a.reserveInfo.quoteTotalAmount,quoteReservedAmount:a.reserveInfo.quoteReservedAmount},fundingInfo:{nextFundingRate:a.fundingInfo.nextFundingRate,lastFundingFeeTracker:a.fundingInfo.lastFundingFeeTracker,nextEpochTime:a.fundingInfo.nextEpochTime},ioTracker:{tracker:a.oi.tracker,longSize:a.oi.longSize,shortSize:a.oi.shortSize,poolEntryPrice:a.oi.poolEntryPrice},liquidityInfo:{windowCaps:a.liquidityInfo.windowCaps,openInterest:a.liquidityInfo.openInterest}}}catch(n){throw console.error(n),typeof n=="string"?n:await I(n)}};var Aa=async({chainId:s,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(M[2]);let n=C[s],a=await Ie(s),i={marketId:t,baseToken:e},r=await a.deployPool.estimateGas(i),p=P(r,n.gasLimitRatio);console.log("gasLimit",r,p);let{gasPrice:o}=await R(s);if(console.log("gasPrice",o),(await(await a.deployPool(i,{gasLimit:p,gasPrice:o}))?.wait())?.hash)return await et({chainId:s,baseToken:e,marketId:t})}catch(n){throw console.error(n),typeof n=="string"?n:await I(n)}};var wa=async(s,e,t)=>{try{return await(await Vn(s,e)).userGenesisShare(t)}catch(n){throw console.error(n),typeof n=="string"?n:await I(n)}};var Ca=async s=>{try{let{chainId:e,poolId:t,poolType:n,slippage:a=.01,tpsl:i=[]}=s;await v(s);let r=await q(e,t);if(!r)throw new Error(M[4006]);let p=18,o=r.quoteDecimals,u=Ce(a,i,p,o),d=C[e],y=await N(e),m={poolId:t,poolType:BigInt(n),tpslParams:u},l=await y.addTpsl.estimateGas(m),f=P(l,d.gasLimitRatio),{gasPrice:c}=await R(e);return await(await y.addTpsl(m,{gasLimit:f,gasPrice:c}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var Pa=async s=>{try{let{chainId:e,orderId:t}=s;await v(s);let n=C[e],a=await N(e),i=await a.cancelTpsl.estimateGas(t),r=P(i,n.gasLimitRatio),{gasPrice:p}=await R(e);return await(await a.cancelTpsl(t,{gasLimit:r,gasPrice:p}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await I(e)}};var tt=require("ethers");async function Ls(s){try{return(await fetch(s,{method:"HEAD"})).ok}catch{return!1}}var Us=async(s,e,t)=>{try{let n=await qn(s,e),a=await n.name();console.log(a);let[i,r,p,o]=await Promise.all([n.name(),n.symbol(),n.decimals(),n.totalSupply()]),u=tt.ethers.getAddress(e),d=`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${s}/assets/${u}/logo.png`,m=await Ls(d)?d:"",l;if(t){let f=await n.balanceOf(t);l=Number(tt.ethers.formatUnits(f,p))}return{address:e,name:i,symbol:r,decimals:p,icon:m,totalSupply:Number(tt.ethers.formatUnits(o,p)),...t?{balance:l}:{}}}catch(n){throw console.error(n),n}};var nt=require("ethers");var Ra=async(s,e,t)=>{try{await v({chainId:s});let n=await q(s,e);if(!n)throw new Error(M[4006]);let a=await L(s),r=((pe?.Markets?.length?pe?.Markets:await pe.getMarkets())||[])?.find(c=>c.chainId===s&&c.marketId===t);if(!r)throw new Error("Invalid Market");let p=(0,nt.parseUnits)(r.oracleFeeUsd.toString(),n.quoteDecimals);if(!p)throw new Error("Invalid Market");await v({tokenAddress:n.quoteToken,contractAddress:x(s).ORACLE_RESERVE,decimals:n.quoteDecimals,account:a,chainId:s,amount:Number((0,nt.formatUnits)(p,n.quoteDecimals))});let o=C[s],u=await Ie(s),d=await u.reprimePool.estimateGas({poolId:e}),y=P(d,o.gasLimitRatio),{gasPrice:m}=await R(s);return await(await u.reprimePool({poolId:e}))?.wait()}catch(n){throw console.error(n),typeof n=="string"?n:await I(n)}};var Ta=async(s,e)=>{try{let t=await ue.getInstance().getConfigManager()?.getAccessToken();if(!t)throw new Error("Failed to obtain accessToken");return(await Tt(t,e,s)).data||[]}catch(t){throw console.error(t),t}};var va=(t=>(t[t.Base=0]="Base",t[t.Quote=1]="Quote",t))(va||{}),Ea=(t=>(t[t.TP=1]="TP",t[t.SL=2]="SL",t))(Ea||{});var zt={};ke(zt,{getMarket:()=>ka,getOracleFee:()=>Sa});var ka=async(s,e)=>{try{if(await v({chainId:s}),!e)return;let n=await(await Je(s)).getMarket(e);return console.log("MarketManage.getMarket request",n),n}catch(t){throw console.error(t),typeof t=="string"?t:await I(t)}};var Sa=async(s,e)=>{try{return await v({chainId:s}),e?await(await Je(s)).getOracleFee(e):void 0}catch(t){throw console.error(t),typeof t=="string"?t:await I(t)}};var at=require("ethers");var Ba=ne(require("mitt"));var Ma=ne(require("crypto-js/enc-hex.ts")),Da=ne(require("crypto-js/md5.ts")),st=(s,e)=>(0,Da.default)(s,{length:e||32}).toString(Ma.default);var it=s=>{switch(s.request){case"signin":return st(s.request)}return st(JSON.stringify(s))},Be=s=>{let{topic:e,params:t}=s;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 st(JSON.stringify({topic:e,params:t}))}},Fa=({type:s})=>s==="pong"||s==="signin"||s==="subv2"||s==="unsubv2"||s==="ping"||s==="pong",qs=s=>{switch(s){case"order":case"position":case"ticker.*":return s;default:let[e]=s.split(".");return e}},Na=s=>{switch(qs(s.type)){case"ticker":{let[,t=""]=s.type.split(".");return{...s,type:Be({topic:"ticker",params:{globalId:parseInt(t)}}),globalId:parseInt(t)}}case"candle":{let[,t=""]=s.type.split("."),[n,a]=t.split("_");return{...s,type:Be({topic:"candle",params:{globalId:parseInt(n),resolution:a}}),globalId:parseInt(n),resolution:a}}}return s};var Pe=class{constructor(e){this.options={...e,logLevel:e?.logLevel||"info"}}debug(e,...t){this.options.logLevel!=="none"&&this.options.logLevel==="debug"&&console.log(`[MYX-SDK-DEBUG] ${e}`,...t)}info(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info")&&console.log(`[MYX-SDK-INFO] ${e}`,...t)}error(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info"||this.options.logLevel==="error")&&console.error(`[MYX-SDK-ERROR] ${e}`,...t)}warn(e,...t){this.options.logLevel!=="none"&&console.warn(`[MYX-SDK-WARN] ${e}`,...t)}};var g=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}`}};var La=ne(require("reconnecting-websocket")),_a={url:"",initialReconnectDelay:1e3,maxReconnectDelay:3e4,reconnectMultiplier:1.5,maxReconnectAttempts:10,maxEnqueuedMessages:100,requestTimeout:1e4,heartbeatInterval:1e4,heartbeatMessage:"ping",noMessageTimeout:5e3,connectionTimeout:1e4},rt=class{constructor(e){this.ws=null;this.subscriptions=new Map;this.waitingRequests=new Map;this.eventBus=(0,Ba.default)();this.heartbeatIntervalId=null;this.isFirstConnection=!0;this.lastMessageTime=0;let t={...e,logLevel:e?.logLevel||"info"},{logLevel:n,...a}=t;this.config={..._a,...a},this.logger=new Pe({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 La.default(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),console.log("onOPen"),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 a=it(e);this.waitingRequests.has(a)?(this.waitingRequests.get(a)?.onSuccess.add(t),this.waitingRequests.get(a)?.onError.add(n)):this.waitingRequests.set(a,{onSuccess:new Set([t]),onError:new Set([n])}),this.send(e)})}subscribe(e,t){let n=Array.isArray(e)?e:[e],a=[],i=new Set;n.forEach(r=>{let p=Be(r);if(!i.has(p))if(i.add(p),this.subscriptions.has(p))this.subscriptions.get(p).callbacks.add(t);else{let o={id:p,topic:r.topic,callbacks:new Set([t])};this.subscriptions.set(p,o),a.push(p),this.logger.debug(`create new subscription: ${p}`)}}),a.length>0&&this.send({request:"subv2",args:a})}unsubscribe(e,t){if(!e)return;let n=Array.isArray(e)?e:[e],a=[],i=new Set;n.forEach(r=>{let p=Be(r);if(i.has(p))return;i.add(p);let o=this.subscriptions.get(p);o&&(o.callbacks.delete(t),this.logger.debug(`remove callback from subscription: ${p}`),o.callbacks.size===0&&(this.subscriptions.delete(p),a.push(p),this.logger.debug(`subscription ${p} has no callbacks, will unsubscribe`)))}),a.length>0&&this.send({request:"unsubv2",args:a})}send(e){let t=typeof e=="string"?e:JSON.stringify(e);if(!this.ws)throw new g("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(Fa(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=it({request:e.type,args:""});break;default:t=it({request:e.type,args:e.data.data});break}let n=this.waitingRequests.get(t),a=e.data.code===9200;a?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&&!a&&n.onError.forEach(i=>{i(new g("REQUEST_FAILED","Request failed"))}),n?.onSuccess.size&&a&&n.onSuccess.forEach(i=>{i(e.data)})}handleSubscriptionMessage(e){let t=Na(e),n=t.type,a=this.subscriptions.get(n);a&&a.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||_a.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 Ua=[56,59144,42161],Ga=[59141,421614,97],qa=[97,421614];var ot={TestNet:"wss://oapi-test.myx.cash/ws",MainNet:"wss://oapi.myx.finance/ws",BetaNet:"wss://oapi-beta.myx.finance/ws"};var pt=class{constructor(e,t){this.clientAuth=!1;this.prevAccessToken="";this.configManager=e,this.logger=t;let n=ot.MainNet;e.getConfig().isBetaMode?n=ot.BetaNet:e.getConfig().isTestnet&&(n=ot.TestNet),this.wsClient=new rt({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(a=>({topic:"ticker",params:{globalId:a}})),t)}unsubscribeTickers(e,t){let n=Array.isArray(e)?e:[e];this.wsClient.unsubscribe(n.map(a=>({topic:"ticker",params:{globalId:a}})),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 getAccessToken(){let e=await this.configManager.refreshAccessToken()??"";return this.logger.debug(`getAccessToken->${e}`),e}async auth(e=!1){let t=await this.getAccessToken();if(t===this.prevAccessToken&&this.clientAuth&&!e)return Promise.resolve();this.logger.debug(`auth ${t}`),await this.wsClient.request({request:"signin",args:`sdk.${t}`}).then(()=>{this.logger.debug(`auth success ${t}`),this.prevAccessToken=t,this.clientAuth=!0})}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)}};var ut=class{constructor(e){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.config={...this.config,signer:void 0,getAccessToken:void 0}}async startSeamlessMode(e){return this.config={...this.config,seamlessMode:e},this.config}updateSeamlessWallet({wallet:e,authorized:t,masterAddress:n}){this.config={...this.config,seamlessAccount:{masterAddress:n??"",wallet:e??null,authorized:t??!1}}}updateClientChainId(e,t){this.config={...this.config,chainId:e,brokerAddress:t}}auth(e){this.clear(),this.config={...this.config,...e},this.validateConfig(this.config)}validateConfig(e){let{isTestnet:t,isBetaMode:n,chainId:a}=e;if(t){if(!Ga.includes(a))throw new g("INVALID_CHAIN_ID",`chainId ${a} is not in the range of TESTNET_CHAIN_IDS`)}else if(n){if(!qa.includes(a))throw new g("INVALID_CHAIN_ID",`chainId ${a} is not in the range of BETA_ENV_CHAIN_IDS`)}else if(!Ua.includes(a))throw new g("INVALID_CHAIN_ID",`chainId ${a} 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 console.warn("No getAccessToken method provided in config"),null;try{console.log("Manually refreshing accessToken...");let t=await this.config.getAccessToken()??{accessToken:"",expireAt:0};if(t&&t.accessToken){let n=3600;if(t.expireAt){let a=Math.floor(Date.now()/1e3);n=t.expireAt-a,n<=0&&(console.warn("Received expired token, using default expiry"),n=3600)}return this.setAccessToken(t.accessToken,n),console.log("\u2705 AccessToken refreshed and stored successfully",{expiryInSeconds:n,expireAt:t.expireAt}),t.accessToken}else return console.warn("\u274C Received empty accessToken"),null}catch(t){return console.error("\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 dt=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}};var za=require("ethers");var Wa=ne(require("dayjs"));var ct=class{constructor(e,t,n,a,i,r){this.configManager=e,this.logger=t,this.utils=n,this.seamless=a,this.account=i,this.api=r}async listPositions(e){let t=await this.configManager.getAccessToken();try{return{code:0,data:(await this.api.getPositions(t??"",e)).data}}catch(n){return console.error("Error fetching positions:",n),{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:a,chainId:i,address:r}){let p=this.configManager.getConfig();try{let o=await this.utils.getOraclePrice(e,i);if(!o)throw new Error("Failed to get price data");let u={poolId:e,oracleType:o.oracleType,oracleUpdateData:o?.vaa??"0",publishTime:o.publishTime},d=!1;Number(n)>0&&(d=await this.utils.needsApproval(r,i,a,n,x(i).TRADING_ROUTER));let y=this.configManager.getConfig().seamlessAccount?.authorized,m=this.configManager.getConfig().seamlessAccount?.wallet,l=BigInt(0),f=BigInt(n)>0?BigInt(n):0n,c=await this.account.getAvailableMarginBalance({poolId:e,chainId:i,address:r}),b=BigInt(0);c<f&&(b=f-c,l=b);let h={token:a,amount:l.toString()};if(p.seamlessMode&&y&&m){if(!await this.utils.checkSeamlessGas(p.seamlessAccount?.masterAddress,i))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let k=await F(i),J=(await Y(this.configManager.getConfig().brokerAddress,m)).interface.encodeFunctionData("updatePriceAndAdjustCollateral",[[u],h,t,n]),Ae=await k.nonces(m.address),z={from:m.address??"",to:this.configManager.getConfig().brokerAddress,value:(o?.value??"1").toString(),gas:"10000000",deadline:(0,Wa.default)().add(60,"minute").unix(),data:J,nonce:Ae.toString()};return this.logger.info("adjust collateral forward tx params --->",z),{code:0,message:"adjust collateral success",data:await this.seamless.forwarderTx(z,i,m)}}if(!p.signer)throw new g("INVALID_SIGNER","Invalid signer");let A=B(p.brokerAddress,ee,p.signer);if(d){let O=await this.utils.approveAuthorization({chainId:i,quoteAddress:a,amount:za.ethers.MaxUint256.toString(),spenderAddress:x(i).TRADING_ROUTER});if(O.code!==0)throw new Error(O.message)}return this.logger.info("adjustCollateral transaction data--->",{updateParams:u,depositData:h,positionId:t,adjustAmount:n,txParams:{value:BigInt(o?.value??"1"),gas:BigInt(1e7)*H[i]/100n}}),{code:0,data:{hash:await(await A.updatePriceAndAdjustCollateral([u],h,t,n,{value:BigInt(o?.value??"1"),gas:BigInt(1e7)*H[i]/100n})).wait()},message:"Adjust collateral transaction submitted"}}catch(o){console.log(o,"error");let u=await this.utils.getErrorMessage(o);return this.logger.error("adjustCollateral error-->",u),{code:-1,message:u}}}};var zs={IOC:0},xe=zs.IOC;var Le={MARKET:0,LIMIT:1,STOP:2,CONDITIONAL:3},Ws={NONE:0,GTE:1,LTE:2},ye={INCREASE:0,DECREASE:1},Vs={LONG:0,SHORT:1},Hs={IOC:0},Qs={PENDING:0,PARTIAL:1,FILLED:2,CANCELLED:3,REJECTED:4,EXPIRED:5};var Wt=require("ethers"),oe=ne(require("dayjs"));var lt=class{constructor(e,t,n,a,i,r){this.configManager=e,this.logger=t,this.utils=n,this.seamless=a,this.account=i,this.api=r}async createIncreaseOrder(e,t,n){try{let a=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),o=await this.account.getAvailableMarginBalance({poolId:e.poolId,chainId:e.chainId,address:e.address}),u=p+r,d=BigInt(0),y=u-o;y>BigInt(0)&&(d=y);let m={token:e.executionFeeToken,amount:d.toString()},l={user:e.address,poolId:e.poolId,orderType:e.orderType,triggerType:e.triggerType,operation:ye.INCREASE,direction:e.direction,collateralAmount:p.toString(),size:e.size,price:e.price,timeInForce:xe,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"},f=this.configManager.getConfig().seamlessAccount?.authorized,c=this.configManager.getConfig().seamlessAccount?.wallet;if(a.seamlessMode&&f&&c){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let k=await F(e.chainId),V=await Y(this.configManager.getConfig().brokerAddress,c),J="";e.positionId?J=V.interface.encodeFunctionData("placeOrderWithPosition",[e.positionId.toString(),{...m},l]):(this.logger.info("createIncreaseOrder placeOrderWithSalt data --->",["1",{...m},l]),J=V.interface.encodeFunctionData("placeOrderWithSalt",["1",{...m},l]));let Ae=await k.nonces(c.address),z={from:c.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:J,nonce:Ae.toString()};return this.logger.info("createIncreaseOrder forward tx params --->",z),{code:0,message:"create increase order success",data:await this.seamless.forwarderTx(z,e.chainId,c)}}let b=await this.utils.needsApproval(e.address,e.chainId,e.executionFeeToken,e.collateralAmount,x(e.chainId).TRADING_ROUTER);if(!a.signer)throw new g("INVALID_SIGNER","Invalid signer");if(b){let O=await this.utils.approveAuthorization({chainId:e.chainId,quoteAddress:e.executionFeeToken,amount:Wt.ethers.MaxUint256.toString(),spenderAddress:x(e.chainId).TRADING_ROUTER});if(O.code!==0)throw new Error(O.message)}let h=await ce(e.chainId,this.configManager.getConfig().brokerAddress),A;if(e.positionId){this.logger.info("createIncreaseOrder nft position params--->",{...l,positionId:e.positionId});let O=await h.placeOrderWithPosition.estimateGas(e.positionId.toString(),{...m},l);A=await h.placeOrderWithPosition(e.positionId.toString(),{...m},l,{gasLimit:O*H[e.chainId]/100n})}else{this.logger.info("createIncreaseOrder salt position params--->",{positionSalt:"1",data:l,depositData:m});let k=await h.placeOrderWithSalt.estimateGas("1",{...m},l);A=await h.placeOrderWithSalt("1",{...m},l,{gasLimit:k*H[e.chainId]/100n})}let T=await A.wait();return{code:0,message:"create increase order success",data:{success:!0,transactionHash:A.hash,blockNumber:T?.blockNumber,gasUsed:T?.gasUsed?.toString(),status:T?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:T}}}catch(a){return this.logger.error("Error placing order:",a),{code:-1,message:a?.message}}}async closeAllPositions(e,t){try{let n=this.configManager.getConfig(),a={token:"0x0000000000000000000000000000000000000000",amount:"0"},i=t.map(l=>l.positionId.toString()),r=t.map(l=>({user:l.address,poolId:l.poolId,orderType:l.orderType,triggerType:l.triggerType,operation:ye.DECREASE,direction:l.direction,collateralAmount:l.collateralAmount,size:l.size,price:l.price,timeInForce:xe,postOnly:l.postOnly,slippagePct:l.slippagePct,leverage:l.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0}));this.logger.info("closeAllPositions params--->",a,i,r);let p=this.configManager.getConfig().seamlessAccount?.authorized,o=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&p&&o){if(!await this.utils.checkSeamlessGas(t[0].address,e))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let f=await F(e),b=(await Y(this.configManager.getConfig().brokerAddress,o)).interface.encodeFunctionData("placeOrdersWithPosition",[a,i,r]),h=await f.nonces(o.address),A={from:o.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:b,nonce:h.toString()};this.logger.info("cancel all positions forward tx params --->",A);let T=await this.seamless.forwarderTx(A,e,o);return console.log("rs-->",T),{code:0,message:"cancel all positions success",data:T}}if(!n.signer)throw new g("INVALID_SIGNER","Invalid signer");let u=await ce(e,this.configManager.getConfig().brokerAddress),d=await u.placeOrdersWithPosition.estimateGas(a,i,r),y=await u.placeOrdersWithPosition(a,i,r,{gasLimit:d*H[e]/100n}),m=await y.wait();return{code:0,message:"close all positions success",transactionHash:y.hash,blockNumber:m?.blockNumber,gasUsed:m?.gasUsed?.toString(),status:m?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:m}}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:ye.DECREASE,direction:e.direction,collateralAmount:e.collateralAmount,size:e.size,price:e.price,timeInForce:xe,postOnly:e.postOnly,slippagePct:e.slippagePct,leverage:e.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0},a={token:"0x0000000000000000000000000000000000000000",amount:"0"},i=this.configManager.getConfig().seamlessAccount?.authorized,r=this.configManager.getConfig().seamlessAccount?.wallet;if(t.seamlessMode&&i&&r){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let m=await F(e.chainId),l=await Y(this.configManager.getConfig().brokerAddress,r),f="";e.positionId?f=l.interface.encodeFunctionData("placeOrderWithPosition",[e.positionId.toString(),{...a},n]):f=l.interface.encodeFunctionData("placeOrderWithSalt",["1",{...a},n]);let c=await m.nonces(r.address),b={from:r.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:f,nonce:c.toString()};return this.logger.info("create decrease order forward tx params --->",b),{code:0,message:"create decrease order success",data:await this.seamless.forwarderTx(b,e.chainId,r)}}if(!t.signer)throw new g("INVALID_SIGNER","Invalid signer");let p=await ce(e.chainId,this.configManager.getConfig().brokerAddress),o;if(e.positionId){this.logger.info("createDecreaseOrder nft position params--->",[e.positionId,a,{data:n}]);let y=await p.placeOrderWithPosition.estimateGas(e.positionId.toString(),a,n);o=await p.placeOrderWithPosition(e.positionId.toString(),a,n,{gasLimit:y*H[e.chainId]/100n})}else{this.logger.info("createDecreaseOrder salt position params--->",[1,a,{data:n}]);let m=await p.placeOrderWithSalt.estimateGas("1",a,n);o=await p.placeOrderWithSalt("1",a,n,{gasLimit:m*H[e.chainId]/100n})}let u=await o.wait();return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:o.hash,blockNumber:u?.blockNumber,gasUsed:u?.gasUsed?.toString(),status:u?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:u}}}catch(t){return{code:-1,message:t?.message}}}async createPositionTpSlOrder(e){try{let t=this.configManager.getConfig();if(!t.signer&&!t.seamlessMode)throw new g("INVALID_SIGNER","Invalid signer");let n=await ce(e.chainId,this.configManager.getConfig().brokerAddress);try{if(e.tpSize!=="0"&&e.slSize!=="0"){let y=[{user:e.address,poolId:e.poolId,orderType:Le.STOP,triggerType:e.tpTriggerType,operation:ye.DECREASE,direction:e.direction,collateralAmount:"0",size:e.tpSize??"0",price:e.tpPrice??"0",timeInForce:xe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},{user:e.address,poolId:e.poolId,orderType:Le.STOP,triggerType:e.slTriggerType,operation:ye.DECREASE,direction:e.direction,collateralAmount:"0",size:e.slSize??"0",price:e.slPrice??"0",timeInForce:xe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"}],m={token:"0x0000000000000000000000000000000000000000",amount:"0"},l=this.configManager.getConfig().seamlessAccount?.authorized,f=this.configManager.getConfig().seamlessAccount?.wallet;if(t.seamlessMode&&l&&f){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let T=await F(e.chainId),$=await Y(this.configManager.getConfig().brokerAddress,f),O="";e.positionId?O=$.interface.encodeFunctionData("placeOrdersWithPosition",[m,[e.positionId.toString(),e.positionId.toString()],y]):O=$.interface.encodeFunctionData("placeOrdersWithSalt",[m,["1","1"],y]);let k=await T.nonces(f.address),V={from:f.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:O,nonce:k.toString()};this.logger.info("createPositionTpSlOrder forward tx params --->",V);let J=await this.seamless.forwarderTx(V,e.chainId,f);return console.log("rs-->",J),{code:0,message:"createPositionTpSlOrder success",data:J}}let c;if(e.positionId){let A=await n.placeOrdersWithPosition.estimateGas(m,[e.positionId.toString(),e.positionId.toString()],y);c=await n.placeOrdersWithPosition(m,[e.positionId.toString(),e.positionId.toString()],y,{gasLimit:A*H[e.chainId]/100n})}else{this.logger.info("createPositionTpSlOrder salt position data--->",y);let A=1,T=await n.placeOrdersWithSalt.estimateGas(m,[A.toString(),A.toString()],y);c=await n.placeOrdersWithSalt(m,[A.toString(),A.toString()],y,{gasLimit:T*H[e.chainId]/100n})}let b=await c.wait();return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:c.hash,blockNumber:b?.blockNumber,gasUsed:b?.gasUsed?.toString(),status:b?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:b}}}let a={user:e.address,poolId:e.poolId,orderType:Le.STOP,triggerType:e.tpSize!=="0"?e.tpTriggerType:e.slTriggerType,operation:ye.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:xe,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:0,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},i={token:"0x0000000000000000000000000000000000000000",amount:"0"},r=this.configManager.getConfig().seamlessAccount?.authorized,p=this.configManager.getConfig().seamlessAccount?.wallet;if(t.seamlessMode&&r&&p){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let m=await F(e.chainId),l=await Y(this.configManager.getConfig().brokerAddress,p),f="";e.positionId?f=l.interface.encodeFunctionData("placeOrderWithPosition",[e.positionId.toString(),i,a]):f=l.interface.encodeFunctionData("placeOrderWithSalt",["1",i,a]);let c=await m.nonces(p.address),b={from:p.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:f,nonce:c.toString()};this.logger.info("createPositionTpSlOrder forward tx params --->",b);let h=await this.seamless.forwarderTx(b,e.chainId,p);return console.log("rs-->",h),{code:0,message:"createPositionTpSlOrder success",data:h}}let o;if(e.positionId){this.logger.info("createPositionTpOrSlOrder nft position data--->",a);let y=await n.placeOrderWithPosition.estimateGas(e.positionId.toString(),i,a);o=await n.placeOrderWithPosition(e.positionId.toString(),i,a,{gasLimit:y*H[e.chainId]/100n})}else{this.logger.info("createPositionTpOrSlOrder salt position data--->",a);let y=1,m=await n.placeOrderWithSalt.estimateGas(y.toString(),i,a);o=await n.placeOrderWithSalt(y.toString(),i,a,{gasLimit:m*H[e.chainId]/100n})}let u=await o.wait();return{code:0,message:"create decrease order success",data:{success:!0,transactionHash:o.hash,blockNumber:u?.blockNumber,gasUsed:u?.gasUsed?.toString(),status:u?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:u}}}catch(a){return{code:-1,message:a?.message}}}catch(t){return{code:-1,message:t?.message}}}async cancelAllOrders(e,t){try{let n=this.configManager.getConfig(),a=this.configManager.getConfig().seamlessAccount?.authorized,i=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&a&&i){if(!await this.utils.checkSeamlessGas(n.seamlessAccount?.masterAddress,t))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let u=await F(t),y=(await Y(this.configManager.getConfig().brokerAddress,i)).interface.encodeFunctionData("cancelOrders",[e]),m=await u.nonces(i.address),l={from:i.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:y,nonce:m.toString()};this.logger.info("create decrease order forward tx params --->",l);let f=await this.seamless.forwarderTx(l,t,i);return console.log("rs-->",f),{code:0,message:"create decrease order success",data:f}}if(!n.signer)throw new g("INVALID_SIGNER","Invalid signer");return await(await(await ce(t,this.configManager.getConfig().brokerAddress)).cancelOrders(e)).wait(),{code:0,message:"cancel all orders success"}}catch(n){return{code:-1,message:n?.message}}}async cancelOrder(e,t){try{let n=this.configManager.getConfig(),a=this.configManager.getConfig().seamlessAccount?.authorized,i=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&a&&i){if(!await this.utils.checkSeamlessGas(n.seamlessAccount?.masterAddress,t))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let u=await Y(this.configManager.getConfig().brokerAddress,i),d=await F(t),y=u.interface.encodeFunctionData("cancelOrder",[BigInt(e)]),m=await d.nonces(i.address),l={from:i.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:y,nonce:m.toString()};return this.logger.info("createIncreaseOrder forward tx params --->",l),{code:0,message:"cancel order success",data:await this.seamless.forwarderTx(l,t,i)}}if(!n.signer)throw new g("INVALID_SIGNER","Invalid signer");return await(await(await ce(t,this.configManager.getConfig().brokerAddress)).cancelOrder(e)).wait(),{code:0,message:"cancel order success"}}catch(n){return{code:-1,message:n?.message}}}async cancelOrders(e,t){try{let n=this.configManager.getConfig(),a=this.configManager.getConfig().seamlessAccount?.authorized,i=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&a&&i){if(!await this.utils.checkSeamlessGas(n.seamlessAccount?.masterAddress,t))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let u=await F(t),y=(await Y(this.configManager.getConfig().brokerAddress,i)).interface.encodeFunctionData("cancelOrders",[e]),m=await u.nonces(i.address),l={from:i.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:y,nonce:m.toString()};return this.logger.info("cancel orders forward tx params --->",l),{code:0,message:"cancel orders success",data:await this.seamless.forwarderTx(l,t,i)}}if(!n.signer)throw new g("INVALID_SIGNER","Invalid signer");return await(await(await ce(t,this.configManager.getConfig().brokerAddress)).cancelOrders(e)).wait(),{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,a,i,r){let p=this.configManager.getConfig(),o=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"}},d={token:t,amount:o.toString()},y=this.configManager.getConfig().seamlessAccount?.authorized,m=this.configManager.getConfig().seamlessAccount?.wallet;if(p.seamlessMode&&y&&m){if(!await this.utils.checkSeamlessGas(p.seamlessAccount?.masterAddress,n))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let c=await Y(this.configManager.getConfig().brokerAddress,m),b=await F(n),h=c.interface.encodeFunctionData("updateOrder",[d,u]),A=await b.nonces(m.address),T={from:m.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:(0,oe.default)().add(60,"minute").unix(),data:h,nonce:A.toString()};return this.logger.info("createIncreaseOrder forward tx params --->",T),{code:0,message:"update order success",data:await this.seamless.forwarderTx(T,n,m)}}if(!p.signer)throw new g("INVALID_SIGNER","Invalid signer");let l=await ce(n,p.brokerAddress);this.logger.info("updateOrderTpSl params",u);try{if(await this.utils.needsApproval(a,n,e.executionFeeToken,o.toString(),x(n).TRADING_ROUTER)){let A=await this.utils.approveAuthorization({chainId:n,quoteAddress:e.executionFeeToken,amount:Wt.ethers.MaxUint256.toString(),spenderAddress:x(n).TRADING_ROUTER});if(A.code!==0)throw new Error(A.message)}let c=await l.updateOrder.estimateGas(d,u),h=await(await l.updateOrder(d,u,{gasLimit:c*H[n]/100n}))?.wait();return this.logger.info("updateOrderTpSl receipt",h),{code:0,data:h,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 console.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}}};var X=require("ethers");var Vt=[{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 Re=[{type:"constructor",payable:!1,inputs:[{type:"string",name:"name"},{type:"string",name:"symbol"},{type:"uint8",name:"decimals_"}]},{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:"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:"ERC2612ExpiredSignature",inputs:[{type:"uint256",name:"deadline"}]},{type:"error",name:"ERC2612InvalidSigner",inputs:[{type:"address",name:"signer"},{type:"address",name:"owner"}]},{type:"error",name:"InvalidAccountNonce",inputs:[{type:"address",name:"account"},{type:"uint256",name:"currentNonce"}]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"StringTooLong",inputs:[{type:"string",name:"str"}]},{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:"EIP712DomainChanged",inputs:[]},{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:"DOMAIN_SEPARATOR",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"bytes32"}]},{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:"decimals",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"uint8"}]},{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:"mint",constant:!1,payable:!1,inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"mintFor",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:"nonces",constant:!0,stateMutability:"view",payable:!1,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"permit",constant:!1,payable:!1,inputs:[{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:"symbol",constant:!0,stateMutability:"view",payable:!1,inputs:[],outputs:[{type:"string"}]},{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"}]}];var mt=class{constructor(e,t){this.configManager=e,this.logger=t}getOrderIdFromTransaction(e){if(!e||!e.logs)return null;let t=new X.ethers.Interface(Vt);if(!Vt.find(i=>i.type==="event"&&i.name==="OrderPlaced"))return this.logger.error("OrderPlaced event not found in Emiter ABI"),null;let a=X.ethers.id("OrderPlaced(address,address,bytes32,uint256,uint256,uint8,uint8,uint8,uint8,uint256,uint256,uint256,uint8,bool,uint16,address,uint256,uint16)");for(let i=0;i<e.logs.length;i++){let r=e.logs[i];if(this.logger.info(`Log ${i}:`,{address:r.address,topics:r.topics,data:r.data}),r.topics&&r.topics.length>0&&r.topics[0]===a)try{let p=t.parseLog({topics:r.topics,data:r.data});if(p&&p.name==="OrderPlaced"){let o=p.args[4];if(o!=null)return o.toString()}}catch(p){this.logger.error(`Error parsing log ${i}:`,p);continue}}return null}async getApproveQuoteAmount(e,t,n,a){try{let i=["function allowance(address owner, address spender) external view returns (uint256)"],r=a??x(t).Account,p=await E(t);return{code:0,data:(await new X.ethers.Contract(n,i,p).allowance(e,r)).toString()}}catch(i){throw this.logger.error("Error getting allowance:",i),typeof i=="string"?i:await I(i)}}async needsApproval(e,t,n,a,i){try{let p=(await this.getApproveQuoteAmount(e,t,n,i)).data,o=X.ethers.getBigInt(p),u=X.ethers.getBigInt(a);return o<u}catch(r){return this.logger.error("Error checking approval needs:",r),!0}}async approveAuthorization({chainId:e,quoteAddress:t,amount:n,spenderAddress:a,signer:i}){try{let r=["function approve(address spender, uint256 amount) external returns (bool)"],p=this.configManager.getConfig(),o=new X.ethers.Contract(t,r,i??p.signer),u=n??X.ethers.MaxUint256,d=a??x(e).Account,y=await this.getGasPriceByRatio(),m=await this.getGasLimitByRatio(await o.approve.estimateGas(d,u));return await(await o.approve(d,u,{gasLimit:m,gasPrice:y})).wait(),{code:0,message:"Approval success"}}catch(r){return this.logger.error("Approval error:",r),{code:-1,message:r?.message}}}async getUserTradingFeeRate(e,t,n){let a=this.configManager.getConfig(),i=a.brokerAddress;try{let r=await E(n),p=new X.ethers.Contract(i,ee,r),o=a.seamlessMode?a.seamlessAccount?.masterAddress:a.signer?.getAddress(),u=await p.getUserFeeRate(o,e,t);return{code:0,data:{takerFeeRate:u[0].toString(),makerFeeRate:u[1].toString(),baseTakerFeeRate:u[2].toString(),baseMakerFeeRate:u[3].toString()}}}catch(r){return this.logger.error("Error getting user trading fee rate:",r),{code:-1,message:r?.message}}}async getNetworkFee(e,t){let n=x(t).MARKET_MANAGER,a=await E(t),i=new X.ethers.Contract(n,be,a);try{return(await i.getExecutionFee(e)).toString()}catch(r){return this.logger.error("Error getting network fee:",r),"0"}}async getOraclePrice(e,t){try{let n=await G(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 g("PARAM_ERROR",`Invalid kline resolution: ${e}`)}}async getErrorMessage(e,t="Unknown error"){try{if(typeof e=="string")return e;if(e instanceof g)return e.message;let n=await I(e);return n?n.error:JSON.stringify(e)}catch(n){return n?.message??n?.toString()??t}}async checkSeamlessGas(e,t){let n=await E(t),a=new X.ethers.Contract(x(t).MARKET_MANAGER,be,n),i=De(t),r=await a.getForwardFeeByToken(i),p=x(t),u=await new X.ethers.Contract(p.ERC20,Re,n).balanceOf(e);return!(BigInt(r)>BigInt(0)&&BigInt(u)<BigInt(r))}async getLiquidityInfo({chainId:e,poolId:t,marketPrice:n}){try{return{code:0,data:await(await je(e)).getPoolInfo(t,n)}}catch(a){return this.logger.error("Error getting pool info:",a),{code:-1,message:a?.message}}}formatErrorMessage(e){if(typeof e=="string")return e;if(e instanceof g)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 a=Object.keys(we).find(i=>i.toLowerCase()===n);if(a)return we[a]}}return e?.reason?e.reason:e?.message?e.message:JSON.stringify(e)}async getGasPriceByRatio(){let e=this.configManager.getConfig().chainId;return(await R(e)).gasPrice}async getGasLimitByRatio(e){let t=this.configManager.getConfig().chainId,n=C[t];return P(e,n?.gasLimitRatio??1.3)}};var Z=require("ethers");var Te=[{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 ve=ne(require("dayjs"));var yt=class{constructor(e,t,n,a){this.configManager=e,this.logger=t,this.utils=n,this.client=a}async getWalletQuoteTokenBalance(e,t){let n=this.configManager.getConfig();if(!n.signer)throw new g("INVALID_SIGNER","Invalid signer");let a=x(e),i=await E(e);return{code:0,data:await new Z.ethers.Contract(a.ERC20,Re,i).balanceOf(t||n.signer.getAddress())}}async getAvailableMarginBalance({poolId:e,chainId:t,address:n}){try{let a=await this.getAccountInfo(t,n,e);if(a.code!==0)throw new g("REQUEST_FAILED","Failed to get account info");let i=a.data,r=BigInt(i.quoteProfit??0);return BigInt(i?.freeMargin??0)+r}catch{throw new g("REQUEST_FAILED","Failed to get getAvailableMarginBalance")}}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 withdraw({chainId:e,receiver:t,amount:n,poolId:a,isQuoteToken:i}){let r=this.configManager.getConfig(),p=x(e);try{let o=this.configManager.getConfig().seamlessAccount?.authorized,u=this.configManager.getConfig().seamlessAccount?.wallet;if(r.seamlessMode&&o&&u){if(!await this.utils.checkSeamlessGas(t,e))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let f=await F(e),b=new Z.ethers.Contract(p.Account,Te,u).interface.encodeFunctionData("updateAndWithdraw",[t,a,!0,n]),h=await f.nonces(u.address),A={from:u.address??"",to:p.Account,value:"0",gas:"350000",deadline:(0,ve.default)().add(60,"minute").unix(),data:b,nonce:h.toString()};return{code:0,message:"withdraw success",data:await this.client.seamless.forwarderTx(A,e,u)}}return{code:0,data:await(await new Z.ethers.Contract(p.Account,Te,r.signer).updateAndWithdraw(t,a,i,n))?.wait(1)}}catch(o){return{code:-1,message:o.message}}}async deposit({amount:e,tokenAddress:t,chainId:n}){let a=this.configManager.getConfig(),i=await a.signer?.getAddress()??"",r=x(n);try{let p=await this.utils.needsApproval(i,n,t,e,r.Account),o=this.configManager.getConfig().seamlessAccount?.authorized,u=this.configManager.getConfig().seamlessAccount?.wallet;if(a.seamlessMode&&o&&u){if(!await this.utils.checkSeamlessGas(i,n))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let f=await F(n),b=new Z.ethers.Contract(r.Account,Te,u).interface.encodeFunctionData("deposit",[i,t,e]),h=await f.nonces(u.address),A={from:u.address??"",to:r.Account,value:"0",gas:"350000",deadline:(0,ve.default)().add(60,"minute").unix(),data:b,nonce:h.toString()};return{code:0,message:"deposit success",data:await this.client.seamless.forwarderTx(A,n,u)}}if(p){let l=await this.utils.approveAuthorization({chainId:n,quoteAddress:t,amount:Z.ethers.MaxUint256.toString(),spenderAddress:r.Account});if(l.code!==0)throw new Error(l.message)}return{code:0,data:await(await new Z.ethers.Contract(r.Account,Te,a.signer).deposit(i,t,e))?.wait(1)}}catch(p){return{code:-1,message:p.message}}}async getAccountInfo(e,t,n){let a=x(e),i=await E(e),r=new Z.ethers.Contract(a.DATA_PROVIDER,Ke,i);try{return{code:0,data:await r.getAccountInfo(n,t)}}catch(p){return{code:-1,message:p.message}}}async getAccountVipInfo(e,t){let n=this.configManager.getConfig(),a=await E(e),i=new Z.ethers.Contract(n.brokerAddress,ee,a),p=((await a.getBlock("latest"))?.timestamp??(0,ve.default)().unix())+300,o=await this.configManager.getAccessToken()??"";try{let u=await this.client.api.getCurrentEpoch({address:t,accessToken:o,broker:n.brokerAddress});if(u.code!==9200)throw new g("REQUEST_FAILED",u.msg??"Failed to get current epoch");let d=await i.userFeeData(u?.data??0,t),y=await i.userNonces(t);return{code:0,data:{...d,nonce:y.toString(),deadline:p}}}catch(u){return{code:-1,message:u.message}}}async getAccountVipInfoByBackend(e,t,n,a){let i=await this.configManager.getAccessToken()??"";try{let r=await this.client.api.getAccountVipInfo({address:e,accessToken:i,chainId:t,deadline:n,nonce:a});if(r.code!==9200)throw new g("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,a,i){let r=this.configManager.getConfig(),p=this.configManager.getConfig().seamlessAccount?.authorized,o=this.configManager.getConfig().seamlessAccount?.wallet;if(n<(0,ve.default)().unix())throw new g("REQUEST_FAILED","Invalid deadline, please try again");let u={user:e,nonce:a.nonce,deadline:n,feeData:{tier:a.tier,referrer:a.referrer||Z.ethers.ZeroAddress,totalReferralRebatePct:a.totalReferralRebatePct,referrerRebatePct:a.referrerRebatePct},signature:i};try{if(r.seamlessMode&&p&&o){if(!await this.utils.checkSeamlessGas(e,t))throw new g("INSUFFICIENT_BALANCE","Insufficient relay fee");let y=await F(t),l=new Z.ethers.Contract(r.brokerAddress,Te,o).interface.encodeFunctionData("setUserFeeData",[u]),f=await y.nonces(o.address),c={from:o.address??"",to:r.brokerAddress,value:"0",gas:"350000",deadline:(0,ve.default)().add(60,"minute").unix(),data:l,nonce:f.toString()};return{code:0,data:await this.client.seamless.forwarderTx(c,t,o)}}else{let d=new Z.ethers.Contract(r.brokerAddress,ee,r.signer),y=await d.userNonces(e);if(parseInt(y.toString())+1!==parseInt(a.nonce.toString()))throw new g("REQUEST_FAILED","Invalid nonce, please try again");return{code:0,data:await(await d.setUserFeeData(u))?.wait(1)}}}catch(d){return{code:-1,message:d.message}}}};function Va(s,e){return`${encodeURIComponent(s)}=${encodeURIComponent(typeof e=="number"?e:`${e}`)}`}function js(s,e){return Va(e,s[e])}function Ys(s,e){return s[e].map(n=>Va(e,n)).join("&")}function Xs(s){let e=s||{};return Object.keys(e).filter(n=>typeof e[n]<"u").map(n=>Array.isArray(e[n])?Ys(e,n):js(e,n)).join("&")}function Ht(s){let e=Xs(s);return e?`?${e}`:""}var Ue=require("lodash-es");var ft=class{constructor(e){this._preSigner=null;this._preUserAddress=null;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(!e.signer)throw new g("INVALID_SIGNER");let t=this._preUserAddress,n=await this.configManager.getAccessToken()??"";if(e.signer!==this._preSigner&&(t=await e.signer.getAddress(),this._preUserAddress=t,this._preSigner=e.signer),!t)throw new g("INVALID_SIGNER");return{headers:{myx_openapi_access_token:n,myx_openapi_account:t}}}buildRequestPath(e){return e.startsWith("http")?e:this.getHost()+e}async get(e,t,{auth:n=!1,...a}={}){let i=n?await this.buildAuthParams():{};return w.get(this.buildRequestPath(e),t,(0,Ue.merge)(i,a))}async post(e,t,{auth:n=!1,...a}={}){let i=n?await this.buildAuthParams():{};return w.post(this.buildRequestPath(e),t,(0,Ue.merge)(i,a))}async put(e,t,{auth:n=!1,...a}={}){let i=n?await this.buildAuthParams():{};return w.put(this.buildRequestPath(e),t,(0,Ue.merge)(i,a))}async delete(e,{auth:t=!1,...n}={}){let a=t?await this.buildAuthParams():{};return w.delete(this.buildRequestPath(e),(0,Ue.merge)(a,n))}};var gt=class extends ft{constructor(e,t){super(e),this.logger=t}async getTradeFlow({accessToken:e,address:t,...n}){return w.get(`${this.getHost()}/openapi/gateway/scan/trade/flow`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getPoolSymbolAll(){return w.get(`${this.getHost()}/openapi/gateway/scan/pools`)}async fetchForwarderGetApi(e){return await w.get(`${this.getHost()}/v2/agent/forwarder/get${Ht(e)}`)}async getPoolList(){return w.get(`${this.getHost()}/openapi/gateway/scan/market/list`)}async forwarderTxApi(e,t){return w.post(`${this.getHost()}/v2/agent/forwarder/tx-v2`,e,{headers:{"myx-chain-id":t.toString()}})}async getOraclePrice(e,t=[]){if(t.length)return w.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 w.get(`${this.getHost()}/openapi/gateway/scan/market/info?chainId=${e}&poolId=${t}`)}async getPoolLevelConfig({poolId:e,chainId:t}){return w.get(`${this.getHost()}/openapi/gateway/risk/market_pool/level_config${Ht({poolId:e,chainId:t})}`)}async getPositions(e,t){return await w.get(`${this.getHost()}/openapi/gateway/scan/position/open`,void 0,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getOrders(e,t){return await w.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 w.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:a,interval:i}){return w.get(`${this.getHost()}/openapi/gateway/quote/candles`,{chainId:e,poolId:t,endTime:n,limit:a,interval:i})}async getKlineLatestBar(e){return w.get(`${this.getHost()}/openapi/gateway/quote/candle/latest`,e)}async getTickerData({chainId:e,poolIds:t}){return w.get(`${this.getHost()}/openapi/gateway/quote/candle/tickers`,{chainId:e,poolIds:t.join(",")})}async getAllTickers(){return w.get(`${this.getHost()}/v2/mx-gateway/quote/candle/all_tickers`)}async searchMarketAuth({accessToken:e,address:t,...n}){return w.get(`${this.getHost()}/openapi/gateway/scan/market/ac-search`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async searchMarket({...e}){return w.get(`${this.getHost()}/openapi/gateway/scan/market/search`,e)}async addFavorite({accessToken:e,address:t,...n}){return w.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 w.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 w.get(`${this.getHost()}/openapi/gateway/scan/market/favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getBaseDetail({...e}){return w.get(`${this.getHost()}/openapi/gateway/scan/market/base-details`,e)}async getMarketDetail({...e}){return w.get(`${this.getHost()}/openapi/gateway/scan/market/detail`,e)}async getHistoryOrders({accessToken:e,address:t,...n}){return w.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 w.get(`${this.getHost()}/openapi/gateway/scan/position/closed`,n,{headers:{myx_openapi_account:t,myx_openapi_access_token:e}})}async getMarketList(){return w.get(`${this.getHost()}/openapi/gateway/scan/market`)}async getAccountVipInfo({address:e,accessToken:t,chainId:n,deadline:a,nonce:i}){return w.get(`${this.getHost()}/openapi/gateway/vip/trade_config`,{chainId:n,deadline:a,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 w.get(`${this.getHost()}/openapi/gateway/scan/get-current-epoch`,{broker:n},{headers:{myx_openapi_account:e,myx_openapi_access_token:t}})}};var _=ne(require("crypto-js"));var D=require("ethers");var Qa=ne(require("dayjs"));var Ha=async s=>{try{let e=await s.eip712Domain();return console.log("eip712Domain-->",e.name),console.log("eip712Domain.version-->",e.version),{name:e.name,version:e.version,chainId:BigInt(e.chainId),verifyingContract:e.verifyingContract}}catch(e){throw new Error(`Error fetching EIP712 domain: ${e}`)}};var Ka=require("@ethersproject/bytes");var Zs={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"}]},ei=2,ti=async s=>{let t=new TextEncoder().encode(s),n=await window.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")},ni="jAkBlC4~5!6@#$%^",ai=s=>{let e=(0,D.toUtf8Bytes)(s),t=(0,D.keccak256)(e),n=(0,D.getBytes)(t),a=(0,D.hexlify)(n);if(!(0,D.isHexString)(a,32))throw new g("INVALID_PRIVATE_KEY","Invalid private key generated");let i=new D.ethers.Wallet(a);return{privateKey:a,wallet:i}},bt=s=>{if(s.length>=16)return s;let t=16-s.length,n=Math.ceil(t/s.length),a=s.repeat(n).slice(0,t);return s+a},It=()=>_.default.enc.Utf8.parse(ni);async function si(s,e,t,n,a,i,r){let p=await Ha(e),o={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u={owner:t,spender:n,value:a,nonce:i,deadline:r},d=await s.signTypedData(p,o,u),{v:y,r:m,s:l}=(0,Ka.splitSignature)(d);return{v:y,r:m,s:l}}var ht=class{constructor(e,t,n,a,i){this.configManager=e,this.logger=t,this.utils=n,this.account=a,this.api=i}async onCheckRelayer(e,t,n){return await(await F(n)).isUserRelayerEnabled(e,t)}async getUSDPermitParams(e,t){let n=this.configManager.getConfig();if(!n.signer)throw new g("INVALID_SIGNER","Signer is required for permit");let a=x(t),i=await n.signer.getAddress(),r=new D.ethers.Contract(a.ERC20,Re,n.signer);try{let p=await r.nonces(i),o=await si(n.signer,r,i,a.TRADING_ROUTER,D.ethers.MaxUint256.toString(),p.toString(),e.toString());return[{token:a.ERC20,owner:i,spender:a.TRADING_ROUTER,value:D.ethers.MaxUint256.toString(),deadline:e.toString(),v:o.v,r:o.r,s:o.s}]}catch{throw new g("INVALID_PRIVATE_KEY","Invalid private key generated")}}async forwarderTx({from:e,to:t,value:n,gas:a,deadline:i,data:r,nonce:p},o,u){let y=await(await F(o)).eip712Domain(),m={name:y.name,version:y.version,chainId:y.chainId,verifyingContract:y.verifyingContract},f=await(u??await W(o)).signTypedData(m,Zs,{from:e,to:t,value:n,gas:a,nonce:p,deadline:i,data:r}),c=De(o);return this.logger.info("forwarderTx-->",{from:e,to:t,value:n,gas:a,nonce:p,data:r,deadline:i,signature:f,forwardFeeToken:c},o),await this.api.forwarderTxApi({from:e,to:t,value:n,gas:a,nonce:p,data:r,deadline:i,signature:f,forwardFeeToken:c},o)}async authorizeSeamlessAccount({approve:e,seamlessAddress:t,chainId:n}){let i=await this.configManager.getConfig().signer?.getAddress()??"",r=E(n);if(e){let f=await this.account.getWalletQuoteTokenBalance(n,i);this.logger.info("balanceRes-->",f);let c=f.data,b=new D.ethers.Contract(x(n).MARKET_MANAGER,be,r),h=De(n);this.logger.info("forwardFeeToken-->",h);let A=await b.getForwardFeeByToken(h);this.logger.info("pledgeFee-->",A);let T=BigInt(A)*BigInt(ei);if(this.logger.info("auth params-->",{gasFee:T,balance:c},n,h),this.logger.info("gasFee > 0 && gasFee > BigInt(balance)-->",T>0&&T>BigInt(c)),T>0&&T>BigInt(c))throw new g("INSUFFICIENT_BALANCE","Insufficient balance")}let p=(0,Qa.default)().add(60,"minute").unix(),o=[];if(e)try{o=await this.getUSDPermitParams(p,n)}catch(f){console.log("error-->",f),console.warn("Failed to get USD permit params, proceeding without permit:",f),o=[]}let u=await F(n,1),y=await new D.ethers.Contract(x(n).FORWARDER,$e,r).nonces(i),m=u.interface.encodeFunctionData("permitAndApproveForwarder",[t,e,o]),l=await this.forwarderTx({from:i,to:u?.target,value:"0",gas:"800000",nonce:y.toString(),data:m,deadline:p},n);if(l.data?.txHash){for(let b=0;b<5;b++)try{if((await this.api.fetchForwarderGetApi({requestId:l.data.requestId})).data?.status===9)return{code:0,data:{seamlessAccount:t,authorized:e}};b<4&&await new Promise(A=>setTimeout(A,1e3))}catch(h){console.error("Poll transaction from chain error:",h),b<4&&await new Promise(A=>setTimeout(A,1e3))}return{code:-1,data:null,message:"Transaction confirmation timeout, please check later"}}else return console.log("txRs-->",l),{code:-1,data:null,message:"Your request timed out, please try again"}}async unLockSeamlessWallet({masterAddress:e,password:t,apiKey:n,chainId:a}){let i=_.default.enc.Utf8.parse(bt(t)),r=It(),o=_.default.AES.decrypt(n,i,{iv:r,mode:_.default.mode.CBC,padding:_.default.pad.Pkcs7}).toString(_.default.enc.Utf8),u=new D.ethers.Wallet(o),d=await this.onCheckRelayer(e,u.address,a);return d||(await this.authorizeSeamlessAccount({approve:!0,seamlessAddress:u.address,chainId:a}),d=!0),this.configManager.updateSeamlessWallet({masterAddress:e,wallet:u,authorized:d}),{code:0,data:{masterAddress:e,seamlessAccount:u.address,authorized:d}}}async exportSeamlessPrivateKey({password:e,apiKey:t}){let n=_.default.enc.Utf8.parse(bt(e)),a=It(),r=_.default.AES.decrypt(t,n,{iv:a,mode:_.default.mode.CBC,padding:_.default.pad.Pkcs7}).toString(_.default.enc.Utf8);if(new D.ethers.Wallet(r).address!==this.configManager.getConfig().seamlessAccount?.wallet?.address)throw new g("INVALID_PRIVATE_KEY","Invalid private key");return{code:0,data:{privateKey:r}}}async importSeamlessPrivateKey({privateKey:e,password:t,chainId:n}){if(!D.ethers.isHexString(e,32))throw new g("INVALID_PRIVATE_KEY","Invalid private key");let a=new D.ethers.Wallet(e),r=await(await F(n)).originAccount(a.address);if(r===D.ZeroAddress)throw new g("INVALID_PRIVATE_KEY","The private key is not a senseless account");let p=await this.onCheckRelayer(r,a.address,n),o=_.default.enc.Utf8.parse(bt(t)),u=It(),y=_.default.AES.encrypt(e,o,{iv:u,mode:_.default.mode.CBC,padding:_.default.pad.Pkcs7}).toString();return this.configManager.updateSeamlessWallet({masterAddress:r,wallet:a,authorized:p}),{code:0,data:{masterAddress:r,seamlessAccount:a.address,authorized:p,apiKey:y}}}async startSeamlessMode({open:e}){return await this.configManager.startSeamlessMode(e),{code:0,data:{open:e}}}async createSeamless({password:e,chainId:t}){let a=this.configManager.getConfig().signer,i=await a?.getAddress()??"";if(!a)throw new g("INVALID_SIGNER","Invalid signer");try{let r=await a.signMessage(`${i}_${e}`),p=await ti(r),{privateKey:o,wallet:u}=ai(p),d=_.default.enc.Utf8.parse(bt(e)),y=It(),l=_.default.AES.encrypt(o,d,{iv:y,mode:_.default.mode.CBC,padding:_.default.pad.Pkcs7}).toString(),f=await this.onCheckRelayer(i,u.address,t);return this.configManager.updateSeamlessWallet({masterAddress:i,wallet:u,authorized:f}),{code:0,data:{masterAddress:i,seamlessAccount:u.address,authorized:f,apiKey:l}}}catch(r){return{code:-1,message:r.message}}}};var Ee=class{constructor(e){this.client=e}getConfig(){return this.client.getConfigManager()?.getConfig()}async getSigner(){let e=this.getConfig();if(!e?.signer)throw new g("INVALID_SIGNER","Invalid signer");return e.signer}getAddressConfig(){let t=this.getConfig()?.chainId;if(!t||!ze(t))throw new g("INVALID_CHAIN_ID","Invalid chain id");return x(t)}async connectContract(e){return e.connect(await this.getSigner())}async getBrokerContract(){let e=this.getConfig();if(!e?.brokerAddress)throw new g("INVALID_BROKER_ADDRESS","Invalid broker address");return Wn(e.chainId,e.brokerAddress)}get config(){return this.getConfig()}};var xt=class extends Ee{constructor(e){super(e)}async getDisputeCourtContract(e=!0){let t=await Qn(this.config.chainId);return e?this.connectContract(t):t}async getReimbursementContract(e=!0){let t=await Hn(this.config.chainId);return e?this.connectContract(t):t}async submitAppeal(e,t,n){let a=await this.config.signer?.getAddress()??"",i=await this.client.utils.needsApproval(a,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),o=BigInt(p[0].value.toString()||"1"),u=await r.fileDispute.estimateGas(p,e,t,{value:o});this.client.logger.debug("_gasLimit",u);let d=await this.client.utils.getGasLimitByRatio(u),y=await this.client.utils.getGasPriceByRatio();this.client.logger.debug("txParams",{gasLimit:d,gasPrice:y,value:o});let l=await(await r.fileDispute(p,e,t,{value:o,gasLimit:d,gasPrice:y})).wait(),f=l?.logs.find(b=>b.eventName==="DisputeFiled");if(!f||!l)throw new g("TRANSACTION_FAILED","DisputeFiledLog not found");let c=f.args.getValue("caseId");return this.client.logger.debug("caseId",c),this.client.logger.debug("event",f),{transaction:l,caseId:c}}async voteForAppeal({caseId:e,validator:t,isFor:n,deadline:a,v:i,r,s:p}){let o=await this.getDisputeCourtContract(),u=await o.vote.estimateGas(e,t,n?1:0,a,i,r,p),d=await this.client.utils.getGasLimitByRatio(u),y=await this.client.utils.getGasPriceByRatio();return await(await o.vote(e,t,n?1:0,a,i,r,p,{gasLimit:d,gasPrice:y})).wait()}async claimAppealMargin(e){let t=await this.getDisputeCourtContract(),n=await t.claimBond.estimateGas(e),a=await this.client.utils.getGasLimitByRatio(n),i=await this.client.utils.getGasPriceByRatio();return await(await t.claimBond(e,{gasLimit:a,gasPrice:i})).wait()}async claimReimbursement(e,t,n,a){let i=await this.getReimbursementContract(),r=await i.claimReimbursement.estimateGas(e,t,n,a),p=await this.client.utils.getGasLimitByRatio(r),o=await this.client.utils.getGasPriceByRatio();return await(await i.claimReimbursement(e,t,n,a,{gasLimit:p,gasPrice:o})).wait()}async getDisputeConfiguration(){return await(await this.getDisputeCourtContract(!1)).getDisputeConfiguration()}async submitAppealByVoteNode(e,t,n){let a=await this.getDisputeCourtContract(),i=await this.client.utils.getGasPriceByRatio(),r=await this.client.utils.getGasLimitByRatio(await a.fileDisputeFromStaker.estimateGas(e,t,n)),o=await(await a.fileDisputeFromStaker(e,t,n,{gasLimit:r,gasPrice:i})).wait(),u=o?.logs.find(y=>y.eventName==="DisputeFiled");if(!u||!o)throw new g("TRANSACTION_FAILED","DisputeFiledLog not found");let d=u.args.getValue("caseId");return{tx:o,caseId:d}}async appealReconsideration(e,t,n){let a=await this.getDisputeCourtContract(),i=await this.config.signer?.getAddress()??"",r=this.getAddressConfig().DISPUTE_COURT;if(await this.client.utils.needsApproval(i,this.config.chainId,t,n,r)){let c=await this.client.utils.approveAuthorization({chainId:this.config.chainId,quoteAddress:t,spenderAddress:r});if(c.code!==0)throw new g("TRANSACTION_FAILED",c.message)}let o=await a.appeal.estimateGas(e),u=await this.client.utils.getGasLimitByRatio(o),d=await this.client.utils.getGasPriceByRatio(),m=await(await a.appeal(e,{gasLimit:u,gasPrice:d})).wait(),l=m?.logs.find(c=>c.eventName==="AppealFiled");if(!l||!m)throw new g("TRANSACTION_FAILED","AppealFiledLog not found");let f=l.args.getValue("appealCaseId");return{tx:m,appealCaseId:f,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()}};var At=class extends Ee{constructor(e){super(e)}async claimRebate(e){let t=await this.connectContract(await this.getBrokerContract()),n=await t.claimRebate.estimateGas(e),a=await this.client.utils.getGasLimitByRatio(n),i=await this.client.utils.getGasPriceByRatio();return await(await t.claimRebate(e,{gasPrice:i,gasLimit:a})).wait()}};var $a=(o=>(o[o.UnderReview=1]="UnderReview",o[o.InitialVote=2]="InitialVote",o[o.PublicNotice=3]="PublicNotice",o[o.UnderReconsideration=4]="UnderReconsideration",o[o.Won=5]="Won",o[o.Failed=6]="Failed",o[o.PlatformRuling=7]="PlatformRuling",o[o.PlatformRevoked=8]="PlatformRevoked",o))($a||{}),Ja=(d=>(d[d.InitialVoting=1]="InitialVoting",d[d.PublicNotice=2]="PublicNotice",d[d.UnderReconsideration=3]="UnderReconsideration",d[d.Won=5]="Won",d[d.Failed=4]="Failed",d[d.PlatformRuling=6]="PlatformRuling",d[d.PlatformRevoked=7]="PlatformRevoked",d[d.ReconsiderationVoting=8]="ReconsiderationVoting",d[d.AppealRevert=9]="AppealRevert",d[d.NotAppealFailed=10]="NotAppealFailed",d))(Ja||{}),ja=(a=>(a[a.UnderReview=1]="UnderReview",a[a.PublicNotice=2]="PublicNotice",a[a.UnderReconsideration=3]="UnderReconsideration",a[a.Completed=4]="Completed",a))(ja||{}),Ya=(t=>(t[t.ElectionNode=0]="ElectionNode",t[t.OfficialNode=1]="OfficialNode",t))(Ya||{}),Xa=(t=>(t[t.Reject=0]="Reject",t[t.Support=1]="Support",t))(Xa||{}),Za=(t=>(t[t.UnClaimed=0]="UnClaimed",t[t.Claimed=1]="Claimed",t))(Za||{}),es=(t=>(t[t.NotVoted=0]="NotVoted",t[t.Voted=1]="Voted",t))(es||{}),ts=(t=>(t[t.Appeal=1]="Appeal",t[t.Reconsideration=2]="Reconsideration",t))(ts||{}),ns=(n=>(n[n.NoVote=0]="NoVote",n[n.Supported=1]="Supported",n[n.Rejected=2]="Rejected",n))(ns||{}),as=(t=>(t[t.Yes=1]="Yes",t[t.No=0]="No",t))(as||{});var wt=class{getConfigManager(){return this.configManager}constructor(e){this.configManager=new ut(e),this.logger=new Pe({logLevel:e.logLevel});let t=ue.getInstance();t.setConfigManager(this.configManager),t.getMarkets().then(),this.utils=new mt(this.configManager,this.logger),this.api=new gt(this.configManager,this.logger),this.account=new yt(this.configManager,this.logger,this.utils,this),this.seamless=new ht(this.configManager,this.logger,this.utils,this.account,this.api),this.markets=new dt(this.configManager,this.utils,this.api),this.position=new ct(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.order=new lt(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.subscription=new pt(this.configManager,this.logger),this.appeal=new xt(this),this.referrals=new At(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)}};0&&(module.exports={AppealCaseTypeEnum,AppealClaimStatusEnum,AppealNodeStateEnum,AppealNodeVotedStateEnum,AppealReconsiderationType,AppealStage,AppealType,COMMON_LP_AMOUNT_DECIMALS,COMMON_PRICE_DECIMALS,ChainId,CloseTypeEnum,Direction,DirectionEnum,ErrorCode,ExecTypeEnum,ForwarderGetStatus,HttpKlineIntervalEnum,IsVoteNodeEnum,MarketCapType,MarketPoolState,MarketType,MxSDK,MyxClient,NodeTypeEnum,OperationEnum,OperationType,OracleType,OrderStatus,OrderStatusEnum,OrderType,OrderTypeEnum,SearchSecondTypeEnum,SearchTypeEnum,TimeInForce,TradeFlowAccountTypeEnum,TradeFlowTypeEnum,TriggerType,TriggerTypeEnum,VoteTypeEnum,approve,base,bigintAmountSlipperCalculator,bigintTradingGasPriceWithRatio,bigintTradingGasToRatioCalculator,formatUnits,getAllowanceApproved,getBalanceOf,getBaseDetail,getBaseUrlByEnv,getMarketDetail,getMarketList,getOraclePrice,getPoolDetail,getPoolList,getPoolOpenOrders,getPriceData,getPricesData,getTickerData,getTokenInfo,market,parseUnits,pool,quote});
|
|
2
|
-
/**
|
|
1
|
+
'use strict';var ethers=require('ethers'),bytes=require('@ethersproject/bytes'),c1=require('wretch'),ethersDecodeError=require('ethers-decode-error'),pv=require('mitt'),lv=require('reconnecting-websocket'),Or=require('dayjs');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var c1__default=/*#__PURE__*/_interopDefault(c1);var pv__default=/*#__PURE__*/_interopDefault(pv);var lv__default=/*#__PURE__*/_interopDefault(lv);var Or__default=/*#__PURE__*/_interopDefault(Or);var _m=Object.create;var ls=Object.defineProperty;var Tm=Object.getOwnPropertyDescriptor;var km=Object.getOwnPropertyNames;var Bm=Object.getPrototypeOf,Sm=Object.prototype.hasOwnProperty;var _u=r=>{throw TypeError(r)};var na=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var ee=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Na=(r,e)=>{for(var t in e)ls(r,t,{get:e[t],enumerable:true});},Dm=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of km(e))!Sm.call(r,a)&&a!==t&&ls(r,a,{get:()=>e[a],enumerable:!(n=Tm(e,a))||n.enumerable});return r};var wr=(r,e,t)=>(t=r!=null?_m(Bm(r)):{},Dm(!r||!r.__esModule?ls(t,"default",{value:r,enumerable:true}):t,r));var Tu=(r,e,t)=>e.has(r)||_u("Cannot "+t);var ku=(r,e,t)=>(Tu(r,e,"read from private field"),t?t.call(r):e.get(r)),Bu=(r,e,t)=>e.has(r)?_u("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),Su=(r,e,t,n)=>(Tu(r,e,"write to private field"),e.set(r,t),t);var bs=ee((fp,xs)=>{(function(r,e){function t(R,u){if(!R)throw new Error(u||"Assertion failed")}function n(R,u){R.super_=u;var m=function(){};m.prototype=u.prototype,R.prototype=new m,R.prototype.constructor=R;}function a(R,u,m){if(a.isBN(R))return R;this.negative=0,this.words=null,this.length=0,this.red=null,R!==null&&((u==="le"||u==="be")&&(m=u,u=10),this._init(R||0,u||10,m||"be"));}typeof r=="object"?r.exports=a:e.BN=a,a.BN=a,a.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=na("buffer").Buffer;}catch{}a.isBN=function(u){return u instanceof a?true:u!==null&&typeof u=="object"&&u.constructor.wordSize===a.wordSize&&Array.isArray(u.words)},a.max=function(u,m){return u.cmp(m)>0?u:m},a.min=function(u,m){return u.cmp(m)<0?u:m},a.prototype._init=function(u,m,b){if(typeof u=="number")return this._initNumber(u,m,b);if(typeof u=="object")return this._initArray(u,m,b);m==="hex"&&(m=16),t(m===(m|0)&&m>=2&&m<=36),u=u.toString().replace(/\s+/g,"");var C=0;u[0]==="-"&&(C++,this.negative=1),C<u.length&&(m===16?this._parseHex(u,C,b):(this._parseBase(u,m,C),b==="le"&&this._initArray(this.toArray(),m,b)));},a.prototype._initNumber=function(u,m,b){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(t(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),m,b);},a.prototype._initArray=function(u,m,b){if(t(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var P,I,k=0;if(b==="be")for(C=u.length-1,P=0;C>=0;C-=3)I=u[C]|u[C-1]<<8|u[C-2]<<16,this.words[P]|=I<<k&67108863,this.words[P+1]=I>>>26-k&67108863,k+=24,k>=26&&(k-=26,P++);else if(b==="le")for(C=0,P=0;C<u.length;C+=3)I=u[C]|u[C+1]<<8|u[C+2]<<16,this.words[P]|=I<<k&67108863,this.words[P+1]=I>>>26-k&67108863,k+=24,k>=26&&(k-=26,P++);return this._strip()};function o(R,u){var m=R.charCodeAt(u);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;t(false,"Invalid character in "+R);}function s(R,u,m){var b=o(R,m);return m-1>=u&&(b|=o(R,m-1)<<4),b}a.prototype._parseHex=function(u,m,b){this.length=Math.ceil((u.length-m)/6),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var P=0,I=0,k;if(b==="be")for(C=u.length-1;C>=m;C-=2)k=s(u,m,C)<<P,this.words[I]|=k&67108863,P>=18?(P-=18,I+=1,this.words[I]|=k>>>26):P+=8;else {var A=u.length-m;for(C=A%2===0?m+1:m;C<u.length;C+=2)k=s(u,m,C)<<P,this.words[I]|=k&67108863,P>=18?(P-=18,I+=1,this.words[I]|=k>>>26):P+=8;}this._strip();};function p(R,u,m,b){for(var C=0,P=0,I=Math.min(R.length,m),k=u;k<I;k++){var A=R.charCodeAt(k)-48;C*=b,A>=49?P=A-49+10:A>=17?P=A-17+10:P=A,t(A>=0&&P<b,"Invalid character"),C+=P;}return C}a.prototype._parseBase=function(u,m,b){this.words=[0],this.length=1;for(var C=0,P=1;P<=67108863;P*=m)C++;C--,P=P/m|0;for(var I=u.length-b,k=I%C,A=Math.min(I,I-k)+b,d=0,T=b;T<A;T+=C)d=p(u,T,T+C,m),this.imuln(P),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(k!==0){var K=1;for(d=p(u,T,u.length,m),T=0;T<k;T++)K*=m;this.imuln(K),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);}this._strip();},a.prototype.copy=function(u){u.words=new Array(this.length);for(var m=0;m<this.length;m++)u.words[m]=this.words[m];u.length=this.length,u.negative=this.negative,u.red=this.red;};function c(R,u){R.words=u.words,R.length=u.length,R.negative=u.negative,R.red=u.red;}if(a.prototype._move=function(u){c(u,this);},a.prototype.clone=function(){var u=new a(null);return this.copy(u),u},a.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=l;}catch{a.prototype.inspect=l;}else a.prototype.inspect=l;function l(){return (this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];a.prototype.toString=function(u,m){u=u||10,m=m|0||1;var b;if(u===16||u==="hex"){b="";for(var C=0,P=0,I=0;I<this.length;I++){var k=this.words[I],A=((k<<C|P)&16777215).toString(16);P=k>>>24-C&16777215,C+=2,C>=26&&(C-=26,I--),P!==0||I!==this.length-1?b=f[6-A.length]+A+b:b=A+b;}for(P!==0&&(b=P.toString(16)+b);b.length%m!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(u===(u|0)&&u>=2&&u<=36){var d=h[u],T=y[u];b="";var K=this.clone();for(K.negative=0;!K.isZero();){var g=K.modrn(T).toString(u);K=K.idivn(T),K.isZero()?b=g+b:b=f[d-g.length]+g+b;}for(this.isZero()&&(b="0"+b);b.length%m!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}t(false,"Base should be between 2 and 36");},a.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&t(false,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},a.prototype.toJSON=function(){return this.toString(16,2)},i&&(a.prototype.toBuffer=function(u,m){return this.toArrayLike(i,u,m)}),a.prototype.toArray=function(u,m){return this.toArrayLike(Array,u,m)};var x=function(u,m){return u.allocUnsafe?u.allocUnsafe(m):new u(m)};a.prototype.toArrayLike=function(u,m,b){this._strip();var C=this.byteLength(),P=b||Math.max(1,C);t(C<=P,"byte array longer than desired length"),t(P>0,"Requested array length <= 0");var I=x(u,P),k=m==="le"?"LE":"BE";return this["_toArrayLike"+k](I,C),I},a.prototype._toArrayLikeLE=function(u,m){for(var b=0,C=0,P=0,I=0;P<this.length;P++){var k=this.words[P]<<I|C;u[b++]=k&255,b<u.length&&(u[b++]=k>>8&255),b<u.length&&(u[b++]=k>>16&255),I===6?(b<u.length&&(u[b++]=k>>24&255),C=0,I=0):(C=k>>>24,I+=2);}if(b<u.length)for(u[b++]=C;b<u.length;)u[b++]=0;},a.prototype._toArrayLikeBE=function(u,m){for(var b=u.length-1,C=0,P=0,I=0;P<this.length;P++){var k=this.words[P]<<I|C;u[b--]=k&255,b>=0&&(u[b--]=k>>8&255),b>=0&&(u[b--]=k>>16&255),I===6?(b>=0&&(u[b--]=k>>24&255),C=0,I=0):(C=k>>>24,I+=2);}if(b>=0)for(u[b--]=C;b>=0;)u[b--]=0;},Math.clz32?a.prototype._countBits=function(u){return 32-Math.clz32(u)}:a.prototype._countBits=function(u){var m=u,b=0;return m>=4096&&(b+=13,m>>>=13),m>=64&&(b+=7,m>>>=7),m>=8&&(b+=4,m>>>=4),m>=2&&(b+=2,m>>>=2),b+m},a.prototype._zeroBits=function(u){if(u===0)return 26;var m=u,b=0;return (m&8191)===0&&(b+=13,m>>>=13),(m&127)===0&&(b+=7,m>>>=7),(m&15)===0&&(b+=4,m>>>=4),(m&3)===0&&(b+=2,m>>>=2),(m&1)===0&&b++,b},a.prototype.bitLength=function(){var u=this.words[this.length-1],m=this._countBits(u);return (this.length-1)*26+m};function w(R){for(var u=new Array(R.bitLength()),m=0;m<u.length;m++){var b=m/26|0,C=m%26;u[m]=R.words[b]>>>C&1;}return u}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,m=0;m<this.length;m++){var b=this._zeroBits(this.words[m]);if(u+=b,b!==26)break}return u},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},a.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var m=0;m<u.length;m++)this.words[m]=this.words[m]|u.words[m];return this._strip()},a.prototype.ior=function(u){return t((this.negative|u.negative)===0),this.iuor(u)},a.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},a.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},a.prototype.iuand=function(u){var m;this.length>u.length?m=u:m=this;for(var b=0;b<m.length;b++)this.words[b]=this.words[b]&u.words[b];return this.length=m.length,this._strip()},a.prototype.iand=function(u){return t((this.negative|u.negative)===0),this.iuand(u)},a.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},a.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},a.prototype.iuxor=function(u){var m,b;this.length>u.length?(m=this,b=u):(m=u,b=this);for(var C=0;C<b.length;C++)this.words[C]=m.words[C]^b.words[C];if(this!==m)for(;C<m.length;C++)this.words[C]=m.words[C];return this.length=m.length,this._strip()},a.prototype.ixor=function(u){return t((this.negative|u.negative)===0),this.iuxor(u)},a.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},a.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},a.prototype.inotn=function(u){t(typeof u=="number"&&u>=0);var m=Math.ceil(u/26)|0,b=u%26;this._expand(m),b>0&&m--;for(var C=0;C<m;C++)this.words[C]=~this.words[C]&67108863;return b>0&&(this.words[C]=~this.words[C]&67108863>>26-b),this._strip()},a.prototype.notn=function(u){return this.clone().inotn(u)},a.prototype.setn=function(u,m){t(typeof u=="number"&&u>=0);var b=u/26|0,C=u%26;return this._expand(b+1),m?this.words[b]=this.words[b]|1<<C:this.words[b]=this.words[b]&~(1<<C),this._strip()},a.prototype.iadd=function(u){var m;if(this.negative!==0&&u.negative===0)return this.negative=0,m=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,m=this.isub(u),u.negative=1,m._normSign();var b,C;this.length>u.length?(b=this,C=u):(b=u,C=this);for(var P=0,I=0;I<C.length;I++)m=(b.words[I]|0)+(C.words[I]|0)+P,this.words[I]=m&67108863,P=m>>>26;for(;P!==0&&I<b.length;I++)m=(b.words[I]|0)+P,this.words[I]=m&67108863,P=m>>>26;if(this.length=b.length,P!==0)this.words[this.length]=P,this.length++;else if(b!==this)for(;I<b.length;I++)this.words[I]=b.words[I];return this},a.prototype.add=function(u){var m;return u.negative!==0&&this.negative===0?(u.negative=0,m=this.sub(u),u.negative^=1,m):u.negative===0&&this.negative!==0?(this.negative=0,m=u.sub(this),this.negative=1,m):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},a.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var m=this.iadd(u);return u.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var b=this.cmp(u);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var C,P;b>0?(C=this,P=u):(C=u,P=this);for(var I=0,k=0;k<P.length;k++)m=(C.words[k]|0)-(P.words[k]|0)+I,I=m>>26,this.words[k]=m&67108863;for(;I!==0&&k<C.length;k++)m=(C.words[k]|0)+I,I=m>>26,this.words[k]=m&67108863;if(I===0&&k<C.length&&C!==this)for(;k<C.length;k++)this.words[k]=C.words[k];return this.length=Math.max(this.length,k),C!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(u){return this.clone().isub(u)};function _(R,u,m){m.negative=u.negative^R.negative;var b=R.length+u.length|0;m.length=b,b=b-1|0;var C=R.words[0]|0,P=u.words[0]|0,I=C*P,k=I&67108863,A=I/67108864|0;m.words[0]=k;for(var d=1;d<b;d++){for(var T=A>>>26,K=A&67108863,g=Math.min(d,u.length-1),F=Math.max(0,d-R.length+1);F<=g;F++){var O=d-F|0;C=R.words[O]|0,P=u.words[F]|0,I=C*P+K,T+=I/67108864|0,K=I&67108863;}m.words[d]=K|0,A=T|0;}return A!==0?m.words[d]=A|0:m.length--,m._strip()}var v=function(u,m,b){var C=u.words,P=m.words,I=b.words,k=0,A,d,T,K=C[0]|0,g=K&8191,F=K>>>13,O=C[1]|0,q=O&8191,Q=O>>>13,X=C[2]|0,j=X&8191,V=X>>>13,Ee=C[3]|0,J=Ee&8191,te=Ee>>>13,Pt=C[4]|0,we=Pt&8191,be=Pt>>>13,it=C[5]|0,pe=it&8191,he=it>>>13,kt=C[6]|0,Ie=kt&8191,ge=kt>>>13,Rt=C[7]|0,De=Rt&8191,Pe=Rt>>>13,$t=C[8]|0,xe=$t&8191,ve=$t>>>13,gr=C[9]|0,Re=gr&8191,_e=gr>>>13,xr=P[0]|0,Me=xr&8191,Te=xr>>>13,br=P[1]|0,ke=br&8191,Fe=br>>>13,er=P[2]|0,Ne=er&8191,Oe=er>>>13,vr=P[3]|0,Be=vr&8191,Le=vr>>>13,Ar=P[4]|0,Se=Ar&8191,Ue=Ar>>>13,tr=P[5]|0,ue=tr&8191,ye=tr>>>13,rr=P[6]|0,qe=rr&8191,ze=rr>>>13,an=P[7]|0,He=an&8191,We=an>>>13,on=P[8]|0,Ke=on&8191,Qe=on>>>13,sn=P[9]|0,Ve=sn&8191,je=sn>>>13;b.negative=u.negative^m.negative,b.length=19,A=Math.imul(g,Me),d=Math.imul(g,Te),d=d+Math.imul(F,Me)|0,T=Math.imul(F,Te);var Ur=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,A=Math.imul(q,Me),d=Math.imul(q,Te),d=d+Math.imul(Q,Me)|0,T=Math.imul(Q,Te),A=A+Math.imul(g,ke)|0,d=d+Math.imul(g,Fe)|0,d=d+Math.imul(F,ke)|0,T=T+Math.imul(F,Fe)|0;var qr=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(qr>>>26)|0,qr&=67108863,A=Math.imul(j,Me),d=Math.imul(j,Te),d=d+Math.imul(V,Me)|0,T=Math.imul(V,Te),A=A+Math.imul(q,ke)|0,d=d+Math.imul(q,Fe)|0,d=d+Math.imul(Q,ke)|0,T=T+Math.imul(Q,Fe)|0,A=A+Math.imul(g,Ne)|0,d=d+Math.imul(g,Oe)|0,d=d+Math.imul(F,Ne)|0,T=T+Math.imul(F,Oe)|0;var Gr=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,A=Math.imul(J,Me),d=Math.imul(J,Te),d=d+Math.imul(te,Me)|0,T=Math.imul(te,Te),A=A+Math.imul(j,ke)|0,d=d+Math.imul(j,Fe)|0,d=d+Math.imul(V,ke)|0,T=T+Math.imul(V,Fe)|0,A=A+Math.imul(q,Ne)|0,d=d+Math.imul(q,Oe)|0,d=d+Math.imul(Q,Ne)|0,T=T+Math.imul(Q,Oe)|0,A=A+Math.imul(g,Be)|0,d=d+Math.imul(g,Le)|0,d=d+Math.imul(F,Be)|0,T=T+Math.imul(F,Le)|0;var zr=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(zr>>>26)|0,zr&=67108863,A=Math.imul(we,Me),d=Math.imul(we,Te),d=d+Math.imul(be,Me)|0,T=Math.imul(be,Te),A=A+Math.imul(J,ke)|0,d=d+Math.imul(J,Fe)|0,d=d+Math.imul(te,ke)|0,T=T+Math.imul(te,Fe)|0,A=A+Math.imul(j,Ne)|0,d=d+Math.imul(j,Oe)|0,d=d+Math.imul(V,Ne)|0,T=T+Math.imul(V,Oe)|0,A=A+Math.imul(q,Be)|0,d=d+Math.imul(q,Le)|0,d=d+Math.imul(Q,Be)|0,T=T+Math.imul(Q,Le)|0,A=A+Math.imul(g,Se)|0,d=d+Math.imul(g,Ue)|0,d=d+Math.imul(F,Se)|0,T=T+Math.imul(F,Ue)|0;var Hr=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,A=Math.imul(pe,Me),d=Math.imul(pe,Te),d=d+Math.imul(he,Me)|0,T=Math.imul(he,Te),A=A+Math.imul(we,ke)|0,d=d+Math.imul(we,Fe)|0,d=d+Math.imul(be,ke)|0,T=T+Math.imul(be,Fe)|0,A=A+Math.imul(J,Ne)|0,d=d+Math.imul(J,Oe)|0,d=d+Math.imul(te,Ne)|0,T=T+Math.imul(te,Oe)|0,A=A+Math.imul(j,Be)|0,d=d+Math.imul(j,Le)|0,d=d+Math.imul(V,Be)|0,T=T+Math.imul(V,Le)|0,A=A+Math.imul(q,Se)|0,d=d+Math.imul(q,Ue)|0,d=d+Math.imul(Q,Se)|0,T=T+Math.imul(Q,Ue)|0,A=A+Math.imul(g,ue)|0,d=d+Math.imul(g,ye)|0,d=d+Math.imul(F,ue)|0,T=T+Math.imul(F,ye)|0;var Yo=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(Yo>>>26)|0,Yo&=67108863,A=Math.imul(Ie,Me),d=Math.imul(Ie,Te),d=d+Math.imul(ge,Me)|0,T=Math.imul(ge,Te),A=A+Math.imul(pe,ke)|0,d=d+Math.imul(pe,Fe)|0,d=d+Math.imul(he,ke)|0,T=T+Math.imul(he,Fe)|0,A=A+Math.imul(we,Ne)|0,d=d+Math.imul(we,Oe)|0,d=d+Math.imul(be,Ne)|0,T=T+Math.imul(be,Oe)|0,A=A+Math.imul(J,Be)|0,d=d+Math.imul(J,Le)|0,d=d+Math.imul(te,Be)|0,T=T+Math.imul(te,Le)|0,A=A+Math.imul(j,Se)|0,d=d+Math.imul(j,Ue)|0,d=d+Math.imul(V,Se)|0,T=T+Math.imul(V,Ue)|0,A=A+Math.imul(q,ue)|0,d=d+Math.imul(q,ye)|0,d=d+Math.imul(Q,ue)|0,T=T+Math.imul(Q,ye)|0,A=A+Math.imul(g,qe)|0,d=d+Math.imul(g,ze)|0,d=d+Math.imul(F,qe)|0,T=T+Math.imul(F,ze)|0;var Xo=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(Xo>>>26)|0,Xo&=67108863,A=Math.imul(De,Me),d=Math.imul(De,Te),d=d+Math.imul(Pe,Me)|0,T=Math.imul(Pe,Te),A=A+Math.imul(Ie,ke)|0,d=d+Math.imul(Ie,Fe)|0,d=d+Math.imul(ge,ke)|0,T=T+Math.imul(ge,Fe)|0,A=A+Math.imul(pe,Ne)|0,d=d+Math.imul(pe,Oe)|0,d=d+Math.imul(he,Ne)|0,T=T+Math.imul(he,Oe)|0,A=A+Math.imul(we,Be)|0,d=d+Math.imul(we,Le)|0,d=d+Math.imul(be,Be)|0,T=T+Math.imul(be,Le)|0,A=A+Math.imul(J,Se)|0,d=d+Math.imul(J,Ue)|0,d=d+Math.imul(te,Se)|0,T=T+Math.imul(te,Ue)|0,A=A+Math.imul(j,ue)|0,d=d+Math.imul(j,ye)|0,d=d+Math.imul(V,ue)|0,T=T+Math.imul(V,ye)|0,A=A+Math.imul(q,qe)|0,d=d+Math.imul(q,ze)|0,d=d+Math.imul(Q,qe)|0,T=T+Math.imul(Q,ze)|0,A=A+Math.imul(g,He)|0,d=d+Math.imul(g,We)|0,d=d+Math.imul(F,He)|0,T=T+Math.imul(F,We)|0;var Zo=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(Zo>>>26)|0,Zo&=67108863,A=Math.imul(xe,Me),d=Math.imul(xe,Te),d=d+Math.imul(ve,Me)|0,T=Math.imul(ve,Te),A=A+Math.imul(De,ke)|0,d=d+Math.imul(De,Fe)|0,d=d+Math.imul(Pe,ke)|0,T=T+Math.imul(Pe,Fe)|0,A=A+Math.imul(Ie,Ne)|0,d=d+Math.imul(Ie,Oe)|0,d=d+Math.imul(ge,Ne)|0,T=T+Math.imul(ge,Oe)|0,A=A+Math.imul(pe,Be)|0,d=d+Math.imul(pe,Le)|0,d=d+Math.imul(he,Be)|0,T=T+Math.imul(he,Le)|0,A=A+Math.imul(we,Se)|0,d=d+Math.imul(we,Ue)|0,d=d+Math.imul(be,Se)|0,T=T+Math.imul(be,Ue)|0,A=A+Math.imul(J,ue)|0,d=d+Math.imul(J,ye)|0,d=d+Math.imul(te,ue)|0,T=T+Math.imul(te,ye)|0,A=A+Math.imul(j,qe)|0,d=d+Math.imul(j,ze)|0,d=d+Math.imul(V,qe)|0,T=T+Math.imul(V,ze)|0,A=A+Math.imul(q,He)|0,d=d+Math.imul(q,We)|0,d=d+Math.imul(Q,He)|0,T=T+Math.imul(Q,We)|0,A=A+Math.imul(g,Ke)|0,d=d+Math.imul(g,Qe)|0,d=d+Math.imul(F,Ke)|0,T=T+Math.imul(F,Qe)|0;var $o=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+($o>>>26)|0,$o&=67108863,A=Math.imul(Re,Me),d=Math.imul(Re,Te),d=d+Math.imul(_e,Me)|0,T=Math.imul(_e,Te),A=A+Math.imul(xe,ke)|0,d=d+Math.imul(xe,Fe)|0,d=d+Math.imul(ve,ke)|0,T=T+Math.imul(ve,Fe)|0,A=A+Math.imul(De,Ne)|0,d=d+Math.imul(De,Oe)|0,d=d+Math.imul(Pe,Ne)|0,T=T+Math.imul(Pe,Oe)|0,A=A+Math.imul(Ie,Be)|0,d=d+Math.imul(Ie,Le)|0,d=d+Math.imul(ge,Be)|0,T=T+Math.imul(ge,Le)|0,A=A+Math.imul(pe,Se)|0,d=d+Math.imul(pe,Ue)|0,d=d+Math.imul(he,Se)|0,T=T+Math.imul(he,Ue)|0,A=A+Math.imul(we,ue)|0,d=d+Math.imul(we,ye)|0,d=d+Math.imul(be,ue)|0,T=T+Math.imul(be,ye)|0,A=A+Math.imul(J,qe)|0,d=d+Math.imul(J,ze)|0,d=d+Math.imul(te,qe)|0,T=T+Math.imul(te,ze)|0,A=A+Math.imul(j,He)|0,d=d+Math.imul(j,We)|0,d=d+Math.imul(V,He)|0,T=T+Math.imul(V,We)|0,A=A+Math.imul(q,Ke)|0,d=d+Math.imul(q,Qe)|0,d=d+Math.imul(Q,Ke)|0,T=T+Math.imul(Q,Qe)|0,A=A+Math.imul(g,Ve)|0,d=d+Math.imul(g,je)|0,d=d+Math.imul(F,Ve)|0,T=T+Math.imul(F,je)|0;var es=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(es>>>26)|0,es&=67108863,A=Math.imul(Re,ke),d=Math.imul(Re,Fe),d=d+Math.imul(_e,ke)|0,T=Math.imul(_e,Fe),A=A+Math.imul(xe,Ne)|0,d=d+Math.imul(xe,Oe)|0,d=d+Math.imul(ve,Ne)|0,T=T+Math.imul(ve,Oe)|0,A=A+Math.imul(De,Be)|0,d=d+Math.imul(De,Le)|0,d=d+Math.imul(Pe,Be)|0,T=T+Math.imul(Pe,Le)|0,A=A+Math.imul(Ie,Se)|0,d=d+Math.imul(Ie,Ue)|0,d=d+Math.imul(ge,Se)|0,T=T+Math.imul(ge,Ue)|0,A=A+Math.imul(pe,ue)|0,d=d+Math.imul(pe,ye)|0,d=d+Math.imul(he,ue)|0,T=T+Math.imul(he,ye)|0,A=A+Math.imul(we,qe)|0,d=d+Math.imul(we,ze)|0,d=d+Math.imul(be,qe)|0,T=T+Math.imul(be,ze)|0,A=A+Math.imul(J,He)|0,d=d+Math.imul(J,We)|0,d=d+Math.imul(te,He)|0,T=T+Math.imul(te,We)|0,A=A+Math.imul(j,Ke)|0,d=d+Math.imul(j,Qe)|0,d=d+Math.imul(V,Ke)|0,T=T+Math.imul(V,Qe)|0,A=A+Math.imul(q,Ve)|0,d=d+Math.imul(q,je)|0,d=d+Math.imul(Q,Ve)|0,T=T+Math.imul(Q,je)|0;var ts=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(ts>>>26)|0,ts&=67108863,A=Math.imul(Re,Ne),d=Math.imul(Re,Oe),d=d+Math.imul(_e,Ne)|0,T=Math.imul(_e,Oe),A=A+Math.imul(xe,Be)|0,d=d+Math.imul(xe,Le)|0,d=d+Math.imul(ve,Be)|0,T=T+Math.imul(ve,Le)|0,A=A+Math.imul(De,Se)|0,d=d+Math.imul(De,Ue)|0,d=d+Math.imul(Pe,Se)|0,T=T+Math.imul(Pe,Ue)|0,A=A+Math.imul(Ie,ue)|0,d=d+Math.imul(Ie,ye)|0,d=d+Math.imul(ge,ue)|0,T=T+Math.imul(ge,ye)|0,A=A+Math.imul(pe,qe)|0,d=d+Math.imul(pe,ze)|0,d=d+Math.imul(he,qe)|0,T=T+Math.imul(he,ze)|0,A=A+Math.imul(we,He)|0,d=d+Math.imul(we,We)|0,d=d+Math.imul(be,He)|0,T=T+Math.imul(be,We)|0,A=A+Math.imul(J,Ke)|0,d=d+Math.imul(J,Qe)|0,d=d+Math.imul(te,Ke)|0,T=T+Math.imul(te,Qe)|0,A=A+Math.imul(j,Ve)|0,d=d+Math.imul(j,je)|0,d=d+Math.imul(V,Ve)|0,T=T+Math.imul(V,je)|0;var rs=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(rs>>>26)|0,rs&=67108863,A=Math.imul(Re,Be),d=Math.imul(Re,Le),d=d+Math.imul(_e,Be)|0,T=Math.imul(_e,Le),A=A+Math.imul(xe,Se)|0,d=d+Math.imul(xe,Ue)|0,d=d+Math.imul(ve,Se)|0,T=T+Math.imul(ve,Ue)|0,A=A+Math.imul(De,ue)|0,d=d+Math.imul(De,ye)|0,d=d+Math.imul(Pe,ue)|0,T=T+Math.imul(Pe,ye)|0,A=A+Math.imul(Ie,qe)|0,d=d+Math.imul(Ie,ze)|0,d=d+Math.imul(ge,qe)|0,T=T+Math.imul(ge,ze)|0,A=A+Math.imul(pe,He)|0,d=d+Math.imul(pe,We)|0,d=d+Math.imul(he,He)|0,T=T+Math.imul(he,We)|0,A=A+Math.imul(we,Ke)|0,d=d+Math.imul(we,Qe)|0,d=d+Math.imul(be,Ke)|0,T=T+Math.imul(be,Qe)|0,A=A+Math.imul(J,Ve)|0,d=d+Math.imul(J,je)|0,d=d+Math.imul(te,Ve)|0,T=T+Math.imul(te,je)|0;var ns=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(ns>>>26)|0,ns&=67108863,A=Math.imul(Re,Se),d=Math.imul(Re,Ue),d=d+Math.imul(_e,Se)|0,T=Math.imul(_e,Ue),A=A+Math.imul(xe,ue)|0,d=d+Math.imul(xe,ye)|0,d=d+Math.imul(ve,ue)|0,T=T+Math.imul(ve,ye)|0,A=A+Math.imul(De,qe)|0,d=d+Math.imul(De,ze)|0,d=d+Math.imul(Pe,qe)|0,T=T+Math.imul(Pe,ze)|0,A=A+Math.imul(Ie,He)|0,d=d+Math.imul(Ie,We)|0,d=d+Math.imul(ge,He)|0,T=T+Math.imul(ge,We)|0,A=A+Math.imul(pe,Ke)|0,d=d+Math.imul(pe,Qe)|0,d=d+Math.imul(he,Ke)|0,T=T+Math.imul(he,Qe)|0,A=A+Math.imul(we,Ve)|0,d=d+Math.imul(we,je)|0,d=d+Math.imul(be,Ve)|0,T=T+Math.imul(be,je)|0;var as=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(as>>>26)|0,as&=67108863,A=Math.imul(Re,ue),d=Math.imul(Re,ye),d=d+Math.imul(_e,ue)|0,T=Math.imul(_e,ye),A=A+Math.imul(xe,qe)|0,d=d+Math.imul(xe,ze)|0,d=d+Math.imul(ve,qe)|0,T=T+Math.imul(ve,ze)|0,A=A+Math.imul(De,He)|0,d=d+Math.imul(De,We)|0,d=d+Math.imul(Pe,He)|0,T=T+Math.imul(Pe,We)|0,A=A+Math.imul(Ie,Ke)|0,d=d+Math.imul(Ie,Qe)|0,d=d+Math.imul(ge,Ke)|0,T=T+Math.imul(ge,Qe)|0,A=A+Math.imul(pe,Ve)|0,d=d+Math.imul(pe,je)|0,d=d+Math.imul(he,Ve)|0,T=T+Math.imul(he,je)|0;var is=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(is>>>26)|0,is&=67108863,A=Math.imul(Re,qe),d=Math.imul(Re,ze),d=d+Math.imul(_e,qe)|0,T=Math.imul(_e,ze),A=A+Math.imul(xe,He)|0,d=d+Math.imul(xe,We)|0,d=d+Math.imul(ve,He)|0,T=T+Math.imul(ve,We)|0,A=A+Math.imul(De,Ke)|0,d=d+Math.imul(De,Qe)|0,d=d+Math.imul(Pe,Ke)|0,T=T+Math.imul(Pe,Qe)|0,A=A+Math.imul(Ie,Ve)|0,d=d+Math.imul(Ie,je)|0,d=d+Math.imul(ge,Ve)|0,T=T+Math.imul(ge,je)|0;var os=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(os>>>26)|0,os&=67108863,A=Math.imul(Re,He),d=Math.imul(Re,We),d=d+Math.imul(_e,He)|0,T=Math.imul(_e,We),A=A+Math.imul(xe,Ke)|0,d=d+Math.imul(xe,Qe)|0,d=d+Math.imul(ve,Ke)|0,T=T+Math.imul(ve,Qe)|0,A=A+Math.imul(De,Ve)|0,d=d+Math.imul(De,je)|0,d=d+Math.imul(Pe,Ve)|0,T=T+Math.imul(Pe,je)|0;var ss=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(ss>>>26)|0,ss&=67108863,A=Math.imul(Re,Ke),d=Math.imul(Re,Qe),d=d+Math.imul(_e,Ke)|0,T=Math.imul(_e,Qe),A=A+Math.imul(xe,Ve)|0,d=d+Math.imul(xe,je)|0,d=d+Math.imul(ve,Ve)|0,T=T+Math.imul(ve,je)|0;var us=(k+A|0)+((d&8191)<<13)|0;k=(T+(d>>>13)|0)+(us>>>26)|0,us&=67108863,A=Math.imul(Re,Ve),d=Math.imul(Re,je),d=d+Math.imul(_e,Ve)|0,T=Math.imul(_e,je);var ps=(k+A|0)+((d&8191)<<13)|0;return k=(T+(d>>>13)|0)+(ps>>>26)|0,ps&=67108863,I[0]=Ur,I[1]=qr,I[2]=Gr,I[3]=zr,I[4]=Hr,I[5]=Yo,I[6]=Xo,I[7]=Zo,I[8]=$o,I[9]=es,I[10]=ts,I[11]=rs,I[12]=ns,I[13]=as,I[14]=is,I[15]=os,I[16]=ss,I[17]=us,I[18]=ps,k!==0&&(I[19]=k,b.length++),b};Math.imul||(v=_);function E(R,u,m){m.negative=u.negative^R.negative,m.length=R.length+u.length;for(var b=0,C=0,P=0;P<m.length-1;P++){var I=C;C=0;for(var k=b&67108863,A=Math.min(P,u.length-1),d=Math.max(0,P-R.length+1);d<=A;d++){var T=P-d,K=R.words[T]|0,g=u.words[d]|0,F=K*g,O=F&67108863;I=I+(F/67108864|0)|0,O=O+k|0,k=O&67108863,I=I+(O>>>26)|0,C+=I>>>26,I&=67108863;}m.words[P]=k,b=I,I=C;}return b!==0?m.words[P]=b:m.length--,m._strip()}function B(R,u,m){return E(R,u,m)}a.prototype.mulTo=function(u,m){var b,C=this.length+u.length;return this.length===10&&u.length===10?b=v(this,u,m):C<63?b=_(this,u,m):C<1024?b=E(this,u,m):b=B(this,u,m),b};a.prototype.mul=function(u){var m=new a(null);return m.words=new Array(this.length+u.length),this.mulTo(u,m)},a.prototype.mulf=function(u){var m=new a(null);return m.words=new Array(this.length+u.length),B(this,u,m)},a.prototype.imul=function(u){return this.clone().mulTo(u,this)},a.prototype.imuln=function(u){var m=u<0;m&&(u=-u),t(typeof u=="number"),t(u<67108864);for(var b=0,C=0;C<this.length;C++){var P=(this.words[C]|0)*u,I=(P&67108863)+(b&67108863);b>>=26,b+=P/67108864|0,b+=I>>>26,this.words[C]=I&67108863;}return b!==0&&(this.words[C]=b,this.length++),this.length=u===0?1:this.length,m?this.ineg():this},a.prototype.muln=function(u){return this.clone().imuln(u)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(u){var m=w(u);if(m.length===0)return new a(1);for(var b=this,C=0;C<m.length&&m[C]===0;C++,b=b.sqr());if(++C<m.length)for(var P=b.sqr();C<m.length;C++,P=P.sqr())m[C]!==0&&(b=b.mul(P));return b},a.prototype.iushln=function(u){t(typeof u=="number"&&u>=0);var m=u%26,b=(u-m)/26,C=67108863>>>26-m<<26-m,P;if(m!==0){var I=0;for(P=0;P<this.length;P++){var k=this.words[P]&C,A=(this.words[P]|0)-k<<m;this.words[P]=A|I,I=k>>>26-m;}I&&(this.words[P]=I,this.length++);}if(b!==0){for(P=this.length-1;P>=0;P--)this.words[P+b]=this.words[P];for(P=0;P<b;P++)this.words[P]=0;this.length+=b;}return this._strip()},a.prototype.ishln=function(u){return t(this.negative===0),this.iushln(u)},a.prototype.iushrn=function(u,m,b){t(typeof u=="number"&&u>=0);var C;m?C=(m-m%26)/26:C=0;var P=u%26,I=Math.min((u-P)/26,this.length),k=67108863^67108863>>>P<<P,A=b;if(C-=I,C=Math.max(0,C),A){for(var d=0;d<I;d++)A.words[d]=this.words[d];A.length=I;}if(I!==0)if(this.length>I)for(this.length-=I,d=0;d<this.length;d++)this.words[d]=this.words[d+I];else this.words[0]=0,this.length=1;var T=0;for(d=this.length-1;d>=0&&(T!==0||d>=C);d--){var K=this.words[d]|0;this.words[d]=T<<26-P|K>>>P,T=K&k;}return A&&T!==0&&(A.words[A.length++]=T),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(u,m,b){return t(this.negative===0),this.iushrn(u,m,b)},a.prototype.shln=function(u){return this.clone().ishln(u)},a.prototype.ushln=function(u){return this.clone().iushln(u)},a.prototype.shrn=function(u){return this.clone().ishrn(u)},a.prototype.ushrn=function(u){return this.clone().iushrn(u)},a.prototype.testn=function(u){t(typeof u=="number"&&u>=0);var m=u%26,b=(u-m)/26,C=1<<m;if(this.length<=b)return false;var P=this.words[b];return !!(P&C)},a.prototype.imaskn=function(u){t(typeof u=="number"&&u>=0);var m=u%26,b=(u-m)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(m!==0&&b++,this.length=Math.min(b,this.length),m!==0){var C=67108863^67108863>>>m<<m;this.words[this.length-1]&=C;}return this._strip()},a.prototype.maskn=function(u){return this.clone().imaskn(u)},a.prototype.iaddn=function(u){return t(typeof u=="number"),t(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<=u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},a.prototype._iaddn=function(u){this.words[0]+=u;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},a.prototype.isubn=function(u){if(t(typeof u=="number"),t(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},a.prototype.addn=function(u){return this.clone().iaddn(u)},a.prototype.subn=function(u){return this.clone().isubn(u)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(u,m,b){var C=u.length+b,P;this._expand(C);var I,k=0;for(P=0;P<u.length;P++){I=(this.words[P+b]|0)+k;var A=(u.words[P]|0)*m;I-=A&67108863,k=(I>>26)-(A/67108864|0),this.words[P+b]=I&67108863;}for(;P<this.length-b;P++)I=(this.words[P+b]|0)+k,k=I>>26,this.words[P+b]=I&67108863;if(k===0)return this._strip();for(t(k===-1),k=0,P=0;P<this.length;P++)I=-(this.words[P]|0)+k,k=I>>26,this.words[P]=I&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(u,m){var b=this.length-u.length,C=this.clone(),P=u,I=P.words[P.length-1]|0,k=this._countBits(I);b=26-k,b!==0&&(P=P.ushln(b),C.iushln(b),I=P.words[P.length-1]|0);var A=C.length-P.length,d;if(m!=="mod"){d=new a(null),d.length=A+1,d.words=new Array(d.length);for(var T=0;T<d.length;T++)d.words[T]=0;}var K=C.clone()._ishlnsubmul(P,1,A);K.negative===0&&(C=K,d&&(d.words[A]=1));for(var g=A-1;g>=0;g--){var F=(C.words[P.length+g]|0)*67108864+(C.words[P.length+g-1]|0);for(F=Math.min(F/I|0,67108863),C._ishlnsubmul(P,F,g);C.negative!==0;)F--,C.negative=0,C._ishlnsubmul(P,1,g),C.isZero()||(C.negative^=1);d&&(d.words[g]=F);}return d&&d._strip(),C._strip(),m!=="div"&&b!==0&&C.iushrn(b),{div:d||null,mod:C}},a.prototype.divmod=function(u,m,b){if(t(!u.isZero()),this.isZero())return {div:new a(0),mod:new a(0)};var C,P,I;return this.negative!==0&&u.negative===0?(I=this.neg().divmod(u,m),m!=="mod"&&(C=I.div.neg()),m!=="div"&&(P=I.mod.neg(),b&&P.negative!==0&&P.iadd(u)),{div:C,mod:P}):this.negative===0&&u.negative!==0?(I=this.divmod(u.neg(),m),m!=="mod"&&(C=I.div.neg()),{div:C,mod:I.mod}):(this.negative&u.negative)!==0?(I=this.neg().divmod(u.neg(),m),m!=="div"&&(P=I.mod.neg(),b&&P.negative!==0&&P.isub(u)),{div:I.div,mod:P}):u.length>this.length||this.cmp(u)<0?{div:new a(0),mod:this}:u.length===1?m==="div"?{div:this.divn(u.words[0]),mod:null}:m==="mod"?{div:null,mod:new a(this.modrn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new a(this.modrn(u.words[0]))}:this._wordDiv(u,m)},a.prototype.div=function(u){return this.divmod(u,"div",false).div},a.prototype.mod=function(u){return this.divmod(u,"mod",false).mod},a.prototype.umod=function(u){return this.divmod(u,"mod",true).mod},a.prototype.divRound=function(u){var m=this.divmod(u);if(m.mod.isZero())return m.div;var b=m.div.negative!==0?m.mod.isub(u):m.mod,C=u.ushrn(1),P=u.andln(1),I=b.cmp(C);return I<0||P===1&&I===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},a.prototype.modrn=function(u){var m=u<0;m&&(u=-u),t(u<=67108863);for(var b=(1<<26)%u,C=0,P=this.length-1;P>=0;P--)C=(b*C+(this.words[P]|0))%u;return m?-C:C},a.prototype.modn=function(u){return this.modrn(u)},a.prototype.idivn=function(u){var m=u<0;m&&(u=-u),t(u<=67108863);for(var b=0,C=this.length-1;C>=0;C--){var P=(this.words[C]|0)+b*67108864;this.words[C]=P/u|0,b=P%u;}return this._strip(),m?this.ineg():this},a.prototype.divn=function(u){return this.clone().idivn(u)},a.prototype.egcd=function(u){t(u.negative===0),t(!u.isZero());var m=this,b=u.clone();m.negative!==0?m=m.umod(u):m=m.clone();for(var C=new a(1),P=new a(0),I=new a(0),k=new a(1),A=0;m.isEven()&&b.isEven();)m.iushrn(1),b.iushrn(1),++A;for(var d=b.clone(),T=m.clone();!m.isZero();){for(var K=0,g=1;(m.words[0]&g)===0&&K<26;++K,g<<=1);if(K>0)for(m.iushrn(K);K-- >0;)(C.isOdd()||P.isOdd())&&(C.iadd(d),P.isub(T)),C.iushrn(1),P.iushrn(1);for(var F=0,O=1;(b.words[0]&O)===0&&F<26;++F,O<<=1);if(F>0)for(b.iushrn(F);F-- >0;)(I.isOdd()||k.isOdd())&&(I.iadd(d),k.isub(T)),I.iushrn(1),k.iushrn(1);m.cmp(b)>=0?(m.isub(b),C.isub(I),P.isub(k)):(b.isub(m),I.isub(C),k.isub(P));}return {a:I,b:k,gcd:b.iushln(A)}},a.prototype._invmp=function(u){t(u.negative===0),t(!u.isZero());var m=this,b=u.clone();m.negative!==0?m=m.umod(u):m=m.clone();for(var C=new a(1),P=new a(0),I=b.clone();m.cmpn(1)>0&&b.cmpn(1)>0;){for(var k=0,A=1;(m.words[0]&A)===0&&k<26;++k,A<<=1);if(k>0)for(m.iushrn(k);k-- >0;)C.isOdd()&&C.iadd(I),C.iushrn(1);for(var d=0,T=1;(b.words[0]&T)===0&&d<26;++d,T<<=1);if(d>0)for(b.iushrn(d);d-- >0;)P.isOdd()&&P.iadd(I),P.iushrn(1);m.cmp(b)>=0?(m.isub(b),C.isub(P)):(b.isub(m),P.isub(C));}var K;return m.cmpn(1)===0?K=C:K=P,K.cmpn(0)<0&&K.iadd(u),K},a.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var m=this.clone(),b=u.clone();m.negative=0,b.negative=0;for(var C=0;m.isEven()&&b.isEven();C++)m.iushrn(1),b.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;b.isEven();)b.iushrn(1);var P=m.cmp(b);if(P<0){var I=m;m=b,b=I;}else if(P===0||b.cmpn(1)===0)break;m.isub(b);}while(true);return b.iushln(C)},a.prototype.invm=function(u){return this.egcd(u).a.umod(u)},a.prototype.isEven=function(){return (this.words[0]&1)===0},a.prototype.isOdd=function(){return (this.words[0]&1)===1},a.prototype.andln=function(u){return this.words[0]&u},a.prototype.bincn=function(u){t(typeof u=="number");var m=u%26,b=(u-m)/26,C=1<<m;if(this.length<=b)return this._expand(b+1),this.words[b]|=C,this;for(var P=C,I=b;P!==0&&I<this.length;I++){var k=this.words[I]|0;k+=P,P=k>>>26,k&=67108863,this.words[I]=k;}return P!==0&&(this.words[I]=P,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(u){var m=u<0;if(this.negative!==0&&!m)return -1;if(this.negative===0&&m)return 1;this._strip();var b;if(this.length>1)b=1;else {m&&(u=-u),t(u<=67108863,"Number is too big");var C=this.words[0]|0;b=C===u?0:C<u?-1:1;}return this.negative!==0?-b|0:b},a.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return -1;if(this.negative===0&&u.negative!==0)return 1;var m=this.ucmp(u);return this.negative!==0?-m|0:m},a.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return -1;for(var m=0,b=this.length-1;b>=0;b--){var C=this.words[b]|0,P=u.words[b]|0;if(C!==P){C<P?m=-1:C>P&&(m=1);break}}return m},a.prototype.gtn=function(u){return this.cmpn(u)===1},a.prototype.gt=function(u){return this.cmp(u)===1},a.prototype.gten=function(u){return this.cmpn(u)>=0},a.prototype.gte=function(u){return this.cmp(u)>=0},a.prototype.ltn=function(u){return this.cmpn(u)===-1},a.prototype.lt=function(u){return this.cmp(u)===-1},a.prototype.lten=function(u){return this.cmpn(u)<=0},a.prototype.lte=function(u){return this.cmp(u)<=0},a.prototype.eqn=function(u){return this.cmpn(u)===0},a.prototype.eq=function(u){return this.cmp(u)===0},a.red=function(u){return new N(u)},a.prototype.toRed=function(u){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},a.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(u){return this.red=u,this},a.prototype.forceRed=function(u){return t(!this.red,"Already a number in reduction context"),this._forceRed(u)},a.prototype.redAdd=function(u){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},a.prototype.redIAdd=function(u){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},a.prototype.redSub=function(u){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},a.prototype.redISub=function(u){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},a.prototype.redShl=function(u){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},a.prototype.redMul=function(u){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},a.prototype.redIMul=function(u){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},a.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(u){return t(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var D={k256:null,p224:null,p192:null,p25519:null};function M(R,u){this.name=R,this.p=new a(u,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp();}M.prototype._tmp=function(){var u=new a(null);return u.words=new Array(Math.ceil(this.n/13)),u},M.prototype.ireduce=function(u){var m=u,b;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),b=m.bitLength();while(b>this.n);var C=b<this.n?-1:m.ucmp(this.p);return C===0?(m.words[0]=0,m.length=1):C>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},M.prototype.split=function(u,m){u.iushrn(this.n,0,m);},M.prototype.imulK=function(u){return u.imul(this.k)};function G(){M.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f");}n(G,M),G.prototype.split=function(u,m){for(var b=4194303,C=Math.min(u.length,9),P=0;P<C;P++)m.words[P]=u.words[P];if(m.length=C,u.length<=9){u.words[0]=0,u.length=1;return}var I=u.words[9];for(m.words[m.length++]=I&b,P=10;P<u.length;P++){var k=u.words[P]|0;u.words[P-10]=(k&b)<<4|I>>>22,I=k;}I>>>=22,u.words[P-10]=I,I===0&&u.length>10?u.length-=10:u.length-=9;},G.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var m=0,b=0;b<u.length;b++){var C=u.words[b]|0;m+=C*977,u.words[b]=m&67108863,m=C*64+(m/67108864|0);}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function L(){M.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001");}n(L,M);function z(){M.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff");}n(z,M);function W(){M.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed");}n(W,M),W.prototype.imulK=function(u){for(var m=0,b=0;b<u.length;b++){var C=(u.words[b]|0)*19+m,P=C&67108863;C>>>=26,u.words[b]=P,m=C;}return m!==0&&(u.words[u.length++]=m),u},a._prime=function(u){if(D[u])return D[u];var m;if(u==="k256")m=new G;else if(u==="p224")m=new L;else if(u==="p192")m=new z;else if(u==="p25519")m=new W;else throw new Error("Unknown prime "+u);return D[u]=m,m};function N(R){if(typeof R=="string"){var u=a._prime(R);this.m=u.p,this.prime=u;}else t(R.gtn(1),"modulus must be greater than 1"),this.m=R,this.prime=null;}N.prototype._verify1=function(u){t(u.negative===0,"red works only with positives"),t(u.red,"red works only with red numbers");},N.prototype._verify2=function(u,m){t((u.negative|m.negative)===0,"red works only with positives"),t(u.red&&u.red===m.red,"red works only with red numbers");},N.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):(c(u,u.umod(this.m)._forceRed(this)),u)},N.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},N.prototype.add=function(u,m){this._verify2(u,m);var b=u.add(m);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},N.prototype.iadd=function(u,m){this._verify2(u,m);var b=u.iadd(m);return b.cmp(this.m)>=0&&b.isub(this.m),b},N.prototype.sub=function(u,m){this._verify2(u,m);var b=u.sub(m);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},N.prototype.isub=function(u,m){this._verify2(u,m);var b=u.isub(m);return b.cmpn(0)<0&&b.iadd(this.m),b},N.prototype.shl=function(u,m){return this._verify1(u),this.imod(u.ushln(m))},N.prototype.imul=function(u,m){return this._verify2(u,m),this.imod(u.imul(m))},N.prototype.mul=function(u,m){return this._verify2(u,m),this.imod(u.mul(m))},N.prototype.isqr=function(u){return this.imul(u,u.clone())},N.prototype.sqr=function(u){return this.mul(u,u)},N.prototype.sqrt=function(u){if(u.isZero())return u.clone();var m=this.m.andln(3);if(t(m%2===1),m===3){var b=this.m.add(new a(1)).iushrn(2);return this.pow(u,b)}for(var C=this.m.subn(1),P=0;!C.isZero()&&C.andln(1)===0;)P++,C.iushrn(1);t(!C.isZero());var I=new a(1).toRed(this),k=I.redNeg(),A=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new a(2*d*d).toRed(this);this.pow(d,A).cmp(k)!==0;)d.redIAdd(k);for(var T=this.pow(d,C),K=this.pow(u,C.addn(1).iushrn(1)),g=this.pow(u,C),F=P;g.cmp(I)!==0;){for(var O=g,q=0;O.cmp(I)!==0;q++)O=O.redSqr();t(q<F);var Q=this.pow(T,new a(1).iushln(F-q-1));K=K.redMul(Q),T=Q.redSqr(),g=g.redMul(T),F=q;}return K},N.prototype.invm=function(u){var m=u._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},N.prototype.pow=function(u,m){if(m.isZero())return new a(1).toRed(this);if(m.cmpn(1)===0)return u.clone();var b=4,C=new Array(1<<b);C[0]=new a(1).toRed(this),C[1]=u;for(var P=2;P<C.length;P++)C[P]=this.mul(C[P-1],u);var I=C[0],k=0,A=0,d=m.bitLength()%26;for(d===0&&(d=26),P=m.length-1;P>=0;P--){for(var T=m.words[P],K=d-1;K>=0;K--){var g=T>>K&1;if(I!==C[0]&&(I=this.sqr(I)),g===0&&k===0){A=0;continue}k<<=1,k|=g,A++,!(A!==b&&(P!==0||K!==0))&&(I=this.mul(I,C[k]),A=0,k=0);}d=26;}return I},N.prototype.convertTo=function(u){var m=u.umod(this.m);return m===u?m.clone():m},N.prototype.convertFrom=function(u){var m=u.clone();return m.red=null,m},a.mont=function(u){return new H(u)};function H(R){N.call(this,R),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv);}n(H,N),H.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},H.prototype.convertFrom=function(u){var m=this.imod(u.mul(this.rinv));return m.red=null,m},H.prototype.imul=function(u,m){if(u.isZero()||m.isZero())return u.words[0]=0,u.length=1,u;var b=u.imul(m),C=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),P=b.isub(C).iushrn(this.shift),I=P;return P.cmp(this.m)>=0?I=P.isub(this.m):P.cmpn(0)<0&&(I=P.iadd(this.m)),I._forceRed(this)},H.prototype.mul=function(u,m){if(u.isZero()||m.isZero())return new a(0)._forceRed(this);var b=u.mul(m),C=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),P=b.isub(C).iushrn(this.shift),I=P;return P.cmp(this.m)>=0?I=P.isub(this.m):P.cmpn(0)<0&&(I=P.iadd(this.m)),I._forceRed(this)},H.prototype.invm=function(u){var m=this.imod(u._invmp(this.m).mul(this.r2));return m._forceRed(this)};})(typeof xs>"u"||xs,fp);});var Op=ee((cE,oi)=>{(function(){var r="input is invalid type",e="finalize already called",t=typeof window=="object",n=t?window:{};n.JS_SHA3_NO_WINDOW&&(t=false);var a=!t&&typeof self=="object",i=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;i?n=global:a&&(n=self);var o=!n.JS_SHA3_NO_COMMON_JS&&typeof oi=="object"&&oi.exports,s=typeof define=="function"&&define.amd,p=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),l=[31,7936,2031616,520093696],f=[4,1024,262144,67108864],h=[1,256,65536,16777216],y=[6,1536,393216,100663296],x=[0,8,16,24],w=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],_=[224,256,384,512],v=[128,256],E=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(g){return Object.prototype.toString.call(g)==="[object Array]"}),p&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(g){return typeof g=="object"&&g.buffer&&g.buffer.constructor===ArrayBuffer});for(var S=function(g,F,O){return function(q){return new d(g,F,g).update(q)[O]()}},D=function(g,F,O){return function(q,Q){return new d(g,F,Q).update(q)[O]()}},M=function(g,F,O){return function(q,Q,X,j){return u["cshake"+g].update(q,Q,X,j)[O]()}},G=function(g,F,O){return function(q,Q,X,j){return u["kmac"+g].update(q,Q,X,j)[O]()}},L=function(g,F,O,q){for(var Q=0;Q<E.length;++Q){var X=E[Q];g[X]=F(O,q,X);}return g},z=function(g,F){var O=S(g,F,"hex");return O.create=function(){return new d(g,F,g)},O.update=function(q){return O.create().update(q)},L(O,S,g,F)},W=function(g,F){var O=D(g,F,"hex");return O.create=function(q){return new d(g,F,q)},O.update=function(q,Q){return O.create(Q).update(q)},L(O,D,g,F)},N=function(g,F){var O=B[g],q=M(g,F,"hex");return q.create=function(Q,X,j){return !X&&!j?u["shake"+g].create(Q):new d(g,F,Q).bytepad([X,j],O)},q.update=function(Q,X,j,V){return q.create(X,j,V).update(Q)},L(q,M,g,F)},H=function(g,F){var O=B[g],q=G(g,F,"hex");return q.create=function(Q,X,j){return new T(g,F,X).bytepad(["KMAC",j],O).bytepad([Q],O)},q.update=function(Q,X,j,V){return q.create(Q,j,V).update(X)},L(q,G,g,F)},R=[{name:"keccak",padding:h,bits:_,createMethod:z},{name:"sha3",padding:y,bits:_,createMethod:z},{name:"shake",padding:l,bits:v,createMethod:W},{name:"cshake",padding:f,bits:v,createMethod:N},{name:"kmac",padding:f,bits:v,createMethod:H}],u={},m=[],b=0;b<R.length;++b)for(var C=R[b],P=C.bits,I=0;I<P.length;++I){var k=C.name+"_"+P[I];if(m.push(k),u[k]=C.createMethod(P[I],C.padding),C.name!=="sha3"){var A=C.name+P[I];m.push(A),u[A]=u[k];}}function d(g,F,O){this.blocks=[],this.s=[],this.padding=F,this.outputBits=O,this.reset=true,this.finalized=false,this.block=0,this.start=0,this.blockCount=1600-(g<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=O>>5,this.extraBytes=(O&31)>>3;for(var q=0;q<50;++q)this.s[q]=0;}d.prototype.update=function(g){if(this.finalized)throw new Error(e);var F,O=typeof g;if(O!=="string"){if(O==="object"){if(g===null)throw new Error(r);if(p&&g.constructor===ArrayBuffer)g=new Uint8Array(g);else if(!Array.isArray(g)&&(!p||!ArrayBuffer.isView(g)))throw new Error(r)}else throw new Error(r);F=true;}for(var q=this.blocks,Q=this.byteCount,X=g.length,j=this.blockCount,V=0,Ee=this.s,J,te;V<X;){if(this.reset)for(this.reset=false,q[0]=this.block,J=1;J<j+1;++J)q[J]=0;if(F)for(J=this.start;V<X&&J<Q;++V)q[J>>2]|=g[V]<<x[J++&3];else for(J=this.start;V<X&&J<Q;++V)te=g.charCodeAt(V),te<128?q[J>>2]|=te<<x[J++&3]:te<2048?(q[J>>2]|=(192|te>>6)<<x[J++&3],q[J>>2]|=(128|te&63)<<x[J++&3]):te<55296||te>=57344?(q[J>>2]|=(224|te>>12)<<x[J++&3],q[J>>2]|=(128|te>>6&63)<<x[J++&3],q[J>>2]|=(128|te&63)<<x[J++&3]):(te=65536+((te&1023)<<10|g.charCodeAt(++V)&1023),q[J>>2]|=(240|te>>18)<<x[J++&3],q[J>>2]|=(128|te>>12&63)<<x[J++&3],q[J>>2]|=(128|te>>6&63)<<x[J++&3],q[J>>2]|=(128|te&63)<<x[J++&3]);if(this.lastByteIndex=J,J>=Q){for(this.start=J-Q,this.block=q[j],J=0;J<j;++J)Ee[J]^=q[J];K(Ee),this.reset=true;}else this.start=J;}return this},d.prototype.encode=function(g,F){var O=g&255,q=1,Q=[O];for(g=g>>8,O=g&255;O>0;)Q.unshift(O),g=g>>8,O=g&255,++q;return F?Q.push(q):Q.unshift(q),this.update(Q),Q.length},d.prototype.encodeString=function(g){var F,O=typeof g;if(O!=="string"){if(O==="object"){if(g===null)throw new Error(r);if(p&&g.constructor===ArrayBuffer)g=new Uint8Array(g);else if(!Array.isArray(g)&&(!p||!ArrayBuffer.isView(g)))throw new Error(r)}else throw new Error(r);F=true;}var q=0,Q=g.length;if(F)q=Q;else for(var X=0;X<g.length;++X){var j=g.charCodeAt(X);j<128?q+=1:j<2048?q+=2:j<55296||j>=57344?q+=3:(j=65536+((j&1023)<<10|g.charCodeAt(++X)&1023),q+=4);}return q+=this.encode(q*8),this.update(g),q},d.prototype.bytepad=function(g,F){for(var O=this.encode(F),q=0;q<g.length;++q)O+=this.encodeString(g[q]);var Q=F-O%F,X=[];return X.length=Q,this.update(X),this},d.prototype.finalize=function(){if(!this.finalized){this.finalized=true;var g=this.blocks,F=this.lastByteIndex,O=this.blockCount,q=this.s;if(g[F>>2]|=this.padding[F&3],this.lastByteIndex===this.byteCount)for(g[0]=g[O],F=1;F<O+1;++F)g[F]=0;for(g[O-1]|=2147483648,F=0;F<O;++F)q[F]^=g[F];K(q);}},d.prototype.toString=d.prototype.hex=function(){this.finalize();for(var g=this.blockCount,F=this.s,O=this.outputBlocks,q=this.extraBytes,Q=0,X=0,j="",V;X<O;){for(Q=0;Q<g&&X<O;++Q,++X)V=F[Q],j+=c[V>>4&15]+c[V&15]+c[V>>12&15]+c[V>>8&15]+c[V>>20&15]+c[V>>16&15]+c[V>>28&15]+c[V>>24&15];X%g===0&&(K(F),Q=0);}return q&&(V=F[Q],j+=c[V>>4&15]+c[V&15],q>1&&(j+=c[V>>12&15]+c[V>>8&15]),q>2&&(j+=c[V>>20&15]+c[V>>16&15])),j},d.prototype.arrayBuffer=function(){this.finalize();var g=this.blockCount,F=this.s,O=this.outputBlocks,q=this.extraBytes,Q=0,X=0,j=this.outputBits>>3,V;q?V=new ArrayBuffer(O+1<<2):V=new ArrayBuffer(j);for(var Ee=new Uint32Array(V);X<O;){for(Q=0;Q<g&&X<O;++Q,++X)Ee[X]=F[Q];X%g===0&&K(F);}return q&&(Ee[Q]=F[Q],V=V.slice(0,j)),V},d.prototype.buffer=d.prototype.arrayBuffer,d.prototype.digest=d.prototype.array=function(){this.finalize();for(var g=this.blockCount,F=this.s,O=this.outputBlocks,q=this.extraBytes,Q=0,X=0,j=[],V,Ee;X<O;){for(Q=0;Q<g&&X<O;++Q,++X)V=X<<2,Ee=F[Q],j[V]=Ee&255,j[V+1]=Ee>>8&255,j[V+2]=Ee>>16&255,j[V+3]=Ee>>24&255;X%g===0&&K(F);}return q&&(V=X<<2,Ee=F[Q],j[V]=Ee&255,q>1&&(j[V+1]=Ee>>8&255),q>2&&(j[V+2]=Ee>>16&255)),j};function T(g,F,O){d.call(this,g,F,O);}T.prototype=new d,T.prototype.finalize=function(){return this.encode(this.outputBits,true),d.prototype.finalize.call(this)};var K=function(g){var F,O,q,Q,X,j,V,Ee,J,te,Pt,we,be,it,pe,he,kt,Ie,ge,Rt,De,Pe,$t,xe,ve,gr,Re,_e,xr,Me,Te,br,ke,Fe,er,Ne,Oe,vr,Be,Le,Ar,Se,Ue,tr,ue,ye,rr,qe,ze,an,He,We,on,Ke,Qe,sn,Ve,je,Ur,qr,Gr,zr,Hr;for(q=0;q<48;q+=2)Q=g[0]^g[10]^g[20]^g[30]^g[40],X=g[1]^g[11]^g[21]^g[31]^g[41],j=g[2]^g[12]^g[22]^g[32]^g[42],V=g[3]^g[13]^g[23]^g[33]^g[43],Ee=g[4]^g[14]^g[24]^g[34]^g[44],J=g[5]^g[15]^g[25]^g[35]^g[45],te=g[6]^g[16]^g[26]^g[36]^g[46],Pt=g[7]^g[17]^g[27]^g[37]^g[47],we=g[8]^g[18]^g[28]^g[38]^g[48],be=g[9]^g[19]^g[29]^g[39]^g[49],F=we^(j<<1|V>>>31),O=be^(V<<1|j>>>31),g[0]^=F,g[1]^=O,g[10]^=F,g[11]^=O,g[20]^=F,g[21]^=O,g[30]^=F,g[31]^=O,g[40]^=F,g[41]^=O,F=Q^(Ee<<1|J>>>31),O=X^(J<<1|Ee>>>31),g[2]^=F,g[3]^=O,g[12]^=F,g[13]^=O,g[22]^=F,g[23]^=O,g[32]^=F,g[33]^=O,g[42]^=F,g[43]^=O,F=j^(te<<1|Pt>>>31),O=V^(Pt<<1|te>>>31),g[4]^=F,g[5]^=O,g[14]^=F,g[15]^=O,g[24]^=F,g[25]^=O,g[34]^=F,g[35]^=O,g[44]^=F,g[45]^=O,F=Ee^(we<<1|be>>>31),O=J^(be<<1|we>>>31),g[6]^=F,g[7]^=O,g[16]^=F,g[17]^=O,g[26]^=F,g[27]^=O,g[36]^=F,g[37]^=O,g[46]^=F,g[47]^=O,F=te^(Q<<1|X>>>31),O=Pt^(X<<1|Q>>>31),g[8]^=F,g[9]^=O,g[18]^=F,g[19]^=O,g[28]^=F,g[29]^=O,g[38]^=F,g[39]^=O,g[48]^=F,g[49]^=O,it=g[0],pe=g[1],ye=g[11]<<4|g[10]>>>28,rr=g[10]<<4|g[11]>>>28,_e=g[20]<<3|g[21]>>>29,xr=g[21]<<3|g[20]>>>29,qr=g[31]<<9|g[30]>>>23,Gr=g[30]<<9|g[31]>>>23,Se=g[40]<<18|g[41]>>>14,Ue=g[41]<<18|g[40]>>>14,Fe=g[2]<<1|g[3]>>>31,er=g[3]<<1|g[2]>>>31,he=g[13]<<12|g[12]>>>20,kt=g[12]<<12|g[13]>>>20,qe=g[22]<<10|g[23]>>>22,ze=g[23]<<10|g[22]>>>22,Me=g[33]<<13|g[32]>>>19,Te=g[32]<<13|g[33]>>>19,zr=g[42]<<2|g[43]>>>30,Hr=g[43]<<2|g[42]>>>30,Ke=g[5]<<30|g[4]>>>2,Qe=g[4]<<30|g[5]>>>2,Ne=g[14]<<6|g[15]>>>26,Oe=g[15]<<6|g[14]>>>26,Ie=g[25]<<11|g[24]>>>21,ge=g[24]<<11|g[25]>>>21,an=g[34]<<15|g[35]>>>17,He=g[35]<<15|g[34]>>>17,br=g[45]<<29|g[44]>>>3,ke=g[44]<<29|g[45]>>>3,xe=g[6]<<28|g[7]>>>4,ve=g[7]<<28|g[6]>>>4,sn=g[17]<<23|g[16]>>>9,Ve=g[16]<<23|g[17]>>>9,vr=g[26]<<25|g[27]>>>7,Be=g[27]<<25|g[26]>>>7,Rt=g[36]<<21|g[37]>>>11,De=g[37]<<21|g[36]>>>11,We=g[47]<<24|g[46]>>>8,on=g[46]<<24|g[47]>>>8,tr=g[8]<<27|g[9]>>>5,ue=g[9]<<27|g[8]>>>5,gr=g[18]<<20|g[19]>>>12,Re=g[19]<<20|g[18]>>>12,je=g[29]<<7|g[28]>>>25,Ur=g[28]<<7|g[29]>>>25,Le=g[38]<<8|g[39]>>>24,Ar=g[39]<<8|g[38]>>>24,Pe=g[48]<<14|g[49]>>>18,$t=g[49]<<14|g[48]>>>18,g[0]=it^~he&Ie,g[1]=pe^~kt&ge,g[10]=xe^~gr&_e,g[11]=ve^~Re&xr,g[20]=Fe^~Ne&vr,g[21]=er^~Oe&Be,g[30]=tr^~ye&qe,g[31]=ue^~rr&ze,g[40]=Ke^~sn&je,g[41]=Qe^~Ve&Ur,g[2]=he^~Ie&Rt,g[3]=kt^~ge&De,g[12]=gr^~_e&Me,g[13]=Re^~xr&Te,g[22]=Ne^~vr&Le,g[23]=Oe^~Be&Ar,g[32]=ye^~qe&an,g[33]=rr^~ze&He,g[42]=sn^~je&qr,g[43]=Ve^~Ur&Gr,g[4]=Ie^~Rt&Pe,g[5]=ge^~De&$t,g[14]=_e^~Me&br,g[15]=xr^~Te&ke,g[24]=vr^~Le&Se,g[25]=Be^~Ar&Ue,g[34]=qe^~an&We,g[35]=ze^~He&on,g[44]=je^~qr&zr,g[45]=Ur^~Gr&Hr,g[6]=Rt^~Pe&it,g[7]=De^~$t&pe,g[16]=Me^~br&xe,g[17]=Te^~ke&ve,g[26]=Le^~Se&Fe,g[27]=Ar^~Ue&er,g[36]=an^~We&tr,g[37]=He^~on&ue,g[46]=qr^~zr&Ke,g[47]=Gr^~Hr&Qe,g[8]=Pe^~it&he,g[9]=$t^~pe&kt,g[18]=br^~xe&gr,g[19]=ke^~ve&Re,g[28]=Se^~Fe&Ne,g[29]=Ue^~er&Oe,g[38]=We^~tr&ye,g[39]=on^~ue&rr,g[48]=zr^~Ke&sn,g[49]=Hr^~Qe&Ve,g[0]^=w[q],g[1]^=w[q+1];};if(o)oi.exports=u;else {for(b=0;b<m.length;++b)n[m[b]]=u[m[b]];s&&define(function(){return u});}})();});var On=ee((m8,_l)=>{_l.exports=Rl;function Rl(r,e){if(!r)throw new Error(e||"Assertion failed")}Rl.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)};});var Tl=ee((h8,Ms)=>{typeof Object.create=="function"?Ms.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}}));}:Ms.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e;}};});var kl=ee((y8,Ns)=>{try{if(Fs=na("util"),typeof Fs.inherits!="function")throw "";Ns.exports=Fs.inherits;}catch{Ns.exports=Tl();}var Fs;});var Gt=ee(Ge=>{var Ux=On(),qx=kl();Ge.inherits=qx;function Gx(r,e){return (r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?false:(r.charCodeAt(e+1)&64512)===56320}function zx(r,e){if(Array.isArray(r))return r.slice();if(!r)return [];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),a=0;a<r.length;a+=2)t.push(parseInt(r[a]+r[a+1],16));}else for(var n=0,a=0;a<r.length;a++){var i=r.charCodeAt(a);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):Gx(r,a)?(i=65536+((i&1023)<<10)+(r.charCodeAt(++a)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128);}else for(a=0;a<r.length;a++)t[a]=r[a]|0;return t}Ge.toArray=zx;function Hx(r){for(var e="",t=0;t<r.length;t++)e+=Sl(r[t].toString(16));return e}Ge.toHex=Hx;function Bl(r){var e=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ge.htonl=Bl;function Wx(r,e){for(var t="",n=0;n<r.length;n++){var a=r[n];e==="little"&&(a=Bl(a)),t+=Dl(a.toString(16));}return t}Ge.toHex32=Wx;function Sl(r){return r.length===1?"0"+r:r}Ge.zero2=Sl;function Dl(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}Ge.zero8=Dl;function Kx(r,e,t,n){var a=t-e;Ux(a%4===0);for(var i=new Array(a/4),o=0,s=e;o<i.length;o++,s+=4){var p;n==="big"?p=r[s]<<24|r[s+1]<<16|r[s+2]<<8|r[s+3]:p=r[s+3]<<24|r[s+2]<<16|r[s+1]<<8|r[s],i[o]=p>>>0;}return i}Ge.join32=Kx;function Qx(r,e){for(var t=new Array(r.length*4),n=0,a=0;n<r.length;n++,a+=4){var i=r[n];e==="big"?(t[a]=i>>>24,t[a+1]=i>>>16&255,t[a+2]=i>>>8&255,t[a+3]=i&255):(t[a+3]=i>>>24,t[a+2]=i>>>16&255,t[a+1]=i>>>8&255,t[a]=i&255);}return t}Ge.split32=Qx;function Vx(r,e){return r>>>e|r<<32-e}Ge.rotr32=Vx;function jx(r,e){return r<<e|r>>>32-e}Ge.rotl32=jx;function Jx(r,e){return r+e>>>0}Ge.sum32=Jx;function Yx(r,e,t){return r+e+t>>>0}Ge.sum32_3=Yx;function Xx(r,e,t,n){return r+e+t+n>>>0}Ge.sum32_4=Xx;function Zx(r,e,t,n,a){return r+e+t+n+a>>>0}Ge.sum32_5=Zx;function $x(r,e,t,n){var a=r[e],i=r[e+1],o=n+i>>>0,s=(o<n?1:0)+t+a;r[e]=s>>>0,r[e+1]=o;}Ge.sum64=$x;function eb(r,e,t,n){var a=e+n>>>0,i=(a<e?1:0)+r+t;return i>>>0}Ge.sum64_hi=eb;function tb(r,e,t,n){var a=e+n;return a>>>0}Ge.sum64_lo=tb;function rb(r,e,t,n,a,i,o,s){var p=0,c=e;c=c+n>>>0,p+=c<e?1:0,c=c+i>>>0,p+=c<i?1:0,c=c+s>>>0,p+=c<s?1:0;var l=r+t+a+o+p;return l>>>0}Ge.sum64_4_hi=rb;function nb(r,e,t,n,a,i,o,s){var p=e+n+i+s;return p>>>0}Ge.sum64_4_lo=nb;function ab(r,e,t,n,a,i,o,s,p,c){var l=0,f=e;f=f+n>>>0,l+=f<e?1:0,f=f+i>>>0,l+=f<i?1:0,f=f+s>>>0,l+=f<s?1:0,f=f+c>>>0,l+=f<c?1:0;var h=r+t+a+o+p+l;return h>>>0}Ge.sum64_5_hi=ab;function ib(r,e,t,n,a,i,o,s,p,c){var l=e+n+i+s+c;return l>>>0}Ge.sum64_5_lo=ib;function ob(r,e,t){var n=e<<32-t|r>>>t;return n>>>0}Ge.rotr64_hi=ob;function sb(r,e,t){var n=r<<32-t|e>>>t;return n>>>0}Ge.rotr64_lo=sb;function ub(r,e,t){return r>>>t}Ge.shr64_hi=ub;function pb(r,e,t){var n=r<<32-t|e>>>t;return n>>>0}Ge.shr64_lo=pb;});var Ln=ee(Fl=>{var Ml=Gt(),lb=On();function mi(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32;}Fl.BlockHash=mi;mi.prototype.update=function(e,t){if(e=Ml.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=Ml.join32(e,0,e.length-n,this.endian);for(var a=0;a<e.length;a+=this._delta32)this._update(e,a,a+this._delta32);}return this};mi.prototype.digest=function(e){return this.update(this._pad()),lb(this.pending===null),this._digest(e)};mi.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,n=t-(e+this.padLength)%t,a=new Array(n+this.padLength);a[0]=128;for(var i=1;i<n;i++)a[i]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)a[i++]=0;a[i++]=0,a[i++]=0,a[i++]=0,a[i++]=0,a[i++]=e>>>24&255,a[i++]=e>>>16&255,a[i++]=e>>>8&255,a[i++]=e&255;}else for(a[i++]=e&255,a[i++]=e>>>8&255,a[i++]=e>>>16&255,a[i++]=e>>>24&255,a[i++]=0,a[i++]=0,a[i++]=0,a[i++]=0,o=8;o<this.padLength;o++)a[i++]=0;return a};});var Os=ee(Ir=>{var cb=Gt(),ir=cb.rotr32;function db(r,e,t,n){if(r===0)return Nl(e,t,n);if(r===1||r===3)return Ll(e,t,n);if(r===2)return Ol(e,t,n)}Ir.ft_1=db;function Nl(r,e,t){return r&e^~r&t}Ir.ch32=Nl;function Ol(r,e,t){return r&e^r&t^e&t}Ir.maj32=Ol;function Ll(r,e,t){return r^e^t}Ir.p32=Ll;function fb(r){return ir(r,2)^ir(r,13)^ir(r,22)}Ir.s0_256=fb;function mb(r){return ir(r,6)^ir(r,11)^ir(r,25)}Ir.s1_256=mb;function hb(r){return ir(r,7)^ir(r,18)^r>>>3}Ir.g0_256=hb;function yb(r){return ir(r,17)^ir(r,19)^r>>>10}Ir.g1_256=yb;});var Gl=ee((v8,ql)=>{var Un=Gt(),gb=Ln(),xb=Os(),Ls=Un.rotl32,ha=Un.sum32,bb=Un.sum32_5,vb=xb.ft_1,Ul=gb.BlockHash,Ab=[1518500249,1859775393,2400959708,3395469782];function or(){if(!(this instanceof or))return new or;Ul.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80);}Un.inherits(or,Ul);ql.exports=or;or.blockSize=512;or.outSize=160;or.hmacStrength=80;or.padLength=64;or.prototype._update=function(e,t){for(var n=this.W,a=0;a<16;a++)n[a]=e[t+a];for(;a<n.length;a++)n[a]=Ls(n[a-3]^n[a-8]^n[a-14]^n[a-16],1);var i=this.h[0],o=this.h[1],s=this.h[2],p=this.h[3],c=this.h[4];for(a=0;a<n.length;a++){var l=~~(a/20),f=bb(Ls(i,5),vb(l,o,s,p),c,n[a],Ab[l]);c=p,p=s,s=Ls(o,30),o=i,i=f;}this.h[0]=ha(this.h[0],i),this.h[1]=ha(this.h[1],o),this.h[2]=ha(this.h[2],s),this.h[3]=ha(this.h[3],p),this.h[4]=ha(this.h[4],c);};or.prototype._digest=function(e){return e==="hex"?Un.toHex32(this.h,"big"):Un.split32(this.h,"big")};});var Us=ee((A8,Hl)=>{var qn=Gt(),wb=Ln(),Gn=Os(),Cb=On(),zt=qn.sum32,Eb=qn.sum32_4,Ib=qn.sum32_5,Pb=Gn.ch32,Rb=Gn.maj32,_b=Gn.s0_256,Tb=Gn.s1_256,kb=Gn.g0_256,Bb=Gn.g1_256,zl=wb.BlockHash,Sb=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function sr(){if(!(this instanceof sr))return new sr;zl.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Sb,this.W=new Array(64);}qn.inherits(sr,zl);Hl.exports=sr;sr.blockSize=512;sr.outSize=256;sr.hmacStrength=192;sr.padLength=64;sr.prototype._update=function(e,t){for(var n=this.W,a=0;a<16;a++)n[a]=e[t+a];for(;a<n.length;a++)n[a]=Eb(Bb(n[a-2]),n[a-7],kb(n[a-15]),n[a-16]);var i=this.h[0],o=this.h[1],s=this.h[2],p=this.h[3],c=this.h[4],l=this.h[5],f=this.h[6],h=this.h[7];for(Cb(this.k.length===n.length),a=0;a<n.length;a++){var y=Ib(h,Tb(c),Pb(c,l,f),this.k[a],n[a]),x=zt(_b(i),Rb(i,o,s));h=f,f=l,l=c,c=zt(p,y),p=s,s=o,o=i,i=zt(y,x);}this.h[0]=zt(this.h[0],i),this.h[1]=zt(this.h[1],o),this.h[2]=zt(this.h[2],s),this.h[3]=zt(this.h[3],p),this.h[4]=zt(this.h[4],c),this.h[5]=zt(this.h[5],l),this.h[6]=zt(this.h[6],f),this.h[7]=zt(this.h[7],h);};sr.prototype._digest=function(e){return e==="hex"?qn.toHex32(this.h,"big"):qn.split32(this.h,"big")};});var Ql=ee((w8,Kl)=>{var qs=Gt(),Wl=Us();function Pr(){if(!(this instanceof Pr))return new Pr;Wl.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428];}qs.inherits(Pr,Wl);Kl.exports=Pr;Pr.blockSize=512;Pr.outSize=224;Pr.hmacStrength=192;Pr.padLength=64;Pr.prototype._digest=function(e){return e==="hex"?qs.toHex32(this.h.slice(0,7),"big"):qs.split32(this.h.slice(0,7),"big")};});var Hs=ee((C8,Yl)=>{var It=Gt(),Db=Ln(),Mb=On(),ur=It.rotr64_hi,pr=It.rotr64_lo,Vl=It.shr64_hi,jl=It.shr64_lo,Xr=It.sum64,Gs=It.sum64_hi,zs=It.sum64_lo,Fb=It.sum64_4_hi,Nb=It.sum64_4_lo,Ob=It.sum64_5_hi,Lb=It.sum64_5_lo,Jl=Db.BlockHash,Ub=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Ht(){if(!(this instanceof Ht))return new Ht;Jl.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Ub,this.W=new Array(160);}It.inherits(Ht,Jl);Yl.exports=Ht;Ht.blockSize=1024;Ht.outSize=512;Ht.hmacStrength=192;Ht.padLength=128;Ht.prototype._prepareBlock=function(e,t){for(var n=this.W,a=0;a<32;a++)n[a]=e[t+a];for(;a<n.length;a+=2){var i=Yb(n[a-4],n[a-3]),o=Xb(n[a-4],n[a-3]),s=n[a-14],p=n[a-13],c=jb(n[a-30],n[a-29]),l=Jb(n[a-30],n[a-29]),f=n[a-32],h=n[a-31];n[a]=Fb(i,o,s,p,c,l,f,h),n[a+1]=Nb(i,o,s,p,c,l,f,h);}};Ht.prototype._update=function(e,t){this._prepareBlock(e,t);var n=this.W,a=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],p=this.h[4],c=this.h[5],l=this.h[6],f=this.h[7],h=this.h[8],y=this.h[9],x=this.h[10],w=this.h[11],_=this.h[12],v=this.h[13],E=this.h[14],B=this.h[15];Mb(this.k.length===n.length);for(var S=0;S<n.length;S+=2){var D=E,M=B,G=Qb(h,y),L=Vb(h,y),z=qb(h,y,x,w,_),W=Gb(h,y,x,w,_,v),N=this.k[S],H=this.k[S+1],R=n[S],u=n[S+1],m=Ob(D,M,G,L,z,W,N,H,R,u),b=Lb(D,M,G,L,z,W,N,H,R,u);D=Wb(a,i),M=Kb(a,i),G=zb(a,i,o,s,p),L=Hb(a,i,o,s,p,c);var C=Gs(D,M,G,L),P=zs(D,M,G,L);E=_,B=v,_=x,v=w,x=h,w=y,h=Gs(l,f,m,b),y=zs(f,f,m,b),l=p,f=c,p=o,c=s,o=a,s=i,a=Gs(m,b,C,P),i=zs(m,b,C,P);}Xr(this.h,0,a,i),Xr(this.h,2,o,s),Xr(this.h,4,p,c),Xr(this.h,6,l,f),Xr(this.h,8,h,y),Xr(this.h,10,x,w),Xr(this.h,12,_,v),Xr(this.h,14,E,B);};Ht.prototype._digest=function(e){return e==="hex"?It.toHex32(this.h,"big"):It.split32(this.h,"big")};function qb(r,e,t,n,a){var i=r&t^~r&a;return i<0&&(i+=4294967296),i}function Gb(r,e,t,n,a,i){var o=e&n^~e&i;return o<0&&(o+=4294967296),o}function zb(r,e,t,n,a){var i=r&t^r&a^t&a;return i<0&&(i+=4294967296),i}function Hb(r,e,t,n,a,i){var o=e&n^e&i^n&i;return o<0&&(o+=4294967296),o}function Wb(r,e){var t=ur(r,e,28),n=ur(e,r,2),a=ur(e,r,7),i=t^n^a;return i<0&&(i+=4294967296),i}function Kb(r,e){var t=pr(r,e,28),n=pr(e,r,2),a=pr(e,r,7),i=t^n^a;return i<0&&(i+=4294967296),i}function Qb(r,e){var t=ur(r,e,14),n=ur(r,e,18),a=ur(e,r,9),i=t^n^a;return i<0&&(i+=4294967296),i}function Vb(r,e){var t=pr(r,e,14),n=pr(r,e,18),a=pr(e,r,9),i=t^n^a;return i<0&&(i+=4294967296),i}function jb(r,e){var t=ur(r,e,1),n=ur(r,e,8),a=Vl(r,e,7),i=t^n^a;return i<0&&(i+=4294967296),i}function Jb(r,e){var t=pr(r,e,1),n=pr(r,e,8),a=jl(r,e,7),i=t^n^a;return i<0&&(i+=4294967296),i}function Yb(r,e){var t=ur(r,e,19),n=ur(e,r,29),a=Vl(r,e,6),i=t^n^a;return i<0&&(i+=4294967296),i}function Xb(r,e){var t=pr(r,e,19),n=pr(e,r,29),a=jl(r,e,6),i=t^n^a;return i<0&&(i+=4294967296),i}});var $l=ee((E8,Zl)=>{var Ws=Gt(),Xl=Hs();function Rr(){if(!(this instanceof Rr))return new Rr;Xl.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428];}Ws.inherits(Rr,Xl);Zl.exports=Rr;Rr.blockSize=1024;Rr.outSize=384;Rr.hmacStrength=192;Rr.padLength=128;Rr.prototype._digest=function(e){return e==="hex"?Ws.toHex32(this.h.slice(0,12),"big"):Ws.split32(this.h.slice(0,12),"big")};});var ec=ee(zn=>{zn.sha1=Gl();zn.sha224=Ql();zn.sha256=Us();zn.sha384=$l();zn.sha512=Hs();});var oc=ee(ic=>{var pn=Gt(),Zb=Ln(),hi=pn.rotl32,tc=pn.sum32,ya=pn.sum32_3,rc=pn.sum32_4,ac=Zb.BlockHash;function lr(){if(!(this instanceof lr))return new lr;ac.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little";}pn.inherits(lr,ac);ic.ripemd160=lr;lr.blockSize=512;lr.outSize=160;lr.hmacStrength=192;lr.padLength=64;lr.prototype._update=function(e,t){for(var n=this.h[0],a=this.h[1],i=this.h[2],o=this.h[3],s=this.h[4],p=n,c=a,l=i,f=o,h=s,y=0;y<80;y++){var x=tc(hi(rc(n,nc(y,a,i,o),e[t2[y]+t],$b(y)),n2[y]),s);n=s,s=o,o=hi(i,10),i=a,a=x,x=tc(hi(rc(p,nc(79-y,c,l,f),e[r2[y]+t],e2(y)),a2[y]),h),p=h,h=f,f=hi(l,10),l=c,c=x;}x=ya(this.h[1],i,f),this.h[1]=ya(this.h[2],o,h),this.h[2]=ya(this.h[3],s,p),this.h[3]=ya(this.h[4],n,c),this.h[4]=ya(this.h[0],a,l),this.h[0]=x;};lr.prototype._digest=function(e){return e==="hex"?pn.toHex32(this.h,"little"):pn.split32(this.h,"little")};function nc(r,e,t,n){return r<=15?e^t^n:r<=31?e&t|~e&n:r<=47?(e|~t)^n:r<=63?e&n|t&~n:e^(t|~n)}function $b(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function e2(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var t2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],r2=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],n2=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],a2=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];});var uc=ee((R8,sc)=>{var i2=Gt(),o2=On();function Hn(r,e,t){if(!(this instanceof Hn))return new Hn(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(i2.toArray(e,t));}sc.exports=Hn;Hn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),o2(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=new this.Hash().update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=new this.Hash().update(e);};Hn.prototype.update=function(e,t){return this.inner.update(e,t),this};Hn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)};});var Ks=ee(pc=>{var ct=pc;ct.utils=Gt();ct.common=Ln();ct.sha=ec();ct.ripemd=oc();ct.hmac=uc();ct.sha1=ct.sha.sha1;ct.sha256=ct.sha.sha256;ct.sha224=ct.sha.sha224;ct.sha384=ct.sha.sha384;ct.sha512=ct.sha.sha512;ct.ripemd160=ct.ripemd.ripemd160;});var xc=ee((X8,gc)=>{var xi="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Qs={};for(xa=0;xa<xi.length;xa++){if(gi=xi.charAt(xa),Qs[gi]!==void 0)throw new TypeError(gi+" is ambiguous");Qs[gi]=xa;}var gi,xa;function Wn(r){var e=r>>25;return (r&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function hc(r){for(var e=1,t=0;t<r.length;++t){var n=r.charCodeAt(t);if(n<33||n>126)return "Invalid prefix ("+r+")";e=Wn(e)^n>>5;}for(e=Wn(e),t=0;t<r.length;++t){var a=r.charCodeAt(t);e=Wn(e)^a&31;}return e}function h2(r,e,t){if(t=t||90,r.length+7+e.length>t)throw new TypeError("Exceeds length limit");r=r.toLowerCase();var n=hc(r);if(typeof n=="string")throw new Error(n);for(var a=r+"1",i=0;i<e.length;++i){var o=e[i];if(o>>5!==0)throw new Error("Non 5-bit word");n=Wn(n)^o,a+=xi.charAt(o);}for(i=0;i<6;++i)n=Wn(n);for(n^=1,i=0;i<6;++i){var s=n>>(5-i)*5&31;a+=xi.charAt(s);}return a}function yc(r,e){if(e=e||90,r.length<8)return r+" too short";if(r.length>e)return "Exceeds length limit";var t=r.toLowerCase(),n=r.toUpperCase();if(r!==t&&r!==n)return "Mixed-case string "+r;r=t;var a=r.lastIndexOf("1");if(a===-1)return "No separator character for "+r;if(a===0)return "Missing prefix for "+r;var i=r.slice(0,a),o=r.slice(a+1);if(o.length<6)return "Data too short";var s=hc(i);if(typeof s=="string")return s;for(var p=[],c=0;c<o.length;++c){var l=o.charAt(c),f=Qs[l];if(f===void 0)return "Unknown character "+l;s=Wn(s)^f,!(c+6>=o.length)&&p.push(f);}return s!==1?"Invalid checksum for "+r:{prefix:i,words:p}}function y2(){var r=yc.apply(null,arguments);if(typeof r=="object")return r}function g2(r){var e=yc.apply(null,arguments);if(typeof e=="object")return e;throw new Error(e)}function bi(r,e,t,n){for(var a=0,i=0,o=(1<<t)-1,s=[],p=0;p<r.length;++p)for(a=a<<e|r[p],i+=e;i>=t;)i-=t,s.push(a>>i&o);if(n)i>0&&s.push(a<<t-i&o);else {if(i>=e)return "Excess padding";if(a<<t-i&o)return "Non-zero padding"}return s}function x2(r){var e=bi(r,8,5,true);if(Array.isArray(e))return e}function b2(r){var e=bi(r,8,5,true);if(Array.isArray(e))return e;throw new Error(e)}function v2(r){var e=bi(r,5,8,false);if(Array.isArray(e))return e}function A2(r){var e=bi(r,5,8,false);if(Array.isArray(e))return e;throw new Error(e)}gc.exports={decodeUnsafe:y2,decode:g2,encode:h2,toWordsUnsafe:x2,toWords:b2,fromWordsUnsafe:v2,fromWords:A2};});var fe=ee((Ki,of)=>{(function(r,e){typeof Ki=="object"?of.exports=Ki=e():typeof define=="function"&&define.amd?define([],e):r.CryptoJS=e();})(Ki,function(){var r=r||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof na=="function")try{n=na("crypto");}catch{}var a=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||(function(){function v(){}return function(E){var B;return v.prototype=E,B=new v,v.prototype=null,B}})(),o={},s=o.lib={},p=s.Base=(function(){return {extend:function(v){var E=i(this);return v&&E.mixIn(v),(!E.hasOwnProperty("init")||this.init===E.init)&&(E.init=function(){E.$super.init.apply(this,arguments);}),E.init.prototype=E,E.$super=this,E},create:function(){var v=this.extend();return v.init.apply(v,arguments),v},init:function(){},mixIn:function(v){for(var E in v)v.hasOwnProperty(E)&&(this[E]=v[E]);v.hasOwnProperty("toString")&&(this.toString=v.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),c=s.WordArray=p.extend({init:function(v,E){v=this.words=v||[],E!=t?this.sigBytes=E:this.sigBytes=v.length*4;},toString:function(v){return (v||f).stringify(this)},concat:function(v){var E=this.words,B=v.words,S=this.sigBytes,D=v.sigBytes;if(this.clamp(),S%4)for(var M=0;M<D;M++){var G=B[M>>>2]>>>24-M%4*8&255;E[S+M>>>2]|=G<<24-(S+M)%4*8;}else for(var L=0;L<D;L+=4)E[S+L>>>2]=B[L>>>2];return this.sigBytes+=D,this},clamp:function(){var v=this.words,E=this.sigBytes;v[E>>>2]&=4294967295<<32-E%4*8,v.length=e.ceil(E/4);},clone:function(){var v=p.clone.call(this);return v.words=this.words.slice(0),v},random:function(v){for(var E=[],B=0;B<v;B+=4)E.push(a());return new c.init(E,v)}}),l=o.enc={},f=l.Hex={stringify:function(v){for(var E=v.words,B=v.sigBytes,S=[],D=0;D<B;D++){var M=E[D>>>2]>>>24-D%4*8&255;S.push((M>>>4).toString(16)),S.push((M&15).toString(16));}return S.join("")},parse:function(v){for(var E=v.length,B=[],S=0;S<E;S+=2)B[S>>>3]|=parseInt(v.substr(S,2),16)<<24-S%8*4;return new c.init(B,E/2)}},h=l.Latin1={stringify:function(v){for(var E=v.words,B=v.sigBytes,S=[],D=0;D<B;D++){var M=E[D>>>2]>>>24-D%4*8&255;S.push(String.fromCharCode(M));}return S.join("")},parse:function(v){for(var E=v.length,B=[],S=0;S<E;S++)B[S>>>2]|=(v.charCodeAt(S)&255)<<24-S%4*8;return new c.init(B,E)}},y=l.Utf8={stringify:function(v){try{return decodeURIComponent(escape(h.stringify(v)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(v){return h.parse(unescape(encodeURIComponent(v)))}},x=s.BufferedBlockAlgorithm=p.extend({reset:function(){this._data=new c.init,this._nDataBytes=0;},_append:function(v){typeof v=="string"&&(v=y.parse(v)),this._data.concat(v),this._nDataBytes+=v.sigBytes;},_process:function(v){var E,B=this._data,S=B.words,D=B.sigBytes,M=this.blockSize,G=M*4,L=D/G;v?L=e.ceil(L):L=e.max((L|0)-this._minBufferSize,0);var z=L*M,W=e.min(z*4,D);if(z){for(var N=0;N<z;N+=M)this._doProcessBlock(S,N);E=S.splice(0,z),B.sigBytes-=W;}return new c.init(E,W)},clone:function(){var v=p.clone.call(this);return v._data=this._data.clone(),v},_minBufferSize:0});s.Hasher=x.extend({cfg:p.extend(),init:function(v){this.cfg=this.cfg.extend(v),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(v){return this._append(v),this._process(),this},finalize:function(v){v&&this._append(v);var E=this._doFinalize();return E},blockSize:512/32,_createHelper:function(v){return function(E,B){return new v.init(B).finalize(E)}},_createHmacHelper:function(v){return function(E,B){return new _.HMAC.init(v,B).finalize(E)}}});var _=o.algo={};return o})(Math);return r});});var uf=ee((Qi,sf)=>{(function(r,e){typeof Qi=="object"?sf.exports=Qi=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(Qi,function(r){return r.enc.Hex});});var Fr=ee((Vi,pf)=>{(function(r,e){typeof Vi=="object"?pf.exports=Vi=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(Vi,function(r){return (function(e){var t=r,n=t.lib,a=n.WordArray,i=n.Hasher,o=t.algo,s=[];(function(){for(var y=0;y<64;y++)s[y]=e.abs(e.sin(y+1))*4294967296|0;})();var p=o.MD5=i.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878]);},_doProcessBlock:function(y,x){for(var w=0;w<16;w++){var _=x+w,v=y[_];y[_]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360;}var E=this._hash.words,B=y[x+0],S=y[x+1],D=y[x+2],M=y[x+3],G=y[x+4],L=y[x+5],z=y[x+6],W=y[x+7],N=y[x+8],H=y[x+9],R=y[x+10],u=y[x+11],m=y[x+12],b=y[x+13],C=y[x+14],P=y[x+15],I=E[0],k=E[1],A=E[2],d=E[3];I=c(I,k,A,d,B,7,s[0]),d=c(d,I,k,A,S,12,s[1]),A=c(A,d,I,k,D,17,s[2]),k=c(k,A,d,I,M,22,s[3]),I=c(I,k,A,d,G,7,s[4]),d=c(d,I,k,A,L,12,s[5]),A=c(A,d,I,k,z,17,s[6]),k=c(k,A,d,I,W,22,s[7]),I=c(I,k,A,d,N,7,s[8]),d=c(d,I,k,A,H,12,s[9]),A=c(A,d,I,k,R,17,s[10]),k=c(k,A,d,I,u,22,s[11]),I=c(I,k,A,d,m,7,s[12]),d=c(d,I,k,A,b,12,s[13]),A=c(A,d,I,k,C,17,s[14]),k=c(k,A,d,I,P,22,s[15]),I=l(I,k,A,d,S,5,s[16]),d=l(d,I,k,A,z,9,s[17]),A=l(A,d,I,k,u,14,s[18]),k=l(k,A,d,I,B,20,s[19]),I=l(I,k,A,d,L,5,s[20]),d=l(d,I,k,A,R,9,s[21]),A=l(A,d,I,k,P,14,s[22]),k=l(k,A,d,I,G,20,s[23]),I=l(I,k,A,d,H,5,s[24]),d=l(d,I,k,A,C,9,s[25]),A=l(A,d,I,k,M,14,s[26]),k=l(k,A,d,I,N,20,s[27]),I=l(I,k,A,d,b,5,s[28]),d=l(d,I,k,A,D,9,s[29]),A=l(A,d,I,k,W,14,s[30]),k=l(k,A,d,I,m,20,s[31]),I=f(I,k,A,d,L,4,s[32]),d=f(d,I,k,A,N,11,s[33]),A=f(A,d,I,k,u,16,s[34]),k=f(k,A,d,I,C,23,s[35]),I=f(I,k,A,d,S,4,s[36]),d=f(d,I,k,A,G,11,s[37]),A=f(A,d,I,k,W,16,s[38]),k=f(k,A,d,I,R,23,s[39]),I=f(I,k,A,d,b,4,s[40]),d=f(d,I,k,A,B,11,s[41]),A=f(A,d,I,k,M,16,s[42]),k=f(k,A,d,I,z,23,s[43]),I=f(I,k,A,d,H,4,s[44]),d=f(d,I,k,A,m,11,s[45]),A=f(A,d,I,k,P,16,s[46]),k=f(k,A,d,I,D,23,s[47]),I=h(I,k,A,d,B,6,s[48]),d=h(d,I,k,A,W,10,s[49]),A=h(A,d,I,k,C,15,s[50]),k=h(k,A,d,I,L,21,s[51]),I=h(I,k,A,d,m,6,s[52]),d=h(d,I,k,A,M,10,s[53]),A=h(A,d,I,k,R,15,s[54]),k=h(k,A,d,I,S,21,s[55]),I=h(I,k,A,d,N,6,s[56]),d=h(d,I,k,A,P,10,s[57]),A=h(A,d,I,k,z,15,s[58]),k=h(k,A,d,I,b,21,s[59]),I=h(I,k,A,d,G,6,s[60]),d=h(d,I,k,A,u,10,s[61]),A=h(A,d,I,k,D,15,s[62]),k=h(k,A,d,I,H,21,s[63]),E[0]=E[0]+I|0,E[1]=E[1]+k|0,E[2]=E[2]+A|0,E[3]=E[3]+d|0;},_doFinalize:function(){var y=this._data,x=y.words,w=this._nDataBytes*8,_=y.sigBytes*8;x[_>>>5]|=128<<24-_%32;var v=e.floor(w/4294967296),E=w;x[(_+64>>>9<<4)+15]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,x[(_+64>>>9<<4)+14]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,y.sigBytes=(x.length+1)*4,this._process();for(var B=this._hash,S=B.words,D=0;D<4;D++){var M=S[D];S[D]=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360;}return B},clone:function(){var y=i.clone.call(this);return y._hash=this._hash.clone(),y}});function c(y,x,w,_,v,E,B){var S=y+(x&w|~x&_)+v+B;return (S<<E|S>>>32-E)+x}function l(y,x,w,_,v,E,B){var S=y+(x&_|w&~_)+v+B;return (S<<E|S>>>32-E)+x}function f(y,x,w,_,v,E,B){var S=y+(x^w^_)+v+B;return (S<<E|S>>>32-E)+x}function h(y,x,w,_,v,E,B){var S=y+(w^(x|~_))+v+B;return (S<<E|S>>>32-E)+x}t.MD5=i._createHelper(p),t.HmacMD5=i._createHmacHelper(p);})(Math),r.MD5});});var Fa=ee((uo,Af)=>{(function(r,e){typeof uo=="object"?Af.exports=uo=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(uo,function(r){return (function(e){var t=r,n=t.lib,a=n.Base,i=n.WordArray,o=t.x64={};o.Word=a.extend({init:function(c,l){this.high=c,this.low=l;}});o.WordArray=a.extend({init:function(c,l){c=this.words=c||[],l!=e?this.sigBytes=l:this.sigBytes=c.length*8;},toX32:function(){for(var c=this.words,l=c.length,f=[],h=0;h<l;h++){var y=c[h];f.push(y.high),f.push(y.low);}return i.create(f,this.sigBytes)},clone:function(){for(var c=a.clone.call(this),l=c.words=this.words.slice(0),f=l.length,h=0;h<f;h++)l[h]=l[h].clone();return c}});})(),r});});var Cf=ee((po,wf)=>{(function(r,e){typeof po=="object"?wf.exports=po=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(po,function(r){return (function(){if(typeof ArrayBuffer=="function"){var e=r,t=e.lib,n=t.WordArray,a=n.init,i=n.init=function(o){if(o instanceof ArrayBuffer&&(o=new Uint8Array(o)),(o instanceof Int8Array||typeof Uint8ClampedArray<"u"&&o instanceof Uint8ClampedArray||o instanceof Int16Array||o instanceof Uint16Array||o instanceof Int32Array||o instanceof Uint32Array||o instanceof Float32Array||o instanceof Float64Array)&&(o=new Uint8Array(o.buffer,o.byteOffset,o.byteLength)),o instanceof Uint8Array){for(var s=o.byteLength,p=[],c=0;c<s;c++)p[c>>>2]|=o[c]<<24-c%4*8;a.call(this,p,s);}else a.apply(this,arguments);};i.prototype=n;}})(),r.lib.WordArray});});var If=ee((lo,Ef)=>{(function(r,e){typeof lo=="object"?Ef.exports=lo=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(lo,function(r){return (function(){var e=r,t=e.lib,n=t.WordArray,a=e.enc;a.Utf16=a.Utf16BE={stringify:function(s){for(var p=s.words,c=s.sigBytes,l=[],f=0;f<c;f+=2){var h=p[f>>>2]>>>16-f%4*8&65535;l.push(String.fromCharCode(h));}return l.join("")},parse:function(s){for(var p=s.length,c=[],l=0;l<p;l++)c[l>>>1]|=s.charCodeAt(l)<<16-l%2*16;return n.create(c,p*2)}};a.Utf16LE={stringify:function(s){for(var p=s.words,c=s.sigBytes,l=[],f=0;f<c;f+=2){var h=o(p[f>>>2]>>>16-f%4*8&65535);l.push(String.fromCharCode(h));}return l.join("")},parse:function(s){for(var p=s.length,c=[],l=0;l<p;l++)c[l>>>1]|=o(s.charCodeAt(l)<<16-l%2*16);return n.create(c,p*2)}};function o(s){return s<<8&4278255360|s>>>8&16711935}})(),r.enc.Utf16});});var nn=ee((co,Pf)=>{(function(r,e){typeof co=="object"?Pf.exports=co=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(co,function(r){return (function(){var e=r,t=e.lib,n=t.WordArray,a=e.enc;a.Base64={stringify:function(s){var p=s.words,c=s.sigBytes,l=this._map;s.clamp();for(var f=[],h=0;h<c;h+=3)for(var y=p[h>>>2]>>>24-h%4*8&255,x=p[h+1>>>2]>>>24-(h+1)%4*8&255,w=p[h+2>>>2]>>>24-(h+2)%4*8&255,_=y<<16|x<<8|w,v=0;v<4&&h+v*.75<c;v++)f.push(l.charAt(_>>>6*(3-v)&63));var E=l.charAt(64);if(E)for(;f.length%4;)f.push(E);return f.join("")},parse:function(s){var p=s.length,c=this._map,l=this._reverseMap;if(!l){l=this._reverseMap=[];for(var f=0;f<c.length;f++)l[c.charCodeAt(f)]=f;}var h=c.charAt(64);if(h){var y=s.indexOf(h);y!==-1&&(p=y);}return o(s,p,l)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function o(s,p,c){for(var l=[],f=0,h=0;h<p;h++)if(h%4){var y=c[s.charCodeAt(h-1)]<<h%4*2,x=c[s.charCodeAt(h)]>>>6-h%4*2,w=y|x;l[f>>>2]|=w<<24-f%4*8,f++;}return n.create(l,f)}})(),r.enc.Base64});});var _f=ee((fo,Rf)=>{(function(r,e){typeof fo=="object"?Rf.exports=fo=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(fo,function(r){return (function(){var e=r,t=e.lib,n=t.WordArray,a=e.enc;a.Base64url={stringify:function(s,p){p===void 0&&(p=true);var c=s.words,l=s.sigBytes,f=p?this._safe_map:this._map;s.clamp();for(var h=[],y=0;y<l;y+=3)for(var x=c[y>>>2]>>>24-y%4*8&255,w=c[y+1>>>2]>>>24-(y+1)%4*8&255,_=c[y+2>>>2]>>>24-(y+2)%4*8&255,v=x<<16|w<<8|_,E=0;E<4&&y+E*.75<l;E++)h.push(f.charAt(v>>>6*(3-E)&63));var B=f.charAt(64);if(B)for(;h.length%4;)h.push(B);return h.join("")},parse:function(s,p){p===void 0&&(p=true);var c=s.length,l=p?this._safe_map:this._map,f=this._reverseMap;if(!f){f=this._reverseMap=[];for(var h=0;h<l.length;h++)f[l.charCodeAt(h)]=h;}var y=l.charAt(64);if(y){var x=s.indexOf(y);x!==-1&&(c=x);}return o(s,c,f)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function o(s,p,c){for(var l=[],f=0,h=0;h<p;h++)if(h%4){var y=c[s.charCodeAt(h-1)]<<h%4*2,x=c[s.charCodeAt(h)]>>>6-h%4*2,w=y|x;l[f>>>2]|=w<<24-f%4*8,f++;}return n.create(l,f)}})(),r.enc.Base64url});});var Iu=ee((mo,Tf)=>{(function(r,e){typeof mo=="object"?Tf.exports=mo=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(mo,function(r){return (function(){var e=r,t=e.lib,n=t.WordArray,a=t.Hasher,i=e.algo,o=[],s=i.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(p,c){for(var l=this._hash.words,f=l[0],h=l[1],y=l[2],x=l[3],w=l[4],_=0;_<80;_++){if(_<16)o[_]=p[c+_]|0;else {var v=o[_-3]^o[_-8]^o[_-14]^o[_-16];o[_]=v<<1|v>>>31;}var E=(f<<5|f>>>27)+w+o[_];_<20?E+=(h&y|~h&x)+1518500249:_<40?E+=(h^y^x)+1859775393:_<60?E+=(h&y|h&x|y&x)-1894007588:E+=(h^y^x)-899497514,w=x,x=y,y=h<<30|h>>>2,h=f,f=E;}l[0]=l[0]+f|0,l[1]=l[1]+h|0,l[2]=l[2]+y|0,l[3]=l[3]+x|0,l[4]=l[4]+w|0;},_doFinalize:function(){var p=this._data,c=p.words,l=this._nDataBytes*8,f=p.sigBytes*8;return c[f>>>5]|=128<<24-f%32,c[(f+64>>>9<<4)+14]=Math.floor(l/4294967296),c[(f+64>>>9<<4)+15]=l,p.sigBytes=c.length*4,this._process(),this._hash},clone:function(){var p=a.clone.call(this);return p._hash=this._hash.clone(),p}});e.SHA1=a._createHelper(s),e.HmacSHA1=a._createHmacHelper(s);})(),r.SHA1});});var yo=ee((ho,kf)=>{(function(r,e){typeof ho=="object"?kf.exports=ho=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(ho,function(r){return (function(e){var t=r,n=t.lib,a=n.WordArray,i=n.Hasher,o=t.algo,s=[],p=[];(function(){function f(w){for(var _=e.sqrt(w),v=2;v<=_;v++)if(!(w%v))return false;return true}function h(w){return (w-(w|0))*4294967296|0}for(var y=2,x=0;x<64;)f(y)&&(x<8&&(s[x]=h(e.pow(y,1/2))),p[x]=h(e.pow(y,1/3)),x++),y++;})();var c=[],l=o.SHA256=i.extend({_doReset:function(){this._hash=new a.init(s.slice(0));},_doProcessBlock:function(f,h){for(var y=this._hash.words,x=y[0],w=y[1],_=y[2],v=y[3],E=y[4],B=y[5],S=y[6],D=y[7],M=0;M<64;M++){if(M<16)c[M]=f[h+M]|0;else {var G=c[M-15],L=(G<<25|G>>>7)^(G<<14|G>>>18)^G>>>3,z=c[M-2],W=(z<<15|z>>>17)^(z<<13|z>>>19)^z>>>10;c[M]=L+c[M-7]+W+c[M-16];}var N=E&B^~E&S,H=x&w^x&_^w&_,R=(x<<30|x>>>2)^(x<<19|x>>>13)^(x<<10|x>>>22),u=(E<<26|E>>>6)^(E<<21|E>>>11)^(E<<7|E>>>25),m=D+u+N+p[M]+c[M],b=R+H;D=S,S=B,B=E,E=v+m|0,v=_,_=w,w=x,x=m+b|0;}y[0]=y[0]+x|0,y[1]=y[1]+w|0,y[2]=y[2]+_|0,y[3]=y[3]+v|0,y[4]=y[4]+E|0,y[5]=y[5]+B|0,y[6]=y[6]+S|0,y[7]=y[7]+D|0;},_doFinalize:function(){var f=this._data,h=f.words,y=this._nDataBytes*8,x=f.sigBytes*8;return h[x>>>5]|=128<<24-x%32,h[(x+64>>>9<<4)+14]=e.floor(y/4294967296),h[(x+64>>>9<<4)+15]=y,f.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var f=i.clone.call(this);return f._hash=this._hash.clone(),f}});t.SHA256=i._createHelper(l),t.HmacSHA256=i._createHmacHelper(l);})(Math),r.SHA256});});var Sf=ee((go,Bf)=>{(function(r,e,t){typeof go=="object"?Bf.exports=go=e(fe(),yo()):typeof define=="function"&&define.amd?define(["./core","./sha256"],e):e(r.CryptoJS);})(go,function(r){return (function(){var e=r,t=e.lib,n=t.WordArray,a=e.algo,i=a.SHA256,o=a.SHA224=i.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);},_doFinalize:function(){var s=i._doFinalize.call(this);return s.sigBytes-=4,s}});e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o);})(),r.SHA224});});var Pu=ee((xo,Df)=>{(function(r,e,t){typeof xo=="object"?Df.exports=xo=e(fe(),Fa()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],e):e(r.CryptoJS);})(xo,function(r){return (function(){var e=r,t=e.lib,n=t.Hasher,a=e.x64,i=a.Word,o=a.WordArray,s=e.algo;function p(){return i.create.apply(i,arguments)}var c=[p(1116352408,3609767458),p(1899447441,602891725),p(3049323471,3964484399),p(3921009573,2173295548),p(961987163,4081628472),p(1508970993,3053834265),p(2453635748,2937671579),p(2870763221,3664609560),p(3624381080,2734883394),p(310598401,1164996542),p(607225278,1323610764),p(1426881987,3590304994),p(1925078388,4068182383),p(2162078206,991336113),p(2614888103,633803317),p(3248222580,3479774868),p(3835390401,2666613458),p(4022224774,944711139),p(264347078,2341262773),p(604807628,2007800933),p(770255983,1495990901),p(1249150122,1856431235),p(1555081692,3175218132),p(1996064986,2198950837),p(2554220882,3999719339),p(2821834349,766784016),p(2952996808,2566594879),p(3210313671,3203337956),p(3336571891,1034457026),p(3584528711,2466948901),p(113926993,3758326383),p(338241895,168717936),p(666307205,1188179964),p(773529912,1546045734),p(1294757372,1522805485),p(1396182291,2643833823),p(1695183700,2343527390),p(1986661051,1014477480),p(2177026350,1206759142),p(2456956037,344077627),p(2730485921,1290863460),p(2820302411,3158454273),p(3259730800,3505952657),p(3345764771,106217008),p(3516065817,3606008344),p(3600352804,1432725776),p(4094571909,1467031594),p(275423344,851169720),p(430227734,3100823752),p(506948616,1363258195),p(659060556,3750685593),p(883997877,3785050280),p(958139571,3318307427),p(1322822218,3812723403),p(1537002063,2003034995),p(1747873779,3602036899),p(1955562222,1575990012),p(2024104815,1125592928),p(2227730452,2716904306),p(2361852424,442776044),p(2428436474,593698344),p(2756734187,3733110249),p(3204031479,2999351573),p(3329325298,3815920427),p(3391569614,3928383900),p(3515267271,566280711),p(3940187606,3454069534),p(4118630271,4000239992),p(116418474,1914138554),p(174292421,2731055270),p(289380356,3203993006),p(460393269,320620315),p(685471733,587496836),p(852142971,1086792851),p(1017036298,365543100),p(1126000580,2618297676),p(1288033470,3409855158),p(1501505948,4234509866),p(1607167915,987167468),p(1816402316,1246189591)],l=[];(function(){for(var h=0;h<80;h++)l[h]=p();})();var f=s.SHA512=n.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)]);},_doProcessBlock:function(h,y){for(var x=this._hash.words,w=x[0],_=x[1],v=x[2],E=x[3],B=x[4],S=x[5],D=x[6],M=x[7],G=w.high,L=w.low,z=_.high,W=_.low,N=v.high,H=v.low,R=E.high,u=E.low,m=B.high,b=B.low,C=S.high,P=S.low,I=D.high,k=D.low,A=M.high,d=M.low,T=G,K=L,g=z,F=W,O=N,q=H,Q=R,X=u,j=m,V=b,Ee=C,J=P,te=I,Pt=k,we=A,be=d,it=0;it<80;it++){var pe,he,kt=l[it];if(it<16)he=kt.high=h[y+it*2]|0,pe=kt.low=h[y+it*2+1]|0;else {var Ie=l[it-15],ge=Ie.high,Rt=Ie.low,De=(ge>>>1|Rt<<31)^(ge>>>8|Rt<<24)^ge>>>7,Pe=(Rt>>>1|ge<<31)^(Rt>>>8|ge<<24)^(Rt>>>7|ge<<25),$t=l[it-2],xe=$t.high,ve=$t.low,gr=(xe>>>19|ve<<13)^(xe<<3|ve>>>29)^xe>>>6,Re=(ve>>>19|xe<<13)^(ve<<3|xe>>>29)^(ve>>>6|xe<<26),_e=l[it-7],xr=_e.high,Me=_e.low,Te=l[it-16],br=Te.high,ke=Te.low;pe=Pe+Me,he=De+xr+(pe>>>0<Pe>>>0?1:0),pe=pe+Re,he=he+gr+(pe>>>0<Re>>>0?1:0),pe=pe+ke,he=he+br+(pe>>>0<ke>>>0?1:0),kt.high=he,kt.low=pe;}var Fe=j&Ee^~j&te,er=V&J^~V&Pt,Ne=T&g^T&O^g&O,Oe=K&F^K&q^F&q,vr=(T>>>28|K<<4)^(T<<30|K>>>2)^(T<<25|K>>>7),Be=(K>>>28|T<<4)^(K<<30|T>>>2)^(K<<25|T>>>7),Le=(j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9),Ar=(V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9),Se=c[it],Ue=Se.high,tr=Se.low,ue=be+Ar,ye=we+Le+(ue>>>0<be>>>0?1:0),ue=ue+er,ye=ye+Fe+(ue>>>0<er>>>0?1:0),ue=ue+tr,ye=ye+Ue+(ue>>>0<tr>>>0?1:0),ue=ue+pe,ye=ye+he+(ue>>>0<pe>>>0?1:0),rr=Be+Oe,qe=vr+Ne+(rr>>>0<Be>>>0?1:0);we=te,be=Pt,te=Ee,Pt=J,Ee=j,J=V,V=X+ue|0,j=Q+ye+(V>>>0<X>>>0?1:0)|0,Q=O,X=q,O=g,q=F,g=T,F=K,K=ue+rr|0,T=ye+qe+(K>>>0<ue>>>0?1:0)|0;}L=w.low=L+K,w.high=G+T+(L>>>0<K>>>0?1:0),W=_.low=W+F,_.high=z+g+(W>>>0<F>>>0?1:0),H=v.low=H+q,v.high=N+O+(H>>>0<q>>>0?1:0),u=E.low=u+X,E.high=R+Q+(u>>>0<X>>>0?1:0),b=B.low=b+V,B.high=m+j+(b>>>0<V>>>0?1:0),P=S.low=P+J,S.high=C+Ee+(P>>>0<J>>>0?1:0),k=D.low=k+Pt,D.high=I+te+(k>>>0<Pt>>>0?1:0),d=M.low=d+be,M.high=A+we+(d>>>0<be>>>0?1:0);},_doFinalize:function(){var h=this._data,y=h.words,x=this._nDataBytes*8,w=h.sigBytes*8;y[w>>>5]|=128<<24-w%32,y[(w+128>>>10<<5)+30]=Math.floor(x/4294967296),y[(w+128>>>10<<5)+31]=x,h.sigBytes=y.length*4,this._process();var _=this._hash.toX32();return _},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h},blockSize:1024/32});e.SHA512=n._createHelper(f),e.HmacSHA512=n._createHmacHelper(f);})(),r.SHA512});});var Ff=ee((bo,Mf)=>{(function(r,e,t){typeof bo=="object"?Mf.exports=bo=e(fe(),Fa(),Pu()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./sha512"],e):e(r.CryptoJS);})(bo,function(r){return (function(){var e=r,t=e.x64,n=t.Word,a=t.WordArray,i=e.algo,o=i.SHA512,s=i.SHA384=o.extend({_doReset:function(){this._hash=new a.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)]);},_doFinalize:function(){var p=o._doFinalize.call(this);return p.sigBytes-=16,p}});e.SHA384=o._createHelper(s),e.HmacSHA384=o._createHmacHelper(s);})(),r.SHA384});});var Of=ee((vo,Nf)=>{(function(r,e,t){typeof vo=="object"?Nf.exports=vo=e(fe(),Fa()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],e):e(r.CryptoJS);})(vo,function(r){return (function(e){var t=r,n=t.lib,a=n.WordArray,i=n.Hasher,o=t.x64,s=o.Word,p=t.algo,c=[],l=[],f=[];(function(){for(var x=1,w=0,_=0;_<24;_++){c[x+5*w]=(_+1)*(_+2)/2%64;var v=w%5,E=(2*x+3*w)%5;x=v,w=E;}for(var x=0;x<5;x++)for(var w=0;w<5;w++)l[x+5*w]=w+(2*x+3*w)%5*5;for(var B=1,S=0;S<24;S++){for(var D=0,M=0,G=0;G<7;G++){if(B&1){var L=(1<<G)-1;L<32?M^=1<<L:D^=1<<L-32;}B&128?B=B<<1^113:B<<=1;}f[S]=s.create(D,M);}})();var h=[];(function(){for(var x=0;x<25;x++)h[x]=s.create();})();var y=p.SHA3=i.extend({cfg:i.cfg.extend({outputLength:512}),_doReset:function(){for(var x=this._state=[],w=0;w<25;w++)x[w]=new s.init;this.blockSize=(1600-2*this.cfg.outputLength)/32;},_doProcessBlock:function(x,w){for(var _=this._state,v=this.blockSize/2,E=0;E<v;E++){var B=x[w+2*E],S=x[w+2*E+1];B=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360,S=(S<<8|S>>>24)&16711935|(S<<24|S>>>8)&4278255360;var D=_[E];D.high^=S,D.low^=B;}for(var M=0;M<24;M++){for(var G=0;G<5;G++){for(var L=0,z=0,W=0;W<5;W++){var D=_[G+5*W];L^=D.high,z^=D.low;}var N=h[G];N.high=L,N.low=z;}for(var G=0;G<5;G++)for(var H=h[(G+4)%5],R=h[(G+1)%5],u=R.high,m=R.low,L=H.high^(u<<1|m>>>31),z=H.low^(m<<1|u>>>31),W=0;W<5;W++){var D=_[G+5*W];D.high^=L,D.low^=z;}for(var b=1;b<25;b++){var L,z,D=_[b],C=D.high,P=D.low,I=c[b];I<32?(L=C<<I|P>>>32-I,z=P<<I|C>>>32-I):(L=P<<I-32|C>>>64-I,z=C<<I-32|P>>>64-I);var k=h[l[b]];k.high=L,k.low=z;}var A=h[0],d=_[0];A.high=d.high,A.low=d.low;for(var G=0;G<5;G++)for(var W=0;W<5;W++){var b=G+5*W,D=_[b],T=h[b],K=h[(G+1)%5+5*W],g=h[(G+2)%5+5*W];D.high=T.high^~K.high&g.high,D.low=T.low^~K.low&g.low;}var D=_[0],F=f[M];D.high^=F.high,D.low^=F.low;}},_doFinalize:function(){var x=this._data,w=x.words;this._nDataBytes*8;var v=x.sigBytes*8,E=this.blockSize*32;w[v>>>5]|=1<<24-v%32,w[(e.ceil((v+1)/E)*E>>>5)-1]|=128,x.sigBytes=w.length*4,this._process();for(var B=this._state,S=this.cfg.outputLength/8,D=S/8,M=[],G=0;G<D;G++){var L=B[G],z=L.high,W=L.low;z=(z<<8|z>>>24)&16711935|(z<<24|z>>>8)&4278255360,W=(W<<8|W>>>24)&16711935|(W<<24|W>>>8)&4278255360,M.push(W),M.push(z);}return new a.init(M,S)},clone:function(){for(var x=i.clone.call(this),w=x._state=this._state.slice(0),_=0;_<25;_++)w[_]=w[_].clone();return x}});t.SHA3=i._createHelper(y),t.HmacSHA3=i._createHmacHelper(y);})(Math),r.SHA3});});var Uf=ee((Ao,Lf)=>{(function(r,e){typeof Ao=="object"?Lf.exports=Ao=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(Ao,function(r){return (function(e){var t=r,n=t.lib,a=n.WordArray,i=n.Hasher,o=t.algo,s=a.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),p=a.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=a.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),l=a.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),f=a.create([0,1518500249,1859775393,2400959708,2840853838]),h=a.create([1352829926,1548603684,1836072691,2053994217,0]),y=o.RIPEMD160=i.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(S,D){for(var M=0;M<16;M++){var G=D+M,L=S[G];S[G]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360;}var z=this._hash.words,W=f.words,N=h.words,H=s.words,R=p.words,u=c.words,m=l.words,b,C,P,I,k,A,d,T,K,g;A=b=z[0],d=C=z[1],T=P=z[2],K=I=z[3],g=k=z[4];for(var F,M=0;M<80;M+=1)F=b+S[D+H[M]]|0,M<16?F+=x(C,P,I)+W[0]:M<32?F+=w(C,P,I)+W[1]:M<48?F+=_(C,P,I)+W[2]:M<64?F+=v(C,P,I)+W[3]:F+=E(C,P,I)+W[4],F=F|0,F=B(F,u[M]),F=F+k|0,b=k,k=I,I=B(P,10),P=C,C=F,F=A+S[D+R[M]]|0,M<16?F+=E(d,T,K)+N[0]:M<32?F+=v(d,T,K)+N[1]:M<48?F+=_(d,T,K)+N[2]:M<64?F+=w(d,T,K)+N[3]:F+=x(d,T,K)+N[4],F=F|0,F=B(F,m[M]),F=F+g|0,A=g,g=K,K=B(T,10),T=d,d=F;F=z[1]+P+K|0,z[1]=z[2]+I+g|0,z[2]=z[3]+k+A|0,z[3]=z[4]+b+d|0,z[4]=z[0]+C+T|0,z[0]=F;},_doFinalize:function(){var S=this._data,D=S.words,M=this._nDataBytes*8,G=S.sigBytes*8;D[G>>>5]|=128<<24-G%32,D[(G+64>>>9<<4)+14]=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360,S.sigBytes=(D.length+1)*4,this._process();for(var L=this._hash,z=L.words,W=0;W<5;W++){var N=z[W];z[W]=(N<<8|N>>>24)&16711935|(N<<24|N>>>8)&4278255360;}return L},clone:function(){var S=i.clone.call(this);return S._hash=this._hash.clone(),S}});function x(S,D,M){return S^D^M}function w(S,D,M){return S&D|~S&M}function _(S,D,M){return (S|~D)^M}function v(S,D,M){return S&M|D&~M}function E(S,D,M){return S^(D|~M)}function B(S,D){return S<<D|S>>>32-D}t.RIPEMD160=i._createHelper(y),t.HmacRIPEMD160=i._createHmacHelper(y);})(),r.RIPEMD160});});var Co=ee((wo,qf)=>{(function(r,e){typeof wo=="object"?qf.exports=wo=e(fe()):typeof define=="function"&&define.amd?define(["./core"],e):e(r.CryptoJS);})(wo,function(r){(function(){var e=r,t=e.lib,n=t.Base,a=e.enc,i=a.Utf8,o=e.algo;o.HMAC=n.extend({init:function(p,c){p=this._hasher=new p.init,typeof c=="string"&&(c=i.parse(c));var l=p.blockSize,f=l*4;c.sigBytes>f&&(c=p.finalize(c)),c.clamp();for(var h=this._oKey=c.clone(),y=this._iKey=c.clone(),x=h.words,w=y.words,_=0;_<l;_++)x[_]^=1549556828,w[_]^=909522486;h.sigBytes=y.sigBytes=f,this.reset();},reset:function(){var p=this._hasher;p.reset(),p.update(this._iKey);},update:function(p){return this._hasher.update(p),this},finalize:function(p){var c=this._hasher,l=c.finalize(p);c.reset();var f=c.finalize(this._oKey.clone().concat(l));return f}});})();});});var zf=ee((Eo,Gf)=>{(function(r,e,t){typeof Eo=="object"?Gf.exports=Eo=e(fe(),yo(),Co()):typeof define=="function"&&define.amd?define(["./core","./sha256","./hmac"],e):e(r.CryptoJS);})(Eo,function(r){return (function(){var e=r,t=e.lib,n=t.Base,a=t.WordArray,i=e.algo,o=i.SHA256,s=i.HMAC,p=i.PBKDF2=n.extend({cfg:n.extend({keySize:128/32,hasher:o,iterations:25e4}),init:function(c){this.cfg=this.cfg.extend(c);},compute:function(c,l){for(var f=this.cfg,h=s.create(f.hasher,c),y=a.create(),x=a.create([1]),w=y.words,_=x.words,v=f.keySize,E=f.iterations;w.length<v;){var B=h.update(l).finalize(x);h.reset();for(var S=B.words,D=S.length,M=B,G=1;G<E;G++){M=h.finalize(M),h.reset();for(var L=M.words,z=0;z<D;z++)S[z]^=L[z];}y.concat(B),_[0]++;}return y.sigBytes=v*4,y}});e.PBKDF2=function(c,l,f){return p.create(f).compute(c,l)};})(),r.PBKDF2});});var Lr=ee((Io,Hf)=>{(function(r,e,t){typeof Io=="object"?Hf.exports=Io=e(fe(),Iu(),Co()):typeof define=="function"&&define.amd?define(["./core","./sha1","./hmac"],e):e(r.CryptoJS);})(Io,function(r){return (function(){var e=r,t=e.lib,n=t.Base,a=t.WordArray,i=e.algo,o=i.MD5,s=i.EvpKDF=n.extend({cfg:n.extend({keySize:128/32,hasher:o,iterations:1}),init:function(p){this.cfg=this.cfg.extend(p);},compute:function(p,c){for(var l,f=this.cfg,h=f.hasher.create(),y=a.create(),x=y.words,w=f.keySize,_=f.iterations;x.length<w;){l&&h.update(l),l=h.update(p).finalize(c),h.reset();for(var v=1;v<_;v++)l=h.finalize(l),h.reset();y.concat(l);}return y.sigBytes=w*4,y}});e.EvpKDF=function(p,c,l){return s.create(l).compute(p,c)};})(),r.EvpKDF});});var st=ee((Po,Wf)=>{(function(r,e,t){typeof Po=="object"?Wf.exports=Po=e(fe(),Lr()):typeof define=="function"&&define.amd?define(["./core","./evpkdf"],e):e(r.CryptoJS);})(Po,function(r){r.lib.Cipher||(function(e){var t=r,n=t.lib,a=n.Base,i=n.WordArray,o=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,l=t.algo,f=l.EvpKDF,h=n.Cipher=o.extend({cfg:a.extend(),createEncryptor:function(N,H){return this.create(this._ENC_XFORM_MODE,N,H)},createDecryptor:function(N,H){return this.create(this._DEC_XFORM_MODE,N,H)},init:function(N,H,R){this.cfg=this.cfg.extend(R),this._xformMode=N,this._key=H,this.reset();},reset:function(){o.reset.call(this),this._doReset();},process:function(N){return this._append(N),this._process()},finalize:function(N){N&&this._append(N);var H=this._doFinalize();return H},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function N(H){return typeof H=="string"?W:G}return function(H){return {encrypt:function(R,u,m){return N(u).encrypt(H,R,u,m)},decrypt:function(R,u,m){return N(u).decrypt(H,R,u,m)}}}})()});n.StreamCipher=h.extend({_doFinalize:function(){var N=this._process(true);return N},blockSize:1});var x=t.mode={},w=n.BlockCipherMode=a.extend({createEncryptor:function(N,H){return this.Encryptor.create(N,H)},createDecryptor:function(N,H){return this.Decryptor.create(N,H)},init:function(N,H){this._cipher=N,this._iv=H;}}),_=x.CBC=(function(){var N=w.extend();N.Encryptor=N.extend({processBlock:function(R,u){var m=this._cipher,b=m.blockSize;H.call(this,R,u,b),m.encryptBlock(R,u),this._prevBlock=R.slice(u,u+b);}}),N.Decryptor=N.extend({processBlock:function(R,u){var m=this._cipher,b=m.blockSize,C=R.slice(u,u+b);m.decryptBlock(R,u),H.call(this,R,u,b),this._prevBlock=C;}});function H(R,u,m){var b,C=this._iv;C?(b=C,this._iv=e):b=this._prevBlock;for(var P=0;P<m;P++)R[u+P]^=b[P];}return N})(),v=t.pad={},E=v.Pkcs7={pad:function(N,H){for(var R=H*4,u=R-N.sigBytes%R,m=u<<24|u<<16|u<<8|u,b=[],C=0;C<u;C+=4)b.push(m);var P=i.create(b,u);N.concat(P);},unpad:function(N){var H=N.words[N.sigBytes-1>>>2]&255;N.sigBytes-=H;}};n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:_,padding:E}),reset:function(){var N;h.reset.call(this);var H=this.cfg,R=H.iv,u=H.mode;this._xformMode==this._ENC_XFORM_MODE?N=u.createEncryptor:(N=u.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==N?this._mode.init(this,R&&R.words):(this._mode=N.call(u,this,R&&R.words),this._mode.__creator=N);},_doProcessBlock:function(N,H){this._mode.processBlock(N,H);},_doFinalize:function(){var N,H=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(H.pad(this._data,this.blockSize),N=this._process(true)):(N=this._process(true),H.unpad(N)),N},blockSize:128/32});var S=n.CipherParams=a.extend({init:function(N){this.mixIn(N);},toString:function(N){return (N||this.formatter).stringify(this)}}),D=t.format={},M=D.OpenSSL={stringify:function(N){var H,R=N.ciphertext,u=N.salt;return u?H=i.create([1398893684,1701076831]).concat(u).concat(R):H=R,H.toString(c)},parse:function(N){var H,R=c.parse(N),u=R.words;return u[0]==1398893684&&u[1]==1701076831&&(H=i.create(u.slice(2,4)),u.splice(0,4),R.sigBytes-=16),S.create({ciphertext:R,salt:H})}},G=n.SerializableCipher=a.extend({cfg:a.extend({format:M}),encrypt:function(N,H,R,u){u=this.cfg.extend(u);var m=N.createEncryptor(R,u),b=m.finalize(H),C=m.cfg;return S.create({ciphertext:b,key:R,iv:C.iv,algorithm:N,mode:C.mode,padding:C.padding,blockSize:N.blockSize,formatter:u.format})},decrypt:function(N,H,R,u){u=this.cfg.extend(u),H=this._parse(H,u.format);var m=N.createDecryptor(R,u).finalize(H.ciphertext);return m},_parse:function(N,H){return typeof N=="string"?H.parse(N,this):N}}),L=t.kdf={},z=L.OpenSSL={execute:function(N,H,R,u,m){if(u||(u=i.random(64/8)),m)var b=f.create({keySize:H+R,hasher:m}).compute(N,u);else var b=f.create({keySize:H+R}).compute(N,u);var C=i.create(b.words.slice(H),R*4);return b.sigBytes=H*4,S.create({key:b,iv:C,salt:u})}},W=n.PasswordBasedCipher=G.extend({cfg:G.cfg.extend({kdf:z}),encrypt:function(N,H,R,u){u=this.cfg.extend(u);var m=u.kdf.execute(R,N.keySize,N.ivSize,u.salt,u.hasher);u.iv=m.iv;var b=G.encrypt.call(this,N,H,m.key,u);return b.mixIn(m),b},decrypt:function(N,H,R,u){u=this.cfg.extend(u),H=this._parse(H,u.format);var m=u.kdf.execute(R,N.keySize,N.ivSize,H.salt,u.hasher);u.iv=m.iv;var b=G.decrypt.call(this,N,H,m.key,u);return b}});})();});});var Qf=ee((Ro,Kf)=>{(function(r,e,t){typeof Ro=="object"?Kf.exports=Ro=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(Ro,function(r){return r.mode.CFB=(function(){var e=r.lib.BlockCipherMode.extend();e.Encryptor=e.extend({processBlock:function(n,a){var i=this._cipher,o=i.blockSize;t.call(this,n,a,o,i),this._prevBlock=n.slice(a,a+o);}}),e.Decryptor=e.extend({processBlock:function(n,a){var i=this._cipher,o=i.blockSize,s=n.slice(a,a+o);t.call(this,n,a,o,i),this._prevBlock=s;}});function t(n,a,i,o){var s,p=this._iv;p?(s=p.slice(0),this._iv=void 0):s=this._prevBlock,o.encryptBlock(s,0);for(var c=0;c<i;c++)n[a+c]^=s[c];}return e})(),r.mode.CFB});});var jf=ee((_o,Vf)=>{(function(r,e,t){typeof _o=="object"?Vf.exports=_o=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(_o,function(r){return r.mode.CTR=(function(){var e=r.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(n,a){var i=this._cipher,o=i.blockSize,s=this._iv,p=this._counter;s&&(p=this._counter=s.slice(0),this._iv=void 0);var c=p.slice(0);i.encryptBlock(c,0),p[o-1]=p[o-1]+1|0;for(var l=0;l<o;l++)n[a+l]^=c[l];}});return e.Decryptor=t,e})(),r.mode.CTR});});var Yf=ee((To,Jf)=>{(function(r,e,t){typeof To=="object"?Jf.exports=To=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(To,function(r){return r.mode.CTRGladman=(function(){var e=r.lib.BlockCipherMode.extend();function t(i){if((i>>24&255)===255){var o=i>>16&255,s=i>>8&255,p=i&255;o===255?(o=0,s===255?(s=0,p===255?p=0:++p):++s):++o,i=0,i+=o<<16,i+=s<<8,i+=p;}else i+=1<<24;return i}function n(i){return (i[0]=t(i[0]))===0&&(i[1]=t(i[1])),i}var a=e.Encryptor=e.extend({processBlock:function(i,o){var s=this._cipher,p=s.blockSize,c=this._iv,l=this._counter;c&&(l=this._counter=c.slice(0),this._iv=void 0),n(l);var f=l.slice(0);s.encryptBlock(f,0);for(var h=0;h<p;h++)i[o+h]^=f[h];}});return e.Decryptor=a,e})(),r.mode.CTRGladman});});var Zf=ee((ko,Xf)=>{(function(r,e,t){typeof ko=="object"?Xf.exports=ko=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(ko,function(r){return r.mode.OFB=(function(){var e=r.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(n,a){var i=this._cipher,o=i.blockSize,s=this._iv,p=this._keystream;s&&(p=this._keystream=s.slice(0),this._iv=void 0),i.encryptBlock(p,0);for(var c=0;c<o;c++)n[a+c]^=p[c];}});return e.Decryptor=t,e})(),r.mode.OFB});});var em=ee((Bo,$f)=>{(function(r,e,t){typeof Bo=="object"?$f.exports=Bo=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(Bo,function(r){return r.mode.ECB=(function(){var e=r.lib.BlockCipherMode.extend();return e.Encryptor=e.extend({processBlock:function(t,n){this._cipher.encryptBlock(t,n);}}),e.Decryptor=e.extend({processBlock:function(t,n){this._cipher.decryptBlock(t,n);}}),e})(),r.mode.ECB});});var rm=ee((So,tm)=>{(function(r,e,t){typeof So=="object"?tm.exports=So=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(So,function(r){return r.pad.AnsiX923={pad:function(e,t){var n=e.sigBytes,a=t*4,i=a-n%a,o=n+i-1;e.clamp(),e.words[o>>>2]|=i<<24-o%4*8,e.sigBytes+=i;},unpad:function(e){var t=e.words[e.sigBytes-1>>>2]&255;e.sigBytes-=t;}},r.pad.Ansix923});});var am=ee((Do,nm)=>{(function(r,e,t){typeof Do=="object"?nm.exports=Do=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(Do,function(r){return r.pad.Iso10126={pad:function(e,t){var n=t*4,a=n-e.sigBytes%n;e.concat(r.lib.WordArray.random(a-1)).concat(r.lib.WordArray.create([a<<24],1));},unpad:function(e){var t=e.words[e.sigBytes-1>>>2]&255;e.sigBytes-=t;}},r.pad.Iso10126});});var om=ee((Mo,im)=>{(function(r,e,t){typeof Mo=="object"?im.exports=Mo=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(Mo,function(r){return r.pad.Iso97971={pad:function(e,t){e.concat(r.lib.WordArray.create([2147483648],1)),r.pad.ZeroPadding.pad(e,t);},unpad:function(e){r.pad.ZeroPadding.unpad(e),e.sigBytes--;}},r.pad.Iso97971});});var um=ee((Fo,sm)=>{(function(r,e,t){typeof Fo=="object"?sm.exports=Fo=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(Fo,function(r){return r.pad.ZeroPadding={pad:function(e,t){var n=t*4;e.clamp(),e.sigBytes+=n-(e.sigBytes%n||n);},unpad:function(e){for(var t=e.words,n=e.sigBytes-1,n=e.sigBytes-1;n>=0;n--)if(t[n>>>2]>>>24-n%4*8&255){e.sigBytes=n+1;break}}},r.pad.ZeroPadding});});var lm=ee((No,pm)=>{(function(r,e,t){typeof No=="object"?pm.exports=No=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(No,function(r){return r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding});});var dm=ee((Oo,cm)=>{(function(r,e,t){typeof Oo=="object"?cm.exports=Oo=e(fe(),st()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],e):e(r.CryptoJS);})(Oo,function(r){return (function(e){var t=r,n=t.lib,a=n.CipherParams,i=t.enc,o=i.Hex,s=t.format;s.Hex={stringify:function(c){return c.ciphertext.toString(o)},parse:function(c){var l=o.parse(c);return a.create({ciphertext:l})}};})(),r.format.Hex});});var mm=ee((Lo,fm)=>{(function(r,e,t){typeof Lo=="object"?fm.exports=Lo=e(fe(),nn(),Fr(),Lr(),st()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(r.CryptoJS);})(Lo,function(r){return (function(){var e=r,t=e.lib,n=t.BlockCipher,a=e.algo,i=[],o=[],s=[],p=[],c=[],l=[],f=[],h=[],y=[],x=[];(function(){for(var v=[],E=0;E<256;E++)E<128?v[E]=E<<1:v[E]=E<<1^283;for(var B=0,S=0,E=0;E<256;E++){var D=S^S<<1^S<<2^S<<3^S<<4;D=D>>>8^D&255^99,i[B]=D,o[D]=B;var M=v[B],G=v[M],L=v[G],z=v[D]*257^D*16843008;s[B]=z<<24|z>>>8,p[B]=z<<16|z>>>16,c[B]=z<<8|z>>>24,l[B]=z;var z=L*16843009^G*65537^M*257^B*16843008;f[D]=z<<24|z>>>8,h[D]=z<<16|z>>>16,y[D]=z<<8|z>>>24,x[D]=z,B?(B=M^v[v[v[L^M]]],S^=v[v[S]]):B=S=1;}})();var w=[0,1,2,4,8,16,32,64,128,27,54],_=a.AES=n.extend({_doReset:function(){var v;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var E=this._keyPriorReset=this._key,B=E.words,S=E.sigBytes/4,D=this._nRounds=S+6,M=(D+1)*4,G=this._keySchedule=[],L=0;L<M;L++)L<S?G[L]=B[L]:(v=G[L-1],L%S?S>6&&L%S==4&&(v=i[v>>>24]<<24|i[v>>>16&255]<<16|i[v>>>8&255]<<8|i[v&255]):(v=v<<8|v>>>24,v=i[v>>>24]<<24|i[v>>>16&255]<<16|i[v>>>8&255]<<8|i[v&255],v^=w[L/S|0]<<24),G[L]=G[L-S]^v);for(var z=this._invKeySchedule=[],W=0;W<M;W++){var L=M-W;if(W%4)var v=G[L];else var v=G[L-4];W<4||L<=4?z[W]=v:z[W]=f[i[v>>>24]]^h[i[v>>>16&255]]^y[i[v>>>8&255]]^x[i[v&255]];}}},encryptBlock:function(v,E){this._doCryptBlock(v,E,this._keySchedule,s,p,c,l,i);},decryptBlock:function(v,E){var B=v[E+1];v[E+1]=v[E+3],v[E+3]=B,this._doCryptBlock(v,E,this._invKeySchedule,f,h,y,x,o);var B=v[E+1];v[E+1]=v[E+3],v[E+3]=B;},_doCryptBlock:function(v,E,B,S,D,M,G,L){for(var z=this._nRounds,W=v[E]^B[0],N=v[E+1]^B[1],H=v[E+2]^B[2],R=v[E+3]^B[3],u=4,m=1;m<z;m++){var b=S[W>>>24]^D[N>>>16&255]^M[H>>>8&255]^G[R&255]^B[u++],C=S[N>>>24]^D[H>>>16&255]^M[R>>>8&255]^G[W&255]^B[u++],P=S[H>>>24]^D[R>>>16&255]^M[W>>>8&255]^G[N&255]^B[u++],I=S[R>>>24]^D[W>>>16&255]^M[N>>>8&255]^G[H&255]^B[u++];W=b,N=C,H=P,R=I;}var b=(L[W>>>24]<<24|L[N>>>16&255]<<16|L[H>>>8&255]<<8|L[R&255])^B[u++],C=(L[N>>>24]<<24|L[H>>>16&255]<<16|L[R>>>8&255]<<8|L[W&255])^B[u++],P=(L[H>>>24]<<24|L[R>>>16&255]<<16|L[W>>>8&255]<<8|L[N&255])^B[u++],I=(L[R>>>24]<<24|L[W>>>16&255]<<16|L[N>>>8&255]<<8|L[H&255])^B[u++];v[E]=b,v[E+1]=C,v[E+2]=P,v[E+3]=I;},keySize:256/32});e.AES=n._createHelper(_);})(),r.AES});});var ym=ee((Uo,hm)=>{(function(r,e,t){typeof Uo=="object"?hm.exports=Uo=e(fe(),nn(),Fr(),Lr(),st()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(r.CryptoJS);})(Uo,function(r){return (function(){var e=r,t=e.lib,n=t.WordArray,a=t.BlockCipher,i=e.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],s=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],p=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],f=i.DES=a.extend({_doReset:function(){for(var w=this._key,_=w.words,v=[],E=0;E<56;E++){var B=o[E]-1;v[E]=_[B>>>5]>>>31-B%32&1;}for(var S=this._subKeys=[],D=0;D<16;D++){for(var M=S[D]=[],G=p[D],E=0;E<24;E++)M[E/6|0]|=v[(s[E]-1+G)%28]<<31-E%6,M[4+(E/6|0)]|=v[28+(s[E+24]-1+G)%28]<<31-E%6;M[0]=M[0]<<1|M[0]>>>31;for(var E=1;E<7;E++)M[E]=M[E]>>>(E-1)*4+3;M[7]=M[7]<<5|M[7]>>>27;}for(var L=this._invSubKeys=[],E=0;E<16;E++)L[E]=S[15-E];},encryptBlock:function(w,_){this._doCryptBlock(w,_,this._subKeys);},decryptBlock:function(w,_){this._doCryptBlock(w,_,this._invSubKeys);},_doCryptBlock:function(w,_,v){this._lBlock=w[_],this._rBlock=w[_+1],h.call(this,4,252645135),h.call(this,16,65535),y.call(this,2,858993459),y.call(this,8,16711935),h.call(this,1,1431655765);for(var E=0;E<16;E++){for(var B=v[E],S=this._lBlock,D=this._rBlock,M=0,G=0;G<8;G++)M|=c[G][((D^B[G])&l[G])>>>0];this._lBlock=D,this._rBlock=S^M;}var L=this._lBlock;this._lBlock=this._rBlock,this._rBlock=L,h.call(this,1,1431655765),y.call(this,8,16711935),y.call(this,2,858993459),h.call(this,16,65535),h.call(this,4,252645135),w[_]=this._lBlock,w[_+1]=this._rBlock;},keySize:64/32,ivSize:64/32,blockSize:64/32});function h(w,_){var v=(this._lBlock>>>w^this._rBlock)&_;this._rBlock^=v,this._lBlock^=v<<w;}function y(w,_){var v=(this._rBlock>>>w^this._lBlock)&_;this._lBlock^=v,this._rBlock^=v<<w;}e.DES=a._createHelper(f);var x=i.TripleDES=a.extend({_doReset:function(){var w=this._key,_=w.words;if(_.length!==2&&_.length!==4&&_.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var v=_.slice(0,2),E=_.length<4?_.slice(0,2):_.slice(2,4),B=_.length<6?_.slice(0,2):_.slice(4,6);this._des1=f.createEncryptor(n.create(v)),this._des2=f.createEncryptor(n.create(E)),this._des3=f.createEncryptor(n.create(B));},encryptBlock:function(w,_){this._des1.encryptBlock(w,_),this._des2.decryptBlock(w,_),this._des3.encryptBlock(w,_);},decryptBlock:function(w,_){this._des3.decryptBlock(w,_),this._des2.encryptBlock(w,_),this._des1.decryptBlock(w,_);},keySize:192/32,ivSize:64/32,blockSize:64/32});e.TripleDES=a._createHelper(x);})(),r.TripleDES});});var xm=ee((qo,gm)=>{(function(r,e,t){typeof qo=="object"?gm.exports=qo=e(fe(),nn(),Fr(),Lr(),st()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(r.CryptoJS);})(qo,function(r){return (function(){var e=r,t=e.lib,n=t.StreamCipher,a=e.algo,i=a.RC4=n.extend({_doReset:function(){for(var p=this._key,c=p.words,l=p.sigBytes,f=this._S=[],h=0;h<256;h++)f[h]=h;for(var h=0,y=0;h<256;h++){var x=h%l,w=c[x>>>2]>>>24-x%4*8&255;y=(y+f[h]+w)%256;var _=f[h];f[h]=f[y],f[y]=_;}this._i=this._j=0;},_doProcessBlock:function(p,c){p[c]^=o.call(this);},keySize:256/32,ivSize:0});function o(){for(var p=this._S,c=this._i,l=this._j,f=0,h=0;h<4;h++){c=(c+1)%256,l=(l+p[c])%256;var y=p[c];p[c]=p[l],p[l]=y,f|=p[(p[c]+p[l])%256]<<24-h*8;}return this._i=c,this._j=l,f}e.RC4=n._createHelper(i);var s=a.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var p=this.cfg.drop;p>0;p--)o.call(this);}});e.RC4Drop=n._createHelper(s);})(),r.RC4});});var vm=ee((Go,bm)=>{(function(r,e,t){typeof Go=="object"?bm.exports=Go=e(fe(),nn(),Fr(),Lr(),st()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(r.CryptoJS);})(Go,function(r){return (function(){var e=r,t=e.lib,n=t.StreamCipher,a=e.algo,i=[],o=[],s=[],p=a.Rabbit=n.extend({_doReset:function(){for(var l=this._key.words,f=this.cfg.iv,h=0;h<4;h++)l[h]=(l[h]<<8|l[h]>>>24)&16711935|(l[h]<<24|l[h]>>>8)&4278255360;var y=this._X=[l[0],l[3]<<16|l[2]>>>16,l[1],l[0]<<16|l[3]>>>16,l[2],l[1]<<16|l[0]>>>16,l[3],l[2]<<16|l[1]>>>16],x=this._C=[l[2]<<16|l[2]>>>16,l[0]&4294901760|l[1]&65535,l[3]<<16|l[3]>>>16,l[1]&4294901760|l[2]&65535,l[0]<<16|l[0]>>>16,l[2]&4294901760|l[3]&65535,l[1]<<16|l[1]>>>16,l[3]&4294901760|l[0]&65535];this._b=0;for(var h=0;h<4;h++)c.call(this);for(var h=0;h<8;h++)x[h]^=y[h+4&7];if(f){var w=f.words,_=w[0],v=w[1],E=(_<<8|_>>>24)&16711935|(_<<24|_>>>8)&4278255360,B=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,S=E>>>16|B&4294901760,D=B<<16|E&65535;x[0]^=E,x[1]^=S,x[2]^=B,x[3]^=D,x[4]^=E,x[5]^=S,x[6]^=B,x[7]^=D;for(var h=0;h<4;h++)c.call(this);}},_doProcessBlock:function(l,f){var h=this._X;c.call(this),i[0]=h[0]^h[5]>>>16^h[3]<<16,i[1]=h[2]^h[7]>>>16^h[5]<<16,i[2]=h[4]^h[1]>>>16^h[7]<<16,i[3]=h[6]^h[3]>>>16^h[1]<<16;for(var y=0;y<4;y++)i[y]=(i[y]<<8|i[y]>>>24)&16711935|(i[y]<<24|i[y]>>>8)&4278255360,l[f+y]^=i[y];},blockSize:128/32,ivSize:64/32});function c(){for(var l=this._X,f=this._C,h=0;h<8;h++)o[h]=f[h];f[0]=f[0]+1295307597+this._b|0,f[1]=f[1]+3545052371+(f[0]>>>0<o[0]>>>0?1:0)|0,f[2]=f[2]+886263092+(f[1]>>>0<o[1]>>>0?1:0)|0,f[3]=f[3]+1295307597+(f[2]>>>0<o[2]>>>0?1:0)|0,f[4]=f[4]+3545052371+(f[3]>>>0<o[3]>>>0?1:0)|0,f[5]=f[5]+886263092+(f[4]>>>0<o[4]>>>0?1:0)|0,f[6]=f[6]+1295307597+(f[5]>>>0<o[5]>>>0?1:0)|0,f[7]=f[7]+3545052371+(f[6]>>>0<o[6]>>>0?1:0)|0,this._b=f[7]>>>0<o[7]>>>0?1:0;for(var h=0;h<8;h++){var y=l[h]+f[h],x=y&65535,w=y>>>16,_=((x*x>>>17)+x*w>>>15)+w*w,v=((y&4294901760)*y|0)+((y&65535)*y|0);s[h]=_^v;}l[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,l[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,l[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,l[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,l[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,l[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,l[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,l[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0;}e.Rabbit=n._createHelper(p);})(),r.Rabbit});});var wm=ee((zo,Am)=>{(function(r,e,t){typeof zo=="object"?Am.exports=zo=e(fe(),nn(),Fr(),Lr(),st()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(r.CryptoJS);})(zo,function(r){return (function(){var e=r,t=e.lib,n=t.StreamCipher,a=e.algo,i=[],o=[],s=[],p=a.RabbitLegacy=n.extend({_doReset:function(){var l=this._key.words,f=this.cfg.iv,h=this._X=[l[0],l[3]<<16|l[2]>>>16,l[1],l[0]<<16|l[3]>>>16,l[2],l[1]<<16|l[0]>>>16,l[3],l[2]<<16|l[1]>>>16],y=this._C=[l[2]<<16|l[2]>>>16,l[0]&4294901760|l[1]&65535,l[3]<<16|l[3]>>>16,l[1]&4294901760|l[2]&65535,l[0]<<16|l[0]>>>16,l[2]&4294901760|l[3]&65535,l[1]<<16|l[1]>>>16,l[3]&4294901760|l[0]&65535];this._b=0;for(var x=0;x<4;x++)c.call(this);for(var x=0;x<8;x++)y[x]^=h[x+4&7];if(f){var w=f.words,_=w[0],v=w[1],E=(_<<8|_>>>24)&16711935|(_<<24|_>>>8)&4278255360,B=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,S=E>>>16|B&4294901760,D=B<<16|E&65535;y[0]^=E,y[1]^=S,y[2]^=B,y[3]^=D,y[4]^=E,y[5]^=S,y[6]^=B,y[7]^=D;for(var x=0;x<4;x++)c.call(this);}},_doProcessBlock:function(l,f){var h=this._X;c.call(this),i[0]=h[0]^h[5]>>>16^h[3]<<16,i[1]=h[2]^h[7]>>>16^h[5]<<16,i[2]=h[4]^h[1]>>>16^h[7]<<16,i[3]=h[6]^h[3]>>>16^h[1]<<16;for(var y=0;y<4;y++)i[y]=(i[y]<<8|i[y]>>>24)&16711935|(i[y]<<24|i[y]>>>8)&4278255360,l[f+y]^=i[y];},blockSize:128/32,ivSize:64/32});function c(){for(var l=this._X,f=this._C,h=0;h<8;h++)o[h]=f[h];f[0]=f[0]+1295307597+this._b|0,f[1]=f[1]+3545052371+(f[0]>>>0<o[0]>>>0?1:0)|0,f[2]=f[2]+886263092+(f[1]>>>0<o[1]>>>0?1:0)|0,f[3]=f[3]+1295307597+(f[2]>>>0<o[2]>>>0?1:0)|0,f[4]=f[4]+3545052371+(f[3]>>>0<o[3]>>>0?1:0)|0,f[5]=f[5]+886263092+(f[4]>>>0<o[4]>>>0?1:0)|0,f[6]=f[6]+1295307597+(f[5]>>>0<o[5]>>>0?1:0)|0,f[7]=f[7]+3545052371+(f[6]>>>0<o[6]>>>0?1:0)|0,this._b=f[7]>>>0<o[7]>>>0?1:0;for(var h=0;h<8;h++){var y=l[h]+f[h],x=y&65535,w=y>>>16,_=((x*x>>>17)+x*w>>>15)+w*w,v=((y&4294901760)*y|0)+((y&65535)*y|0);s[h]=_^v;}l[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,l[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,l[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,l[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,l[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,l[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,l[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,l[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0;}e.RabbitLegacy=n._createHelper(p);})(),r.RabbitLegacy});});var Em=ee((Ho,Cm)=>{(function(r,e,t){typeof Ho=="object"?Cm.exports=Ho=e(fe(),nn(),Fr(),Lr(),st()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(r.CryptoJS);})(Ho,function(r){return (function(){var e=r,t=e.lib,n=t.BlockCipher,a=e.algo;let i=16,o=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],s=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var p={pbox:[],sbox:[]};function c(x,w){let _=w>>24&255,v=w>>16&255,E=w>>8&255,B=w&255,S=x.sbox[0][_]+x.sbox[1][v];return S=S^x.sbox[2][E],S=S+x.sbox[3][B],S}function l(x,w,_){let v=w,E=_,B;for(let S=0;S<i;++S)v=v^x.pbox[S],E=c(x,v)^E,B=v,v=E,E=B;return B=v,v=E,E=B,E=E^x.pbox[i],v=v^x.pbox[i+1],{left:v,right:E}}function f(x,w,_){let v=w,E=_,B;for(let S=i+1;S>1;--S)v=v^x.pbox[S],E=c(x,v)^E,B=v,v=E,E=B;return B=v,v=E,E=B,E=E^x.pbox[1],v=v^x.pbox[0],{left:v,right:E}}function h(x,w,_){for(let D=0;D<4;D++){x.sbox[D]=[];for(let M=0;M<256;M++)x.sbox[D][M]=s[D][M];}let v=0;for(let D=0;D<i+2;D++)x.pbox[D]=o[D]^w[v],v++,v>=_&&(v=0);let E=0,B=0,S=0;for(let D=0;D<i+2;D+=2)S=l(x,E,B),E=S.left,B=S.right,x.pbox[D]=E,x.pbox[D+1]=B;for(let D=0;D<4;D++)for(let M=0;M<256;M+=2)S=l(x,E,B),E=S.left,B=S.right,x.sbox[D][M]=E,x.sbox[D][M+1]=B;return true}var y=a.Blowfish=n.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var x=this._keyPriorReset=this._key,w=x.words,_=x.sigBytes/4;h(p,w,_);}},encryptBlock:function(x,w){var _=l(p,x[w],x[w+1]);x[w]=_.left,x[w+1]=_.right;},decryptBlock:function(x,w){var _=f(p,x[w],x[w+1]);x[w]=_.left,x[w+1]=_.right;},blockSize:64/32,keySize:128/32,ivSize:64/32});e.Blowfish=n._createHelper(y);})(),r.Blowfish});});var Pm=ee((Wo,Im)=>{(function(r,e,t){typeof Wo=="object"?Im.exports=Wo=e(fe(),Fa(),Cf(),If(),nn(),_f(),Fr(),Iu(),yo(),Sf(),Pu(),Ff(),Of(),Uf(),Co(),zf(),Lr(),st(),Qf(),jf(),Yf(),Zf(),em(),rm(),am(),om(),um(),lm(),dm(),mm(),ym(),xm(),vm(),wm(),Em()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./lib-typedarrays","./enc-utf16","./enc-base64","./enc-base64url","./md5","./sha1","./sha256","./sha224","./sha512","./sha384","./sha3","./ripemd160","./hmac","./pbkdf2","./evpkdf","./cipher-core","./mode-cfb","./mode-ctr","./mode-ctr-gladman","./mode-ofb","./mode-ecb","./pad-ansix923","./pad-iso10126","./pad-iso97971","./pad-zeropadding","./pad-nopadding","./format-hex","./aes","./tripledes","./rc4","./rabbit","./rabbit-legacy","./blowfish"],e):r.CryptoJS=e(r.CryptoJS);})(Wo,function(r){return r});});var Md={};Na(Md,{claimBasePoolRebate:()=>Cd,claimBasePoolRebates:()=>Ed,deposit:()=>Td,getLpPrice:()=>Dd,getRewards:()=>Sd,previewUserWithdrawData:()=>Pd,withdraw:()=>Bd,withdrawableLpAmount:()=>kd});var Du=[{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:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:false,payable:false,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"addTpsl",constant:false,payable:false,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:false,payable:false,inputs:[{type:"uint256",name:"orderId"}],outputs:[]},{type:"function",name:"claimBasePoolRebate",constant:false,stateMutability:"payable",payable:true,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:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimBasePoolRebates",constant:false,stateMutability:"payable",payable:true,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:false,payable:false,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebate",constant:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"claimQuotePoolRebate",constant:false,stateMutability:"payable",payable:true,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:false,stateMutability:"payable",payable:true,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:false,payable:false,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"recipient"}],outputs:[]},{type:"function",name:"currentOrderId",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"depositBase",constant:false,payable:false,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:false,stateMutability:"payable",payable:true,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:false,payable:false,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:false,stateMutability:"payable",payable:true,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:false,payable:false,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:false,stateMutability:"payable",payable:true,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getTpslData",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"user"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"initialize",constant:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isTrustedForwarder",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"migrateLiquidity",constant:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"trustedForwarder",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdrawBase",constant:false,stateMutability:"payable",payable:true,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:false,payable:false,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:false,payable:false,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:false,stateMutability:"payable",payable:true,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:[]}];var Fm=typeof global=="object"&&global&&global.Object===Object&&global,Oa=Fm;var Nm=typeof self=="object"&&self&&self.Object===Object&&self,Om=Oa||Nm||Function("return this")(),Bt=Om;var Lm=Bt.Symbol,An=Lm;var Mu=Object.prototype,Um=Mu.hasOwnProperty,qm=Mu.toString,aa=An?An.toStringTag:void 0;function Gm(r){var e=Um.call(r,aa),t=r[aa];try{r[aa]=void 0;var n=!0;}catch{}var a=qm.call(r);return n&&(e?r[aa]=t:delete r[aa]),a}var Fu=Gm;var zm=Object.prototype,Hm=zm.toString;function Wm(r){return Hm.call(r)}var Nu=Wm;var Km="[object Null]",Qm="[object Undefined]",Ou=An?An.toStringTag:void 0;function Vm(r){return r==null?r===void 0?Qm:Km:Ou&&Ou in Object(r)?Fu(r):Nu(r)}var Wr=Vm;function jm(r){return r!=null&&typeof r=="object"}var nr=jm;var Jm=Array.isArray,ia=Jm;function Ym(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var vt=Ym;function Xm(r){return r}var La=Xm;var Zm="[object AsyncFunction]",$m="[object Function]",eh="[object GeneratorFunction]",th="[object Proxy]";function rh(r){if(!vt(r))return false;var e=Wr(r);return e==$m||e==eh||e==Zm||e==th}var wn=rh;var nh=Bt["__core-js_shared__"],Ua=nh;var Lu=(function(){var r=/[^.]+$/.exec(Ua&&Ua.keys&&Ua.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function ah(r){return !!Lu&&Lu in r}var Uu=ah;var ih=Function.prototype,oh=ih.toString;function sh(r){if(r!=null){try{return oh.call(r)}catch{}try{return r+""}catch{}}return ""}var qu=sh;var uh=/[\\^$.*+?()[\]{}|]/g,ph=/^\[object .+?Constructor\]$/,lh=Function.prototype,ch=Object.prototype,dh=lh.toString,fh=ch.hasOwnProperty,mh=RegExp("^"+dh.call(fh).replace(uh,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hh(r){if(!vt(r)||Uu(r))return false;var e=wn(r)?mh:ph;return e.test(qu(r))}var Gu=hh;function yh(r,e){return r?.[e]}var zu=yh;function gh(r,e){var t=zu(r,e);return Gu(t)?t:void 0}var Cn=gh;var Hu=Object.create,xh=(function(){function r(){}return function(e){if(!vt(e))return {};if(Hu)return Hu(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}})(),Wu=xh;function bh(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var Ku=bh;function vh(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var Qu=vh;var Ah=800,wh=16,Ch=Date.now;function Eh(r){var e=0,t=0;return function(){var n=Ch(),a=wh-(n-t);if(t=n,a>0){if(++e>=Ah)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var Vu=Eh;function Ih(r){return function(){return r}}var ju=Ih;var Ph=(function(){try{var r=Cn(Object,"defineProperty");return r({},"",{}),r}catch{}})(),En=Ph;var Rh=En?function(r,e){return En(r,"toString",{configurable:true,enumerable:false,value:ju(e),writable:true})}:La,Ju=Rh;var _h=Vu(Ju),Yu=_h;var Th=9007199254740991,kh=/^(?:0|[1-9]\d*)$/;function Bh(r,e){var t=typeof r;return e=e??Th,!!e&&(t=="number"||t!="symbol"&&kh.test(r))&&r>-1&&r%1==0&&r<e}var qa=Bh;function Sh(r,e,t){e=="__proto__"&&En?En(r,e,{configurable:true,enumerable:true,value:t,writable:true}):r[e]=t;}var In=Sh;function Dh(r,e){return r===e||r!==r&&e!==e}var Kr=Dh;var Mh=Object.prototype,Fh=Mh.hasOwnProperty;function Nh(r,e,t){var n=r[e];(!(Fh.call(r,e)&&Kr(n,t))||t===void 0&&!(e in r))&&In(r,e,t);}var Xu=Nh;function Oh(r,e,t,n){var a=!t;t||(t={});for(var i=-1,o=e.length;++i<o;){var s=e[i],p=n?n(t[s],r[s],s,t,r):void 0;p===void 0&&(p=r[s]),a?In(t,s,p):Xu(t,s,p);}return t}var Zu=Oh;var $u=Math.max;function Lh(r,e,t){return e=$u(e===void 0?r.length-1:e,0),function(){for(var n=arguments,a=-1,i=$u(n.length-e,0),o=Array(i);++a<i;)o[a]=n[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=n[a];return s[e]=t(o),Ku(r,this,s)}}var e0=Lh;function Uh(r,e){return Yu(e0(r,e,La),r+"")}var t0=Uh;var qh=9007199254740991;function Gh(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=qh}var Ga=Gh;function zh(r){return r!=null&&Ga(r.length)&&!wn(r)}var Pn=zh;function Hh(r,e,t){if(!vt(t))return false;var n=typeof e;return (n=="number"?Pn(t)&&qa(e,t.length):n=="string"&&e in t)?Kr(t[e],r):false}var r0=Hh;function Wh(r){return t0(function(e,t){var n=-1,a=t.length,i=a>1?t[a-1]:void 0,o=a>2?t[2]:void 0;for(i=r.length>3&&typeof i=="function"?(a--,i):void 0,o&&r0(t[0],t[1],o)&&(i=a<3?void 0:i,a=1),e=Object(e);++n<a;){var s=t[n];s&&r(e,s,n,i);}return e})}var n0=Wh;var Kh=Object.prototype;function Qh(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||Kh;return r===t}var za=Qh;function Vh(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var a0=Vh;var jh="[object Arguments]";function Jh(r){return nr(r)&&Wr(r)==jh}var cs=Jh;var i0=Object.prototype,Yh=i0.hasOwnProperty,Xh=i0.propertyIsEnumerable,Zh=cs((function(){return arguments})())?cs:function(r){return nr(r)&&Yh.call(r,"callee")&&!Xh.call(r,"callee")},oa=Zh;function $h(){return false}var o0=$h;var p0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,s0=p0&&typeof module=="object"&&module&&!module.nodeType&&module,ey=s0&&s0.exports===p0,u0=ey?Bt.Buffer:void 0,ty=u0?u0.isBuffer:void 0,ry=ty||o0,Ha=ry;var ny="[object Arguments]",ay="[object Array]",iy="[object Boolean]",oy="[object Date]",sy="[object Error]",uy="[object Function]",py="[object Map]",ly="[object Number]",cy="[object Object]",dy="[object RegExp]",fy="[object Set]",my="[object String]",hy="[object WeakMap]",yy="[object ArrayBuffer]",gy="[object DataView]",xy="[object Float32Array]",by="[object Float64Array]",vy="[object Int8Array]",Ay="[object Int16Array]",wy="[object Int32Array]",Cy="[object Uint8Array]",Ey="[object Uint8ClampedArray]",Iy="[object Uint16Array]",Py="[object Uint32Array]",Je={};Je[xy]=Je[by]=Je[vy]=Je[Ay]=Je[wy]=Je[Cy]=Je[Ey]=Je[Iy]=Je[Py]=true;Je[ny]=Je[ay]=Je[yy]=Je[iy]=Je[gy]=Je[oy]=Je[sy]=Je[uy]=Je[py]=Je[ly]=Je[cy]=Je[dy]=Je[fy]=Je[my]=Je[hy]=false;function Ry(r){return nr(r)&&Ga(r.length)&&!!Je[Wr(r)]}var l0=Ry;function _y(r){return function(e){return r(e)}}var c0=_y;var d0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,sa=d0&&typeof module=="object"&&module&&!module.nodeType&&module,Ty=sa&&sa.exports===d0,ds=Ty&&Oa.process,ky=(function(){try{var r=sa&&sa.require&&sa.require("util").types;return r||ds&&ds.binding&&ds.binding("util")}catch{}})(),fs=ky;var f0=fs&&fs.isTypedArray,By=f0?c0(f0):l0,Wa=By;var Sy=Object.prototype,Dy=Sy.hasOwnProperty;function My(r,e){var t=ia(r),n=!t&&oa(r),a=!t&&!n&&Ha(r),i=!t&&!n&&!a&&Wa(r),o=t||n||a||i,s=o?a0(r.length,String):[],p=s.length;for(var c in r)(e||Dy.call(r,c))&&!(o&&(c=="length"||a&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||qa(c,p)))&&s.push(c);return s}var m0=My;function Fy(r,e){return function(t){return r(e(t))}}var h0=Fy;function Ny(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var y0=Ny;var Oy=Object.prototype,Ly=Oy.hasOwnProperty;function Uy(r){if(!vt(r))return y0(r);var e=za(r),t=[];for(var n in r)n=="constructor"&&(e||!Ly.call(r,n))||t.push(n);return t}var g0=Uy;function qy(r){return Pn(r)?m0(r,true):g0(r)}var Ka=qy;var Gy=Cn(Object,"create"),Cr=Gy;function zy(){this.__data__=Cr?Cr(null):{},this.size=0;}var x0=zy;function Hy(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var b0=Hy;var Wy="__lodash_hash_undefined__",Ky=Object.prototype,Qy=Ky.hasOwnProperty;function Vy(r){var e=this.__data__;if(Cr){var t=e[r];return t===Wy?void 0:t}return Qy.call(e,r)?e[r]:void 0}var v0=Vy;var jy=Object.prototype,Jy=jy.hasOwnProperty;function Yy(r){var e=this.__data__;return Cr?e[r]!==void 0:Jy.call(e,r)}var A0=Yy;var Xy="__lodash_hash_undefined__";function Zy(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Cr&&e===void 0?Xy:e,this}var w0=Zy;function Rn(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1]);}}Rn.prototype.clear=x0;Rn.prototype.delete=b0;Rn.prototype.get=v0;Rn.prototype.has=A0;Rn.prototype.set=w0;var ms=Rn;function $y(){this.__data__=[],this.size=0;}var C0=$y;function eg(r,e){for(var t=r.length;t--;)if(Kr(r[t][0],e))return t;return -1}var Qr=eg;var tg=Array.prototype,rg=tg.splice;function ng(r){var e=this.__data__,t=Qr(e,r);if(t<0)return false;var n=e.length-1;return t==n?e.pop():rg.call(e,t,1),--this.size,true}var E0=ng;function ag(r){var e=this.__data__,t=Qr(e,r);return t<0?void 0:e[t][1]}var I0=ag;function ig(r){return Qr(this.__data__,r)>-1}var P0=ig;function og(r,e){var t=this.__data__,n=Qr(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var R0=og;function _n(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1]);}}_n.prototype.clear=C0;_n.prototype.delete=E0;_n.prototype.get=I0;_n.prototype.has=P0;_n.prototype.set=R0;var Vr=_n;var sg=Cn(Bt,"Map"),Qa=sg;function ug(){this.size=0,this.__data__={hash:new ms,map:new(Qa||Vr),string:new ms};}var _0=ug;function pg(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var T0=pg;function lg(r,e){var t=r.__data__;return T0(e)?t[typeof e=="string"?"string":"hash"]:t.map}var jr=lg;function cg(r){var e=jr(this,r).delete(r);return this.size-=e?1:0,e}var k0=cg;function dg(r){return jr(this,r).get(r)}var B0=dg;function fg(r){return jr(this,r).has(r)}var S0=fg;function mg(r,e){var t=jr(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var D0=mg;function Tn(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1]);}}Tn.prototype.clear=_0;Tn.prototype.delete=k0;Tn.prototype.get=B0;Tn.prototype.has=S0;Tn.prototype.set=D0;var M0=Tn;var hg=h0(Object.getPrototypeOf,Object),Va=hg;var yg="[object Object]",gg=Function.prototype,xg=Object.prototype,F0=gg.toString,bg=xg.hasOwnProperty,vg=F0.call(Object);function Ag(r){if(!nr(r)||Wr(r)!=yg)return false;var e=Va(r);if(e===null)return true;var t=bg.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&F0.call(t)==vg}var N0=Ag;function wg(){this.__data__=new Vr,this.size=0;}var O0=wg;function Cg(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var L0=Cg;function Eg(r){return this.__data__.get(r)}var U0=Eg;function Ig(r){return this.__data__.has(r)}var q0=Ig;var Pg=200;function Rg(r,e){var t=this.__data__;if(t instanceof Vr){var n=t.__data__;if(!Qa||n.length<Pg-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new M0(n);}return t.set(r,e),this.size=t.size,this}var G0=Rg;function kn(r){var e=this.__data__=new Vr(r);this.size=e.size;}kn.prototype.clear=O0;kn.prototype.delete=L0;kn.prototype.get=U0;kn.prototype.has=q0;kn.prototype.set=G0;var z0=kn;var Q0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,H0=Q0&&typeof module=="object"&&module&&!module.nodeType&&module,_g=H0&&H0.exports===Q0,W0=_g?Bt.Buffer:void 0,K0=W0?W0.allocUnsafe:void 0;function Tg(r,e){if(e)return r.slice();var t=r.length,n=K0?K0(t):new r.constructor(t);return r.copy(n),n}var V0=Tg;var kg=Bt.Uint8Array,hs=kg;function Bg(r){var e=new r.constructor(r.byteLength);return new hs(e).set(new hs(r)),e}var j0=Bg;function Sg(r,e){var t=e?j0(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var J0=Sg;function Dg(r){return typeof r.constructor=="function"&&!za(r)?Wu(Va(r)):{}}var Y0=Dg;function Mg(r){return function(e,t,n){for(var a=-1,i=Object(e),o=n(e),s=o.length;s--;){var p=o[r?s:++a];if(t(i[p],p,i)===false)break}return e}}var X0=Mg;var Fg=X0(),Z0=Fg;function Ng(r,e,t){(t!==void 0&&!Kr(r[e],t)||t===void 0&&!(e in r))&&In(r,e,t);}var ua=Ng;function Og(r){return nr(r)&&Pn(r)}var $0=Og;function Lg(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}var pa=Lg;function Ug(r){return Zu(r,Ka(r))}var ep=Ug;function qg(r,e,t,n,a,i,o){var s=pa(r,t),p=pa(e,t),c=o.get(p);if(c){ua(r,t,c);return}var l=i?i(s,p,t+"",r,e,o):void 0,f=l===void 0;if(f){var h=ia(p),y=!h&&Ha(p),x=!h&&!y&&Wa(p);l=p,h||y||x?ia(s)?l=s:$0(s)?l=Qu(s):y?(f=false,l=V0(p,true)):x?(f=false,l=J0(p,true)):l=[]:N0(p)||oa(p)?(l=s,oa(s)?l=ep(s):(!vt(s)||wn(s))&&(l=Y0(p))):f=false;}f&&(o.set(p,l),a(l,p,n,i,o),o.delete(p)),ua(r,t,l);}var tp=qg;function rp(r,e,t,n,a){r!==e&&Z0(e,function(i,o){if(a||(a=new z0),vt(i))tp(r,e,o,t,rp,n,a);else {var s=n?n(pa(r,o),i,o+"",r,e,a):void 0;s===void 0&&(s=i),ua(r,o,s);}},Ka);}var np=rp;function Gg(r){return r==null}var ys=Gg;function zg(r){return r===void 0}var gs=zg;var Hg=n0(function(r,e,t){np(r,e,t);}),Bn=Hg;var ap="0x0000000000000000000000000000000000000000",la=class la{constructor(e){(gs(e)||Number(e)===0)&&(e=ap.toString()),this._addr=ethers.getAddress(e);}toString(){return this._addr.toString()}format(){return ip(this._addr.toString(),true)}unmaskFormat(){return ip(this._addr.toString(),false)}static from(e){return new la(e)}isEqualTo(e){return !!e&&this.toString().toLowerCase()===e.toString().toLowerCase()}};la.ZERO_ADDRESS=new la(ap);var ja=la,ip=(r,e=true)=>e?`${r.slice(0,6).toLowerCase()}...${r.slice(-4).toLowerCase()}`:r.toLowerCase();var St=(o=>(o[o.LINEA_SEPOLIA=59141]="LINEA_SEPOLIA",o[o.LINEA_MAINNET=59144]="LINEA_MAINNET",o[o.ARB_TESTNET=421614]="ARB_TESTNET",o[o.ARB_MAINNET=42161]="ARB_MAINNET",o[o.BSC_TESTNET=97]="BSC_TESTNET",o[o.BSC_MAINNET=56]="BSC_MAINNET",o))(St||{});var Kg=[421614,59141,97,42161,59144,56];function Ja(r){return !!r&&Kg.includes(r)}var Dt=10;var At={42161:130n,421614:130n,59144:130n,59141:130n,56:150n,97:150n};var op={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)*Dt,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var sp={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)*Dt,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var up={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)*Dt,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var pp={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)*Dt,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var lp={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)*Dt,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18}}};var cp={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)*Dt,nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18}}};var oe={59141:op.chainInfo,421614:sp.chainInfo,97:up.chainInfo,59144:pp.chainInfo,42161:lp.chainInfo,56:cp.chainInfo};function dp(r){let e=oe[r];if(!e)throw new Error(`Could not find information with chain id ${r}`);return e}var Ep=wr(bs());var mp="logger/5.8.0";var hp=false,yp=false,Ya={debug:1,default:2,info:2,warning:3,error:4,off:5},gp=Ya.default,vs=null;function Qg(){try{let r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e);}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var xp=Qg(),As;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF";})(As||(As={}));var Ut;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED";})(Ut||(Ut={}));var bp="0123456789abcdef",U=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:true,value:e,writable:false});}_log(e,t){let n=e.toLowerCase();Ya[n]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(gp>Ya[n])&&console.log.apply(console,t);}debug(...e){this._log(r.levels.DEBUG,e);}info(...e){this._log(r.levels.INFO,e);}warn(...e){this._log(r.levels.WARNING,e);}makeError(e,t,n){if(yp)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),n||(n={});let a=[];Object.keys(n).forEach(p=>{let c=n[p];try{if(c instanceof Uint8Array){let l="";for(let f=0;f<c.length;f++)l+=bp[c[f]>>4],l+=bp[c[f]&15];a.push(p+"=Uint8Array(0x"+l+")");}else a.push(p+"="+JSON.stringify(c));}catch{a.push(p+"="+JSON.stringify(n[p].toString()));}}),a.push(`code=${t}`),a.push(`version=${this.version}`);let i=e,o="";switch(t){case Ut.NUMERIC_FAULT:{o="NUMERIC_FAULT";let p=e;switch(p){case "overflow":case "underflow":case "division-by-zero":o+="-"+p;break;case "negative-power":case "negative-width":o+="-unsupported";break;case "unbound-bitwise-result":o+="-unbound-result";break}break}case Ut.CALL_EXCEPTION:case Ut.INSUFFICIENT_FUNDS:case Ut.MISSING_NEW:case Ut.NONCE_EXPIRED:case Ut.REPLACEMENT_UNDERPRICED:case Ut.TRANSACTION_REPLACED:case Ut.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),a.length&&(e+=" ("+a.join(", ")+")");let s=new Error(e);return s.reason=i,s.code=t,Object.keys(n).forEach(function(p){s[p]=n[p];}),s}throwError(e,t,n){throw this.makeError(e,t,n)}throwArgumentError(e,t,n){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:n})}assert(e,t,n,a){e||this.throwError(t,n,a);}assertArgument(e,t,n,a){e||this.throwArgumentError(t,n,a);}checkNormalize(e){xp&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:xp});}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}));}checkArgumentCount(e,t,n){n?n=": "+n:n="",e<t&&this.throwError("missing argument"+n,r.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+n,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t});}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name});}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name});}static globalLogger(){return vs||(vs=new r(mp)),vs}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),hp){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"});}yp=!!e,hp=!!t;}static setLogLevel(e){let t=Ya[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}gp=t;}static from(e){return new r(e)}};U.errors=Ut;U.levels=As;var vp="bignumber/5.8.0";var Xa=Ep.default.BN,Er=new U(vp),ws={},wp=9007199254740991;var Cp=false,Z=class r{constructor(e,t){e!==ws&&Er.throwError("cannot call constructor directly; use BigNumber.from",U.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=true,Object.freeze(this);}fromTwos(e){return wt(me(this).fromTwos(e))}toTwos(e){return wt(me(this).toTwos(e))}abs(){return this._hex[0]==="-"?r.from(this._hex.substring(1)):this}add(e){return wt(me(this).add(me(e)))}sub(e){return wt(me(this).sub(me(e)))}div(e){return r.from(e).isZero()&&Mt("division-by-zero","div"),wt(me(this).div(me(e)))}mul(e){return wt(me(this).mul(me(e)))}mod(e){let t=me(e);return t.isNeg()&&Mt("division-by-zero","mod"),wt(me(this).umod(t))}pow(e){let t=me(e);return t.isNeg()&&Mt("negative-power","pow"),wt(me(this).pow(t))}and(e){let t=me(e);return (this.isNegative()||t.isNeg())&&Mt("unbound-bitwise-result","and"),wt(me(this).and(t))}or(e){let t=me(e);return (this.isNegative()||t.isNeg())&&Mt("unbound-bitwise-result","or"),wt(me(this).or(t))}xor(e){let t=me(e);return (this.isNegative()||t.isNeg())&&Mt("unbound-bitwise-result","xor"),wt(me(this).xor(t))}mask(e){return (this.isNegative()||e<0)&&Mt("negative-width","mask"),wt(me(this).maskn(e))}shl(e){return (this.isNegative()||e<0)&&Mt("negative-width","shl"),wt(me(this).shln(e))}shr(e){return (this.isNegative()||e<0)&&Mt("negative-width","shr"),wt(me(this).shrn(e))}eq(e){return me(this).eq(me(e))}lt(e){return me(this).lt(me(e))}lte(e){return me(this).lte(me(e))}gt(e){return me(this).gt(me(e))}gte(e){return me(this).gte(me(e))}isNegative(){return this._hex[0]==="-"}isZero(){return me(this).isZero()}toNumber(){try{return me(this).toNumber()}catch{Mt("overflow","toNumber",this.toString());}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Er.throwError("this platform does not support BigInt",U.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Cp||(Cp=true,Er.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Er.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",U.errors.UNEXPECTED_ARGUMENT,{}):Er.throwError("BigNumber.toString does not accept parameters",U.errors.UNEXPECTED_ARGUMENT,{})),me(this).toString(10)}toHexString(){return this._hex}toJSON(e){return {type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof r)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new r(ws,ca(e)):e.match(/^-?[0-9]+$/)?new r(ws,ca(new Xa(e))):Er.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Mt("underflow","BigNumber.from",e),(e>=wp||e<=-wp)&&Mt("overflow","BigNumber.from",e),r.from(String(e));let t=e;if(typeof t=="bigint")return r.from(t.toString());if(bytes.isBytes(t))return r.from(bytes.hexlify(t));if(t)if(t.toHexString){let n=t.toHexString();if(typeof n=="string")return r.from(n)}else {let n=t._hex;if(n==null&&t.type==="BigNumber"&&(n=t.hex),typeof n=="string"&&(bytes.isHexString(n)||n[0]==="-"&&bytes.isHexString(n.substring(1))))return r.from(n)}return Er.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return !!(e&&e._isBigNumber)}};function ca(r){if(typeof r!="string")return ca(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&Er.throwArgumentError("invalid hex","value",r),r=ca(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return "0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function wt(r){return Z.from(ca(r))}function me(r){let e=Z.from(r).toHexString();return e[0]==="-"?new Xa("-"+e.substring(3),16):new Xa(e.substring(2),16)}function Mt(r,e,t){let n={fault:r,operation:e};return t!=null&&(n.value=t),Er.throwError(r,U.errors.NUMERIC_FAULT,n)}function Cs(r){return new Xa(r,36).toString(16)}var Ip="properties/5.8.0";var Yg=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},Za=new U(Ip);function se(r,e,t){Object.defineProperty(r,e,{enumerable:true,value:t,writable:false});}function Jr(r,e){for(let t=0;t<32;t++){if(r[e])return r[e];if(!r.prototype||typeof r.prototype!="object")break;r=Object.getPrototypeOf(r.prototype).constructor;}return null}function et(r){return Yg(this,void 0,void 0,function*(){let e=Object.keys(r).map(n=>{let a=r[n];return Promise.resolve(a).then(i=>({key:n,value:i}))});return (yield Promise.all(e)).reduce((n,a)=>(n[a.key]=a.value,n),{})})}function Pp(r,e){(!r||typeof r!="object")&&Za.throwArgumentError("invalid object","object",r),Object.keys(r).forEach(t=>{e[t]||Za.throwArgumentError("invalid object key - "+t,"transaction:"+t,r);});}function ot(r){let e={};for(let t in r)e[t]=r[t];return e}var Xg={bigint:true,boolean:true,function:true,number:true,string:true};function Rp(r){if(r==null||Xg[typeof r])return true;if(Array.isArray(r)||typeof r=="object"){if(!Object.isFrozen(r))return false;let e=Object.keys(r);for(let t=0;t<e.length;t++){let n=null;try{n=r[e[t]];}catch{continue}if(!Rp(n))return false}return true}return Za.throwArgumentError(`Cannot deepCopy ${typeof r}`,"object",r)}function Zg(r){if(Rp(r))return r;if(Array.isArray(r))return Object.freeze(r.map(e=>un(e)));if(typeof r=="object"){let e={};for(let t in r){let n=r[t];n!==void 0&&se(e,t,un(n));}return e}return Za.throwArgumentError(`Cannot deepCopy ${typeof r}`,"object",r)}function un(r){return Zg(r)}var $a=class{constructor(e){for(let t in e)this[t]=un(e[t]);}};var _p="abstract-provider/5.8.0";var $g=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},ex=new U(_p),ei=class extends $a{static isForkEvent(e){return !!(e&&e._isForkEvent)}};var ti=class r{constructor(){ex.checkAbstract(new.target,r),se(this,"_isProvider",true);}getFeeData(){return $g(this,void 0,void 0,function*(){let{block:e,gasPrice:t}=yield et({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(o=>null)}),n=null,a=null,i=null;return e&&e.baseFeePerGas&&(n=e.baseFeePerGas,i=Z.from("1500000000"),a=e.baseFeePerGas.mul(2).add(i)),{lastBaseFeePerGas:n,maxFeePerGas:a,maxPriorityFeePerGas:i,gasPrice:t}})}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}static isProvider(e){return !!(e&&e._isProvider)}};var Tp="networks/5.8.0";var kp=new U(Tp);function tx(r){return r&&typeof r.renetwork=="function"}function qt(r){let e=function(t,n){n==null&&(n={});let a=[];if(t.InfuraProvider&&n.infura!=="-")try{a.push(new t.InfuraProvider(r,n.infura));}catch{}if(t.EtherscanProvider&&n.etherscan!=="-")try{a.push(new t.EtherscanProvider(r,n.etherscan));}catch{}if(t.AlchemyProvider&&n.alchemy!=="-")try{a.push(new t.AlchemyProvider(r,n.alchemy));}catch{}if(t.PocketProvider&&n.pocket!=="-"){let i=["goerli","ropsten","rinkeby","sepolia"];try{let o=new t.PocketProvider(r,n.pocket);o.network&&i.indexOf(o.network.name)===-1&&a.push(o);}catch{}}if(t.CloudflareProvider&&n.cloudflare!=="-")try{a.push(new t.CloudflareProvider(r));}catch{}if(t.AnkrProvider&&n.ankr!=="-")try{let i=["ropsten"],o=new t.AnkrProvider(r,n.ankr);o.network&&i.indexOf(o.network.name)===-1&&a.push(o);}catch{}if(t.QuickNodeProvider&&n.quicknode!=="-")try{a.push(new t.QuickNodeProvider(r,n.quicknode));}catch{}if(a.length===0)return null;if(t.FallbackProvider){let i=1;return n.quorum!=null?i=n.quorum:r==="homestead"&&(i=2),new t.FallbackProvider(a,i)}return a[0]};return e.renetwork=function(t){return qt(t)},e}function ni(r,e){let t=function(n,a){return n.JsonRpcProvider?new n.JsonRpcProvider(r,e):null};return t.renetwork=function(n){return ni(r,n)},t}var Bp={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:qt("homestead")},Sp={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:qt("ropsten")},Dp={chainId:63,name:"classicMordor",_defaultProvider:ni("https://www.ethercluster.com/mordor","classicMordor")},ri={unspecified:{chainId:0,name:"unspecified"},homestead:Bp,mainnet:Bp,morden:{chainId:2,name:"morden"},ropsten:Sp,testnet:Sp,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:qt("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:qt("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:qt("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"sepolia",_defaultProvider:qt("sepolia")},holesky:{chainId:17e3,name:"holesky",_defaultProvider:qt("holesky")},classic:{chainId:61,name:"classic",_defaultProvider:ni("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:Dp,classicTestnet:Dp,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:ni("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:qt("matic")},maticmum:{chainId:80001,name:"maticmum",_defaultProvider:qt("maticmum")},optimism:{chainId:10,name:"optimism",_defaultProvider:qt("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},"optimism-sepolia":{chainId:11155420,name:"optimism-sepolia"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},"arbitrum-sepolia":{chainId:421614,name:"arbitrum-sepolia"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function Mp(r){if(r==null)return null;if(typeof r=="number"){for(let n in ri){let a=ri[n];if(a.chainId===r)return {name:a.name,chainId:a.chainId,ensAddress:a.ensAddress||null,_defaultProvider:a._defaultProvider||null}}return {chainId:r,name:"unknown"}}if(typeof r=="string"){let n=ri[r];return n==null?null:{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress,_defaultProvider:n._defaultProvider||null}}let e=ri[r.name];if(!e)return typeof r.chainId!="number"&&kp.throwArgumentError("invalid network chainId","network",r),r;r.chainId!==0&&r.chainId!==e.chainId&&kp.throwArgumentError("network chainId mismatch","network",r);let t=r._defaultProvider||null;return t==null&&e._defaultProvider&&(tx(e._defaultProvider)?t=e._defaultProvider.renetwork(r):t=e._defaultProvider),{name:r.name,chainId:e.chainId,ensAddress:r.ensAddress||e.ensAddress||null,_defaultProvider:t}}function da(r){r=atob(r);let e=[];for(let t=0;t<r.length;t++)e.push(r.charCodeAt(t));return bytes.arrayify(e)}function fa(r){r=bytes.arrayify(r);let e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e)}var ai=class{constructor(e){se(this,"alphabet",e),se(this,"base",e.length),se(this,"_alphabetMap",{}),se(this,"_leader",e.charAt(0));for(let t=0;t<e.length;t++)this._alphabetMap[e.charAt(t)]=t;}encode(e){let t=bytes.arrayify(e);if(t.length===0)return "";let n=[0];for(let i=0;i<t.length;++i){let o=t[i];for(let s=0;s<n.length;++s)o+=n[s]<<8,n[s]=o%this.base,o=o/this.base|0;for(;o>0;)n.push(o%this.base),o=o/this.base|0;}let a="";for(let i=0;t[i]===0&&i<t.length-1;++i)a+=this._leader;for(let i=n.length-1;i>=0;--i)a+=this.alphabet[n[i]];return a}decode(e){if(typeof e!="string")throw new TypeError("Expected String");let t=[];if(e.length===0)return new Uint8Array(t);t.push(0);for(let n=0;n<e.length;n++){let a=this._alphabetMap[e[n]];if(a===void 0)throw new Error("Non-base"+this.base+" character");let i=a;for(let o=0;o<t.length;++o)i+=t[o]*this.base,t[o]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8;}for(let n=0;e[n]===this._leader&&n<e.length-1;++n)t.push(0);return bytes.arrayify(new Uint8Array(t.reverse()))}};new ai("abcdefghijklmnopqrstuvwxyz234567");var ii=new ai("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var Es="0x0000000000000000000000000000000000000000";var Is=Z.from(0);var Ps="0x0000000000000000000000000000000000000000000000000000000000000000";var Lp=wr(Op());function $e(r){return "0x"+Lp.default.keccak_256(bytes.arrayify(r))}var Up="strings/5.8.0";var Gp=new U(Up),Sn;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD";})(Sn||(Sn={}));var Ct;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation";})(Ct||(Ct={}));function nx(r,e,t,n,a){return Gp.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function zp(r,e,t,n,a){if(r===Ct.BAD_PREFIX||r===Ct.UNEXPECTED_CONTINUE){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return r===Ct.OVERRUN?t.length-e-1:0}function ax(r,e,t,n,a){return r===Ct.OVERLONG?(n.push(a),0):(n.push(65533),zp(r,e,t))}var Hp=Object.freeze({error:nx,ignore:zp,replace:ax});function Wp(r,e){e==null&&(e=Hp.error),r=bytes.arrayify(r);let t=[],n=0;for(;n<r.length;){let a=r[n++];if(a>>7===0){t.push(a);continue}let i=null,o=null;if((a&224)===192)i=1,o=127;else if((a&240)===224)i=2,o=2047;else if((a&248)===240)i=3,o=65535;else {(a&192)===128?n+=e(Ct.UNEXPECTED_CONTINUE,n-1,r,t):n+=e(Ct.BAD_PREFIX,n-1,r,t);continue}if(n-1+i>=r.length){n+=e(Ct.OVERRUN,n-1,r,t);continue}let s=a&(1<<8-i-1)-1;for(let p=0;p<i;p++){let c=r[n];if((c&192)!=128){n+=e(Ct.MISSING_CONTINUE,n,r,t),s=null;break}s=s<<6|c&63,n++;}if(s!==null){if(s>1114111){n+=e(Ct.OUT_OF_RANGE,n-1-i,r,t,s);continue}if(s>=55296&&s<=57343){n+=e(Ct.UTF16_SURROGATE,n-1-i,r,t,s);continue}if(s<=o){n+=e(Ct.OVERLONG,n-1-i,r,t,s);continue}t.push(s);}}return t}function bt(r,e=Sn.current){e!=Sn.current&&(Gp.checkNormalize(),r=r.normalize(e));let t=[];for(let n=0;n<r.length;n++){let a=r.charCodeAt(n);if(a<128)t.push(a);else if(a<2048)t.push(a>>6|192),t.push(a&63|128);else if((a&64512)==55296){n++;let i=r.charCodeAt(n);if(n>=r.length||(i&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((a&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128);}else t.push(a>>12|224),t.push(a>>6&63|128),t.push(a&63|128);}return bytes.arrayify(t)}function ix(r){return r.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Yr(r,e){return ix(Wp(r,e))}function Rs(r,e=Sn.current){return Wp(bt(r,e))}function _s(r){return $e(bt(r))}var si="hash/5.8.0";function Qp(r,e){e==null&&(e=1);let t=[],n=t.forEach,a=function(i,o){n.call(i,function(s){o>0&&Array.isArray(s)?a(s,o-1):t.push(s);});};return a(r,e),t}function ox(r){let e={};for(let t=0;t<r.length;t++){let n=r[t];e[n[0]]=n[1];}return e}function sx(r){let e=0;function t(){return r[e++]<<8|r[e++]}let n=t(),a=1,i=[0,1];for(let D=1;D<n;D++)i.push(a+=t());let o=t(),s=e;e+=o;let p=0,c=0;function l(){return p==0&&(c=c<<8|r[e++],p=8),c>>--p&1}let f=31,h=Math.pow(2,f),y=h>>>1,x=y>>1,w=h-1,_=0;for(let D=0;D<f;D++)_=_<<1|l();let v=[],E=0,B=h;for(;;){let D=Math.floor(((_-E+1)*a-1)/B),M=0,G=n;for(;G-M>1;){let W=M+G>>>1;D<i[W]?G=W:M=W;}if(M==0)break;v.push(M);let L=E+Math.floor(B*i[M]/a),z=E+Math.floor(B*i[M+1]/a)-1;for(;((L^z)&y)==0;)_=_<<1&w|l(),L=L<<1&w,z=z<<1&w|1;for(;L&~z&x;)_=_&y|_<<1&w>>>1|l(),L=L<<1^y,z=(z^y)<<1|y|1;E=L,B=1+z-L;}let S=n-4;return v.map(D=>{switch(D-S){case 3:return S+65792+(r[s++]<<16|r[s++]<<8|r[s++]);case 2:return S+256+(r[s++]<<8|r[s++]);case 1:return S+r[s++];default:return D-1}})}function ux(r){let e=0;return ()=>r[e++]}function Vp(r){return ux(sx(r))}function px(r){return r&1?~r>>1:r>>1}function lx(r,e){let t=Array(r);for(let n=0;n<r;n++)t[n]=1+e();return t}function Kp(r,e){let t=Array(r);for(let n=0,a=-1;n<r;n++)t[n]=a+=1+e();return t}function cx(r,e){let t=Array(r);for(let n=0,a=0;n<r;n++)t[n]=a+=px(e());return t}function ma(r,e){let t=Kp(r(),r),n=r(),a=Kp(n,r),i=lx(n,r);for(let o=0;o<n;o++)for(let s=0;s<i[o];s++)t.push(a[o]+s);return e?t.map(o=>e[o]):t}function jp(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(fx(t,r));}for(;;){let t=r()-1;if(t<0)break;e.push(mx(t,r));}return ox(Qp(e))}function dx(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t);}return e}function Jp(r,e,t){let n=Array(r).fill(void 0).map(()=>[]);for(let a=0;a<e;a++)cx(r,t).forEach((i,o)=>n[o].push(i));return n}function fx(r,e){let t=1+e(),n=e(),a=dx(e),i=Jp(a.length,1+r,e);return Qp(i.map((o,s)=>{let p=o[0],c=o.slice(1);return Array(a[s]).fill(void 0).map((l,f)=>{let h=f*n;return [p+f*t,c.map(y=>y+h)]})}))}function mx(r,e){let t=1+e();return Jp(t,1+r,e).map(a=>[a[0],a.slice(1)])}function Yp(r){let e=ma(r).sort((n,a)=>n-a);return t();function t(){let n=[];for(;;){let c=ma(r,e);if(c.length==0)break;n.push({set:new Set(c),node:t()});}n.sort((c,l)=>l.set.size-c.set.size);let a=r(),i=a%3;a=a/3|0;let o=!!(a&1);a>>=1;let s=a==1,p=a==2;return {branches:n,valid:i,fe0f:o,save:s,check:p}}}function Xp(){return Vp(da("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}var ui=Xp(),hx=new Set(ma(ui)),yx=new Set(ma(ui)),gx=jp(ui),xx=Yp(ui),Zp=45,$p=95;function el(r){return Rs(r)}function bx(r){return r.filter(e=>e!=65039)}function tl(r){for(let e of r.split(".")){let t=el(e);try{for(let n=t.lastIndexOf($p)-1;n>=0;n--)if(t[n]!==$p)throw new Error("underscore only allowed at start");if(t.length>=4&&t.every(n=>n<128)&&t[2]===Zp&&t[3]===Zp)throw new Error("invalid label extension")}catch(n){throw new Error(`Invalid label "${e}": ${n.message}`)}}return r}function rl(r){return tl(vx(r,bx))}function vx(r,e){let t=el(r).reverse(),n=[];for(;t.length;){let a=wx(t);if(a){n.push(...e(a));continue}let i=t.pop();if(hx.has(i)){n.push(i);continue}if(yx.has(i))continue;let o=gx[i];if(o){n.push(...o);continue}throw new Error(`Disallowed codepoint: 0x${i.toString(16).toUpperCase()}`)}return tl(Ax(String.fromCodePoint(...n)))}function Ax(r){return r.normalize("NFC")}function wx(r,e){var t;let n=xx,a,i,o=[],s=r.length;for(e;s;){let p=r[--s];if(n=(t=n.branches.find(c=>c.set.has(p)))===null||t===void 0?void 0:t.node,!n)break;if(n.save)i=p;else if(n.check&&p===i)break;o.push(p),n.fe0f&&(o.push(65039),s>0&&r[s-1]==65039&&s--),n.valid&&(a=o.slice(),n.valid==2&&a.splice(1,1),r.length=s);}return a}var Cx=new U(si),ol=new Uint8Array(32);ol.fill(0);function nl(r){if(r.length===0)throw new Error("invalid ENS name; empty component");return r}function sl(r){let e=bt(rl(r)),t=[];if(r.length===0)return t;let n=0;for(let a=0;a<e.length;a++)e[a]===46&&(t.push(nl(e.slice(n,a))),n=a+1);if(n>=e.length)throw new Error("invalid ENS name; empty component");return t.push(nl(e.slice(n))),t}function Dn(r){typeof r!="string"&&Cx.throwArgumentError("invalid ENS name; not a string","name",r);let e=ol,t=sl(r);for(;t.length;)e=$e(bytes.concat([e,$e(t.pop())]));return bytes.hexlify(e)}function Ts(r){return bytes.hexlify(bytes.concat(sl(r).map(e=>{if(e.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");let t=new Uint8Array(e.length+1);return t.set(e,1),t[0]=t.length-1,t})))+"00"}var ul="rlp/5.8.0";var ar=new U(ul);function pl(r){let e=[];for(;r;)e.unshift(r&255),r>>=8;return e}function ll(r,e,t){let n=0;for(let a=0;a<t;a++)n=n*256+r[e+a];return n}function fl(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(i){n=n.concat(fl(i));}),n.length<=55)return n.unshift(192+n.length),n;let a=pl(n.length);return a.unshift(247+a.length),a.concat(n)}bytes.isBytesLike(r)||ar.throwArgumentError("RLP object must be BytesLike","object",r);let e=Array.prototype.slice.call(bytes.arrayify(r));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;let t=pl(e.length);return t.unshift(183+t.length),t.concat(e)}function Mn(r){return bytes.hexlify(fl(r))}function cl(r,e,t,n){let a=[];for(;t<e+1+n;){let i=ml(r,t);a.push(i.result),t+=i.consumed,t>e+1+n&&ar.throwError("child data too short",U.errors.BUFFER_OVERRUN,{});}return {consumed:1+n,result:a}}function ml(r,e){if(r.length===0&&ar.throwError("data too short",U.errors.BUFFER_OVERRUN,{}),r[e]>=248){let t=r[e]-247;e+1+t>r.length&&ar.throwError("data short segment too short",U.errors.BUFFER_OVERRUN,{});let n=ll(r,e+1,t);return e+1+t+n>r.length&&ar.throwError("data long segment too short",U.errors.BUFFER_OVERRUN,{}),cl(r,e,e+1+t,t+n)}else if(r[e]>=192){let t=r[e]-192;return e+1+t>r.length&&ar.throwError("data array too short",U.errors.BUFFER_OVERRUN,{}),cl(r,e,e+1,t)}else if(r[e]>=184){let t=r[e]-183;e+1+t>r.length&&ar.throwError("data array too short",U.errors.BUFFER_OVERRUN,{});let n=ll(r,e+1,t);e+1+t+n>r.length&&ar.throwError("data array too short",U.errors.BUFFER_OVERRUN,{});let a=bytes.hexlify(r.slice(e+1+t,e+1+t+n));return {consumed:1+t+n,result:a}}else if(r[e]>=128){let t=r[e]-128;e+1+t>r.length&&ar.throwError("data too short",U.errors.BUFFER_OVERRUN,{});let n=bytes.hexlify(r.slice(e+1,e+1+t));return {consumed:1+t,result:n}}return {consumed:1,result:bytes.hexlify(r[e])}}function li(r){let e=bytes.arrayify(r),t=ml(e,0);return t.consumed!==e.length&&ar.throwArgumentError("invalid rlp data","data",r),t.result}var hl="address/5.8.0";var Fn=new U(hl);function yl(r){bytes.isHexString(r,20)||Fn.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let a=0;a<40;a++)t[a]=e[a].charCodeAt(0);let n=bytes.arrayify($e(t));for(let a=0;a<40;a+=2)n[a>>1]>>4>=8&&(e[a]=e[a].toUpperCase()),(n[a>>1]&15)>=8&&(e[a+1]=e[a+1].toUpperCase());return "0x"+e.join("")}var Tx=9007199254740991;function kx(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var ks={};for(let r=0;r<10;r++)ks[String(r)]=String(r);for(let r=0;r<26;r++)ks[String.fromCharCode(65+r)]=String(10+r);var gl=Math.floor(kx(Tx));function Bx(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(n=>ks[n]).join("");for(;e.length>=gl;){let n=e.substring(0,gl);e=parseInt(n,10)%97+e.substring(n.length);}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function Et(r){let e=null;if(typeof r!="string"&&Fn.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=yl(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&Fn.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Bx(r)&&Fn.throwArgumentError("bad icap checksum","address",r),e=Cs(r.substring(4));e.length<40;)e="0"+e;e=yl("0x"+e);}else Fn.throwArgumentError("invalid address","address",r);return e}function bl(r){let e=null;try{e=Et(r.from);}catch{Fn.throwArgumentError("missing from address","transaction",r);}let t=bytes.stripZeros(bytes.arrayify(Z.from(r.nonce).toHexString()));return Et(bytes.hexDataSlice($e(Mn([e,t])),12))}var Sx=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},Xe=new U(si),El=new Uint8Array(32);El.fill(0);var Dx=Z.from(-1),Il=Z.from(0),Pl=Z.from(1),Mx=Z.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function Fx(r){let e=bytes.arrayify(r),t=e.length%32;return t?bytes.hexConcat([e,El.slice(t)]):bytes.hexlify(e)}var Nx=bytes.hexZeroPad(Pl.toHexString(),32),Ox=bytes.hexZeroPad(Il.toHexString(),32),Al={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Bs=["name","version","chainId","verifyingContract","salt"];function wl(r){return function(e){return typeof e!="string"&&Xe.throwArgumentError(`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,e),e}}var Lx={name:wl("name"),version:wl("version"),chainId:function(r){try{return Z.from(r).toString()}catch{}return Xe.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",r)},verifyingContract:function(r){try{return Et(r).toLowerCase()}catch{}return Xe.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",r)},salt:function(r){try{let e=bytes.arrayify(r);if(e.length!==32)throw new Error("bad length");return bytes.hexlify(e)}catch{}return Xe.throwArgumentError('invalid domain value "salt"',"domain.salt",r)}};function Ss(r){{let e=r.match(/^(u?)int(\d*)$/);if(e){let t=e[1]==="",n=parseInt(e[2]||"256");(n%8!==0||n>256||e[2]&&e[2]!==String(n))&&Xe.throwArgumentError("invalid numeric width","type",r);let a=Mx.mask(t?n-1:n),i=t?a.add(Pl).mul(Dx):Il;return function(o){let s=Z.from(o);return (s.lt(i)||s.gt(a))&&Xe.throwArgumentError(`value out-of-bounds for ${r}`,"value",o),bytes.hexZeroPad(s.toTwos(256).toHexString(),32)}}}{let e=r.match(/^bytes(\d+)$/);if(e){let t=parseInt(e[1]);return (t===0||t>32||e[1]!==String(t))&&Xe.throwArgumentError("invalid bytes width","type",r),function(n){return bytes.arrayify(n).length!==t&&Xe.throwArgumentError(`invalid length for ${r}`,"value",n),Fx(n)}}}switch(r){case "address":return function(e){return bytes.hexZeroPad(Et(e),32)};case "bool":return function(e){return e?Nx:Ox};case "bytes":return function(e){return $e(e)};case "string":return function(e){return _s(e)}}return null}function Cl(r,e){return `${r}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}var Nn=class r{constructor(e){se(this,"types",Object.freeze(un(e))),se(this,"_encoderCache",{}),se(this,"_types",{});let t={},n={},a={};Object.keys(e).forEach(s=>{t[s]={},n[s]=[],a[s]={};});for(let s in e){let p={};e[s].forEach(c=>{p[c.name]&&Xe.throwArgumentError(`duplicate variable name ${JSON.stringify(c.name)} in ${JSON.stringify(s)}`,"types",e),p[c.name]=true;let l=c.type.match(/^([^\x5b]*)(\x5b|$)/)[1];l===s&&Xe.throwArgumentError(`circular type reference to ${JSON.stringify(l)}`,"types",e),!Ss(l)&&(n[l]||Xe.throwArgumentError(`unknown type ${JSON.stringify(l)}`,"types",e),n[l].push(s),t[s][l]=true);});}let i=Object.keys(n).filter(s=>n[s].length===0);i.length===0?Xe.throwArgumentError("missing primary type","types",e):i.length>1&&Xe.throwArgumentError(`ambiguous primary types or unused types: ${i.map(s=>JSON.stringify(s)).join(", ")}`,"types",e),se(this,"primaryType",i[0]);function o(s,p){p[s]&&Xe.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",e),p[s]=true,Object.keys(t[s]).forEach(c=>{n[c]&&(o(c,p),Object.keys(p).forEach(l=>{a[l][c]=true;}));}),delete p[s];}o(this.primaryType,{});for(let s in a){let p=Object.keys(a[s]);p.sort(),this._types[s]=Cl(s,e[s])+p.map(c=>Cl(c,e[c])).join("");}}getEncoder(e){let t=this._encoderCache[e];return t||(t=this._encoderCache[e]=this._getEncoder(e)),t}_getEncoder(e){{let a=Ss(e);if(a)return a}let t=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){let a=t[1],i=this.getEncoder(a),o=parseInt(t[3]);return s=>{o>=0&&s.length!==o&&Xe.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",s);let p=s.map(i);return this._types[a]&&(p=p.map($e)),$e(bytes.hexConcat(p))}}let n=this.types[e];if(n){let a=_s(this._types[e]);return i=>{let o=n.map(({name:s,type:p})=>{let c=this.getEncoder(p)(i[s]);return this._types[p]?$e(c):c});return o.unshift(a),bytes.hexConcat(o)}}return Xe.throwArgumentError(`unknown type: ${e}`,"type",e)}encodeType(e){let t=this._types[e];return t||Xe.throwArgumentError(`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return $e(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(Ss(e))return n(e,t);let a=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(a){let o=a[1],s=parseInt(a[3]);return s>=0&&t.length!==s&&Xe.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map(p=>this._visit(o,p,n))}let i=this.types[e];return i?i.reduce((o,{name:s,type:p})=>(o[s]=this._visit(p,t[s],n),o),{}):Xe.throwArgumentError(`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new r(e)}static getPrimaryType(e){return r.from(e).primaryType}static hashStruct(e,t,n){return r.from(t).hashStruct(e,n)}static hashDomain(e){let t=[];for(let n in e){let a=Al[n];a||Xe.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:a});}return t.sort((n,a)=>Bs.indexOf(n.name)-Bs.indexOf(a.name)),r.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return bytes.hexConcat(["0x1901",r.hashDomain(e),r.from(t).hash(n)])}static hash(e,t,n){return $e(r.encode(e,t,n))}static resolveNames(e,t,n,a){return Sx(this,void 0,void 0,function*(){e=ot(e);let i={};e.verifyingContract&&!bytes.isHexString(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");let o=r.from(t);o.visit(n,(s,p)=>(s==="address"&&!bytes.isHexString(p,20)&&(i[p]="0x"),p));for(let s in i)i[s]=yield a(s);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),n=o.visit(n,(s,p)=>s==="address"&&i[p]?i[p]:p),{domain:e,value:n}})}static getPayload(e,t,n){r.hashDomain(e);let a={},i=[];Bs.forEach(p=>{let c=e[p];c!=null&&(a[p]=Lx[p](c),i.push({name:p,type:Al[p]}));});let o=r.from(t),s=ot(t);return s.EIP712Domain?Xe.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):s.EIP712Domain=i,o.encode(n),{types:s,domain:a,primaryType:o.primaryType,message:o.visit(n,(p,c)=>{if(p.match(/^bytes(\d*)/))return bytes.hexlify(bytes.arrayify(c));if(p.match(/^u?int/))return Z.from(c).toString();switch(p){case "address":return c.toLowerCase();case "bool":return !!c;case "string":return typeof c!="string"&&Xe.throwArgumentError("invalid string","value",c),c}return Xe.throwArgumentError("unsupported type","type",p)})}}};var cc=wr(Ks());function yi(r){return "0x"+cc.default.sha256().update(bytes.arrayify(r)).digest("hex")}var dc="web/5.8.0";var u2=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})};function fc(r,e){return u2(this,void 0,void 0,function*(){e==null&&(e={});let t={method:e.method||"GET",headers:e.headers||{},body:e.body||void 0};if(e.skipFetchSetup!==true&&(t.mode="cors",t.cache="no-cache",t.credentials="same-origin",t.redirect="follow",t.referrer="client"),e.fetchOptions!=null){let o=e.fetchOptions;o.mode&&(t.mode=o.mode),o.cache&&(t.cache=o.cache),o.credentials&&(t.credentials=o.credentials),o.redirect&&(t.redirect=o.redirect),o.referrer&&(t.referrer=o.referrer);}let n=yield fetch(r,t),a=yield n.arrayBuffer(),i={};return n.headers.forEach?n.headers.forEach((o,s)=>{i[s.toLowerCase()]=o;}):n.headers.keys().forEach(o=>{i[o.toLowerCase()]=n.headers.get(o);}),{headers:i,statusCode:n.status,statusMessage:n.statusText,body:bytes.arrayify(new Uint8Array(a))}})}var l2=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},Wt=new U(dc);function mc(r){return new Promise(e=>{setTimeout(e,r);})}function Zr(r,e){if(r==null)return null;if(typeof r=="string")return r;if(bytes.isBytesLike(r)){if(e&&(e.split("/")[0]==="text"||e.split(";")[0].trim()==="application/json"))try{return Yr(r)}catch{}return bytes.hexlify(r)}return r}function f2(r){return bt(r.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function m2(r,e,t){let n=typeof r=="object"&&r.throttleLimit!=null?r.throttleLimit:12;Wt.assertArgument(n>0&&n%1===0,"invalid connection throttle limit","connection.throttleLimit",n);let a=typeof r=="object"?r.throttleCallback:null,i=typeof r=="object"&&typeof r.throttleSlotInterval=="number"?r.throttleSlotInterval:100;Wt.assertArgument(i>0&&i%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",i);let o=typeof r=="object"?!!r.errorPassThrough:false,s={},p=null,c={method:"GET"},l=false,f=120*1e3;if(typeof r=="string")p=r;else if(typeof r=="object"){if((r==null||r.url==null)&&Wt.throwArgumentError("missing URL","connection.url",r),p=r.url,typeof r.timeout=="number"&&r.timeout>0&&(f=r.timeout),r.headers)for(let v in r.headers)s[v.toLowerCase()]={key:v,value:String(r.headers[v])},["if-none-match","if-modified-since"].indexOf(v.toLowerCase())>=0&&(l=true);if(c.allowGzip=!!r.allowGzip,r.user!=null&&r.password!=null){p.substring(0,6)!=="https:"&&r.allowInsecureAuthentication!==true&&Wt.throwError("basic authentication requires a secure https url",U.errors.INVALID_ARGUMENT,{argument:"url",url:p,user:r.user,password:"[REDACTED]"});let v=r.user+":"+r.password;s.authorization={key:"Authorization",value:"Basic "+fa(bt(v))};}r.skipFetchSetup!=null&&(c.skipFetchSetup=!!r.skipFetchSetup),r.fetchOptions!=null&&(c.fetchOptions=ot(r.fetchOptions));}let h=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),y=p?p.match(h):null;if(y)try{let v={statusCode:200,statusMessage:"OK",headers:{"content-type":y[1]||"text/plain"},body:y[2]?da(y[3]):f2(y[3])},E=v.body;return t&&(E=t(v.body,v)),Promise.resolve(E)}catch(v){Wt.throwError("processing response error",U.errors.SERVER_ERROR,{body:Zr(y[1],y[2]),error:v,requestBody:null,requestMethod:"GET",url:p});}e&&(c.method="POST",c.body=e,s["content-type"]==null&&(s["content-type"]={key:"Content-Type",value:"application/octet-stream"}),s["content-length"]==null&&(s["content-length"]={key:"Content-Length",value:String(e.length)}));let x={};Object.keys(s).forEach(v=>{let E=s[v];x[E.key]=E.value;}),c.headers=x;let w=(function(){let v=null;return {promise:new Promise(function(S,D){f&&(v=setTimeout(()=>{v!=null&&(v=null,D(Wt.makeError("timeout",U.errors.TIMEOUT,{requestBody:Zr(c.body,x["content-type"]),requestMethod:c.method,timeout:f,url:p})));},f));}),cancel:function(){v!=null&&(clearTimeout(v),v=null);}}})(),_=(function(){return l2(this,void 0,void 0,function*(){for(let v=0;v<n;v++){let E=null;try{if(E=yield fc(p,c),v<n){if(E.statusCode===301||E.statusCode===302){let S=E.headers.location||"";if(c.method==="GET"&&S.match(/^https:/)){p=E.headers.location;continue}}else if(E.statusCode===429){let S=!0;if(a&&(S=yield a(v,p)),S){let D=0,M=E.headers["retry-after"];typeof M=="string"&&M.match(/^[1-9][0-9]*$/)?D=parseInt(M)*1e3:D=i*parseInt(String(Math.random()*Math.pow(2,v))),yield mc(D);continue}}}}catch(S){E=S.response,E==null&&(w.cancel(),Wt.throwError("missing response",U.errors.SERVER_ERROR,{requestBody:Zr(c.body,x["content-type"]),requestMethod:c.method,serverError:S,url:p}));}let B=E.body;if(l&&E.statusCode===304?B=null:!o&&(E.statusCode<200||E.statusCode>=300)&&(w.cancel(),Wt.throwError("bad response",U.errors.SERVER_ERROR,{status:E.statusCode,headers:E.headers,body:Zr(B,E.headers?E.headers["content-type"]:null),requestBody:Zr(c.body,x["content-type"]),requestMethod:c.method,url:p})),t)try{let S=yield t(B,E);return w.cancel(),S}catch(S){if(S.throttleRetry&&v<n){let D=true;if(a&&(D=yield a(v,p)),D){let M=i*parseInt(String(Math.random()*Math.pow(2,v)));yield mc(M);continue}}w.cancel(),Wt.throwError("processing response error",U.errors.SERVER_ERROR,{body:Zr(B,E.headers?E.headers["content-type"]:null),error:S,requestBody:Zr(c.body,x["content-type"]),requestMethod:c.method,url:p});}return w.cancel(),B}return Wt.throwError("failed response",U.errors.SERVER_ERROR,{requestBody:Zr(c.body,x["content-type"]),requestMethod:c.method,url:p})})})();return Promise.race([w.promise,_])}function ga(r,e,t){let n=(i,o)=>{let s=null;if(i!=null)try{s=JSON.parse(Yr(i));}catch(p){Wt.throwError("invalid JSON",U.errors.SERVER_ERROR,{body:i,error:p});}return t&&(s=t(s,o)),s},a=null;if(e!=null){a=bt(e);let i=typeof r=="string"?{url:r}:ot(r);i.headers?Object.keys(i.headers).filter(s=>s.toLowerCase()==="content-type").length!==0||(i.headers=ot(i.headers),i.headers["content-type"]="application/json"):i.headers={"content-type":"application/json"},r=i;}return m2(r,a,n)}function ln(r,e){return e||(e={}),e=ot(e),e.floor==null&&(e.floor=0),e.ceiling==null&&(e.ceiling=1e4),e.interval==null&&(e.interval=250),new Promise(function(t,n){let a=null,i=false,o=()=>i?false:(i=true,a&&clearTimeout(a),true);e.timeout&&(a=setTimeout(()=>{o()&&n(new Error("timeout"));},e.timeout));let s=e.retryLimit,p=0;function c(){return r().then(function(l){if(l!==void 0)o()&&t(l);else if(e.oncePoll)e.oncePoll.once("poll",c);else if(e.onceBlock)e.onceBlock.once("block",c);else if(!i){if(p++,p>s){o()&&n(new Error("retry limit reached"));return}let f=e.interval*parseInt(String(Math.random()*Math.pow(2,p)));f<e.floor&&(f=e.floor),f>e.ceiling&&(f=e.ceiling),setTimeout(c,f);}return null},function(l){o()&&n(l);})}c();})}var lu=wr(xc());var cr="providers/5.8.0";var re=wr(bs()),dr=wr(Ks());function Kn(r,e,t){return t={path:e,exports:{},require:function(n,a){return w2(n,a??t.path)}},r(t,t.exports),t.exports}function w2(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Ys=vc;function vc(r,e){if(!r)throw new Error(e||"Assertion failed")}vc.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)};var Kt=Kn(function(r,e){var t=e;function n(o,s){if(Array.isArray(o))return o.slice();if(!o)return [];var p=[];if(typeof o!="string"){for(var c=0;c<o.length;c++)p[c]=o[c]|0;return p}if(s==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var c=0;c<o.length;c+=2)p.push(parseInt(o[c]+o[c+1],16));}else for(var c=0;c<o.length;c++){var l=o.charCodeAt(c),f=l>>8,h=l&255;f?p.push(f,h):p.push(h);}return p}t.toArray=n;function a(o){return o.length===1?"0"+o:o}t.zero2=a;function i(o){for(var s="",p=0;p<o.length;p++)s+=a(o[p].toString(16));return s}t.toHex=i,t.encode=function(s,p){return p==="hex"?i(s):s};}),_t=Kn(function(r,e){var t=e;t.assert=Ys,t.toArray=Kt.toArray,t.zero2=Kt.zero2,t.toHex=Kt.toHex,t.encode=Kt.encode;function n(p,c,l){var f=new Array(Math.max(p.bitLength(),l)+1),h;for(h=0;h<f.length;h+=1)f[h]=0;var y=1<<c+1,x=p.clone();for(h=0;h<f.length;h++){var w,_=x.andln(y-1);x.isOdd()?(_>(y>>1)-1?w=(y>>1)-_:w=_,x.isubn(w)):w=0,f[h]=w,x.iushrn(1);}return f}t.getNAF=n;function a(p,c){var l=[[],[]];p=p.clone(),c=c.clone();for(var f=0,h=0,y;p.cmpn(-f)>0||c.cmpn(-h)>0;){var x=p.andln(3)+f&3,w=c.andln(3)+h&3;x===3&&(x=-1),w===3&&(w=-1);var _;(x&1)===0?_=0:(y=p.andln(7)+f&7,(y===3||y===5)&&w===2?_=-x:_=x),l[0].push(_);var v;(w&1)===0?v=0:(y=c.andln(7)+h&7,(y===3||y===5)&&x===2?v=-w:v=w),l[1].push(v),2*f===_+1&&(f=1-f),2*h===v+1&&(h=1-h),p.iushrn(1),c.iushrn(1);}return l}t.getJSF=a;function i(p,c,l){var f="_"+c;p.prototype[c]=function(){return this[f]!==void 0?this[f]:this[f]=l.call(this)};}t.cachedProperty=i;function o(p){return typeof p=="string"?t.toArray(p,"hex"):p}t.parseBytes=o;function s(p){return new re.default(p,"hex","le")}t.intFromLE=s;}),wi=_t.getNAF,C2=_t.getJSF,Ci=_t.assert;function en(r,e){this.type=r,this.p=new re.default(e.p,16),this.red=e.prime?re.default.red(e.prime):re.default.mont(this.p),this.zero=new re.default(0).toRed(this.red),this.one=new re.default(1).toRed(this.red),this.two=new re.default(2).toRed(this.red),this.n=e.n&&new re.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=true,this.redN=this.n.toRed(this.red));}var dn=en;en.prototype.point=function(){throw new Error("Not implemented")};en.prototype.validate=function(){throw new Error("Not implemented")};en.prototype._fixedNafMul=function(e,t){Ci(e.precomputed);var n=e._getDoubles(),a=wi(t,1,this._bitLength),i=(1<<n.step+1)-(n.step%2===0?2:1);i/=3;var o=[],s,p;for(s=0;s<a.length;s+=n.step){p=0;for(var c=s+n.step-1;c>=s;c--)p=(p<<1)+a[c];o.push(p);}for(var l=this.jpoint(null,null,null),f=this.jpoint(null,null,null),h=i;h>0;h--){for(s=0;s<o.length;s++)p=o[s],p===h?f=f.mixedAdd(n.points[s]):p===-h&&(f=f.mixedAdd(n.points[s].neg()));l=l.add(f);}return l.toP()};en.prototype._wnafMul=function(e,t){var n=4,a=e._getNAFPoints(n);n=a.wnd;for(var i=a.points,o=wi(t,n,this._bitLength),s=this.jpoint(null,null,null),p=o.length-1;p>=0;p--){for(var c=0;p>=0&&o[p]===0;p--)c++;if(p>=0&&c++,s=s.dblp(c),p<0)break;var l=o[p];Ci(l!==0),e.type==="affine"?l>0?s=s.mixedAdd(i[l-1>>1]):s=s.mixedAdd(i[-l-1>>1].neg()):l>0?s=s.add(i[l-1>>1]):s=s.add(i[-l-1>>1].neg());}return e.type==="affine"?s.toP():s};en.prototype._wnafMulAdd=function(e,t,n,a,i){var o=this._wnafT1,s=this._wnafT2,p=this._wnafT3,c=0,l,f,h;for(l=0;l<a;l++){h=t[l];var y=h._getNAFPoints(e);o[l]=y.wnd,s[l]=y.points;}for(l=a-1;l>=1;l-=2){var x=l-1,w=l;if(o[x]!==1||o[w]!==1){p[x]=wi(n[x],o[x],this._bitLength),p[w]=wi(n[w],o[w],this._bitLength),c=Math.max(p[x].length,c),c=Math.max(p[w].length,c);continue}var _=[t[x],null,null,t[w]];t[x].y.cmp(t[w].y)===0?(_[1]=t[x].add(t[w]),_[2]=t[x].toJ().mixedAdd(t[w].neg())):t[x].y.cmp(t[w].y.redNeg())===0?(_[1]=t[x].toJ().mixedAdd(t[w]),_[2]=t[x].add(t[w].neg())):(_[1]=t[x].toJ().mixedAdd(t[w]),_[2]=t[x].toJ().mixedAdd(t[w].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],E=C2(n[x],n[w]);for(c=Math.max(E[0].length,c),p[x]=new Array(c),p[w]=new Array(c),f=0;f<c;f++){var B=E[0][f]|0,S=E[1][f]|0;p[x][f]=v[(B+1)*3+(S+1)],p[w][f]=0,s[x]=_;}}var D=this.jpoint(null,null,null),M=this._wnafT4;for(l=c;l>=0;l--){for(var G=0;l>=0;){var L=true;for(f=0;f<a;f++)M[f]=p[f][l]|0,M[f]!==0&&(L=false);if(!L)break;G++,l--;}if(l>=0&&G++,D=D.dblp(G),l<0)break;for(f=0;f<a;f++){var z=M[f];z!==0&&(z>0?h=s[f][z-1>>1]:z<0&&(h=s[f][-z-1>>1].neg()),h.type==="affine"?D=D.mixedAdd(h):D=D.add(h));}}for(l=0;l<a;l++)s[l]=null;return i?D:D.toP()};function Nt(r,e){this.curve=r,this.type=e,this.precomputed=null;}en.BasePoint=Nt;Nt.prototype.eq=function(){throw new Error("Not implemented")};Nt.prototype.validate=function(){return this.curve.validate(this)};en.prototype.decodePoint=function(e,t){e=_t.toArray(e,t);var n=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*n){e[0]===6?Ci(e[e.length-1]%2===0):e[0]===7&&Ci(e[e.length-1]%2===1);var a=this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));return a}else if((e[0]===2||e[0]===3)&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),e[0]===3);throw new Error("Unknown point format")};Nt.prototype.encodeCompressed=function(e){return this.encode(e,true)};Nt.prototype._encode=function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))};Nt.prototype.encode=function(e,t){return _t.encode(this._encode(t),e)};Nt.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this};Nt.prototype._hasDoubles=function(e){if(!this.precomputed)return false;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):false};Nt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],a=this,i=0;i<t;i+=e){for(var o=0;o<e;o++)a=a.dbl();n.push(a);}return {step:e,points:n}};Nt.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,a=n===1?null:this.dbl(),i=1;i<n;i++)t[i]=t[i-1].add(a);return {wnd:e,points:t}};Nt.prototype._getBeta=function(){return null};Nt.prototype.dblp=function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t};var Xs=Kn(function(r){typeof Object.create=="function"?r.exports=function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:false,writable:true,configurable:true}}));}:r.exports=function(t,n){if(n){t.super_=n;var a=function(){};a.prototype=n.prototype,t.prototype=new a,t.prototype.constructor=t;}};}),E2=_t.assert;function Ot(r){dn.call(this,"short",r),this.a=new re.default(r.a,16).toRed(this.red),this.b=new re.default(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4);}Xs(Ot,dn);var I2=Ot;Ot.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,n;if(e.beta)t=new re.default(e.beta,16).toRed(this.red);else {var a=this._getEndoRoots(this.p);t=a[0].cmp(a[1])<0?a[0]:a[1],t=t.toRed(this.red);}if(e.lambda)n=new re.default(e.lambda,16);else {var i=this._getEndoRoots(this.n);this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))===0?n=i[0]:(n=i[1],E2(this.g.mul(n).x.cmp(this.g.x.redMul(t))===0));}var o;return e.basis?o=e.basis.map(function(s){return {a:new re.default(s.a,16),b:new re.default(s.b,16)}}):o=this._getEndoBasis(n),{beta:t,lambda:n,basis:o}}};Ot.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:re.default.mont(e),n=new re.default(2).toRed(t).redInvm(),a=n.redNeg(),i=new re.default(3).toRed(t).redNeg().redSqrt().redMul(n),o=a.redAdd(i).fromRed(),s=a.redSub(i).fromRed();return [o,s]};Ot.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,a=this.n.clone(),i=new re.default(1),o=new re.default(0),s=new re.default(0),p=new re.default(1),c,l,f,h,y,x,w,_=0,v,E;n.cmpn(0)!==0;){var B=a.div(n);v=a.sub(B.mul(n)),E=s.sub(B.mul(i));var S=p.sub(B.mul(o));if(!f&&v.cmp(t)<0)c=w.neg(),l=i,f=v.neg(),h=E;else if(f&&++_===2)break;w=v,a=n,n=v,s=i,i=E,p=o,o=S;}y=v.neg(),x=E;var D=f.sqr().add(h.sqr()),M=y.sqr().add(x.sqr());return M.cmp(D)>=0&&(y=c,x=l),f.negative&&(f=f.neg(),h=h.neg()),y.negative&&(y=y.neg(),x=x.neg()),[{a:f,b:h},{a:y,b:x}]};Ot.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],a=t[1],i=a.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),s=i.mul(n.a),p=o.mul(a.a),c=i.mul(n.b),l=o.mul(a.b),f=e.sub(s).sub(p),h=c.add(l).neg();return {k1:f,k2:h}};Ot.prototype.pointFromX=function(e,t){e=new re.default(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),a=n.redSqrt();if(a.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var i=a.fromRed().isOdd();return (t&&!i||!t&&i)&&(a=a.redNeg()),this.point(e,a)};Ot.prototype.validate=function(e){if(e.inf)return true;var t=e.x,n=e.y,a=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(a).redIAdd(this.b);return n.redSqr().redISub(i).cmpn(0)===0};Ot.prototype._endoWnafMulAdd=function(e,t,n){for(var a=this._endoWnafT1,i=this._endoWnafT2,o=0;o<e.length;o++){var s=this._endoSplit(t[o]),p=e[o],c=p._getBeta();s.k1.negative&&(s.k1.ineg(),p=p.neg(true)),s.k2.negative&&(s.k2.ineg(),c=c.neg(true)),a[o*2]=p,a[o*2+1]=c,i[o*2]=s.k1,i[o*2+1]=s.k2;}for(var l=this._wnafMulAdd(1,a,i,o*2,n),f=0;f<o*2;f++)a[f]=null,i[f]=null;return l};function ut(r,e,t,n){dn.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=true):(this.x=new re.default(e,16),this.y=new re.default(t,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=false);}Xs(ut,dn.BasePoint);Ot.prototype.point=function(e,t,n){return new ut(this,e,t,n)};Ot.prototype.pointFromJSON=function(e,t){return ut.fromJSON(this,e,t)};ut.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,a=function(i){return n.point(i.x.redMul(n.endo.beta),i.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(a)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(a)}};}return t}};ut.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};ut.fromJSON=function(e,t,n){typeof t=="string"&&(t=JSON.parse(t));var a=e.point(t[0],t[1],n);if(!t[2])return a;function i(s){return e.point(s[0],s[1],n)}var o=t[2];return a.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[a].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[a].concat(o.naf.points.map(i))}},a};ut.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};ut.prototype.isInfinity=function(){return this.inf};ut.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),a=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,a)};ut.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),a=e.redInvm(),i=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(a),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)};ut.prototype.getX=function(){return this.x.fromRed()};ut.prototype.getY=function(){return this.y.fromRed()};ut.prototype.mul=function(e){return e=new re.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ut.prototype.mulAdd=function(e,t,n){var a=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(a,i):this.curve._wnafMulAdd(1,a,i,2)};ut.prototype.jmulAdd=function(e,t,n){var a=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(a,i,true):this.curve._wnafMulAdd(1,a,i,2,true)};ut.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ut.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,a=function(i){return i.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(a)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(a)}};}return t};ut.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function dt(r,e,t,n){dn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new re.default(0)):(this.x=new re.default(e,16),this.y=new re.default(t,16),this.z=new re.default(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one;}Xs(dt,dn.BasePoint);Ot.prototype.jpoint=function(e,t,n){return new dt(this,e,t,n)};dt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),a=this.y.redMul(t).redMul(e);return this.curve.point(n,a)};dt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};dt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),a=this.x.redMul(t),i=e.x.redMul(n),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(n.redMul(this.z)),p=a.redSub(i),c=o.redSub(s);if(p.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=p.redSqr(),f=l.redMul(p),h=a.redMul(l),y=c.redSqr().redIAdd(f).redISub(h).redISub(h),x=c.redMul(h.redISub(y)).redISub(o.redMul(f)),w=this.z.redMul(e.z).redMul(p);return this.curve.jpoint(y,x,w)};dt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,a=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=n.redSub(a),p=i.redSub(o);if(s.cmpn(0)===0)return p.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),l=c.redMul(s),f=n.redMul(c),h=p.redSqr().redIAdd(l).redISub(f).redISub(f),y=p.redMul(f.redISub(h)).redISub(i.redMul(l)),x=this.z.redMul(s);return this.curve.jpoint(h,y,x)};dt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t<e;t++)n=n.dbl();return n}var a=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,p=this.z,c=p.redSqr().redSqr(),l=s.redAdd(s);for(t=0;t<e;t++){var f=o.redSqr(),h=l.redSqr(),y=h.redSqr(),x=f.redAdd(f).redIAdd(f).redIAdd(a.redMul(c)),w=o.redMul(h),_=x.redSqr().redISub(w.redAdd(w)),v=w.redISub(_),E=x.redMul(v);E=E.redIAdd(E).redISub(y);var B=l.redMul(p);t+1<e&&(c=c.redMul(y)),o=_,p=B,l=E;}return this.curve.jpoint(o,l.redMul(i),p)};dt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};dt.prototype._zeroDbl=function(){var e,t,n;if(this.zOne){var a=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(a).redISub(o);s=s.redIAdd(s);var p=a.redAdd(a).redIAdd(a),c=p.redSqr().redISub(s).redISub(s),l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),e=c,t=p.redMul(s.redISub(c)).redISub(l),n=this.y.redAdd(this.y);}else {var f=this.x.redSqr(),h=this.y.redSqr(),y=h.redSqr(),x=this.x.redAdd(h).redSqr().redISub(f).redISub(y);x=x.redIAdd(x);var w=f.redAdd(f).redIAdd(f),_=w.redSqr(),v=y.redIAdd(y);v=v.redIAdd(v),v=v.redIAdd(v),e=_.redISub(x).redISub(x),t=w.redMul(x.redISub(e)).redISub(v),n=this.y.redMul(this.z),n=n.redIAdd(n);}return this.curve.jpoint(e,t,n)};dt.prototype._threeDbl=function(){var e,t,n;if(this.zOne){var a=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(a).redISub(o);s=s.redIAdd(s);var p=a.redAdd(a).redIAdd(a).redIAdd(this.curve.a),c=p.redSqr().redISub(s).redISub(s);e=c;var l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),t=p.redMul(s.redISub(c)).redISub(l),n=this.y.redAdd(this.y);}else {var f=this.z.redSqr(),h=this.y.redSqr(),y=this.x.redMul(h),x=this.x.redSub(f).redMul(this.x.redAdd(f));x=x.redAdd(x).redIAdd(x);var w=y.redIAdd(y);w=w.redIAdd(w);var _=w.redAdd(w);e=x.redSqr().redISub(_),n=this.y.redAdd(this.z).redSqr().redISub(h).redISub(f);var v=h.redSqr();v=v.redIAdd(v),v=v.redIAdd(v),v=v.redIAdd(v),t=x.redMul(w.redISub(e)).redISub(v);}return this.curve.jpoint(e,t,n)};dt.prototype._dbl=function(){var e=this.curve.a,t=this.x,n=this.y,a=this.z,i=a.redSqr().redSqr(),o=t.redSqr(),s=n.redSqr(),p=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(i)),c=t.redAdd(t);c=c.redIAdd(c);var l=c.redMul(s),f=p.redSqr().redISub(l.redAdd(l)),h=l.redISub(f),y=s.redSqr();y=y.redIAdd(y),y=y.redIAdd(y),y=y.redIAdd(y);var x=p.redMul(h).redISub(y),w=n.redAdd(n).redMul(a);return this.curve.jpoint(f,x,w)};dt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),a=t.redSqr(),i=e.redAdd(e).redIAdd(e),o=i.redSqr(),s=this.x.redAdd(t).redSqr().redISub(e).redISub(a);s=s.redIAdd(s),s=s.redAdd(s).redIAdd(s),s=s.redISub(o);var p=s.redSqr(),c=a.redIAdd(a);c=c.redIAdd(c),c=c.redIAdd(c),c=c.redIAdd(c);var l=i.redIAdd(s).redSqr().redISub(o).redISub(p).redISub(c),f=t.redMul(l);f=f.redIAdd(f),f=f.redIAdd(f);var h=this.x.redMul(p).redISub(f);h=h.redIAdd(h),h=h.redIAdd(h);var y=this.y.redMul(l.redMul(c.redISub(l)).redISub(s.redMul(p)));y=y.redIAdd(y),y=y.redIAdd(y),y=y.redIAdd(y);var x=this.z.redAdd(s).redSqr().redISub(n).redISub(p);return this.curve.jpoint(h,y,x)};dt.prototype.mul=function(e,t){return e=new re.default(e,t),this.curve._wnafMul(this,e)};dt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return true;var t=this.z.redSqr(),n=e.z.redSqr();if(this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0)!==0)return false;var a=t.redMul(this.z),i=n.redMul(e.z);return this.y.redMul(i).redISub(e.y.redMul(a)).cmpn(0)===0};dt.prototype.eqXToP=function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(n)===0)return true;for(var a=e.clone(),i=this.curve.redN.redMul(t);;){if(a.iadd(this.curve.n),a.cmp(this.curve.p)>=0)return false;if(n.redIAdd(i),this.x.cmp(n)===0)return true}};dt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};dt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var vi=Kn(function(r,e){var t=e;t.base=dn,t.short=I2,t.mont=null,t.edwards=null;}),Ai=Kn(function(r,e){var t=e,n=_t.assert;function a(s){s.type==="short"?this.curve=new vi.short(s):s.type==="edwards"?this.curve=new vi.edwards(s):this.curve=new vi.mont(s),this.g=this.curve.g,this.n=this.curve.n,this.hash=s.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O");}t.PresetCurve=a;function i(s,p){Object.defineProperty(t,s,{configurable:true,enumerable:true,get:function(){var c=new a(p);return Object.defineProperty(t,s,{configurable:true,enumerable:true,value:c}),c}});}i("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:dr.default.sha256,gRed:false,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),i("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:dr.default.sha256,gRed:false,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),i("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:dr.default.sha256,gRed:false,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),i("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:dr.default.sha384,gRed:false,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),i("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:dr.default.sha512,gRed:false,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:dr.default.sha256,gRed:false,g:["9"]}),i("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:dr.default.sha256,gRed:false,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash();}catch{o=void 0;}i("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:dr.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:false,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]});});function $r(r){if(!(this instanceof $r))return new $r(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Kt.toArray(r.entropy,r.entropyEnc||"hex"),t=Kt.toArray(r.nonce,r.nonceEnc||"hex"),n=Kt.toArray(r.pers,r.persEnc||"hex");Ys(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,n);}var Ac=$r;$r.prototype._init=function(e,t,n){var a=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(a),this._reseed=1,this.reseedInterval=281474976710656;};$r.prototype._hmac=function(){return new dr.default.hmac(this.hash,this.K)};$r.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest());};$r.prototype.reseed=function(e,t,n,a){typeof t!="string"&&(a=n,n=t,t=null),e=Kt.toArray(e,t),n=Kt.toArray(n,a),Ys(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1;};$r.prototype.generate=function(e,t,n,a){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(a=n,n=t,t=null),n&&(n=Kt.toArray(n,a||"hex"),this._update(n));for(var i=[];i.length<e;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var o=i.slice(0,e);return this._update(n),this._reseed++,Kt.encode(o,t)};var Js=_t.assert;function mt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc);}var Zs=mt;mt.fromPublic=function(e,t,n){return t instanceof mt?t:new mt(e,{pub:t,pubEnc:n})};mt.fromPrivate=function(e,t,n){return t instanceof mt?t:new mt(e,{priv:t,privEnc:n})};mt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:false,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:true,reason:null}:{result:false,reason:"Public key * N != O"}:{result:false,reason:"Public key is not a point"}};mt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};mt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};mt.prototype._importPrivate=function(e,t){this.priv=new re.default(e,t||16),this.priv=this.priv.umod(this.ec.curve.n);};mt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Js(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Js(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t);};mt.prototype.derive=function(e){return e.validate()||Js(e.validate(),"public point not validated"),e.mul(this.priv).getX()};mt.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)};mt.prototype.verify=function(e,t,n){return this.ec.verify(e,t,this,void 0,n)};mt.prototype.inspect=function(){return "<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var P2=_t.assert;function Ei(r,e){if(r instanceof Ei)return r;this._importDER(r,e)||(P2(r.r&&r.s,"Signature without r or s"),this.r=new re.default(r.r,16),this.s=new re.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam);}var Ii=Ei;function R2(){this.place=0;}function Vs(r,e){var t=r[e.place++];if(!(t&128))return t;var n=t&15;if(n===0||n>4||r[e.place]===0)return false;for(var a=0,i=0,o=e.place;i<n;i++,o++)a<<=8,a|=r[o],a>>>=0;return a<=127?false:(e.place=o,a)}function bc(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}Ei.prototype._importDER=function(e,t){e=_t.toArray(e,t);var n=new R2;if(e[n.place++]!==48)return false;var a=Vs(e,n);if(a===false||a+n.place!==e.length||e[n.place++]!==2)return false;var i=Vs(e,n);if(i===false||(e[n.place]&128)!==0)return false;var o=e.slice(n.place,i+n.place);if(n.place+=i,e[n.place++]!==2)return false;var s=Vs(e,n);if(s===false||e.length!==s+n.place||(e[n.place]&128)!==0)return false;var p=e.slice(n.place,s+n.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return false;if(p[0]===0)if(p[1]&128)p=p.slice(1);else return false;return this.r=new re.default(o),this.s=new re.default(p),this.recoveryParam=null,true};function js(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e);}Ei.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),n[0]&128&&(n=[0].concat(n)),t=bc(t),n=bc(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var a=[2];js(a,t.length),a=a.concat(t),a.push(2),js(a,n.length);var i=a.concat(n),o=[48];return js(o,i.length),o=o.concat(i),_t.encode(o,e)};var _2=(function(){throw new Error("unsupported")}),cn=_t.assert;function Ft(r){if(!(this instanceof Ft))return new Ft(r);typeof r=="string"&&(cn(Object.prototype.hasOwnProperty.call(Ai,r),"Unknown curve "+r),r=Ai[r]),r instanceof Ai.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash;}var T2=Ft;Ft.prototype.keyPair=function(e){return new Zs(this,e)};Ft.prototype.keyFromPrivate=function(e,t){return Zs.fromPrivate(this,e,t)};Ft.prototype.keyFromPublic=function(e,t){return Zs.fromPublic(this,e,t)};Ft.prototype.genKeyPair=function(e){e||(e={});for(var t=new Ac({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||_2(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),a=this.n.sub(new re.default(2));;){var i=new re.default(t.generate(n));if(!(i.cmp(a)>0))return i.iaddn(1),this.keyFromPrivate(i)}};Ft.prototype._truncateToN=function(e,t,n){var a;if(re.default.isBN(e)||typeof e=="number")e=new re.default(e,16),a=e.byteLength();else if(typeof e=="object")a=e.length,e=new re.default(e,16);else {var i=e.toString();a=i.length+1>>>1,e=new re.default(i,16);}typeof n!="number"&&(n=a*8);var o=n-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Ft.prototype.sign=function(e,t,n,a){if(typeof n=="object"&&(a=n,n=null),a||(a={}),typeof e!="string"&&typeof e!="number"&&!re.default.isBN(e)){cn(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),cn(e.length>>>0===e.length);for(var i=0;i<e.length;i++)cn((e[i]&255)===e[i]);}t=this.keyFromPrivate(t,n),e=this._truncateToN(e,false,a.msgBitLength),cn(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),s=t.getPrivate().toArray("be",o),p=e.toArray("be",o);cn(new re.default(p).eq(e),"Can not sign message");for(var c=new Ac({hash:this.hash,entropy:s,nonce:p,pers:a.pers,persEnc:a.persEnc||"utf8"}),l=this.n.sub(new re.default(1)),f=0;;f++){var h=a.k?a.k(f):new re.default(c.generate(this.n.byteLength()));if(h=this._truncateToN(h,true),!(h.cmpn(1)<=0||h.cmp(l)>=0)){var y=this.g.mul(h);if(!y.isInfinity()){var x=y.getX(),w=x.umod(this.n);if(w.cmpn(0)!==0){var _=h.invm(this.n).mul(w.mul(t.getPrivate()).iadd(e));if(_=_.umod(this.n),_.cmpn(0)!==0){var v=(y.getY().isOdd()?1:0)|(x.cmp(w)!==0?2:0);return a.canonical&&_.cmp(this.nh)>0&&(_=this.n.sub(_),v^=1),new Ii({r:w,s:_,recoveryParam:v})}}}}}};Ft.prototype.verify=function(e,t,n,a,i){i||(i={}),e=this._truncateToN(e,false,i.msgBitLength),n=this.keyFromPublic(n,a),t=new Ii(t,"hex");var o=t.r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return false;var p=s.invm(this.n),c=p.mul(e).umod(this.n),l=p.mul(o).umod(this.n),f;return this.curve._maxwellTrick?(f=this.g.jmulAdd(c,n.getPublic(),l),f.isInfinity()?false:f.eqXToP(o)):(f=this.g.mulAdd(c,n.getPublic(),l),f.isInfinity()?false:f.getX().umod(this.n).cmp(o)===0)};Ft.prototype.recoverPubKey=function(r,e,t,n){cn((3&t)===t,"The recovery param is more than two bits"),e=new Ii(e,n);var a=this.n,i=new re.default(r),o=e.r,s=e.s,p=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),p):o=this.curve.pointFromX(o,p);var l=e.r.invm(a),f=a.sub(i).mul(l).umod(a),h=s.mul(l).umod(a);return this.g.mulAdd(f,o,h)};Ft.prototype.getKeyRecoveryParam=function(r,e,t,n){if(e=new Ii(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var a=0;a<4;a++){var i;try{i=this.recoverPubKey(r,e,a);}catch{continue}if(i.eq(t))return a}throw new Error("Unable to find valid recovery factor")};var k2=Kn(function(r,e){var t=e;t.version="6.6.1",t.utils=_t,t.rand=(function(){throw new Error("unsupported")}),t.curve=vi,t.curves=Ai,t.ec=T2,t.eddsa=null;}),wc=k2.ec;var Cc="signing-key/5.8.0";var ru=new U(Cc),eu=null;function fr(){return eu||(eu=new wc("secp256k1")),eu}var nu=class{constructor(e){se(this,"curve","secp256k1"),se(this,"privateKey",bytes.hexlify(e)),bytes.hexDataLength(this.privateKey)!==32&&ru.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=fr().keyFromPrivate(bytes.arrayify(this.privateKey));se(this,"publicKey","0x"+t.getPublic(false,"hex")),se(this,"compressedPublicKey","0x"+t.getPublic(true,"hex")),se(this,"_isSigningKey",true);}_addPoint(e){let t=fr().keyFromPublic(bytes.arrayify(this.publicKey)),n=fr().keyFromPublic(bytes.arrayify(e));return "0x"+t.pub.add(n.pub).encodeCompressed("hex")}signDigest(e){let t=fr().keyFromPrivate(bytes.arrayify(this.privateKey)),n=bytes.arrayify(e);n.length!==32&&ru.throwArgumentError("bad digest length","digest",e);let a=t.sign(n,{canonical:true});return bytes.splitSignature({recoveryParam:a.recoveryParam,r:bytes.hexZeroPad("0x"+a.r.toString(16),32),s:bytes.hexZeroPad("0x"+a.s.toString(16),32)})}computeSharedSecret(e){let t=fr().keyFromPrivate(bytes.arrayify(this.privateKey)),n=fr().keyFromPublic(bytes.arrayify(au(e)));return bytes.hexZeroPad("0x"+t.derive(n.getPublic()).toString(16),32)}static isSigningKey(e){return !!(e&&e._isSigningKey)}};function Ic(r,e){let t=bytes.splitSignature(e),n={r:bytes.arrayify(t.r),s:bytes.arrayify(t.s)};return "0x"+fr().recoverPubKey(bytes.arrayify(r),n,t.recoveryParam).encode("hex",false)}function au(r,e){let t=bytes.arrayify(r);if(t.length===32){let n=new nu(t);return n.publicKey}else {if(t.length===33)return "0x"+fr().keyFromPublic(t).getPublic(false,"hex");if(t.length===65)return bytes.hexlify(t)}return ru.throwArgumentError("invalid public or private key","key","[REDACTED]")}var Pc="transactions/5.8.0";var _r=new U(Pc),_c;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559";})(_c||(_c={}));function ou(r){return r==="0x"?null:Et(r)}function ht(r){return r==="0x"?Is:Z.from(r)}function D2(r){let e=au(r);return Et(bytes.hexDataSlice($e(bytes.hexDataSlice(e,1)),12))}function Sc(r,e){return D2(Ic(bytes.arrayify(r),e))}function Tt(r,e){let t=bytes.stripZeros(Z.from(r).toHexString());return t.length>32&&_r.throwArgumentError("invalid length for "+e,"transaction:"+e,r),t}function iu(r,e){return {address:Et(r),storageKeys:(e||[]).map((t,n)=>(bytes.hexDataLength(t)!==32&&_r.throwArgumentError("invalid access list storageKey",`accessList[${r}:${n}]`,t),t.toLowerCase()))}}function fn(r){if(Array.isArray(r))return r.map((t,n)=>Array.isArray(t)?(t.length>2&&_r.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${n}]`,t),iu(t[0],t[1])):iu(t.address,t.storageKeys));let e=Object.keys(r).map(t=>{let n=r[t].reduce((a,i)=>(a[i]=true,a),{});return iu(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function Dc(r){return fn(r).map(e=>[e.address,e.storageKeys])}function M2(r,e){if(r.gasPrice!=null){let n=Z.from(r.gasPrice),a=Z.from(r.maxFeePerGas||0);n.eq(a)||_r.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:n,maxFeePerGas:a});}let t=[Tt(r.chainId||0,"chainId"),Tt(r.nonce||0,"nonce"),Tt(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Tt(r.maxFeePerGas||0,"maxFeePerGas"),Tt(r.gasLimit||0,"gasLimit"),r.to!=null?Et(r.to):"0x",Tt(r.value||0,"value"),r.data||"0x",Dc(r.accessList||[])];if(e){let n=bytes.splitSignature(e);t.push(Tt(n.recoveryParam,"recoveryParam")),t.push(bytes.stripZeros(n.r)),t.push(bytes.stripZeros(n.s));}return bytes.hexConcat(["0x02",Mn(t)])}function F2(r,e){let t=[Tt(r.chainId||0,"chainId"),Tt(r.nonce||0,"nonce"),Tt(r.gasPrice||0,"gasPrice"),Tt(r.gasLimit||0,"gasLimit"),r.to!=null?Et(r.to):"0x",Tt(r.value||0,"value"),r.data||"0x",Dc(r.accessList||[])];if(e){let n=bytes.splitSignature(e);t.push(Tt(n.recoveryParam,"recoveryParam")),t.push(bytes.stripZeros(n.r)),t.push(bytes.stripZeros(n.s));}return bytes.hexConcat(["0x01",Mn(t)])}function Mc(r,e,t){try{let n=ht(e[0]).toNumber();if(n!==0&&n!==1)throw new Error("bad recid");r.v=n;}catch{_r.throwArgumentError("invalid v for transaction type: 1","v",e[0]);}r.r=bytes.hexZeroPad(e[1],32),r.s=bytes.hexZeroPad(e[2],32);try{let n=$e(t(r));r.from=Sc(n,{r:r.r,s:r.s,recoveryParam:r.v});}catch{}}function N2(r){let e=li(r.slice(1));e.length!==9&&e.length!==12&&_r.throwArgumentError("invalid component count for transaction type: 2","payload",bytes.hexlify(r));let t=ht(e[2]),n=ht(e[3]),a={type:2,chainId:ht(e[0]).toNumber(),nonce:ht(e[1]).toNumber(),maxPriorityFeePerGas:t,maxFeePerGas:n,gasPrice:null,gasLimit:ht(e[4]),to:ou(e[5]),value:ht(e[6]),data:e[7],accessList:fn(e[8])};return e.length===9||(a.hash=$e(r),Mc(a,e.slice(9),M2)),a}function O2(r){let e=li(r.slice(1));e.length!==8&&e.length!==11&&_r.throwArgumentError("invalid component count for transaction type: 1","payload",bytes.hexlify(r));let t={type:1,chainId:ht(e[0]).toNumber(),nonce:ht(e[1]).toNumber(),gasPrice:ht(e[2]),gasLimit:ht(e[3]),to:ou(e[4]),value:ht(e[5]),data:e[6],accessList:fn(e[7])};return e.length===8||(t.hash=$e(r),Mc(t,e.slice(8),F2)),t}function L2(r){let e=li(r);e.length!==9&&e.length!==6&&_r.throwArgumentError("invalid raw transaction","rawTransaction",r);let t={nonce:ht(e[0]).toNumber(),gasPrice:ht(e[1]),gasLimit:ht(e[2]),to:ou(e[3]),value:ht(e[4]),data:e[5],chainId:0};if(e.length===6)return t;try{t.v=Z.from(e[6]).toNumber();}catch{return t}if(t.r=bytes.hexZeroPad(e[7],32),t.s=bytes.hexZeroPad(e[8],32),Z.from(t.r).isZero()&&Z.from(t.s).isZero())t.chainId=t.v,t.v=0;else {t.chainId=Math.floor((t.v-35)/2),t.chainId<0&&(t.chainId=0);let n=t.v-27,a=e.slice(0,6);t.chainId!==0&&(a.push(bytes.hexlify(t.chainId)),a.push("0x"),a.push("0x"),n-=t.chainId*2+8);let i=$e(Mn(a));try{t.from=Sc(i,{r:bytes.hexlify(t.r),s:bytes.hexlify(t.s),recoveryParam:n});}catch{}t.hash=$e(r);}return t.type=null,t}function Fc(r){let e=bytes.arrayify(r);if(e[0]>127)return L2(e);switch(e[0]){case 1:return O2(e);case 2:return N2(e);}return _r.throwError(`unsupported transaction type: ${e[0]}`,U.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}var Aa=new U(cr),wa=class r{constructor(){this.formats=this.getDefaultFormats();}getDefaultFormats(){let e={},t=this.address.bind(this),n=this.bigNumber.bind(this),a=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),p=this.number.bind(this),c=this.type.bind(this),l=f=>this.data(f,true);return e.transaction={hash:o,type:c,accessList:r.allowNull(this.accessList.bind(this),null),blockHash:r.allowNull(o,null),blockNumber:r.allowNull(p,null),transactionIndex:r.allowNull(p,null),confirmations:r.allowNull(p,null),from:t,gasPrice:r.allowNull(n),maxPriorityFeePerGas:r.allowNull(n),maxFeePerGas:r.allowNull(n),gasLimit:n,to:r.allowNull(t,null),value:n,nonce:p,data:i,r:r.allowNull(this.uint256),s:r.allowNull(this.uint256),v:r.allowNull(p),creates:r.allowNull(t,null),raw:r.allowNull(i)},e.transactionRequest={from:r.allowNull(t),nonce:r.allowNull(p),gasLimit:r.allowNull(n),gasPrice:r.allowNull(n),maxPriorityFeePerGas:r.allowNull(n),maxFeePerGas:r.allowNull(n),to:r.allowNull(t),value:r.allowNull(n),data:r.allowNull(l),type:r.allowNull(p),accessList:r.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:p,blockNumber:p,transactionHash:o,address:t,topics:r.arrayOf(o),data:i,logIndex:p,blockHash:o},e.receipt={to:r.allowNull(this.address,null),from:r.allowNull(this.address,null),contractAddress:r.allowNull(t,null),transactionIndex:p,root:r.allowNull(s),gasUsed:n,logsBloom:r.allowNull(i),blockHash:o,transactionHash:o,logs:r.arrayOf(this.receiptLog.bind(this)),blockNumber:p,confirmations:r.allowNull(p,null),cumulativeGasUsed:n,effectiveGasPrice:r.allowNull(n),status:r.allowNull(p),type:c},e.block={hash:r.allowNull(o),parentHash:o,number:p,timestamp:p,nonce:r.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:n,gasUsed:n,miner:r.allowNull(t),extraData:i,transactions:r.allowNull(r.arrayOf(o)),baseFeePerGas:r.allowNull(n)},e.blockWithTransactions=ot(e.block),e.blockWithTransactions.transactions=r.allowNull(r.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:r.allowNull(a,void 0),toBlock:r.allowNull(a,void 0),blockHash:r.allowNull(o,void 0),address:r.allowNull(t,void 0),topics:r.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:r.allowNull(p),blockHash:r.allowNull(o),transactionIndex:p,removed:r.allowNull(this.boolean.bind(this)),address:t,data:r.allowFalsish(i,"0x"),topics:r.arrayOf(o),transactionHash:o,logIndex:p},e}accessList(e){return fn(e||[])}number(e){return e==="0x"?0:Z.from(e).toNumber()}type(e){return e==="0x"||e==null?0:Z.from(e).toNumber()}bigNumber(e){return Z.from(e)}boolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return true;if(e==="false")return false}throw new Error("invalid boolean - "+e)}hex(e,t){return typeof e=="string"&&(!t&&e.substring(0,2)!=="0x"&&(e="0x"+e),bytes.isHexString(e))?e.toLowerCase():Aa.throwArgumentError("invalid hash","value",e)}data(e,t){let n=this.hex(e,t);if(n.length%2!==0)throw new Error("invalid data; odd-length - "+e);return n}address(e){return Et(e)}callAddress(e){if(!bytes.isHexString(e,32))return null;let t=Et(bytes.hexDataSlice(e,12));return t===Es?null:t}contractAddress(e){return bl(e)}blockTag(e){if(e==null)return "latest";if(e==="earliest")return "0x0";switch(e){case "earliest":return "0x0";case "latest":case "pending":case "safe":case "finalized":return e}if(typeof e=="number"||bytes.isHexString(e))return bytes.hexValue(e);throw new Error("invalid blockTag")}hash(e,t){let n=this.hex(e,t);return bytes.hexDataLength(n)!==32?Aa.throwArgumentError("invalid hash","value",e):n}difficulty(e){if(e==null)return null;let t=Z.from(e);try{return t.toNumber()}catch{}return null}uint256(e){if(!bytes.isHexString(e))throw new Error("invalid uint256");return bytes.hexZeroPad(e,32)}_block(e,t){e.author!=null&&e.miner==null&&(e.miner=e.author);let n=e._difficulty!=null?e._difficulty:e.difficulty,a=r.check(t,e);return a._difficulty=n==null?null:Z.from(n),a}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return r.check(this.formats.transactionRequest,e)}transactionResponse(e){e.gas!=null&&e.gasLimit==null&&(e.gasLimit=e.gas),e.to&&Z.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),e.input!=null&&e.data==null&&(e.data=e.input),e.to==null&&e.creates==null&&(e.creates=this.contractAddress(e)),(e.type===1||e.type===2)&&e.accessList==null&&(e.accessList=[]);let t=r.check(this.formats.transaction,e);if(e.chainId!=null){let n=e.chainId;bytes.isHexString(n)&&(n=Z.from(n).toNumber()),t.chainId=n;}else {let n=e.networkId;n==null&&t.v==null&&(n=e.chainId),bytes.isHexString(n)&&(n=Z.from(n).toNumber()),typeof n!="number"&&t.v!=null&&(n=(t.v-35)/2,n<0&&(n=0),n=parseInt(n)),typeof n!="number"&&(n=0),t.chainId=n;}return t.blockHash&&t.blockHash.replace(/0/g,"")==="x"&&(t.blockHash=null),t}transaction(e){return Fc(e)}receiptLog(e){return r.check(this.formats.receiptLog,e)}receipt(e){let t=r.check(this.formats.receipt,e);if(t.root!=null)if(t.root.length<=4){let n=Z.from(t.root).toNumber();n===0||n===1?(t.status!=null&&t.status!==n&&Aa.throwArgumentError("alt-root-status/status mismatch","value",{root:t.root,status:t.status}),t.status=n,delete t.root):Aa.throwArgumentError("invalid alt-root-status","value.root",t.root);}else t.root.length!==66&&Aa.throwArgumentError("invalid root hash","value.root",t.root);return t.status!=null&&(t.byzantium=true),t}topics(e){return Array.isArray(e)?e.map(t=>this.topics(t)):e!=null?this.hash(e,true):null}filter(e){return r.check(this.formats.filter,e)}filterLog(e){return r.check(this.formats.filterLog,e)}static check(e,t){let n={};for(let a in e)try{let i=e[a](t[a]);i!==void 0&&(n[a]=i);}catch(i){throw i.checkKey=a,i.checkValue=t[a],i}return n}static allowNull(e,t){return(function(n){return n==null?t:e(n)})}static allowFalsish(e,t){return(function(n){return n?e(n):t})}static arrayOf(e){return(function(t){if(!Array.isArray(t))throw new Error("not an array");let n=[];return t.forEach(function(a){n.push(e(a));}),n})}};var ne=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},le=new U(cr),W2=10;function Nc(r){return r==null?"null":(bytes.hexDataLength(r)!==32&&le.throwArgumentError("invalid topic","topic",r),r.toLowerCase())}function Oc(r){for(r=r.slice();r.length>0&&r[r.length-1]==null;)r.pop();return r.map(e=>{if(Array.isArray(e)){let t={};e.forEach(a=>{t[Nc(a)]=true;});let n=Object.keys(t);return n.sort(),n.join("|")}else return Nc(e)}).join("&")}function K2(r){return r===""?[]:r.split(/&/g).map(e=>{if(e==="")return [];let t=e.split("|").map(n=>n==="null"?null:n);return t.length===1?t[0]:t})}function Vn(r){if(typeof r=="string"){if(r=r.toLowerCase(),bytes.hexDataLength(r)===32)return "tx:"+r;if(r.indexOf(":")===-1)return r}else {if(Array.isArray(r))return "filter:*:"+Oc(r);if(ei.isForkEvent(r))throw le.warn("not implemented"),new Error("not implemented");if(r&&typeof r=="object")return "filter:"+(r.address||"*")+":"+Oc(r.topics||[])}throw new Error("invalid event - "+r)}function Ca(){return new Date().getTime()}function Lc(r){return new Promise(e=>{setTimeout(e,r);})}var Q2=["block","network","pending","poll"],cu=class{constructor(e,t,n){se(this,"tag",e),se(this,"listener",t),se(this,"once",n),this._lastBlockNumber=-2,this._inflight=false;}get event(){switch(this.type){case "tx":return this.hash;case "filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){let e=this.tag.split(":");return e[0]!=="tx"?null:e[1]}get filter(){let e=this.tag.split(":");if(e[0]!=="filter")return null;let t=e[1],n=K2(e[2]),a={};return n.length>0&&(a.topics=n),t&&t!=="*"&&(a.address=t),a}pollable(){return this.tag.indexOf(":")>=0||Q2.indexOf(this.tag)>=0}},V2={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function su(r){return bytes.hexZeroPad(Z.from(r).toHexString(),32)}function Uc(r){return ii.encode(bytes.concat([r,bytes.hexDataSlice(yi(yi(r)),0,4)]))}var zc=new RegExp("^(ipfs)://(.*)$","i"),qc=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),zc,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Ti(r,e){try{return Yr(Ia(r,e))}catch{}return null}function Ia(r,e){if(r==="0x")return null;let t=Z.from(bytes.hexDataSlice(r,e,e+32)).toNumber(),n=Z.from(bytes.hexDataSlice(r,t,t+32)).toNumber();return bytes.hexDataSlice(r,t+32,t+32+n)}function uu(r){return r.match(/^ipfs:\/\/ipfs\//i)?r=r.substring(12):r.match(/^ipfs:\/\//i)?r=r.substring(7):le.throwArgumentError("unsupported IPFS format","link",r),`https://gateway.ipfs.io/ipfs/${r}`}function Gc(r){let e=bytes.arrayify(r);if(e.length>32)throw new Error("internal; should not happen");let t=new Uint8Array(32);return t.set(e,32-e.length),t}function j2(r){if(r.length%32===0)return r;let e=new Uint8Array(Math.ceil(r.length/32)*32);return e.set(r),e}function Hc(r){let e=[],t=0;for(let n=0;n<r.length;n++)e.push(null),t+=32;for(let n=0;n<r.length;n++){let a=bytes.arrayify(r[n]);e[n]=Gc(t),e.push(Gc(a.length)),e.push(j2(a)),t+=32+Math.ceil(a.length/32)*32;}return bytes.hexConcat(e)}var Pa=class{constructor(e,t,n,a){se(this,"provider",e),se(this,"name",n),se(this,"address",e.formatter.address(t)),se(this,"_resolvedAddress",a);}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(e=>Z.from(e).eq(1)).catch(e=>{if(e.code===U.errors.CALL_EXCEPTION)return false;throw this._supportsEip2544=null,e})),this._supportsEip2544}_fetch(e,t){return ne(this,void 0,void 0,function*(){let n={to:this.address,ccipReadEnabled:true,data:bytes.hexConcat([e,Dn(this.name),t||"0x"])},a=false;(yield this.supportsWildcard())&&(a=true,n.data=bytes.hexConcat(["0x9061b923",Hc([Ts(this.name),n.data])]));try{let i=yield this.provider.call(n);return bytes.arrayify(i).length%32===4&&le.throwError("resolver threw error",U.errors.CALL_EXCEPTION,{transaction:n,data:i}),a&&(i=Ia(i,0)),i}catch(i){if(i.code===U.errors.CALL_EXCEPTION)return null;throw i}})}_fetchBytes(e,t){return ne(this,void 0,void 0,function*(){let n=yield this._fetch(e,t);return n!=null?Ia(n,0):null})}_getAddress(e,t){let n=V2[String(e)];if(n==null&&le.throwError(`unsupported coin type: ${e}`,U.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),n.ilk==="eth")return this.provider.formatter.address(t);let a=bytes.arrayify(t);if(n.p2pkh!=null){let i=t.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(i){let o=parseInt(i[1],16);if(i[2].length===o*2&&o>=1&&o<=75)return Uc(bytes.concat([[n.p2pkh],"0x"+i[2]]))}}if(n.p2sh!=null){let i=t.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(i){let o=parseInt(i[1],16);if(i[2].length===o*2&&o>=1&&o<=75)return Uc(bytes.concat([[n.p2sh],"0x"+i[2]]))}}if(n.prefix!=null){let i=a[1],o=a[0];if(o===0?i!==20&&i!==32&&(o=-1):o=-1,o>=0&&a.length===2+i&&i>=1&&i<=75){let s=lu.default.toWords(a.slice(2));return s.unshift(o),lu.default.encode(n.prefix,s)}}return null}getAddress(e){return ne(this,void 0,void 0,function*(){if(e==null&&(e=60),e===60)try{let a=yield this._fetch("0x3b3b57de");return a==="0x"||a===Ps?null:this.provider.formatter.callAddress(a)}catch(a){if(a.code===U.errors.CALL_EXCEPTION)return null;throw a}let t=yield this._fetchBytes("0xf1cb7e06",su(e));if(t==null||t==="0x")return null;let n=this._getAddress(e,t);return n==null&&le.throwError("invalid or unsupported coin data",U.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:t}),n})}getAvatar(){return ne(this,void 0,void 0,function*(){let e=[{type:"name",content:this.name}];try{let t=yield this.getText("avatar");if(t==null)return null;for(let n=0;n<qc.length;n++){let a=t.match(qc[n]);if(a==null)continue;let i=a[1].toLowerCase();switch(i){case "https":return e.push({type:"url",content:t}),{linkage:e,url:t};case "data":return e.push({type:"data",content:t}),{linkage:e,url:t};case "ipfs":return e.push({type:"ipfs",content:t}),{linkage:e,url:uu(t)};case "erc721":case "erc1155":{let o=i==="erc721"?"0xc87b56dd":"0x0e89341c";e.push({type:i,content:t});let s=this._resolvedAddress||(yield this.getAddress()),p=(a[2]||"").split("/");if(p.length!==2)return null;let c=yield this.provider.formatter.address(p[0]),l=bytes.hexZeroPad(Z.from(p[1]).toHexString(),32);if(i==="erc721"){let w=this.provider.formatter.callAddress(yield this.provider.call({to:c,data:bytes.hexConcat(["0x6352211e",l])}));if(s!==w)return null;e.push({type:"owner",content:w});}else if(i==="erc1155"){let w=Z.from(yield this.provider.call({to:c,data:bytes.hexConcat(["0x00fdd58e",bytes.hexZeroPad(s,32),l])}));if(w.isZero())return null;e.push({type:"balance",content:w.toString()});}let f={to:this.provider.formatter.address(p[0]),data:bytes.hexConcat([o,l])},h=Ti(yield this.provider.call(f),0);if(h==null)return null;e.push({type:"metadata-url-base",content:h}),i==="erc1155"&&(h=h.replace("{id}",l.substring(2)),e.push({type:"metadata-url-expanded",content:h})),h.match(/^ipfs:/i)&&(h=uu(h)),e.push({type:"metadata-url",content:h});let y=yield ga(h);if(!y)return null;e.push({type:"metadata",content:JSON.stringify(y)});let x=y.image;if(typeof x!="string")return null;if(!x.match(/^(https:\/\/|data:)/i)){if(x.match(zc)==null)return null;e.push({type:"url-ipfs",content:x}),x=uu(x);}return e.push({type:"url",content:x}),{linkage:e,url:x}}}}}catch{}return null})}getContentHash(){return ne(this,void 0,void 0,function*(){let e=yield this._fetchBytes("0xbc1c58d1");if(e==null||e==="0x")return null;let t=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){let o=parseInt(t[3],16);if(t[4].length===o*2)return "ipfs://"+ii.encode("0x"+t[1])}let n=e.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(n){let o=parseInt(n[3],16);if(n[4].length===o*2)return "ipns://"+ii.encode("0x"+n[1])}let a=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(a&&a[1].length===64)return "bzz://"+a[1];let i=e.match(/^0x90b2c605([0-9a-f]*)$/);if(i&&i[1].length===68){let o={"=":"","+":"-","/":"_"};return "sia://"+fa("0x"+i[1]).replace(/[=+\/]/g,p=>o[p])}return le.throwError("invalid or unsupported content hash data",U.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})})}getText(e){return ne(this,void 0,void 0,function*(){let t=bt(e);t=bytes.concat([su(64),su(t.length),t]),t.length%32!==0&&(t=bytes.concat([t,bytes.hexZeroPad("0x",32-e.length%32)]));let n=yield this._fetchBytes("0x59d1d43c",bytes.hexlify(t));return n==null||n==="0x"?null:Yr(n)})}},pu=null,J2=1,hn=class extends ti{constructor(e){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=false,this.formatter=new.target.getFormatter(),se(this,"anyNetwork",e==="any"),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch(t=>{}),this._ready().catch(t=>{});else {let t=Jr(new.target,"getNetwork")(e);t?(se(this,"_network",t),this.emit("network",t,null)):le.throwArgumentError("invalid network","network",e);}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0;}_ready(){return ne(this,void 0,void 0,function*(){if(this._network==null){let e=null;if(this._networkPromise)try{e=yield this._networkPromise;}catch{}e==null&&(e=yield this.detectNetwork()),e||le.throwError("no network detected",U.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=e:se(this,"_network",e),this.emit("network",e,null));}return this._network})}get ready(){return ln(()=>this._ready().then(e=>e,e=>{if(!(e.code===U.errors.NETWORK_ERROR&&e.event==="noNetwork"))throw e}))}static getFormatter(){return pu==null&&(pu=new wa),pu}static getNetwork(e){return Mp(e??"homestead")}ccipReadFetch(e,t,n){return ne(this,void 0,void 0,function*(){if(this.disableCcipRead||n.length===0)return null;let a=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let s=0;s<n.length;s++){let p=n[s],c=p.replace("{sender}",a).replace("{data}",i),l=p.indexOf("{data}")>=0?null:JSON.stringify({data:i,sender:a}),f=yield ga({url:c,errorPassThrough:true},l,(y,x)=>(y.status=x.statusCode,y));if(f.data)return f.data;let h=f.message||"unknown error";if(f.status>=400&&f.status<500)return le.throwError(`response not found during CCIP fetch: ${h}`,U.errors.SERVER_ERROR,{url:p,errorMessage:h});o.push(h);}return le.throwError(`error encountered during CCIP fetch: ${o.map(s=>JSON.stringify(s)).join(", ")}`,U.errors.SERVER_ERROR,{urls:n,errorMessages:o})})}_getInternalBlockNumber(e){return ne(this,void 0,void 0,function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){let a=this._internalBlockNumber;try{let i=yield a;if(Ca()-i.respTime<=e)return i.blockNumber;break}catch{if(this._internalBlockNumber===a)break}}let t=Ca(),n=et({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(a=>null,a=>a)}).then(({blockNumber:a,networkError:i})=>{if(i)throw this._internalBlockNumber===n&&(this._internalBlockNumber=null),i;let o=Ca();return a=Z.from(a).toNumber(),a<this._maxInternalBlockNumber&&(a=this._maxInternalBlockNumber),this._maxInternalBlockNumber=a,this._setFastBlockNumber(a),{blockNumber:a,reqTime:t,respTime:o}});return this._internalBlockNumber=n,n.catch(a=>{this._internalBlockNumber===n&&(this._internalBlockNumber=null);}),(yield n).blockNumber})}poll(){return ne(this,void 0,void 0,function*(){let e=J2++,t=[],n=null;try{n=yield this._getInternalBlockNumber(100+this.pollingInterval/2);}catch(a){this.emit("error",a);return}if(this._setFastBlockNumber(n),this.emit("poll",e,n),n===this._lastBlockNumber){this.emit("didPoll",e);return}if(this._emitted.block===-2&&(this._emitted.block=n-1),Math.abs(this._emitted.block-n)>1e3)le.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${n})`),this.emit("error",le.makeError("network block skew detected",U.errors.NETWORK_ERROR,{blockNumber:n,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",n);else for(let a=this._emitted.block+1;a<=n;a++)this.emit("block",a);this._emitted.block!==n&&(this._emitted.block=n,Object.keys(this._emitted).forEach(a=>{if(a==="block")return;let i=this._emitted[a];i!=="pending"&&n-i>12&&delete this._emitted[a];})),this._lastBlockNumber===-2&&(this._lastBlockNumber=n-1),this._events.forEach(a=>{switch(a.type){case "tx":{let i=a.hash,o=this.getTransactionReceipt(i).then(s=>(!s||s.blockNumber==null||(this._emitted["t:"+i]=s.blockNumber,this.emit(i,s)),null)).catch(s=>{this.emit("error",s);});t.push(o);break}case "filter":{if(!a._inflight){a._inflight=true,a._lastBlockNumber===-2&&(a._lastBlockNumber=n-1);let i=a.filter;i.fromBlock=a._lastBlockNumber+1,i.toBlock=n;let o=i.toBlock-this._maxFilterBlockRange;o>i.fromBlock&&(i.fromBlock=o),i.fromBlock<0&&(i.fromBlock=0);let s=this.getLogs(i).then(p=>{a._inflight=false,p.length!==0&&p.forEach(c=>{c.blockNumber>a._lastBlockNumber&&(a._lastBlockNumber=c.blockNumber),this._emitted["b:"+c.blockHash]=c.blockNumber,this._emitted["t:"+c.transactionHash]=c.blockNumber,this.emit(i,c);});}).catch(p=>{this.emit("error",p),a._inflight=false;});t.push(s);}break}}}),this._lastBlockNumber=n,Promise.all(t).then(()=>{this.emit("didPoll",e);}).catch(a=>{this.emit("error",a);});})}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll();}get network(){return this._network}detectNetwork(){return ne(this,void 0,void 0,function*(){return le.throwError("provider does not support network detection",U.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return ne(this,void 0,void 0,function*(){let e=yield this._ready(),t=yield this.detectNetwork();if(e.chainId!==t.chainId){if(this.anyNetwork)return this._network=t,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",t,e),yield Lc(0),this._network;let n=le.makeError("underlying network changed",U.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:t});throw this.emit("error",n),n}return e})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(e=>{this._setFastBlockNumber(e);},e=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(e){e&&!this._poller?(this._poller=setInterval(()=>{this.poll();},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null;},this.pollingInterval);},0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null);}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if(typeof e!="number"||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll();},this._pollingInterval));}_getFastBlockNumber(){let e=Ca();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(e){this._fastBlockNumber!=null&&e<this._fastBlockNumber||(this._fastQueryDate=Ca(),(this._fastBlockNumber==null||e>this._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)));}waitForTransaction(e,t,n){return ne(this,void 0,void 0,function*(){return this._waitForTransaction(e,t??1,n||0,null)})}_waitForTransaction(e,t,n,a){return ne(this,void 0,void 0,function*(){let i=yield this.getTransactionReceipt(e);return (i?i.confirmations:0)>=t?i:new Promise((o,s)=>{let p=[],c=false,l=function(){return c?true:(c=true,p.forEach(h=>{h();}),false)},f=h=>{h.confirmations<t||l()||o(h);};if(this.on(e,f),p.push(()=>{this.removeListener(e,f);}),a){let h=a.startBlock,y=null,x=w=>ne(this,void 0,void 0,function*(){c||(yield Lc(1e3),this.getTransactionCount(a.from).then(_=>ne(this,void 0,void 0,function*(){if(!c){if(_<=a.nonce)h=w;else {{let v=yield this.getTransaction(e);if(v&&v.blockNumber!=null)return}for(y==null&&(y=h-3,y<a.startBlock&&(y=a.startBlock));y<=w;){if(c)return;let v=yield this.getBlockWithTransactions(y);for(let E=0;E<v.transactions.length;E++){let B=v.transactions[E];if(B.hash===e)return;if(B.from===a.from&&B.nonce===a.nonce){if(c)return;let S=yield this.waitForTransaction(B.hash,t);if(l())return;let D="replaced";B.data===a.data&&B.to===a.to&&B.value.eq(a.value)?D="repriced":B.data==="0x"&&B.from===B.to&&B.value.isZero()&&(D="cancelled"),s(le.makeError("transaction was replaced",U.errors.TRANSACTION_REPLACED,{cancelled:D==="replaced"||D==="cancelled",reason:D,replacement:this._wrapTransaction(B),hash:e,receipt:S}));return}}y++;}}c||this.once("block",x);}}),_=>{c||this.once("block",x);}));});if(c)return;this.once("block",x),p.push(()=>{this.removeListener("block",x);});}if(typeof n=="number"&&n>0){let h=setTimeout(()=>{l()||s(le.makeError("timeout exceeded",U.errors.TIMEOUT,{timeout:n}));},n);h.unref&&h.unref(),p.push(()=>{clearTimeout(h);});}})})}getBlockNumber(){return ne(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let e=yield this.perform("getGasPrice",{});try{return Z.from(e)}catch(t){return le.throwError("bad result from backend",U.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:t})}})}getBalance(e,t){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let n=yield et({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),a=yield this.perform("getBalance",n);try{return Z.from(a)}catch(i){return le.throwError("bad result from backend",U.errors.SERVER_ERROR,{method:"getBalance",params:n,result:a,error:i})}})}getTransactionCount(e,t){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let n=yield et({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),a=yield this.perform("getTransactionCount",n);try{return Z.from(a).toNumber()}catch(i){return le.throwError("bad result from backend",U.errors.SERVER_ERROR,{method:"getTransactionCount",params:n,result:a,error:i})}})}getCode(e,t){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let n=yield et({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),a=yield this.perform("getCode",n);try{return bytes.hexlify(a)}catch(i){return le.throwError("bad result from backend",U.errors.SERVER_ERROR,{method:"getCode",params:n,result:a,error:i})}})}getStorageAt(e,t,n){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let a=yield et({address:this._getAddress(e),blockTag:this._getBlockTag(n),position:Promise.resolve(t).then(o=>bytes.hexValue(o))}),i=yield this.perform("getStorageAt",a);try{return bytes.hexlify(i)}catch(o){return le.throwError("bad result from backend",U.errors.SERVER_ERROR,{method:"getStorageAt",params:a,result:i,error:o})}})}_wrapTransaction(e,t,n){if(t!=null&&bytes.hexDataLength(t)!==32)throw new Error("invalid response - sendTransaction");let a=e;return t!=null&&e.hash!==t&&le.throwError("Transaction hash mismatch from Provider.sendTransaction.",U.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:t}),a.wait=(i,o)=>ne(this,void 0,void 0,function*(){i==null&&(i=1),o==null&&(o=0);let s;i!==0&&n!=null&&(s={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:n});let p=yield this._waitForTransaction(e.hash,i,o,s);return p==null&&i===0?null:(this._emitted["t:"+e.hash]=p.blockNumber,p.status===0&&le.throwError("transaction failed",U.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:p}),p)}),a}sendTransaction(e){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let t=yield Promise.resolve(e).then(i=>bytes.hexlify(i)),n=this.formatter.transaction(e);n.confirmations==null&&(n.confirmations=0);let a=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{let i=yield this.perform("sendTransaction",{signedTransaction:t});return this._wrapTransaction(n,i,a)}catch(i){throw i.transaction=n,i.transactionHash=n.hash,i}})}_getTransactionRequest(e){return ne(this,void 0,void 0,function*(){let t=yield e,n={};return ["from","to"].forEach(a=>{t[a]!=null&&(n[a]=Promise.resolve(t[a]).then(i=>i?this._getAddress(i):null));}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(a=>{t[a]!=null&&(n[a]=Promise.resolve(t[a]).then(i=>i?Z.from(i):null));}),["type"].forEach(a=>{t[a]!=null&&(n[a]=Promise.resolve(t[a]).then(i=>i??null));}),t.accessList&&(n.accessList=this.formatter.accessList(t.accessList)),["data"].forEach(a=>{t[a]!=null&&(n[a]=Promise.resolve(t[a]).then(i=>i?bytes.hexlify(i):null));}),this.formatter.transactionRequest(yield et(n))})}_getFilter(e){return ne(this,void 0,void 0,function*(){e=yield e;let t={};return e.address!=null&&(t.address=this._getAddress(e.address)),["blockHash","topics"].forEach(n=>{e[n]!=null&&(t[n]=e[n]);}),["fromBlock","toBlock"].forEach(n=>{e[n]!=null&&(t[n]=this._getBlockTag(e[n]));}),this.formatter.filter(yield et(t))})}_call(e,t,n){return ne(this,void 0,void 0,function*(){n>=W2&&le.throwError("CCIP read exceeded maximum redirections",U.errors.SERVER_ERROR,{redirects:n,transaction:e});let a=e.to,i=yield this.perform("call",{transaction:e,blockTag:t});if(n>=0&&t==="latest"&&a!=null&&i.substring(0,10)==="0x556f1830"&&bytes.hexDataLength(i)%32===4)try{let o=bytes.hexDataSlice(i,4),s=bytes.hexDataSlice(o,0,32);Z.from(s).eq(a)||le.throwError("CCIP Read sender did not match",U.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:i});let p=[],c=Z.from(bytes.hexDataSlice(o,32,64)).toNumber(),l=Z.from(bytes.hexDataSlice(o,c,c+32)).toNumber(),f=bytes.hexDataSlice(o,c+32);for(let v=0;v<l;v++){let E=Ti(f,v*32);E==null&&le.throwError("CCIP Read contained corrupt URL string",U.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:i}),p.push(E);}let h=Ia(o,64);Z.from(bytes.hexDataSlice(o,100,128)).isZero()||le.throwError("CCIP Read callback selector included junk",U.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:i});let y=bytes.hexDataSlice(o,96,100),x=Ia(o,128),w=yield this.ccipReadFetch(e,h,p);w==null&&le.throwError("CCIP Read disabled or provided no URLs",U.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:i});let _={to:a,data:bytes.hexConcat([y,Hc([w,x])])};return this._call(_,t,n+1)}catch(o){if(o.code===U.errors.SERVER_ERROR)throw o}try{return bytes.hexlify(i)}catch(o){return le.throwError("bad result from backend",U.errors.SERVER_ERROR,{method:"call",params:{transaction:e,blockTag:t},result:i,error:o})}})}call(e,t){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let n=yield et({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(t),ccipReadEnabled:Promise.resolve(e.ccipReadEnabled)});return this._call(n.transaction,n.blockTag,n.ccipReadEnabled?0:-1)})}estimateGas(e){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let t=yield et({transaction:this._getTransactionRequest(e)}),n=yield this.perform("estimateGas",t);try{return Z.from(n)}catch(a){return le.throwError("bad result from backend",U.errors.SERVER_ERROR,{method:"estimateGas",params:t,result:n,error:a})}})}_getAddress(e){return ne(this,void 0,void 0,function*(){e=yield e,typeof e!="string"&&le.throwArgumentError("invalid address or ENS name","name",e);let t=yield this.resolveName(e);return t==null&&le.throwError("ENS name not configured",U.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(e)})`}),t})}_getBlock(e,t){return ne(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let n=-128,a={includeTransactions:!!t};if(bytes.isHexString(e,32))a.blockHash=e;else try{a.blockTag=yield this._getBlockTag(e),bytes.isHexString(a.blockTag)&&(n=parseInt(a.blockTag.substring(2),16));}catch{le.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e);}return ln(()=>ne(this,void 0,void 0,function*(){let i=yield this.perform("getBlock",a);if(i==null)return a.blockHash!=null&&this._emitted["b:"+a.blockHash]==null||a.blockTag!=null&&n>this._emitted.block?null:void 0;if(t){let o=null;for(let p=0;p<i.transactions.length;p++){let c=i.transactions[p];if(c.blockNumber==null)c.confirmations=0;else if(c.confirmations==null){o==null&&(o=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let l=o-c.blockNumber+1;l<=0&&(l=1),c.confirmations=l;}}let s=this.formatter.blockWithTransactions(i);return s.transactions=s.transactions.map(p=>this._wrapTransaction(p)),s}return this.formatter.block(i)}),{oncePoll:this})})}getBlock(e){return this._getBlock(e,false)}getBlockWithTransactions(e){return this._getBlock(e,true)}getTransaction(e){return ne(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let t={transactionHash:this.formatter.hash(e,true)};return ln(()=>ne(this,void 0,void 0,function*(){let n=yield this.perform("getTransaction",t);if(n==null)return this._emitted["t:"+e]==null?null:void 0;let a=this.formatter.transactionResponse(n);if(a.blockNumber==null)a.confirmations=0;else if(a.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-a.blockNumber+1;o<=0&&(o=1),a.confirmations=o;}return this._wrapTransaction(a)}),{oncePoll:this})})}getTransactionReceipt(e){return ne(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let t={transactionHash:this.formatter.hash(e,true)};return ln(()=>ne(this,void 0,void 0,function*(){let n=yield this.perform("getTransactionReceipt",t);if(n==null)return this._emitted["t:"+e]==null?null:void 0;if(n.blockHash==null)return;let a=this.formatter.receipt(n);if(a.blockNumber==null)a.confirmations=0;else if(a.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-a.blockNumber+1;o<=0&&(o=1),a.confirmations=o;}return a}),{oncePoll:this})})}getLogs(e){return ne(this,void 0,void 0,function*(){yield this.getNetwork();let t=yield et({filter:this._getFilter(e)}),n=yield this.perform("getLogs",t);return n.forEach(a=>{a.removed==null&&(a.removed=false);}),wa.arrayOf(this.formatter.filterLog.bind(this.formatter))(n)})}getEtherPrice(){return ne(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(e){return ne(this,void 0,void 0,function*(){if(e=yield e,typeof e=="number"&&e<0){e%1&&le.throwArgumentError("invalid BlockTag","blockTag",e);let t=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return t+=e,t<0&&(t=0),this.formatter.blockTag(t)}return this.formatter.blockTag(e)})}getResolver(e){return ne(this,void 0,void 0,function*(){let t=e;for(;;){if(t===""||t==="."||e!=="eth"&&t==="eth")return null;let n=yield this._getResolver(t,"getResolver");if(n!=null){let a=new Pa(this,n,e);return t!==e&&!(yield a.supportsWildcard())?null:a}t=t.split(".").slice(1).join(".");}})}_getResolver(e,t){return ne(this,void 0,void 0,function*(){t==null&&(t="ENS");let n=yield this.getNetwork();n.ensAddress||le.throwError("network does not support ENS",U.errors.UNSUPPORTED_OPERATION,{operation:t,network:n.name});try{let a=yield this.call({to:n.ensAddress,data:"0x0178b8bf"+Dn(e).substring(2)});return this.formatter.callAddress(a)}catch{}return null})}resolveName(e){return ne(this,void 0,void 0,function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(n){if(bytes.isHexString(e))throw n}typeof e!="string"&&le.throwArgumentError("invalid ENS name","name",e);let t=yield this.getResolver(e);return t?yield t.getAddress():null})}lookupAddress(e){return ne(this,void 0,void 0,function*(){e=yield e,e=this.formatter.address(e);let t=e.substring(2).toLowerCase()+".addr.reverse",n=yield this._getResolver(t,"lookupAddress");if(n==null)return null;let a=Ti(yield this.call({to:n,data:"0x691f3431"+Dn(t).substring(2)}),0);return (yield this.resolveName(a))!=e?null:a})}getAvatar(e){return ne(this,void 0,void 0,function*(){let t=null;if(bytes.isHexString(e)){let i=this.formatter.address(e).substring(2).toLowerCase()+".addr.reverse",o=yield this._getResolver(i,"getAvatar");if(!o)return null;t=new Pa(this,o,i);try{let s=yield t.getAvatar();if(s)return s.url}catch(s){if(s.code!==U.errors.CALL_EXCEPTION)throw s}try{let s=Ti(yield this.call({to:o,data:"0x691f3431"+Dn(i).substring(2)}),0);t=yield this.getResolver(s);}catch(s){if(s.code!==U.errors.CALL_EXCEPTION)throw s;return null}}else if(t=yield this.getResolver(e),!t)return null;let n=yield t.getAvatar();return n==null?null:n.url})}perform(e,t){return le.throwError(e+" not implemented",U.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter(t=>t.pollable()).length>0;}_stopEvent(e){this.polling=this._events.filter(t=>t.pollable()).length>0;}_addEventListener(e,t,n){let a=new cu(Vn(e),t,n);return this._events.push(a),this._startEvent(a),this}on(e,t){return this._addEventListener(e,t,false)}once(e,t){return this._addEventListener(e,t,true)}emit(e,...t){let n=false,a=[],i=Vn(e);return this._events=this._events.filter(o=>o.tag!==i?true:(setTimeout(()=>{o.listener.apply(this,t);},0),n=true,o.once?(a.push(o),false):true)),a.forEach(o=>{this._stopEvent(o);}),n}listenerCount(e){if(!e)return this._events.length;let t=Vn(e);return this._events.filter(n=>n.tag===t).length}listeners(e){if(e==null)return this._events.map(n=>n.listener);let t=Vn(e);return this._events.filter(n=>n.tag===t).map(n=>n.listener)}off(e,t){if(t==null)return this.removeAllListeners(e);let n=[],a=false,i=Vn(e);return this._events=this._events.filter(o=>o.tag!==i||o.listener!=t||a?true:(a=true,n.push(o),false)),n.forEach(o=>{this._stopEvent(o);}),this}removeAllListeners(e){let t=[];if(e==null)t=this._events,this._events=[];else {let n=Vn(e);this._events=this._events.filter(a=>a.tag!==n?true:(t.push(a),false));}return t.forEach(n=>{this._stopEvent(n);}),this}};var Wc="abstract-signer/5.8.0";var jt=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},Jt=new U(Wc),Y2=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],X2=[U.errors.INSUFFICIENT_FUNDS,U.errors.NONCE_EXPIRED,U.errors.REPLACEMENT_UNDERPRICED],Si=class r{constructor(){Jt.checkAbstract(new.target,r),se(this,"_isSigner",true);}getBalance(e){return jt(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),e)})}getTransactionCount(e){return jt(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),e)})}estimateGas(e){return jt(this,void 0,void 0,function*(){this._checkProvider("estimateGas");let t=yield et(this.checkTransaction(e));return yield this.provider.estimateGas(t)})}call(e,t){return jt(this,void 0,void 0,function*(){this._checkProvider("call");let n=yield et(this.checkTransaction(e));return yield this.provider.call(n,t)})}sendTransaction(e){return jt(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");let t=yield this.populateTransaction(e),n=yield this.signTransaction(t);return yield this.provider.sendTransaction(n)})}getChainId(){return jt(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return jt(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return jt(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(e){return jt(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(e)})}checkTransaction(e){for(let n in e)Y2.indexOf(n)===-1&&Jt.throwArgumentError("invalid transaction key: "+n,"transaction",e);let t=ot(e);return t.from==null?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then(n=>(n[0].toLowerCase()!==n[1].toLowerCase()&&Jt.throwArgumentError("from address mismatch","transaction",e),n[0])),t}populateTransaction(e){return jt(this,void 0,void 0,function*(){let t=yield et(this.checkTransaction(e));t.to!=null&&(t.to=Promise.resolve(t.to).then(a=>jt(this,void 0,void 0,function*(){if(a==null)return null;let i=yield this.resolveName(a);return i==null&&Jt.throwArgumentError("provided ENS name resolves to null","tx.to",a),i})),t.to.catch(a=>{}));let n=t.maxFeePerGas!=null||t.maxPriorityFeePerGas!=null;if(t.gasPrice!=null&&(t.type===2||n)?Jt.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",e):(t.type===0||t.type===1)&&n&&Jt.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",e),(t.type===2||t.type==null)&&t.maxFeePerGas!=null&&t.maxPriorityFeePerGas!=null)t.type=2;else if(t.type===0||t.type===1)t.gasPrice==null&&(t.gasPrice=this.getGasPrice());else {let a=yield this.getFeeData();if(t.type==null)if(a.maxFeePerGas!=null&&a.maxPriorityFeePerGas!=null)if(t.type=2,t.gasPrice!=null){let i=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=i,t.maxPriorityFeePerGas=i;}else t.maxFeePerGas==null&&(t.maxFeePerGas=a.maxFeePerGas),t.maxPriorityFeePerGas==null&&(t.maxPriorityFeePerGas=a.maxPriorityFeePerGas);else a.gasPrice!=null?(n&&Jt.throwError("network does not support EIP-1559",U.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),t.gasPrice==null&&(t.gasPrice=a.gasPrice),t.type=0):Jt.throwError("failed to get consistent fee data",U.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else t.type===2&&(t.maxFeePerGas==null&&(t.maxFeePerGas=a.maxFeePerGas),t.maxPriorityFeePerGas==null&&(t.maxPriorityFeePerGas=a.maxPriorityFeePerGas));}return t.nonce==null&&(t.nonce=this.getTransactionCount("pending")),t.gasLimit==null&&(t.gasLimit=this.estimateGas(t).catch(a=>{if(X2.indexOf(a.code)>=0)throw a;return Jt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",U.errors.UNPREDICTABLE_GAS_LIMIT,{error:a,tx:t})})),t.chainId==null?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then(a=>(a[1]!==0&&a[0]!==a[1]&&Jt.throwArgumentError("chainId address mismatch","transaction",e),a[0])),yield et(t)})}_checkProvider(e){this.provider||Jt.throwError("missing provider",U.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"});}static isSigner(e){return !!(e&&e._isSigner)}};var Tr=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},rt=new U(cr),t1=["call","estimateGas"];function _a(r,e){if(r==null)return null;if(typeof r.message=="string"&&r.message.match("reverted")){let t=bytes.isHexString(r.data)?r.data:null;if(!e||t)return {message:r.message,data:t}}if(typeof r=="object"){for(let t in r){let n=_a(r[t],e);if(n)return n}return null}if(typeof r=="string")try{return _a(JSON.parse(r),e)}catch{}return null}function Qc(r,e,t){let n=t.transaction||t.signedTransaction;if(r==="call"){let i=_a(e,true);if(i)return i.data;rt.throwError("missing revert data in call exception; Transaction reverted without a reason string",U.errors.CALL_EXCEPTION,{data:"0x",transaction:n,error:e});}if(r==="estimateGas"){let i=_a(e.body,false);i==null&&(i=_a(e,false)),i&&rt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",U.errors.UNPREDICTABLE_GAS_LIMIT,{reason:i.message,method:r,transaction:n,error:e});}let a=e.message;throw e.code===U.errors.SERVER_ERROR&&e.error&&typeof e.error.message=="string"?a=e.error.message:typeof e.body=="string"?a=e.body:typeof e.responseText=="string"&&(a=e.responseText),a=(a||"").toLowerCase(),a.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&rt.throwError("insufficient funds for intrinsic transaction cost",U.errors.INSUFFICIENT_FUNDS,{error:e,method:r,transaction:n}),a.match(/nonce (is )?too low/i)&&rt.throwError("nonce has already been used",U.errors.NONCE_EXPIRED,{error:e,method:r,transaction:n}),a.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&rt.throwError("replacement fee too low",U.errors.REPLACEMENT_UNDERPRICED,{error:e,method:r,transaction:n}),a.match(/only replay-protected/i)&&rt.throwError("legacy pre-eip-155 transactions not supported",U.errors.UNSUPPORTED_OPERATION,{error:e,method:r,transaction:n}),t1.indexOf(r)>=0&&a.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&rt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",U.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:r,transaction:n}),e}function Kc(r){return new Promise(function(e){setTimeout(e,r);})}function r1(r){if(r.error){let e=new Error(r.error.message);throw e.code=r.error.code,e.data=r.error.data,e}return r.result}function Ra(r){return r&&r.toLowerCase()}var fu={},Di=class extends Si{constructor(e,t,n){if(super(),e!==fu)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");se(this,"provider",t),n==null&&(n=0),typeof n=="string"?(se(this,"_address",this.provider.formatter.address(n)),se(this,"_index",null)):typeof n=="number"?(se(this,"_index",n),se(this,"_address",null)):rt.throwArgumentError("invalid address or index","addressOrIndex",n);}connect(e){return rt.throwError("cannot alter JSON-RPC Signer connection",U.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new mu(fu,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(e=>(e.length<=this._index&&rt.throwError("unknown account #"+this._index,U.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index])))}sendUncheckedTransaction(e){e=ot(e);let t=this.getAddress().then(n=>(n&&(n=n.toLowerCase()),n));if(e.gasLimit==null){let n=ot(e);n.from=t,e.gasLimit=this.provider.estimateGas(n);}return e.to!=null&&(e.to=Promise.resolve(e.to).then(n=>Tr(this,void 0,void 0,function*(){if(n==null)return null;let a=yield this.provider.resolveName(n);return a==null&&rt.throwArgumentError("provided ENS name resolves to null","tx.to",n),a}))),et({tx:et(e),sender:t}).then(({tx:n,sender:a})=>{n.from!=null?n.from.toLowerCase()!==a&&rt.throwArgumentError("from address mismatch","transaction",e):n.from=a;let i=this.provider.constructor.hexlifyTransaction(n,{from:true});return this.provider.send("eth_sendTransaction",[i]).then(o=>o,o=>(typeof o.message=="string"&&o.message.match(/user denied/i)&&rt.throwError("user rejected transaction",U.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:n}),Qc("sendTransaction",o,i)))})}signTransaction(e){return rt.throwError("signing transactions is unsupported",U.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return Tr(this,void 0,void 0,function*(){let t=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),n=yield this.sendUncheckedTransaction(e);try{return yield ln(()=>Tr(this,void 0,void 0,function*(){let a=yield this.provider.getTransaction(n);if(a!==null)return this.provider._wrapTransaction(a,n,t)}),{oncePoll:this.provider})}catch(a){throw a.transactionHash=n,a}})}signMessage(e){return Tr(this,void 0,void 0,function*(){let t=typeof e=="string"?bt(e):e,n=yield this.getAddress();try{return yield this.provider.send("personal_sign",[bytes.hexlify(t),n.toLowerCase()])}catch(a){throw typeof a.message=="string"&&a.message.match(/user denied/i)&&rt.throwError("user rejected signing",U.errors.ACTION_REJECTED,{action:"signMessage",from:n,messageData:e}),a}})}_legacySignMessage(e){return Tr(this,void 0,void 0,function*(){let t=typeof e=="string"?bt(e):e,n=yield this.getAddress();try{return yield this.provider.send("eth_sign",[n.toLowerCase(),bytes.hexlify(t)])}catch(a){throw typeof a.message=="string"&&a.message.match(/user denied/i)&&rt.throwError("user rejected signing",U.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:n,messageData:e}),a}})}_signTypedData(e,t,n){return Tr(this,void 0,void 0,function*(){let a=yield Nn.resolveNames(e,t,n,o=>this.provider.resolveName(o)),i=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[i.toLowerCase(),JSON.stringify(Nn.getPayload(a.domain,t,a.value))])}catch(o){throw typeof o.message=="string"&&o.message.match(/user denied/i)&&rt.throwError("user rejected signing",U.errors.ACTION_REJECTED,{action:"_signTypedData",from:i,messageData:{domain:a.domain,types:t,value:a.value}}),o}})}unlock(e){return Tr(this,void 0,void 0,function*(){let t=this.provider,n=yield this.getAddress();return t.send("personal_unlockAccount",[n.toLowerCase(),e,null])})}},mu=class extends Di{sendTransaction(e){return this.sendUncheckedTransaction(e).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:n=>this.provider.waitForTransaction(t,n)}))}},n1={chainId:true,data:true,gasLimit:true,gasPrice:true,nonce:true,to:true,value:true,type:true,accessList:true,maxFeePerGas:true,maxPriorityFeePerGas:true},Mi=class extends hn{constructor(e,t){let n=t;n==null&&(n=new Promise((a,i)=>{setTimeout(()=>{this.detectNetwork().then(o=>{a(o);},o=>{i(o);});},0);})),super(n),e||(e=Jr(this.constructor,"defaultUrl")()),typeof e=="string"?se(this,"connection",Object.freeze({url:e})):se(this,"connection",Object.freeze(ot(e))),this._nextId=42;}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return "http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null;},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return Tr(this,void 0,void 0,function*(){yield Kc(0);let e=null;try{e=yield this.send("eth_chainId",[]);}catch{try{e=yield this.send("net_version",[]);}catch{}}if(e!=null){let t=Jr(this.constructor,"getNetwork");try{return t(Z.from(e).toNumber())}catch(n){return rt.throwError("could not detect network",U.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:n})}}return rt.throwError("could not detect network",U.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(e){return new Di(fu,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(e=>e.map(t=>this.formatter.address(t)))}send(e,t){let n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:un(n),provider:this});let a=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(a&&this._cache[e])return this._cache[e];let i=ga(this.connection,JSON.stringify(n),r1).then(o=>(this.emit("debug",{action:"response",request:n,response:o,provider:this}),o),o=>{throw this.emit("debug",{action:"response",error:o,request:n,provider:this}),o});return a&&(this._cache[e]=i,setTimeout(()=>{this._cache[e]=null;},0)),i}prepareRequest(e,t){switch(e){case "getBlockNumber":return ["eth_blockNumber",[]];case "getGasPrice":return ["eth_gasPrice",[]];case "getBalance":return ["eth_getBalance",[Ra(t.address),t.blockTag]];case "getTransactionCount":return ["eth_getTransactionCount",[Ra(t.address),t.blockTag]];case "getCode":return ["eth_getCode",[Ra(t.address),t.blockTag]];case "getStorageAt":return ["eth_getStorageAt",[Ra(t.address),bytes.hexZeroPad(t.position,32),t.blockTag]];case "sendTransaction":return ["eth_sendRawTransaction",[t.signedTransaction]];case "getBlock":return t.blockTag?["eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]]:t.blockHash?["eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]]:null;case "getTransaction":return ["eth_getTransactionByHash",[t.transactionHash]];case "getTransactionReceipt":return ["eth_getTransactionReceipt",[t.transactionHash]];case "call":return ["eth_call",[Jr(this.constructor,"hexlifyTransaction")(t.transaction,{from:true}),t.blockTag]];case "estimateGas":return ["eth_estimateGas",[Jr(this.constructor,"hexlifyTransaction")(t.transaction,{from:true})]];case "getLogs":return t.filter&&t.filter.address!=null&&(t.filter.address=Ra(t.filter.address)),["eth_getLogs",[t.filter]];}return null}perform(e,t){return Tr(this,void 0,void 0,function*(){if(e==="call"||e==="estimateGas"){let a=t.transaction;if(a&&a.type!=null&&Z.from(a.type).isZero()&&a.maxFeePerGas==null&&a.maxPriorityFeePerGas==null){let i=yield this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=ot(t),t.transaction=ot(a),delete t.transaction.type);}}let n=this.prepareRequest(e,t);n==null&&rt.throwError(e+" not implemented",U.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(n[0],n[1])}catch(a){return Qc(e,a,t)}})}_startEvent(e){e.tag==="pending"&&this._startPending(),super._startEvent(e);}_startPending(){if(this._pendingFilter!=null)return;let e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(n){function a(){e.send("eth_getFilterChanges",[n]).then(function(i){if(e._pendingFilter!=t)return null;let o=Promise.resolve();return i.forEach(function(s){e._emitted["t:"+s.toLowerCase()]="pending",o=o.then(function(){return e.getTransaction(s).then(function(p){return e.emit("pending",p),null})});}),o.then(function(){return Kc(1e3)})}).then(function(){if(e._pendingFilter!=t){e.send("eth_uninstallFilter",[n]);return}return setTimeout(function(){a();},0),null}).catch(i=>{});}return a(),n}).catch(n=>{});}_stopEvent(e){e.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(e);}static hexlifyTransaction(e,t){let n=ot(n1);if(t)for(let i in t)t[i]&&(n[i]=true);Pp(e,n);let a={};return ["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(i){if(e[i]==null)return;let o=bytes.hexValue(Z.from(e[i]));i==="gasLimit"&&(i="gas"),a[i]=o;}),["from","to","data"].forEach(function(i){e[i]!=null&&(a[i]=bytes.hexlify(e[i]));}),e.accessList&&(a.accessList=fn(e.accessList)),a}};var a1=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i);})}return new(t||(t=Promise))(function(i,o){function s(l){try{c(n.next(l));}catch(f){o(f);}}function p(l){try{c(n.throw(l));}catch(f){o(f);}}function c(l){l.done?i(l.value):a(l.value).then(s,p);}c((n=n.apply(r,[])).next());})},i1=new U(cr),Ta=class extends Mi{detectNetwork(){let e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return a1(this,void 0,void 0,function*(){let t=this.network;return t==null&&(t=yield e.detectNetwork.call(this),t||i1.throwError("no network detected",U.errors.UNKNOWN_ERROR,{}),this._network==null&&(se(this,"_network",t),this.emit("network",t,null))),t})}};var o1=6e4,s1=1;function u1(r){return new Promise(e=>setTimeout(e,r))}function p1(r){r.length===0&&console.error("no networks provided");let e;for(let t=0;t<r.length;t++){let n=r[t];if(n||console.error("network not defined"),!e){e=n;continue}e.name.toLowerCase()===n.name.toLowerCase()&&e.chainId===n.chainId&&(e.ensAddress?.toLowerCase()===n.ensAddress?.toLowerCase()||e.ensAddress==null&&n.ensAddress==null)||console.error("provider mismatch");}return e||console.error("no networks defined"),e}var Fi=class extends hn{constructor(t,n,a){super(n);this.currentProviderIndex=0;this.firstRotationTimestamp=0;this.maxRetries=0;this.retries=0;this.lastError="";this.providers=t.map(i=>new Ta(i,n)),this.maxRetries=a?.maxRetries||s1,this.fallForwardDelay=a?.fallFowardDelay||o1;}async fallForwardRotation(){let n=Date.now()-this.firstRotationTimestamp;n<this.fallForwardDelay&&(await u1(this.fallForwardDelay-n),this.currentProviderIndex=0);}rotateUrl(t){if(t===this.currentProviderIndex)if(this.currentProviderIndex===0)this.currentProviderIndex+=1,this.firstRotationTimestamp=Date.now(),this.fallForwardRotation();else if(this.currentProviderIndex===this.providers.length-1){if(this.retries+=1,this.retries>this.maxRetries)throw this.retries=0,new Error(`RotationProvider exceeded max number of retries. Last error: ${this.lastError}`);this.currentProviderIndex=0;}else this.currentProviderIndex+=1;}async detectNetwork(){let t=await Promise.all(this.providers.map(n=>n.getNetwork()));return p1(t)}async perform(t,n){let a=this.currentProviderIndex;try{return await this.providers[a].perform(t,n)}catch(i){return console.error(i.message),this.lastError=i.message,this.emit("debug",{action:"perform",provider:this.providers[a]}),await this.rotateUrl(a),this.perform(t,n)}}};var Vc={version:"0.1.267-beta.79"};var Ni=c1__default.default(),d1=(r,e)=>e?(e=JSON.parse(JSON.stringify(e)),r.includes("?")?r+"&"+new URLSearchParams(e).toString():r+"?"+new URLSearchParams(e).toString()):r,ie={get:(r,e,t={})=>{let n=d1(r,e);return Ni.url(n).options(t).get().json()},post:(r,e,t={})=>Ni.url(r).options(t).post(e).json(),put:(r,e,t={})=>Ni.url(r).options(t).put(e).json(),delete:(r,e={})=>Ni.url(r).options(e).delete().json()};var f1=(l=>(l[l.SUCCESS=9200]="SUCCESS",l[l.SUCCESS_ORIGIN=0]="SUCCESS_ORIGIN",l[l.IDENTITY_VERIFICATION_FAILED=9401]="IDENTITY_VERIFICATION_FAILED",l[l.PERMISSION_DENIED=9403]="PERMISSION_DENIED",l[l.NOT_EXIST=9404]="NOT_EXIST",l[l.REQUEST_LIMIT=9429]="REQUEST_LIMIT",l[l.SERVICE_ERROR=9500]="SERVICE_ERROR",l[l.MISS_REQUESTED_PARAMETER=9900]="MISS_REQUESTED_PARAMETER",l[l.INVALID_PARAMETER=9901]="INVALID_PARAMETER",l.NETWORK_ERROR="ERR_NETWORK",l))(f1||{}),Jn=(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))(Jn||{}),jc=(t=>(t[t.Chainlink=1]="Chainlink",t[t.Pyth=2]="Pyth",t))(jc||{}),Jc=(c=>(c[c.Minute1=1]="Minute1",c[c.Minute5=5]="Minute5",c[c.Minute15=15]="Minute15",c[c.Minute30=30]="Minute30",c[c.Hour1=60]="Hour1",c[c.Hour4=240]="Hour4",c[c.Day1=1440]="Day1",c[c.Week1=10080]="Week1",c[c.Month1=40320]="Month1",c))(Jc||{}),m1=(n=>(n[n.Contract=1]="Contract",n[n.Cook=2]="Cook",n[n.Earn=3]="Earn",n))(m1||{}),h1=(a=>(a[a.All=0]="All",a[a.Contract=1]="Contract",a[a.Cook=2]="Cook",a[a.Earn=3]="Earn",a))(h1||{}),y1=(t=>(t[t.BlueChips=1]="BlueChips",t[t.Alpha=2]="Alpha",t))(y1||{}),g1=(n=>(n[n.BlueChips=1]="BlueChips",n[n.Alpha=2]="Alpha",n[n.Favorite=3]="Favorite",n))(g1||{});var x1=(a=>(a[a.Market=0]="Market",a[a.Limit=1]="Limit",a[a.Stop=2]="Stop",a[a.Conditional=3]="Conditional",a))(x1||{}),b1=(t=>(t[t.Increase=0]="Increase",t[t.Decrease=1]="Decrease",t))(b1||{}),v1=(w=>(w[w.Increase=0]="Increase",w[w.Decrease=1]="Decrease",w[w.AddMargin=2]="AddMargin",w[w.RemoveMargin=3]="RemoveMargin",w[w.CancelOrder=4]="CancelOrder",w[w.ADL=5]="ADL",w[w.Liquidation=6]="Liquidation",w[w.MarketClose=7]="MarketClose",w[w.EarlyClose=8]="EarlyClose",w[w.AddTPSL=9]="AddTPSL",w[w.SecurityDeposit=10]="SecurityDeposit",w[w.TransferToWallet=11]="TransferToWallet",w[w.MarginAccountDeposit=12]="MarginAccountDeposit",w[w.ReferralReward=13]="ReferralReward",w[w.ReferralRewardClaim=14]="ReferralRewardClaim",w))(v1||{}),A1=(n=>(n[n.Unknown=0]="Unknown",n[n.GTE=1]="GTE",n[n.LTE=2]="LTE",n))(A1||{}),w1=(t=>(t[t.Long=0]="Long",t[t.Short=1]="Short",t))(w1||{}),C1=(a=>(a[a.Cancelled=1]="Cancelled",a[a.Expired=2]="Expired",a[a.Successful=9]="Successful",a[a.PartialFilled=8]="PartialFilled",a))(C1||{}),E1=(c=>(c[c.Market=1]="Market",c[c.Limit=2]="Limit",c[c.TP=3]="TP",c[c.SL=4]="SL",c[c.ADL=5]="ADL",c[c.ADLTrigger=6]="ADLTrigger",c[c.Liquidation=7]="Liquidation",c[c.EarlyClose=8]="EarlyClose",c[c.MarketClose=9]="MarketClose",c))(E1||{}),I1=(l=>(l[l.Open=0]="Open",l[l.PartialClose=1]="PartialClose",l[l.FullClose=2]="FullClose",l[l.Liquidation=3]="Liquidation",l[l.EarlyClose=4]="EarlyClose",l[l.MarketClose=5]="MarketClose",l[l.ADL=6]="ADL",l[l.TP=7]="TP",l[l.SL=8]="SL",l[l.Increase=9]="Increase",l))(I1||{}),P1=(n=>(n[n.MarginAccount=1]="MarginAccount",n[n.WalletAccount=2]="WalletAccount",n[n.ReferralReward=3]="ReferralReward",n))(P1||{});var R1=(a=>(a[a.EXECUTING=1]="EXECUTING",a[a.BROADCAST_FAILED=2]="BROADCAST_FAILED",a[a.TIMEOUT_CANCEL=3]="TIMEOUT_CANCEL",a[a.EXECUTED=9]="EXECUTED",a))(R1||{});var T4=async()=>ie.get(`${kr()}/openapi/gateway/scan/market/list`);var kr=()=>{let{isTestnet:r,isBetaMode:e}=Sr?.getConfigManager()?.getConfig()||{};return e?"https://api-beta.myx.finance":r?"https://api-test.myx.cash":"https://api.myx.finance"},Br=async(r,e=[])=>e.length?ie.get(`${kr()}/openapi/gateway/quote/price/oracles`,{chainId:r,poolIds:e.join(",")}):Promise.reject(new Error("Invalid pool id")),Yc=async(r,e)=>await ie.get(`${kr()}/openapi/gateway/scan/market/info?chainId=${r}&poolId=${e}`),Xc=async(r,e,t)=>await ie.get(`${kr()}/openapi/gateway/scan/market/pool-order/open?chainId=${t}`,void 0,{headers:{myx_openapi_access_token:r,myx_openapi_account:e}}),D4=async({chainId:r,poolIds:e},t)=>ie.get(`${kr()}/openapi/gateway/quote/candle/tickers`,{chainId:r,poolIds:e.join(",")}),M4=async({...r})=>ie.get(`${kr()}/openapi/gateway/scan/market/base-details`,r),F4=async({...r})=>ie.get(`${kr()}/openapi/gateway/scan/market/detail`,r),Zc=async()=>ie.get(`${kr()}/openapi/gateway/scan/market`);function pt(r,e,t){if(ja.from(r).isEqualTo(ethers.ZeroAddress))throw new Error(`Invalid 'address' parameter '${r}'.`);return new ethers.Contract(r,e,t)}var Ce=r=>{let e=dp(r),t=[];if(e.privateJsonRPCUrl&&t.push(e.privateJsonRPCUrl),e.publicJsonRPCUrl.length>0&&e.publicJsonRPCUrl.map(n=>t.push(n)),t.length===0)throw new Error(`${r} has no jsonRPCUrl configured`);return t.length===1?new ethers.JsonRpcProvider(t[0],r,{staticNetwork:true}):new Fi(t,r)},ka,hu=class hu{constructor(){this.version=Vc.version;Bu(this,ka);console.log(this.version);}setConfigManager(e){Su(this,ka,e);}getConfigManager(){return ku(this,ka)}setProvider(e){this.provider=e;}getProvider(){return this.provider}static getInstance(){return this._instance||(this._instance=new hu),this._instance}async getMarkets(){try{let t=(await Zc())?.data||[];return this.Markets=t,t}catch(e){throw e}}};ka=new WeakMap;var tn=hu,Oi=tn.getInstance();typeof window<"u"?window.MxSDK=Oi:typeof globalThis<"u"&&(globalThis.MxSDK=Oi);var Sr=Oi,D1=async r=>{try{let e=Oi.getConfigManager()?.getConfig()?.walletClient,t=new ethers.BrowserProvider(e?.transport);if(!t)throw new Error("missing provider");return t}catch(e){return console.error("Error getting wallet provider:",e),ethers.ethers.getDefaultProvider("mainnet")}},yt=async r=>(await D1())?.getSigner?.();var $c=[{type:"constructor",payable:false,inputs:[]},{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:"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:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"benchPool",constant:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"checkPoolExists",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bool"}]},{type:"function",name:"deployPool",constant:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"marketId"},{type:"address",name:"baseToken"}]}],outputs:[]},{type:"function",name:"getAddressManager",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getMarketPool",constant:true,stateMutability:"view",payable:false,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:"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:"function",name:"getPairToken",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address",name:"baseToken"},{type:"address",name:"quoteToken"}]},{type:"function",name:"getPool",constant:true,stateMutability:"view",payable:false,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:"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:"function",name:"getPoolMarket",constant:true,stateMutability:"view",payable:false,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:"uint64",name:"oracleRefundFeeUsd"},{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:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"executionFee"}]},{type:"function",name:"getPoolMarketForwardFee",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"forwardFee"}]},{type:"function",name:"getPoolMarketId",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"bytes32",name:"marketId"}]},{type:"function",name:"getPoolRiskTier",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint8"}]},{type:"function",name:"getPoolVault",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address"}]},{type:"function",name:"getPools",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32[]",name:"pools"}]},{type:"function",name:"getTradingVault",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isPoolAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"addr"}],outputs:[{type:"bool"}]},{type:"function",name:"perBenchPool",constant:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"primePool",constant:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"referencePrice"}]}],outputs:[]},{type:"function",name:"proxiableUUID",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"reprimePool",constant:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"}]}],outputs:[]},{type:"function",name:"trenchPool",constant:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bytes32",name:"oracleFeedId"},{type:"uint32",name:"oracleDecimals"},{type:"uint8",name:"oracleType"},{type:"uint16",name:"maxPriceDeviation"},{type:"uint8",name:"riskTier"},{type:"uint64",name:"windowCapUsd"}]}],outputs:[]},{type:"function",name:"updatePoolCompoundEnabled",constant:false,payable:false,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"bool",name:"enabled"}]}],outputs:[]},{type:"function",name:"updatePoolPriceDeviations",constant:false,payable:false,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint16",name:"maxPriceDeviation"}]}],outputs:[]},{type:"function",name:"updatePoolRiskTiers",constant:false,payable:false,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint8",name:"riskTier"}]}],outputs:[]},{type:"function",name:"updatePoolWindowCaps",constant:false,payable:false,inputs:[{type:"tuple[]",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"uint64",name:"windowCapUsd"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var yn=[{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:false,inputs:[{indexed:true,internalType:"address",name:"owner",type:"address"},{indexed:true,internalType:"address",name:"spender",type:"address"},{indexed:false,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:false,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"previousOwner",type:"address"},{indexed:true,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"from",type:"address"},{indexed:true,internalType:"address",name:"to",type:"address"},{indexed:false,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 ed=[{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:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"QuotePoolProfitDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"amount",indexed:false},{type:"uint256",name:"genesisAmount",indexed:false},{type:"uint256",name:"price",indexed:false},{type:"uint256",name:"exchangeRate",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"function",name:"EXCHANGE_RATE_PRECISION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"POOL_TOKEN_DECIMALS",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"REBATE_INDEX_PRECISION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimUserRebate",constant:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"rebateOut"}]},{type:"function",name:"claimUserRebates",constant:false,payable:false,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256[]",name:"rebateOut"}]},{type:"function",name:"deposit",constant:false,payable:false,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:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"amount"},{type:"uint256",name:"genesisAmount"},{type:"uint256",name:"price"}],outputs:[]},{type:"function",name:"getAddressManager",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExchangeRate",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeRate",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolData",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"tuple",components:[{type:"uint256",name:"genesisRebateIndex"}]}]},{type:"function",name:"getPoolTokenPrice",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getUserData",constant:true,stateMutability:"view",payable:false,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:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"pendingUserRebates",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewLpAmountOut",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"quoteAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewPoolTokenPrice",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewQuoteAmountOut",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewUserWithdrawData",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updatePool",constant:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"oraclePrice"}],outputs:[]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdraw",constant:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]}];var td=[{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:false,name:"BasePoolProfitDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:true},{type:"uint256",name:"baseAmount",indexed:false},{type:"uint256",name:"quoteAmount",indexed:false},{type:"uint256",name:"price",indexed:false},{type:"uint256",name:"exchangeRate",indexed:false},{type:"uint256",name:"rebateIndex",indexed:false},{type:"uint256",name:"genesisRebateIndex",indexed:false}]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"PoolProfitExchanged",inputs:[{type:"bytes32",name:"poolId",indexed:true},{type:"uint256",name:"baseIn",indexed:false},{type:"uint256",name:"quoteOut",indexed:false},{type:"uint256",name:"price",indexed:false},{type:"address",name:"recipient",indexed:false}]},{type:"event",anonymous:false,name:"PoolRebateIndexUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:true},{type:"uint256",name:"unexchangedProfits",indexed:false},{type:"uint256",name:"oldIndex",indexed:false},{type:"uint256",name:"newIndex",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"function",name:"EXCHANGE_RATE_PRECISION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"POOL_TOKEN_DECIMALS",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"REBATE_INDEX_PRECISION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimUserRebate",constant:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256",name:"rebateOut"}]},{type:"function",name:"claimUserRebates",constant:false,payable:false,inputs:[{type:"bytes32[]",name:"poolIds"},{type:"address",name:"user"},{type:"address",name:"recipient"}],outputs:[{type:"uint256[]",name:"rebateOut"}]},{type:"function",name:"deposit",constant:false,payable:false,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:false,payable:false,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:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExchangeRate",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeRate",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExchangeableProfit",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256",name:"baseIn"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolData",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"getUserData",constant:true,stateMutability:"view",payable:false,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:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"pendingUserRebates",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"lpAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewExchangeableProfit",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"baseIn"},{type:"uint256",name:"quoteOut"}]},{type:"function",name:"previewLpAmountOut",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmountIn"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewPoolTokenPrice",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256"}]},{type:"function",name:"previewUserWithdrawData",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updatePool",constant:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"oraclePrice"}],outputs:[]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"withdraw",constant:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"price"}],outputs:[{type:"uint256"}]}];var Yt=[{type:"constructor",payable:false,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:false,name:"BrokerStatusUpdated",inputs:[{type:"address",name:"broker",indexed:false},{type:"bool",name:"isActive",indexed:false}]},{type:"event",anonymous:false,name:"EIP712DomainChanged",inputs:[]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"OwnershipTransferStarted",inputs:[{type:"address",name:"previousOwner",indexed:true},{type:"address",name:"newOwner",indexed:true}]},{type:"event",anonymous:false,name:"OwnershipTransferred",inputs:[{type:"address",name:"previousOwner",indexed:true},{type:"address",name:"newOwner",indexed:true}]},{type:"event",anonymous:false,name:"RebateClaimed",inputs:[{type:"address",name:"user",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"SignerUpdated",inputs:[{type:"address",name:"signer",indexed:false},{type:"bool",name:"isSigner",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"event",anonymous:false,name:"UserFeeDataReset",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"signer",indexed:false},{type:"uint256",name:"epoch",indexed:false}]},{type:"event",anonymous:false,name:"UserFeeDataUpdated",inputs:[{type:"address",name:"broker",indexed:true},{type:"address",name:"signer",indexed:false},{type:"address",name:"user",indexed:false},{type:"uint256",name:"epoch",indexed:false},{type:"uint8",name:"tier",indexed:false},{type:"address",name:"referrer",indexed:false},{type:"uint32",name:"totalReferralRebatePct",indexed:false},{type:"uint32",name:"referrerRebatePct",indexed:false}]},{type:"function",name:"FEE_TYPEHASH",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:false,payable:false,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"acceptOwnership",constant:false,payable:false,inputs:[],outputs:[]},{type:"function",name:"activeFeeTiers",constant:true,stateMutability:"view",payable:false,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"activeSpecialFeeTierList",constant:true,stateMutability:"view",payable:false,inputs:[{type:"uint8",name:"assetClass"},{type:"uint8",name:"riskTier"}],outputs:[{type:"uint256[]"}]},{type:"function",name:"addressManager",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"batchSetSpecialFeeTiers",constant:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"uint256",name:"orderId"}],outputs:[]},{type:"function",name:"cancelOrders",constant:false,payable:false,inputs:[{type:"uint256[]",name:"orderIds"}],outputs:[]},{type:"function",name:"claimRebate",constant:false,payable:false,inputs:[{type:"address",name:"token"}],outputs:[]},{type:"function",name:"claimRebates",constant:false,payable:false,inputs:[{type:"address[]",name:"tokens"}],outputs:[]},{type:"function",name:"currentFeeDataEpoch",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"domainSeparatorV4",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"eip712Domain",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"uint8",name:"assetClass"}],outputs:[{type:"tuple",name:"baseFeeRate",components:[{type:"uint32",name:"takerFeeRate"},{type:"uint32",name:"makerFeeRate"}]}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getSpecialFeeTier",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bool"}]},{type:"function",name:"isTrustedForwarder",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"name",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"onBrokerFee",constant:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"pendingOwner",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"placeOrderWithPosition",constant:false,stateMutability:"payable",payable:true,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:false,stateMutability:"payable",payable:true,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:false,stateMutability:"payable",payable:true,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:false,stateMutability:"payable",payable:true,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"renounceOwnership",constant:false,payable:false,inputs:[],outputs:[]},{type:"function",name:"resetAllUserFeeData",constant:false,payable:false,inputs:[],outputs:[]},{type:"function",name:"setSigner",constant:false,payable:false,inputs:[{type:"address",name:"signer"},{type:"bool",name:"isSigner"}],outputs:[]},{type:"function",name:"setSpecialFeeTier",constant:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"address",name:"user"},{type:"uint8",name:"feeTier"}],outputs:[]},{type:"function",name:"supportedAssetClasses",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256[]"}]},{type:"function",name:"transferOwnership",constant:false,payable:false,inputs:[{type:"address",name:"newOwner"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateBaseFeeRates",constant:false,payable:false,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:false,payable:false,inputs:[{type:"bool",name:"active"}],outputs:[]},{type:"function",name:"updateFeeTier",constant:false,payable:false,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:false,payable:false,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:false,stateMutability:"payable",payable:true,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:false,payable:false,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:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"userFeeData",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"user"}],outputs:[{type:"uint64",name:"nonce"}]},{type:"function",name:"userRebates",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"user"},{type:"address",name:"token"}],outputs:[{type:"uint256",name:"rebateAmount"}]}];var rd=[{type:"constructor",payable:false,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:false,name:"Approval",inputs:[{type:"address",name:"owner",indexed:true},{type:"address",name:"spender",indexed:true},{type:"uint256",name:"value",indexed:false}]},{type:"event",anonymous:false,name:"GenesisShareBurned",inputs:[{type:"address",name:"account",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"GenesisShareMinted",inputs:[{type:"address",name:"account",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"Transfer",inputs:[{type:"address",name:"from",indexed:true},{type:"address",name:"to",indexed:true},{type:"uint256",name:"value",indexed:false}]},{type:"function",name:"addressManager",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"allowance",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"owner"},{type:"address",name:"spender"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",constant:false,payable:false,inputs:[{type:"address",name:"spender"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"}],outputs:[{type:"uint256"}]},{type:"function",name:"burnFrom",constant:false,payable:false,inputs:[{type:"address",name:"from"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"decimals",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"initialize",constant:false,payable:false,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:false,payable:false,inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"name",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"poolId",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"symbol",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalGenesisShare",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"totalSupply",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",constant:false,payable:false,inputs:[{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",constant:false,payable:false,inputs:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"underlyingToken",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"userGenesisShare",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"}],outputs:[{type:"uint256"}]}];var gn=[{type:"constructor",payable:false,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:false,name:"ExecutionFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"uint256",name:"oldExecutionFee",indexed:false},{type:"uint256",name:"newExecutionFee",indexed:false}]},{type:"event",anonymous:false,name:"ForwardFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"uint256",name:"oldForwardFee",indexed:false},{type:"uint256",name:"newForwardFee",indexed:false}]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"MaxExecutionFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"uint256",name:"oldMaxExecutionFee",indexed:false},{type:"uint256",name:"newMaxExecutionFee",indexed:false}]},{type:"event",anonymous:false,name:"MaxForwardFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"uint256",name:"oldMaxForwardFee",indexed:false},{type:"uint256",name:"newMaxForwardFee",indexed:false}]},{type:"event",anonymous:false,name:"OracleFeeUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"uint64",name:"newOracleFeeUsd",indexed:false}]},{type:"event",anonymous:false,name:"PoolPrimeThresholdUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"uint128",name:"newPoolPrimeThreshold",indexed:false}]},{type:"event",anonymous:false,name:"ReserveRatioUpdated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"uint32",name:"newBaseReserveRatio",indexed:false},{type:"uint32",name:"newQuoteReserveRatio",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"createMarket",constant:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getExecutionFee",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getExecutionFeeByToken",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"quoteToken"}],outputs:[{type:"uint256"}]},{type:"function",name:"getForwardFee",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"getForwardFeeByToken",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"quoteToken"}],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getMarket",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32[]"}]},{type:"function",name:"getOracleFee",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"uint256"}]},{type:"function",name:"initialize",constant:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"marketExists",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"marketId"}],outputs:[{type:"bool"}]},{type:"function",name:"proxiableUUID",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"updateExecutionFee",constant:false,payable:false,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_executionFee"}],outputs:[]},{type:"function",name:"updateForwardFee",constant:false,payable:false,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_forwardFee"}],outputs:[]},{type:"function",name:"updateMarketQuoteConfiguration",constant:false,payable:false,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:false,payable:false,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_maxExecutionFee"}],outputs:[]},{type:"function",name:"updateMaxForwardFee",constant:false,payable:false,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_maxForwardFee"}],outputs:[]},{type:"function",name:"updateOracleFee",constant:false,payable:false,inputs:[{type:"bytes32",name:"marketId"},{type:"uint64",name:"_oracleFeeUsd"}],outputs:[]},{type:"function",name:"updatePoolPrimeThreshold",constant:false,payable:false,inputs:[{type:"bytes32",name:"marketId"},{type:"uint128",name:"_poolPrimeThreshold"}],outputs:[]},{type:"function",name:"updateReserveRatio",constant:false,payable:false,inputs:[{type:"bytes32",name:"marketId"},{type:"uint32",name:"_baseReserveRatio"},{type:"uint32",name:"_quoteReserveRatio"}],outputs:[]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var Li=[{type:"constructor",payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getAccountInfo",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"positionId"},{type:"uint256",name:"marketPrice"},{type:"address",name:"broker"}],outputs:[{type:"uint256"}]},{type:"function",name:"getPoolInfo",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,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 Ui=[{type:"constructor",payable:false,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:"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:false,name:"AddAllowedTarget",inputs:[{type:"address",name:"target",indexed:false}]},{type:"event",anonymous:false,name:"ChargeForwardFee",inputs:[{type:"address",name:"account",indexed:false},{type:"address",name:"feeToken",indexed:false},{type:"uint256",name:"relayFee",indexed:false}]},{type:"event",anonymous:false,name:"EIP712DomainChanged",inputs:[]},{type:"event",anonymous:false,name:"ERC20PermitFailed",inputs:[{type:"address",name:"token",indexed:false},{type:"string",name:"reason",indexed:false}]},{type:"event",anonymous:false,name:"ERC20PermitLowLevelFailed",inputs:[{type:"bytes",name:"data",indexed:false}]},{type:"event",anonymous:false,name:"ExecutedForwardRequest",inputs:[{type:"address",name:"signer",indexed:true},{type:"uint256",name:"nonce",indexed:false},{type:"bool",name:"success",indexed:false}]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"RemoveAllowedTarget",inputs:[{type:"address",name:"target",indexed:false}]},{type:"event",anonymous:false,name:"SetUserRelayer",inputs:[{type:"address",name:"account",indexed:false},{type:"address",name:"relayer",indexed:false},{type:"bool",name:"enable",indexed:false}]},{type:"event",anonymous:false,name:"UpdateAcquiescentFeeToken",inputs:[{type:"address",name:"sender",indexed:false},{type:"address",name:"oldRelayGas",indexed:false},{type:"address",name:"newRelayGas",indexed:false}]},{type:"event",anonymous:false,name:"UpdateEquilibriumGas",inputs:[{type:"address",name:"sender",indexed:false},{type:"uint256",name:"oldRelayGas",indexed:false},{type:"uint256",name:"newRelayGas",indexed:false}]},{type:"event",anonymous:false,name:"UpdateMaxRelayFee",inputs:[{type:"address",name:"sender",indexed:false},{type:"uint256",name:"oldMaxRelayFee",indexed:false},{type:"uint256",name:"newMaxRelayFee",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:false,payable:false,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"addAllowedTarget",constant:false,payable:false,inputs:[{type:"address",name:"target"}],outputs:[]},{type:"function",name:"batchExecuteForwarder",constant:false,stateMutability:"payable",payable:true,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:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"execute",constant:false,stateMutability:"payable",payable:true,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"}]},{type:"address",name:"masterAccount"}],outputs:[]},{type:"function",name:"executeBatch",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"tuple[]",name:"requests",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",name:"masterAccount"},{type:"address",name:"refundReceiver"}],outputs:[]},{type:"function",name:"executeForwarder",constant:false,stateMutability:"payable",payable:true,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:false,payable:false,inputs:[],outputs:[]},{type:"function",name:"getAddressManager",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getAllowedTargets",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address[]"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getDesignatedToken",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getEquilibriumGas",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getUserRelayers",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"}],outputs:[{type:"address[]"}]},{type:"function",name:"inForwardMode",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bool"}]},{type:"function",name:"initialize",constant:false,payable:false,inputs:[{type:"address",name:"addressManager"},{type:"uint256",name:"_equilibriumGas"}],outputs:[]},{type:"function",name:"isAllowedTargets",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"contractAddr"}],outputs:[{type:"bool"}]},{type:"function",name:"isTrustedForwarder",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"isUserRelayerEnabled",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"},{type:"address",name:"relayer"}],outputs:[{type:"bool"}]},{type:"function",name:"nonces",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"originAccount",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"relayer"}],outputs:[{type:"address",name:"account"}]},{type:"function",name:"permitAndApproveForwarder",constant:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"removeAllowedTarget",constant:false,payable:false,inputs:[{type:"address",name:"target"}],outputs:[]},{type:"function",name:"trustedForwarder",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateEquilibriumGas",constant:false,payable:false,inputs:[{type:"uint256",name:"_equilibriumGas"}],outputs:[]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"verify",constant:true,stateMutability:"view",payable:false,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 nd=[{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:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"ReimbursementClaimExpired",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"address",name:"user",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint256",name:"baseAmount",indexed:false},{type:"uint256",name:"quoteAmount",indexed:false}]},{type:"event",anonymous:false,name:"ReimbursementClaimed",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"address",name:"user",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint256",name:"baseAmount",indexed:false},{type:"uint256",name:"quoteAmount",indexed:false}]},{type:"event",anonymous:false,name:"ReimbursementInfoSet",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"bytes32",name:"merkleRoot",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint256",name:"totalBaseAmount",indexed:false},{type:"uint256",name:"totalQuoteAmount",indexed:false},{type:"uint256",name:"claimedBaseAmount",indexed:false},{type:"uint256",name:"claimedQuoteAmount",indexed:false},{type:"uint256",name:"expireTime",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"claimExpiredCases",constant:false,payable:false,inputs:[{type:"uint256[]",name:"caseIds"},{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"claimReimbursement",constant:false,payable:false,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"},{type:"bytes32[]",name:"merkleProof"}],outputs:[]},{type:"function",name:"getAddressManager",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getReimbursementInfo",constant:true,stateMutability:"view",payable:false,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:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"proxiableUUID",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"setReimbursementInfo",constant:false,payable:false,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:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var ad=[{type:"constructor",payable:false,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:false,name:"AppealCanceled",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"uint256",name:"appealCaseId",indexed:false},{type:"address",name:"complainant",indexed:false},{type:"bool",name:"isMalicious",indexed:false}]},{type:"event",anonymous:false,name:"AppealFiled",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"uint256",name:"appealCaseId",indexed:false},{type:"address",name:"respondent",indexed:false},{type:"address",name:"appealToken",indexed:false},{type:"uint256",name:"appealBond",indexed:false},{type:"uint64",name:"appealDeadline",indexed:false}]},{type:"event",anonymous:false,name:"AppealResolved",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"uint256",name:"appealCaseId",indexed:false},{type:"uint8",name:"resolution",indexed:false},{type:"address",name:"complainant",indexed:false}]},{type:"event",anonymous:false,name:"BondClaimed",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"address",name:"user",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"CaseAppealsResolved",inputs:[{type:"uint256",name:"caseId",indexed:false}]},{type:"event",anonymous:false,name:"CaseRiskClosed",inputs:[{type:"uint256",name:"caseId",indexed:false}]},{type:"event",anonymous:false,name:"DisputeCanceled",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"address",name:"complainant",indexed:false},{type:"bool",name:"isMalicious",indexed:false}]},{type:"event",anonymous:false,name:"DisputeConfigurationUpdated",inputs:[{type:"tuple",name:"newDisputeConfigration",indexed:false,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:false,name:"DisputeFiled",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"complainant",indexed:false},{type:"address",name:"poolToken",indexed:false},{type:"uint256",name:"disputeBond",indexed:false},{type:"uint64",name:"caseDeadline",indexed:false}]},{type:"event",anonymous:false,name:"DisputeResolved",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"uint8",name:"resolution",indexed:false},{type:"uint64",name:"appealDeadline",indexed:false}]},{type:"event",anonymous:false,name:"ForfeitBondsClaimed",inputs:[{type:"address",name:"receiver",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"ReimbursementProcessed",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"tuple",name:"reimbursementInfo",indexed:false,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:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"event",anonymous:false,name:"Voted",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"address",name:"voter",indexed:false},{type:"uint8",name:"voteOption",indexed:false}]},{type:"event",anonymous:false,name:"VotingOpened",inputs:[{type:"uint256",name:"caseId",indexed:false},{type:"uint256",name:"evidenceId",indexed:false},{type:"uint64",name:"voteDeadline",indexed:false},{type:"address[]",name:"respondents",indexed:false}]},{type:"event",anonymous:false,name:"WormholeConfigurationUpdated",inputs:[{type:"tuple",name:"newWormholeConfiguration",indexed:false,components:[{type:"address",name:"wormhole"},{type:"address",name:"staker"},{type:"bytes4",name:"selector"}]}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"appeal",constant:false,payable:false,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"canRiskControlClose",constant:true,stateMutability:"view",payable:false,inputs:[{type:"uint256",name:"caseId"}],outputs:[{type:"bool"}]},{type:"function",name:"cancelAppeal",constant:false,payable:false,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"appealCaseId"},{type:"bool",name:"isMalicious"}],outputs:[]},{type:"function",name:"cancelDispute",constant:false,payable:false,inputs:[{type:"uint256",name:"caseId"},{type:"bool",name:"isMalicious"}],outputs:[]},{type:"function",name:"caseIdSequencer",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"checkRiskControlCloseCompleted",constant:false,payable:false,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"claimBond",constant:false,payable:false,inputs:[{type:"uint256",name:"caseId"}],outputs:[]},{type:"function",name:"claimForfeitBonds",constant:false,payable:false,inputs:[{type:"address",name:"receiver"}],outputs:[]},{type:"function",name:"fileDispute",constant:false,stateMutability:"payable",payable:true,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:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getDisputeConfiguration",constant:true,stateMutability:"view",payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isCaseRespondents",constant:true,stateMutability:"view",payable:false,inputs:[{type:"uint256",name:"caseId"},{type:"address",name:"account"}],outputs:[{type:"bool"}]},{type:"function",name:"nonces",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"openVoting",constant:false,payable:false,inputs:[{type:"uint256",name:"caseId"},{type:"uint256",name:"evidenceId"},{type:"address[]",name:"respondents"}],outputs:[]},{type:"function",name:"processReimbursement",constant:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"resolveCaseAppeals",constant:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"tuple",name:"wormholeConfiguration",components:[{type:"address",name:"wormhole"},{type:"address",name:"staker"},{type:"bytes4",name:"selector"}]}],outputs:[]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"vote",constant:false,payable:false,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 id={USDC:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",POOL_MANAGER:"0xf268D9FeD3Bd56fd9aBdb4FeEb993338613678A8",Account:"0x396a6aDb17903f4b0ED3EA55F18391C403fa3Bb4",POSITION_MANAGER:"0x89d1091Ef4aB71d688a86f3D92112715905d7B8A",ORDER_MANAGER:"0x5948bc0E0c72a7B7a90eb8f5a1951bDB0ef0f68D",PYTH:"0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",ERC20:"0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",LIQUIDITY_ROUTER:"0x5E16C0699de2Ee5D69a620AB38AE2c81A29a58df",BASE_POOL:"0xDb41D850e9b30fc0417F488D1aB64fdc1d0DdFdc",QUOTE_POOL:"0xF0784c1023C051Bf1D5b8470A896c536039B06B9",ORACLE:"0xb3C295769d86fc321bA70a7C43EAfa10322CC66F",EIP7702Delegation:"0xe3D34CbDfC221e064510Cfa82EFF99172651BeB9",MARKET_MANAGER:"0xB3EEc5C2eEc049b4eD4C528Dcd9a97680E3edFb7",DATA_PROVIDER:"0xeA2be692Da76Bf6851f3cBf9750075e10E9085cB",ORACLE_RESERVE:"0x247e3A9d6E9CF6D619c7D0A0eE11B7CD966FA3aa",FORWARDER:"0x065Adb8183c114c3a61d75c89051ecE6C1C9A6fB",TRADING_ROUTER:"0x6A2aF0be0629B424a6A7EfEf54a3b50a99bC1a29",REIMBURSEMENT:"0x2C294a480006703B1A4F6493eA3B1dAC7A84454b",DISPUTE_COURT:"0x09F56485B5FB01C6C27bB81f54605F4d55d7d10B"};var od={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 sd={USDC:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",POOL_MANAGER:"0x784808c123B778BacB2c08782837BC083e6C5cF0",Account:"0xB219526B2DC7Aa25Eb78A8Bd5e0AeaC9880f26Ca",POSITION_MANAGER:"0xca570536de1398d855507bA62c01B0dF3ecf8FE9",ORDER_MANAGER:"0x679859C80e58e5026018401bED798C574c844560",PYTH:"0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",ERC20:"0xD984fd34f91F92DA0586e1bE82E262fF27DC431b",LIQUIDITY_ROUTER:"0xf1395643D77DD839E4b8d3Bb122fd0275Cf07631",BASE_POOL:"0x31b093BBADbb2A3Bcd7E433E8Ed5bcdD76fFAFFe",QUOTE_POOL:"0xFF8A6797E2063A7a4cd1468eB7cC0db9798C753f",ORACLE:"0x0074441b86da2aE6818304B586fCf619c68C4204",EIP7702Delegation:"0x7629731046b2498b4C00B8a2208e538E706E5bfc",MARKET_MANAGER:"0x170F95d91B27d8bc7afA85B06d8B129BA34f405F",DATA_PROVIDER:"0x8873C5828fe1A903221971817b17dc67903544d6",ORACLE_RESERVE:"0xDc9321c19b02cefe57fFB2C1F70014a478D06ddF",FORWARDER:"0x2AC73d767D2c3e44741410c3E41988a05bCf9C86",TRADING_ROUTER:"0x5976abbC616520968b12EeB4b11AFa8490281453",REIMBURSEMENT:"0x257BF8df1CF76762985F3cf19c7cd1D6Adb67Bc7",DISPUTE_COURT:"0x02495c66dfb2ECeF5ebb7339a997EBb7D73DFdbf"};var ud={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 pd={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 ld={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"};var cd={USDC:"0x55d398326f99059fF775485246999027B3197955",POOL_MANAGER:"0x13F2130c2F3bfd612BBCBF35FB9E467dd32bAF3A",Account:"0xa32D0550F127fCFF0FA13D21523c5d4a2b86595D",POSITION_MANAGER:"0x93062Ec7Ef0aCf73c877A1d816A6CECc736d018e",ORDER_MANAGER:"0x9438d539e169b72FC2bEC819D4165ABe488921CD",PYTH:"0x4D7E825f80bDf85e913E0DD2A2D54927e9dE1594",ERC20:"0x55d398326f99059fF775485246999027B3197955",LIQUIDITY_ROUTER:"0x06d76c78B56D361de01A8903deA8aCEFFe6251d6",BASE_POOL:"0x59E365A627C5A1CE459e8e3489C97Ab2BEd56FEa",QUOTE_POOL:"0xB1E6df749A602892FafB27bb39Fd4F044527121E",ORACLE:"0xcb0F698f8FC931d97520a61296D0cA05688B8836",EIP7702Delegation:"0xF27e4C5bb5328453C37eD000170a3e16D6C68689",MARKET_MANAGER:"0x7fbEAd5ef0cDb301fe0e5555819f1d99F8a08468",DATA_PROVIDER:"0xD689523Ed33479DC9b5A43bC65568b9240c8D612",ORACLE_RESERVE:"0xaBde34Cb13ab013292576F3C5a0919B65C59CE80",FORWARDER:"0x54aE996239e9ca5d37a8933Df752144279aE266c",TRADING_ROUTER:"0xb2aDa5ebc0641fb81c182C1eF4E4bee0dc0Fef98",REIMBURSEMENT:"0xdE1aB9C84DFB0C2e6965889bDE152bEdD97E305a",DISPUTE_COURT:"0xc35EA4657211315de5270d7d882Ea7161F653368"};var ae=r=>{let{isBetaMode:e}=Sr?.getConfigManager()?.getConfig()||{};switch(r){case 421614:return e?od:id;case 59141:return e?ud:sd;case 97:return e?ld:pd;case 56:return cd;default:return {}}};var Ba=r=>r===421614?"0x7e248ec1721639413a280d9e82e2862cae2e6e28":r===59141?"":r===97?"0xe944d7c0f7005a76e898ee3b9ec10479eba9cc02":r===56?"0x8bfc51e1928e91e47c6734983ac018b2fc0adf4e":"";var dd=async(r,e)=>{let t=Ce(r);return pt(e,yn,t)},fd=async(r,e)=>{let t=await yt();return pt(e,yn,t)},lt=async r=>await(await yt())?.getAddress()??void 0,nt=async r=>{let t=ae(r).LIQUIDITY_ROUTER,n=await yt();return pt(t,Du,n)},xn=async(r,e=1)=>{let n=ae(r).POOL_MANAGER,a=e===0?Ce(r):await yt();return pt(n,$c,a)};var Dr=async(r,e=0)=>{let n=ae(r).QUOTE_POOL,a=e===0?Ce(r):await yt();return pt(n,ed,a)},mr=async(r,e=0)=>{let n=ae(r).BASE_POOL,a=e===0?Ce(r):await yt();return pt(n,td,a)},Mr=async(r,e)=>{let t=e,n=await yt();return pt(t,Yt,n)},Lt=async(r,e)=>pt(r,Yt,e),md=async(r,e)=>{let t=e,n=Ce(r);return pt(t,Yt,n)};var hd=async(r,e,t=0)=>{let n=e,a=t===0?Ce(r):await yt();return pt(n,rd,a)},qi=async(r,e=0)=>{let t=ae(r),n=t.MARKET_MANAGER;console.log(t.MARKET_MANAGER);let a=e===0?Ce(r):await yt();return pt(n,gn,a)},Gi=async(r,e=0)=>{let n=ae(r).DATA_PROVIDER,a=e===0?Ce(r):await yt();return pt(n,Li,a)},tt=async(r,e=0)=>{let n=ae(r).FORWARDER,a=e===0?Ce(r):await yt();return pt(n,Ui,a)},yd=async(r,e=0)=>{let n=ae(r).REIMBURSEMENT,a=e===0?Ce(r):await yt();return pt(n,nd,a)},gd=async(r,e=0)=>{let n=ae(r).DISPUTE_COURT,a=e===0?Ce(r):await yt();return pt(n,ad,a)};var Yn={"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 Q1=ethersDecodeError.ErrorDecoder.create();var Ze={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 V1(r){return r?.code===4001}async function $(r){if(V1(r))return {error:Ze[4001]};let e=await Q1.decode(r);if(console.log(e),e.type===ethersDecodeError.ErrorType.UserRejectError||e.name==="ACTION_REJECTED")return {error:Ze[4001]};if(e.type===ethersDecodeError.ErrorType.CustomError){let t=Object.keys(Yn).find(n=>n.toLowerCase()===e.selector.toLowerCase());return t?{error:{code:t,message:Yn[t]}}:{error:{code:r?.code,message:r?.reason||e.reason||r.message}}}return {error:{code:e.type,message:e.reason}}}var bd=async(r,e,t)=>{try{let n=Ce(r),i=new ethers.ethers.Interface(yn).encodeFunctionData("balanceOf",[e]),o={to:t,data:i},s=await n.call(o);return BigInt(s)}catch(n){throw console.error(n),n}};var vd=async(r,e,t,n,a)=>{try{let i=Ce(r),s=new ethers.ethers.Interface(yn).encodeFunctionData("allowance",[e,n]),p={to:t,data:s},c=await i.call(p);return BigInt(c)>=a}catch(i){throw i}};var Ad=async(r,e,t,n,a)=>{try{await(await(await fd(r,t)).approve(n,a))?.wait();}catch(i){throw i}};var Ae=async r=>{if("chainId"in r&&!Ja(r.chainId))throw new Error(Ze[1]);if("slippage"in r&&!(Number(r?.slippage)<=1&&Number(r?.slippage)>0))throw new Error(Ze[4003]);if("amount"in r&&(Number(r.amount)===Number.NaN||Number(r.amount)<0))throw new Error(Ze[4004]);let{tokenAddress:e,contractAddress:t,chainId:n,amount:a,decimals:i,account:o}=r;if(a&&n&&i&&o){let s=ethers.parseUnits(a.toString(),i);if(e){let p=await bd(n,o,e);if(!p||p<s)throw new Error(Ze[3])}t&&e&&(await vd(n,o,e,t,s)||await Ad(n,o,e,t,ethers.MaxUint256));}};var Ye=30,gt=18;var ce=(r,e)=>BigInt(r)*ethers.parseUnits(e.toString(),8)/BigInt(10**8),de=async r=>{try{let e=oe[r],t=Ce(r),{gasPrice:n}=await t.getFeeData();if(!n)throw new Error("Network Error");return {gasPrice:ce(BigInt(n),e.gasPriceRatio)}}catch(e){throw e}},hr=(r,e=.01)=>{let t=ethers.parseUnits("1",8)-ethers.parseUnits(e.toString(),8);return r*t/BigInt(10**8)};var wd=async(r,e)=>await Promise.all(e.map(async n=>{let{publishTime:a,vaa:i,oracleType:o,nativeFee:s,price:p,poolId:c}=n,l=ys(s)?1n:BigInt(s);return {poolId:c,price:p,value:l,publishTime:a,oracleType:o??2,vaa:i}})),Xn=async(r,e)=>{if(!e||!e.length)return;let t=await Br(r,e);return await wd(r,t.data)},xt=async(r,e)=>{if(!e)return;let n=(await Br(r,[e]))?.data?.[0];if(!n)throw new Error(`Unable to get price for ${e} in the deposit`);return (await wd(r,[n]))?.[0]};var Cd=async r=>{try{let{chainId:e,poolId:t}=r,n=oe[e],a=await lt(e);await Ae({account:a,chainId:e});let i=await Xn(e,[t]);if(!i)return;let o=i.map(x=>x.value),s=i.map(x=>({poolId:t,oracleUpdateData:x?.vaa??"0",publishTime:x.publishTime,oracleType:x.oracleType})),p={prices:s,values:o,poolId:t,recipient:a},c=await nt(e),l=await c["claimBasePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"].estimateGas(s,t,a,{value:o[0]}),f=ce(l,n.gasLimitRatio),{gasPrice:h}=await de(e);return await c["claimBasePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"](s,t,a,{gasLimit:f,gasPrice:h,value:o[0]})}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}},Ed=async r=>{try{let{chainId:e,poolIds:t}=r;if(t.length===0)return;let n=oe[e],a=await lt(e);await Ae({account:a,chainId:e});let i=await Xn(e,t);if(!i)return;let o=i.map(w=>({poolId:w.poolId,oracleUpdateData:w?.vaa??"0",publishTime:w.publishTime,oracleType:w.oracleType})),p=i.map(w=>w.value).reduce((w,_)=>_+w,0n),c={prices:o,poolIds:t,value:p,recipient:a},l=await nt(e),f=await l["claimBasePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"].estimateGas(o,t,a,{value:p}),h=ce(f,n.gasLimitRatio),{gasPrice:y}=await de(e);return await l["claimBasePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"](o,t,a,{gasLimit:h,gasPrice:y,value:p})}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var gu=async({chainId:r,amountIn:e,poolId:t,price:n=0n})=>{try{let a=oe[r],i=await mr(r),o=await i.previewLpAmountOut.estimateGas(t,e,n),s=ce(o,a.gasLimitRatio),{gasPrice:p}=await de(r);return await i.previewLpAmountOut(t,e,n,{gasLimit:s,gasPrice:p})}catch(a){throw console.error(a),typeof a=="string"?a:await $(a)}},xu=async({chainId:r,amountIn:e,poolId:t,price:n=0n})=>{try{let a=oe[r],i=await mr(r),o=await i.previewBaseAmountOut.estimateGas(t,e,n),s=ce(o,a.gasLimitRatio),{gasPrice:p}=await de(r);return await i.previewBaseAmountOut(t,e,n,{gasLimit:s,gasPrice:p})}catch(a){throw console.error(a),typeof a=="string"?a:await $(a)}},Pd=async({chainId:r,account:e,poolId:t,amount:n=0})=>{try{if(!r||!e||!t)return;if(!n)return {baseAmountOut:0n,rebateAmount:0n};let a=oe[r],i=18;await Ae({decimals:i,account:e,chainId:r,amount:Number(n)});let o=ethers.parseUnits(n.toString(),i),p=(await Br(r,[t])).data?.[0]?.price||"0",c=ethers.parseUnits(p,30),l=await mr(r),f=await l.previewUserWithdrawData.estimateGas(t,o,e,c),h=ce(f,a.gasLimitRatio),{gasPrice:y}=await de(r),x=await l.previewUserWithdrawData(t,o,e,c,{gasLimit:h,gasPrice:y}),{baseAmountOut:w,rebateAmount:_}=x;return {baseAmountOut:w,rebateAmount:_}}catch(a){throw console.error(a),typeof a=="string"?a:await $(a)}};var ft=async(r,e)=>{try{return !r||!e?void 0:(await Yc(r,e)).data}catch(t){throw typeof t=="string"?t:await $(t)}};function Rd(r){return r.includes(".")?r.split(".")[1].length:0}var Zn=(r=.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(Ze[4006]);return e.map(i=>{let o=ethers.parseUnits(i.amount.toString(),t),s=ethers.parseUnits(i.triggerPrice.toString(),30),p=Rd(i.triggerPrice.toString()),c=ethers.parseUnits(i.triggerPrice.toString(),p),l=hr(o*c*BigInt(10**n)/BigInt(10**(p+t)),r);return {amount:o,triggerPrice:s,triggerType:BigInt(i.triggerType),minQuoteOut:l}})};var Td=async r=>{try{let{poolId:e,chainId:t,amount:n,slippage:a=.01,tpsl:i=[]}=r;await Ae(r);let o=await ft(t,e);if(!o)throw new Error(Ze[4006]);let s=o?.baseDecimals,p=o?.quoteDecimals,c=o?.baseToken,l=oe[t],f=await lt(t),y=ae(t).BASE_POOL;await Ae({tokenAddress:c,contractAddress:y,decimals:s,account:f,chainId:t,amount:n});let x=!(Number(o?.state)===0||Number(o?.state)===1),w=[],_=ethers.parseUnits(n.toString(),s),v=0n,E;if(x){let N=await xt(t,e);if(!N)return;let H=ethers.parseUnits(N.price,30);w.push({poolId:e,oracleUpdateData:N.vaa,publishTime:N.publishTime,oracleType:N.oracleType}),E=await gu({chainId:t,poolId:e,amountIn:_,price:H}),v=N.value;}else E=await gu({chainId:t,poolId:e,amountIn:_});let B=i.map(N=>({amount:n,triggerPrice:N.triggerPrice,triggerType:N.triggerType})),S=Zn(a,B,s,p),D={poolId:e,amountIn:_,minAmountOut:hr(E,a),recipient:f,tpslParams:S},M=await nt(t),G=await M["depositBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(w,D,{value:v}),L=ce(G,l.gasLimitRatio),{gasPrice:z}=await de(t);return await M["depositBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"](w,D,{gasLimit:L,gasPrice:z,value:v})}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var kd=async r=>{try{let{chainId:e,poolId:t,price:n}=r,a=n,i=await mr(e);if(typeof n>"u"||n===null)try{let p=await xt(e,t);a=ethers.parseUnits(p?.price||"0",30);}catch{a=ethers.parseUnits("0",30);}let o={poolId:t,price:a||0n},s=await i.withdrawableLpAmount(t,a||0n);return console.log(`base pool withdrawableLpAmount: ${s}`),s}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}},Bd=async r=>{try{let{chainId:e,poolId:t,amount:n,slippage:a=.01}=r,i=await ft(e,t),o=i?.basePoolToken,s=oe[e],p=await lt(e),c=18;await Ae({tokenAddress:o,decimals:c,account:p,chainId:e,amount:n});let l=ethers.parseUnits(n.toString(),c),f=!(Number(i?.state)===0||Number(i?.state)===1),h=[],y=0n,x;if(f){let M=await xt(e,t);if(!M)return;let G=ethers.parseUnits(M.price,30);h.push({poolId:t,oracleUpdateData:M.vaa,publishTime:M.publishTime,oracleType:M.oracleType}),x=await xu({chainId:e,poolId:t,amountIn:l,price:G}),y=M.value;}else x=await xu({chainId:e,poolId:t,amountIn:l});let w={poolId:t,amountIn:l,minAmountOut:hr(x,a),recipient:p},_=await nt(e),v=await _["withdrawBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"].estimateGas(h,w,{value:y}),E=ce(v,s.gasLimitRatio),{gasPrice:B}=await de(e);return await(await _["withdrawBase((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"](h,w,{gasLimit:E,gasPrice:B,value:y}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var Sd=async r=>{try{let{chainId:e,account:t,poolId:n}=r;if(!e||!t||!n)return;let a=oe[e],i=0n,s=(await Br(e,[n])).data?.[0]?.price||"0",p=ethers.parseUnits(s,30),c=await mr(e),l=await c.pendingUserRebates.estimateGas(n,t,p),f=ce(l,a.gasLimitRatio),{gasPrice:h}=await de(e),y=await c.pendingUserRebates(n,t,p,{gasLimit:f,gasPrice:h});return console.log("pendingUserRebates base result:",{rebates:y?.rebates,genesisRebates:y?.genesisRebates}),{rebates:y?.rebates,genesisRebates:y?.genesisRebates}}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var Dd=async(r,e)=>{if(e)try{let t=await mr(r),n=0n,a=await xt(r,e);return a?.price&&(n=ethers.parseUnits(a.price,30)),await t.getPoolTokenPrice(e,n)}catch(t){throw console.error(t),typeof t=="string"?t:await $(t)}};var Wd={};Na(Wd,{claimQuotePoolRebate:()=>Gd,claimQuotePoolRebates:()=>zd,deposit:()=>Nd,getLpPrice:()=>Hd,getRewards:()=>qd,transfer:()=>Ud,withdraw:()=>Ld,withdrawableLpAmount:()=>Od});var vu=async({chainId:r,amountIn:e,poolId:t,price:n=0n})=>{try{let a=oe[r],i=await Dr(r),o=await i.previewLpAmountOut.estimateGas(t,e,n),s=ce(o,a.gasLimitRatio),{gasPrice:p}=await de(r);return await i.previewLpAmountOut(t,e,n,{gasLimit:s,gasPrice:p})}catch(a){throw console.error(a),typeof a=="string"?a:await $(a)}},Au=async({chainId:r,amountIn:e,poolId:t,price:n=0n})=>{try{let a=oe[r],i=await Dr(r),o=await i.previewQuoteAmountOut.estimateGas(t,e,n),s=ce(o,a.gasLimitRatio),{gasPrice:p}=await de(r);return await i.previewQuoteAmountOut(t,e,n,{gasLimit:s,gasPrice:p})}catch(a){throw console.error(a),typeof a=="string"?a:await $(a)}};var Nd=async r=>{try{let{poolId:e,chainId:t,amount:n,slippage:a=.01,tpsl:i=[]}=r;await Ae(r);let o=await ft(t,e);if(!o)throw new Error(Ze[4006]);let s=oe[t],p=await lt(t),l=ae(t).QUOTE_POOL,f=o.quoteToken,h=o?.quoteDecimals;await Ae({tokenAddress:f,contractAddress:l,decimals:h,account:p,chainId:t,amount:n});let y=ethers.parseUnits(n.toString(),h),x=!(Number(o?.state)===0||Number(o?.state)===1),w=[],_=0n,v;if(x){let W=await xt(t,e);if(!W)return;let N=ethers.parseUnits(W.price,30);w.push({poolId:e,oracleUpdateData:W.vaa,publishTime:W.publishTime,oracleType:W.oracleType}),v=await vu({chainId:t,poolId:e,amountIn:y,price:N}),_=W.value;}else v=await vu({chainId:t,poolId:e,amountIn:y});let E=i.map(W=>({amount:n,triggerPrice:W.triggerPrice,triggerType:W.triggerType})),B=Zn(a,E,h,h),S={poolId:e,amountIn:y,minAmountOut:hr(v,a),recipient:p,tpslParams:B},D=await nt(t),M=await D["depositQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(w,S,{value:_}),G=ce(M,s.gasLimitRatio),{gasPrice:L}=await de(t);return await D["depositQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"](w,S,{gasLimit:G,gasPrice:L,value:_})}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var Od=async r=>{try{let{chainId:e,poolId:t,price:n}=r,a=n,i=await Dr(e);if(typeof n>"u"||n===null)try{let p=await xt(e,t);a=ethers.parseUnits(p?.price||"0",30);}catch{a=ethers.parseUnits("0",30);}let o={poolId:t,price:a||0n},s=await i.withdrawableLpAmount(t,a||0n);return console.log(`quote pool withdrawableLpAmount: ${s}`),s}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}},Ld=async r=>{try{let{chainId:e,poolId:t,amount:n,slippage:a=.01}=r,i=await ft(e,t),o=i?.quotePoolToken,s=oe[e],p=await lt(e),c=18;await Ae({tokenAddress:o,decimals:c,account:p,chainId:e,amount:n});let l=ethers.parseUnits(n.toString(),c),f=!(Number(i?.state)===0||Number(i?.state)===1),h=[],y=0n,x;if(f){let M=await xt(e,t);if(!M)return;let G=ethers.parseUnits(M.price,30);h.push({poolId:t,oracleUpdateData:M.vaa,publishTime:M.publishTime,oracleType:M.oracleType}),x=await Au({chainId:e,poolId:t,amountIn:l,price:G}),y=M.value;}else x=await Au({chainId:e,poolId:t,amountIn:l});let w={poolId:t,amountIn:l,minAmountOut:hr(x,a),recipient:p},_=await nt(e),v=await _["withdrawQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"].estimateGas(h,w,{value:y}),E=ce(v,s.gasLimitRatio),{gasPrice:B}=await de(e);return await(await _["withdrawQuote((bytes32,uint8,uint64,bytes)[],(bytes32,uint256,uint256,address))"](h,w,{gasLimit:E,gasPrice:B,value:y}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var Ud=async(r,e,t,n)=>{try{let a=await ft(r,e),i=await ft(r,t);if(!i||!a)return null;if([3,4].includes(i.state))throw new Error(Ze[4005]);let o=await lt(r),s=oe[r],p=18;await Ae({chainId:r,amount:n,account:o,decimals:p,tokenAddress:a.quotePoolToken});let c={fromPoolId:e,toPoolId:t,minLpOut:0n,amount:ethers.parseUnits(n.toString(),p)},l=await nt(r),f=await l.migrateLiquidity.estimateGas(c),h=ce(f,s.gasLimitRatio),{gasPrice:y}=await de(r);return await l.migrateLiquidity(c,{gasLimit:h,gasPrice:y})}catch(a){throw typeof a=="string"?a:await $(a)}};var qd=async r=>{try{let{chainId:e,account:t,poolId:n}=r;if(!e||!t||!n)return;let a=oe[e],o=(await Br(e,[n])).data?.[0]?.price||"0",s=ethers.parseUnits(o,30),p=await Dr(e),c=await p.pendingUserRebates.estimateGas(n,t,s),l=ce(c,a.gasLimitRatio),{gasPrice:f}=await de(e),h=await p.pendingUserRebates(n,t,s,{gasLimit:l,gasPrice:f});return console.log("pendingUserRebates quote result:",h),h}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var Gd=async r=>{try{let{chainId:e,poolId:t}=r,n=oe[e],a=await lt(e),i=18;await Ae({account:a,chainId:e});let o=await Xn(e,[t]);if(!o)return;let s=o.map(w=>w.value),p=o.map(w=>({poolId:w.poolId,oracleUpdateData:w?.vaa??"0",publishTime:w.publishTime,oracleType:w.oracleType})),c={prices:p,values:s,poolId:t,recipient:a},l=await nt(e),f=await l["claimQuotePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"].estimateGas(p,t,a,{value:s[0]}),h=ce(f,n.gasLimitRatio),{gasPrice:y}=await de(e);return await l["claimQuotePoolRebate((bytes32,uint8,uint64,bytes)[],bytes32,address)"](p,t,a,{gasLimit:h,gasPrice:y,value:s[0]})}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}},zd=async r=>{try{let{chainId:e,poolIds:t}=r;if(t.length===0)return;let n=oe[e],a=await lt(e),i=18;await Ae({account:a,chainId:e});let o=await Xn(e,t);if(!o)return;let s=o.map(_=>({poolId:_.poolId,oracleUpdateData:_?.vaa??"0",publishTime:_.publishTime,oracleType:_.oracleType})),c=o.map(_=>_.value).reduce((_,v)=>v+_,0n),l={prices:s,value:c,poolIds:t,recipient:a},f=await nt(e),h=await f["claimQuotePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"].estimateGas(s,t,a,{value:c}),y=ce(h,n.gasLimitRatio),{gasPrice:x}=await de(e);return await f["claimQuotePoolRebates((bytes32,uint8,uint64,bytes)[],bytes32[],address)"](s,t,a,{gasLimit:y,gasPrice:x,value:c})}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var Hd=async(r,e)=>{if(e)try{let t=await Dr(r),n=0n,a=await xt(r,e);return a?.price&&(n=ethers.parseUnits(a.price,30)),await t.getPoolTokenPrice(e,n)}catch(t){throw console.error(t),typeof t=="string"?t:await $(t)}};var tf={};Na(tf,{PoolType:()=>$d,TriggerType:()=>ef,addTpSl:()=>Jd,cancelTpSl:()=>Yd,createPool:()=>Vd,getMarketPoolId:()=>Wi,getMarketPools:()=>Kd,getOpenOrders:()=>Zd,getPoolDetail:()=>ft,getPoolInfo:()=>Qd,getUserGenesisShare:()=>jd,reprime:()=>Xd});var Wi=async({chainId:r,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(Ze[2]);let n=oe[r],i=ae(r).POOL_MANAGER,o=await xn(r,0),s=[t,e],p=await o.getMarketPool(t,e);return p.poolId==="0x0000000000000000000000000000000000000000000000000000000000000000"||!p.poolId?void 0:p.poolId}catch(n){throw console.error(n),typeof n=="string"?n:await $(n)}},Kd=async r=>{try{let t=await(await xn(r)).getPools();return console.log(t),t||[]}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}},Qd=async(r,e,t=0n)=>{try{let a=await(await Gi(r)).getPoolInfo(e,t);return {quotePool:{poolToken:a.quotePool.poolToken,exchangeRate:a.quotePool.exchangeRate,poolTokenPrice:a.quotePool.poolTokenPrice,poolTokenSupply:a.quotePool.poolTokenSupply,totalDebt:a.quotePool.totalDebt,baseCollateral:a.quotePool.baseCollateral},basePool:{poolToken:a.basePool.poolToken,exchangeRate:a.basePool.exchangeRate,poolTokenPrice:a.basePool.poolTokenPrice,poolTokenSupply:a.basePool.poolTokenSupply,totalDebt:a.basePool.totalDebt,baseCollateral:a.basePool.baseCollateral},reserveInfo:{baseTotalAmount:a.reserveInfo.baseTotalAmount,baseReservedAmount:a.reserveInfo.baseReservedAmount,quoteTotalAmount:a.reserveInfo.quoteTotalAmount,quoteReservedAmount:a.reserveInfo.quoteReservedAmount},fundingInfo:{nextFundingRate:a.fundingInfo.nextFundingRate,lastFundingFeeTracker:a.fundingInfo.lastFundingFeeTracker,nextEpochTime:a.fundingInfo.nextEpochTime},ioTracker:{tracker:a.oi.tracker,longSize:a.oi.longSize,shortSize:a.oi.shortSize,poolEntryPrice:a.oi.poolEntryPrice},liquidityInfo:{windowCaps:a.liquidityInfo.windowCaps,openInterest:a.liquidityInfo.openInterest}}}catch(n){throw console.error(n),typeof n=="string"?n:await $(n)}};var Vd=async({chainId:r,baseToken:e,marketId:t})=>{try{if(!e)throw new Error(Ze[2]);let n=oe[r],a=await xn(r),i={marketId:t,baseToken:e},o=await a.deployPool.estimateGas(i),s=ce(o,n.gasLimitRatio);console.log("gasLimit",o,s);let{gasPrice:p}=await de(r);if(console.log("gasPrice",p),(await(await a.deployPool(i,{gasLimit:s,gasPrice:p}))?.wait())?.hash)return await Wi({chainId:r,baseToken:e,marketId:t})}catch(n){throw console.error(n),typeof n=="string"?n:await $(n)}};var jd=async(r,e,t)=>{try{return await(await hd(r,e)).userGenesisShare(t)}catch(n){throw console.error(n),typeof n=="string"?n:await $(n)}};var Jd=async r=>{try{let{chainId:e,poolId:t,poolType:n,slippage:a=.01,tpsl:i=[]}=r;await Ae(r);let o=await ft(e,t);if(!o)throw new Error(Ze[4006]);let s=18,p=o.quoteDecimals,c=Zn(a,i,s,p),l=oe[e],f=await nt(e),h={poolId:t,poolType:BigInt(n),tpslParams:c},y=await f.addTpsl.estimateGas(h),x=ce(y,l.gasLimitRatio),{gasPrice:w}=await de(e);return await(await f.addTpsl(h,{gasLimit:x,gasPrice:w}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};var Yd=async r=>{try{let{chainId:e,orderId:t}=r;await Ae(r);let n=oe[e],a=await nt(e),i=await a.cancelTpsl.estimateGas(t),o=ce(i,n.gasLimitRatio),{gasPrice:s}=await de(e);return await(await a.cancelTpsl(t,{gasLimit:o,gasPrice:s}))?.wait()}catch(e){throw console.error(e),typeof e=="string"?e:await $(e)}};async function av(r){try{return (await fetch(r,{method:"HEAD"})).ok}catch{return false}}var zk=async(r,e,t)=>{try{let n=await dd(r,e),a=await n.name();console.log(a);let[i,o,s,p]=await Promise.all([n.name(),n.symbol(),n.decimals(),n.totalSupply()]),c=ethers.ethers.getAddress(e),l=`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${r}/assets/${c}/logo.png`,h=await av(l)?l:"",y;if(t){let x=await n.balanceOf(t);y=Number(ethers.ethers.formatUnits(x,s));}return {address:e,name:i,symbol:o,decimals:s,icon:h,totalSupply:Number(ethers.ethers.formatUnits(p,s)),...t?{balance:y}:{}}}catch(n){throw console.error(n),n}};var Xd=async(r,e,t)=>{try{await Ae({chainId:r});let n=await ft(r,e);if(!n)throw new Error(Ze[4006]);let a=await lt(r),o=((Sr?.Markets?.length?Sr?.Markets:await Sr.getMarkets())||[])?.find(w=>w.chainId===r&&w.marketId===t);if(!o)throw new Error("Invalid Market");let s=ethers.parseUnits(o.oracleFeeUsd.toString(),n.quoteDecimals);if(!s)throw new Error("Invalid Market");await Ae({tokenAddress:n.quoteToken,contractAddress:ae(r).ORACLE_RESERVE,decimals:n.quoteDecimals,account:a,chainId:r,amount:Number(ethers.formatUnits(s,n.quoteDecimals))});let p=oe[r],c=await xn(r),l=await c.reprimePool.estimateGas({poolId:e}),f=ce(l,p.gasLimitRatio),{gasPrice:h}=await de(r);return await(await c.reprimePool({poolId:e}))?.wait()}catch(n){throw console.error(n),typeof n=="string"?n:await $(n)}};var Zd=async(r,e)=>{try{let t=await tn.getInstance().getConfigManager()?.getAccessToken();if(!t)throw new Error("Failed to obtain accessToken");return (await Xc(t,e,r)).data||[]}catch(t){throw console.error(t),t}};var $d=(t=>(t[t.Base=0]="Base",t[t.Quote=1]="Quote",t))($d||{}),ef=(t=>(t[t.TP=1]="TP",t[t.SL=2]="SL",t))(ef||{});var af={};Na(af,{getMarket:()=>rf,getOracleFee:()=>nf});var rf=async(r,e)=>{try{if(await Ae({chainId:r}),!e)return;let n=await(await qi(r)).getMarket(e);return console.log("MarketManage.getMarket request",n),n}catch(t){throw console.error(t),typeof t=="string"?t:await $(t)}};var nf=async(r,e)=>{try{return await Ae({chainId:r}),e?await(await qi(r)).getOracleFee(e):void 0}catch(t){throw console.error(t),typeof t=="string"?t:await $(t)}};var lf=wr(uf()),cf=wr(Fr()),ji=(r,e)=>(0, cf.default)(r,{length:32}).toString(lf.default);var Ji=r=>{switch(r.request){case "signin":return ji(r.request)}return ji(JSON.stringify(r))},Da=r=>{let{topic:e,params:t}=r;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 ji(JSON.stringify({topic:e,params:t}))}},ff=({type:r})=>r==="pong"||r==="signin"||r==="subv2"||r==="unsubv2"||r==="ping"||r==="pong",uv=r=>{switch(r){case "order":case "position":case "ticker.*":return r;default:let[e]=r.split(".");return e}},mf=r=>{switch(uv(r.type)){case "ticker":{let[,t=""]=r.type.split(".");return {...r,type:Da({topic:"ticker",params:{globalId:parseInt(t)}}),globalId:parseInt(t)}}case "candle":{let[,t=""]=r.type.split("."),[n,a]=t.split("_");return {...r,type:Da({topic:"candle",params:{globalId:parseInt(n),resolution:a}}),globalId:parseInt(n),resolution:a}}}return r};var $n=class{constructor(e){this.options={...e,logLevel:e?.logLevel||"info"};}debug(e,...t){this.options.logLevel!=="none"&&this.options.logLevel==="debug"&&console.log(`[MYX-SDK-DEBUG] ${e}`,...t);}info(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info")&&console.log(`[MYX-SDK-INFO] ${e}`,...t);}error(e,...t){this.options.logLevel!=="none"&&(this.options.logLevel==="debug"||this.options.logLevel==="info"||this.options.logLevel==="error")&&console.error(`[MYX-SDK-ERROR] ${e}`,...t);}warn(e,...t){this.options.logLevel!=="none"&&console.warn(`[MYX-SDK-WARN] ${e}`,...t);}};var Y=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}`}};var hf={url:"",initialReconnectDelay:1e3,maxReconnectDelay:3e4,reconnectMultiplier:1.5,maxReconnectAttempts:10,maxEnqueuedMessages:100,requestTimeout:1e4,heartbeatInterval:1e4,heartbeatMessage:"ping",noMessageTimeout:5e3,connectionTimeout:1e4},Yi=class{constructor(e){this.ws=null;this.subscriptions=new Map;this.waitingRequests=new Map;this.eventBus=pv__default.default();this.heartbeatIntervalId=null;this.isFirstConnection=true;this.lastMessageTime=0;let t={...e,logLevel:e?.logLevel||"info"},{logLevel:n,...a}=t;this.config={...hf,...a},this.logger=new $n({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 lv__default.default(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(),true}setupEventListeners(e,t){this.ws&&(this.ws.onopen=async n=>{this.eventBus.emit("open",n),console.log("onOPen"),this.lastMessageTime=Date.now(),this.timeoutHeartbeat(),this.isFirstConnection||this.onBeforeReSubscribe().then(()=>this.resubscribeAll()),this.isFirstConnection=false,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=false;}),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 a=Ji(e);this.waitingRequests.has(a)?(this.waitingRequests.get(a)?.onSuccess.add(t),this.waitingRequests.get(a)?.onError.add(n)):this.waitingRequests.set(a,{onSuccess:new Set([t]),onError:new Set([n])}),this.send(e);})}subscribe(e,t){let n=Array.isArray(e)?e:[e],a=[],i=new Set;n.forEach(o=>{let s=Da(o);if(!i.has(s))if(i.add(s),this.subscriptions.has(s))this.subscriptions.get(s).callbacks.add(t);else {let p={id:s,topic:o.topic,callbacks:new Set([t])};this.subscriptions.set(s,p),a.push(s),this.logger.debug(`create new subscription: ${s}`);}}),a.length>0&&this.send({request:"subv2",args:a});}unsubscribe(e,t){if(!e)return;let n=Array.isArray(e)?e:[e],a=[],i=new Set;n.forEach(o=>{let s=Da(o);if(i.has(s))return;i.add(s);let p=this.subscriptions.get(s);p&&(p.callbacks.delete(t),this.logger.debug(`remove callback from subscription: ${s}`),p.callbacks.size===0&&(this.subscriptions.delete(s),a.push(s),this.logger.debug(`subscription ${s} has no callbacks, will unsubscribe`)));}),a.length>0&&this.send({request:"unsubv2",args:a});}send(e){let t=typeof e=="string"?e:JSON.stringify(e);if(!this.ws)throw new Y("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(ff(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=Ji({request:e.type,args:""});break;default:t=Ji({request:e.type,args:e.data.data});break}let n=this.waitingRequests.get(t),a=e.data.code===9200;a?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&&!a&&n.onError.forEach(i=>{i(new Y("REQUEST_FAILED","Request failed"));}),n?.onSuccess.size&&a&&n.onSuccess.forEach(i=>{i(e.data);});}handleSubscriptionMessage(e){let t=mf(e),n=t.type,a=this.subscriptions.get(n);a&&a.callbacks.forEach(i=>{try{i(t);}catch(o){this.logger.error(`Callback Error (${n}): ${o}`);}});}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||hf.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 yf=[56,59144,42161],gf=[59141,421614,97],xf=[97,421614];var Xi={TestNet:"wss://oapi-test.myx.cash/ws",MainNet:"wss://oapi.myx.finance/ws",BetaNet:"wss://oapi-beta.myx.finance/ws"};var Zi=class{constructor(e,t){this.clientAuth=false;this.prevAccessToken="";this.configManager=e,this.logger=t;let n=Xi.MainNet;e.getConfig().isBetaMode?n=Xi.BetaNet:e.getConfig().isTestnet&&(n=Xi.TestNet),this.wsClient=new Yi({logLevel:this.configManager.getConfig()?.logLevel,url:n,...this.configManager.getConfig()?.socketConfig,onBeforeReSubscribe:()=>{if(this.clientAuth)return this.auth(true).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(a=>({topic:"ticker",params:{globalId:a}})),t);}unsubscribeTickers(e,t){let n=Array.isArray(e)?e:[e];this.wsClient.unsubscribe(n.map(a=>({topic:"ticker",params:{globalId:a}})),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 getAccessToken(){let e=await this.configManager.refreshAccessToken()??"";return this.logger.debug(`getAccessToken->${e}`),e}async auth(e=false){let t=await this.getAccessToken();if(t===this.prevAccessToken&&this.clientAuth&&!e)return Promise.resolve();this.logger.debug(`auth ${t}`),await this.wsClient.request({request:"signin",args:`sdk.${t}`}).then(()=>{this.logger.debug(`auth success ${t}`),this.prevAccessToken=t,this.clientAuth=true;});}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);}};var $i=class{constructor(e){this._getAccessTokenQueue=[];this._isGettingAccessToken=false;let t={isTestnet:false,isBetaMode:false,...e};this.validateConfig(t),this.config=t;}clear(){this.accessToken=void 0,this.accessTokenExpiry=void 0,this.config={...this.config,signer:void 0,getAccessToken:void 0};}async startSeamlessMode(e){return this.config={...this.config,seamlessMode:e},this.config}updateSeamlessWallet({wallet:e,authorized:t,masterAddress:n}){this.config={...this.config,seamlessAccount:{masterAddress:n??"",wallet:e??null,authorized:t??false}};}updateClientChainId(e,t){this.config={...this.config,chainId:e,brokerAddress:t};}auth(e){this.clear(),this.config={...this.config,...e},this.validateConfig(this.config);}validateConfig(e){let{isTestnet:t,isBetaMode:n,chainId:a}=e;if(t){if(!gf.includes(a))throw new Y("INVALID_CHAIN_ID",`chainId ${a} is not in the range of TESTNET_CHAIN_IDS`)}else if(n){if(!xf.includes(a))throw new Y("INVALID_CHAIN_ID",`chainId ${a} is not in the range of BETA_ENV_CHAIN_IDS`)}else if(!yf.includes(a))throw new Y("INVALID_CHAIN_ID",`chainId ${a} is not in the range of MAINNET_CHAIN_IDS`)}async getAccessToken(){return this.accessToken??null}async refreshAccessToken(e=false){return new Promise((t,n)=>{this._getAccessTokenQueue.push({resolve:t,reject:n,forceRefresh:e}),this._processAccessTokenQueue();})}_processAccessTokenQueue(){if(this._isGettingAccessToken)return;this._isGettingAccessToken=true;let e=this._getAccessTokenQueue.shift();e?this._refreshAccessToken(e.forceRefresh).then(e.resolve).catch(e.reject).finally(()=>{this._isGettingAccessToken=false,this._getAccessTokenQueue.length>0&&this._processAccessTokenQueue();}):this._isGettingAccessToken=false;}async _refreshAccessToken(e=false){if(!e&&this.isAccessTokenValid())return this._isGettingAccessToken=false,this.accessToken;if(!this.config.getAccessToken)return console.warn("No getAccessToken method provided in config"),null;try{console.log("Manually refreshing accessToken...");let t=await this.config.getAccessToken()??{accessToken:"",expireAt:0};if(t&&t.accessToken){let n=3600;if(t.expireAt){let a=Math.floor(Date.now()/1e3);n=t.expireAt-a,n<=0&&(console.warn("Received expired token, using default expiry"),n=3600);}return this.setAccessToken(t.accessToken,n),console.log("\u2705 AccessToken refreshed and stored successfully",{expiryInSeconds:n,expireAt:t.expireAt}),t.accessToken}else return console.warn("\u274C Received empty accessToken"),null}catch(t){return console.error("\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 eo=class{constructor(e,t,n){this.configManager=e,this.utils=t,this.api=n;}getMarkets(){return Promise.resolve([])}async getPoolLevelConfig(e,t){this.configManager.getConfig();return (await this.api.getPoolLevelConfig({poolId:e,chainId:t})).data}async getKlineList({interval:e,...t}){this.configManager.getConfig();return (await this.api.getKlineData({...t,interval:this.utils.transferKlineResolutionToInterval(e)})).data}async getKlineLatestBar({interval:e,...t}){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}};var to=class{constructor(e,t,n,a,i,o){this.configManager=e,this.logger=t,this.utils=n,this.seamless=a,this.account=i,this.api=o;}async listPositions(e){let t=await this.configManager.getAccessToken();try{return {code:0,data:(await this.api.getPositions(t??"",e)).data}}catch(n){return console.error("Error fetching positions:",n),{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:a,chainId:i,address:o}){let s=this.configManager.getConfig();try{let p=await this.utils.getOraclePrice(e,i);if(!p)throw new Error("Failed to get price data");let c={poolId:e,oracleType:p.oracleType,oracleUpdateData:p?.vaa??"0",publishTime:p.publishTime},l=!1;Number(n)>0&&(l=await this.utils.needsApproval(o,i,a,n,ae(i).TRADING_ROUTER));let f=this.configManager.getConfig().seamlessAccount?.authorized,h=this.configManager.getConfig().seamlessAccount?.wallet,y=BigInt(0),x=BigInt(n)>0?BigInt(n):0n,w=await this.account.getAvailableMarginBalance({poolId:e,chainId:i,address:o}),_=BigInt(0);w<x&&(_=x-w,y=_);let v={token:a,amount:y.toString()};if(s.seamlessMode&&f&&h){if(!await this.utils.checkSeamlessGas(s.seamlessAccount?.masterAddress,i))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let M=await tt(i),L=(await Lt(this.configManager.getConfig().brokerAddress,h)).interface.encodeFunctionData("updatePriceAndAdjustCollateral",[[c],v,t,n]),z=await M.nonces(h.address),W={from:h.address??"",to:this.configManager.getConfig().brokerAddress,value:(p?.value??"1").toString(),gas:"10000000",deadline:Or__default.default().add(60,"minute").unix(),data:L,nonce:z.toString()};return this.logger.info("adjust collateral forward tx params --->",W),{code:0,message:"adjust collateral success",data:await this.seamless.forwarderTx(W,i,h)}}if(!s.signer)throw new Y("INVALID_SIGNER","Invalid signer");let E=pt(s.brokerAddress,Yt,s.signer);if(l){let D=await this.utils.approveAuthorization({chainId:i,quoteAddress:a,amount:ethers.ethers.MaxUint256.toString(),spenderAddress:ae(i).TRADING_ROUTER});if(D.code!==0)throw new Error(D.message)}return this.logger.info("adjustCollateral transaction data--->",{updateParams:c,depositData:v,positionId:t,adjustAmount:n,txParams:{value:BigInt(p?.value??"1"),gas:BigInt(1e7)*At[i]/100n}}),{code:0,data:{hash:await(await E.updatePriceAndAdjustCollateral([c],v,t,n,{value:BigInt(p?.value??"1"),gas:BigInt(1e7)*At[i]/100n})).wait()},message:"Adjust collateral transaction submitted"}}catch(p){console.log(p,"error");let c=await this.utils.getErrorMessage(p);return this.logger.error("adjustCollateral error-->",c),{code:-1,message:c}}}};var fv={IOC:0},bn=fv.IOC;var ro={MARKET:0,LIMIT:1,STOP:2,CONDITIONAL:3},qS={NONE:0,GTE:1,LTE:2},vn={INCREASE:0,DECREASE:1},GS={LONG:0,SHORT:1},zS={IOC:0},HS={PENDING:0,PARTIAL:1,FILLED:2,CANCELLED:3,REJECTED:4,EXPIRED:5};var no=class{constructor(e,t,n,a,i,o){this.configManager=e,this.logger=t,this.utils=n,this.seamless=a,this.account=i,this.api=o;}async createIncreaseOrder(e,t,n){try{let a=this.configManager.getConfig(),i=await this.utils.getNetworkFee(n,e.chainId),o=BigInt(i);e.tpSize&&BigInt(e.tpSize)>0&&(o+=BigInt(i)),e.slSize&&BigInt(e.slSize)>0&&(o+=BigInt(i));let s=BigInt(e.collateralAmount)+BigInt(t),p=await this.account.getAvailableMarginBalance({poolId:e.poolId,chainId:e.chainId,address:e.address}),c=s+o,l=BigInt(0),f=c-p;f>BigInt(0)&&(l=f);let h={token:e.executionFeeToken,amount:l.toString()},y={user:e.address,poolId:e.poolId,orderType:e.orderType,triggerType:e.triggerType,operation:vn.INCREASE,direction:e.direction,collateralAmount:s.toString(),size:e.size,price:e.price,timeInForce:bn,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"},x=this.configManager.getConfig().seamlessAccount?.authorized,w=this.configManager.getConfig().seamlessAccount?.wallet;if(a.seamlessMode&&x&&w){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let M=await tt(e.chainId),G=await Lt(this.configManager.getConfig().brokerAddress,w),L="";e.positionId?L=G.interface.encodeFunctionData("placeOrderWithPosition",[e.positionId.toString(),{...h},y]):(this.logger.info("createIncreaseOrder placeOrderWithSalt data --->",["1",{...h},y]),L=G.interface.encodeFunctionData("placeOrderWithSalt",["1",{...h},y]));let z=await M.nonces(w.address),W={from:w.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:L,nonce:z.toString()};return this.logger.info("createIncreaseOrder forward tx params --->",W),{code:0,message:"create increase order success",data:await this.seamless.forwarderTx(W,e.chainId,w)}}let _=await this.utils.needsApproval(e.address,e.chainId,e.executionFeeToken,e.collateralAmount,ae(e.chainId).TRADING_ROUTER);if(!a.signer)throw new Y("INVALID_SIGNER","Invalid signer");if(_){let D=await this.utils.approveAuthorization({chainId:e.chainId,quoteAddress:e.executionFeeToken,amount:ethers.ethers.MaxUint256.toString(),spenderAddress:ae(e.chainId).TRADING_ROUTER});if(D.code!==0)throw new Error(D.message)}let v=await Mr(e.chainId,this.configManager.getConfig().brokerAddress),E;if(e.positionId){this.logger.info("createIncreaseOrder nft position params--->",{...y,positionId:e.positionId});let D=await v.placeOrderWithPosition.estimateGas(e.positionId.toString(),{...h},y);E=await v.placeOrderWithPosition(e.positionId.toString(),{...h},y,{gasLimit:D*At[e.chainId]/100n});}else {this.logger.info("createIncreaseOrder salt position params--->",{positionSalt:"1",data:y,depositData:h});let M=await v.placeOrderWithSalt.estimateGas("1",{...h},y);E=await v.placeOrderWithSalt("1",{...h},y,{gasLimit:M*At[e.chainId]/100n});}let B=await E.wait();return {code:0,message:"create increase order success",data:{success:!0,transactionHash:E.hash,blockNumber:B?.blockNumber,gasUsed:B?.gasUsed?.toString(),status:B?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:B}}}catch(a){return this.logger.error("Error placing order:",a),{code:-1,message:a?.message}}}async closeAllPositions(e,t){try{let n=this.configManager.getConfig(),a={token:"0x0000000000000000000000000000000000000000",amount:"0"},i=t.map(y=>y.positionId.toString()),o=t.map(y=>({user:y.address,poolId:y.poolId,orderType:y.orderType,triggerType:y.triggerType,operation:vn.DECREASE,direction:y.direction,collateralAmount:y.collateralAmount,size:y.size,price:y.price,timeInForce:bn,postOnly:y.postOnly,slippagePct:y.slippagePct,leverage:y.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0}));this.logger.info("closeAllPositions params--->",a,i,o);let s=this.configManager.getConfig().seamlessAccount?.authorized,p=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&s&&p){if(!await this.utils.checkSeamlessGas(t[0].address,e))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let x=await tt(e),_=(await Lt(this.configManager.getConfig().brokerAddress,p)).interface.encodeFunctionData("placeOrdersWithPosition",[a,i,o]),v=await x.nonces(p.address),E={from:p.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:_,nonce:v.toString()};this.logger.info("cancel all positions forward tx params --->",E);let B=await this.seamless.forwarderTx(E,e,p);return console.log("rs-->",B),{code:0,message:"cancel all positions success",data:B}}if(!n.signer)throw new Y("INVALID_SIGNER","Invalid signer");let c=await Mr(e,this.configManager.getConfig().brokerAddress),l=await c.placeOrdersWithPosition.estimateGas(a,i,o),f=await c.placeOrdersWithPosition(a,i,o,{gasLimit:l*At[e]/100n}),h=await f.wait();return {code:0,message:"close all positions success",transactionHash:f.hash,blockNumber:h?.blockNumber,gasUsed:h?.gasUsed?.toString(),status:h?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:h}}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:vn.DECREASE,direction:e.direction,collateralAmount:e.collateralAmount,size:e.size,price:e.price,timeInForce:bn,postOnly:e.postOnly,slippagePct:e.slippagePct,leverage:e.leverage,tpSize:0,tpPrice:0,slSize:0,slPrice:0},a={token:"0x0000000000000000000000000000000000000000",amount:"0"},i=this.configManager.getConfig().seamlessAccount?.authorized,o=this.configManager.getConfig().seamlessAccount?.wallet;if(t.seamlessMode&&i&&o){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let h=await tt(e.chainId),y=await Lt(this.configManager.getConfig().brokerAddress,o),x="";e.positionId?x=y.interface.encodeFunctionData("placeOrderWithPosition",[e.positionId.toString(),{...a},n]):x=y.interface.encodeFunctionData("placeOrderWithSalt",["1",{...a},n]);let w=await h.nonces(o.address),_={from:o.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:x,nonce:w.toString()};return this.logger.info("create decrease order forward tx params --->",_),{code:0,message:"create decrease order success",data:await this.seamless.forwarderTx(_,e.chainId,o)}}if(!t.signer)throw new Y("INVALID_SIGNER","Invalid signer");let s=await Mr(e.chainId,this.configManager.getConfig().brokerAddress),p;if(e.positionId){this.logger.info("createDecreaseOrder nft position params--->",[e.positionId,a,{data:n}]);let f=await s.placeOrderWithPosition.estimateGas(e.positionId.toString(),a,n);p=await s.placeOrderWithPosition(e.positionId.toString(),a,n,{gasLimit:f*At[e.chainId]/100n});}else {this.logger.info("createDecreaseOrder salt position params--->",[1,a,{data:n}]);let h=await s.placeOrderWithSalt.estimateGas("1",a,n);p=await s.placeOrderWithSalt("1",a,n,{gasLimit:h*At[e.chainId]/100n});}let c=await p.wait();return {code:0,message:"create decrease order success",data:{success:!0,transactionHash:p.hash,blockNumber:c?.blockNumber,gasUsed:c?.gasUsed?.toString(),status:c?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:c}}}catch(t){return {code:-1,message:t?.message}}}async createPositionTpSlOrder(e){try{let t=this.configManager.getConfig();if(!t.signer&&!t.seamlessMode)throw new Y("INVALID_SIGNER","Invalid signer");let n=await Mr(e.chainId,this.configManager.getConfig().brokerAddress);try{if(e.tpSize!=="0"&&e.slSize!=="0"){let f=[{user:e.address,poolId:e.poolId,orderType:ro.STOP,triggerType:e.tpTriggerType,operation:vn.DECREASE,direction:e.direction,collateralAmount:"0",size:e.tpSize??"0",price:e.tpPrice??"0",timeInForce:bn,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},{user:e.address,poolId:e.poolId,orderType:ro.STOP,triggerType:e.slTriggerType,operation:vn.DECREASE,direction:e.direction,collateralAmount:"0",size:e.slSize??"0",price:e.slPrice??"0",timeInForce:bn,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:e.leverage,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"}],h={token:"0x0000000000000000000000000000000000000000",amount:"0"},y=this.configManager.getConfig().seamlessAccount?.authorized,x=this.configManager.getConfig().seamlessAccount?.wallet;if(t.seamlessMode&&y&&x){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let B=await tt(e.chainId),S=await Lt(this.configManager.getConfig().brokerAddress,x),D="";e.positionId?D=S.interface.encodeFunctionData("placeOrdersWithPosition",[h,[e.positionId.toString(),e.positionId.toString()],f]):D=S.interface.encodeFunctionData("placeOrdersWithSalt",[h,["1","1"],f]);let M=await B.nonces(x.address),G={from:x.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:D,nonce:M.toString()};this.logger.info("createPositionTpSlOrder forward tx params --->",G);let L=await this.seamless.forwarderTx(G,e.chainId,x);return console.log("rs-->",L),{code:0,message:"createPositionTpSlOrder success",data:L}}let w;if(e.positionId){let E=await n.placeOrdersWithPosition.estimateGas(h,[e.positionId.toString(),e.positionId.toString()],f);w=await n.placeOrdersWithPosition(h,[e.positionId.toString(),e.positionId.toString()],f,{gasLimit:E*At[e.chainId]/100n});}else {this.logger.info("createPositionTpSlOrder salt position data--->",f);let E=1,B=await n.placeOrdersWithSalt.estimateGas(h,[E.toString(),E.toString()],f);w=await n.placeOrdersWithSalt(h,[E.toString(),E.toString()],f,{gasLimit:B*At[e.chainId]/100n});}let _=await w.wait();return {code:0,message:"create decrease order success",data:{success:!0,transactionHash:w.hash,blockNumber:_?.blockNumber,gasUsed:_?.gasUsed?.toString(),status:_?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:_}}}let a={user:e.address,poolId:e.poolId,orderType:ro.STOP,triggerType:e.tpSize!=="0"?e.tpTriggerType:e.slTriggerType,operation:vn.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:bn,postOnly:!1,slippagePct:e.slippagePct??"0",leverage:0,tpSize:"0",tpPrice:"0",slSize:"0",slPrice:"0"},i={token:"0x0000000000000000000000000000000000000000",amount:"0"},o=this.configManager.getConfig().seamlessAccount?.authorized,s=this.configManager.getConfig().seamlessAccount?.wallet;if(t.seamlessMode&&o&&s){if(!await this.utils.checkSeamlessGas(e.address,e.chainId))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let h=await tt(e.chainId),y=await Lt(this.configManager.getConfig().brokerAddress,s),x="";e.positionId?x=y.interface.encodeFunctionData("placeOrderWithPosition",[e.positionId.toString(),i,a]):x=y.interface.encodeFunctionData("placeOrderWithSalt",["1",i,a]);let w=await h.nonces(s.address),_={from:s.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:x,nonce:w.toString()};this.logger.info("createPositionTpSlOrder forward tx params --->",_);let v=await this.seamless.forwarderTx(_,e.chainId,s);return console.log("rs-->",v),{code:0,message:"createPositionTpSlOrder success",data:v}}let p;if(e.positionId){this.logger.info("createPositionTpOrSlOrder nft position data--->",a);let f=await n.placeOrderWithPosition.estimateGas(e.positionId.toString(),i,a);p=await n.placeOrderWithPosition(e.positionId.toString(),i,a,{gasLimit:f*At[e.chainId]/100n});}else {this.logger.info("createPositionTpOrSlOrder salt position data--->",a);let f=1,h=await n.placeOrderWithSalt.estimateGas(f.toString(),i,a);p=await n.placeOrderWithSalt(f.toString(),i,a,{gasLimit:h*At[e.chainId]/100n});}let c=await p.wait();return {code:0,message:"create decrease order success",data:{success:!0,transactionHash:p.hash,blockNumber:c?.blockNumber,gasUsed:c?.gasUsed?.toString(),status:c?.status===1?"success":"failed",confirmations:1,timestamp:Date.now(),receipt:c}}}catch(a){return {code:-1,message:a?.message}}}catch(t){return {code:-1,message:t?.message}}}async cancelAllOrders(e,t){try{let n=this.configManager.getConfig(),a=this.configManager.getConfig().seamlessAccount?.authorized,i=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&a&&i){if(!await this.utils.checkSeamlessGas(n.seamlessAccount?.masterAddress,t))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let c=await tt(t),f=(await Lt(this.configManager.getConfig().brokerAddress,i)).interface.encodeFunctionData("cancelOrders",[e]),h=await c.nonces(i.address),y={from:i.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:f,nonce:h.toString()};this.logger.info("create decrease order forward tx params --->",y);let x=await this.seamless.forwarderTx(y,t,i);return console.log("rs-->",x),{code:0,message:"create decrease order success",data:x}}if(!n.signer)throw new Y("INVALID_SIGNER","Invalid signer");return await(await(await Mr(t,this.configManager.getConfig().brokerAddress)).cancelOrders(e)).wait(),{code:0,message:"cancel all orders success"}}catch(n){return {code:-1,message:n?.message}}}async cancelOrder(e,t){try{let n=this.configManager.getConfig(),a=this.configManager.getConfig().seamlessAccount?.authorized,i=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&a&&i){if(!await this.utils.checkSeamlessGas(n.seamlessAccount?.masterAddress,t))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let c=await Lt(this.configManager.getConfig().brokerAddress,i),l=await tt(t),f=c.interface.encodeFunctionData("cancelOrder",[BigInt(e)]),h=await l.nonces(i.address),y={from:i.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:f,nonce:h.toString()};return this.logger.info("createIncreaseOrder forward tx params --->",y),{code:0,message:"cancel order success",data:await this.seamless.forwarderTx(y,t,i)}}if(!n.signer)throw new Y("INVALID_SIGNER","Invalid signer");return await(await(await Mr(t,this.configManager.getConfig().brokerAddress)).cancelOrder(e)).wait(),{code:0,message:"cancel order success"}}catch(n){return {code:-1,message:n?.message}}}async cancelOrders(e,t){try{let n=this.configManager.getConfig(),a=this.configManager.getConfig().seamlessAccount?.authorized,i=this.configManager.getConfig().seamlessAccount?.wallet;if(n.seamlessMode&&a&&i){if(!await this.utils.checkSeamlessGas(n.seamlessAccount?.masterAddress,t))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let c=await tt(t),f=(await Lt(this.configManager.getConfig().brokerAddress,i)).interface.encodeFunctionData("cancelOrders",[e]),h=await c.nonces(i.address),y={from:i.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:f,nonce:h.toString()};return this.logger.info("cancel orders forward tx params --->",y),{code:0,message:"cancel orders success",data:await this.seamless.forwarderTx(y,t,i)}}if(!n.signer)throw new Y("INVALID_SIGNER","Invalid signer");return await(await(await Mr(t,this.configManager.getConfig().brokerAddress)).cancelOrders(e)).wait(),{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,a,i,o){let s=this.configManager.getConfig(),p=await this.utils.getNetworkFee(i,n),c={orderId:e.orderId,size:e.size,price:e.price,tpsl:{tpSize:o?e.tpSize:"0",tpPrice:o?e.tpPrice:"0",slSize:o?e.slSize:"0",slPrice:o?e.slPrice:"0"}},l={token:t,amount:p.toString()},f=this.configManager.getConfig().seamlessAccount?.authorized,h=this.configManager.getConfig().seamlessAccount?.wallet;if(s.seamlessMode&&f&&h){if(!await this.utils.checkSeamlessGas(s.seamlessAccount?.masterAddress,n))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let w=await Lt(this.configManager.getConfig().brokerAddress,h),_=await tt(n),v=w.interface.encodeFunctionData("updateOrder",[l,c]),E=await _.nonces(h.address),B={from:h.address??"",to:this.configManager.getConfig().brokerAddress,value:"0",gas:"800000",deadline:Or__default.default().add(60,"minute").unix(),data:v,nonce:E.toString()};return this.logger.info("createIncreaseOrder forward tx params --->",B),{code:0,message:"update order success",data:await this.seamless.forwarderTx(B,n,h)}}if(!s.signer)throw new Y("INVALID_SIGNER","Invalid signer");let y=await Mr(n,s.brokerAddress);this.logger.info("updateOrderTpSl params",c);try{if(await this.utils.needsApproval(a,n,e.executionFeeToken,p.toString(),ae(n).TRADING_ROUTER)){let E=await this.utils.approveAuthorization({chainId:n,quoteAddress:e.executionFeeToken,amount:ethers.ethers.MaxUint256.toString(),spenderAddress:ae(n).TRADING_ROUTER});if(E.code!==0)throw new Error(E.message)}let w=await y.updateOrder.estimateGas(l,c),v=await(await y.updateOrder(l,c,{gasLimit:w*At[n]/100n}))?.wait();return this.logger.info("updateOrderTpSl receipt",v),{code:0,data:v,message:"update order success"}}catch(x){return this.logger.error("Error updating order:",x),{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 console.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}}};var Cu=[{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:false,name:"BlockHeader",inputs:[{type:"uint256",name:"blockNumber",indexed:false},{type:"uint256",name:"blockTimestamp",indexed:false},{type:"uint256",name:"sequence",indexed:false}]},{type:"event",anonymous:false,name:"CollateralAccepted",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"quoteDebt",indexed:false},{type:"uint256",name:"baseCollateral",indexed:false},{type:"uint256",name:"quoteCollateral",indexed:false},{type:"uint256",name:"totalQuoteDebt",indexed:false},{type:"uint256",name:"totalBaseCollateral",indexed:false}]},{type:"event",anonymous:false,name:"CollateralAdjusted",inputs:[{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"uint8",name:"direction",indexed:false},{type:"uint256",name:"beforeCollateralAmount",indexed:false},{type:"uint256",name:"afterCollateralAmount",indexed:false}]},{type:"event",anonymous:false,name:"EnterDispute",inputs:[{type:"bytes32",name:"poolId",indexed:false}]},{type:"event",anonymous:false,name:"Exchanged",inputs:[{type:"address",name:"user",indexed:false},{type:"address",name:"source",indexed:false},{type:"address",name:"target",indexed:false},{type:"uint256",name:"sourceAmount",indexed:false},{type:"uint256",name:"targetAmount",indexed:false},{type:"uint256",name:"price",indexed:false}]},{type:"event",anonymous:false,name:"ExecutionMatched",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256[]",name:"triggerOrderIds",indexed:false},{type:"uint256[]",name:"matchedOrderIds",indexed:false},{type:"uint8",name:"matchType",indexed:false},{type:"uint256",name:"price",indexed:false}]},{type:"event",anonymous:false,name:"ExitDispute",inputs:[{type:"bytes32",name:"poolId",indexed:false}]},{type:"event",anonymous:false,name:"FeeDistributed",inputs:[{type:"address",name:"user",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"int32",name:"tradingFeeRate",indexed:false},{type:"bool",name:"isMaker",indexed:false},{type:"int256",name:"tradingFee",indexed:false},{type:"uint256",name:"baseTradingFee",indexed:false},{type:"uint256",name:"brokerTradingFee",indexed:false},{type:"address",name:"broker",indexed:false},{type:"uint256",name:"referralRebate",indexed:false},{type:"uint256",name:"referrerRebate",indexed:false},{type:"address",name:"referrer",indexed:false},{type:"int256",name:"reserveFee",indexed:false}]},{type:"event",anonymous:false,name:"FundingRateUpdated",inputs:[{type:"uint64",name:"epochs",indexed:false},{type:"uint64",name:"duration",indexed:false},{type:"uint64",name:"previousEpochTime",indexed:false},{type:"uint64",name:"lastEpochTime",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"int256",name:"fundingRate",indexed:false},{type:"int256",name:"fundingRateTracker",indexed:false},{type:"uint256",name:"price",indexed:false}]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"LiquidityLockUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint64",name:"windowAnchor",indexed:false},{type:"uint256",name:"priceFloor",indexed:false},{type:"uint256",name:"priceCeiling",indexed:false},{type:"int256",name:"openInterest",indexed:false}]},{type:"event",anonymous:false,name:"LiquidityMigrated",inputs:[{type:"address",name:"user",indexed:false},{type:"bytes32",name:"fromPoolId",indexed:false},{type:"bytes32",name:"toPoolId",indexed:false},{type:"uint256",name:"lpAmountIn",indexed:false},{type:"uint256",name:"lpAmountOut",indexed:false}]},{type:"event",anonymous:false,name:"LiquidityStopOrderCancelled",inputs:[{type:"uint256",name:"orderId",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"string",name:"reason",indexed:false}]},{type:"event",anonymous:false,name:"LiquidityStopOrderCreated",inputs:[{type:"uint256",name:"orderId",indexed:false},{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"uint8",name:"poolType",indexed:false},{type:"uint256",name:"amount",indexed:false},{type:"uint256",name:"triggerPrice",indexed:false},{type:"uint8",name:"triggerType",indexed:false},{type:"uint256",name:"minQuoteOut",indexed:false}]},{type:"event",anonymous:false,name:"LiquidityStopOrderExecuted",inputs:[{type:"uint256",name:"orderId",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"executor",indexed:false},{type:"uint256",name:"oraclePrice",indexed:false},{type:"uint256",name:"poolTokenPrice",indexed:false}]},{type:"event",anonymous:false,name:"MarketCreated",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"address",name:"deployer",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint32",name:"baseReserveRatio",indexed:false},{type:"uint32",name:"quoteReserveRatio",indexed:false},{type:"uint64",name:"oracleFeeUsd",indexed:false},{type:"uint64",name:"oracleRefundFeeUsd",indexed:false},{type:"uint128",name:"poolPrimeThreshold",indexed:false}]},{type:"event",anonymous:false,name:"OrderCancelled",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"string",name:"remark",indexed:false}]},{type:"event",anonymous:false,name:"OrderFilled",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"uint8",name:"orderType",indexed:false},{type:"uint256",name:"orderSize",indexed:false},{type:"uint256",name:"fillSize",indexed:false},{type:"uint256",name:"filledSize",indexed:false},{type:"uint256",name:"orderPrice",indexed:false},{type:"uint256",name:"fillPrice",indexed:false},{type:"int256",name:"realizedPnl",indexed:false},{type:"int256",name:"tradingFee",indexed:false},{type:"int256",name:"fundingFee",indexed:false},{type:"uint256",name:"executionFeeAmount",indexed:false},{type:"address",name:"keeper",indexed:false}]},{type:"event",anonymous:false,name:"OrderMarkedADL",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"uint256",name:"available",indexed:false},{type:"uint256",name:"requested",indexed:false}]},{type:"event",anonymous:false,name:"OrderPlaced",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"uint8",name:"orderType",indexed:false},{type:"uint8",name:"operation",indexed:false},{type:"uint8",name:"direction",indexed:false},{type:"uint8",name:"triggerType",indexed:false},{type:"uint256",name:"collateralAmount",indexed:false},{type:"uint256",name:"size",indexed:false},{type:"uint256",name:"price",indexed:false},{type:"uint8",name:"tif",indexed:false},{type:"bool",name:"postOnly",indexed:false},{type:"uint16",name:"slippagePct",indexed:false},{type:"uint256",name:"executionFeeAmount",indexed:false},{type:"uint16",name:"userLeverage",indexed:false}]},{type:"event",anonymous:false,name:"OrderUpdated",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"uint256",name:"size",indexed:false},{type:"uint256",name:"price",indexed:false},{type:"uint256",name:"tpSize",indexed:false},{type:"uint256",name:"tpPrice",indexed:false},{type:"uint256",name:"slSize",indexed:false},{type:"uint256",name:"slPrice",indexed:false}]},{type:"event",anonymous:false,name:"PoolActivated",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint8",name:"oracleType",indexed:false},{type:"bytes32",name:"oracleFeedId",indexed:false}]},{type:"event",anonymous:false,name:"PoolDeactivated",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"string",name:"remark",indexed:false}]},{type:"event",anonymous:false,name:"PoolDeployed",inputs:[{type:"bytes32",name:"marketId",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"deployer",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"address",name:"basePoolToken",indexed:false},{type:"address",name:"quotePoolToken",indexed:false}]},{type:"event",anonymous:false,name:"PoolDeposited",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"user",indexed:false},{type:"address",name:"recipient",indexed:false},{type:"address",name:"underlyingToken",indexed:false},{type:"address",name:"poolToken",indexed:false},{type:"uint256",name:"underlyingIn",indexed:false},{type:"uint256",name:"poolTokenOut",indexed:false},{type:"uint256",name:"oraclePrice",indexed:false},{type:"uint256",name:"exchangeRate",indexed:false},{type:"uint256",name:"poolTokenPrice",indexed:false}]},{type:"event",anonymous:false,name:"PoolFundDistributed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"profits",indexed:false},{type:"uint256",name:"genesisProfits",indexed:false},{type:"uint256",name:"basePoolAmount",indexed:false},{type:"uint256",name:"quotePoolAmount",indexed:false},{type:"uint256",name:"genesisBasePoolAmount",indexed:false},{type:"uint256",name:"genesisQuotePoolAmount",indexed:false},{type:"uint256",name:"exchangedBaseFromProfits",indexed:false},{type:"uint256",name:"exchangedBaseAmount",indexed:false}]},{type:"event",anonymous:false,name:"PoolFundingFeeSettled",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"int256",name:"prevFundingRateTracker",indexed:false},{type:"int256",name:"nextFundingRateTracker",indexed:false},{type:"uint256",name:"price",indexed:false},{type:"uint8",name:"direction",indexed:false},{type:"uint256",name:"positionSize",indexed:false},{type:"uint256",name:"fundingFee",indexed:false}]},{type:"event",anonymous:false,name:"PoolPreDeactivated",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"string",name:"remark",indexed:false}]},{type:"event",anonymous:false,name:"PoolPrimed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint256",name:"baseAmount",indexed:false},{type:"uint256",name:"quoteAmount",indexed:false}]},{type:"event",anonymous:false,name:"PoolRebateClaimed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"user",indexed:false},{type:"address",name:"recipient",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"PoolRefunded",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"receiver",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint256",name:"baseAmount",indexed:false},{type:"uint256",name:"quoteAmount",indexed:false}]},{type:"event",anonymous:false,name:"PoolReprimed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"primer",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"PoolSettlementRecorded",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"uint256",name:"poolEntryPrice",indexed:false},{type:"int256",name:"realizedPnl",indexed:false}]},{type:"event",anonymous:false,name:"PoolWithdrawn",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"user",indexed:false},{type:"address",name:"recipient",indexed:false},{type:"address",name:"underlyingToken",indexed:false},{type:"address",name:"poolToken",indexed:false},{type:"uint256",name:"poolTokenIn",indexed:false},{type:"uint256",name:"underlyingOut",indexed:false},{type:"uint256",name:"rebateOut",indexed:false},{type:"uint256",name:"oraclePrice",indexed:false},{type:"uint256",name:"exchangeRate",indexed:false},{type:"uint256",name:"poolTokenPrice",indexed:false}]},{type:"event",anonymous:false,name:"PositionEarlyClosed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"uint256",name:"positionSize",indexed:false},{type:"uint256",name:"executeSize",indexed:false},{type:"uint256",name:"executePrice",indexed:false}]},{type:"event",anonymous:false,name:"PositionForceClosed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"uint256",name:"positionSize",indexed:false},{type:"uint256",name:"executePrice",indexed:false},{type:"string",name:"reason",indexed:false}]},{type:"event",anonymous:false,name:"PositionLiquidated",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"uint256",name:"positionSize",indexed:false},{type:"uint256",name:"liquidationSize",indexed:false},{type:"uint256",name:"liquidationPrice",indexed:false}]},{type:"event",anonymous:false,name:"PositionNFTMinted",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"oldPositionId",indexed:false},{type:"bytes32",name:"newPositionId",indexed:false},{type:"uint256",name:"tokenId",indexed:false},{type:"address",name:"owner",indexed:false},{type:"address",name:"recipient",indexed:false}]},{type:"event",anonymous:false,name:"PositionRiskControlDataMigrated",inputs:[{type:"bytes32",name:"from",indexed:false},{type:"bytes32",name:"to",indexed:false}]},{type:"event",anonymous:false,name:"PositionRiskControlDataUpdated",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"uint256",name:"freeAmount",indexed:false},{type:"uint256",name:"lockedAmount",indexed:false}]},{type:"event",anonymous:false,name:"PositionTransfer",inputs:[{type:"address",name:"from",indexed:false},{type:"address",name:"to",indexed:false},{type:"bytes32",name:"positionId",indexed:false}]},{type:"event",anonymous:false,name:"PositionUpdated",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"owner",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"uint8",name:"direction",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"uint256",name:"beforeSize",indexed:false},{type:"uint256",name:"afterSize",indexed:false},{type:"uint256",name:"beforeCollateralAmount",indexed:false},{type:"uint256",name:"afterCollateralAmount",indexed:false},{type:"uint256",name:"entryPrice",indexed:false},{type:"int256",name:"fundingRateIndex",indexed:false},{type:"uint8",name:"riskTier",indexed:false},{type:"uint256",name:"earlyClosePrice",indexed:false}]},{type:"event",anonymous:false,name:"ReferralRebateClaimed",inputs:[{type:"address",name:"user",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"ReserveRebateCollected",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false},{type:"address",name:"keeper",indexed:false},{type:"uint256",name:"poolAmount",indexed:false},{type:"uint256",name:"stakingAmount",indexed:false},{type:"uint256",name:"keeperAmount",indexed:false},{type:"uint256",name:"treasuryAmount",indexed:false},{type:"uint256",name:"reservedAmount",indexed:false},{type:"uint256",name:"ecoFundAmount",indexed:false}]},{type:"event",anonymous:false,name:"ReserveRebateDisbursed",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false},{type:"address",name:"keeper",indexed:false},{type:"uint256",name:"poolAmount",indexed:false},{type:"uint256",name:"stakingAmount",indexed:false},{type:"uint256",name:"keeperAmount",indexed:false},{type:"uint256",name:"treasuryAmount",indexed:false},{type:"uint256",name:"reservedAmount",indexed:false},{type:"uint256",name:"ecoFundAmount",indexed:false}]},{type:"event",anonymous:false,name:"TradingFeeTierUpdated",inputs:[{type:"address",name:"broker",indexed:false},{type:"uint8",name:"feeType",indexed:false},{type:"uint8",name:"tier",indexed:false},{type:"uint32",name:"takerFeeRate",indexed:false},{type:"int32",name:"makerFeeRate",indexed:false},{type:"bool",name:"isEnabled",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"event",anonymous:false,name:"UserFeeDataUpdated",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"signer",indexed:false},{type:"address",name:"user",indexed:false},{type:"uint8",name:"tier",indexed:false},{type:"address",name:"referrer",indexed:false},{type:"uint32",name:"totalReferralRebatePct",indexed:false},{type:"uint32",name:"referrerRebatePct",indexed:false}]},{type:"event",anonymous:false,name:"UserSettlementRecorded",inputs:[{type:"address",name:"user",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"int256",name:"charge",indexed:false},{type:"int256",name:"realizedPnl",indexed:false},{type:"int256",name:"tradingFee",indexed:false},{type:"int256",name:"fundingFee",indexed:false}]},{type:"event",anonymous:false,name:"UserSpecialFeeTierUpdated",inputs:[{type:"address",name:"broker",indexed:false},{type:"address",name:"user",indexed:false},{type:"uint8",name:"oldTier",indexed:false},{type:"uint8",name:"newTier",indexed:false}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"emitCollateralAccepted",constant:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[]},{type:"function",name:"emitExchanged",constant:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"bytes32",name:"poolId"}],outputs:[]},{type:"function",name:"emitFundingRateUpdated",constant:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"uint256",name:"orderId"},{type:"bytes32",name:"poolId"},{type:"string",name:"reason"}]}],outputs:[]},{type:"function",name:"emitLiquidityStopOrderCreated",constant:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"poolId"},{type:"string",name:"remark"}]}],outputs:[]},{type:"function",name:"emitPoolPrimed",constant:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"bytes32",name:"from"},{type:"bytes32",name:"to"}]}],outputs:[]},{type:"function",name:"emitPositionRiskControlDataUpdated",constant:false,payable:false,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:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"bytes32",name:"positionId"}]}],outputs:[]},{type:"function",name:"emitPositionUpdated",constant:false,payable:false,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:false,payable:false,inputs:[{type:"tuple",name:"params",components:[{type:"address",name:"user"},{type:"address",name:"token"},{type:"uint256",name:"amount"}]}],outputs:[]},{type:"function",name:"emitReserveRebateCollected",constant:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"initialize",constant:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isBlockHeaderEmitted",constant:true,stateMutability:"view",payable:false,inputs:[{type:"uint256",name:"blockNumber"}],outputs:[{type:"bool"}]},{type:"function",name:"proxiableUUID",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"registerContract",constant:false,payable:false,inputs:[{type:"bytes32[]",name:"identifiers"}],outputs:[]},{type:"function",name:"sequencer",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var ea=[{type:"constructor",payable:false,inputs:[{type:"string",name:"name"},{type:"string",name:"symbol"},{type:"uint8",name:"decimals_"}]},{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:"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:"ERC2612ExpiredSignature",inputs:[{type:"uint256",name:"deadline"}]},{type:"error",name:"ERC2612InvalidSigner",inputs:[{type:"address",name:"signer"},{type:"address",name:"owner"}]},{type:"error",name:"InvalidAccountNonce",inputs:[{type:"address",name:"account"},{type:"uint256",name:"currentNonce"}]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"StringTooLong",inputs:[{type:"string",name:"str"}]},{type:"event",anonymous:false,name:"Approval",inputs:[{type:"address",name:"owner",indexed:true},{type:"address",name:"spender",indexed:true},{type:"uint256",name:"value",indexed:false}]},{type:"event",anonymous:false,name:"EIP712DomainChanged",inputs:[]},{type:"event",anonymous:false,name:"Transfer",inputs:[{type:"address",name:"from",indexed:true},{type:"address",name:"to",indexed:true},{type:"uint256",name:"value",indexed:false}]},{type:"function",name:"DOMAIN_SEPARATOR",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"allowance",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"owner"},{type:"address",name:"spender"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",constant:false,payable:false,inputs:[{type:"address",name:"spender"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"eip712Domain",constant:true,stateMutability:"view",payable:false,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:"mint",constant:false,payable:false,inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"mintFor",constant:false,payable:false,inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"name",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"nonces",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{type:"function",name:"permit",constant:false,payable:false,inputs:[{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:"symbol",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",constant:false,payable:false,inputs:[{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",constant:false,payable:false,inputs:[{type:"address",name:"from"},{type:"address",name:"to"},{type:"uint256",name:"value"}],outputs:[{type:"bool"}]}];var ao=class{constructor(e,t){this.configManager=e,this.logger=t;}getOrderIdFromTransaction(e){if(!e||!e.logs)return null;let t=new ethers.ethers.Interface(Cu);if(!Cu.find(i=>i.type==="event"&&i.name==="OrderPlaced"))return this.logger.error("OrderPlaced event not found in Emiter ABI"),null;let a=ethers.ethers.id("OrderPlaced(address,address,bytes32,uint256,uint256,uint8,uint8,uint8,uint8,uint256,uint256,uint256,uint8,bool,uint16,address,uint256,uint16)");for(let i=0;i<e.logs.length;i++){let o=e.logs[i];if(this.logger.info(`Log ${i}:`,{address:o.address,topics:o.topics,data:o.data}),o.topics&&o.topics.length>0&&o.topics[0]===a)try{let s=t.parseLog({topics:o.topics,data:o.data});if(s&&s.name==="OrderPlaced"){let p=s.args[4];if(p!=null)return p.toString()}}catch(s){this.logger.error(`Error parsing log ${i}:`,s);continue}}return null}async getApproveQuoteAmount(e,t,n,a){try{let i=["function allowance(address owner, address spender) external view returns (uint256)"],o=a??ae(t).Account,s=await Ce(t);return {code:0,data:(await new ethers.ethers.Contract(n,i,s).allowance(e,o)).toString()}}catch(i){throw this.logger.error("Error getting allowance:",i),typeof i=="string"?i:await $(i)}}async needsApproval(e,t,n,a,i){try{let s=(await this.getApproveQuoteAmount(e,t,n,i)).data,p=ethers.ethers.getBigInt(s),c=ethers.ethers.getBigInt(a);return p<c}catch(o){return this.logger.error("Error checking approval needs:",o),true}}async approveAuthorization({chainId:e,quoteAddress:t,amount:n,spenderAddress:a,signer:i}){try{let o=["function approve(address spender, uint256 amount) external returns (bool)"],s=this.configManager.getConfig(),p=new ethers.ethers.Contract(t,o,i??s.signer),c=n??ethers.ethers.MaxUint256,l=a??ae(e).Account,f=await this.getGasPriceByRatio(),h=await this.getGasLimitByRatio(await p.approve.estimateGas(l,c));return await(await p.approve(l,c,{gasLimit:h,gasPrice:f})).wait(),{code:0,message:"Approval success"}}catch(o){return this.logger.error("Approval error:",o),{code:-1,message:o?.message}}}async getUserTradingFeeRate(e,t,n){let a=this.configManager.getConfig(),i=a.brokerAddress;try{let o=await Ce(n),s=new ethers.ethers.Contract(i,Yt,o),p=a.seamlessMode?a.seamlessAccount?.masterAddress:a.signer?.getAddress(),c=await s.getUserFeeRate(p,e,t);return {code:0,data:{takerFeeRate:c[0].toString(),makerFeeRate:c[1].toString(),baseTakerFeeRate:c[2].toString(),baseMakerFeeRate:c[3].toString()}}}catch(o){return this.logger.error("Error getting user trading fee rate:",o),{code:-1,message:o?.message}}}async getNetworkFee(e,t){let n=ae(t).MARKET_MANAGER,a=await Ce(t),i=new ethers.ethers.Contract(n,gn,a);try{return (await i.getExecutionFee(e)).toString()}catch(o){return this.logger.error("Error getting network fee:",o),"0"}}async getOraclePrice(e,t){try{let n=await xt(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 Y("PARAM_ERROR",`Invalid kline resolution: ${e}`)}}async getErrorMessage(e,t="Unknown error"){try{if(typeof e=="string")return e;if(e instanceof Y)return e.message;let n=await $(e);return n?n.error:JSON.stringify(e)}catch(n){return n?.message??n?.toString()??t}}async checkSeamlessGas(e,t){let n=await Ce(t),a=new ethers.ethers.Contract(ae(t).MARKET_MANAGER,gn,n),i=Ba(t),o=await a.getForwardFeeByToken(i),s=ae(t),c=await new ethers.ethers.Contract(s.ERC20,ea,n).balanceOf(e);return !(BigInt(o)>BigInt(0)&&BigInt(c)<BigInt(o))}async getLiquidityInfo({chainId:e,poolId:t,marketPrice:n}){try{return {code:0,data:await(await Gi(e)).getPoolInfo(t,n)}}catch(a){return this.logger.error("Error getting pool info:",a),{code:-1,message:a?.message}}}formatErrorMessage(e){if(typeof e=="string")return e;if(e instanceof Y)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 a=Object.keys(Yn).find(i=>i.toLowerCase()===n);if(a)return Yn[a]}}return e?.reason?e.reason:e?.message?e.message:JSON.stringify(e)}async getGasPriceByRatio(){let e=this.configManager.getConfig().chainId;return (await de(e)).gasPrice}async getGasLimitByRatio(e){let t=this.configManager.getConfig().chainId,n=oe[t];return ce(e,n?.gasLimitRatio??1.3)}};var ta=[{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:false,name:"DepositToAccount",inputs:[{type:"address",name:"account",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"ExecuteCompensation",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"baseAmount",indexed:false},{type:"uint256",name:"quoteAmount",indexed:false}]},{type:"event",anonymous:false,name:"Initialized",inputs:[{type:"uint64",name:"version",indexed:false}]},{type:"event",anonymous:false,name:"PayWithPrincipal",inputs:[{type:"address",name:"account",indexed:false},{type:"address",name:"receiver",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"PayWithProfitFirst",inputs:[{type:"address",name:"account",indexed:false},{type:"address",name:"receiver",indexed:false},{type:"bytes32",name:"poolId",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"usedFreeAmount",indexed:false},{type:"uint256",name:"usedRestrictedAmount",indexed:false}]},{type:"event",anonymous:false,name:"ReleaseForOrder",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"address",name:"account",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"ReleaseProfit",inputs:[{type:"address",name:"account",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"ReserveForOrder",inputs:[{type:"bytes32",name:"poolId",indexed:false},{type:"uint256",name:"orderId",indexed:false},{type:"address",name:"account",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"event",anonymous:false,name:"SettleToAccount",inputs:[{type:"address",name:"account",indexed:false},{type:"bytes32",name:"positionId",indexed:false},{type:"address",name:"baseToken",indexed:false},{type:"address",name:"quoteToken",indexed:false},{type:"uint256",name:"freeBase",indexed:false},{type:"uint256",name:"profitBase",indexed:false},{type:"uint256",name:"freeAmount",indexed:false},{type:"uint256",name:"profitAmount",indexed:false}]},{type:"event",anonymous:false,name:"Upgraded",inputs:[{type:"address",name:"implementation",indexed:true}]},{type:"event",anonymous:false,name:"WithdrawFromAccount",inputs:[{type:"address",name:"account",indexed:false},{type:"address",name:"token",indexed:false},{type:"uint256",name:"amount",indexed:false}]},{type:"function",name:"UPGRADE_INTERFACE_VERSION",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"string"}]},{type:"function",name:"__ERC2771ContextUpgradeable_init",constant:false,payable:false,inputs:[{type:"address",name:"trustedForwarder_"}],outputs:[]},{type:"function",name:"deposit",constant:false,payable:false,inputs:[{type:"address",name:"account"},{type:"address",name:"token"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"executeCompensation",constant:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"address",name:"reimbursement"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}],outputs:[]},{type:"function",name:"getAddressManager",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getDependencyAddress",constant:true,stateMutability:"view",payable:false,inputs:[{type:"bytes32",name:"identifier"}],outputs:[{type:"address"}]},{type:"function",name:"getImplementation",constant:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"getPoolWithdrawableBaseToken",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"}],outputs:[{type:"uint256",name:"baseAmount"}]},{type:"function",name:"getTradableAmount",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"}],outputs:[{type:"bool"},{type:"uint256"},{type:"uint256"},{type:"uint256"}]},{type:"function",name:"getUserAsset",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"},{type:"address",name:"token"}],outputs:[{type:"uint256",name:"amount"}]},{type:"function",name:"getUserAssets",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"account"}],outputs:[{type:"tuple[]",components:[{type:"address",name:"asset"},{type:"uint256",name:"amount"}]}]},{type:"function",name:"initialize",constant:false,payable:false,inputs:[{type:"address",name:"addressManager"}],outputs:[]},{type:"function",name:"isTrustedForwarder",constant:true,stateMutability:"view",payable:false,inputs:[{type:"address",name:"forwarder"}],outputs:[{type:"bool"}]},{type:"function",name:"payWithPrincipal",constant:false,payable:false,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:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"releaseForCancelOrder",constant:false,payable:false,inputs:[{type:"bytes32",name:"poolId"},{type:"uint256",name:"orderId"},{type:"address",name:"account"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"releaseFromProfitUnlock",constant:false,payable:false,inputs:[{type:"address",name:"account"},{type:"bytes32",name:"poolId"},{type:"uint256",name:"baseAmount"},{type:"uint256",name:"quoteAmount"}],outputs:[]},{type:"function",name:"reserveForOrder",constant:false,payable:false,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:false,payable:false,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:true,stateMutability:"view",payable:false,inputs:[],outputs:[{type:"address"}]},{type:"function",name:"updateAndWithdraw",constant:false,payable:false,inputs:[{type:"address",name:"receiver"},{type:"bytes32",name:"poolId"},{type:"bool",name:"isQuoteToken"},{type:"uint256",name:"amount"}],outputs:[]},{type:"function",name:"upgradeTo",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]},{type:"function",name:"upgradeToAndCall",constant:false,stateMutability:"payable",payable:true,inputs:[{type:"address",name:"newImplementation"},{type:"bytes",name:"data"}],outputs:[]}];var io=class{constructor(e,t,n,a){this.configManager=e,this.logger=t,this.utils=n,this.client=a;}async getWalletQuoteTokenBalance(e,t){let n=this.configManager.getConfig();if(!n.signer)throw new Y("INVALID_SIGNER","Invalid signer");let a=ae(e),i=await Ce(e);return {code:0,data:await new ethers.ethers.Contract(a.ERC20,ea,i).balanceOf(t||n.signer.getAddress())}}async getAvailableMarginBalance({poolId:e,chainId:t,address:n}){try{let a=await this.getAccountInfo(t,n,e);if(a.code!==0)throw new Y("REQUEST_FAILED","Failed to get account info");let i=a.data,o=BigInt(i.quoteProfit??0);return BigInt(i?.freeMargin??0)+o}catch{throw new Y("REQUEST_FAILED","Failed to get getAvailableMarginBalance")}}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 withdraw({chainId:e,receiver:t,amount:n,poolId:a,isQuoteToken:i}){let o=this.configManager.getConfig(),s=ae(e);try{let p=this.configManager.getConfig().seamlessAccount?.authorized,c=this.configManager.getConfig().seamlessAccount?.wallet;if(o.seamlessMode&&p&&c){if(!await this.utils.checkSeamlessGas(t,e))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let x=await tt(e),_=new ethers.ethers.Contract(s.Account,ta,c).interface.encodeFunctionData("updateAndWithdraw",[t,a,!0,n]),v=await x.nonces(c.address),E={from:c.address??"",to:s.Account,value:"0",gas:"350000",deadline:Or__default.default().add(60,"minute").unix(),data:_,nonce:v.toString()};return {code:0,message:"withdraw success",data:await this.client.seamless.forwarderTx(E,e,c)}}return {code:0,data:await(await new ethers.ethers.Contract(s.Account,ta,o.signer).updateAndWithdraw(t,a,i,n))?.wait(1)}}catch(p){return {code:-1,message:p.message}}}async deposit({amount:e,tokenAddress:t,chainId:n}){let a=this.configManager.getConfig(),i=await a.signer?.getAddress()??"",o=ae(n);try{let s=await this.utils.needsApproval(i,n,t,e,o.Account),p=this.configManager.getConfig().seamlessAccount?.authorized,c=this.configManager.getConfig().seamlessAccount?.wallet;if(a.seamlessMode&&p&&c){if(!await this.utils.checkSeamlessGas(i,n))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let x=await tt(n),_=new ethers.ethers.Contract(o.Account,ta,c).interface.encodeFunctionData("deposit",[i,t,e]),v=await x.nonces(c.address),E={from:c.address??"",to:o.Account,value:"0",gas:"350000",deadline:Or__default.default().add(60,"minute").unix(),data:_,nonce:v.toString()};return {code:0,message:"deposit success",data:await this.client.seamless.forwarderTx(E,n,c)}}if(s){let y=await this.utils.approveAuthorization({chainId:n,quoteAddress:t,amount:ethers.ethers.MaxUint256.toString(),spenderAddress:o.Account});if(y.code!==0)throw new Error(y.message)}return {code:0,data:await(await new ethers.ethers.Contract(o.Account,ta,a.signer).deposit(i,t,e))?.wait(1)}}catch(s){return {code:-1,message:s.message}}}async getAccountInfo(e,t,n){let a=ae(e),i=await Ce(e),o=new ethers.ethers.Contract(a.DATA_PROVIDER,Li,i);try{return {code:0,data:await o.getAccountInfo(n,t)}}catch(s){return {code:-1,message:s.message}}}async getAccountVipInfo(e,t){let n=this.configManager.getConfig(),a=await Ce(e),i=new ethers.ethers.Contract(n.brokerAddress,Yt,a),s=((await a.getBlock("latest"))?.timestamp??Or__default.default().unix())+300,p=await this.configManager.getAccessToken()??"";try{let c=await this.client.api.getCurrentEpoch({address:t,accessToken:p,broker:n.brokerAddress});if(c.code!==9200)throw new Y("REQUEST_FAILED",c.msg??"Failed to get current epoch");let l=await i.userFeeData(c?.data??0,t),f=await i.userNonces(t);return {code:0,data:{...l,nonce:f.toString(),deadline:s}}}catch(c){return {code:-1,message:c.message}}}async getAccountVipInfoByBackend(e,t,n,a){let i=await this.configManager.getAccessToken()??"";try{let o=await this.client.api.getAccountVipInfo({address:e,accessToken:i,chainId:t,deadline:n,nonce:a});if(o.code!==9200)throw new Y("REQUEST_FAILED",o.msg??"Failed to get account vip info");return {code:0,data:o.data}}catch(o){return {code:-1,message:o.message}}}async setUserFeeData(e,t,n,a,i){let o=this.configManager.getConfig(),s=this.configManager.getConfig().seamlessAccount?.authorized,p=this.configManager.getConfig().seamlessAccount?.wallet;if(n<Or__default.default().unix())throw new Y("REQUEST_FAILED","Invalid deadline, please try again");let c={user:e,nonce:a.nonce,deadline:n,feeData:{tier:a.tier,referrer:a.referrer||ethers.ethers.ZeroAddress,totalReferralRebatePct:a.totalReferralRebatePct,referrerRebatePct:a.referrerRebatePct},signature:i};try{if(o.seamlessMode&&s&&p){if(!await this.utils.checkSeamlessGas(e,t))throw new Y("INSUFFICIENT_BALANCE","Insufficient relay fee");let f=await tt(t),y=new ethers.ethers.Contract(o.brokerAddress,ta,p).interface.encodeFunctionData("setUserFeeData",[c]),x=await f.nonces(p.address),w={from:p.address??"",to:o.brokerAddress,value:"0",gas:"350000",deadline:Or__default.default().add(60,"minute").unix(),data:y,nonce:x.toString()};return {code:0,data:await this.client.seamless.forwarderTx(w,t,p)}}else {let l=new ethers.ethers.Contract(o.brokerAddress,Yt,o.signer),f=await l.userNonces(e);if(parseInt(f.toString())+1!==parseInt(a.nonce.toString()))throw new Y("REQUEST_FAILED","Invalid nonce, please try again");return {code:0,data:await(await l.setUserFeeData(c))?.wait(1)}}}catch(l){return {code:-1,message:l.message}}}};function vf(r,e){return `${encodeURIComponent(r)}=${encodeURIComponent(typeof e=="number"?e:`${e}`)}`}function gv(r,e){return vf(e,r[e])}function xv(r,e){return r[e].map(n=>vf(e,n)).join("&")}function bv(r){let e=r||{};return Object.keys(e).filter(n=>typeof e[n]<"u").map(n=>Array.isArray(e[n])?xv(e,n):gv(e,n)).join("&")}function Eu(r){let e=bv(r);return e?`?${e}`:""}var oo=class{constructor(e){this._preSigner=null;this._preUserAddress=null;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(!e.signer)throw new Y("INVALID_SIGNER");let t=this._preUserAddress,n=await this.configManager.getAccessToken()??"";if(e.signer!==this._preSigner&&(t=await e.signer.getAddress(),this._preUserAddress=t,this._preSigner=e.signer),!t)throw new Y("INVALID_SIGNER");return {headers:{myx_openapi_access_token:n,myx_openapi_account:t}}}buildRequestPath(e){return e.startsWith("http")?e:this.getHost()+e}async get(e,t,{auth:n=false,...a}={}){let i=n?await this.buildAuthParams():{};return ie.get(this.buildRequestPath(e),t,Bn(i,a))}async post(e,t,{auth:n=false,...a}={}){let i=n?await this.buildAuthParams():{};return ie.post(this.buildRequestPath(e),t,Bn(i,a))}async put(e,t,{auth:n=false,...a}={}){let i=n?await this.buildAuthParams():{};return ie.put(this.buildRequestPath(e),t,Bn(i,a))}async delete(e,{auth:t=false,...n}={}){let a=t?await this.buildAuthParams():{};return ie.delete(this.buildRequestPath(e),Bn(a,n))}};var so=class extends oo{constructor(e,t){super(e),this.logger=t;}async getTradeFlow({accessToken:e,address:t,...n}){return ie.get(`${this.getHost()}/openapi/gateway/scan/trade/flow`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getPoolSymbolAll(){return ie.get(`${this.getHost()}/openapi/gateway/scan/pools`)}async fetchForwarderGetApi(e){return await ie.get(`${this.getHost()}/v2/agent/forwarder/get${Eu(e)}`)}async getPoolList(){return ie.get(`${this.getHost()}/openapi/gateway/scan/market/list`)}async forwarderTxApi(e,t){return ie.post(`${this.getHost()}/v2/agent/forwarder/tx-v2`,e,{headers:{"myx-chain-id":t.toString()}})}async getOraclePrice(e,t=[]){if(t.length)return ie.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 ie.get(`${this.getHost()}/openapi/gateway/scan/market/info?chainId=${e}&poolId=${t}`)}async getPoolLevelConfig({poolId:e,chainId:t}){return ie.get(`${this.getHost()}/openapi/gateway/risk/market_pool/level_config${Eu({poolId:e,chainId:t})}`)}async getPositions(e,t){return await ie.get(`${this.getHost()}/openapi/gateway/scan/position/open`,void 0,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getOrders(e,t){return await ie.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 ie.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:a,interval:i}){return ie.get(`${this.getHost()}/openapi/gateway/quote/candles`,{chainId:e,poolId:t,endTime:n,limit:a,interval:i})}async getKlineLatestBar(e){return ie.get(`${this.getHost()}/openapi/gateway/quote/candle/latest`,e)}async getTickerData({chainId:e,poolIds:t}){return ie.get(`${this.getHost()}/openapi/gateway/quote/candle/tickers`,{chainId:e,poolIds:t.join(",")})}async getAllTickers(){return ie.get(`${this.getHost()}/v2/mx-gateway/quote/candle/all_tickers`)}async searchMarketAuth({accessToken:e,address:t,...n}){return ie.get(`${this.getHost()}/openapi/gateway/scan/market/ac-search`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async searchMarket({...e}){return ie.get(`${this.getHost()}/openapi/gateway/scan/market/search`,e)}async addFavorite({accessToken:e,address:t,...n}){return ie.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 ie.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 ie.get(`${this.getHost()}/openapi/gateway/scan/market/favorites`,n,{headers:{myx_openapi_access_token:e,myx_openapi_account:t}})}async getBaseDetail({...e}){return ie.get(`${this.getHost()}/openapi/gateway/scan/market/base-details`,e)}async getMarketDetail({...e}){return ie.get(`${this.getHost()}/openapi/gateway/scan/market/detail`,e)}async getHistoryOrders({accessToken:e,address:t,...n}){return ie.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 ie.get(`${this.getHost()}/openapi/gateway/scan/position/closed`,n,{headers:{myx_openapi_account:t,myx_openapi_access_token:e}})}async getMarketList(){return ie.get(`${this.getHost()}/openapi/gateway/scan/market`)}async getAccountVipInfo({address:e,accessToken:t,chainId:n,deadline:a,nonce:i}){return ie.get(`${this.getHost()}/openapi/gateway/vip/trade_config`,{chainId:n,deadline:a,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:true})}async getAppealDetail(e){return this.get("/openapi/gateway/scan/dispute/details",e,{auth:true})}async uploadAppealEvidence(e){return this.get("/openapi/gateway/scan/dispute/upload/evidence",e,{auth:true})}async getAppealReconsiderationList(e){return this.get("/openapi/gateway/scan/dispute/appeal/list",e,{auth:true})}async getAppealReconsiderationDetail(e){return this.get("/openapi/gateway/scan/dispute/appeal/details",e,{auth:true})}async getAppealReimbursementList(e){return this.get("/openapi/gateway/scan/reimbursement/list",e,{auth:true})}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:true})}async getPedingVoteCount(){return this.get("/openapi/gateway/scan/node/pending-vote-total",{},{auth:true})}async getMyAppealCount(){return this.get("/openapi/gateway/scan/processing-total",{},{auth:true})}async getWarmholeSign(e){return this.get("/openapi/gateway/scan/get-warmhole-sign",e,{auth:true})}async getDisputeTotalCount(){return this.get("/openapi/gateway/scan/dispute/dispute-total",{},{auth:true})}async getAppealTotalCount(){return this.get("/openapi/gateway/scan/dispute/appeal-total",{},{auth:true})}async getReimbursementTotalCount(){return this.get("/openapi/gateway/scan/dispute/reimbursement-total",{},{auth:true})}async getCurrentEpoch({address:e,accessToken:t,broker:n}){return ie.get(`${this.getHost()}/openapi/gateway/scan/get-current-epoch`,{broker:n},{headers:{myx_openapi_account:e,myx_openapi_access_token:t}})}};var at=wr(Pm());var Rm=async r=>{try{let e=await r.eip712Domain();return console.log("eip712Domain-->",e.name),console.log("eip712Domain.version-->",e.version),{name:e.name,version:e.version,chainId:BigInt(e.chainId),verifyingContract:e.verifyingContract}}catch(e){throw new Error(`Error fetching EIP712 domain: ${e}`)}};var _v={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"}]},Tv=2,kv=async r=>{let t=new TextEncoder().encode(r),n=await window.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")},Bv="jAkBlC4~5!6@#$%^",Sv=r=>{let e=ethers.toUtf8Bytes(r),t=ethers.keccak256(e),n=ethers.getBytes(t),a=ethers.hexlify(n);if(!ethers.isHexString(a,32))throw new Y("INVALID_PRIVATE_KEY","Invalid private key generated");let i=new ethers.ethers.Wallet(a);return {privateKey:a,wallet:i}},Ko=r=>{if(r.length>=16)return r;let t=16-r.length,n=Math.ceil(t/r.length),a=r.repeat(n).slice(0,t);return r+a},Qo=()=>at.default.enc.Utf8.parse(Bv);async function Dv(r,e,t,n,a,i,o){let s=await Rm(e),p={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},c={owner:t,spender:n,value:a,nonce:i,deadline:o},l=await r.signTypedData(s,p,c),{v:f,r:h,s:y}=bytes.splitSignature(l);return {v:f,r:h,s:y}}var Vo=class{constructor(e,t,n,a,i){this.configManager=e,this.logger=t,this.utils=n,this.account=a,this.api=i;}async onCheckRelayer(e,t,n){return await(await tt(n)).isUserRelayerEnabled(e,t)}async getUSDPermitParams(e,t){let n=this.configManager.getConfig();if(!n.signer)throw new Y("INVALID_SIGNER","Signer is required for permit");let a=ae(t),i=await n.signer.getAddress(),o=new ethers.ethers.Contract(a.ERC20,ea,n.signer);try{let s=await o.nonces(i),p=await Dv(n.signer,o,i,a.TRADING_ROUTER,ethers.ethers.MaxUint256.toString(),s.toString(),e.toString());return [{token:a.ERC20,owner:i,spender:a.TRADING_ROUTER,value:ethers.ethers.MaxUint256.toString(),deadline:e.toString(),v:p.v,r:p.r,s:p.s}]}catch{throw new Y("INVALID_PRIVATE_KEY","Invalid private key generated")}}async forwarderTx({from:e,to:t,value:n,gas:a,deadline:i,data:o,nonce:s},p,c){let f=await(await tt(p)).eip712Domain(),h={name:f.name,version:f.version,chainId:f.chainId,verifyingContract:f.verifyingContract},x=await(c??await yt()).signTypedData(h,_v,{from:e,to:t,value:n,gas:a,nonce:s,deadline:i,data:o}),w=Ba(p);return this.logger.info("forwarderTx-->",{from:e,to:t,value:n,gas:a,nonce:s,data:o,deadline:i,signature:x,forwardFeeToken:w},p),await this.api.forwarderTxApi({from:e,to:t,value:n,gas:a,nonce:s,data:o,deadline:i,signature:x,forwardFeeToken:w},p)}async authorizeSeamlessAccount({approve:e,seamlessAddress:t,chainId:n}){let i=await this.configManager.getConfig().signer?.getAddress()??"",o=Ce(n);if(e){let x=await this.account.getWalletQuoteTokenBalance(n,i);this.logger.info("balanceRes-->",x);let w=x.data,_=new ethers.ethers.Contract(ae(n).MARKET_MANAGER,gn,o),v=Ba(n);this.logger.info("forwardFeeToken-->",v);let E=await _.getForwardFeeByToken(v);this.logger.info("pledgeFee-->",E);let B=BigInt(E)*BigInt(Tv);if(this.logger.info("auth params-->",{gasFee:B,balance:w},n,v),this.logger.info("gasFee > 0 && gasFee > BigInt(balance)-->",B>0&&B>BigInt(w)),B>0&&B>BigInt(w))throw new Y("INSUFFICIENT_BALANCE","Insufficient balance")}let s=Or__default.default().add(60,"minute").unix(),p=[];if(e)try{p=await this.getUSDPermitParams(s,n);}catch(x){console.log("error-->",x),console.warn("Failed to get USD permit params, proceeding without permit:",x),p=[];}let c=await tt(n,1),f=await new ethers.ethers.Contract(ae(n).FORWARDER,Ui,o).nonces(i),h=c.interface.encodeFunctionData("permitAndApproveForwarder",[t,e,p]),y=await this.forwarderTx({from:i,to:c?.target,value:"0",gas:"800000",nonce:f.toString(),data:h,deadline:s},n);if(y.data?.txHash){for(let _=0;_<5;_++)try{if((await this.api.fetchForwarderGetApi({requestId:y.data.requestId})).data?.status===9)return {code:0,data:{seamlessAccount:t,authorized:e}};_<4&&await new Promise(E=>setTimeout(E,1e3));}catch(v){console.error("Poll transaction from chain error:",v),_<4&&await new Promise(E=>setTimeout(E,1e3));}return {code:-1,data:null,message:"Transaction confirmation timeout, please check later"}}else return console.log("txRs-->",y),{code:-1,data:null,message:"Your request timed out, please try again"}}async unLockSeamlessWallet({masterAddress:e,password:t,apiKey:n,chainId:a}){let i=at.default.enc.Utf8.parse(Ko(t)),o=Qo(),p=at.default.AES.decrypt(n,i,{iv:o,mode:at.default.mode.CBC,padding:at.default.pad.Pkcs7}).toString(at.default.enc.Utf8),c=new ethers.ethers.Wallet(p),l=await this.onCheckRelayer(e,c.address,a);return l||(await this.authorizeSeamlessAccount({approve:true,seamlessAddress:c.address,chainId:a}),l=true),this.configManager.updateSeamlessWallet({masterAddress:e,wallet:c,authorized:l}),{code:0,data:{masterAddress:e,seamlessAccount:c.address,authorized:l}}}async exportSeamlessPrivateKey({password:e,apiKey:t}){let n=at.default.enc.Utf8.parse(Ko(e)),a=Qo(),o=at.default.AES.decrypt(t,n,{iv:a,mode:at.default.mode.CBC,padding:at.default.pad.Pkcs7}).toString(at.default.enc.Utf8);if(new ethers.ethers.Wallet(o).address!==this.configManager.getConfig().seamlessAccount?.wallet?.address)throw new Y("INVALID_PRIVATE_KEY","Invalid private key");return {code:0,data:{privateKey:o}}}async importSeamlessPrivateKey({privateKey:e,password:t,chainId:n}){if(!ethers.ethers.isHexString(e,32))throw new Y("INVALID_PRIVATE_KEY","Invalid private key");let a=new ethers.ethers.Wallet(e),o=await(await tt(n)).originAccount(a.address);if(o===ethers.ZeroAddress)throw new Y("INVALID_PRIVATE_KEY","The private key is not a senseless account");let s=await this.onCheckRelayer(o,a.address,n),p=at.default.enc.Utf8.parse(Ko(t)),c=Qo(),f=at.default.AES.encrypt(e,p,{iv:c,mode:at.default.mode.CBC,padding:at.default.pad.Pkcs7}).toString();return this.configManager.updateSeamlessWallet({masterAddress:o,wallet:a,authorized:s}),{code:0,data:{masterAddress:o,seamlessAccount:a.address,authorized:s,apiKey:f}}}async startSeamlessMode({open:e}){return await this.configManager.startSeamlessMode(e),{code:0,data:{open:e}}}async createSeamless({password:e,chainId:t}){let a=this.configManager.getConfig().signer,i=await a?.getAddress()??"";if(!a)throw new Y("INVALID_SIGNER","Invalid signer");try{let o=await a.signMessage(`${i}_${e}`),s=await kv(o),{privateKey:p,wallet:c}=Sv(s),l=at.default.enc.Utf8.parse(Ko(e)),f=Qo(),y=at.default.AES.encrypt(p,l,{iv:f,mode:at.default.mode.CBC,padding:at.default.pad.Pkcs7}).toString(),x=await this.onCheckRelayer(i,c.address,t);return this.configManager.updateSeamlessWallet({masterAddress:i,wallet:c,authorized:x}),{code:0,data:{masterAddress:i,seamlessAccount:c.address,authorized:x,apiKey:y}}}catch(o){return {code:-1,message:o.message}}}};var ra=class{constructor(e){this.client=e;}getConfig(){return this.client.getConfigManager()?.getConfig()}async getSigner(){let e=this.getConfig();if(!e?.signer)throw new Y("INVALID_SIGNER","Invalid signer");return e.signer}getAddressConfig(){let t=this.getConfig()?.chainId;if(!t||!Ja(t))throw new Y("INVALID_CHAIN_ID","Invalid chain id");return ae(t)}async connectContract(e){return e.connect(await this.getSigner())}async getBrokerContract(){let e=this.getConfig();if(!e?.brokerAddress)throw new Y("INVALID_BROKER_ADDRESS","Invalid broker address");return md(e.chainId,e.brokerAddress)}get config(){return this.getConfig()}};var jo=class extends ra{constructor(e){super(e);}async getDisputeCourtContract(e=true){let t=await gd(this.config.chainId);return e?this.connectContract(t):t}async getReimbursementContract(e=true){let t=await yd(this.config.chainId);return e?this.connectContract(t):t}async submitAppeal(e,t,n){let a=await this.config.signer?.getAddress()??"",i=await this.client.utils.needsApproval(a,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 o=await this.getDisputeCourtContract(),s=await this.client.utils.buildUpdatePriceParams(e,this.config.chainId),p=BigInt(s[0].value.toString()||"1"),c=await o.fileDispute.estimateGas(s,e,t,{value:p});this.client.logger.debug("_gasLimit",c);let l=await this.client.utils.getGasLimitByRatio(c),f=await this.client.utils.getGasPriceByRatio();this.client.logger.debug("txParams",{gasLimit:l,gasPrice:f,value:p});let y=await(await o.fileDispute(s,e,t,{value:p,gasLimit:l,gasPrice:f})).wait(),x=y?.logs.find(_=>_.eventName==="DisputeFiled");if(!x||!y)throw new Y("TRANSACTION_FAILED","DisputeFiledLog not found");let w=x.args.getValue("caseId");return this.client.logger.debug("caseId",w),this.client.logger.debug("event",x),{transaction:y,caseId:w}}async voteForAppeal({caseId:e,validator:t,isFor:n,deadline:a,v:i,r:o,s}){let p=await this.getDisputeCourtContract(),c=await p.vote.estimateGas(e,t,n?1:0,a,i,o,s),l=await this.client.utils.getGasLimitByRatio(c),f=await this.client.utils.getGasPriceByRatio();return await(await p.vote(e,t,n?1:0,a,i,o,s,{gasLimit:l,gasPrice:f})).wait()}async claimAppealMargin(e){let t=await this.getDisputeCourtContract(),n=await t.claimBond.estimateGas(e),a=await this.client.utils.getGasLimitByRatio(n),i=await this.client.utils.getGasPriceByRatio();return await(await t.claimBond(e,{gasLimit:a,gasPrice:i})).wait()}async claimReimbursement(e,t,n,a){let i=await this.getReimbursementContract(),o=await i.claimReimbursement.estimateGas(e,t,n,a),s=await this.client.utils.getGasLimitByRatio(o),p=await this.client.utils.getGasPriceByRatio();return await(await i.claimReimbursement(e,t,n,a,{gasLimit:s,gasPrice:p})).wait()}async getDisputeConfiguration(){return await(await this.getDisputeCourtContract(false)).getDisputeConfiguration()}async submitAppealByVoteNode(e,t,n){let a=await this.getDisputeCourtContract(),i=await this.client.utils.getGasPriceByRatio(),o=await this.client.utils.getGasLimitByRatio(await a.fileDisputeFromStaker.estimateGas(e,t,n)),p=await(await a.fileDisputeFromStaker(e,t,n,{gasLimit:o,gasPrice:i})).wait(),c=p?.logs.find(f=>f.eventName==="DisputeFiled");if(!c||!p)throw new Y("TRANSACTION_FAILED","DisputeFiledLog not found");let l=c.args.getValue("caseId");return {tx:p,caseId:l}}async appealReconsideration(e,t,n){let a=await this.getDisputeCourtContract(),i=await this.config.signer?.getAddress()??"",o=this.getAddressConfig().DISPUTE_COURT;if(await this.client.utils.needsApproval(i,this.config.chainId,t,n,o)){let w=await this.client.utils.approveAuthorization({chainId:this.config.chainId,quoteAddress:t,spenderAddress:o});if(w.code!==0)throw new Y("TRANSACTION_FAILED",w.message)}let p=await a.appeal.estimateGas(e),c=await this.client.utils.getGasLimitByRatio(p),l=await this.client.utils.getGasPriceByRatio(),h=await(await a.appeal(e,{gasLimit:c,gasPrice:l})).wait(),y=h?.logs.find(w=>w.eventName==="AppealFiled");if(!y||!h)throw new Y("TRANSACTION_FAILED","AppealFiledLog not found");let x=y.args.getValue("appealCaseId");return {tx:h,appealCaseId:x,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()}};var Jo=class extends ra{constructor(e){super(e);}async claimRebate(e){let t=await this.connectContract(await this.getBrokerContract()),n=await t.claimRebate.estimateGas(e),a=await this.client.utils.getGasLimitByRatio(n),i=await this.client.utils.getGasPriceByRatio();return await(await t.claimRebate(e,{gasPrice:i,gasLimit:a})).wait()}};var Mv=(p=>(p[p.UnderReview=1]="UnderReview",p[p.InitialVote=2]="InitialVote",p[p.PublicNotice=3]="PublicNotice",p[p.UnderReconsideration=4]="UnderReconsideration",p[p.Won=5]="Won",p[p.Failed=6]="Failed",p[p.PlatformRuling=7]="PlatformRuling",p[p.PlatformRevoked=8]="PlatformRevoked",p))(Mv||{}),Fv=(l=>(l[l.InitialVoting=1]="InitialVoting",l[l.PublicNotice=2]="PublicNotice",l[l.UnderReconsideration=3]="UnderReconsideration",l[l.Won=5]="Won",l[l.Failed=4]="Failed",l[l.PlatformRuling=6]="PlatformRuling",l[l.PlatformRevoked=7]="PlatformRevoked",l[l.ReconsiderationVoting=8]="ReconsiderationVoting",l[l.AppealRevert=9]="AppealRevert",l[l.NotAppealFailed=10]="NotAppealFailed",l))(Fv||{}),Nv=(a=>(a[a.UnderReview=1]="UnderReview",a[a.PublicNotice=2]="PublicNotice",a[a.UnderReconsideration=3]="UnderReconsideration",a[a.Completed=4]="Completed",a))(Nv||{}),Ov=(t=>(t[t.ElectionNode=0]="ElectionNode",t[t.OfficialNode=1]="OfficialNode",t))(Ov||{}),Lv=(t=>(t[t.Reject=0]="Reject",t[t.Support=1]="Support",t))(Lv||{}),Uv=(t=>(t[t.UnClaimed=0]="UnClaimed",t[t.Claimed=1]="Claimed",t))(Uv||{}),qv=(t=>(t[t.NotVoted=0]="NotVoted",t[t.Voted=1]="Voted",t))(qv||{}),Gv=(t=>(t[t.Appeal=1]="Appeal",t[t.Reconsideration=2]="Reconsideration",t))(Gv||{}),zv=(n=>(n[n.NoVote=0]="NoVote",n[n.Supported=1]="Supported",n[n.Rejected=2]="Rejected",n))(zv||{}),Hv=(t=>(t[t.Yes=1]="Yes",t[t.No=0]="No",t))(Hv||{});var Ru=class{getConfigManager(){return this.configManager}constructor(e){this.configManager=new $i(e),this.logger=new $n({logLevel:e.logLevel});let t=tn.getInstance();t.setConfigManager(this.configManager),t.getMarkets().then(),this.utils=new ao(this.configManager,this.logger),this.api=new so(this.configManager,this.logger),this.account=new io(this.configManager,this.logger,this.utils,this),this.seamless=new Vo(this.configManager,this.logger,this.utils,this.account,this.api),this.markets=new eo(this.configManager,this.utils,this.api),this.position=new to(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.order=new no(this.configManager,this.logger,this.utils,this.seamless,this.account,this.api),this.subscription=new Zi(this.configManager,this.logger),this.appeal=new jo(this),this.referrals=new Jo(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=false){return await this.configManager.refreshAccessToken(e)}};/**
|
|
3
2
|
* MyxLogger
|
|
4
3
|
* @description MyxLogger is a logger for Myx SDK
|
|
5
4
|
* @author Myx
|
|
@@ -9,3 +8,45 @@
|
|
|
9
8
|
* @copyright Myx
|
|
10
9
|
* @description MyxLogger is a logger for Myx SDK
|
|
11
10
|
*/
|
|
11
|
+
/*! Bundled license information:
|
|
12
|
+
|
|
13
|
+
js-sha3/src/sha3.js:
|
|
14
|
+
(**
|
|
15
|
+
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
16
|
+
*
|
|
17
|
+
* @version 0.8.0
|
|
18
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
19
|
+
* @copyright Chen, Yi-Cyuan 2015-2018
|
|
20
|
+
* @license MIT
|
|
21
|
+
*)
|
|
22
|
+
|
|
23
|
+
crypto-js/ripemd160.js:
|
|
24
|
+
(** @preserve
|
|
25
|
+
(c) 2012 by Cédric Mesnil. All rights reserved.
|
|
26
|
+
|
|
27
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
28
|
+
|
|
29
|
+
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
30
|
+
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
31
|
+
|
|
32
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
+
*)
|
|
34
|
+
|
|
35
|
+
crypto-js/mode-ctr-gladman.js:
|
|
36
|
+
(** @preserve
|
|
37
|
+
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
|
38
|
+
* derived from CryptoJS.mode.CTR
|
|
39
|
+
* Jan Hruby jhruby.web@gmail.com
|
|
40
|
+
*)
|
|
41
|
+
|
|
42
|
+
lodash-es/lodash.js:
|
|
43
|
+
(**
|
|
44
|
+
* @license
|
|
45
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
46
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
47
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
48
|
+
* Released under MIT license <https://lodash.com/license>
|
|
49
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
50
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
51
|
+
*)
|
|
52
|
+
*/Object.defineProperty(exports,"formatUnits",{enumerable:true,get:function(){return ethers.formatUnits}});Object.defineProperty(exports,"parseUnits",{enumerable:true,get:function(){return ethers.parseUnits}});exports.AppealCaseTypeEnum=Gv;exports.AppealClaimStatusEnum=Uv;exports.AppealNodeStateEnum=zv;exports.AppealNodeVotedStateEnum=qv;exports.AppealReconsiderationType=Fv;exports.AppealStage=Nv;exports.AppealType=Mv;exports.COMMON_LP_AMOUNT_DECIMALS=gt;exports.COMMON_PRICE_DECIMALS=Ye;exports.ChainId=St;exports.CloseTypeEnum=I1;exports.Direction=GS;exports.DirectionEnum=w1;exports.ErrorCode=f1;exports.ExecTypeEnum=E1;exports.ForwarderGetStatus=R1;exports.HttpKlineIntervalEnum=Jc;exports.IsVoteNodeEnum=Hv;exports.MarketCapType=y1;exports.MarketPoolState=Jn;exports.MarketType=m1;exports.MxSDK=tn;exports.MyxClient=Ru;exports.NodeTypeEnum=Ov;exports.OperationEnum=b1;exports.OperationType=vn;exports.OracleType=jc;exports.OrderStatus=HS;exports.OrderStatusEnum=C1;exports.OrderType=ro;exports.OrderTypeEnum=x1;exports.SearchSecondTypeEnum=g1;exports.SearchTypeEnum=h1;exports.TimeInForce=zS;exports.TradeFlowAccountTypeEnum=P1;exports.TradeFlowTypeEnum=v1;exports.TriggerType=qS;exports.TriggerTypeEnum=A1;exports.VoteTypeEnum=Lv;exports.approve=Ad;exports.base=Md;exports.bigintAmountSlipperCalculator=hr;exports.bigintTradingGasPriceWithRatio=de;exports.bigintTradingGasToRatioCalculator=ce;exports.getAllowanceApproved=vd;exports.getBalanceOf=bd;exports.getBaseDetail=M4;exports.getBaseUrlByEnv=kr;exports.getMarketDetail=F4;exports.getMarketList=Zc;exports.getOraclePrice=Br;exports.getPoolDetail=Yc;exports.getPoolList=T4;exports.getPoolOpenOrders=Xc;exports.getPriceData=xt;exports.getPricesData=Xn;exports.getTickerData=D4;exports.getTokenInfo=zk;exports.market=af;exports.pool=tf;exports.quote=Wd;
|