UNPKG

synthetix

Version:

The smart contracts which make up the Synthetix system. (synthetix.io)

2 lines 8.61 MB
/*! For license information please see browser.js.LICENSE.txt */ !function(e,a){"object"==typeof exports&&"object"==typeof module?module.exports=a():"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?exports.synthetix=a():e.synthetix=a()}(self,(()=>(()=>{var e={6010:(e,a,b)=>{"use strict";const t=b(8269),f=b(2295),n={mainnet:b(8684),goerli:b(5985),"goerli-ovm":b(3902),"local-ovm":b(7448),"mainnet-ovm":b(8846)},d=b(6534),s=b(4582),i=b(4766),c=Object.entries({1:{network:"mainnet"},5:{network:"goerli"},31337:{network:"mainnet",fork:!0},10:{network:"mainnet",useOvm:!0},420:{network:"goerli",useOvm:!0},"-1":{network:"unknown",useOvm:!0}}).reduce(((e,[a,b])=>(e[a]=Object.assign({useOvm:!1,fork:!1},b),e)),{}),r=Object.entries(c).reduce(((e,[a,{network:b,useOvm:t,fork:f}])=>(e[b+(t?"-ovm":"")+(f?"-fork":"")]=a,e)),{}),u={BUILD_FOLDER:"build",CONTRACTS_FOLDER:"contracts",MIGRATIONS_FOLDER:"migrations",COMPILED_FOLDER:"compiled",FLATTENED_FOLDER:"flattened",AST_FOLDER:"ast",CONFIG_FILENAME:"config.json",RELEASES_FILENAME:"releases.json",PARAMS_FILENAME:"params.json",SYNTHS_FILENAME:"synths.json",STAKING_REWARDS_FILENAME:"rewards.json",SHORTING_REWARDS_FILENAME:"shorting-rewards.json",OWNER_ACTIONS_FILENAME:"owner-actions.json",DEPLOYMENT_FILENAME:"deployment.json",VERSIONS_FILENAME:"versions.json",FEEDS_FILENAME:"feeds.json",OFFCHAIN_FEEDS_FILENAME:"offchain-feeds.json",FUTURES_MARKETS_FILENAME:"futures-markets.json",PERPS_V2_MARKETS_FILENAME:"perpsv2-markets.json",AST_FILENAME:"asts.json",ZERO_ADDRESS:"0x"+"0".repeat(40),ZERO_BYTES32:"0x"+"0".repeat(64),inflationStartTimestampInSecs:1551830400},p={TEMP_OWNER_DEFAULT_DURATION:5184e3,WAITING_PERIOD_SECS:300..toString(),PRICE_DEVIATION_THRESHOLD_FACTOR:t.toWei("3"),TRADING_REWARDS_ENABLED:!1,ISSUANCE_RATIO:t.toBN(1).mul(t.toBN(1e18)).div(t.toBN(3)).toString(),FEE_PERIOD_DURATION:604800..toString(),TARGET_THRESHOLD:"1",LIQUIDATION_DELAY:86400..toString(),LIQUIDATION_RATIO:t.toBN(1).mul(t.toBN(2e18)).div(t.toBN(3)).toString(),LIQUIDATION_ESCROW_DURATION:31536e3.toString(),LIQUIDATION_PENALTY:t.toWei("0.1"),SNX_LIQUIDATION_PENALTY:t.toWei("0.3"),SELF_LIQUIDATION_PENALTY:t.toWei("0.2"),FLAG_REWARD:t.toWei("10"),LIQUIDATE_REWARD:t.toWei("20"),RATE_STALE_PERIOD:9e4.toString(),EXCHANGE_FEE_RATES:{forex:t.toWei("0.003"),commodity:t.toWei("0.003"),equities:t.toWei("0.003"),crypto:t.toWei("0.01"),index:t.toWei("0.01")},EXCHANGE_DYNAMIC_FEE_THRESHOLD:t.toWei("0.0025"),EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY:t.toWei("0.95"),EXCHANGE_DYNAMIC_FEE_ROUNDS:"6",EXCHANGE_MAX_DYNAMIC_FEE:t.toWei("0.015"),MINIMUM_STAKE_TIME:86400..toString(),DEBT_SNAPSHOT_STALE_TIME:43800..toString(),AGGREGATOR_WARNING_FLAGS:{mainnet:"0x4A5b9B4aD08616D11F3A402FF7cBEAcB732a76C6"},RENBTC_ERC20_ADDRESSES:{mainnet:"0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D",goerli:"0x9B2fE385cEDea62D839E4dE89B0A23EF4eacC717"},WETH_ERC20_ADDRESSES:{mainnet:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",goerli:"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6","mainnet-ovm":"0x4200000000000000000000000000000000000006","goerli-ovm":"0x4200000000000000000000000000000000000006"},INITIAL_ISSUANCE:t.toWei("100000000"),CROSS_DOMAIN_DEPOSIT_GAS_LIMIT:"3000000",CROSS_DOMAIN_ESCROW_GAS_LIMIT:"8000000",CROSS_DOMAIN_REWARD_GAS_LIMIT:"8000000",CROSS_DOMAIN_WITHDRAWAL_GAS_LIMIT:"3000000",CROSS_DOMAIN_RELAY_GAS_LIMIT:"8000000",CROSS_DOMAIN_FEE_PERIOD_CLOSE_GAS_LIMIT:"8000000",COLLATERAL_MANAGER:{SYNTHS:["sUSD","sBTC","sETH"],SHORTS:["sBTC","sETH"],MAX_DEBT:t.toWei("75000000"),MAX_SKEW_RATE:t.toWei("0.2"),BASE_BORROW_RATE:Math.round(158443823.07706398).toString(),BASE_SHORT_RATE:Math.round(158443823.07706398).toString()},COLLATERAL_ETH:{SYNTHS:["sUSD","sETH"],MIN_CRATIO:t.toWei("1.3"),MIN_COLLATERAL:t.toWei("2"),ISSUE_FEE_RATE:t.toWei("0.001")},COLLATERAL_RENBTC:{SYNTHS:["sUSD","sBTC"],MIN_CRATIO:t.toWei("1.3"),MIN_COLLATERAL:t.toWei("0.05"),ISSUE_FEE_RATE:t.toWei("0.001")},COLLATERAL_SHORT:{SYNTHS:["sBTC","sETH"],MIN_CRATIO:t.toWei("1.2"),MIN_COLLATERAL:t.toWei("1000"),ISSUE_FEE_RATE:t.toWei("0.005"),INTERACTION_DELAY:"3600",COLLAPSE_FEE_RATE:"0"},ETHER_WRAPPER_MAX_ETH:t.toWei("5000"),ETHER_WRAPPER_MINT_FEE_RATE:t.toWei("0.005"),ETHER_WRAPPER_BURN_FEE_RATE:"0",FUTURES_MIN_KEEPER_FEE:t.toWei("1"),FUTURES_MAX_KEEPER_FEE:t.toWei("1000"),FUTURES_LIQUIDATION_FEE_RATIO:t.toWei("0.0035"),FUTURES_LIQUIDATION_BUFFER_RATIO:t.toWei("0.0025"),FUTURES_MIN_INITIAL_MARGIN:t.toWei("40"),ATOMIC_MAX_VOLUME_PER_BLOCK:t.toWei("200000"),ATOMIC_TWAP_WINDOW:"1800"},l=e=>t.hexToAscii(e),y=({network:e,useOvm:a=!1})=>e.includes("ovm")?e:a?`${e}-ovm`:e,o=({network:e="mainnet",file:a="",useOvm:b=!1,path:t}={})=>t.join("/","publish","deployed",y({network:e,useOvm:b}),a),m=({network:e="mainnet",path:a,fs:b,deploymentPath:t,useOvm:f=!1})=>{if(!(t||a&&b))return n[y({network:e,useOvm:f})].deployment;const d=t?a.join(t,u.DEPLOYMENT_FILENAME):o({network:e,useOvm:f,path:a,file:u.DEPLOYMENT_FILENAME});if(!b.existsSync(d))throw Error(`Cannot find deployment for network: ${e}.`);return JSON.parse(b.readFileSync(d))},h=({network:e="mainnet",useOvm:a=!1,contract:b,path:t,fs:f,deploymentPath:n}={})=>{const d=m({network:e,useOvm:a,path:t,fs:f,deploymentPath:n});return b?d.targets[b]:d.targets},T=({network:e="mainnet",useOvm:a=!1,contract:b,path:t,fs:f,deploymentPath:n}={})=>{const d=m({network:e,useOvm:a,path:t,fs:f,deploymentPath:n});return b?d.sources[b]:d.sources},x=({network:e,path:a,fs:b,deploymentPath:t,useOvm:f=!1}={})=>{let s;if(t||a&&b){const n=t?a.join(t,u.FEEDS_FILENAME):o({network:e,path:a,useOvm:f,file:u.FEEDS_FILENAME});if(!b.existsSync(n))throw Error("Cannot find feeds file.");s=JSON.parse(b.readFileSync(n))}else s=n[y({network:e,useOvm:f})].feeds;return Object.entries(s).reduce(((e,[a,b])=>(e[a]=Object.assign(d[a],b),e)),{})},w=({network:e="mainnet",path:a,fs:b,deploymentPath:t,useOvm:f=!1,skipPopulate:s=!1}={})=>{let i;if(t||a&&b){const n=t?a.join(t,u.SYNTHS_FILENAME):o({network:e,useOvm:f,path:a,file:u.SYNTHS_FILENAME});if(!b.existsSync(n))throw Error("Cannot find synth list.");i=JSON.parse(b.readFileSync(n))}else i=n[y({network:e,useOvm:f})].synths;if(s)return i;const c=x({network:e,useOvm:f,path:a,fs:b,deploymentPath:t});return i.map((e=>{if(e=Object.assign({},d[e.asset],e),c[e.asset]){const{feed:a}=c[e.asset];e=Object.assign({feed:a},e)}if("string"==typeof e.index){const{index:a}=i.find((({name:a})=>a===e.index))||{};if(!a)throw Error(`While processing ${e.name}, it's index mapping "${e.index}" cannot be found - this is an error in the deployment config and should be fixed`);e=Object.assign({},e,{index:a})}return e.index&&(e.index=e.index.map((e=>Object.assign({},d[e.asset],e)))),e}))};e.exports={chainIdMapping:c,constants:u,decode:({network:e="mainnet",fs:a,path:b,data:n,target:d,useOvm:s=!1,decodeMigration:i=!1,enhanceDecode:c=!1}={})=>{const r=T({network:e,path:b,fs:a,useOvm:s});for(const{abi:e}of Object.values(r))f.addABI(e);i&&f.addABI([{constant:!1,inputs:[],name:"migrate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}]);const u=h({network:e,path:b,fs:a,useOvm:s});let p;d&&(p=Object.values(u).filter((({address:e})=>e.toLowerCase()===d.toLowerCase()))[0].name);const y={method:f.decodeMethod(n),contract:p};return c?(e=>{const a=e=>{try{return{ascii:l(e).replaceAll("\0","")}}catch(e){return{ascii:"\\error decoding\\"}}},b=e=>e.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),f=e=>{try{const a=t.toBN(e);return{bp:a.div(t.toBN(1e14)).toString(),decimal:b(a.div(t.toBN(1e18)).toString()),number:b(a.toString())}}catch(e){return{ascii:"\\error decoding\\"}}},n=e.method.params.map((e=>{if("bytes32"===e.type)return{...e,enhanced:a(e.value)};if("bytes32[]"===e.type&&(e.value=e.value.map((e=>({original:e,enhanced:a(e)})))),/u?int[1-3][0-9]?./.test(e.type))return{...e,enhanced:f(e.value)};if("tuple"===e.type){const b=Object.keys(e.value).filter((e=>isNaN(e))),t=[];for(const n of b)if(e.value[n].startsWith("0x")){if(66===e.value[n].length){t[n]={original:e.value[n],enhanced:a(e.value[n])};continue}t[n]=e.value[n]}else t[n]={original:e.value[n],enhanced:f(e.value[n])};e.value=t}return e})),d={...e.method,params:n};return{...e,method:d}})(y):y},defaults:p,getAST:({source:e,path:a,fs:b,match:t=/^contracts\//}={})=>{let f;if(a&&b){const e=a.resolve("/",u.BUILD_FOLDER,u.AST_FOLDER,u.AST_FILENAME);if(!b.existsSync(e))throw Error("Cannot find AST");f=JSON.parse(b.readFileSync(e))}else{if(!n.ast)throw Error("AST currently not supported in browser mode");f=n.ast}const d=Object.entries(f).filter((([e])=>t.test(e))).reduce(((e,[a,b])=>(e[a]=b,e)),{});if(e&&e in d)return d[e];if(e){const[a,b]=Object.entries(d).find((([a])=>a.includes("/"+e)))||[];if(!a||!b)throw Error(`Cannot find AST entry for source: ${e}`);return{[a]:b}}return d},getNetworkFromId:({id:e})=>c[e],getNextRelease:({useOvm:e})=>{const a=i.releases.find((({released:a,ovm:b})=>!a&&(e?b:!b)));return Object.assign({},a,{releaseName:a.name.replace(/[^\w]/g,"")})},getPathToNetwork:o,getSource:T,getStakingRewards:({network:e="mainnet",useOvm:a=!1,path:b,fs:t,deploymentPath:f}={})=>{if(!(f||b&&t))return n[y({network:e,useOvm:a})].rewards;const d=f?b.join(f,u.STAKING_REWARDS_FILENAME):o({network:e,path:b,useOvm:a,file:u.STAKING_REWARDS_FILENAME});return t.existsSync(d)?JSON.parse(t.readFileSync(d)):[]},getShortingRewards:({network:e="mainnet",useOvm:a=!1,path:b,fs:t,deploymentPath:f}={})=>{if(!(f||b&&t))return n[y({network:e,useOvm:a})]["shorting-rewards"];const d=f?b.join(f,u.SHORTING_REWARDS_FILENAME):o({network:e,path:b,useOvm:a,file:u.SHORTING_REWARDS_FILENAME});return t.existsSync(d)?JSON.parse(t.readFileSync(d)):[]},getSuspensionReasons:({code:e}={})=>{const a={1:"System Upgrade",2:"Market Closure",4:"iSynth Reprice",6:"Index Rebalance",55:"Circuit Breaker (Phase one)",65:"Decentralized Circuit Breaker (Phase two)",80:"Futures configuration",231:"Latency Breaker",99999:"Emergency"};return e?a[e]:a},getFeeds:x,getOffchainFeeds:({network:e,path:a,fs:b,deploymentPath:t,useOvm:f=!1}={})=>{if(t||a&&b){const n=t?a.join(t,u.OFFCHAIN_FEEDS_FILENAME):o({network:e,path:a,useOvm:f,file:u.OFFCHAIN_FEEDS_FILENAME});if(!b.existsSync(n))throw Error("Cannot find off-chain feeds file.");return JSON.parse(b.readFileSync(n))}return n[y({network:e,useOvm:f})].offchainFeeds},getSynths:w,getFuturesMarkets:({network:e="mainnet",useOvm:a=!1,path:b,fs:t,deploymentPath:f}={})=>{let s;if(f||b&&t){const n=f?b.join(f,u.FUTURES_MARKETS_FILENAME):o({network:e,path:b,useOvm:a,file:u.FUTURES_MARKETS_FILENAME});s=t.existsSync(n)&&JSON.parse(t.readFileSync(n))||[]}else s=n[y({network:e,useOvm:a})].futuresMarkets;return s.map((e=>{const a=["sBTC","sETH","sLINK"].includes(e.asset)?e.asset.slice(1):e.asset;return Object.assign({},d[a],e)}))},getPerpsMarkets:({network:e="mainnet",useOvm:a=!1,path:b,fs:t,deploymentPath:f}={})=>{let s;if(f||b&&t){const n=f?b.join(f,u.PERPS_V2_MARKETS_FILENAME):o({network:e,path:b,useOvm:a,file:u.PERPS_V2_MARKETS_FILENAME});s=t.existsSync(n)&&JSON.parse(t.readFileSync(n))||[]}else s=n[y({network:e,useOvm:a})].perpsv2Markets;return s.map((e=>{const a=["sBTC","sETH"].includes(e.asset)?e.asset.slice(1):e.asset;return Object.assign({},d[a],e)}))},getPerpsV2ProxiedMarkets:({network:e="mainnet",fs:a,deploymentPath:b,path:t})=>{const f=(e,a,b,t)=>{const f="PerpsV2Proxy",d="PerpsV2Market",s=["PerpsV2MarketViews","PerpsV2DelayedOrder","PerpsV2OffchainDelayedOrder"];if(!["PerpsV2MarketSettings","PerpsV2MarketData"].includes(e)&&!e.startsWith("PerpsV2MarketState"))if(e.startsWith(f)){const b=e.slice(f.length);t[b]||(t[b]={},t[b].abi=[]),t[b].address=a.address}else{let a,f=!1;for(const b of s)e.startsWith(b)&&(a=e.slice(b.length),f=!0);f||e.startsWith(d)&&(a=e.slice(d.length),f=!0),f&&(t[a]||(t[a]={},t[a].abi=[]),n(b.abi,t[a].abi))}},n=(e,a)=>{for(const b of e)a.find((e=>e.type===b.type&&e.name&&b.name&&e.name===b.name))||"constructor"!==b.type&&a.push(b)},d=m({network:e,useOvm:!1,path:t,fs:a,deploymentPath:b}),s=Object.keys(d.targets),i={};for(const n of s){if(!n.startsWith("PerpsV2"))continue;const d=h({contract:n,network:e,useOvm:!1,path:t,fs:a,deploymentPath:b});f(n,d,T({contract:d.source,network:e,useOvm:!1,path:t,fs:a,deploymentPath:b}),i)}return i},getTarget:h,getTokens:({network:e="mainnet",path:a,fs:b,useOvm:t=!1}={})=>{const f=w({network:e,useOvm:t,path:a,fs:b}),n=h({network:e,useOvm:t,path:a,fs:b}),d=x({network:e,useOvm:t,path:a,fs:b});return[Object.assign({symbol:"SNX",asset:"SNX",name:"Synthetix",address:n.ProxySynthetix.address,decimals:18},d.SNX.feed?{feed:d.SNX.feed}:{})].concat(f.filter((({category:e})=>"internal"!==e)).map((e=>({symbol:e.name,asset:e.asset,name:e.description,address:(n[`Proxy${e.name}`]||{}).address,index:e.index,decimals:18,feed:e.feed}))).sort(((e,a)=>e.symbol>a.symbol?1:-1)))},getUsers:({network:e="mainnet",user:a,useOvm:b=!1}={})=>{const t="0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9",f={owner:t,deployer:t,marketClosure:t,oracle:"0xac1e8B385230970319906C03A1d8567e3996d1d5",fee:"0xfeEFEEfeefEeFeefEEFEEfEeFeefEEFeeFEEFEeF",zero:"0x"+"0".repeat(40)},n={mainnet:Object.assign({},f,{owner:"0xEb3107117FEAd7de89Cd14D463D340A2E6917769",deployer:"0x302d2451d9f47620374B54c521423Bf0403916A2",marketClosure:"0xC105Ea57Eb434Fbe44690d7Dec2702e4a2FBFCf7",oracle:"0xaC1ED4Fabbd5204E02950D68b6FC8c446AC95362"}),"mainnet-ovm":Object.assign({},f,{owner:"0x6d4a64C57612841c2C6745dB2a4E4db34F002D20",deployer:"0x302d2451d9f47620374B54c521423Bf0403916A2"}),goerli:Object.assign({},f,{owner:"0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9",deployer:"0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9"}),"goerli-ovm":Object.assign({},f,{owner:"0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9",deployer:"0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9"}),local:Object.assign({},f,{owner:"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"}),"local-ovm":Object.assign({},f,{owner:"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",deployer:"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",oracle:"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"})},d=Object.entries(n[y({network:e,useOvm:b})]).map((([e,a])=>({name:e,address:a})));return a?d.find((({name:e})=>e===a)):d},getVersions:({network:e="mainnet",path:a,fs:b,deploymentPath:t,useOvm:f,byContract:d=!1}={})=>{let s;if(t||a&&b){const n=t?a.join(t,u.VERSIONS_FILENAME):o({network:e,useOvm:f,path:a,file:u.VERSIONS_FILENAME});if(!b.existsSync(n))throw Error("Cannot find versions for network.");s=JSON.parse(b.readFileSync(n))}else s=n[y({network:e,useOvm:f})].versions;return d?Object.values(s).reduce(((e,{tag:a,release:b,date:t,commit:f,block:n,contracts:d})=>{for(const[s,i]of Object.entries(d))e[s]=e[s]||[],e[s].push(Object.assign({tag:a,release:b,date:t,commit:f,block:n},i));return e}),{}):s},networks:["local","mainnet","goerli"],networkToChainId:r,toBytes32:e=>t.rightPad(t.asciiToHex(e),64),fromBytes32:l,wrap:({network:a,deploymentPath:b,fs:t,path:f,useOvm:n=!1})=>["decode","getAST","getPathToNetwork","getSource","getStakingRewards","getShortingRewards","getFeeds","getOffchainFeeds","getSynths","getTarget","getFuturesMarkets","getPerpsMarkets","getPerpsV2ProxiedMarkets","getTokens","getUsers","getVersions"].reduce(((d,s)=>(d[s]=(d={})=>e.exports[s](Object.assign({network:a,deploymentPath:b,fs:t,path:f,useOvm:n},d)),d)),{}),nonUpgradeable:s,releases:i,knownAccounts:{mainnet:[{name:"binance",address:"0xF977814e90dA44bFA03b6295A0616a897441aceC"},{name:"renBTCWallet",address:"0x35ffd6e268610e764ff6944d07760d0efe5e40e5"},{name:"loansAccount",address:"0x62f7A1F94aba23eD2dD108F8D23Aa3e7d452565B"}]}}},2816:(e,a,b)=>{"use strict";b.d(a,{RQ:()=>Be,_R:()=>M});let t=!1,f=!1;const n={debug:1,default:2,info:2,warning:3,error:4,off:5};let d=n.default,s=null;const i=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((a=>{try{if("test"!=="test".normalize(a))throw new Error("bad normalize")}catch(b){e.push(a)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var c,r;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(c||(c={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(r||(r={}));const u="0123456789abcdef";class p{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,a){const b=e.toLowerCase();null==n[b]&&this.throwArgumentError("invalid log level name","logLevel",e),d>n[b]||console.log.apply(console,a)}debug(...e){this._log(p.levels.DEBUG,e)}info(...e){this._log(p.levels.INFO,e)}warn(...e){this._log(p.levels.WARNING,e)}makeError(e,a,b){if(f)return this.makeError("censored error",a,{});a||(a=p.errors.UNKNOWN_ERROR),b||(b={});const t=[];Object.keys(b).forEach((e=>{const a=b[e];try{if(a instanceof Uint8Array){let b="";for(let e=0;e<a.length;e++)b+=u[a[e]>>4],b+=u[15&a[e]];t.push(e+"=Uint8Array(0x"+b+")")}else t.push(e+"="+JSON.stringify(a))}catch(a){t.push(e+"="+JSON.stringify(b[e].toString()))}})),t.push(`code=${a}`),t.push(`version=${this.version}`);const n=e;let d="";switch(a){case r.NUMERIC_FAULT:{d="NUMERIC_FAULT";const a=e;switch(a){case"overflow":case"underflow":case"division-by-zero":d+="-"+a;break;case"negative-power":case"negative-width":d+="-unsupported";break;case"unbound-bitwise-result":d+="-unbound-result"}break}case r.CALL_EXCEPTION:case r.INSUFFICIENT_FUNDS:case r.MISSING_NEW:case r.NONCE_EXPIRED:case r.REPLACEMENT_UNDERPRICED:case r.TRANSACTION_REPLACED:case r.UNPREDICTABLE_GAS_LIMIT:d=a}d&&(e+=" [ See: https://links.ethers.org/v5-errors-"+d+" ]"),t.length&&(e+=" ("+t.join(", ")+")");const s=new Error(e);return s.reason=n,s.code=a,Object.keys(b).forEach((function(e){s[e]=b[e]})),s}throwError(e,a,b){throw this.makeError(e,a,b)}throwArgumentError(e,a,b){return this.throwError(e,p.errors.INVALID_ARGUMENT,{argument:a,value:b})}assert(e,a,b,t){e||this.throwError(a,b,t)}assertArgument(e,a,b,t){e||this.throwArgumentError(a,b,t)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),i&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:i})}checkSafeUint53(e,a){"number"==typeof e&&(null==a&&(a="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(a,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(a,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,a,b){b=b?": "+b:"",e<a&&this.throwError("missing argument"+b,p.errors.MISSING_ARGUMENT,{count:e,expectedCount:a}),e>a&&this.throwError("too many arguments"+b,p.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:a})}checkNew(e,a){e!==Object&&null!=e||this.throwError("missing new",p.errors.MISSING_NEW,{name:a.name})}checkAbstract(e,a){e===a?this.throwError("cannot instantiate abstract class "+JSON.stringify(a.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",p.errors.MISSING_NEW,{name:a.name})}static globalLogger(){return s||(s=new p("logger/5.7.0")),s}static setCensorship(e,a){if(!e&&a&&this.globalLogger().throwError("cannot permanently disable censorship",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),t){if(!e)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}f=!!e,t=!!a}static setLogLevel(e){const a=n[e.toLowerCase()];null!=a?d=a:p.globalLogger().warn("invalid log level - "+e)}static from(e){return new p(e)}}function l(e,a,b){Object.defineProperty(e,a,{enumerable:!0,value:b,writable:!1})}p.errors=r,p.levels=c,new p("properties/5.7.0");const y="abi/5.7.0",o=new p(y),m={};let h={calldata:!0,memory:!0,storage:!0},T={calldata:!0,memory:!0};function x(e,a){if("bytes"===e||"string"===e){if(h[a])return!0}else if("address"===e){if("payable"===a)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&T[a])return!0;return(h[a]||"payable"===a)&&o.throwArgumentError("invalid modifier","name",a),!1}function w(e,a){for(let b in a)l(e,b,a[b])}const g=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),v=new RegExp(/^(.*)\[([0-9]*)\]$/);class M{constructor(e,a){e!==m&&o.throwError("use fromString",p.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),w(this,a);let b=this.type.match(v);w(this,b?{arrayLength:parseInt(b[2]||"-1"),arrayChildren:M.fromObject({type:b[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=g.sighash),g[e]||o.throwArgumentError("invalid format type","format",e),e===g.json){let a={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(a.indexed=this.indexed),this.components&&(a.components=this.components.map((a=>JSON.parse(a.format(e))))),JSON.stringify(a)}let a="";return"array"===this.baseType?(a+=this.arrayChildren.format(e),a+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==g.sighash&&(a+=this.type),a+="("+this.components.map((a=>a.format(e))).join(e===g.full?", ":",")+")"):a+=this.type,e!==g.sighash&&(!0===this.indexed&&(a+=" indexed"),e===g.full&&this.name&&(a+=" "+this.name)),a}static from(e,a){return"string"==typeof e?M.fromString(e,a):M.fromObject(e)}static fromObject(e){return M.isParamType(e)?e:new M(m,{name:e.name||null,type:E(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(M.fromObject):null})}static fromString(e,a){return b=function(e,a){let b=e;function t(a){o.throwArgumentError(`unexpected character at position ${a}`,"param",e)}function f(e){let b={type:"",name:"",parent:e,state:{allowType:!0}};return a&&(b.indexed=!1),b}e=e.replace(/\s/g," ");let n={type:"",name:"",state:{allowType:!0}},d=n;for(let b=0;b<e.length;b++){let n=e[b];switch(n){case"(":d.state.allowType&&""===d.type?d.type="tuple":d.state.allowParams||t(b),d.state.allowType=!1,d.type=E(d.type),d.components=[f(d)],d=d.components[0];break;case")":delete d.state,"indexed"===d.name&&(a||t(b),d.indexed=!0,d.name=""),x(d.type,d.name)&&(d.name=""),d.type=E(d.type);let e=d;d=d.parent,d||t(b),delete e.parent,d.state.allowParams=!1,d.state.allowName=!0,d.state.allowArray=!0;break;case",":delete d.state,"indexed"===d.name&&(a||t(b),d.indexed=!0,d.name=""),x(d.type,d.name)&&(d.name=""),d.type=E(d.type);let s=f(d.parent);d.parent.components.push(s),delete d.parent,d=s;break;case" ":d.state.allowType&&""!==d.type&&(d.type=E(d.type),delete d.state.allowType,d.state.allowName=!0,d.state.allowParams=!0),d.state.allowName&&""!==d.name&&("indexed"===d.name?(a||t(b),d.indexed&&t(b),d.indexed=!0,d.name=""):x(d.type,d.name)?d.name="":d.state.allowName=!1);break;case"[":d.state.allowArray||t(b),d.type+=n,d.state.allowArray=!1,d.state.allowName=!1,d.state.readArray=!0;break;case"]":d.state.readArray||t(b),d.type+=n,d.state.readArray=!1,d.state.allowArray=!0,d.state.allowName=!0;break;default:d.state.allowType?(d.type+=n,d.state.allowParams=!0,d.state.allowArray=!0):d.state.allowName?(d.name+=n,delete d.state.allowArray):d.state.readArray?d.type+=n:t(b)}}return d.parent&&o.throwArgumentError("unexpected eof","param",e),delete n.state,"indexed"===d.name?(a||t(b.length-7),d.indexed&&t(b.length-7),d.indexed=!0,d.name=""):x(d.type,d.name)&&(d.name=""),n.type=E(n.type),n}(e,!!a),M.fromObject({name:b.name,type:b.type,indexed:b.indexed,components:b.components});var b}static isParamType(e){return!(null==e||!e._isParamType)}}function E(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const A=new p("bytes/5.7.0");function C(e){return!!e.toHexString}function k(e){return e.slice||(e.slice=function(){const a=Array.prototype.slice.call(arguments);return k(new Uint8Array(Array.prototype.slice.apply(e,a)))}),e}function D(e){return"number"==typeof e&&e==e&&e%1==0}function F(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(!D(e.length)||e.length<0)return!1;for(let a=0;a<e.length;a++){const b=e[a];if(!D(b)||b<0||b>=256)return!1}return!0}function S(e,a){if(a||(a={}),"number"==typeof e){A.checkSafeUint53(e,"invalid arrayify value");const a=[];for(;e;)a.unshift(255&e),e=parseInt(String(e/256));return 0===a.length&&a.push(0),k(new Uint8Array(a))}if(a.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),C(e)&&(e=e.toHexString()),P(e)){let b=e.substring(2);b.length%2&&("left"===a.hexPad?b="0"+b:"right"===a.hexPad?b+="0":A.throwArgumentError("hex data is odd-length","value",e));const t=[];for(let e=0;e<b.length;e+=2)t.push(parseInt(b.substring(e,e+2),16));return k(new Uint8Array(t))}return F(e)?k(new Uint8Array(e)):A.throwArgumentError("invalid arrayify value","value",e)}function B(e){const a=e.map((e=>S(e))),b=a.reduce(((e,a)=>e+a.length),0),t=new Uint8Array(b);return a.reduce(((e,a)=>(t.set(a,e),e+a.length)),0),k(t)}function P(e,a){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/)||a&&e.length!==2+2*a)}const _="0123456789abcdef";function R(e,a){if(a||(a={}),"number"==typeof e){A.checkSafeUint53(e,"invalid hexlify value");let a="";for(;e;)a=_[15&e]+a,e=Math.floor(e/16);return a.length?(a.length%2&&(a="0"+a),"0x"+a):"0x00"}if("bigint"==typeof e)return(e=e.toString(16)).length%2?"0x0"+e:"0x"+e;if(a.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),C(e))return e.toHexString();if(P(e))return e.length%2&&("left"===a.hexPad?e="0x0"+e.substring(2):"right"===a.hexPad?e+="0":A.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(F(e)){let a="0x";for(let b=0;b<e.length;b++){let t=e[b];a+=_[(240&t)>>4]+_[15&t]}return a}return A.throwArgumentError("invalid hexlify value","value",e)}var O=b(3877),I=b.n(O)().BN;const V=new p("bignumber/5.7.0"),N={},L=9007199254740991;let z=!1;class U{constructor(e,a){e!==N&&V.throwError("cannot call constructor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=a,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return q(W(this).fromTwos(e))}toTwos(e){return q(W(this).toTwos(e))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(e){return q(W(this).add(W(e)))}sub(e){return q(W(this).sub(W(e)))}div(e){return U.from(e).isZero()&&Z("division-by-zero","div"),q(W(this).div(W(e)))}mul(e){return q(W(this).mul(W(e)))}mod(e){const a=W(e);return a.isNeg()&&Z("division-by-zero","mod"),q(W(this).umod(a))}pow(e){const a=W(e);return a.isNeg()&&Z("negative-power","pow"),q(W(this).pow(a))}and(e){const a=W(e);return(this.isNegative()||a.isNeg())&&Z("unbound-bitwise-result","and"),q(W(this).and(a))}or(e){const a=W(e);return(this.isNegative()||a.isNeg())&&Z("unbound-bitwise-result","or"),q(W(this).or(a))}xor(e){const a=W(e);return(this.isNegative()||a.isNeg())&&Z("unbound-bitwise-result","xor"),q(W(this).xor(a))}mask(e){return(this.isNegative()||e<0)&&Z("negative-width","mask"),q(W(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Z("negative-width","shl"),q(W(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Z("negative-width","shr"),q(W(this).shrn(e))}eq(e){return W(this).eq(W(e))}lt(e){return W(this).lt(W(e))}lte(e){return W(this).lte(W(e))}gt(e){return W(this).gt(W(e))}gte(e){return W(this).gte(W(e))}isNegative(){return"-"===this._hex[0]}isZero(){return W(this).isZero()}toNumber(){try{return W(this).toNumber()}catch(e){Z("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return V.throwError("this platform does not support BigInt",p.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?z||(z=!0,V.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?V.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",p.errors.UNEXPECTED_ARGUMENT,{}):V.throwError("BigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{})),W(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof U)return e;if("string"==typeof e)return e.match(/^-?0x[0-9a-f]+$/i)?new U(N,K(e)):e.match(/^-?[0-9]+$/)?new U(N,K(new I(e))):V.throwArgumentError("invalid BigNumber string","value",e);if("number"==typeof e)return e%1&&Z("underflow","BigNumber.from",e),(e>=L||e<=-L)&&Z("overflow","BigNumber.from",e),U.from(String(e));const a=e;if("bigint"==typeof a)return U.from(a.toString());if(F(a))return U.from(R(a));if(a)if(a.toHexString){const e=a.toHexString();if("string"==typeof e)return U.from(e)}else{let e=a._hex;if(null==e&&"BigNumber"===a.type&&(e=a.hex),"string"==typeof e&&(P(e)||"-"===e[0]&&P(e.substring(1))))return U.from(e)}return V.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function K(e){if("string"!=typeof e)return K(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&V.throwArgumentError("invalid hex","value",e),"0x00"===(e=K(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function q(e){return U.from(K(e))}function W(e){const a=U.from(e).toHexString();return"-"===a[0]?new I("-"+a.substring(3),16):new I(a.substring(2),16)}function Z(e,a,b){const t={fault:e,operation:a};return null!=b&&(t.value=b),V.throwError(e,p.errors.NUMERIC_FAULT,t)}const X=new p(y);class Q{constructor(e,a,b,t){this.name=e,this.type=a,this.localName=b,this.dynamic=t}_throwError(e,a){X.throwArgumentError(e,this.localName,a)}}class H{constructor(e){l(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return function(e){let a="0x";return e.forEach((e=>{a+=R(e).substring(2)})),a}(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(B(e._data))}writeBytes(e){let a=S(e);const b=a.length%this.wordSize;return b&&(a=B([a,this._padding.slice(b)])),this._writeData(a)}_getValue(e){let a=S(U.from(e));return a.length>this.wordSize&&X.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:a.length}),a.length%this.wordSize&&(a=B([this._padding.slice(a.length%this.wordSize),a])),a}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,a=>{this._data[e]=this._getValue(a)}}}class j{constructor(e,a,b,t){l(this,"_data",S(e)),l(this,"wordSize",a||32),l(this,"_coerceFunc",b),l(this,"allowLoose",t),this._offset=0}get data(){return R(this._data)}get consumed(){return this._offset}static coerce(e,a){let b=e.match("^u?int([0-9]+)$");return b&&parseInt(b[1])<=48&&(a=a.toNumber()),a}coerce(e,a){return this._coerceFunc?this._coerceFunc(e,a):j.coerce(e,a)}_peekBytes(e,a,b){let t=Math.ceil(a/this.wordSize)*this.wordSize;return this._offset+t>this._data.length&&(this.allowLoose&&b&&this._offset+a<=this._data.length?t=a:X.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+t})),this._data.slice(this._offset,this._offset+t)}subReader(e){return new j(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,a){let b=this._peekBytes(0,e,!!a);return this._offset+=b.length,b.slice(0,e)}readValue(){return U.from(this.readBytes(this.wordSize))}}var G=b(1094),$=b.n(G);const Y=new p("address/5.7.0");function J(e){P(e,20)||Y.throwArgumentError("invalid address","address",e);const a=(e=e.toLowerCase()).substring(2).split(""),b=new Uint8Array(40);for(let e=0;e<40;e++)b[e]=a[e].charCodeAt(0);const t=S((f=b,"0x"+$().keccak_256(S(f))));var f;for(let e=0;e<40;e+=2)t[e>>1]>>4>=8&&(a[e]=a[e].toUpperCase()),(15&t[e>>1])>=8&&(a[e+1]=a[e+1].toUpperCase());return"0x"+a.join("")}const ee={};for(let e=0;e<10;e++)ee[String(e)]=String(e);for(let e=0;e<26;e++)ee[String.fromCharCode(65+e)]=String(10+e);const ae=Math.floor((be=9007199254740991,Math.log10?Math.log10(be):Math.log(be)/Math.LN10));var be;function te(e){let a=null;if("string"!=typeof e&&Y.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),a=J(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&a!==e&&Y.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==function(e){let a=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((e=>ee[e])).join("");for(;a.length>=ae;){let e=a.substring(0,ae);a=parseInt(e,10)%97+a.substring(e.length)}let b=String(98-parseInt(a,10)%97);for(;b.length<2;)b="0"+b;return b}(e)&&Y.throwArgumentError("bad icap checksum","address",e),b=e.substring(4),a=new I(b,36).toString(16);a.length<40;)a="0"+a;a=J("0x"+a)}else Y.throwArgumentError("invalid address","address",e);var b;return a}class fe extends Q{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,a){try{a=te(a)}catch(e){this._throwError(e.message,a)}return e.writeValue(a)}decode(e){return te(function(e,a){for("string"!=typeof e?e=R(e):P(e)||A.throwArgumentError("invalid hex string","value",e),e.length>2*a+2&&A.throwArgumentError("value out of range","value",arguments[1]);e.length<2*a+2;)e="0x0"+e.substring(2);return e}(e.readValue().toHexString(),20))}}class ne extends Q{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,a){return this.coder.encode(e,a)}decode(e){return this.coder.decode(e)}}const de=new p(y);function se(e,a,b){let t=null;if(Array.isArray(b))t=b;else if(b&&"object"==typeof b){let e={};t=a.map((a=>{const t=a.localName;return t||de.throwError("cannot encode object for signature with missing names",p.errors.INVALID_ARGUMENT,{argument:"values",coder:a,value:b}),e[t]&&de.throwError("cannot encode object for signature with duplicate names",p.errors.INVALID_ARGUMENT,{argument:"values",coder:a,value:b}),e[t]=!0,b[t]}))}else de.throwArgumentError("invalid tuple value","tuple",b);a.length!==t.length&&de.throwArgumentError("types/value length mismatch","tuple",b);let f=new H(e.wordSize),n=new H(e.wordSize),d=[];a.forEach(((e,a)=>{let b=t[a];if(e.dynamic){let a=n.length;e.encode(n,b);let t=f.writeUpdatableValue();d.push((e=>{t(e+a)}))}else e.encode(f,b)})),d.forEach((e=>{e(f.length)}));let s=e.appendWriter(f);return s+=e.appendWriter(n),s}function ie(e,a){let b=[],t=e.subReader(0);a.forEach((a=>{let f=null;if(a.dynamic){let b=e.readValue(),n=t.subReader(b.toNumber());try{f=a.decode(n)}catch(e){if(e.code===p.errors.BUFFER_OVERRUN)throw e;f=e,f.baseType=a.name,f.name=a.localName,f.type=a.type}}else try{f=a.decode(e)}catch(e){if(e.code===p.errors.BUFFER_OVERRUN)throw e;f=e,f.baseType=a.name,f.name=a.localName,f.type=a.type}null!=f&&b.push(f)}));const f=a.reduce(((e,a)=>{const b=a.localName;return b&&(e[b]||(e[b]=0),e[b]++),e}),{});a.forEach(((e,a)=>{let t=e.localName;if(!t||1!==f[t])return;if("length"===t&&(t="_length"),null!=b[t])return;const n=b[a];n instanceof Error?Object.defineProperty(b,t,{enumerable:!0,get:()=>{throw n}}):b[t]=n}));for(let e=0;e<b.length;e++){const a=b[e];a instanceof Error&&Object.defineProperty(b,e,{enumerable:!0,get:()=>{throw a}})}return Object.freeze(b)}class ce extends Q{constructor(e,a,b){super("array",e.type+"["+(a>=0?a:"")+"]",b,-1===a||e.dynamic),this.coder=e,this.length=a}defaultValue(){const e=this.coder.defaultValue(),a=[];for(let b=0;b<this.length;b++)a.push(e);return a}encode(e,a){Array.isArray(a)||this._throwError("expected array value",a);let b=this.length;-1===b&&(b=a.length,e.writeValue(a.length)),de.checkArgumentCount(a.length,b,"coder array"+(this.localName?" "+this.localName:""));let t=[];for(let e=0;e<a.length;e++)t.push(this.coder);return se(e,t,a)}decode(e){let a=this.length;-1===a&&(a=e.readValue().toNumber(),32*a>e._data.length&&de.throwError("insufficient data length",p.errors.BUFFER_OVERRUN,{length:e._data.length,count:a}));let b=[];for(let e=0;e<a;e++)b.push(new ne(this.coder));return e.coerce(this.name,ie(e,b))}}class re extends Q{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,a){return e.writeValue(a?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class ue extends Q{constructor(e,a){super(e,e,a,!0)}defaultValue(){return"0x"}encode(e,a){a=S(a);let b=e.writeValue(a.length);return b+=e.writeBytes(a),b}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class pe extends ue{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,R(super.decode(e)))}}class le extends Q{constructor(e,a){let b="bytes"+String(e);super(b,b,a,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,a){let b=S(a);return b.length!==this.size&&this._throwError("incorrect data length",a),e.writeBytes(b)}decode(e){return e.coerce(this.name,R(e.readBytes(this.size)))}}class ye extends Q{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,a){return null!=a&&this._throwError("not null",a),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}const oe=U.from(-1),me=U.from(0),he=U.from(1),Te=U.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class xe extends Q{constructor(e,a,b){const t=(a?"int":"uint")+8*e;super(t,t,b,!1),this.size=e,this.signed=a}defaultValue(){return 0}encode(e,a){let b=U.from(a),t=Te.mask(8*e.wordSize);if(this.signed){let e=t.mask(8*this.size-1);(b.gt(e)||b.lt(e.add(he).mul(oe)))&&this._throwError("value out-of-bounds",a)}else(b.lt(me)||b.gt(t.mask(8*this.size)))&&this._throwError("value out-of-bounds",a);return b=b.toTwos(8*this.size).mask(8*this.size),this.signed&&(b=b.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(b)}decode(e){let a=e.readValue().mask(8*this.size);return this.signed&&(a=a.fromTwos(8*this.size)),e.coerce(this.name,a)}}const we=new p("strings/5.7.0");var ge,ve;function Me(e,a,b,t,f){if(e===ve.BAD_PREFIX||e===ve.UNEXPECTED_CONTINUE){let e=0;for(let t=a+1;t<b.length&&b[t]>>6==2;t++)e++;return e}return e===ve.OVERRUN?b.length-a-1:0}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(ge||(ge={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(ve||(ve={}));const Ee=Object.freeze({error:function(e,a,b,t,f){return we.throwArgumentError(`invalid codepoint at offset ${a}; ${e}`,"bytes",b)},ignore:Me,replace:function(e,a,b,t,f){return e===ve.OVERLONG?(t.push(f),0):(t.push(65533),Me(e,a,b))}});function Ae(e,a){return function(e,a){null==a&&(a=Ee.error),e=S(e);const b=[];let t=0;for(;t<e.length;){const f=e[t++];if(f>>7==0){b.push(f);continue}let n=null,d=null;if(192==(224&f))n=1,d=127;else if(224==(240&f))n=2,d=2047;else{if(240!=(248&f)){t+=a(128==(192&f)?ve.UNEXPECTED_CONTINUE:ve.BAD_PREFIX,t-1,e,b);continue}n=3,d=65535}if(t-1+n>=e.length){t+=a(ve.OVERRUN,t-1,e,b);continue}let s=f&(1<<8-n-1)-1;for(let f=0;f<n;f++){let f=e[t];if(128!=(192&f)){t+=a(ve.MISSING_CONTINUE,t,e,b),s=null;break}s=s<<6|63&f,t++}null!==s&&(s>1114111?t+=a(ve.OUT_OF_RANGE,t-1-n,e,b,s):s>=55296&&s<=57343?t+=a(ve.UTF16_SURROGATE,t-1-n,e,b,s):s<=d?t+=a(ve.OVERLONG,t-1-n,e,b,s):b.push(s))}return b}(e,a).map((e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e))))).join("")}class Ce extends ue{constructor(e){super("string",e)}defaultValue(){return""}encode(e,a){return super.encode(e,function(e,a=ge.current){a!=ge.current&&(we.checkNormalize(),e=e.normalize(a));let b=[];for(let a=0;a<e.length;a++){const t=e.charCodeAt(a);if(t<128)b.push(t);else if(t<2048)b.push(t>>6|192),b.push(63&t|128);else if(55296==(64512&t)){a++;const f=e.charCodeAt(a);if(a>=e.length||56320!=(64512&f))throw new Error("invalid utf-8 string");const n=65536+((1023&t)<<10)+(1023&f);b.push(n>>18|240),b.push(n>>12&63|128),b.push(n>>6&63|128),b.push(63&n|128)}else b.push(t>>12|224),b.push(t>>6&63|128),b.push(63&t|128)}return S(b)}(a))}decode(e){return Ae(super.decode(e))}}class ke extends Q{constructor(e,a){let b=!1;const t=[];e.forEach((e=>{e.dynamic&&(b=!0),t.push(e.type)})),super("tuple","tuple("+t.join(",")+")",a,b),this.coders=e}defaultValue(){const e=[];this.coders.forEach((a=>{e.push(a.defaultValue())}));const a=this.coders.reduce(((e,a)=>{const b=a.localName;return b&&(e[b]||(e[b]=0),e[b]++),e}),{});return this.coders.forEach(((b,t)=>{let f=b.localName;f&&1===a[f]&&("length"===f&&(f="_length"),null==e[f]&&(e[f]=e[t]))})),Object.freeze(e)}encode(e,a){return se(e,this.coders,a)}decode(e){return e.coerce(this.name,ie(e,this.coders))}}const De=new p(y),Fe=new RegExp(/^bytes([0-9]*)$/),Se=new RegExp(/^(u?int)([0-9]*)$/);class Be{constructor(e){l(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new fe(e.name);case"bool":return new re(e.name);case"string":return new Ce(e.name);case"bytes":return new pe(e.name);case"array":return new ce(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new ke((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new ye(e.name)}let a=e.type.match(Se);if(a){let b=parseInt(a[2]||"256");return(0===b||b>256||b%8!=0)&&De.throwArgumentError("invalid "+a[1]+" bit length","param",e),new xe(b/8,"int"===a[1],e.name)}if(a=e.type.match(Fe),a){let b=parseInt(a[1]);return(0===b||b>32)&&De.throwArgumentError("invalid bytes length","param",e),new le(b,e.name)}return De.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,a){return new j(e,this._getWordSize(),this.coerceFunc,a)}_getWriter(){return new H(this._getWordSize())}getDefaultValue(e){const a=e.map((e=>this._getCoder(M.from(e))));return new ke(a,"_").defaultValue()}encode(e,a){e.length!==a.length&&De.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:e.length,values:a.length},value:{types:e,values:a}});const b=e.map((e=>this._getCoder(M.from(e)))),t=new ke(b,"_"),f=this._getWriter();return t.encode(f,a),f.data}decode(e,a,b){const t=e.map((e=>this._getCoder(M.from(e))));return new ke(t,"_").decode(this._getReader(S(a),b))}}new Be},3877:function(e,a,b){!function(e,a){"use strict";function t(e,a){if(!e)throw new Error(a||"Assertion failed")}function f(e,a){e.super_=a;var b=function(){};b.prototype=a.prototype,e.prototype=new b,e.prototype.constructor=e}function n(e,a,b){if(n.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==a&&"be"!==a||(b=a,a=10),this._init(e||0,a||10,b||"be"))}var d;"object"==typeof e?e.exports=n:a.BN=n,n.BN=n,n.wordSize=26;try{d="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:b(8677).Buffer}catch(e){}function s(e,a){var b=e.charCodeAt(a);return b>=48&&b<=57?b-48:b>=65&&b<=70?b-55:b>=97&&b<=102?b-87:void t(!1,"Invalid character in "+e)}function i(e,a,b){var t=s(e,b);return b-1>=a&&(t|=s(e,b-1)<<4),t}function c(e,a,b,f){for(var n=0,d=0,s=Math.min(e.length,b),i=a;i<s;i++){var c=e.charCodeAt(i)-48;n*=f,d=c>=49?c-49+10:c>=17?c-17+10:c,t(c>=0&&d<f,"Invalid character"),n+=d}return n}function r(e,a){e.words=a.words,e.length=a.length,e.negative=a.negative,e.red=a.red}if(n.isBN=function(e){return e instanceof n||null!==e&&"object"==typeof e&&e.constructor.wordSize===n.wordSize&&Array.isArray(e.words)},n.max=function(e,a){return e.cmp(a)>0?e:a},n.min=function(e,a){return e.cmp(a)<0?e:a},n.prototype._init=function(e,a,b){if("number"==typeof e)return this._initNumber(e,a,b);if("object"==typeof e)return this._initArray(e,a,b);"hex"===a&&(a=16),t(a===(0|a)&&a>=2&&a<=36);var f=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(f++,this.negative=1),f<e.length&&(16===a?this._parseHex(e,f,b):(this._parseBase(e,a,f),"le"===b&&this._initArray(this.toArray(),a,b)))},n.prototype._initNumber=function(e,a,b){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(t(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===b&&this._initArray(this.toArray(),a,b)},n.prototype._initArray=function(e,a,b){if(t("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var n,d,s=0;if("be"===b)for(f=e.length-1,n=0;f>=0;f-=3)d=e[f]|e[f-1]<<8|e[f-2]<<16,this.words[n]|=d<<s&67108863,this.words[n+1]=d>>>26-s&67108863,(s+=24)>=26&&(s-=26,n++);else if("le"===b)for(f=0,n=0;f<e.length;f+=3)d=e[f]|e[f+1]<<8|e[f+2]<<16,this.words[n]|=d<<s&67108863,this.words[n+1]=d>>>26-s&67108863,(s+=24)>=26&&(s-=26,n++);return this._strip()},n.prototype._parseHex=function(e,a,b){this.length=Math.ceil((e.length-a)/6),this.words=new Array(this.length);for(var t=0;t<this.length;t++)this.words[t]=0;var f,n=0,d=0;if("be"===b)for(t=e.length-1;t>=a;t-=2)f=i(e,a,t)<<n,this.words[d]|=67108863&f,n>=18?(n-=18,d+=1,this.words[d]|=f>>>26):n+=8;else for(t=(e.length-a)%2==0?a+1:a;t<e.length;t+=2)f=i(e,a,t)<<n,this.words[d]|=67108863&f,n>=18?(n-=18,d+=1,this.words[d]|=f>>>26):n+=8;this._strip()},n.prototype._parseBase=function(e,a,b){this.words=[0],this.length=1;for(var t=0,f=1;f<=67108863;f*=a)t++;t--,f=f/a|0;for(var n=e.length-b,d=n%t,s=Math.min(n,n-d)+b,i=0,r=b;r<s;r+=t)i=c(e,r,r+t,a),this.imuln(f),this.words[0]+i<67108864?this.words[0]+=i:this._iaddn(i);if(0!==d){var u=1;for(i=c(e,r,e.length,a),r=0;r<d;r++)u*=a;this.imuln(u),this.words[0]+i<67108864?this.words[0]+=i:this._iaddn(i)}this._strip()},n.prototype.copy=function(e){e.words=new Array(this.length);for(var a=0;a<this.length;a++)e.words[a]=this.words[a];e.length=this.length,e.negative=this.negative,e.red=this.red},n.prototype._move=function(e){r(e,this)},n.prototype.clone=function(){var e=new n(null);return this.copy(e),e},n.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch(e){n.prototype.inspect=u}else n.prototype.inspect=u;function u(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var p=["","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"],l=[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];function o(e,a,b){b.negative=a.negative^e.negative;var t=e.length+a.length|0;b.length=t,t=t-1|0;var f=0|e.words[0],n=0|a.words[0],d=f*n,s=67108863&d,i=d/67108864|0;b.words[0]=s;for(var c=1;c<t;c++){for(var r=i>>>26,u=67108863&i,p=Math.min(c,a.length-1),l=Math.max(0,c-e.length+1);l<=p;l++){var y=c-l|0;r+=(d=(f=0|e.words[y])*(n=0|a.words[l])+u)/67108864|0,u=67108863&d}b.words[c]=0|u,i=0|r}return 0!==i?b.words[c]=0|i:b.length--,b._strip()}n.prototype.toString=function(e,a){var b;if(a=0|a||1,16===(e=e||10)||"hex"===e){b="";for(var f=0,n=0,d=0;d<this.length;d++){var s=this.words[d],i=(16777215&(s<<f|n)).toString(16);n=s>>>24-f&16777215,(f+=2)>=26&&(f-=26,d--),b=0!==n||d!==this.length-1?p[6-i.length]+i+b:i+b}for(0!==n&&(b=n.toString(16)+b);b.length%a!=0;)b="0"+b;return 0!==this.negative&&(b="-"+b),b}if(e===(0|e)&&e>=2&&e<=36){var c=l[e],r=y[e];b="";var u=this.clone();for(u.negative=0;!u.isZero();){var o=u.modrn(r).toString(e);b=(u=u.idivn(r)).isZero()?o+b:p[c-o.length]+o+b}for(this.isZero()&&(b="0"+b);b.length%a!=0;)b="0"+b;return 0!==this.negative&&(b="-"+b),b}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},n.prototype.toJSON=function(){return this.toString(16,2)},d&&(n.prototype.toBuffer=function(e,a){return this.toArrayLi