@defiverse/balancer-sdk-megaeth 0.1.252

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.
@@ -0,0 +1,489 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@ethersproject/abi"),require("@ethersproject/constants"),require("@ethersproject/bignumber"),require("@ethersproject/address"),require("@ethersproject/contracts"),require("@ethersproject/bytes"),require("@ethersproject/abstract-signer"),require("axios"),require("lodash"),require("@defiverse/sor"),require("@balancer-labs/typechain"),require("@ethersproject/providers"),require("graphql-request"),require("graphql"),require("json-to-graphql-query")):"function"==typeof define&&define.amd?define(["exports","@ethersproject/abi","@ethersproject/constants","@ethersproject/bignumber","@ethersproject/address","@ethersproject/contracts","@ethersproject/bytes","@ethersproject/abstract-signer","axios","lodash","@defiverse/sor","@balancer-labs/typechain","@ethersproject/providers","graphql-request","graphql","json-to-graphql-query"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["balancer-js"]={},e.abi,e.constants,e.bignumber,e.address,e.contracts,e.bytes,e.abstractSigner,e.axios,e.lodash,e.sor,e.typechain,e.providers,e.graphqlRequest,e.graphql,e.jsonToGraphqlQuery)}(this,(function(e,t,a,n,s,i,r,o,d,c,l,p,u,y,b,m){"use strict";function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return e[a]}})}})),t.default=e,Object.freeze(t)}var T,g,I,w,E,x=f(d),A=h(l);e.StablePoolJoinKind=void 0,(T=e.StablePoolJoinKind||(e.StablePoolJoinKind={}))[T.INIT=0]="INIT",T[T.EXACT_TOKENS_IN_FOR_BPT_OUT=1]="EXACT_TOKENS_IN_FOR_BPT_OUT",T[T.TOKEN_IN_FOR_EXACT_BPT_OUT=2]="TOKEN_IN_FOR_EXACT_BPT_OUT",e.StablePhantomPoolJoinKind=void 0,(g=e.StablePhantomPoolJoinKind||(e.StablePhantomPoolJoinKind={}))[g.INIT=0]="INIT",g[g.COLLECT_PROTOCOL_FEES=1]="COLLECT_PROTOCOL_FEES",e.StablePoolExitKind=void 0,(I=e.StablePoolExitKind||(e.StablePoolExitKind={}))[I.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT=0]="EXACT_BPT_IN_FOR_ONE_TOKEN_OUT",I[I.EXACT_BPT_IN_FOR_TOKENS_OUT=1]="EXACT_BPT_IN_FOR_TOKENS_OUT",I[I.BPT_IN_FOR_EXACT_TOKENS_OUT=2]="BPT_IN_FOR_EXACT_TOKENS_OUT";class S{constructor(){}}S.joinInit=a=>t.defaultAbiCoder.encode(["uint256","uint256[]"],[e.StablePoolJoinKind.INIT,a]),S.joinCollectProtocolFees=()=>t.defaultAbiCoder.encode(["uint256"],[e.StablePhantomPoolJoinKind.COLLECT_PROTOCOL_FEES]),S.joinExactTokensInForBPTOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256[]","uint256"],[e.StablePoolJoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT,a,n]),S.joinTokenInForExactBPTOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256","uint256"],[e.StablePoolJoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT,a,n]),S.exitExactBPTInForOneTokenOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256","uint256"],[e.StablePoolExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,a,n]),S.exitExactBPTInForTokensOut=a=>t.defaultAbiCoder.encode(["uint256","uint256"],[e.StablePoolExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT,a]),S.exitBPTInForExactTokensOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256[]","uint256"],[e.StablePoolExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT,a,n]),e.WeightedPoolJoinKind=void 0,(w=e.WeightedPoolJoinKind||(e.WeightedPoolJoinKind={}))[w.INIT=0]="INIT",w[w.EXACT_TOKENS_IN_FOR_BPT_OUT=1]="EXACT_TOKENS_IN_FOR_BPT_OUT",w[w.TOKEN_IN_FOR_EXACT_BPT_OUT=2]="TOKEN_IN_FOR_EXACT_BPT_OUT",w[w.ALL_TOKENS_IN_FOR_EXACT_BPT_OUT=3]="ALL_TOKENS_IN_FOR_EXACT_BPT_OUT",e.WeightedPoolExitKind=void 0,(E=e.WeightedPoolExitKind||(e.WeightedPoolExitKind={}))[E.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT=0]="EXACT_BPT_IN_FOR_ONE_TOKEN_OUT",E[E.EXACT_BPT_IN_FOR_TOKENS_OUT=1]="EXACT_BPT_IN_FOR_TOKENS_OUT",E[E.BPT_IN_FOR_EXACT_TOKENS_OUT=2]="BPT_IN_FOR_EXACT_TOKENS_OUT",E[E.MANAGEMENT_FEE_TOKENS_OUT=3]="MANAGEMENT_FEE_TOKENS_OUT";class P{constructor(){}}P.joinInit=a=>t.defaultAbiCoder.encode(["uint256","uint256[]"],[e.WeightedPoolJoinKind.INIT,a]),P.joinExactTokensInForBPTOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256[]","uint256"],[e.WeightedPoolJoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT,a,n]),P.joinTokenInForExactBPTOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256","uint256"],[e.WeightedPoolJoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT,a,n]),P.joinAllTokensInForExactBPTOut=a=>t.defaultAbiCoder.encode(["uint256","uint256"],[e.WeightedPoolJoinKind.ALL_TOKENS_IN_FOR_EXACT_BPT_OUT,a]),P.exitExactBPTInForOneTokenOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256","uint256"],[e.WeightedPoolExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,a,n]),P.exitExactBPTInForTokensOut=a=>t.defaultAbiCoder.encode(["uint256","uint256"],[e.WeightedPoolExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT,a]),P.exitBPTInForExactTokensOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256[]","uint256"],[e.WeightedPoolExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT,a,n]);class _{constructor(){}}_.exitForManagementFees=()=>t.defaultAbiCoder.encode(["uint256"],[e.WeightedPoolExitKind.MANAGEMENT_FEE_TOKENS_OUT]);var B,O;e.ComposableStablePoolJoinKind=void 0,(B=e.ComposableStablePoolJoinKind||(e.ComposableStablePoolJoinKind={}))[B.INIT=0]="INIT",B[B.EXACT_TOKENS_IN_FOR_BPT_OUT=1]="EXACT_TOKENS_IN_FOR_BPT_OUT",B[B.TOKEN_IN_FOR_EXACT_BPT_OUT=2]="TOKEN_IN_FOR_EXACT_BPT_OUT",e.ComposableStablePoolExitKind=void 0,(O=e.ComposableStablePoolExitKind||(e.ComposableStablePoolExitKind={}))[O.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT=0]="EXACT_BPT_IN_FOR_ONE_TOKEN_OUT",O[O.BPT_IN_FOR_EXACT_TOKENS_OUT=1]="BPT_IN_FOR_EXACT_TOKENS_OUT";class v{constructor(){}}v.joinInit=a=>t.defaultAbiCoder.encode(["uint256","uint256[]"],[e.ComposableStablePoolJoinKind.INIT,a]),v.joinCollectProtocolFees=()=>t.defaultAbiCoder.encode(["uint256"],[e.StablePhantomPoolJoinKind.COLLECT_PROTOCOL_FEES]),v.joinExactTokensInForBPTOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256[]","uint256"],[e.ComposableStablePoolJoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT,a,n]),v.joinTokenInForExactBPTOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256","uint256"],[e.ComposableStablePoolJoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT,a,n]),v.exitExactBPTInForOneTokenOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256","uint256"],[e.ComposableStablePoolExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,a,n]),v.exitBPTInForExactTokensOut=(a,n)=>t.defaultAbiCoder.encode(["uint256","uint256[]","uint256"],[e.ComposableStablePoolExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT,a,n]);var k="production"===process.env.NODE_ENV,N="Invariant failed";function C(e,t){if(!e){if(k)throw new Error(N);var a="function"==typeof t?t():t,n=a?"".concat(N,": ").concat(a):N;throw new Error(n)}}const D=e=>(C(66===e.length,"Invalid poolId length"),e.slice(0,42)),R=e=>{C(66===e.length,"Invalid poolId length");const t=parseInt(e[45]);return C(t<3,"Invalid pool specialization"),t},F=e=>(C(66===e.length,"Invalid poolId length"),n.BigNumber.from(`0x${e.slice(46)}`));var M;e.Network=void 0,(M=e.Network||(e.Network={}))[M.MAINNET=1]="MAINNET",M[M.ROPSTEN=3]="ROPSTEN",M[M.RINKEBY=4]="RINKEBY",M[M.GOERLI=5]="GOERLI",M[M["GÖRLI"]=5]="GÖRLI",M[M.OPTIMISM=10]="OPTIMISM",M[M.KOVAN=42]="KOVAN",M[M.GNOSIS=100]="GNOSIS",M[M.POLYGON=137]="POLYGON",M[M.ARBITRUM=42161]="ARBITRUM",M[M.DEFIVERSE=16116]="DEFIVERSE",M[M.DEFIVERSE_TESTNET=17117]="DEFIVERSE_TESTNET",M[M.OASYS=248]="OASYS",M[M.OASYS_TESTNET=9372]="OASYS_TESTNET";const L={IdsMap:{},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","Linear","ERC4626Linear"],Stable:{AllowList:["0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063","0xfeadd389a5c427952d8fdb8057d6c8ba1156cc56000000000000000000000066","0x9f19a375709baf0e8e35c2c5c65aca676c4c719100000000000000000000006e","0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080","0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112","0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012","0xfeadd389a5c427952d8fdb8057d6c8ba1156cc5600020000000000000000001e","0x6b15a01b5d46a5321b627bd7deef1af57bc629070000000000000000000000d4","0xe08590bde837eb9b2d42aa1196469d6e08fe96ec000200000000000000000101","0xb4c23af48e79f73e3a7e36c0e54eb38e1ce1755e0002000000000000000000d3","0x9be7de742865d021c0e8fb9d64311b2c040c1ec1000200000000000000000012","0x9f19a375709baf0e8e35c2c5c65aca676c4c7191000200000000000000000022","0x1533a3278f3f9141d5f820a184ea4b017fce2382000000000000000000000016","0xf38cf113d2d4f60c36cbd95af2f48a9a0167045a00000000000000000000005b","0x0d34e5dd4d8f043557145598e4e2dc286b35fd4f000000000000000000000068","0x386b5d43ba8b97c43d4afb4cdae7877a1b295e8a000000000000000000000020","0x5028497af0c9a54ea8c6d42a054c0341b9fc616800020000000000000000007b","0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe","0x8fd162f338b770f7e879030830cde9173367f3010000000000000000000004d8","0xd387dfd3a786e7caa06e6cf0c675352c7ffff30400000000000000000000063e","0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366"]},Investment:{AllowList:["0x4fd63966879300cafafbb35d157dc5229278ed23000100000000000000000169","0x37a6fc079cad790e556baedda879358e076ef1b3000100000000000000000348","0xccf5575570fac94cec733a58ff91bb3d073085c70002000000000000000000af","0xe7b1d394f3b40abeaa0b64a545dbcf89da1ecb3f00010000000000000000009a","0x3b40d7d5ae25df2561944dd68b252016c4c7b2800001000000000000000000c2"]},Factories:{"0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0":"oracleWeightedPool","0x8e9aa87e45e92bad84d5f8dd1bff34fb92637de9":"weightedPool","0xc66ba2b6595d3613ccab350c886ace23866ede24":"stablePool","0x67d27634e44793fe63c467035e31ea8635117cd4":"stablePool","0x751dfdace1ad995ff13c927f6f761c6604532c79":"stablePool","0x590e544e7ca956bb878f8c873e82e65550d67d2f":"stablePool","0x7dfdef5f355096603419239ce743bfaf1120312b":"weightedPool","0xcf0a32bbef8f064969f21f7e02328fb577382018":"weightedPool","0x2433477a10fc5d31b9513c638f19ee85caed53fd":"stablePool","0xebfd5681977e38af65a7487dc70b8221d089ccad":"stablePool","0x751a0bc0e3f75b38e01cf25bfce7ff36de1c87de":"liquidityBootstrappingPool","0x0f3e0c4218b7b0108a3643cfe9d3ec0d4f57c54e":"liquidityBootstrappingPool","0x142b9666a0a3a30477b052962dda81547e7029ab":"liquidityBootstrappingPool","0x1802953277fd955f9a254b80aa0582f193cf1d77":"liquidityBootstrappingPool","0x48767f9f868a4a7b86a90736632f6e44c2df7fa9":"managedPool","0x0f7bb7ce7b6ed9366f9b6b910adefe72dc538193":"managedPool","0xacd615b3705b9c880e4e7293f1030b34e57b4c1c":"managedPool","0xb08e16cfc07c684daa2f93c70323badb2a6cbfd2":"boostedPool","0xdae7e32adc5d490a43ccba1f0c736033f2b4efca":"boostedPool","0xc128a9954e6c874ea3d62ce62b468ba073093f25":"boostedPool","0x6c7f4d97269ece163fd08d5c2584a21e4a33934c":"boostedPool"},Stakable:{AllowList:[]},Metadata:{"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe":{name:"Balancer Boosted Aave USD",hasIcon:!0},"0x8fd162f338b770f7e879030830cde9173367f3010000000000000000000004d8":{name:"Balancer Boosted Aave USD",hasIcon:!0},"0xd387dfd3a786e7caa06e6cf0c675352c7ffff30400000000000000000000063e":{name:"Balancer Stable USD",hasIcon:!0}}},U={[e.Network.KOVAN]:{IdsMap:{staBAL:"0xd387dfd3a786e7caa06e6cf0c675352c7ffff30400000000000000000000063e",bbAaveUSD:{v1:"0x8fd162f338b770f7e879030830cde9173367f3010000000000000000000004d8",v2:""},veBAL:"0xdc2ecfdf2688f92c85064be0b929693acc6dbca6000200000000000000000701"},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:["0x22d398c68030ef6b1c55321cca6e0cecc5c93b2f000200000000000000000678","0xca1eb8624be8e11418f629559321587197557e0c000200000000000000000682","0xa21da5768186c1bc0f56dd72aa94672d77bdf23e00020000000000000000067a","0x7f9db0d15eea32e205b7df0fa5184f4a8a905abb000200000000000000000683","0x72c5a86831f019df6fac146fc14ef60ebe0d5f2600020000000000000000067f","0x542b9f6fd4500b94d453974d8c70783ef794ff6a00020000000000000000067c","0x47f9309a8c5a68a93ac27a4cccc0e222cd3adfa2000200000000000000000684","0x3f3050a0fe84778aeff96906c9218b318f924d22000200000000000000000680","0x31e61587b5dc148ae42ae323655fb8d7af7bb86600020000000000000000067d","0x28efa7f86341aa0ad534bdfb033edb4f4ac6adf700020000000000000000067e","0x10ee90b9ff4b9a44a773107280c0ce083619286800020000000000000000067b"],ExcludedPoolTypes:["Element","AaveLinear","Linear","ERC4626Linear"],Stable:{AllowList:["0x6b15a01b5d46a5321b627bd7deef1af57bc629070000000000000000000000d4","0xe08590bde837eb9b2d42aa1196469d6e08fe96ec000200000000000000000101","0xb4c23af48e79f73e3a7e36c0e54eb38e1ce1755e0002000000000000000000d3","0x8fd162f338b770f7e879030830cde9173367f3010000000000000000000004d8","0xd387dfd3a786e7caa06e6cf0c675352c7ffff30400000000000000000000063e"]},Investment:{AllowList:["0x4fd63966879300cafafbb35d157dc5229278ed23000100000000000000000169","0x37a6fc079cad790e556baedda879358e076ef1b3000100000000000000000348"]},Factories:{"0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0":"oracleWeightedPool","0x8e9aa87e45e92bad84d5f8dd1bff34fb92637de9":"weightedPool","0xc66ba2b6595d3613ccab350c886ace23866ede24":"stablePool","0x1b57f637ce3408f1f834b0b70f9a595b062daea7":"liquidityBootstrappingPool","0x751dfdace1ad995ff13c927f6f761c6604532c79":"stablePool","0x590e544e7ca956bb878f8c873e82e65550d67d2f":"stablePool","0xb08e16cfc07c684daa2f93c70323badb2a6cbfd2":"managedPool","0x6c7f4d97269ece163fd08d5c2584a21e4a33934c":"boostedPool","0x1f47ab83420cd1f818df9acbd6ee68341bb91592":"stablePool"},Stakable:{AllowList:["0xf767f0a3fcf1eafec2180b7de79d0c559d7e7e370001000000000000000003e3","0xdc2ecfdf2688f92c85064be0b929693acc6dbca6000200000000000000000701","0x647c1fd457b95b75d0972ff08fe01d7d7bda05df000200000000000000000001","0x8fd162f338b770f7e879030830cde9173367f3010000000000000000000004d8"]},Metadata:{"0x8fd162f338b770f7e879030830cde9173367f3010000000000000000000004d8":{name:"Balancer Boosted Aave USD",hasIcon:!1},"0xd387dfd3a786e7caa06e6cf0c675352c7ffff30400000000000000000000063e":{name:"Balancer Stable USD",hasIcon:!1}}},[e.Network.GOERLI]:{IdsMap:{staBAL:"0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2000000000000000000000062",bbAaveUSD:{v1:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f",v2:"0x3d5981bdd8d3e49eb7bbdc1d2b156a3ee019c18e0000000000000000000001a7"},veBAL:"0xf8a0623ab66f985effc1c69d05f1af4badb01b00000200000000000000000060"},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:["0x22d398c68030ef6b1c55321cca6e0cecc5c93b2f000200000000000000000678"],ExcludedPoolTypes:["Element","AaveLinear","Linear","ERC4626Linear"],Stable:{AllowList:["0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f","0xb60e46d90f2de35f7062a27d3a98749414036d5d000200000000000000000061","0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2000000000000000000000062","0xc957b1acceb21707b782eb8eee2ed8e20088463d000200000000000000000076","0x3d5981bdd8d3e49eb7bbdc1d2b156a3ee019c18e0000000000000000000001a7","0x14f93df8a4e37bfdb49d2cec4789df7a010603d700000000000000000000011d","0x00a62d31b6c776b6813543bc99ff265f7222dbe100000000000000000000011e","0x0c925fce89a22e36ebd9b3c6e0262234e853d2f600000000000000000000019c"]},Investment:{AllowList:[]},Factories:{"0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0":"oracleWeightedPool","0x8e9aa87e45e92bad84d5f8dd1bff34fb92637de9":"weightedPool","0x44afeb87c871d8fea9398a026dea2bd3a13f5769":"stablePool","0xa55f73e2281c60206ba43a3590db07b8955832be":"stablePool","0xb48cc42c45d262534e46d5965a9ac496f1b7a830":"liquidityBootstrappingPool","0xb0c726778c3ae4b3454d85557a48e8fa502bdd6a":"liquidityBootstrappingPool","0x41e9036ae350baedcc7107760a020dca3c0731ec":"boostedPool","0xb848f50141f3d4255b37ac288c25c109104f2158":"composableStablePool","0x94f68b54191f62f781fe8298a8a5fa3ed772d227":"weightedPool"},Stakable:{AllowList:["0x16faf9f73748013155b7bc116a3008b57332d1e600020000000000000000005b","0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f","0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2000000000000000000000062","0x67f8fcb9d3c463da05de1392efdbb2a87f8599ea000200000000000000000059"]},Metadata:{"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f":{name:"Balancer Boosted Aave USD",hasIcon:!1}}},[e.Network.MAINNET]:{IdsMap:{staBAL:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063",bbAaveUSD:{v1:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe",v2:"0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d"},veBAL:"0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014"},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","Linear","ERC4626Linear","Gyro2","Gyro3"],Stable:{AllowList:["0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063","0xfeadd389a5c427952d8fdb8057d6c8ba1156cc56000000000000000000000066","0x9f19a375709baf0e8e35c2c5c65aca676c4c719100000000000000000000006e","0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080","0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112","0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe","0x851523a36690bf267bbfec389c823072d82921a90002000000000000000001ed","0x3dd0843a028c86e0b760b1a76929d1c5ef93a2dd000200000000000000000249","0x2d011adf89f0576c9b722c28269fcb5d50c2d17900020000000000000000024d","0x178e029173417b1f9c8bc16dcec6f697bc32374600000000000000000000025d","0xf93579002dbe8046c43fefe86ec78b1112247bb80000000000000000000002bc","0xf3aeb3abba741f0eece8a1b1d2f11b85899951cb000200000000000000000351","0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d","0x5b3240b6be3e7487d61cd1afdfc7fe4fa1d81e6400000000000000000000037b"]},Investment:{AllowList:["0xccf5575570fac94cec733a58ff91bb3d073085c70002000000000000000000af","0xe7b1d394f3b40abeaa0b64a545dbcf89da1ecb3f00010000000000000000009a","0x3b40d7d5ae25df2561944dd68b252016c4c7b2800001000000000000000000c2"]},Factories:{"0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0":"oracleWeightedPool","0x8e9aa87e45e92bad84d5f8dd1bff34fb92637de9":"weightedPool","0xc66ba2b6595d3613ccab350c886ace23866ede24":"stablePool","0x67d27634e44793fe63c467035e31ea8635117cd4":"stablePool","0x751a0bc0e3f75b38e01cf25bfce7ff36de1c87de":"liquidityBootstrappingPool","0x0f3e0c4218b7b0108a3643cfe9d3ec0d4f57c54e":"liquidityBootstrappingPool","0x48767f9f868a4a7b86a90736632f6e44c2df7fa9":"managedPool","0xb08e16cfc07c684daa2f93c70323badb2a6cbfd2":"boostedPool","0x8df6efec5547e31b0eb7d1291b511ff8a2bf987c":"stablePool","0xf9ac7b9df2b3454e841110cce5550bd5ac6f875f":"composableStablePool","0xcc508a455f5b0073973107db6a878ddbdab957bc":"weightedPool"},Stakable:{AllowList:["0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063","0x072f14b85add63488ddad88f855fda4a99d6ac9b000200000000000000000027","0x0b09dea16768f0799065c475be02919503cb2a3500020000000000000000001a","0x186084ff790c65088ba694df11758fae4943ee9e000200000000000000000013","0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112","0x27c9f71cc31464b906e0006d4fcbc8900f48f15f00020000000000000000010f","0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080","0x350196326aeaa9b98f1903fb5e8fc2686f85318c000200000000000000000084","0x3e5fa9518ea95c3e533eb377c001702a9aacaa32000200000000000000000052","0x51735bdfbfe3fc13dea8dc6502e2e958989429610002000000000000000000a0","0x5d66fff62c17d841935b60df5f07f6cf79bd0f4700020000000000000000014c","0x5f7fa48d765053f8dd85e052843e12d23e3d7bc50002000000000000000000c0","0x702605f43471183158938c1a3e5f5a359d7b31ba00020000000000000000009f","0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe","0x7edde0cb05ed19e03a9a47cd5e53fc57fde1c80c0002000000000000000000c8","0x8f4205e1604133d1875a3e771ae7e4f2b086563900020000000000000000010e","0x90291319f1d4ea3ad4db0dd8fe9e12baf749e84500020000000000000000013c","0x96646936b91d6b9d7d0c47c496afbf3d6ec7b6f8000200000000000000000019","0x96ba9025311e2f47b840a1f68ed57a3df1ea8747000200000000000000000160","0xa02e4b3d18d4e6b8d18ac421fbc3dfff8933c40a00020000000000000000004b","0xa6f548df93de924d73be7d25dc02554c6bd66db500020000000000000000000e","0xbaeec99c90e3420ec6c1e7a769d2a856d2898e4d00020000000000000000008a","0xbf96189eee9357a95c7719f4f5047f76bde804e5000200000000000000000087","0xe2469f47ab58cf9cf59f9822e3c5de4950a41c49000200000000000000000089","0xe99481dc77691d8e2456e5f3f61c1810adfc1503000200000000000000000018","0xec60a5fef79a92c741cb74fdd6bfc340c0279b01000200000000000000000015","0xedf085f65b4f6c155e13155502ef925c9a756003000200000000000000000123","0xefaa1604e82e1b3af8430b90192c1b9e8197e377000200000000000000000021","0xf4c0dd9b82da36c07605df83c8a416f11724d88b000200000000000000000026","0xf5aaf7ee8c39b651cebf5f1f50c10631e78e0ef9000200000000000000000069","0xfeadd389a5c427952d8fdb8057d6c8ba1156cc56000000000000000000000066","0x92762b42a06dcdddc5b7362cfb01e631c4d44b40000200000000000000000182","0xde8c195aa41c11a0c4787372defbbddaa31306d2000200000000000000000181","0x17ddd9646a69c9445cd8a9f921d4cd93bf50d108000200000000000000000159","0xc45d42f801105e861e86658648e3678ad7aa70f900010000000000000000011e","0x2d344a84bac123660b021eebe4eb6f12ba25fe8600020000000000000000018a","0xb460daa847c45f1c4a41cb05bfb3b51c92e41b36000200000000000000000194","0x5122e01d819e58bb2e22528c0d68d310f0aa6fd7000200000000000000000163","0x851523a36690bf267bbfec389c823072d82921a90002000000000000000001ed","0xe8cc7e765647625b95f59c15848379d10b9ab4af0002000000000000000001de","0x85370d9e3bb111391cc89f6de344e801760461830002000000000000000001ef","0xa7ff759dbef9f3efdd1d59beee44b966acafe214000200000000000000000180","0x3f7c10701b14197e2695dec6428a2ca4cf7fc3b800020000000000000000023c","0x2d011adf89f0576c9b722c28269fcb5d50c2d17900020000000000000000024d","0x178e029173417b1f9c8bc16dcec6f697bc32374600000000000000000000025d","0xcfca23ca9ca720b6e98e3eb9b6aa0ffc4a5c08b9000200000000000000000274","0x3dd0843a028c86e0b760b1a76929d1c5ef93a2dd000200000000000000000249","0x0578292cb20a443ba1cde459c985ce14ca2bdee5000100000000000000000269","0x8eb6c82c3081bbbd45dcac5afa631aac53478b7c000100000000000000000270","0x1b65fe4881800b91d4277ba738b567cbb200a60d0002000000000000000002cc","0x99a14324cfd525a34bbc93ac7e348929909d57fd00020000000000000000030e","0x9b532ab955417afd0d012eb9f7389457cd0ea712000000000000000000000338","0x48607651416a943bf5ac71c41be1420538e78f87000200000000000000000327","0x6a5ead5433a50472642cd268e584dafa5a394490000200000000000000000366","0x0fd5663d4893ae0d579d580584806aadd2dd0b8b000200000000000000000367","0x441b8a1980f2f2e43a9397099d15cc2fe6d3625000020000000000000000035f","0xf3aeb3abba741f0eece8a1b1d2f11b85899951cb000200000000000000000351","0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d"]},Metadata:{"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe":{name:"Balancer Boosted Aave USD",hasIcon:!0},"0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d":{name:"Balancer Boosted Aave USD",hasIcon:!0},"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063":{name:"Balancer Stable USD",hasIcon:!0},"0x3dd0843a028c86e0b760b1a76929d1c5ef93a2dd000200000000000000000249":{name:"AuraBAL Stable Pool",hasIcon:!1}}},[e.Network.POLYGON]:{IdsMap:{xMatic:{v1:"0xc17636e36398602dd37bb5d1b3a9008c7629005f0002000000000000000004c4",v2:"0xb20fc01d21a50d2c734c4a1262b4404d41fa7bf000000000000000000000075c"},stMatic:{v1:"0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366",v2:"0x8159462d255c1d24915cb51ec361f700174cd99400000000000000000000075d"},mai4:{mai4:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012",maiBbaUsd:"0xb54b2125b711cd183edd3dd09433439d5396165200000000000000000000075e"}},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","Linear","ERC4626Linear","Gyro2","Gyro3"],Stable:{AllowList:["0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012","0xfeadd389a5c427952d8fdb8057d6c8ba1156cc5600020000000000000000001e","0xf38cf113d2d4f60c36cbd95af2f48a9a0167045a00000000000000000000005b","0x0d34e5dd4d8f043557145598e4e2dc286b35fd4f000000000000000000000068","0x5028497af0c9a54ea8c6d42a054c0341b9fc616800020000000000000000007b","0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366","0xb4670d1389c758e4380c4211bcbc85342688b9c50002000000000000000003d8","0xc31a37105b94ab4efca1954a14f059af11fcd9bb000000000000000000000455","0xc17636e36398602dd37bb5d1b3a9008c7629005f0002000000000000000004c4","0xb4b22bd6cdad0ab828be6f8a4086dfa54e9b373600020000000000000000058f","0xb797adfb7b268faeaa90cadbfed464c76ee599cd0002000000000000000005ba","0x0b8319061732b34cab22445fa83b81f950e4b7ed000000000000000000000709","0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366","0x8159462d255c1d24915cb51ec361f700174cd99400000000000000000000075d","0xb20fc01d21a50d2c734c4a1262b4404d41fa7bf000000000000000000000075c","0xb54b2125b711cd183edd3dd09433439d5396165200000000000000000000075e","0x48e6b98ef6329f8f0a30ebb8c7c960330d64808500000000000000000000075b","0xa48d164f6eb0edc68bd03b56fa59e12f24499ad10000000000000000000007c4"]},Investment:{AllowList:[""]},Factories:{"0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0":"oracleWeightedPool","0x8e9aa87e45e92bad84d5f8dd1bff34fb92637de9":"weightedPool","0xc66ba2b6595d3613ccab350c886ace23866ede24":"stablePool","0xdae7e32adc5d490a43ccba1f0c736033f2b4efca":"stablePool","0x751a0bc0e3f75b38e01cf25bfce7ff36de1c87de":"liquidityBootstrappingPool","0x41b953164995c11c81da73d212ed8af25741b7ac":"liquidityBootstrappingPool","0x0f7bb7ce7b6ed9366f9b6b910adefe72dc538193":"managedPool","0xc128a9954e6c874ea3d62ce62b468ba073093f25":"boostedPool","0xca96c4f198d343e251b1a01f3eba061ef3da73c1":"stablePool","0x136fd06fa01ecf624c7f2b3cb15742c1339dc2c4":"composableStablePool","0x0e39c3d9b2ec765efd9c5c70bb290b1fcd8536e3":"weightedPool"},Stakable:{AllowList:["0x0297e37f1873d2dab4487aa67cd56b58e2f27875000100000000000000000002","0x03cd191f589d12b0582a99808cf19851e468e6b500010000000000000000000a","0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012","0x0d34e5dd4d8f043557145598e4e2dc286b35fd4f000000000000000000000068","0x10f21c9bd8128a29aa785ab2de0d044dcdd79436000200000000000000000059","0x186084ff790c65088ba694df11758fae4943ee9e000200000000000000000032","0x36128d5436d2d70cab39c9af9cce146c38554ff0000100000000000000000008","0x5a6ae1fd70d04ba4a279fc219dfabc53825cb01d00020000000000000000020e","0x614b5038611729ed49e0ded154d8a5d3af9d1d9e00010000000000000000001d","0x7c9cf12d783821d5c63d8e9427af5c44bad92445000100000000000000000051","0x805ca3ccc61cc231851dee2da6aabff0a7714aa7000200000000000000000361","0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366","0xb204bf10bc3a5435017d3db247f56da601dfe08a0002000000000000000000fe","0xc31a37105b94ab4efca1954a14f059af11fcd9bb000000000000000000000455","0xce66904b68f1f070332cbc631de7ee98b650b499000100000000000000000009","0xcf354603a9aebd2ff9f33e1b04246d8ea204ae9500020000000000000000005a","0xdb1db6e248d7bb4175f6e5a382d0a03fe3dcc813000100000000000000000035","0xea4e073c8ac859f2994c07e627178719c8002dc00002000000000000000003dc","0xfeadd389a5c427952d8fdb8057d6c8ba1156cc5600020000000000000000001e","0xc17636e36398602dd37bb5d1b3a9008c7629005f0002000000000000000004c4","0x2dbc9ab0160087ae59474fb7bed95b9e808fa6bc0001000000000000000003db","0xb797adfb7b268faeaa90cadbfed464c76ee599cd0002000000000000000005ba","0x8f9dd2064eb38e8e40f2ab67bde27c0e16ea9b080002000000000000000004ca","0x48e6b98ef6329f8f0a30ebb8c7c960330d64808500000000000000000000075b","0xb54b2125b711cd183edd3dd09433439d5396165200000000000000000000075e","0x8159462d255c1d24915cb51ec361f700174cd99400000000000000000000075d","0xb20fc01d21a50d2c734c4a1262b4404d41fa7bf000000000000000000000075c"]},Metadata:{}},[e.Network.ARBITRUM]:{IdsMap:{},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","Linear","ERC4626Linear"],Stable:{AllowList:["0x9be7de742865d021c0e8fb9d64311b2c040c1ec1000200000000000000000012","0x1533a3278f3f9141d5f820a184ea4b017fce2382000000000000000000000016","0x386b5d43ba8b97c43d4afb4cdae7877a1b295e8a000000000000000000000020","0x0510ccf9eb3ab03c1508d3b9769e8ee2cfd6fdcf00000000000000000000005d","0x5a5884fc31948d59df2aeccca143de900d49e1a300000000000000000000006f","0xd89746affa5483627a87e55713ec1905114394950002000000000000000000bf","0x7bceaa9c5e7f4836fec3bce2d5346637c9b13970000000000000000000000102","0xfb5e6d0c1dfed2ba000fbc040ab8df3615ac329c000000000000000000000159"]},Investment:{AllowList:[""]},Factories:{"0x7dfdef5f355096603419239ce743bfaf1120312b":"weightedPool","0xcf0a32bbef8f064969f21f7e02328fb577382018":"weightedPool","0x2433477a10fc5d31b9513c638f19ee85caed53fd":"stablePool","0xebfd5681977e38af65a7487dc70b8221d089ccad":"stablePool","0x142b9666a0a3a30477b052962dda81547e7029ab":"liquidityBootstrappingPool","0x1802953277fd955f9a254b80aa0582f193cf1d77":"liquidityBootstrappingPool","0xacd615b3705b9c880e4e7293f1030b34e57b4c1c":"managedPool","0xdae7e32adc5d490a43ccba1f0c736033f2b4efca":"boostedPool","0xef44d6786b2b4d544b7850fe67ce6381626bf2d6":"stablePool","0xaeb406b0e430bf5ea2dc0b9fe62e4e53f74b3a33":"composableStablePool","0x8df6efec5547e31b0eb7d1291b511ff8a2bf987c":"weightedPool"},Stakable:{AllowList:["0x0510ccf9eb3ab03c1508d3b9769e8ee2cfd6fdcf00000000000000000000005d","0x0adeb25cb5920d4f7447af4a0428072edc2cee2200020000000000000000004a","0x1533a3278f3f9141d5f820a184ea4b017fce2382000000000000000000000016","0x1779900c7707885720d39aa741f4086886307e9e00020000000000000000004b","0x4a3a22a3e7fee0ffbb66f1c28bfac50f75546fc7000200000000000000000008","0x5a5884fc31948d59df2aeccca143de900d49e1a300000000000000000000006f","0x64541216bafffeec8ea535bb71fbc927831d0595000100000000000000000002","0x651e00ffd5ecfa7f3d4f33d62ede0a97cf62ede2000200000000000000000006","0xb28670b3e7ad27bd41fb5938136bf9e9cba90d6500020000000000000000001e","0xb340b6b1a34019853cb05b2de6ee8ffd0b89a008000100000000000000000036","0xb5b77f1ad2b520df01612399258e7787af63025d000200000000000000000010","0xc2f082d33b5b8ef3a7e3de30da54efd3114512ac000200000000000000000017","0xc61ff48f94d801c1ceface0289085197b5ec44f000020000000000000000004d","0xcc65a812ce382ab909a11e434dbf75b34f1cc59d000200000000000000000001","0xe1b40094f1446722c424c598ac412d590e0b3ffb000200000000000000000076","0xb3028ca124b80cfe6e9ca57b70ef2f0ccc41ebd40002000000000000000000ba","0x7bceaa9c5e7f4836fec3bce2d5346637c9b13970000000000000000000000102","0xfb5e6d0c1dfed2ba000fbc040ab8df3615ac329c000000000000000000000159","0x178e029173417b1f9c8bc16dcec6f697bc323746000200000000000000000158"]},Metadata:{}},[e.Network.GNOSIS]:{IdsMap:{},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","Linear","ERC4626Linear","FX","Gyro2","Gyro3","GyroE","HighAmpComposableStable"],Stable:{AllowList:["0x11884da90fb4221b3aa288a7741c51ec4fc43b2f000000000000000000000004","0x707b7d4a1bae449d546dcab869256591bbb3d70b000000000000000000000000"]},Investment:{AllowList:[]},Factories:{},Stakable:{AllowList:[]},Metadata:{}},[e.Network.DEFIVERSE]:{IdsMap:{veBAL:""},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","EulerLinear","Linear","ERC4626Linear","FX","Gyro2","Gyro3","GyroE","HighAmpComposableStable"],Stable:{AllowList:[]},Investment:{AllowList:[]},Factories:{"0xd01ad3085fb3e1fbb2541b5b3326b1f47b189747":"composableStablePool","0xd1920dd25e4998b0d7cc8de7f12beaf9796c7475":"weightedPool","0xe952b0409e6768e270a671ebbc5b8605a7c5a0b8":"weightedPool","0xc04ce4fe0f4013814ea1a4b0577d3678d5a7c91c":"weightedPool","0x9f9e8668ee128c365365f7d1963b4891034fb513":"weightedPool"},Stakable:{AllowList:[]},Metadata:{}},[e.Network.DEFIVERSE_TESTNET]:{IdsMap:{veBAL:""},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","EulerLinear","Linear","ERC4626Linear","FX","Gyro2","Gyro3","GyroE","HighAmpComposableStable"],Stable:{AllowList:[]},Investment:{AllowList:[]},Factories:{"0xab6bac0f5f4c7c166c5234b528a1cd46fbcb9f4b":"weightedPool","0x58e6f99bb65378f47a520fc9630bd711f2cf3dc7":"composableStablePool","0x48494fa9ead46ee8e3fcb66487a6dbbd34dcafe3":"weightedPool"},Stakable:{AllowList:[]},Metadata:{}},[e.Network.OASYS]:{IdsMap:{veBAL:""},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:[""],ExcludedPoolTypes:["Element","AaveLinear","EulerLinear","Linear","ERC4626Linear","FX","Gyro2","Gyro3","GyroE","HighAmpComposableStable"],Stable:{AllowList:[]},Investment:{AllowList:[]},Factories:{"0x061e05853fb45d3d41ec227459ec98bb25580ad3":"composableStablePool","0x4ef0b4827ce3d5fecbc2c6ab80ee81dbf9631d37":"weightedPool","0x5737600b98e7f1cf98daca2a36bca22c974370b0":"weightedPool"},Stakable:{AllowList:[]},Metadata:{}},[e.Network.OASYS_TESTNET]:{IdsMap:{veBAL:""},Pagination:{PerPage:10,PerPool:10,PerPoolInitial:5},DelegateOwner:"0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b",ZeroAddress:"0x0000000000000000000000000000000000000000",DynamicFees:{Gauntlet:[]},BlockList:["0x950f31e8a327a49ae4443284d0137f3b74858474000200000000000000000030"],ExcludedPoolTypes:["Element","AaveLinear","EulerLinear","Linear","ERC4626Linear","FX","Gyro2","Gyro3","GyroE","HighAmpComposableStable"],Stable:{AllowList:["0xeaac5ae5255407cf933dfcf2b0d3eb4f5dc042cd000000000000000000000035","0x34936c3e61371e9ebd1dcd580b23a52c26080b70000000000000000000000036"]},Investment:{AllowList:[]},Factories:{"0xfda8fa80dd77a99bf71becfce47077859e689898":"composableStablePool","0xd2d7f457b9749b6a0a637685a65681f03116125c":"weightedPool"},Stakable:{AllowList:["0x4e66d5f08e81979bd5951c93839bc97265681975000200000000000000000000","0x66180966de2a4180183d7e5dffd76e13b364efe2000200000000000000000001","0xe5b67bf732b7f96127454126069f94f939914d62000200000000000000000002","0x82bfc330a92789c02b3ce2daed3ca889b1a112b7000100000000000000000003","0x0b014863ba970f50b0ea2ad7d57151994b7cac21000100000000000000000004","0x4a54649fb507ee0bf3ad2e1661516b5700c520ab000100000000000000000005","0x981401f589c5768a41d3c4d1a39e84a86f11ad9f000200000000000000000006"]},Metadata:{}}};var G=[{inputs:[{internalType:"contract IStaticAToken",name:"_waToken",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"waToken",outputs:[{internalType:"contract IStaticAToken",name:"",type:"address"}],stateMutability:"view",type:"function"}];const q=e=>e[0].map(((t,a)=>e.map((e=>e[a]))));class W{constructor(e){this.ETH=a.AddressZero,this.isETH=e=>W.isEqual(e,this.ETH),this.isWETH=e=>W.isEqual(e,this.WETH),this.translateToERC20=e=>this.isETH(e)?this.WETH:e,this.WETH=s.getAddress(e)}sortTokens(e,...t){t.forEach((t=>C(e.length===t.length,"array length mismatch")));const a=e.map(this.translateToERC20),n=q([a,...t]).sort((([e],[t])=>((e,t)=>e.toLowerCase()>t.toLowerCase()?1:-1)(e,t))),[s,...i]=q(n);return[e.includes(this.ETH)?s.map((e=>this.isWETH(e)?this.ETH:e)):s,...i]}}W.isEqual=(e,t)=>s.getAddress(e)===s.getAddress(t);const $={"000":"ADD_OVERFLOW","001":"SUB_OVERFLOW","002":"SUB_UNDERFLOW","003":"MUL_OVERFLOW","004":"ZERO_DIVISION","005":"DIV_INTERNAL","006":"X_OUT_OF_BOUNDS","007":"Y_OUT_OF_BOUNDS","008":"PRODUCT_OUT_OF_BOUNDS","009":"INVALID_EXPONENT",100:"OUT_OF_BOUNDS",101:"UNSORTED_ARRAY",102:"UNSORTED_TOKENS",103:"INPUT_LENGTH_MISMATCH",104:"ZERO_TOKEN",200:"MIN_TOKENS",201:"MAX_TOKENS",202:"MAX_SWAP_FEE_PERCENTAGE",203:"MIN_SWAP_FEE_PERCENTAGE",204:"MINIMUM_BPT",205:"CALLER_NOT_VAULT",206:"UNINITIALIZED",207:"BPT_IN_MAX_AMOUNT",208:"BPT_OUT_MIN_AMOUNT",209:"EXPIRED_PERMIT",210:"NOT_TWO_TOKENS",211:"DISABLED",300:"MIN_AMP",301:"MAX_AMP",302:"MIN_WEIGHT",303:"MAX_STABLE_TOKENS",304:"MAX_IN_RATIO",305:"MAX_OUT_RATIO",306:"MIN_BPT_IN_FOR_TOKEN_OUT",307:"MAX_OUT_BPT_FOR_TOKEN_IN",308:"NORMALIZED_WEIGHT_INVARIANT",309:"INVALID_TOKEN",310:"UNHANDLED_JOIN_KIND",311:"ZERO_INVARIANT",312:"ORACLE_INVALID_SECONDS_QUERY",313:"ORACLE_NOT_INITIALIZED",314:"ORACLE_QUERY_TOO_OLD",315:"ORACLE_INVALID_INDEX",316:"ORACLE_BAD_SECS",317:"AMP_END_TIME_TOO_CLOSE",318:"AMP_ONGOING_UPDATE",319:"AMP_RATE_TOO_HIGH",320:"AMP_NO_ONGOING_UPDATE",321:"STABLE_INVARIANT_DIDNT_CONVERGE",322:"STABLE_GET_BALANCE_DIDNT_CONVERGE",323:"RELAYER_NOT_CONTRACT",324:"BASE_POOL_RELAYER_NOT_CALLED",325:"REBALANCING_RELAYER_REENTERED",326:"GRADUAL_UPDATE_TIME_TRAVEL",327:"SWAPS_DISABLED",328:"CALLER_IS_NOT_LBP_OWNER",329:"PRICE_RATE_OVERFLOW",330:"INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED",331:"WEIGHT_CHANGE_TOO_FAST",332:"LOWER_GREATER_THAN_UPPER_TARGET",333:"UPPER_TARGET_TOO_HIGH",334:"UNHANDLED_BY_LINEAR_POOL",335:"OUT_OF_TARGET_RANGE",336:"UNHANDLED_EXIT_KIND ",337:"UNAUTHORIZED_EXIT",338:"MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE",339:"UNHANDLED_BY_MANAGED_POOL",340:"UNHANDLED_BY_PHANTOM_POOL",341:"TOKEN_DOES_NOT_HAVE_RATE_PROVIDER",342:"INVALID_INITIALIZATION",343:"OUT_OF_NEW_TARGET_RANGE",344:"UNAUTHORIZED_OPERATION",345:"UNINITIALIZED_POOL_CONTROLLER",400:"REENTRANCY",401:"SENDER_NOT_ALLOWED",402:"PAUSED",403:"PAUSE_WINDOW_EXPIRED",404:"MAX_PAUSE_WINDOW_DURATION",405:"MAX_BUFFER_PERIOD_DURATION",406:"INSUFFICIENT_BALANCE",407:"INSUFFICIENT_ALLOWANCE",408:"ERC20_TRANSFER_FROM_ZERO_ADDRESS",409:"ERC20_TRANSFER_TO_ZERO_ADDRESS",410:"ERC20_MINT_TO_ZERO_ADDRESS",411:"ERC20_BURN_FROM_ZERO_ADDRESS",412:"ERC20_APPROVE_FROM_ZERO_ADDRESS",413:"ERC20_APPROVE_TO_ZERO_ADDRESS",414:"ERC20_TRANSFER_EXCEEDS_ALLOWANCE",415:"ERC20_DECREASED_ALLOWANCE_BELOW_ZERO",416:"ERC20_TRANSFER_EXCEEDS_BALANCE",417:"ERC20_BURN_EXCEEDS_ALLOWANCE",418:"SAFE_ERC20_CALL_FAILED",419:"ADDRESS_INSUFFICIENT_BALANCE",420:"ADDRESS_CANNOT_SEND_VALUE",421:"SAFE_CAST_VALUE_CANT_FIT_INT256",422:"GRANT_SENDER_NOT_ADMIN",423:"REVOKE_SENDER_NOT_ADMIN",424:"RENOUNCE_SENDER_NOT_ALLOWED",425:"BUFFER_PERIOD_EXPIRED",426:"CALLER_IS_NOT_OWNER",427:"NEW_OWNER_IS_ZERO",428:"CODE_DEPLOYMENT_FAILED",429:"CALL_TO_NON_CONTRACT",430:"LOW_LEVEL_CALL_FAILED",431:"NOT_PAUSED",432:"ADDRESS_ALREADY_ALLOWLISTED",433:"ADDRESS_NOT_ALLOWLISTED",434:"ERC20_BURN_EXCEEDS_BALANCE",500:"INVALID_POOL_ID",501:"CALLER_NOT_POOL",502:"SENDER_NOT_ASSET_MANAGER",503:"USER_DOESNT_ALLOW_RELAYER",504:"INVALID_SIGNATURE",505:"EXIT_BELOW_MIN",506:"JOIN_ABOVE_MAX",507:"SWAP_LIMIT",508:"SWAP_DEADLINE",509:"CANNOT_SWAP_SAME_TOKEN",510:"UNKNOWN_AMOUNT_IN_FIRST_SWAP",511:"MALCONSTRUCTED_MULTIHOP_SWAP",512:"INTERNAL_BALANCE_OVERFLOW",513:"INSUFFICIENT_INTERNAL_BALANCE",514:"INVALID_ETH_INTERNAL_BALANCE",515:"INVALID_POST_LOAN_BALANCE",516:"INSUFFICIENT_ETH",517:"UNALLOCATED_ETH",518:"ETH_TRANSFER",519:"CANNOT_USE_ETH_SENTINEL",520:"TOKENS_MISMATCH",521:"TOKEN_NOT_REGISTERED",522:"TOKEN_ALREADY_REGISTERED",523:"TOKENS_ALREADY_SET",524:"TOKENS_LENGTH_MUST_BE_2",525:"NONZERO_TOKEN_BALANCE",526:"BALANCE_TOTAL_OVERFLOW",527:"POOL_NO_TOKENS",528:"INSUFFICIENT_FLASH_LOAN_BALANCE",600:"SWAP_FEE_PERCENTAGE_TOO_HIGH",601:"FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH",602:"INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT"};class V{constructor(){}}async function H(e){if("string"==typeof e)return e;if(o.Signer.isSigner(e))return e.getAddress();if(e.address)return e.address;throw new Error("Could not read account address")}var j;V.isErrorCode=e=>{if(!e.includes("BAL#"))return!1;const t=e.replace("BAL#","");return Object.keys($).includes(t)},V.parseErrorCode=e=>{if(!e.includes("BAL#"))throw new Error("Error code not found");const t=e.replace("BAL#",""),a=$[t];if(!a)throw new Error("Error code not found");return a},V.tryParseErrorCode=e=>{try{return V.parseErrorCode(e)}catch{return e}},V.isBalancerError=e=>Object.values($).includes(e),V.encodeError=e=>{const t=Object.entries($).find((([,t])=>t===e));if(!t)throw Error("Error message not found");return`BAL#${t[0]}`},e.RelayerAction=void 0,(j=e.RelayerAction||(e.RelayerAction={})).JoinPool="JoinPool",j.ExitPool="ExitPool",j.Swap="Swap",j.BatchSwap="BatchSwap",j.SetRelayerApproval="SetRelayerApproval";class K{constructor(){}}K.encodeCalldataAuthorization=(e,t,a)=>{const n=r.hexZeroPad(r.hexValue(t),32).slice(2),{v:s,r:i,s:o}=r.splitSignature(a);return`${e}${n}${r.hexZeroPad(r.hexValue(s),32).slice(2)}${i.slice(2)}${o.slice(2)}`},K.signJoinAuthorization=(t,a,n,s,i,r)=>K.signAuthorizationFor(e.RelayerAction.JoinPool,t,a,n,s,i,r),K.signExitAuthorization=(t,a,n,s,i,r)=>K.signAuthorizationFor(e.RelayerAction.ExitPool,t,a,n,s,i,r),K.signSwapAuthorization=(t,a,n,s,i,r)=>K.signAuthorizationFor(e.RelayerAction.Swap,t,a,n,s,i,r),K.signBatchSwapAuthorization=(t,a,n,s,i,r)=>K.signAuthorizationFor(e.RelayerAction.BatchSwap,t,a,n,s,i,r),K.signSetRelayerApprovalAuthorization=(t,a,n,s,i,r)=>K.signAuthorizationFor(e.RelayerAction.SetRelayerApproval,t,a,n,s,i,r),K.signAuthorizationFor=async(e,t,n,s,i,r=a.MaxUint256,o)=>{const{chainId:d}=await t.provider.getNetwork();if(!o){const e=await n.getAddress();o=await t.getNextNonce(e)}const c={name:"Balancer V2 Vault",version:"1",chainId:d,verifyingContract:t.address},l={[e]:[{name:"calldata",type:"bytes"},{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},p={calldata:i,sender:await H(s),nonce:o.toString(),deadline:r.toString()};return n._signTypedData(c,l,p)};class Z{constructor(){}}Z.signSetMinterApproval=async(e,t,s,i,o=a.MaxUint256,d)=>{const{chainId:c}=await e.provider.getNetwork();if(!d){const t=await i.getAddress();d=await e.getNextNonce(t)}const l={name:"Balancer Minter",version:"1",chainId:c,verifyingContract:e.address},p={minter:await H(t),approval:s,nonce:d.toString(),deadline:o.toString()},u=await i._signTypedData(l,{SetMinterApproval:[{name:"minter",type:"address"},{name:"approval",type:"bool"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},p);return{...r.splitSignature(u),deadline:n.BigNumber.from(o)}};const X=BigInt(0),J=BigInt(1),Y=BigInt("1000000000000000000"),z=(e,t)=>{if(!e)throw new Error(t)};function Q(e){const t=BigInt(18)-e;return Y*BigInt(10)**t}function ee(e,t){return ae.mulDownFixed(e,t)}function te(e,t){const a=new Array(e.length);for(let n=0;n<e.length;++n)a[n]=ae.mulDownFixed(e[n],t[n]);return a}class ae{static add(e,t){const a=e+t;return z(t>=0&&a>=e||t<0&&a<e,"Errors.ADD_OVERFLOW"),a}static sub(e,t){z(t<=e,"Errors.SUB_OVERFLOW");return e-t}static max(e,t){return e>=t?e:t}static min(e,t){return e<t?e:t}static mul(e,t){const a=e*t;return z(e==X||a/e==t,"Errors.MUL_OVERFLOW"),a}static div(e,t,a){return a?this.divUp(e,t):this.divDown(e,t)}static divDown(e,t){return z(t!=X,"Errors.ZERO_DIVISION"),e/t}static divUp(e,t){return z(t!=X,"Errors.ZERO_DIVISION"),e==X?X:J+(e-J)/t}static mulUpFixed(e,t){const a=e*t;return z(e==X||a/e==t,"Errors.MUL_OVERFLOW"),a==X?X:(a-J)/Y+J}static divDownFixed(e,t){if(z(t!=X,"Errors.ZERO_DIVISION"),e==X)return X;return e*Y/t}static divUpFixed(e,t){if(z(t!=X,"Errors.ZERO_DIVISION"),e==X)return X;{const a=e*Y;return z(a/e==Y,"Errors.DIV_INTERNAL"),(a-J)/t+J}}static powUpFixed(e,t){const a=ne.pow(e,t),n=this.add(this.mulUpFixed(a,this.MAX_POW_RELATIVE_ERROR),J);return this.add(a,n)}static complementFixed(e){return e<Y?Y-e:X}static mulDownFixed(e,t){const a=e*t;return z(e==X||a/e==t,"Errors.MUL_OVERFLOW"),a/Y}}ae.MAX_POW_RELATIVE_ERROR=BigInt(1e4);class ne{static pow(e,t){if(t===X)return this.ONE_18;if(e==X)return X;z(e<BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819968"),"Errors.X_OUT_OF_BOUNDS");const a=e;z(t<this.MILD_EXPONENT_BOUND,"Errors.Y_OUT_OF_BOUNDS");const n=t;let s;if(this.LN_36_LOWER_BOUND<a&&a<this.LN_36_UPPER_BOUND){const e=this._ln_36(a);s=e/this.ONE_18*n+e%this.ONE_18*n/this.ONE_18}else s=this._ln(a)*n;return s/=this.ONE_18,z(this.MIN_NATURAL_EXPONENT<=s&&s<=this.MAX_NATURAL_EXPONENT,"Errors.PRODUCT_OUT_OF_BOUNDS"),this.exp(s)}static exp(e){if(z(e>=this.MIN_NATURAL_EXPONENT&&e<=this.MAX_NATURAL_EXPONENT,"Errors.INVALID_EXPONENT"),e<0)return this.ONE_18*this.ONE_18/this.exp(BigInt(-1)*e);let t;e>=this.x0?(e-=this.x0,t=this.a0):e>=this.x1?(e-=this.x1,t=this.a1):t=BigInt(1),e*=BigInt(100);let a=this.ONE_20;e>=this.x2&&(e-=this.x2,a=a*this.a2/this.ONE_20),e>=this.x3&&(e-=this.x3,a=a*this.a3/this.ONE_20),e>=this.x4&&(e-=this.x4,a=a*this.a4/this.ONE_20),e>=this.x5&&(e-=this.x5,a=a*this.a5/this.ONE_20),e>=this.x6&&(e-=this.x6,a=a*this.a6/this.ONE_20),e>=this.x7&&(e-=this.x7,a=a*this.a7/this.ONE_20),e>=this.x8&&(e-=this.x8,a=a*this.a8/this.ONE_20),e>=this.x9&&(e-=this.x9,a=a*this.a9/this.ONE_20);let n,s=this.ONE_20;return n=e,s+=n,n=n*e/this.ONE_20/BigInt(2),s+=n,n=n*e/this.ONE_20/BigInt(3),s+=n,n=n*e/this.ONE_20/BigInt(4),s+=n,n=n*e/this.ONE_20/BigInt(5),s+=n,n=n*e/this.ONE_20/BigInt(6),s+=n,n=n*e/this.ONE_20/BigInt(7),s+=n,n=n*e/this.ONE_20/BigInt(8),s+=n,n=n*e/this.ONE_20/BigInt(9),s+=n,n=n*e/this.ONE_20/BigInt(10),s+=n,n=n*e/this.ONE_20/BigInt(11),s+=n,n=n*e/this.ONE_20/BigInt(12),s+=n,a*s/this.ONE_20*t/BigInt(100)}static _ln_36(e){const t=((e*=this.ONE_18)-this.ONE_36)*this.ONE_36/(e+this.ONE_36),a=t*t/this.ONE_36;let n=t,s=n;return n=n*a/this.ONE_36,s+=n/BigInt(3),n=n*a/this.ONE_36,s+=n/BigInt(5),n=n*a/this.ONE_36,s+=n/BigInt(7),n=n*a/this.ONE_36,s+=n/BigInt(9),n=n*a/this.ONE_36,s+=n/BigInt(11),n=n*a/this.ONE_36,s+=n/BigInt(13),n=n*a/this.ONE_36,s+=n/BigInt(15),s*BigInt(2)}static _ln(e){if(e<this.ONE_18)return BigInt(-1)*this._ln(this.ONE_18*this.ONE_18/e);let t=X;e>=this.a0*this.ONE_18&&(e/=this.a0,t+=this.x0),e>=this.a1*this.ONE_18&&(e/=this.a1,t+=this.x1),t*=BigInt(100),(e*=BigInt(100))>=this.a2&&(e=e*this.ONE_20/this.a2,t+=this.x2),e>=this.a3&&(e=e*this.ONE_20/this.a3,t+=this.x3),e>=this.a4&&(e=e*this.ONE_20/this.a4,t+=this.x4),e>=this.a5&&(e=e*this.ONE_20/this.a5,t+=this.x5),e>=this.a6&&(e=e*this.ONE_20/this.a6,t+=this.x6),e>=this.a7&&(e=e*this.ONE_20/this.a7,t+=this.x7),e>=this.a8&&(e=e*this.ONE_20/this.a8,t+=this.x8),e>=this.a9&&(e=e*this.ONE_20/this.a9,t+=this.x9),e>=this.a10&&(e=e*this.ONE_20/this.a10,t+=this.x10),e>=this.a11&&(e=e*this.ONE_20/this.a11,t+=this.x11);const a=(e-this.ONE_20)*this.ONE_20/(e+this.ONE_20),n=a*a/this.ONE_20;let s=a,i=s;return s=s*n/this.ONE_20,i+=s/BigInt(3),s=s*n/this.ONE_20,i+=s/BigInt(5),s=s*n/this.ONE_20,i+=s/BigInt(7),s=s*n/this.ONE_20,i+=s/BigInt(9),s=s*n/this.ONE_20,i+=s/BigInt(11),i*=BigInt(2),(t+i)/BigInt(100)}}ne.ONE_18=BigInt("1000000000000000000"),ne.ONE_20=BigInt("100000000000000000000"),ne.ONE_36=BigInt("1000000000000000000000000000000000000"),ne.MAX_NATURAL_EXPONENT=BigInt("130000000000000000000"),ne.MIN_NATURAL_EXPONENT=BigInt("-41000000000000000000"),ne.LN_36_LOWER_BOUND=BigInt(ne.ONE_18)-BigInt("100000000000000000"),ne.LN_36_UPPER_BOUND=BigInt(ne.ONE_18)+BigInt("100000000000000000"),ne.MILD_EXPONENT_BOUND=BigInt(2)**BigInt(254)/ne.ONE_20,ne.x0=BigInt("128000000000000000000"),ne.a0=BigInt("38877084059945950922200000000000000000000000000000000000"),ne.x1=BigInt("64000000000000000000"),ne.a1=BigInt("6235149080811616882910000000"),ne.x2=BigInt("3200000000000000000000"),ne.a2=BigInt("7896296018268069516100000000000000"),ne.x3=BigInt("1600000000000000000000"),ne.a3=BigInt("888611052050787263676000000"),ne.x4=BigInt("800000000000000000000"),ne.a4=BigInt("298095798704172827474000"),ne.x5=BigInt("400000000000000000000"),ne.a5=BigInt("5459815003314423907810"),ne.x6=BigInt("200000000000000000000"),ne.a6=BigInt("738905609893065022723"),ne.x7=BigInt("100000000000000000000"),ne.a7=BigInt("271828182845904523536"),ne.x8=BigInt("50000000000000000000"),ne.a8=BigInt("164872127070012814685"),ne.x9=BigInt("25000000000000000000"),ne.a9=BigInt("128402541668774148407"),ne.x10=BigInt("12500000000000000000"),ne.a10=BigInt("113314845306682631683"),ne.x11=BigInt("6250000000000000000"),ne.a11=BigInt("106449445891785942956");const se=(e,t)=>{let a=e.tokens.map((e=>e.address)),s=e.tokens.map((e=>e.decimals?e.decimals.toString():void 0)),i=s.map((e=>Q(BigInt(e)))),r=e.tokens.map((e=>n.parseFixed(e.balance,e.decimals).toString())),o=e.tokens.map((e=>n.parseFixed(e.balance,18).toString())),d=e.tokens.map((e=>e.weight?n.parseFixed(e.weight,18).toString():void 0)),c=e.tokens.map((e=>e.priceRate?n.parseFixed(e.priceRate,18).toString():void 0));if(t){const e=new W(t);let n;[a,s,n,r,o,d,c]=e.sortTokens(a,s,i,r,o,d,c),i=n.map(BigInt)}const l=e.amp?n.parseFixed(e.amp,3).toString():void 0,p=n.parseFixed(e.totalShares,18).toString(),u=n.parseFixed(e.swapFee,18).toString(),y=[],b=[],m=[],f=a.indexOf(e.address);return-1!==f&&i.forEach(((e,t)=>{t!==f&&(y.push(i[t]),b.push(a[t]),m.push(r[t]))})),{parsedTokens:a,parsedDecimals:s,parsedBalances:r,parsedWeights:d,parsedPriceRates:c,parsedAmp:l,parsedTotalShares:p,parsedSwapFee:u,upScaledBalances:o,scalingFactors:i,scalingFactorsWithoutBpt:y,parsedTokensWithoutBpt:b,parsedBalancesWithoutBpt:m,bptIndex:f}},ie={Popular:{Symbols:["WBTC","DAI","USDC","BAL","AAVE","WETH"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",WETH:"0x0000000000000000000000000000000000000000",BAL:"0x0000000000000000000000000000000000000000"}},re={[e.Network.KOVAN]:{Popular:{Symbols:["WBTC","DAI","USDC","BAL","AAVE","WETH"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1",WETH:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1",BAL:"0xcb355677E36f390Ccc4a5d4bEADFbF1Eb2071c81",bbaUSD:"0x8fd162f338B770F7E879030830cDe9173367f301"},PriceChainMap:{"0xdfcea9088c8a88a76ff74892c1457c17dfeef9c1":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x1c8e3bcb3378a443cc591f154c5ce0ebb4da9648":"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599","0x8f4bebf498cc624a0797fe64114a6ff169eee078":"0xbc396689893d065f41bc2c6ecbee5e0085233447","0xaf9ac3235be96ed496db7969f60d354fe5e426b0":"0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2","0xcb355677e36f390ccc4a5d4beadfbf1eb2071c81":"0xba100000625a3754423978a60c9317c58a424e3d","0xc2569dd7d0fd715b054fbf16e75b001e5c0c1115":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x04df6e4121c27713ed22341e7c7df330f56f289b":"0x6b175474e89094c44da98b954eedeac495271d0f","0x4803bb90d18a1cb7a2187344fe4feb0e07878d05":"0xae7ab96520de3a18e5e111b5eaab095312d7fe84","0xff795577d9ac8bd7d90ee22b6c1703490b6512fd":"0x6b175474e89094c44da98b954eedeac495271d0f","0xe22da380ee6b445bb8273c81944adeb6e8450422":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x13512979ade267ab5100878e2e0f485b568328a4":"0xdac17f958d2ee523a2206206994597c13d831ec7","0xa387b91e393cfb9356a460370842bc8dbb2f29af":"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"}},[e.Network.GOERLI]:{Popular:{Symbols:["WBTC","DAI","USDC","BAL","USDT","WETH"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1",WETH:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1",BAL:"0xfA8449189744799aD2AcE7e0EBAC8BB7575eff47",bbaUSD:"0x13ACD41C585d7EbB4a9460f7C8f50BE60DC080Cd"},PriceChainMap:{"0xdfcea9088c8a88a76ff74892c1457c17dfeef9c1":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x37f03a12241e9fd3658ad6777d289c3fb8512bc9":"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599","0xfa8449189744799ad2ace7e0ebac8bb7575eff47":"0xba100000625a3754423978a60c9317c58a424e3d","0xe0c9275e44ea80ef17579d33c55136b7da269aeb":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x8c9e6c40d3402480ace624730524facc5482798c":"0x6b175474e89094c44da98b954eedeac495271d0f","0x1f1f156e0317167c11aa412e3d1435ea29dc3cce":"0xdac17f958d2ee523a2206206994597c13d831ec7","0x4cb1892fddf14f772b2e39e299f44b2e5da90d04":"0x3ed3b47dd13ec9a98b44e6204a523e766b225811","0x811151066392fd641fe74a9b55a712670572d161":"0xbcca60bb61934080951369a648fb03df4f96263c","0x89534a24450081aa267c79b07411e9617d984052":"0x028171bca77440897b824ca71d1c56cac55b68a3","0x829f35cebbcd47d3c120793c12f7a232c903138b":"0x956f47f50a910163d8bf957cf5846d573e7f87ca","0xff386a3d08f80ac38c77930d173fa56c6286dc8b":"0x6810e776880c02933d47db1b9fc05908e5386b96"}},[e.Network.MAINNET]:{Popular:{Symbols:["WBTC","DAI","USDC","BAL","AAVE","WETH"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",WETH:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",BAL:"0xba100000625a3754423978a60c9317c58a424e3d",bbaUSD:"0x7B50775383d3D6f0215A8F290f2C9e2eEBBEceb2",bbaUSDv2:"0xA13a9247ea42D743238089903570127DdA72fE44"}},[e.Network.POLYGON]:{Popular:{Symbols:["WBTC","DAI","USDC","BAL","AAVE","WETH"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",WETH:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",BAL:"0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3"}},[e.Network.ARBITRUM]:{Popular:{Symbols:["WBTC","DAI","USDC","BAL","AAVE","WETH"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",WETH:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",BAL:"0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8"}},[e.Network.GNOSIS]:{Popular:{Symbols:["xDAI","WXDAI","WETH","BAL"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0xe91d153e0b41518a2ce8dd3d7944fa863463a97d",WETH:"0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1",BAL:"0x7eF541E2a22058048904fE5744f9c7E4C57AF717"}},[e.Network.DEFIVERSE]:{Popular:{Symbols:["GDT","BAL","WETH","OAS"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0x5a89E11Cb554E00c2f51C4bb7F05bc7Ab0Fa6351",WETH:"0x5a89E11Cb554E00c2f51C4bb7F05bc7Ab0Fa6351",BAL:"",GDT:""},PriceChainMap:{"0x5a89e11cb554e00c2f51c4bb7f05bc7ab0fa6351":"0x5a89e11cb554e00c2f51c4bb7f05bc7ab0fa6351","0x7c6b91d9be155a6db01f749217d76ff02a7227f2":"0x7c6b91d9be155a6db01f749217d76ff02a7227f2"}},[e.Network.DEFIVERSE_TESTNET]:{Popular:{Symbols:["WETH","OAS"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0x6B382742b07AAbBA58c38d792B5d7CBAaB246e99",WETH:"0x6B382742b07AAbBA58c38d792B5d7CBAaB246e99",BAL:"",GDT:""},PriceChainMap:{}},[e.Network.OASYS]:{Popular:{Symbols:["GDT","BAL","WETH","OAS"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0x5200000000000000000000000000000000000001",WETH:"0x5200000000000000000000000000000000000001",BAL:"0x2B726256AdD04e65403cEf6679A2f2dfF7DDe9F9",GDT:""},PriceChainMap:{"0x5200000000000000000000000000000000000001":"0x5a89e11cb554e00c2f51c4bb7f05bc7ab0fa6351"}},[e.Network.OASYS_TESTNET]:{Popular:{Symbols:["GDT","BAL","WETH","OAS"]},Addresses:{nativeAsset:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",wNativeAsset:"0x5200000000000000000000000000000000000001",WETH:"0x5200000000000000000000000000000000000001",BAL:"0x9288F664FEFc9f374A53C4307BD3c8F91e83f466",GDT:"0x9288F664FEFc9f374A53C4307BD3c8F91e83f466"},PriceChainMap:{"0x5200000000000000000000000000000000000001":"0x5a89e11cb554e00c2f51c4bb7f05bc7ab0fa6351"}}};var oe,de,ce,le,pe,ue,ye;e.PoolGaugesAttributes=void 0,(oe=e.PoolGaugesAttributes||(e.PoolGaugesAttributes={})).Id="id",oe.Address="address",oe.PoolId="poolId",e.PoolShareAttributes=void 0,(de=e.PoolShareAttributes||(e.PoolShareAttributes={})).Balance="balance",de.Id="id",de.PoolId="poolId",de.UserAddress="userAddress",e.GaugeShareAttributes=void 0,(ce=e.GaugeShareAttributes||(e.GaugeShareAttributes={})).Id="id",ce.UserAddress="user",ce.GaugeId="gauge",ce.Balance="balance",e.PoolSpecialization=void 0,(le=e.PoolSpecialization||(e.PoolSpecialization={}))[le.GeneralPool=0]="GeneralPool",le[le.MinimalSwapInfoPool=1]="MinimalSwapInfoPool",le[le.TwoTokenPool=2]="TwoTokenPool",e.UserBalanceOpKind=void 0,(pe=e.UserBalanceOpKind||(e.UserBalanceOpKind={}))[pe.DepositInternal=0]="DepositInternal",pe[pe.WithdrawInternal=1]="WithdrawInternal",pe[pe.TransferInternal=2]="TransferInternal",pe[pe.TransferExternal=3]="TransferExternal",e.PoolBalanceOpKind=void 0,(ue=e.PoolBalanceOpKind||(e.PoolBalanceOpKind={}))[ue.Withdraw=0]="Withdraw",ue[ue.Deposit=1]="Deposit",ue[ue.Update=2]="Update",e.PoolType=void 0,(ye=e.PoolType||(e.PoolType={})).Weighted="Weighted",ye.Investment="Investment",ye.Stable="Stable",ye.HighAmpComposableStable="HighAmpComposableStable",ye.ComposableStable="ComposableStable",ye.MetaStable="MetaStable",ye.StablePhantom="StablePhantom",ye.LiquidityBootstrapping="LiquidityBootstrapping",ye.AaveLinear="AaveLinear",ye.Linear="Linear",ye.EulerLinear="EulerLinear",ye.ERC4626Linear="ERC4626Linear",ye.Element="Element",ye.Gyro2="Gyro2",ye.Gyro3="Gyro3",ye.Managed="Managed";let be=!1,me=!1;const fe={debug:1,default:2,info:2,warning:3,error:4,off:5};let he=fe.default,Te=null;const ge=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(a){e.push(t)}})),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 Ie,we;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(Ie||(Ie={})),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"}(we||(we={}));const Ee="0123456789abcdef";class xe{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const a=e.toLowerCase();null==fe[a]&&this.throwArgumentError("invalid log level name","logLevel",e),he>fe[a]||console.log.apply(console,t)}debug(...e){this._log(xe.levels.DEBUG,e)}info(...e){this._log(xe.levels.INFO,e)}warn(...e){this._log(xe.levels.WARNING,e)}makeError(e,t,a){if(me)return this.makeError("censored error",t,{});t||(t=xe.errors.UNKNOWN_ERROR),a||(a={});const n=[];Object.keys(a).forEach((e=>{const t=a[e];try{if(t instanceof Uint8Array){let a="";for(let e=0;e<t.length;e++)a+=Ee[t[e]>>4],a+=Ee[15&t[e]];n.push(e+"=Uint8Array(0x"+a+")")}else n.push(e+"="+JSON.stringify(t))}catch(t){n.push(e+"="+JSON.stringify(a[e].toString()))}})),n.push(`code=${t}`),n.push(`version=${this.version}`);const s=e;let i="";switch(t){case we.NUMERIC_FAULT:{i="NUMERIC_FAULT";const t=e;switch(t){case"overflow":case"underflow":case"division-by-zero":i+="-"+t;break;case"negative-power":case"negative-width":i+="-unsupported";break;case"unbound-bitwise-result":i+="-unbound-result"}break}case we.CALL_EXCEPTION:case we.INSUFFICIENT_FUNDS:case we.MISSING_NEW:case we.NONCE_EXPIRED:case we.REPLACEMENT_UNDERPRICED:case we.TRANSACTION_REPLACED:case we.UNPREDICTABLE_GAS_LIMIT:i=t}i&&(e+=" [ See: https://links.ethers.org/v5-errors-"+i+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const r=new Error(e);return r.reason=s,r.code=t,Object.keys(a).forEach((function(e){r[e]=a[e]})),r}throwError(e,t,a){throw this.makeError(e,t,a)}throwArgumentError(e,t,a){return this.throwError(e,xe.errors.INVALID_ARGUMENT,{argument:t,value:a})}assert(e,t,a,n){e||this.throwError(t,a,n)}assertArgument(e,t,a,n){e||this.throwArgumentError(t,a,n)}checkNormalize(e){ge&&this.throwError("platform missing String.prototype.normalize",xe.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ge})}checkSafeUint53(e,t){"number"==typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,xe.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,xe.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,a){a=a?": "+a:"",e<t&&this.throwError("missing argument"+a,xe.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+a,xe.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",xe.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",xe.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",xe.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Te||(Te=new xe("logger/5.7.0")),Te}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",xe.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),be){if(!e)return;this.globalLogger().throwError("error censorship permanent",xe.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}me=!!e,be=!!t}static setLogLevel(e){const t=fe[e.toLowerCase()];null!=t?he=t:xe.globalLogger().warn("invalid log level - "+e)}static from(e){return new xe(e)}}xe.errors=we,xe.levels=Ie;const Ae=new xe("units/5.7.0"),Se=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Pe(e,t){if("string"==typeof t){const e=Se.indexOf(t);-1!==e&&(t=3*e)}return n.formatFixed(e,null!=t?t:18)}function _e(e,t){if("string"!=typeof e&&Ae.throwArgumentError("value must be a string","value",e),"string"==typeof t){const e=Se.indexOf(t);-1!==e&&(t=3*e)}return n.parseFixed(e,null!=t?t:18)}const Be={[e.Network.MAINNET]:{waUSDT:"0xf8fd466f12e236f4c96f7cce6c79eadb819abf58",waUSDC:"0xd093fa4fb80d09bb30817fdcd442d4d02ed3e5de",waDAI:"0x02d60b84491589974263d922d9cc7a3152618ef6"},[e.Network.POLYGON]:{wamDAI:"0xee029120c72b0607344f35b17cdd90025e647b00",wamUSDC:"0x221836a597948dce8f3568e044ff123108acc42a",wamUSDT:"0x19c60a251e525fa88cd6f3768416a8024e98fc19"}},Oe={...Be[e.Network.MAINNET],...Be[e.Network.POLYGON]},ve={[e.Network.MAINNET]:{[Be[e.Network.MAINNET].waUSDT]:{aToken:"0x3ed3b47dd13ec9a98b44e6204a523e766b225811",underlying:"0xdac17f958d2ee523a2206206994597c13d831ec7"},[Be[e.Network.MAINNET].waUSDC]:{aToken:"0xbcca60bb61934080951369a648fb03df4f96263c",underlying:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"},[Be[e.Network.MAINNET].waDAI]:{aToken:"0x028171bca77440897b824ca71d1c56cac55b68a3",underlying:"0x6b175474e89094c44da98b954eedeac495271d0f"}},[e.Network.POLYGON]:{[Be[e.Network.POLYGON].wamUSDT]:{aToken:"0x60d55f02a771d515e077c9c2403a1ef324885cec",underlying:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f"},[Be[e.Network.POLYGON].wamUSDC]:{aToken:"0x1a13f4ca1d028320a707d99520abfefca3998b7f",underlying:"0x2791bca1f2de4661ed88a30c99a7a9449aa84174"},[Be[e.Network.POLYGON].wamDAI]:{aToken:"0x27f8d03b3a2196956ed754badc28d73be8830a6e",underlying:"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"}}},ke={[e.Network.MAINNET]:Object.values(ve[e.Network.MAINNET]).map((e=>e.aToken)),[e.Network.POLYGON]:Object.values(ve[e.Network.POLYGON]).map((e=>e.aToken))},Ne={[e.Network.MAINNET]:Object.values(ve[e.Network.MAINNET]).map((e=>e.underlying)),[e.Network.POLYGON]:Object.values(ve[e.Network.POLYGON]).map((e=>e.underlying))},Ce={[e.Network.MAINNET]:Object.fromEntries(Object.keys(ve[e.Network.MAINNET]).map((t=>[ve[e.Network.MAINNET][t].underlying,t]))),[e.Network.POLYGON]:Object.fromEntries(Object.keys(ve[e.Network.POLYGON]).map((t=>[ve[e.Network.POLYGON][t].underlying,t])))},De={[e.Network.MAINNET]:"https://api.thegraph.com/subgraphs/name/aave/protocol-v2",[e.Network.POLYGON]:"https://api.thegraph.com/subgraphs/name/aave/aave-v2-matic"},Re=async t=>{const a=Object.fromEntries(Object.keys(ve).map((e=>[e,0])));if(!t||t!=e.Network.MAINNET&&t!=e.Network.POLYGON)return a;try{const e={operationName:"getReserves",query:"\n query getReserves($aTokens: [String!], $underlyingAssets: [Bytes!]) {\n reserves(\n where: {\n aToken_in: $aTokens\n underlyingAsset_in: $underlyingAssets\n isActive: true\n }\n ) {\n underlyingAsset\n liquidityRate\n }\n }\n",variables:{aTokens:ke[t],underlyingAssets:Ne[t]}},a=await x.default.post(De[t],e),{data:{reserves:s}}=a.data,i=s.map((e=>[Ce[t][e.underlyingAsset],Math.round(1e4*parseFloat(Pe(n.BigNumber.from(e.liquidityRate),27)))]));return Object.fromEntries(i)}catch(e){return a}};function Fe(e,t){let a=e.toLowerCase();return a=Me(a,t),a=Le(a,t),a}const Me=(e,t)=>{const a=(n=t,re[n]?re[n]:ie).PriceChainMap;var n;return a&&a[e.toLowerCase()]||e},Le=(e,t)=>{const a=e.toLocaleLowerCase(),n=t;return null!=ve[n]&&null!=ve[n]&&Object.keys(ve[n]).includes(a)?ve[n][a].aToken:a};class Ue{constructor(e,t=200){this.fn=e,this.wait=t,this.requestSet=new Set,this.promisedCalls=[],this.promisedCount=0,this.debounceCancel=()=>{}}fetch(e){if(e&&this.requestSet.add(e),this.promisedCalls[this.promisedCount])return this.promisedCalls[this.promisedCount].promise;this.promisedCalls[this.promisedCount]=(()=>{let e=()=>{},t=()=>{};return{promise:new Promise(((a,n)=>{[e,t]=[a,n]})),reject:t,resolve:e}})();const{promise:t,resolve:a,reject:n}=this.promisedCalls[this.promisedCount];return this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout((()=>{this.promisedCount++;const e=[...this.requestSet];this.requestSet.clear(),this.fn(e).then((e=>{a(e),this.debounceCancel=()=>{}})).catch((e=>{e.response&&e.response.data&&e.response.data.error&&(e=e.response.data.error),n(e)}))}),this.wait),this.debounceCancel=()=>{this.timeout&&clearTimeout(this.timeout),n("Cancelled"),delete this.promisedCalls[this.promisedCount]},t}}function Ge(e,t){const a=new RegExp(`[0-9]+\\.?[0-9]{0,${t}}`),s=e.match(a);let i=e;return s&&(i=s[0]),n.parseFixed(i,t)}function qe(e,t){return n.formatFixed(e,t).replace(/(.0$)/,"")}function We(e){return Ge(e,18).toBigInt()}const $e=(e,t)=>s.getAddress(e)===s.getAddress(t);function Ve(e,t,a){return[...e.slice(0,t),a,...e.slice(t)]}class He{format(e){return e}}class je{constructor(){this.operatorMap={gt:"_gt",lt:"_lt",eq:"",in:"_in",not_in:"_not_in",contains:"_contains"}}format(e){const t={};return e.where&&Object.entries(e.where).forEach((([e,a])=>{Object.entries(a).forEach((([a,n])=>{t[`${e}${this.operatorMap[a]}`]=n}))})),{...e,where:t}}}class Ke{constructor(e){this.args=e}merge(e){const t=c.mergeWith(this.args,e.args,((e,t)=>{if(Array.isArray(e))return e.concat(t)}));return new Ke(t)}format(e){return e.format(this.args)}}var Ze;function Xe(t,s,i,r,o,d){const c=new Array(o.length).fill(a.Zero);return o.forEach(((o,l)=>{if(t.some((e=>$e(o,e)))){const t=n.BigNumber.from(d).add(a.WeiPerEther);c[l]=i===e.SwapType.SwapExactOut?c[l].add(n.BigNumber.from(r[l]).mul(t).div(a.WeiPerEther)):c[l].add(r[l])}if(s.some((e=>$e(o,e)))){const t=a.WeiPerEther.sub(n.BigNumber.from(d));c[l]=i===e.SwapType.SwapExactIn?c[l].add(n.BigNumber.from(r[l]).mul(t).div(a.WeiPerEther)):c[l].add(r[l])}})),c}e.SwapType=void 0,(Ze=e.SwapType||(e.SwapType={}))[Ze.SwapExactIn=0]="SwapExactIn",Ze[Ze.SwapExactOut=1]="SwapExactOut";const Je=n.BigNumber.from("10000"),Ye=(e,t)=>e.mul(t).div(Je),ze=(e,t)=>{const a=Ye(e,t);return e.sub(a)},Qe=(e,t)=>{const a=Ye(e,t);return e.add(a)},et="0x2FA699664752B34E90A414A42D62D7A8b2702B85",tt={[e.Network.MAINNET]:{chainId:e.Network.MAINNET,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",balancerHelpers:"0x5aDDCCa35b7A0D07C74063c48700C8590E87864E",lidoRelayer:"0xdcdbf71A870cc60C6F9B621E28a7D3Ffd6Dd4965",relayerV3:"0x886A3Ec7bcC508B8795990B60Fa21f85F9dB7948",relayerV4:"0x2536dfeeCB7A0397CF98eDaDA8486254533b1aFA",gaugeController:"0xc128468b7ce63ea702c1f104d55a2566b13d3abd",feeDistributor:"0xD3cf852898b21fc233251427c2DC93d3d604F3BB",protocolFeePercentagesProvider:"0x97207B095e4D5C9a6e4cfbfcd2C3358E03B90c4A",veBal:"0xC128a9954e6c874eA3d62ce62B468bA073093F25",veBalProxy:"0x6f5a2eE11E7a772AeB5114A20d0D7c0ff61EB8A0",weightedPoolFactory:"0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9",composableStablePoolFactory:"0x85a80afee867adf27b50bdb7b76da70f1e853062"},tokens:{wrappedNativeAsset:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",lbpRaisingTokens:["0x6B175474E89094C44Da98b954EedeAC495271d0F","0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],stETH:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",wstETH:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",bal:"0xba100000625a3754423978a60c9317c58a424e3d",veBal:"0xC128a9954e6c874eA3d62ce62B468bA073093F25",bbaUsd:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2",gaugesSubgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges",blockNumberSubgraph:"https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks"},pools:{wETHwstETH:{id:"0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080",address:"0x32296969ef14eb0c6d29669c550d4a0449130230"}},poolsToIgnore:["0xbd482ffb3e6e50dc1c437557c3bea2b68f3683ee"],sorConnectingTokens:[{symbol:"wEth",address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"},{symbol:"wstEth",address:"0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"},{symbol:"DOLA",address:"0x865377367054516e17014CcdED1e7d814EDC9ce4"}]},[e.Network.POLYGON]:{chainId:e.Network.POLYGON,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0xa1B2b503959aedD81512C37e9dce48164ec6a94d",relayerV3:"0xcf6a66E32dCa0e26AcC3426b851FD8aCbF12Dac7",relayerV4:"0x28A224d9d398a1eBB7BA69BCA515898966Bb1B6b",balancerHelpers:"0x239e55F427D44C3cc793f49bFB507ebe76638a2b",weightedPoolFactory:"0x0e39C3D9b2ec765eFd9c5c70BB290B1fCD8536E3",composableStablePoolFactory:"0x85a80afee867adf27b50bdb7b76da70f1e853062"},tokens:{bal:"0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",wrappedNativeAsset:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-prune-v2",gaugesSubgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-polygon",blockNumberSubgraph:"https://api.thegraph.com/subgraphs/name/ianlapham/polygon-blocks"},pools:{},poolsToIgnore:["0x600bd01b6526611079e12e1ff93aba7a3e34226f"],sorConnectingTokens:[{symbol:"weth",address:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"},{symbol:"bbrz2",address:"0xe22483774bd8611be2ad2f4194078dac9159f4ba"}]},[e.Network.ARBITRUM]:{chainId:e.Network.ARBITRUM,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0x269ff446d9892c9e19082564df3f5e8741e190a1",relayerV3:"0x42E49B48573c725ee32d2579060Ed06894f97002",relayerV4:"0x5bf3B7c14b10f16939d63Bd679264A1Aa951B4D5",balancerHelpers:"0x77d46184d22CA6a3726a2F500c776767b6A3d6Ab",weightedPoolFactory:"0x8df6EfEc5547e31B0eb7d1291B511FF8a2bf987c",composableStablePoolFactory:"0x85a80afee867adf27b50bdb7b76da70f1e853062"},tokens:{bal:"0x040d1edc9569d4bab2d15287dc5a4f10f56a56b8",wrappedNativeAsset:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2",gaugesSubgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-arbitrum",blockNumberSubgraph:"https://api.thegraph.com/subgraphs/name/ianlapham/arbitrum-one-blocks"},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}]},[e.Network.KOVAN]:{chainId:e.Network.KOVAN,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A",veBal:"0x16ba924752EF283C7946db8A122a6742AA35C1DC",veBalProxy:"0x98D0d0a65cBeCCaa647a5a95cf27Cf2f00E1231C",balancerHelpers:"0x94905e703fEAd7f0fD0eEe355D267eE909784e6d",weightedPoolFactory:"0x8df6EfEc5547e31B0eb7d1291B511FF8a2bf987c"},tokens:{wrappedNativeAsset:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-kovan-v2",gaugesSubgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges"},pools:{}},[e.Network.ROPSTEN]:{chainId:e.Network.ROPSTEN,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0x53c43764255c17bd724f74c4ef150724ac50a3ed",balancerHelpers:""},tokens:{wrappedNativeAsset:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1"}},urls:{subgraph:"",gaugesSubgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges"},pools:{}},[e.Network.RINKEBY]:{chainId:e.Network.RINKEBY,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821",balancerHelpers:"0x5aDDCCa35b7A0D07C74063c48700C8590E87864E",weightedPoolFactory:"0x8df6EfEc5547e31B0eb7d1291B511FF8a2bf987c"},tokens:{wrappedNativeAsset:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-rinkeby-v2",gaugesSubgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges"},pools:{}},[e.Network.GOERLI]:{chainId:e.Network.GOERLI,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e",relayerV3:"0x7b9B6f094DC2Bd1c12024b0D9CC63d6993Be1888",relayerV4:"0x00e695aA8000df01B8DC8401B4C34Fba5D56BBb2",gaugeController:"0xBB1CE49b16d55A1f2c6e88102f32144C7334B116",veBal:"0x33A99Dcc4C85C014cf12626959111D5898bbCAbF",veBalProxy:"0xA1F107D1cD709514AE8A914eCB757E95f9cedB31",balancerHelpers:"0x5aDDCCa35b7A0D07C74063c48700C8590E87864E",weightedPoolFactory:"0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9",composableStablePoolFactory:"0x85a80afee867adf27b50bdb7b76da70f1e853062"},tokens:{wrappedNativeAsset:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2",gaugesSubgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-goerli",blockNumberSubgraph:"https://api.thegraph.com/subgraphs/name/blocklytics/goerli-blocks"},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1"}]},[e.Network.OPTIMISM]:{chainId:e.Network.OPTIMISM,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0x2dc0e2aa608532da689e89e237df582b783e552c",relayerV3:"0x195CcCBE464EF9073d1f7A1ba1C9Bf0f56dfFFff",relayerV4:"0x1a58897Ab366082028ced3740900ecBD765Af738",balancerHelpers:"0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9",weightedPoolFactory:"0x0e39C3D9b2ec765eFd9c5c70BB290B1fCD8536E3",composableStablePoolFactory:"0x85a80afee867adf27b50bdb7b76da70f1e853062"},tokens:{wrappedNativeAsset:"0x4200000000000000000000000000000000000006"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/beethovenxfi/beethovenx-optimism",gaugesSubgraph:""},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0x4200000000000000000000000000000000000006"}]},[e.Network.GNOSIS]:{chainId:e.Network.GNOSIS,addresses:{contracts:{vault:"0xBA12222222228d8Ba445958a75a0704d566BF2C8",multicall:"0xbb6fab6b627947dae0a75808250d8b2652952cb5",relayerV4:"0xeF606F58A4FD0fCcb066c6203d0994694d3eB2D3",balancerHelpers:"0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9",weightedPoolFactory:"0xf302f9F50958c5593770FDf4d4812309fF77414f",composableStablePoolFactory:"0x76578ecf9a141296ec657847fb45b0585bcda3a6"},tokens:{wrappedNativeAsset:"0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d"}},urls:{subgraph:"https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gnosis-chain-v2",gaugesSubgraph:""},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d"}]},[e.Network.DEFIVERSE]:{chainId:e.Network.DEFIVERSE,addresses:{contracts:{vault:"0x2FA699664752B34E90A414A42D62D7A8b2702B85",multicall:"0x8633dD7223f76c99bdc5a2D116FCF369d79852C4",relayerV4:"0x00e695aA8000df01B8DC8401B4C34Fba5D56BBb2",gaugeController:"",feeDistributor:"",protocolFeePercentagesProvider:"0xC462175C87672c7aad536c1248b72B1Cf46BEe27",veBal:"",veBalProxy:"",balancerHelpers:"0x4087EDb699803608A0214FD92e32119CAF57EcA3",weightedPoolFactory:"0xD1920DD25e4998B0d7cC8de7F12BeAf9796C7475",composableStablePoolFactory:"0xD01ad3085fb3e1fbB2541b5B3326B1F47B189747"},tokens:{wrappedNativeAsset:"0x5a89E11Cb554E00c2f51C4bb7F05bc7Ab0Fa6351",bal:"",veBal:""}},urls:{priceUrl:"https://price-api.gaming-dex.com/api/v1",subgraph:"https://graphnode.defi-verse.org/subgraphs/name/balancer-labs/defiverse",gaugesSubgraph:"https://graphnode.defi-verse.org/subgraphs/name/balancer-labs/gauges-defiverse"},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0x5a89E11Cb554E00c2f51C4bb7F05bc7Ab0Fa6351"}]},[e.Network.DEFIVERSE_TESTNET]:{chainId:e.Network.DEFIVERSE_TESTNET,addresses:{contracts:{vault:"0x2Da016a77E290fb82F5af7051198304d57779f5d",multicall:"0xEB47269E97EeDB20EF782EB8caFb09ed55b02A39",relayerV4:"0x00e695aA8000df01B8DC8401B4C34Fba5D56BBb2",gaugeController:"",feeDistributor:"",protocolFeePercentagesProvider:"0x38d04d161247031484B31fB8403D20bed5287cf7",veBal:"",veBalProxy:"",balancerHelpers:"0x47404b46E0340F879ECC15977Ce196458cadc2DF",weightedPoolFactory:"0x48494Fa9eAd46EE8E3FcB66487a6dBBD34DcAFe3",composableStablePoolFactory:"0x58e6F99bB65378f47A520fC9630Bd711f2cf3Dc7"},tokens:{wrappedNativeAsset:"0x6B382742b07AAbBA58c38d792B5d7CBAaB246e99",bal:"0xb5C5C48D3082751f60EE1CAc8FC84a921931EC24"}},urls:{priceUrl:"https://price-api-testnet.gaming-dex.com/api/v1",subgraph:"https://graphnode-testnet.defi-verse.org/subgraphs/name/balancer-labs/defiverse-testnet-v2",gaugesSubgraph:"https://graphnode-testnet.defi-verse.org/subgraphs/name/balancer-labs/gauges-defiverse-testnet-v2"},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0x6B382742b07AAbBA58c38d792B5d7CBAaB246e99"}]},[e.Network.OASYS]:{chainId:e.Network.OASYS,addresses:{contracts:{vault:"0xfb6f8FEdE0Cb63674Ab964affB93D65a4a7D55eA",multicall:"0xc52dc4a7dad06BEAB9230D482AcBEcFFc3aB009B",relayerV4:"0x00e695aA8000df01B8DC8401B4C34Fba5D56BBb2",gaugeController:"0x2D2BB676EfE00998ABf25aa499A19af16cC99F3e",feeDistributor:"0xE93F762E0d736fB2780bb9271233367942189B86",protocolFeePercentagesProvider:"0x56C181Ecf83e773978137b2B567d660768f8c8e3",veBal:"0x2B726256AdD04e65403cEf6679A2f2dfF7DDe9F9",veBalProxy:"0xe5276B39E604999c05d3051D896310A620E4Cc49",balancerHelpers:"0xf199DDb57d75225e13Fe13eb8BDDE8b16e188374",weightedPoolFactory:"0x4EF0b4827cE3D5FEcBc2C6ab80Ee81dBF9631D37",composableStablePoolFactory:"0x0A7A98c9553192755f22b282278f0FA26f4de742"},tokens:{wrappedNativeAsset:"0x5200000000000000000000000000000000000001",bal:"0x2B726256AdD04e65403cEf6679A2f2dfF7DDe9F9",veBal:"0x2B726256AdD04e65403cEf6679A2f2dfF7DDe9F9"}},urls:{priceUrl:"https://price-api.gaming-dex.com/api/v1",subgraph:"https://graphnode-oasys.defi-verse.org/subgraphs/name/balancer-labs/oasys",gaugesSubgraph:"https://graphnode-oasys.defi-verse.org/subgraphs/name/balancer-labs/gauges-oasys"},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0x5200000000000000000000000000000000000001"}]},[e.Network.OASYS_TESTNET]:{chainId:e.Network.OASYS_TESTNET,addresses:{contracts:{vault:"0x1f7a0Bea1CB70FaA0f6b7B1126eCbd01Ef4E5BC8",multicall:"0xe5Fce05D922e3961F053bD2BF1F29F92d2a0a94B",relayerV4:"0x00e695aA8000df01B8DC8401B4C34Fba5D56BBb2",gaugeController:"0x82e3ACEE6e747B164327cca5e6309bb38f114848",feeDistributor:"0x8A55C4F4f178d62Da281c244e4AD98A9C72c418a",protocolFeePercentagesProvider:"0xACA587e675102f0fDcBc9FddC441f820cB2c64b9",veBal:"0x9288F664FEFc9f374A53C4307BD3c8F91e83f466",veBalProxy:"0x0b205Ed28BC51E7DE4686ef725488bCecEe87606",balancerHelpers:"0x3B847f3Fa5585Dc3aeDB40780fF47e31B0fF14C0",weightedPoolFactory:"0xd2d7F457B9749B6A0A637685A65681F03116125C",composableStablePoolFactory:"0xfDA8fa80dd77A99BF71BeCFce47077859e689898"},tokens:{wrappedNativeAsset:"0x5200000000000000000000000000000000000001",bal:"0x9288F664FEFc9f374A53C4307BD3c8F91e83f466",veBal:"0x9288F664FEFc9f374A53C4307BD3c8F91e83f466"}},urls:{priceUrl:"https://price-api-testnet.gaming-dex.com/api/v1",subgraph:"https://graphnode-oasys-testnet.defi-verse.org/subgraphs/name/balancer-labs/oasys-testnet",gaugesSubgraph:"https://graphnode-oasys-testnet.defi-verse.org/subgraphs/name/balancer-labs/gauges-oasys-testnet-v2"},pools:{},sorConnectingTokens:[{symbol:"weth",address:"0x5200000000000000000000000000000000000001"}]}},at=e=>tt[e].addresses;var nt;e.BalancerErrorCode=void 0,(nt=e.BalancerErrorCode||(e.BalancerErrorCode={})).SWAP_ZERO_RETURN_AMOUNT="SWAP_ZERO_RETURN_AMOUNT",nt.UNWRAP_ZERO_AMOUNT="UNWRAP_ZERO_AMOUNT",nt.WRAP_ZERO_AMOUNT="WRAP_ZERO_AMOUNT",nt.QUERY_BATCH_SWAP="QUERY_BATCH_SWAP",nt.POOL_DOESNT_EXIST="POOL_DOESNT_EXIST",nt.UNSUPPORTED_POOL_TYPE="UNSUPPORTED_POOL_TYPE",nt.UNSUPPORTED_PAIR="UNSUPPORTED_PAIR",nt.NO_POOL_DATA="NO_POOL_DATA",nt.INPUT_OUT_OF_BOUNDS="INPUT_OUT_OF_BOUNDS",nt.INPUT_LENGTH_MISMATCH="INPUT_LENGTH_MISMATCH",nt.INPUT_TOKEN_INVALID="INPUT_TOKEN_INVALID",nt.INPUT_ZERO_NOT_ALLOWED="INPUT_ZERO_NOT_ALLOWED",nt.INTERNAL_ERROR_INVALID_ABI="INTERNAL_ERROR_INVALID_ABI",nt.TOKEN_MISMATCH="TOKEN_MISMATCH",nt.MISSING_TOKENS="MISSING_TOKENS",nt.MISSING_AMP="MISSING_AMP",nt.MISSING_DECIMALS="MISSING_DECIMALS",nt.MISSING_PRICE_RATE="MISSING_PRICE_RATE",nt.MISSING_WEIGHT="MISSING_WEIGHT",nt.RELAY_SWAP_AMOUNTS="RELAY_SWAP_AMOUNTS",nt.NO_VALUE_PARAMETER="NO_VALUE_PARAMETER",nt.ILLEGAL_PARAMETER="ILLEGAL_PARAMETER",nt.TIMESTAMP_IN_THE_FUTURE="TIMESTAMP_IN_THE_FUTURE",nt.JOIN_DELTA_AMOUNTS="JOIN_DELTA_AMOUNTS",nt.EXIT_DELTA_AMOUNTS="EXIT_DELTA_AMOUNTS";class st extends Error{constructor(e){super(st.getMessage(e)),this.code=e,this.name="BalancerError"}static getMessage(t){switch(t){case e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT:return"queryBatchSwapWithSor returned 0 amount";case e.BalancerErrorCode.UNWRAP_ZERO_AMOUNT:return"swapUnwrapAaveStaticExactIn unwrapped amount < 0";case e.BalancerErrorCode.WRAP_ZERO_AMOUNT:return"swapUnwrapAaveStaticExactOut wrapped amount < 0";case e.BalancerErrorCode.QUERY_BATCH_SWAP:return"queryBatchSwap on chain call error";case e.BalancerErrorCode.POOL_DOESNT_EXIST:return"balancer pool does not exist";case e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE:return"unsupported pool type";case e.BalancerErrorCode.UNSUPPORTED_PAIR:return"unsupported token pair";case e.BalancerErrorCode.NO_POOL_DATA:return"no pool data";case e.BalancerErrorCode.INPUT_OUT_OF_BOUNDS:return"input out of bounds";case e.BalancerErrorCode.INPUT_LENGTH_MISMATCH:return"input length mismatch";case e.BalancerErrorCode.INPUT_TOKEN_INVALID:return"input token invalid";case e.BalancerErrorCode.TOKEN_MISMATCH:return"token mismatch";case e.BalancerErrorCode.MISSING_DECIMALS:return"missing decimals";case e.BalancerErrorCode.MISSING_TOKENS:return"missing tokens";case e.BalancerErrorCode.MISSING_AMP:return"missing amp";case e.BalancerErrorCode.MISSING_PRICE_RATE:return"missing price rate";case e.BalancerErrorCode.MISSING_WEIGHT:return"missing weight";case e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED:return"zero input not allowed";case e.BalancerErrorCode.RELAY_SWAP_AMOUNTS:return"Error when checking swap amounts";case e.BalancerErrorCode.NO_VALUE_PARAMETER:return"Illegal value passed as parameter";case e.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE:return"Timestamp cannot be in the future";case e.BalancerErrorCode.ILLEGAL_PARAMETER:return"An illegal parameter has been passed";case e.BalancerErrorCode.JOIN_DELTA_AMOUNTS:return"Error when checking join call deltas";case e.BalancerErrorCode.EXIT_DELTA_AMOUNTS:return"Error when checking exit call deltas";default:return"Unknown error"}}}class it{constructor(){this.buildExitExactBPTIn=({exiter:t,pool:s,bptIn:i,slippage:r,shouldUnwrapNativeAsset:o,wrappedNativeAsset:d,singleTokenMaxOut:c})=>{if(!i.length||n.parseFixed(i,18).isNegative())throw new st(e.BalancerErrorCode.INPUT_OUT_OF_BOUNDS);if(c&&c!==a.AddressZero&&!s.tokens.map((e=>e.address)).some((e=>$e(e,c))))throw new st(e.BalancerErrorCode.TOKEN_MISMATCH);if(!o&&c===a.AddressZero)throw new Error("shouldUnwrapNativeAsset and singleTokenMaxOut should not have conflicting values");if(s.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);if(!s.amp)throw new st(e.BalancerErrorCode.MISSING_AMP);const{parsedTokens:l,parsedAmp:u,parsedTotalShares:y,parsedSwapFee:b,upScaledBalances:m,scalingFactors:f}=se(s),h=l.map((e=>e===d?a.AddressZero:e)),T=new W(d),[g,I,w]=T.sortTokens(o?h:l,m,f);let E,x=Array(l.length).fill("0"),P=Array(l.length).fill("0");if(c){const e=l.indexOf(c),t=A.StableMathBigInt._calcTokenOutGivenExactBptIn(BigInt(u),I.map((e=>BigInt(e))),e,BigInt(i),BigInt(y),BigInt(b)).toString();x[e]=t,P[e]=ze(n.BigNumber.from(t),n.BigNumber.from(r)).toString(),E=S.exitExactBPTInForOneTokenOut(i,e)}else{const e=function(e,t){const a=new Array(e.length);for(let n=0;n<e.length;++n)a[n]=ae.divDownFixed(e[n],t[n]);return a}(A.StableMathBigInt._calcTokensOutGivenExactBptIn(I.map((e=>BigInt(e))),BigInt(i),BigInt(y)).map((e=>e.toString())).map((e=>BigInt(e))),w.map((e=>BigInt(e))));x=e.map((e=>e.toString())),P=e.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(r)).toString())),E=S.exitExactBPTInForTokensOut(i)}const _=et,B="exitPool",O={poolId:s.id,sender:t,recipient:t,exitPoolRequest:{assets:g,minAmountsOut:P,userData:E,toInternalBalance:!1}};return{to:_,functionName:B,attributes:O,data:p.Vault__factory.createInterface().encodeFunctionData(B,[O.poolId,O.sender,O.recipient,O.exitPoolRequest]),expectedAmountsOut:x,minAmountsOut:P}},this.buildExitExactTokensOut=({exiter:t,pool:a,tokensOut:s,amountsOut:i,slippage:r,wrappedNativeAsset:o})=>{if(s.length!=i.length||s.length!=a.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);if(a.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);if(!a.amp)throw new st(e.BalancerErrorCode.MISSING_AMP);const{parsedTokens:d,parsedAmp:c,parsedTotalShares:l,parsedSwapFee:u,upScaledBalances:y,scalingFactors:b}=se(a),m=new W(o),[,f,h]=m.sortTokens(d,y,b),[T,g]=m.sortTokens(s,i),I=te(g.map((e=>BigInt(e))),h.map((e=>BigInt(e)))),w=A.StableMathBigInt._calcBptInGivenExactTokensOut(BigInt(c),f.map((e=>BigInt(e))),I,BigInt(l),BigInt(u)).toString(),E=Qe(n.BigNumber.from(w),n.BigNumber.from(r)).toString(),x=S.exitBPTInForExactTokensOut(g,E),P=et,_="exitPool",B={poolId:a.id,sender:t,recipient:t,exitPoolRequest:{assets:T,minAmountsOut:g,userData:x,toInternalBalance:!1}};return{to:P,functionName:_,attributes:B,data:p.Vault__factory.createInterface().encodeFunctionData(_,[B.poolId,B.sender,B.recipient,B.exitPoolRequest]),expectedBPTIn:w,maxBPTIn:E}}}}class rt{constructor(){this.buildJoin=({joiner:t,pool:s,tokensIn:i,amountsIn:r,slippage:o,wrappedNativeAsset:d})=>{if(i.length!=r.length||i.length!=s.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);if(s.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);if(!s.amp)throw new st(e.BalancerErrorCode.MISSING_AMP);const{parsedTokens:c,parsedAmp:l,parsedTotalShares:u,parsedSwapFee:y,scalingFactors:b,upScaledBalances:m}=se(s),f=new W(d),[h,T]=f.sortTokens(i,r),[,g,I]=f.sortTokens(c,m,b),w=te(T.map((e=>BigInt(e))),I.map((e=>BigInt(e)))),E=A.StableMathBigInt._calcBptOutGivenExactTokensIn(BigInt(l),g.map((e=>BigInt(e))),w,BigInt(u),BigInt(y)).toString(),x=ze(n.BigNumber.from(E),n.BigNumber.from(o)).toString(),P=S.joinExactTokensInForBPTOut(T,x),_=et,B="joinPool",O={poolId:s.id,sender:t,recipient:t,joinPoolRequest:{assets:h,maxAmountsIn:T,userData:P,fromInternalBalance:!1}},v=p.Vault__factory.createInterface().encodeFunctionData(B,[O.poolId,O.sender,O.recipient,O.joinPoolRequest]),k=r.filter(((e,t)=>i[t]===a.AddressZero));return{to:_,functionName:B,attributes:O,data:v,value:k[0]?n.BigNumber.from(k[0]):void 0,minBPTOut:x,expectedBPTOut:E}}}}class ot{calcTotal(e){var t,a;let s=n.BigNumber.from(0),i=n.BigNumber.from(0);for(let a=0;a<e.length;a++){const n=e[a];if(!(null===(t=n.price)||void 0===t?void 0:t.usd))continue;const r=Ge(n.price.usd.toString(),18),o=Ge(n.balance,18),d=o.mul(r);i=i.add(d),s=s.add(o)}if(s.gt(0)){const t=i.div(s);for(let n=0;n<e.length;n++){const r=e[n];if(null===(a=r.price)||void 0===a?void 0:a.usd)continue;const o=Ge(r.balance,18),d=o.mul(t);i=i.add(d),s=s.add(o)}}return n.formatFixed(i,36).toString()}}class dt{calcPoolSpotPrice(e,t,a){const n=l.StablePool.fromPool(a),s=n.parsePoolPairData(e,t);return n._spotPriceAfterSwapExactTokenInForTokenOut(s,l.ZERO).toString()}}function ct(e,t,a){return a?function(e,t){const a=Y-ae.divDownFixed(e,t);return a<0?BigInt(0):a}(e,t):function(e,t){const a=ae.divDownFixed(e,t)-Y;return a<0?BigInt(0):a}(e,t)}const lt=BigInt(1e3);function pt(e,t,a,n){const s=t.length,i=function(e,t,a){let n=X;const s=t.length;for(let e=0;e<s;e++)n+=t[e];if(n==X)return X;let i=X,r=n;const o=e*BigInt(s);for(let e=0;e<255;e++){let e=t[0]*BigInt(s);for(let n=1;n<s;n++)e=ae.div(ae.mul(ae.mul(e,t[n]),BigInt(s)),r,a);if(i=r,r=ae.div(ae.mul(ae.mul(BigInt(s),r),r)+ae.div(ae.mul(ae.mul(o,n),e),lt,a),ae.mul(BigInt(s+1),r)+ae.div(ae.mul(o-lt,e),lt,!a),a),r>i){if(r-i<=1)return r}else if(i-r<=1)return r}throw new Error("Errors.STABLE_INVARIANT_DIDNT_CONVERGE")}(e,t,!0);let r=X,o=i/BigInt(s);for(let e=0;e<s;e++)e!=n&&(r+=t[e],o=o*i/(BigInt(s)*t[e]));const d=t[n],c=e*BigInt(s),l=c*r,p=BigInt(lt)-c,u=BigInt(2)*c*d+l+p*i,y=o*BigInt(s+1)*lt-p*d;return ae.divUpFixed(u*a/y,i)}class ut{bptZeroPriceImpact(t,a){if(a.length!==t.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const{parsedBalances:n,parsedDecimals:s,parsedAmp:i,parsedTotalShares:r}=se(t),o=s.map((t=>{if(!t)throw new st(e.BalancerErrorCode.MISSING_DECIMALS);return BigInt(t)}));if(!i)throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const d=BigInt(r),c=o.map((e=>Q(BigInt(e)))),l=n.map(((e,t)=>ee(BigInt(e),c[t])));let p=X;for(let e=0;e<l.length;e++){const t=pt(BigInt(i),l,d,e),n=Q(BigInt(o[e]));p+=t*ee(a[e],n)/Y}return p}calcPriceImpact(e,t,a,n){const s=this.bptZeroPriceImpact(e,t.map((e=>BigInt(e))));return ct(BigInt(a),s,n).toString()}}class yt{constructor(e=new it,t=new rt,a=new ot,n=new dt,s=new ut){this.exit=e,this.join=t,this.liquidity=a,this.spotPriceCalculator=n,this.priceImpactCalculator=s}}class bt{calcPoolSpotPrice(e,t,a){const n=l.PhantomStablePool.fromPool(a),s=n.parsePoolPairData(e,t);return n._spotPriceAfterSwapExactTokenInForTokenOut(s,l.ZERO).toString()}}class mt{bptZeroPriceImpact(t,a){if(a.length!==t.tokensList.length-1)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const n=c.cloneDeep(t.tokensList),s=n.findIndex((e=>e==t.address)),{parsedBalances:i,parsedDecimals:r,parsedPriceRates:o,parsedAmp:d,parsedTotalShares:l}=se(t),p=r.map((t=>{if(!t)throw new st(e.BalancerErrorCode.MISSING_DECIMALS);return BigInt(t)})),u=o.map((t=>{if(!t)throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);return BigInt(t)}));if(!d)throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const y=BigInt(l);n.splice(s,1);const b=p.map((e=>Q(BigInt(e)))),m=i.map(((e,t)=>ee(BigInt(e),b[t])));if(a.length!==n.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);m.splice(s,1);const f=m.map(((e,t)=>ae.mulDownFixed(e,u[t])));let h=X;for(let e=0;e<n.length;e++){const t=pt(BigInt(d),f,y,e)*u[e]/Y,n=Q(BigInt(p[e]));h+=t*ee(a[e],n)/Y}return h}calcPriceImpact(e,t,a,n){const s=this.bptZeroPriceImpact(e,t.map((e=>BigInt(e))));return ct(BigInt(a),s,n).toString()}}class ft{constructor(){this.buildJoin=({joiner:t,pool:s,tokensIn:i,amountsIn:r,slippage:o,wrappedNativeAsset:d})=>{if(i.length!=r.length||i.length!=s.tokensList.length-1)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);if(s.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);const c=new W(d),[,u]=c.sortTokens(i,r),{parsedTokens:y,parsedAmp:b,parsedSwapFee:m,parsedTotalShares:f,scalingFactorsWithoutBpt:h,parsedBalancesWithoutBpt:T,bptIndex:g}=se(s,d);if(!b)throw new st(e.BalancerErrorCode.MISSING_AMP);const I=te(u.map(BigInt),h.map(BigInt)),w=l.StableMathBigInt._calcBptOutGivenExactTokensIn(BigInt(b),T.map(BigInt),I,BigInt(f),BigInt(m)).toString(),E=ze(n.BigNumber.from(w),n.BigNumber.from(o)).toString(),x=v.joinExactTokensInForBPTOut(u,E),A="joinPool",S={poolId:s.id,sender:t,recipient:t,joinPoolRequest:{assets:y,maxAmountsIn:Ve(u,g,"0"),userData:x,fromInternalBalance:!1}},P=p.Vault__factory.createInterface().encodeFunctionData(A,[S.poolId,S.sender,S.recipient,S.joinPoolRequest]),_=r.filter(((e,t)=>i[t]===a.AddressZero)),B=_[0]?n.BigNumber.from(_[0]):void 0;return{to:et,functionName:A,attributes:S,data:P,value:B,minBPTOut:E,expectedBPTOut:w}}}}class ht{constructor(){this.buildExitExactBPTIn=({exiter:e,pool:t,bptIn:a,slippage:n,shouldUnwrapNativeAsset:s,wrappedNativeAsset:i,singleTokenMaxOut:r})=>{throw new Error("To be implemented")},this.buildExitExactTokensOut=({exiter:e,pool:t,tokensOut:a,amountsOut:n,slippage:s,wrappedNativeAsset:i})=>{throw new Error("To be implemented")}}}class Tt{constructor(e=new ht,t=new ot,a=new bt,n=new mt,s=new ft){this.exit=e,this.liquidity=t,this.spotPriceCalculator=a,this.priceImpactCalculator=n,this.join=s}}class gt{constructor(){this.buildExitExactBPTIn=({exiter:t,pool:s,bptIn:i,slippage:r,shouldUnwrapNativeAsset:o,wrappedNativeAsset:d,singleTokenMaxOut:c})=>{if(!i.length||n.parseFixed(i,18).isNegative())throw new st(e.BalancerErrorCode.INPUT_OUT_OF_BOUNDS);if(c&&c!==a.AddressZero&&!s.tokens.map((e=>e.address)).some((e=>$e(e,c))))throw new st(e.BalancerErrorCode.TOKEN_MISMATCH);if(!o&&c===a.AddressZero)throw new Error("shouldUnwrapNativeAsset and singleTokenMaxOut should not have conflicting values");const{parsedTokens:l,parsedBalances:u,parsedWeights:y,parsedTotalShares:b,parsedSwapFee:m}=se(s),f=l.map((e=>e===d?a.AddressZero:e)),h=new W(d),[T,g,I]=h.sortTokens(o?f:l,u,y);let w,E=Array(T.length).fill("0"),x=Array(T.length).fill("0");if(c){const e=T.indexOf(c),t=A.WeightedMaths._calcTokenOutGivenExactBptIn(BigInt(g[e]),BigInt(I[e]),BigInt(i),BigInt(b),BigInt(m)).toString();E[e]=t,x[e]=ze(n.BigNumber.from(t),n.BigNumber.from(r)).toString(),w=P.exitExactBPTInForOneTokenOut(i,e)}else E=A.WeightedMaths._calcTokensOutGivenExactBptIn(g.map((e=>BigInt(e))),BigInt(i),BigInt(b)).map((e=>e.toString())),x=E.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(r)).toString())),w=P.exitExactBPTInForTokensOut(i);const S=et,_="exitPool",B={poolId:s.id,sender:t,recipient:t,exitPoolRequest:{assets:T,minAmountsOut:x,userData:w,toInternalBalance:!1}};return{to:S,functionName:_,attributes:B,data:p.Vault__factory.createInterface().encodeFunctionData(_,[B.poolId,B.sender,B.recipient,B.exitPoolRequest]),expectedAmountsOut:E,minAmountsOut:x}},this.buildExitExactTokensOut=({exiter:t,pool:a,tokensOut:s,amountsOut:i,slippage:r,wrappedNativeAsset:o})=>{if(s.length!=i.length||s.length!=a.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const{parsedTokens:d,parsedBalances:c,parsedWeights:l,parsedTotalShares:u,parsedSwapFee:y}=se(a),b=new W(o),[,m,f]=b.sortTokens(d,c,l),[h,T]=b.sortTokens(s,i),g=A.WeightedMaths._calcBptInGivenExactTokensOut(m.map((e=>BigInt(e))),f.map((e=>BigInt(e))),T.map((e=>BigInt(e))),BigInt(u),BigInt(y)).toString(),I=Qe(n.BigNumber.from(g),n.BigNumber.from(r)).toString(),w=P.exitBPTInForExactTokensOut(T,I),E=et,x="exitPool",S={poolId:a.id,sender:t,recipient:t,exitPoolRequest:{assets:h,minAmountsOut:T,userData:w,toInternalBalance:!1}};return{to:E,functionName:x,attributes:S,data:p.Vault__factory.createInterface().encodeFunctionData(x,[S.poolId,S.sender,S.recipient,S.exitPoolRequest]),expectedBPTIn:g,maxBPTIn:I}}}}class It{constructor(){this.buildJoin=({joiner:t,pool:s,tokensIn:i,amountsIn:r,slippage:o,wrappedNativeAsset:d})=>{if(i.length!=r.length||i.length!=s.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);if(s.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);if(s.tokens.some((e=>!e.weight)))throw new st(e.BalancerErrorCode.MISSING_WEIGHT);const{parsedTokens:c,parsedBalances:u,parsedWeights:y,parsedTotalShares:b,parsedSwapFee:m}=se(s),f=new W(d),[h,T]=f.sortTokens(i,r),[,g,I]=f.sortTokens(c,u,y),w=l.WeightedMaths._calcBptOutGivenExactTokensIn(g.map((e=>BigInt(e))),I.map((e=>BigInt(e))),T.map((e=>BigInt(e))),BigInt(b),BigInt(m)).toString(),E=ze(n.BigNumber.from(w),n.BigNumber.from(o)).toString(),x=P.joinExactTokensInForBPTOut(T,E),A=et,S="joinPool",_={poolId:s.id,sender:t,recipient:t,joinPoolRequest:{assets:h,maxAmountsIn:T,userData:x,fromInternalBalance:!1}},B=p.Vault__factory.createInterface().encodeFunctionData(S,[_.poolId,_.sender,_.recipient,_.joinPoolRequest]),O=r.filter(((e,t)=>i[t]===a.AddressZero));return{to:A,functionName:S,attributes:_,data:B,value:O[0]?n.BigNumber.from(O[0]):void 0,minBPTOut:E,expectedBPTOut:w}}}}class wt{calcTotal(e){var t;let a=n.BigNumber.from(0),s=n.BigNumber.from(0);for(let n=0;n<e.length;n++){const i=e[n];if(!(null===(t=i.price)||void 0===t?void 0:t.usd))continue;let r;r=parseFloat(i.price.usd)<1?Ge(parseFloat(i.price.usd).toFixed(10),10).mul(1e8):Ge(i.price.usd,18);const o=Ge(i.balance,18),d=Ge(i.weight||"0",18),c=o.mul(r);s=s.add(c),a=a.add(d)}const i=e.reduce(((e,t)=>e.add(Ge(t.weight||"0",18))),n.BigNumber.from(0));if(a.gt(0)){return qe(s.mul(i).div(a),36)}return"0"}}class Et{calcPoolSpotPrice(e,t,a){const n=e===a.address||t===a.address;if(n){const e={address:a.address,balance:a.totalShares,decimals:18,priceRate:"1",weight:"0"};a.tokens.push(e),a.tokensList.push(a.address)}const s=l.WeightedPool.fromPool(a),i=s.parsePoolPairData(e,t),r=s._spotPriceAfterSwapExactTokenInForTokenOut(i,l.ZERO).toString();return n&&(a.tokens.pop(),a.tokensList.pop()),r}}class xt{bptZeroPriceImpact(t,a){if(a.length!==t.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const{parsedBalances:n,parsedDecimals:s,parsedTotalShares:i,parsedWeights:r}=se(t),o=BigInt(i),d=c.cloneDeep(t.tokensList);let l=X;for(let t=0;t<d.length;t++){const i=s[t];let d,c;if(!i)throw new st(e.BalancerErrorCode.MISSING_DECIMALS);d=Q(BigInt(i)),c=ee(BigInt(n[t]),d);const p=r[t];let u;if(!p)throw new st(e.BalancerErrorCode.MISSING_WEIGHT);u=BigInt(p);l+=u*o/c*ee(a[t],d)/Y}return l}calcPriceImpact(e,t,a,n){const s=this.bptZeroPriceImpact(e,t.map((e=>BigInt(e))));return ct(BigInt(a),s,n).toString()}}class At{constructor(e=new gt,t=new It,a=new wt,n=new Et,s=new xt){this.exit=e,this.join=t,this.liquidity=a,this.spotPriceCalculator=n,this.priceImpactCalculator=s}}class St{constructor(){this.buildExitExactBPTIn=({exiter:t,pool:s,bptIn:i,slippage:r,shouldUnwrapNativeAsset:o,wrappedNativeAsset:d,singleTokenMaxOut:c})=>{if(!i.length||n.parseFixed(i,18).isNegative())throw new st(e.BalancerErrorCode.INPUT_OUT_OF_BOUNDS);if(c&&c!==a.AddressZero&&!s.tokens.map((e=>e.address)).some((e=>$e(e,c))))throw new st(e.BalancerErrorCode.TOKEN_MISMATCH);if(!o&&c===a.AddressZero)throw new Error("shouldUnwrapNativeAsset and singleTokenMaxOut should not have conflicting values");if(s.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);if(!s.amp)throw new st(e.BalancerErrorCode.MISSING_AMP);if(s.tokens.some((e=>!e.priceRate)))throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const{parsedTokens:l,parsedBalances:u,parsedAmp:y,parsedPriceRates:b,parsedTotalShares:m,parsedSwapFee:f}=se(s),h=l.map((e=>e===d?a.AddressZero:e)),T=new W(d),[g,I,w]=T.sortTokens(o?h:l,u,b),E=I.map(((e,t)=>n.BigNumber.from(e).mul(n.BigNumber.from(w[t])).div(n.parseFixed("1",18)).toString()));let x,P=Array(l.length).fill("0"),_=Array(l.length).fill("0");if(c){const e=g.indexOf(c),t=A.StableMathBigInt._calcTokenOutGivenExactBptIn(BigInt(y),E.map((e=>BigInt(e))),e,BigInt(i),BigInt(m),BigInt(f)).toString(),a=n.BigNumber.from(t).div(n.BigNumber.from(w[e])).mul(n.parseFixed("1",18)).toString();P[e]=a,_[e]=ze(n.BigNumber.from(a),n.BigNumber.from(r)).toString(),x=S.exitExactBPTInForOneTokenOut(i,e)}else{P=A.StableMathBigInt._calcTokensOutGivenExactBptIn(E.map((e=>BigInt(e))),BigInt(i),BigInt(m)).map((e=>e.toString())).map(((e,t)=>n.BigNumber.from(e).mul(n.parseFixed("1",18)).div(n.BigNumber.from(w[t])).toString())),_=P.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(r)).toString())),x=S.exitExactBPTInForTokensOut(i)}const B=et,O="exitPool",v={poolId:s.id,sender:t,recipient:t,exitPoolRequest:{assets:g,minAmountsOut:_,userData:x,toInternalBalance:!1}};return{to:B,functionName:O,attributes:v,data:p.Vault__factory.createInterface().encodeFunctionData(O,[v.poolId,v.sender,v.recipient,v.exitPoolRequest]),expectedAmountsOut:P,minAmountsOut:_}},this.buildExitExactTokensOut=({exiter:t,pool:a,tokensOut:s,amountsOut:i,slippage:r,wrappedNativeAsset:o})=>{if(s.length!=i.length||s.length!=a.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);if(a.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);if(!a.amp)throw new st(e.BalancerErrorCode.MISSING_AMP);if(a.tokens.some((e=>!e.priceRate)))throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const{parsedTokens:d,parsedBalances:c,parsedPriceRates:l,parsedAmp:u,parsedTotalShares:y,parsedSwapFee:b}=se(a),m=new W(o),[,f,h]=m.sortTokens(d,c,l),[T,g]=m.sortTokens(s,i),I=g.map(((e,t)=>n.BigNumber.from(e).mul(n.BigNumber.from(h[t])).div(n.parseFixed("1",18)).toString())),w=f.map(((e,t)=>n.BigNumber.from(e).mul(n.BigNumber.from(h[t])).div(n.parseFixed("1",18)).toString())),E=A.StableMathBigInt._calcBptInGivenExactTokensOut(BigInt(u),w.map((e=>BigInt(e))),I.map((e=>BigInt(e))),BigInt(y),BigInt(b)).toString(),x=Qe(n.BigNumber.from(E),n.BigNumber.from(r)).toString(),P=S.exitBPTInForExactTokensOut(g,x),_=g.map(((e,t)=>e===I[t]?e:n.BigNumber.from(e).sub(1).toString())),B=et,O="exitPool",v={poolId:a.id,sender:t,recipient:t,exitPoolRequest:{assets:T,minAmountsOut:_,userData:P,toInternalBalance:!1}};return{to:B,functionName:O,attributes:v,data:p.Vault__factory.createInterface().encodeFunctionData(O,[v.poolId,v.sender,v.recipient,v.exitPoolRequest]),expectedBPTIn:E,maxBPTIn:x}}}}class Pt{constructor(){this.buildJoin=({joiner:t,pool:s,tokensIn:i,amountsIn:r,slippage:o,wrappedNativeAsset:d})=>{if(i.length!=r.length||i.length!=s.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);if(s.tokens.some((e=>!e.decimals)))throw new st(e.BalancerErrorCode.MISSING_DECIMALS);if(!s.amp)throw new st(e.BalancerErrorCode.MISSING_AMP);if(s.tokens.some((e=>!e.priceRate)))throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const{parsedTokens:c,parsedBalances:l,parsedPriceRates:u,parsedAmp:y,parsedTotalShares:b,parsedSwapFee:m}=se(s),f=new W(d),[h,T]=f.sortTokens(i,r),[,g,I]=f.sortTokens(c,l,u),w=T.map(((e,t)=>n.BigNumber.from(e).mul(n.BigNumber.from(I[t])).div(n.parseFixed("1",18)).toString())),E=g.map(((e,t)=>n.BigNumber.from(e).mul(n.BigNumber.from(I[t])).div(n.parseFixed("1",18)).toString())),x=A.StableMathBigInt._calcBptOutGivenExactTokensIn(BigInt(y),E.map((e=>BigInt(e))),w.map((e=>BigInt(e))),BigInt(b),BigInt(m)).toString(),P=ze(n.BigNumber.from(x),n.BigNumber.from(o)).toString(),_=S.joinExactTokensInForBPTOut(T,P),B=et,O="joinPool",v={poolId:s.id,sender:t,recipient:t,joinPoolRequest:{assets:h,maxAmountsIn:T,userData:_,fromInternalBalance:!1}},k=p.Vault__factory.createInterface().encodeFunctionData(O,[v.poolId,v.sender,v.recipient,v.joinPoolRequest]),N=r.filter(((e,t)=>i[t]===a.AddressZero));return{to:B,functionName:O,attributes:v,data:k,value:N[0]?n.BigNumber.from(N[0]):void 0,minBPTOut:P,expectedBPTOut:x}}}}class _t{calcTotal(e){var t,s;let i=a.Zero,r=a.Zero;for(let a=0;a<e.length;a++){const n=e[a];if(!(null===(t=n.price)||void 0===t?void 0:t.usd))continue;const s=Ge(n.price.usd.toString(),18),o=Ge(n.balance,18),d=o.mul(s);r=r.add(d),i=i.add(o)}if(i.gt(0)){const t=r.div(i);for(let a=0;a<e.length;a++){const n=e[a];if(null===(s=n.price)||void 0===s?void 0:s.usd)continue;const o=Ge(n.balance,18),d=o.mul(t);r=r.add(d),i=i.add(o)}}return n.formatFixed(r,36).toString()}}class Bt{calcPoolSpotPrice(e,t,a){const n=l.MetaStablePool.fromPool(a),s=n.parsePoolPairData(e,t);return n._spotPriceAfterSwapExactTokenInForTokenOut(s,l.ZERO).toString()}}class Ot{bptZeroPriceImpact(t,a){if(a.length!==t.tokensList.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const{parsedBalances:n,parsedDecimals:s,parsedPriceRates:i,parsedAmp:r,parsedTotalShares:o}=se(t),d=BigInt(o),c=s.map((t=>{if(!t)throw new st(e.BalancerErrorCode.MISSING_DECIMALS);return BigInt(t)})),l=i.map((t=>{if(!t)throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);return BigInt(t)}));if(!r)throw new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const p=c.map((e=>Q(BigInt(e)))),u=n.map(((e,t)=>ee(BigInt(e),p[t]))),y=u.map(((e,t)=>ae.mulDownFixed(e,l[t])));let b=X;for(let e=0;e<u.length;e++){const n=pt(BigInt(r),y,d,e)*l[e]/Y,s=Q(BigInt(t.tokens[e].decimals));b+=n*ee(a[e],s)/Y}return b}calcPriceImpact(e,t,a,n){const s=this.bptZeroPriceImpact(e,t.map((e=>BigInt(e))));return ct(BigInt(a),s,n).toString()}}class vt{constructor(e=new St,t=new Pt,a=new _t,n=new Bt,s=new Ot){this.exit=e,this.join=t,this.liquidity=a,this.spotPriceCalculator=n,this.priceImpactCalculator=s}}class kt{constructor(){this.buildExitExactBPTIn=({exiter:e,pool:t,bptIn:a,slippage:n,shouldUnwrapNativeAsset:s,wrappedNativeAsset:i,singleTokenMaxOut:r})=>{throw new Error("To be implemented")},this.buildExitExactTokensOut=({exiter:e,pool:t,tokensOut:a,amountsOut:n,slippage:s,wrappedNativeAsset:i})=>{throw new Error("To be implemented")}}}class Nt{constructor(){this.buildJoin=({joiner:e,pool:t,tokensIn:a,amountsIn:n,slippage:s,wrappedNativeAsset:i})=>{throw new Error("To be implemented")}}}class Ct{constructor(e=new kt,t=new Nt,a=new ot,n=new bt,s=new mt){this.exit=e,this.join=t,this.liquidity=a,this.spotPriceCalculator=n,this.priceImpactCalculator=s}}class Dt{constructor(){this.buildExitExactBPTIn=({exiter:e,pool:t,bptIn:a,slippage:n,shouldUnwrapNativeAsset:s,wrappedNativeAsset:i,singleTokenMaxOut:r})=>{throw new Error("To be implemented")},this.buildExitExactTokensOut=({exiter:e,pool:t,tokensOut:a,amountsOut:n,slippage:s,wrappedNativeAsset:i})=>{throw new Error("To be implemented")}}}class Rt{constructor(){this.buildJoin=({joiner:e,pool:t,tokensIn:a,amountsIn:n,slippage:s,wrappedNativeAsset:i})=>{throw new Error("To be implemented")}}}const Ft=18,Mt=Ge("1",Ft);class Lt{calcTotal(e){var t,n;let s=a.Zero,i=a.Zero;for(let a=0;a<e.length;a++){const n=e[a];if(!(null===(t=n.price)||void 0===t?void 0:t.usd))continue;const r=Ge(n.price.usd.toString(),Ft),o=Ge(n.balance,Ft),d=o.mul(r);i=i.add(d),s=s.add(o)}if(s.gt(0)){const t=i.div(s);for(let a=0;a<e.length;a++){const r=e[a];if(null===(n=r.price)||void 0===n?void 0:n.usd)continue;const o=Ge(r.priceRate||"1",Ft),d=Ge(r.balance,Ft).mul(o).div(Mt),c=d.mul(t);i=i.add(c),s=s.add(d)}}return qe(i,36)}}class Ut{calcPoolSpotPrice(e,t,a){const n=l.LinearPool.fromPool(a),s=n.parsePoolPairData(e,t);return n._spotPriceAfterSwapExactTokenInForTokenOut(s,l.ZERO).toString()}}class Gt{bptZeroPriceImpact(e,t){throw new Error("Linear Pool bptZeroPriceImpact Not Implented")}calcPriceImpact(e,t,a){throw new Error("Linear Pool Price Impact Not Implented")}}class qt{constructor(e=new Dt,t=new Rt,a=new Lt,n=new Ut,s=new Gt){this.exit=e,this.join=t,this.liquidity=a,this.spotPriceCalculator=n,this.priceImpactCalculator=s}}class Wt{constructor(e,t=new At,a=new yt,n=new Tt,s=new vt,i=new Ct,r=new qt){this.weighted=t,this.stable=a,this.composableStable=n,this.metaStable=s,this.stablePhantom=i,this.linear=r}static from(t){switch(t){case"Weighted":case"Investment":case"LiquidityBootstrapping":return new At;case"Stable":return new yt;case"HighAmpComposableStable":case"ComposableStable":return new Tt;case"MetaStable":return new vt;case"StablePhantom":return new Ct;case"AaveLinear":case"EulerLinear":case"ERC4626Linear":return new qt;default:throw new st(e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE)}}}class $t{constructor(e,t){this.pools=e,this.tokenPrices=t}async getLiquidity(e){if(e.totalLiquidity)return e.totalLiquidity;const t=e.tokens.filter((t=>t.address!==e.address)),a=await Promise.all(t.map((async e=>{const t=await this.pools.findBy("address",e.address);if(!t)return;const a=Ge(await this.getLiquidity(t),18),n=Ge(t.totalShares,18),s=Ge(e.balance,18),i=n.eq(0)?0:a.mul(s).div(n);return{address:t.address,liquidity:i.toString()}}))),s=a.reduce(((e,t)=>e.add(t?t.liquidity:n.BigNumber.from(0))),n.BigNumber.from(0)),i=t.filter((e=>!a.find((t=>(null==t?void 0:t.address)===e.address)))),r=await Promise.all(i.map((async e=>{var t;const a=await this.tokenPrices.find(e.address);return{address:e.address,decimals:e.decimals,priceRate:e.priceRate,price:(null==a?void 0:a.usd)&&a||{usd:null===(t=e.token)||void 0===t?void 0:t.latestUSDPrice},balance:e.balance,weight:e.weight}}))),o=Ge(Wt.from(e.poolType).liquidity.calcTotal(r),18);return qe(s.add(o),18)}}async function Vt(e,t,n,s){const i={sender:a.AddressZero,recipient:a.AddressZero,fromInternalBalance:!1,toInternalBalance:!1};try{return(await e.callStatic.queryBatchSwap(t,n,s,i)).map((e=>e.toString()))}catch(e){throw`queryBatchSwap call error: ${e}`}}async function Ht(t,n,s){s.fetchPools.fetchPools&&await t.fetchPools();const i=[],r=[];for(let n=0;n<s.tokensIn.length;n++){const o=await jt(s.tokensIn[n],s.tokensOut[n],s.swapType,s.amounts[n].toString(),t);if(!o.returnAmount.gt(a.Zero))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);i.push(o.swaps),r.push(o.tokenAddresses)}const o=function(e,t){const a=[...new Set(e.flat())];t.forEach(((t,n)=>{t.forEach((t=>{t.assetInIndex=a.indexOf(e[n][t.assetInIndex]),t.assetOutIndex=a.indexOf(e[n][t.assetOutIndex])}))}));const n=t.flat();return{swaps:n,assets:a}}(r,i),d=s.swapType===e.SwapType.SwapExactIn?s.tokensOut:s.tokensIn,c=Array(d.length).fill("0");let l=Array(o.assets.length).fill("0");try{l=await Vt(n,s.swapType,o.swaps,o.assets),l.length>0&&d.forEach(((e,t)=>{var n;return c[t]=null!==(n=l[o.assets.indexOf(e.toLowerCase())].toString())&&void 0!==n?n:a.Zero.toString()}))}catch(t){throw new st(e.BalancerErrorCode.QUERY_BATCH_SWAP)}return{returnAmounts:c,swaps:o.swaps,assets:o.assets,deltas:l.map((e=>e.toString()))}}async function jt(t,a,n,s,i){const r=n===e.SwapType.SwapExactIn?l.SwapTypes.SwapExactIn:l.SwapTypes.SwapExactOut;return await i.getSwaps(t.toLowerCase(),a.toLowerCase(),r,s)}var Kt=function(){return Kt=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var s in t=arguments[a])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},Kt.apply(this,arguments)},Zt=new Map,Xt=new Map,Jt=!0,Yt=!1;function zt(e){return e.replace(/[\s,]+/g," ").trim()}function Qt(e){var t=new Set,a=[];return e.definitions.forEach((function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,s=zt((r=e.loc).source.body.substring(r.start,r.end)),i=Xt.get(n);i&&!i.has(s)?Jt&&console.warn("Warning: fragment with name "+n+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):i||Xt.set(n,i=new Set),i.add(s),t.has(s)||(t.add(s),a.push(e))}else a.push(e);var r})),Kt(Kt({},e),{definitions:a})}function ea(e){var t=zt(e);if(!Zt.has(t)){var a=b.parse(e,{experimentalFragmentVariables:Yt,allowLegacyFragmentVariables:Yt});if(!a||"Document"!==a.kind)throw new Error("Not a valid GraphQL document.");Zt.set(t,function(e){var t=new Set(e.definitions);t.forEach((function(e){e.loc&&delete e.loc,Object.keys(e).forEach((function(a){var n=e[a];n&&"object"==typeof n&&t.add(n)}))}));var a=e.loc;return a&&(delete a.startToken,delete a.endToken),e}(Qt(a)))}return Zt.get(t)}function ta(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];"string"==typeof e&&(e=[e]);var n=e[0];return t.forEach((function(t,a){t&&"Document"===t.kind?n+=t.loc.source.body:n+=t,n+=e[a+1]})),ea(n)}var aa,na=ta,sa=function(){Zt.clear(),Xt.clear()},ia=function(){Jt=!1},ra=function(){Yt=!0},oa=function(){Yt=!1};(aa=ta||(ta={})).gql=na,aa.resetCaches=sa,aa.disableFragmentWarnings=ia,aa.enableExperimentalFragmentVariables=ra,aa.disableExperimentalFragmentVariables=oa,ta.default=ta;var da,ca,la,pa,ua,ya,ba,ma,fa,ha,Ta,ga,Ia,wa,Ea,xa,Aa,Sa,Pa,_a,Ba,Oa,va,ka,Na,Ca,Da,Ra=ta;!function(e){e.EndAmp="endAmp",e.EndTimestamp="endTimestamp",e.Id="id",e.PoolId="poolId",e.ScheduledTimestamp="scheduledTimestamp",e.StartAmp="startAmp",e.StartTimestamp="startTimestamp"}(da||(da={})),function(e){e.Id="id",e.PoolCount="poolCount",e.Timestamp="timestamp",e.TotalLiquidity="totalLiquidity",e.TotalSwapCount="totalSwapCount",e.TotalSwapFee="totalSwapFee",e.TotalSwapVolume="totalSwapVolume",e.Vault="vault"}(ca||(ca={})),function(e){e.Id="id",e.PoolCount="poolCount",e.Pools="pools",e.TotalLiquidity="totalLiquidity",e.TotalSwapCount="totalSwapCount",e.TotalSwapFee="totalSwapFee",e.TotalSwapVolume="totalSwapVolume"}(la||(la={})),function(e){e.EndTimestamp="endTimestamp",e.EndWeights="endWeights",e.Id="id",e.PoolId="poolId",e.ScheduledTimestamp="scheduledTimestamp",e.StartTimestamp="startTimestamp",e.StartWeights="startWeights"}(pa||(pa={})),function(e){e.Exit="Exit",e.Join="Join"}(ua||(ua={})),function(e){e.Amounts="amounts",e.Id="id",e.Pool="pool",e.Sender="sender",e.Timestamp="timestamp",e.Tx="tx",e.Type="type",e.User="user",e.ValueUsd="valueUSD"}(ya||(ya={})),function(e){e.Asset="asset",e.Block="block",e.Id="id",e.PoolId="poolId",e.Price="price",e.PricingAsset="pricingAsset"}(ba||(ba={})),function(e){e.CashDelta="cashDelta",e.Id="id",e.ManagedDelta="managedDelta",e.PoolTokenId="poolTokenId",e.Timestamp="timestamp",e.Type="type"}(ma||(ma={})),function(e){e.Deposit="Deposit",e.Update="Update",e.Withdraw="Withdraw"}(fa||(fa={})),function(e){e.Asc="asc",e.Desc="desc"}(ha||(ha={})),function(e){e.Id="id",e.Pool="pool"}(Ta||(Ta={})),function(e){e.Block="block",e.Id="id",e.PoolId="poolId",e.PoolLiquidity="poolLiquidity",e.PoolShareValue="poolShareValue",e.PoolTotalShares="poolTotalShares",e.PricingAsset="pricingAsset"}(ga||(ga={})),function(e){e.Balance="balance",e.Id="id",e.PoolId="poolId",e.UserAddress="userAddress"}(Ia||(Ia={})),function(e){e.Amounts="amounts",e.HoldersCount="holdersCount",e.Id="id",e.Liquidity="liquidity",e.Pool="pool",e.SwapFees="swapFees",e.SwapVolume="swapVolume",e.SwapsCount="swapsCount",e.Timestamp="timestamp",e.TotalShares="totalShares"}(wa||(wa={})),function(e){e.Address="address",e.AssetManager="assetManager",e.Balance="balance",e.CashBalance="cashBalance",e.Decimals="decimals",e.Id="id",e.Index="index",e.IsExemptFromYieldProtocolFee="isExemptFromYieldProtocolFee",e.ManagedBalance="managedBalance",e.Managements="managements",e.Name="name",e.PoolId="poolId",e.PriceRate="priceRate",e.Symbol="symbol",e.Token="token",e.Weight="weight"}(Ea||(Ea={})),function(e){e.Address="address",e.Alpha="alpha",e.Amp="amp",e.BaseToken="baseToken",e.Beta="beta",e.C="c",e.CreateTime="createTime",e.DSq="dSq",e.Delta="delta",e.Epsilon="epsilon",e.ExpiryTime="expiryTime",e.Factory="factory",e.HistoricalValues="historicalValues",e.HoldersCount="holdersCount",e.Id="id",e.IsInRecoveryMode="isInRecoveryMode",e.IsPaused="isPaused",e.Lambda="lambda",e.LowerTarget="lowerTarget",e.MainIndex="mainIndex",e.ManagementFee="managementFee",e.Name="name",e.OracleEnabled="oracleEnabled",e.Owner="owner",e.PoolType="poolType",e.PoolTypeVersion="poolTypeVersion",e.PriceRateProviders="priceRateProviders",e.PrincipalToken="principalToken",e.ProtocolAumFeeCache="protocolAumFeeCache",e.ProtocolId="protocolId",e.ProtocolSwapFeeCache="protocolSwapFeeCache",e.ProtocolYieldFeeCache="protocolYieldFeeCache",e.Root3Alpha="root3Alpha",e.S="s",e.Shares="shares",e.Snapshots="snapshots",e.SqrtAlpha="sqrtAlpha",e.SqrtBeta="sqrtBeta",e.StrategyType="strategyType",e.SwapEnabled="swapEnabled",e.SwapFee="swapFee",e.Swaps="swaps",e.SwapsCount="swapsCount",e.Symbol="symbol",e.TauAlphaX="tauAlphaX",e.TauAlphaY="tauAlphaY",e.TauBetaX="tauBetaX",e.TauBetaY="tauBetaY",e.Tokens="tokens",e.TokensList="tokensList",e.TotalLiquidity="totalLiquidity",e.TotalShares="totalShares",e.TotalSwapFee="totalSwapFee",e.TotalSwapVolume="totalSwapVolume",e.TotalWeight="totalWeight",e.Tx="tx",e.U="u",e.UnitSeconds="unitSeconds",e.UpperTarget="upperTarget",e.V="v",e.VaultId="vaultID",e.W="w",e.WeightUpdates="weightUpdates",e.WrappedIndex="wrappedIndex",e.Z="z"}(xa||(xa={})),function(e){e.Address="address",e.CacheDuration="cacheDuration",e.CacheExpiry="cacheExpiry",e.Id="id",e.LastCached="lastCached",e.PoolId="poolId",e.Rate="rate",e.Token="token"}(Aa||(Aa={})),function(e){e.EndSwapFeePercentage="endSwapFeePercentage",e.EndTimestamp="endTimestamp",e.Id="id",e.Pool="pool",e.ScheduledTimestamp="scheduledTimestamp",e.StartSwapFeePercentage="startSwapFeePercentage",e.StartTimestamp="startTimestamp"}(Sa||(Sa={})),function(e){e.Caller="caller",e.Id="id",e.PoolId="poolId",e.Timestamp="timestamp",e.TokenAmountIn="tokenAmountIn",e.TokenAmountOut="tokenAmountOut",e.TokenIn="tokenIn",e.TokenInSym="tokenInSym",e.TokenOut="tokenOut",e.TokenOutSym="tokenOutSym",e.Tx="tx",e.UserAddress="userAddress",e.ValueUsd="valueUSD"}(Pa||(Pa={})),function(e){e.Amount="amount",e.Asset="asset",e.Block="block",e.Id="id",e.PoolId="poolId",e.Price="price",e.PricingAsset="pricingAsset",e.Timestamp="timestamp"}(_a||(_a={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token="token",e.TotalBalanceNotional="totalBalanceNotional",e.TotalBalanceUsd="totalBalanceUSD",e.TotalSwapCount="totalSwapCount",e.TotalVolumeNotional="totalVolumeNotional",e.TotalVolumeUsd="totalVolumeUSD"}(Ba||(Ba={})),function(e){e.Address="address",e.Decimals="decimals",e.Id="id",e.LatestFxPrice="latestFXPrice",e.LatestPrice="latestPrice",e.LatestUsdPrice="latestUSDPrice",e.Name="name",e.Pool="pool",e.Symbol="symbol",e.TotalBalanceNotional="totalBalanceNotional",e.TotalBalanceUsd="totalBalanceUSD",e.TotalSwapCount="totalSwapCount",e.TotalVolumeNotional="totalVolumeNotional",e.TotalVolumeUsd="totalVolumeUSD"}(Oa||(Oa={})),function(e){e.Id="id",e.Pair="pair",e.Timestamp="timestamp",e.TotalSwapFee="totalSwapFee",e.TotalSwapVolume="totalSwapVolume"}(va||(va={})),function(e){e.Id="id",e.Token0="token0",e.Token1="token1",e.TotalSwapFee="totalSwapFee",e.TotalSwapVolume="totalSwapVolume"}(ka||(ka={})),function(e){e.Balance="balance",e.Id="id",e.Token="token",e.UserAddress="userAddress"}(Na||(Na={})),function(e){e.Id="id",e.SharesOwned="sharesOwned",e.Swaps="swaps",e.UserInternalBalances="userInternalBalances"}(Ca||(Ca={})),function(e){e.Allow="allow",e.Deny="deny"}(Da||(Da={}));const Fa=Ra`
2
+ fragment SubgraphPoolShare on PoolShare {
3
+ id
4
+ balance
5
+ userAddress {
6
+ id
7
+ }
8
+ poolId {
9
+ id
10
+ address
11
+ }
12
+ }
13
+ `,Ma=Ra`
14
+ fragment SubgraphPool on Pool {
15
+ id
16
+ address
17
+ poolType
18
+ poolTypeVersion
19
+ factory
20
+ strategyType
21
+ symbol
22
+ name
23
+ swapEnabled
24
+ swapFee
25
+ protocolYieldFeeCache
26
+ protocolSwapFeeCache
27
+ owner
28
+ totalWeight
29
+ totalSwapVolume
30
+ totalSwapFee
31
+ totalLiquidity
32
+ totalShares
33
+ tokens(first: 100) {
34
+ ...SubgraphPoolToken
35
+ }
36
+ swapsCount
37
+ holdersCount
38
+ tokensList
39
+ amp
40
+ priceRateProviders(first: 100) {
41
+ ...SubgraphPriceRateProvider
42
+ }
43
+ expiryTime
44
+ unitSeconds
45
+ createTime
46
+ principalToken
47
+ baseToken
48
+ wrappedIndex
49
+ mainIndex
50
+ lowerTarget
51
+ upperTarget
52
+ sqrtAlpha
53
+ sqrtBeta
54
+ root3Alpha
55
+ }
56
+ ${Ra`
57
+ fragment SubgraphPoolToken on PoolToken {
58
+ id
59
+ symbol
60
+ name
61
+ decimals
62
+ address
63
+ balance
64
+ managedBalance
65
+ weight
66
+ priceRate
67
+ isExemptFromYieldProtocolFee
68
+ token {
69
+ ...TokenTree
70
+ }
71
+ }
72
+ ${Ra`
73
+ fragment TokenTree on Token {
74
+ latestUSDPrice
75
+ pool {
76
+ ...SubgraphSubPool
77
+ tokens {
78
+ ...SubgraphSubPoolToken
79
+ token {
80
+ latestUSDPrice
81
+ pool {
82
+ ...SubgraphSubPool
83
+ tokens {
84
+ ...SubgraphSubPoolToken
85
+ token {
86
+ latestUSDPrice
87
+ pool {
88
+ ...SubgraphSubPool
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ ${Ra`
98
+ fragment SubgraphSubPool on Pool {
99
+ id
100
+ totalShares
101
+ address
102
+ poolType
103
+ mainIndex
104
+ }
105
+ `}
106
+ ${Ra`
107
+ fragment SubgraphSubPoolToken on PoolToken {
108
+ address
109
+ balance
110
+ weight
111
+ priceRate
112
+ symbol
113
+ decimals
114
+ isExemptFromYieldProtocolFee
115
+ }
116
+ `}`}`}
117
+ ${Ra`
118
+ fragment SubgraphPriceRateProvider on PriceRateProvider {
119
+ address
120
+ token {
121
+ address
122
+ }
123
+ }
124
+ `}`;Ra`
125
+ fragment TokenAttrs on Token {
126
+ address
127
+ symbol
128
+ decimals
129
+ }
130
+ `;const La=Ra`
131
+ fragment SubgraphPoolSnapshot on PoolSnapshot {
132
+ id
133
+ pool {
134
+ id
135
+ }
136
+ totalShares
137
+ swapVolume
138
+ swapFees
139
+ timestamp
140
+ }
141
+ `,Ua=Ra`
142
+ fragment SubgraphJoinExit on JoinExit {
143
+ amounts
144
+ id
145
+ sender
146
+ timestamp
147
+ tx
148
+ type
149
+ user {
150
+ id
151
+ }
152
+ pool {
153
+ id
154
+ tokensList
155
+ }
156
+ }
157
+ `,Ga=Ra`
158
+ fragment SubgraphBalancer on Balancer {
159
+ id
160
+ totalLiquidity
161
+ totalSwapVolume
162
+ totalSwapFee
163
+ totalSwapCount
164
+ poolCount
165
+ }
166
+ `,qa=Ra`
167
+ fragment SubgraphTokenPrice on TokenPrice {
168
+ id
169
+ poolId {
170
+ id
171
+ }
172
+ asset
173
+ amount
174
+ pricingAsset
175
+ price
176
+ block
177
+ timestamp
178
+ }
179
+ `,Wa=Ra`
180
+ fragment SubgraphTokenLatestPrice on LatestPrice {
181
+ id
182
+ asset
183
+ price
184
+ poolId {
185
+ id
186
+ }
187
+ pricingAsset
188
+ }
189
+ `,$a=Ra`
190
+ fragment SubgraphUser on User {
191
+ id
192
+ sharesOwned(first: 1000) {
193
+ balance
194
+ poolId {
195
+ id
196
+ }
197
+ }
198
+ }
199
+ `,Va=Ra`
200
+ query PoolShare($id: ID!, $block: Block_height) {
201
+ poolShare(id: $id, block: $block) {
202
+ ...SubgraphPoolShare
203
+ }
204
+ }
205
+ ${Fa}`,Ha=Ra`
206
+ query PoolShares($first: Int, $orderBy: PoolShare_orderBy, $orderDirection: OrderDirection, $skip: Int, $where: PoolShare_filter, $block: Block_height) {
207
+ poolShares(
208
+ first: $first
209
+ orderBy: $orderBy
210
+ orderDirection: $orderDirection
211
+ skip: $skip
212
+ where: $where
213
+ block: $block
214
+ ) {
215
+ ...SubgraphPoolShare
216
+ }
217
+ }
218
+ ${Fa}`,ja=Ra`
219
+ query Pools($skip: Int, $first: Int, $orderBy: Pool_orderBy, $orderDirection: OrderDirection, $where: Pool_filter, $block: Block_height) {
220
+ pools(
221
+ skip: $skip
222
+ first: $first
223
+ orderBy: $orderBy
224
+ orderDirection: $orderDirection
225
+ where: $where
226
+ block: $block
227
+ ) {
228
+ ...SubgraphPool
229
+ }
230
+ }
231
+ ${Ma}`,Ka=Ra`
232
+ query AllPools($skip: Int, $first: Int, $orderBy: Pool_orderBy, $orderDirection: OrderDirection, $where: Pool_filter, $block: Block_height) {
233
+ pool0: pools(
234
+ first: 1000
235
+ orderBy: $orderBy
236
+ orderDirection: $orderDirection
237
+ where: $where
238
+ block: $block
239
+ ) {
240
+ ...SubgraphPool
241
+ }
242
+ pool1000: pools(
243
+ first: 1000
244
+ skip: 1000
245
+ orderBy: $orderBy
246
+ orderDirection: $orderDirection
247
+ where: $where
248
+ block: $block
249
+ ) {
250
+ ...SubgraphPool
251
+ }
252
+ pool2000: pools(
253
+ first: 1000
254
+ skip: 2000
255
+ orderBy: $orderBy
256
+ orderDirection: $orderDirection
257
+ where: $where
258
+ block: $block
259
+ ) {
260
+ ...SubgraphPool
261
+ }
262
+ }
263
+ ${Ma}`,Za=Ra`
264
+ query Pool($id: ID!, $block: Block_height) {
265
+ pool(id: $id, block: $block) {
266
+ ...SubgraphPool
267
+ }
268
+ }
269
+ ${Ma}`,Xa=Ra`
270
+ query PoolHistoricalLiquidities($skip: Int, $first: Int, $orderBy: PoolHistoricalLiquidity_orderBy, $orderDirection: OrderDirection, $where: PoolHistoricalLiquidity_filter, $block: Block_height) {
271
+ poolHistoricalLiquidities(
272
+ skip: $skip
273
+ first: $first
274
+ orderBy: $orderBy
275
+ orderDirection: $orderDirection
276
+ where: $where
277
+ block: $block
278
+ ) {
279
+ id
280
+ poolId {
281
+ id
282
+ }
283
+ poolTotalShares
284
+ poolLiquidity
285
+ poolShareValue
286
+ pricingAsset
287
+ block
288
+ }
289
+ }
290
+ `,Ja=Ra`
291
+ query PoolSnapshots($skip: Int, $first: Int, $orderBy: PoolSnapshot_orderBy, $orderDirection: OrderDirection, $where: PoolSnapshot_filter, $block: Block_height) {
292
+ poolSnapshots(
293
+ skip: $skip
294
+ first: $first
295
+ orderBy: $orderBy
296
+ orderDirection: $orderDirection
297
+ where: $where
298
+ block: $block
299
+ ) {
300
+ ...SubgraphPoolSnapshot
301
+ }
302
+ }
303
+ ${La}`,Ya=Ra`
304
+ query JoinExits($skip: Int, $first: Int, $orderBy: JoinExit_orderBy, $orderDirection: OrderDirection, $where: JoinExit_filter, $block: Block_height) {
305
+ joinExits(
306
+ skip: $skip
307
+ first: $first
308
+ orderBy: $orderBy
309
+ orderDirection: $orderDirection
310
+ where: $where
311
+ block: $block
312
+ ) {
313
+ ...SubgraphJoinExit
314
+ }
315
+ }
316
+ ${Ua}`,za=Ra`
317
+ query Balancers($skip: Int, $first: Int, $orderBy: Balancer_orderBy, $orderDirection: OrderDirection, $where: Balancer_filter, $block: Block_height) {
318
+ balancers(
319
+ skip: $skip
320
+ first: $first
321
+ orderBy: $orderBy
322
+ orderDirection: $orderDirection
323
+ where: $where
324
+ block: $block
325
+ ) {
326
+ ...SubgraphBalancer
327
+ }
328
+ }
329
+ ${Ga}`,Qa=Ra`
330
+ query TokenPrices($skip: Int, $first: Int, $orderBy: TokenPrice_orderBy, $orderDirection: OrderDirection, $where: TokenPrice_filter, $block: Block_height) {
331
+ tokenPrices(
332
+ skip: $skip
333
+ first: $first
334
+ orderBy: $orderBy
335
+ orderDirection: $orderDirection
336
+ where: $where
337
+ block: $block
338
+ ) {
339
+ ...SubgraphTokenPrice
340
+ }
341
+ }
342
+ ${qa}`,en=Ra`
343
+ query TokenLatestPrices($skip: Int, $first: Int, $orderBy: LatestPrice_orderBy, $orderDirection: OrderDirection, $where: LatestPrice_filter, $block: Block_height) {
344
+ latestPrices(
345
+ skip: $skip
346
+ first: $first
347
+ orderBy: $orderBy
348
+ orderDirection: $orderDirection
349
+ where: $where
350
+ block: $block
351
+ ) {
352
+ ...SubgraphTokenLatestPrice
353
+ }
354
+ }
355
+ ${Wa}`,tn=Ra`
356
+ query TokenLatestPrice($id: ID!) {
357
+ latestPrice(id: $id) {
358
+ ...SubgraphTokenLatestPrice
359
+ }
360
+ }
361
+ ${Wa}`,an=Ra`
362
+ query User($id: ID!, $block: Block_height) {
363
+ user(id: $id, block: $block) {
364
+ ...SubgraphUser
365
+ }
366
+ }
367
+ ${$a}`,nn=Ra`
368
+ query Users($skip: Int, $first: Int, $orderBy: User_orderBy, $orderDirection: OrderDirection, $where: User_filter, $block: Block_height) {
369
+ users(
370
+ skip: $skip
371
+ first: $first
372
+ orderBy: $orderBy
373
+ orderDirection: $orderDirection
374
+ where: $where
375
+ block: $block
376
+ ) {
377
+ ...SubgraphUser
378
+ }
379
+ }
380
+ ${$a}`,sn=(e,t,a)=>e();function rn(e,t=sn){return{PoolShare:(a,n)=>t((t=>e.request(Va,a,{...n,...t})),"PoolShare","query"),PoolShares:(a,n)=>t((t=>e.request(Ha,a,{...n,...t})),"PoolShares","query"),Pools:(a,n)=>t((t=>e.request(ja,a,{...n,...t})),"Pools","query"),AllPools:(a,n)=>t((t=>e.request(Ka,a,{...n,...t})),"AllPools","query"),Pool:(a,n)=>t((t=>e.request(Za,a,{...n,...t})),"Pool","query"),PoolHistoricalLiquidities:(a,n)=>t((t=>e.request(Xa,a,{...n,...t})),"PoolHistoricalLiquidities","query"),PoolSnapshots:(a,n)=>t((t=>e.request(Ja,a,{...n,...t})),"PoolSnapshots","query"),JoinExits:(a,n)=>t((t=>e.request(Ya,a,{...n,...t})),"JoinExits","query"),Balancers:(a,n)=>t((t=>e.request(za,a,{...n,...t})),"Balancers","query"),TokenPrices:(a,n)=>t((t=>e.request(Qa,a,{...n,...t})),"TokenPrices","query"),TokenLatestPrices:(a,n)=>t((t=>e.request(en,a,{...n,...t})),"TokenLatestPrices","query"),TokenLatestPrice:(a,n)=>t((t=>e.request(tn,a,{...n,...t})),"TokenLatestPrice","query"),User:(a,n)=>t((t=>e.request(an,a,{...n,...t})),"User","query"),Users:(a,n)=>t((t=>e.request(nn,a,{...n,...t})),"Users","query")}}var on,dn,cn,ln,pn,un,yn,bn,mn,fn,hn,Tn,gn,In,wn;!function(e){e.Arbitrum="Arbitrum",e.Optimism="Optimism",e.Polygon="Polygon",e.Defiverse="Defiverse"}(on||(on={})),function(e){e.Gauges="gauges",e.Id="id",e.NumGauges="numGauges"}(dn||(dn={})),function(e){e.Balance="balance",e.Gauge="gauge",e.Id="id",e.User="user"}(cn||(cn={})),function(e){e.Id="id",e.Name="name"}(ln||(ln={})),function(e){e.Gauge="gauge",e.Id="id",e.Timestamp="timestamp",e.User="user",e.Weight="weight"}(pn||(pn={})),function(e){e.AddedTimestamp="addedTimestamp",e.Address="address",e.Id="id",e.LiquidityGauge="liquidityGauge",e.RootGauge="rootGauge",e.Type="type"}(un||(un={})),function(e){e.Factory="factory",e.Gauge="gauge",e.Id="id",e.IsKilled="isKilled",e.IsPreferentialGauge="isPreferentialGauge",e.Pool="pool",e.PoolAddress="poolAddress",e.PoolId="poolId",e.RelativeWeightCap="relativeWeightCap",e.Shares="shares",e.Streamer="streamer",e.Symbol="symbol",e.Tokens="tokens",e.TotalSupply="totalSupply"}(yn||(yn={})),function(e){e.Asc="asc",e.Desc="desc"}(bn||(bn={})),function(e){e.Address="address",e.Gauges="gauges",e.GaugesList="gaugesList",e.Id="id",e.PoolId="poolId",e.PreferentialGauge="preferentialGauge"}(mn||(mn={})),function(e){e.Decimals="decimals",e.Gauge="gauge",e.Id="id",e.PeriodFinish="periodFinish",e.Rate="rate",e.Symbol="symbol",e.TotalDeposited="totalDeposited"}(fn||(fn={})),function(e){e.Chain="chain",e.Factory="factory",e.Gauge="gauge",e.Id="id",e.IsKilled="isKilled",e.Recipient="recipient",e.RelativeWeightCap="relativeWeightCap"}(hn||(hn={})),function(e){e.GaugeShares="gaugeShares",e.GaugeVotes="gaugeVotes",e.Id="id",e.VotingLocks="votingLocks"}(Tn||(Tn={})),function(e){e.Id="id",e.LockedBalance="lockedBalance",e.UnlockTime="unlockTime",e.UpdatedAt="updatedAt",e.User="user",e.VotingEscrowId="votingEscrowID"}(gn||(gn={})),function(e){e.Id="id",e.Locks="locks",e.StakedSupply="stakedSupply"}(In||(In={})),function(e){e.Allow="allow",e.Deny="deny"}(wn||(wn={}));const En=Ra`
381
+ fragment SubgraphGaugeShare on GaugeShare {
382
+ id
383
+ balance
384
+ user {
385
+ id
386
+ }
387
+ gauge {
388
+ id
389
+ isKilled
390
+ poolId
391
+ poolAddress
392
+ totalSupply
393
+ }
394
+ }
395
+ `,xn=Ra`
396
+ fragment SubgraphLiquidityGauge on LiquidityGauge {
397
+ id
398
+ symbol
399
+ poolAddress
400
+ poolId
401
+ streamer
402
+ factory {
403
+ id
404
+ numGauges
405
+ }
406
+ totalSupply
407
+ tokens {
408
+ id
409
+ symbol
410
+ decimals
411
+ totalDeposited
412
+ rate
413
+ periodFinish
414
+ }
415
+ }
416
+ `,An=Ra`
417
+ fragment SubgraphPoolWithPreferentialGauge on Pool {
418
+ id
419
+ poolId
420
+ preferentialGauge {
421
+ ...SubgraphLiquidityGauge
422
+ }
423
+ }
424
+ ${xn}`,Sn=Ra`
425
+ query GaugeShare($id: ID!, $block: Block_height) {
426
+ gaugeShare(id: $id, block: $block) {
427
+ ...SubgraphGaugeShare
428
+ }
429
+ }
430
+ ${En}`,Pn=Ra`
431
+ query GaugeShares($first: Int, $orderBy: GaugeShare_orderBy, $orderDirection: OrderDirection, $skip: Int, $where: GaugeShare_filter, $block: Block_height) {
432
+ gaugeShares(
433
+ first: $first
434
+ orderBy: $orderBy
435
+ orderDirection: $orderDirection
436
+ skip: $skip
437
+ where: $where
438
+ block: $block
439
+ ) {
440
+ ...SubgraphGaugeShare
441
+ }
442
+ }
443
+ ${En}`,_n=Ra`
444
+ query LiquidityGauges($skip: Int, $first: Int, $orderBy: LiquidityGauge_orderBy, $orderDirection: OrderDirection, $where: LiquidityGauge_filter, $block: Block_height) {
445
+ liquidityGauges(
446
+ skip: $skip
447
+ first: $first
448
+ orderBy: $orderBy
449
+ orderDirection: $orderDirection
450
+ where: $where
451
+ block: $block
452
+ ) {
453
+ ...SubgraphLiquidityGauge
454
+ }
455
+ }
456
+ ${xn}`,Bn=Ra`
457
+ query Pools($skip: Int, $first: Int, $orderBy: Pool_orderBy, $orderDirection: OrderDirection, $where: Pool_filter, $block: Block_height) {
458
+ pools(
459
+ skip: $skip
460
+ first: $first
461
+ orderBy: $orderBy
462
+ orderDirection: $orderDirection
463
+ where: $where
464
+ block: $block
465
+ ) {
466
+ ...SubgraphPoolWithPreferentialGauge
467
+ }
468
+ }
469
+ ${An}`,On=Ra`
470
+ query PoolGauges($where: Pool_filter, $first: Int, $orderBy: Pool_orderBy, $orderDirection: OrderDirection, $skip: Int, $block: Block_height) {
471
+ pools(
472
+ where: $where
473
+ first: $first
474
+ orderBy: $orderBy
475
+ orderDirection: $orderDirection
476
+ skip: $skip
477
+ block: $block
478
+ ) {
479
+ gauges {
480
+ id
481
+ relativeWeightCap
482
+ }
483
+ preferentialGauge {
484
+ id
485
+ }
486
+ }
487
+ }
488
+ `,vn=(e,t,a)=>e();function kn(e){return rn(new y.GraphQLClient(e))}function Nn(e){return function(e,t=vn){return{GaugeShare:(a,n)=>t((t=>e.request(Sn,a,{...n,...t})),"GaugeShare","query"),GaugeShares:(a,n)=>t((t=>e.request(Pn,a,{...n,...t})),"GaugeShares","query"),LiquidityGauges:(a,n)=>t((t=>e.request(_n,a,{...n,...t})),"LiquidityGauges","query"),Pools:(a,n)=>t((t=>e.request(Bn,a,{...n,...t})),"Pools","query"),PoolGauges:(a,n)=>t((t=>e.request(On,a,{...n,...t})),"PoolGauges","query")}}(new y.GraphQLClient(e))}const Cn=["function aggregate(tuple[](address target, bytes callData) memory calls) public view returns (uint256 blockNumber, bytes[] memory returnData)"],Dn=(e,t)=>new i.Contract(e,Cn,t);class Rn{constructor(e,a,n,s={}){this.options={},this.calls=[],this.paths=[],this.multiAddress=e,this.provider=a,this.interface=new t.Interface(n),this.options=s}call(e,t,a,n){return this.calls.push([t,a,n]),this.paths.push(e),this}async execute(e={}){const t=e;return(await this.executeMulticall()).forEach(((e,a)=>c.set(t,this.paths[a],e.length>1?e:e[0]))),this.calls=[],this.paths=[],t}async executeMulticall(){const e=Dn(this.multiAddress,this.provider),[,t]=await e.aggregate(this.calls.map((([e,t,a])=>[e,this.interface.encodeFunctionData(t,a)])),this.options);return t.map(((e,t)=>this.interface.decodeFunctionResult(this.calls[t][1],e)))}}var Fn=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"uint256[]",name:"normalizedWeights",type:"uint256[]"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{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:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",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:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getNormalizedWeights",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"increaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"balanceTokenIn",type:"uint256"},{internalType:"uint256",name:"balanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",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:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Mn=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"startValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"}],name:"AmpUpdateStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"currentValue",type:"uint256"}],name:"AmpUpdateStopped",type:"event"},{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:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",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:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAmplificationParameter",outputs:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"isUpdating",type:"bool"},{internalType:"uint256",name:"precision",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],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:[],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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"balanceTokenIn",type:"uint256"},{internalType:"uint256",name:"balanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"rawEndValue",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"}],name:"startAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"stopAmplificationParameterUpdate",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:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Ln=[{inputs:[{internalType:"contract IERC20",name:"_underlying",type:"address"},{internalType:"contract IERC20",name:"_bond",type:"address"},{internalType:"uint256",name:"_expiration",type:"uint256"},{internalType:"uint256",name:"_unitSeconds",type:"uint256"},{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"uint256",name:"_percentFee",type:"uint256"},{internalType:"uint256",name:"_percentFeeGov",type:"uint256"},{internalType:"address",name:"_governance",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{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:[{indexed:!1,internalType:"uint256",name:"collectedBase",type:"uint256"},{indexed:!1,internalType:"uint256",name:"collectedBond",type:"uint256"},{indexed:!1,internalType:"uint256",name:"remainingBase",type:"uint256"},{indexed:!1,internalType:"uint256",name:"remainingBond",type:"uint256"}],name:"FeeCollection",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:[],name:"FEE_BOUND",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:[],name:"bond",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"bondDecimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"expiration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"feesBond",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"feesUnderlying",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"governance",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"increaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"currentBalances",type:"uint256[]"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"protocolSwapFee",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"},{internalType:"uint256[]",name:"dueProtocolFeeAmounts",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"currentBalances",type:"uint256[]"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"protocolSwapFee",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"},{internalType:"uint256[]",name:"dueProtocolFeeAmounts",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256",name:"currentBalanceTokenIn",type:"uint256"},{internalType:"uint256",name:"currentBalanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"percentFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"percentFeeGov",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:[{internalType:"uint256",name:"amountX",type:"uint256"},{internalType:"uint256",name:"reserveX",type:"uint256"},{internalType:"uint256",name:"reserveY",type:"uint256"},{internalType:"bool",name:"out",type:"bool"}],name:"solveTradeInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",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:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"underlying",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"underlyingDecimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"unitSeconds",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],Un=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20",name:"mainToken",type:"address"},{internalType:"contract IERC20",name:"wrappedToken",type:"address"},{internalType:"uint256",name:"upperTarget",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{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:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract IERC20",name:"token",type:"address"},{indexed:!1,internalType:"uint256",name:"lowerTarget",type:"uint256"},{indexed:!1,internalType:"uint256",name:"upperTarget",type:"uint256"}],name:"TargetsSet",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:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBptIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMainIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMainToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getScalingFactors",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getTargets",outputs:[{internalType:"uint256",name:"lowerTarget",type:"uint256"},{internalType:"uint256",name:"upperTarget",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVirtualSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedTokenRate",outputs:[{internalType:"uint256",name:"",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:[],name:"initialize",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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newLowerTarget",type:"uint256"},{internalType:"uint256",name:"newUpperTarget",type:"uint256"}],name:"setTargets",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:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Gn=[{inputs:[{components:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IProtocolFeePercentagesProvider",name:"protocolFeeProvider",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"contract IRateProvider[]",name:"rateProviders",type:"address[]"},{internalType:"uint256[]",name:"tokenRateCacheDurations",type:"uint256[]"},{internalType:"bool[]",name:"exemptFromYieldProtocolFeeFlags",type:"bool[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],internalType:"struct ComposableStablePool.NewPoolParams",name:"params",type:"tuple"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"startValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"}],name:"AmpUpdateStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"currentValue",type:"uint256"}],name:"AmpUpdateStopped",type:"event"},{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:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"feeType",type:"uint256"},{indexed:!1,internalType:"uint256",name:"protocolFeePercentage",type:"uint256"}],name:"ProtocolFeePercentageCacheUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"enabled",type:"bool"}],name:"RecoveryModeStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenIndex",type:"uint256"},{indexed:!1,internalType:"uint256",name:"rate",type:"uint256"}],name:"TokenRateCacheUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenIndex",type:"uint256"},{indexed:!0,internalType:"contract IRateProvider",name:"provider",type:"address"},{indexed:!1,internalType:"uint256",name:"cacheDuration",type:"uint256"}],name:"TokenRateProviderSet",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:"DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{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:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"disableRecoveryMode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"enableRecoveryMode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getActualSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAmplificationParameter",outputs:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"isUpdating",type:"bool"},{internalType:"uint256",name:"precision",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBptIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDomainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastJoinExitData",outputs:[{internalType:"uint256",name:"lastJoinExitAmplification",type:"uint256"},{internalType:"uint256",name:"lastPostJoinExitInvariant",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMinimumBpt",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"getNextNonce",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"feeType",type:"uint256"}],name:"getProtocolFeePercentageCache",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProtocolFeesCollector",outputs:[{internalType:"contract IProtocolFeesCollector",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProtocolSwapFeeDelegation",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRateProviders",outputs:[{internalType:"contract IRateProvider[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getScalingFactors",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"getTokenRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"getTokenRateCache",outputs:[{internalType:"uint256",name:"rate",type:"uint256"},{internalType:"uint256",name:"oldRate",type:"uint256"},{internalType:"uint256",name:"duration",type:"uint256"},{internalType:"uint256",name:"expires",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"inRecoveryMode",outputs:[{internalType:"bool",name:"",type:"bool"}],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:"contract IERC20",name:"token",type:"address"}],name:"isTokenExemptFromYieldProtocolFee",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",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:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"uint256",name:"duration",type:"uint256"}],name:"setTokenRateCacheDuration",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"rawEndValue",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"}],name:"startAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"stopAmplificationParameterUpdate",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:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"updateProtocolFeePercentageCache",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"updateTokenRateCache",outputs:[],stateMutability:"nonpayable",type:"function"}];async function qn(e,t,a,s){if(0===e.length)return e;const i=Object.values(Object.fromEntries([...p.Vault__factory.abi,...G,...Fn,...Mn,...Ln,...Un,...Gn].map((e=>[e.name,e])))),r=new Rn(t,s,i),o=Object.values(l.PoolFilter),d=[];e.forEach((e=>{o.includes(e.poolType)?(d.push(e),r.call(`${e.id}.poolTokens`,a,"getPoolTokens",[e.id]),r.call(`${e.id}.totalSupply`,e.address,"totalSupply"),(e.poolType.includes("Linear")||"StablePhantom"===e.poolType)&&r.call(`${e.id}.virtualSupply`,e.address,"getVirtualSupply"),"ComposableStable"===e.poolType&&r.call(`${e.id}.actualSupply`,e.address,"getActualSupply"),"Weighted"===e.poolType||"LiquidityBootstrapping"===e.poolType||"Investment"===e.poolType?(r.call(`${e.id}.weights`,e.address,"getNormalizedWeights"),r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Stable"===e.poolType||"MetaStable"===e.poolType||"StablePhantom"===e.poolType||"ComposableStable"===e.poolType?(r.call(`${e.id}.amp`,e.address,"getAmplificationParameter"),r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Element"===e.poolType?r.call(`${e.id}.swapFee`,e.address,"percentFee"):e.poolType.toString().includes("Linear")?(r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage"),r.call(`${e.id}.targets`,e.address,"getTargets"),r.call(`${e.id}.rate`,e.address,"getWrappedTokenRate")):e.poolType.toString().includes("Gyro")&&r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):console.error(`Unknown pool type: ${e.poolType} ${e.id}`)}));let c={};try{c=await r.execute()}catch(e){throw"Issue with multicall execution."}const u=[];return Object.entries(c).forEach((([e,t],a)=>{try{const{poolTokens:s,swapFee:i,weights:r,totalSupply:o,virtualSupply:c,actualSupply:l}=t;if("Stable"===d[a].poolType||"MetaStable"===d[a].poolType||"StablePhantom"===d[a].poolType||"ComposableStable"===d[a].poolType){if(!t.amp)return void console.error(`Stable Pool Missing Amp: ${e}`);d[a].amp=n.formatFixed(t.amp[0],3)}if(d[a].poolType.includes("Linear")){if(!t.targets)return void console.error(`Linear Pool Missing Targets: ${e}`);d[a].lowerTarget=n.formatFixed(t.targets[0],18),d[a].upperTarget=n.formatFixed(t.targets[1],18);const s=d[a].wrappedIndex;if(void 0===s||void 0===t.rate)return void console.error(`Linear Pool Missing WrappedIndex or PriceRate: ${e}`);d[a].tokens[s].priceRate=n.formatFixed(t.rate,18)}if(d[a].swapFee=n.formatFixed(i,18),s.tokens.forEach(((t,i)=>{const o=d[a].tokens.find((e=>$e(e.address,t)));if(!o)throw`Pool Missing Expected Token: ${e} ${t}`;o.balance=n.formatFixed(s.balances[i],o.decimals),r&&(o.weight=n.formatFixed(r[i],18))})),d[a].poolType.includes("Linear")||"StablePhantom"===d[a].poolType){if(void 0===c)return void console.error(`Pool with pre-minted BPT missing Virtual Supply: ${e}`);d[a].totalShares=n.formatFixed(c,18)}else if("ComposableStable"===d[a].poolType){if(void 0===l)return void console.error(`ComposableStable missing Actual Supply: ${e}`);d[a].totalShares=n.formatFixed(l,18)}else d[a].totalShares=n.formatFixed(o,18);u.push(d[a])}catch(e){throw`Issue with pool onchain data: ${e}`}})),u}class Wn{constructor(e,t,a,n){this.client=e,this.provider=t,this.network=a,this.sorConfig=n}async getPools(){const e=function(e){return e.map((e=>({...e,poolType:e.poolType||"",tokens:(e.tokens||[]).map((e=>({...e,weight:e.weight||null}))),totalWeight:e.totalWeight||void 0,amp:e.amp||void 0,expiryTime:e.expiryTime?c.parseInt(e.expiryTime):void 0,unitSeconds:e.unitSeconds?c.parseInt(e.unitSeconds):void 0,principalToken:e.principalToken||void 0,baseToken:e.baseToken||void 0})))}((await this.getSubgraphPools()).filter((e=>{if(!this.network.poolsToIgnore)return!0;return-1===this.network.poolsToIgnore.findIndex((t=>$e(t,e.address)))})));return!1===this.sorConfig.fetchOnChainBalances?e:qn(e,this.network.addresses.contracts.multicall,this.network.addresses.contracts.vault,this.provider)}async getSubgraphPools(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0,totalShares_gt:"1"},orderBy:xa.TotalLiquidity,orderDirection:ha.Desc});return[...e,...t,...a]}}class $n{constructor(e){this.chainId=e}async getNativeAssetPriceInToken(e){const t=await this.getTokenPriceInNativeAsset(e);return""+1/parseFloat(t)}async getTokenPriceInNativeAsset(e){const t=`https://api.coingecko.com/api/v3/simple/token_price/${this.platformId}?contract_addresses=${e}&vs_currencies=${this.nativeAssetId}`,{data:a}=await x.default.get(t,{headers:{Accept:"application/json","Content-Type":"application/json"}});if(void 0===a[e.toLowerCase()][this.nativeAssetId])throw Error("No price returned from Coingecko");return a[e.toLowerCase()][this.nativeAssetId]}get platformId(){switch(this.chainId){case 1:case 42:case 248:case 16116:case 17117:return"ethereum";case 137:return"polygon-pos";case 42161:return"arbitrum-one";case 100:return"xdai"}return"3"}get nativeAssetId(){switch(this.chainId){case 1:case 42:case 42161:case 248:case 16116:case 17117:return"eth";case 137:return"";case 100:return"xdai"}return""}}class Vn{constructor(e,t){this.client=e,this.weth=t.toLowerCase()}async getNativeAssetPriceInToken(e){const t=await this.getLatestPriceInEthFromSubgraph(e);if(!t)throw Error("No price found in the subgraph");return""+1/t}async getLatestPriceInEthFromSubgraph(e){e=e.toLowerCase();const{latestPrices:t}=await this.client.TokenLatestPrices({where:{asset_in:[e,this.weth]}}),a=c.keyBy(t,"id");if(a[`${e}-${this.weth}`])return parseFloat(a[`${e}-${this.weth}`].price);const n=t.filter((t=>t.asset===e));for(const e of n){const t=a[`${e.pricingAsset}-${this.weth}`];if(t)return parseFloat(e.price)*parseFloat(t.price)}return null}}function Hn(e){var t,a;if("number"==typeof e.network){const a=tt[e.network];return{...a,urls:{...a.urls,subgraph:null!==(t=e.customSubgraphUrl)&&void 0!==t?t:a.urls.subgraph},tenderly:e.tenderly}}return{...e.network,urls:{...e.network.urls,subgraph:null!==(a=e.customSubgraphUrl)&&void 0!==a?a:e.network.urls.subgraph},tenderly:e.network.tenderly}}class jn extends l.SOR{constructor(e){const t=Hn(e),a=jn.getSorConfig(e),n=jn.getSorNetworkConfig(t),s=new u.JsonRpcProvider(e.rpcUrl,e.network),i=kn(t.urls.subgraph);super(s,n,jn.getPoolDataService(t,a,s,i),jn.getTokenPriceService(t,a,i))}static getSorConfig(e){return{tokenPriceService:"coingecko",poolDataService:"subgraph",fetchOnChainBalances:!0,...e.sor}}static getSorNetworkConfig(e){var t;return{...e,vault:e.addresses.contracts.vault,weth:e.addresses.tokens.wrappedNativeAsset,lbpRaisingTokens:null===(t=e.addresses.tokens)||void 0===t?void 0:t.lbpRaisingTokens,wETHwstETH:e.pools.wETHwstETH,connectingTokens:e.sorConnectingTokens}}static getPoolDataService(e,t,a,n){return"object"==typeof t.poolDataService?t.poolDataService:new Wn(n,a,e,t)}static getTokenPriceService(e,t,a){return"object"==typeof t.tokenPriceService?t.tokenPriceService:("subgraph"===t.tokenPriceService&&new Vn(a,e.addresses.tokens.wrappedNativeAsset),new $n(e.chainId))}}function Kn(e){if(e.poolIds.length>2)throw new Error("Simple flash swap only supports a maximum of two pools");if(e.assets.length>2)throw new Error("Simple flash swap only supports a maximum of to two assets (tokens)")}function Zn(e,t){return[{poolId:e[0],assetInIndex:0,assetOutIndex:1,amount:t,userData:"0x"},{poolId:e[1],assetInIndex:1,assetOutIndex:0,amount:"0",userData:"0x"}]}function Xn(e){return-1*Number(e)}function Jn(e){return c.sum(e)}var Yn=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IERC20",name:"wstETH",type:"address"},{internalType:"contract IBalancerMinter",name:"minter",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approveVault",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"assetInIndex",type:"uint256"},{internalType:"uint256",name:"assetOutIndex",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.BatchSwapStep[]",name:"swaps",type:"tuple[]"},{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"int256[]",name:"limits",type:"int256[]"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{components:[{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"key",type:"uint256"}],internalType:"struct VaultActions.OutputReference[]",name:"outputReferences",type:"tuple[]"}],name:"batchSwap",outputs:[{internalType:"int256[]",name:"",type:"int256[]"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum VaultActions.PoolKind",name:"kind",type:"uint8"},{internalType:"address",name:"sender",type:"address"},{internalType:"address payable",name:"recipient",type:"address"},{components:[{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{internalType:"uint256[]",name:"minAmountsOut",type:"uint256[]"},{internalType:"bytes",name:"userData",type:"bytes"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.ExitPoolRequest",name:"request",type:"tuple"},{components:[{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"key",type:"uint256"}],internalType:"struct VaultActions.OutputReference[]",name:"outputReferences",type:"tuple[]"}],name:"exitPool",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge[]",name:"gauges",type:"address[]"}],name:"gaugeClaimRewards",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge",name:"gauge",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"gaugeDeposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address[]",name:"gauges",type:"address[]"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"gaugeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bool",name:"approval",type:"bool"},{internalType:"address",name:"user",type:"address"},{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:"gaugeSetMinterApproval",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge",name:"gauge",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"gaugeWithdraw",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"getEntrypoint",outputs:[{internalType:"contract IBalancerRelayer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum VaultActions.PoolKind",name:"kind",type:"uint8"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{components:[{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{internalType:"uint256[]",name:"maxAmountsIn",type:"uint256[]"},{internalType:"bytes",name:"userData",type:"bytes"},{internalType:"bool",name:"fromInternalBalance",type:"bool"}],internalType:"struct IVault.JoinPoolRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"joinPool",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.UserBalanceOpKind",name:"kind",type:"uint8"},{internalType:"contract IAsset",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"sender",type:"address"},{internalType:"address payable",name:"recipient",type:"address"}],internalType:"struct IVault.UserBalanceOp[]",name:"ops",type:"tuple[]"},{internalType:"uint256",name:"value",type:"uint256"}],name:"manageUserBalance",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"ref",type:"uint256"}],name:"peekChainedReferenceValue",outputs:[{internalType:"uint256",name:"value",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"relayer",type:"address"},{internalType:"bool",name:"approved",type:"bool"},{internalType:"bytes",name:"authorisation",type:"bytes"}],name:"setRelayerApproval",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"stakeETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"stakeETHAndWrap",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IAsset",name:"assetIn",type:"address"},{internalType:"contract IAsset",name:"assetOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.SingleSwap",name:"singleSwap",type:"tuple"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"uint256",name:"limit",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"swap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStaticATokenLM",name:"staticToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"toUnderlying",type:"bool"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapAaveStaticToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC4626",name:"wrappedToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapERC4626",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IUnbuttonToken",name:"wrapperToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapUnbuttonToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapWstETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC20Permit",name:"token",type:"address"},{internalType:"address",name:"owner",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:"vaultPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC20PermitDAI",name:"token",type:"address"},{internalType:"address",name:"holder",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"bool",name:"allowed",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"vaultPermitDAI",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStaticATokenLM",name:"staticToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"fromUnderlying",type:"bool"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapAaveDynamicToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC4626",name:"wrappedToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapERC4626",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapStETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IUnbuttonToken",name:"wrapperToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"uAmount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapUnbuttonToken",outputs:[],stateMutability:"payable",type:"function"}];const zn={"0xae7ab96520de3a18e5e111b5eaab095312d7fe84":"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0","0xd46ba6d942050d489dbd938a2c909a5d5039a161":"0xedb171c18ce90b633db442f2a6f72874093b49ef","0x1e6bb68acec8fefbd87d192be09bb274170a0548":"0xF03387d8d0FF326ab586A58E0ab4121d106147DF"};function Qn(e){let t=e;return zn.hasOwnProperty(e)&&(t=zn[e]),t}var es;function ts(e,t,a){const{tokens:n,contracts:s}=at(a);let i={id:es.vault,address:s.vault};return n.stETH&&s.lidoRelayer&&[e,t].includes(n.stETH)&&(i={id:es.lido,address:s.lidoRelayer}),i}function as(e){let t=p.Vault__factory.abi;e.id===es.lido&&(t=Yn);return t.filter((e=>e.name&&["swap","batchSwap"].includes(e.name)))}function ns(e){return{amount:e,max:t=>e.mul(1e3+t).div(1e3),min:t=>e.mul(1e3-t).div(1e3)}}function ss(t,a){const n=a===e.SwapType.SwapExactIn?t.swapAmount:t.returnAmount,s=a===e.SwapType.SwapExactIn?t.returnAmount:t.swapAmount,i=a===e.SwapType.SwapExactIn?t.swapAmountForSwaps||t.swapAmount:t.returnAmountFromSwaps||t.returnAmount,r=a===e.SwapType.SwapExactIn?t.returnAmountFromSwaps||t.returnAmount:t.swapAmountForSwaps||t.swapAmount,o=Qn(t.tokenIn),d=Qn(t.tokenOut);return{...t,amountIn:n,amountOut:s,amountInForLimits:ns(i),amountOutForLimits:ns(r),tokenInForSwaps:o,tokenOutFromSwaps:d}}!function(e){e[e.vault=1]="vault",e[e.lido=2]="lido"}(es||(es={}));class is{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="swap",this.swapInfo=ss(e,t),this.relayer=ts(this.swapInfo.tokenIn,this.swapInfo.tokenOut,this.chainId)}setFunds(e,t){this.funds={sender:e,recipient:t||e,fromInternalBalance:!1,toInternalBalance:!1}}setDeadline(e){this.deadline=e.toString()}get amount(){return this.kind===e.SwapType.SwapExactOut?this.swapInfo.amountOutForLimits.amount:this.swapInfo.amountInForLimits.amount}setLimits(t){this.limit=this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(t).toString():this.swapInfo.amountInForLimits.max(t).toString()}get singleSwap(){return{poolId:this.swapInfo.swaps[0].poolId,kind:this.kind,assetIn:this.swapInfo.tokenInForSwaps,assetOut:this.swapInfo.tokenOutFromSwaps,amount:this.amount.toString(),userData:"0x"}}attributes(){var e;if(!this.funds||!this.limit||!this.deadline)throw new Error("Uninitialized arguments");let t={request:this.singleSwap,funds:this.funds,limit:this.limit,deadline:this.deadline};const a=this.fragment();return a[0].inputs&&(null===(e=a[0].inputs)||void 0===e?void 0:e.length)>4&&(t={...t,value:"0",outputReference:"0"}),t}data(){return new t.Interface(this.fragment()).encodeFunctionData("swap",Object.values(this.attributes()))}value(t){let s=n.BigNumber.from(0);return this.swapInfo.tokenIn===a.AddressZero&&(s=this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountIn:this.swapInfo.amountInForLimits.max(t)),s}to(){return this.relayer.address}fragment(){return as(this.relayer).filter((e=>e.name===this.functionName))}}class rs{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="batchSwap",this.swapInfo=ss(e,t),this.relayer=ts(this.swapInfo.tokenIn,this.swapInfo.tokenOut,this.chainId)}setFunds(e,t){this.funds={sender:e,recipient:t||e,fromInternalBalance:!1,toInternalBalance:!1}}setDeadline(e){this.deadline=e}minAmountOut(t){return this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(t):this.swapInfo.amountOutForLimits.amount}maxAmountIn(t){return this.kind===e.SwapType.SwapExactOut?this.swapInfo.amountInForLimits.max(t):this.swapInfo.amountInForLimits.amount}setLimits(e){this.limits=this.swapInfo.tokenAddresses.map((t=>{let a=n.BigNumber.from(0);return t===this.swapInfo.tokenInForSwaps&&(a=this.maxAmountIn(e)),t===this.swapInfo.tokenOutFromSwaps&&(a=this.minAmountOut(e).mul(-1)),a})).map((e=>e.toString().split(".")[0]))}attributes(){var e;if(!this.funds||!this.limits||!this.deadline)throw new Error("Uninitialized arguments");let t={kind:this.kind,swaps:this.swapInfo.swaps,assets:this.swapInfo.tokenAddresses,funds:this.funds,limits:this.limits,deadline:this.deadline};const a=this.fragment();return a[0].inputs&&(null===(e=a[0].inputs)||void 0===e?void 0:e.length)>6&&(t={...t,value:"0",outputReferences:[]}),t}data(){return new t.Interface(this.fragment()).encodeFunctionData("batchSwap",Object.values(this.attributes()))}value(e){let t=n.BigNumber.from(0);return this.swapInfo.tokenIn===a.AddressZero&&(t=this.maxAmountIn(e)),t}to(){return this.relayer.address}fragment(){return as(this.relayer).filter((e=>e.name===this.functionName))}}class os{constructor(e){e instanceof l.SOR?(this.sor=e,this.chainId=this.sor.provider._network.chainId):(this.sor=new jn(e),this.chainId=e.network),this.vaultContract=p.Vault__factory.connect(et,this.sor.provider)}static getLimitsForSlippage(e,t,a,n,s,i){return Xe(e,t,a,n,s,i).map((e=>e.toString()))}async findRouteGivenIn({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s=4}){return this.sor.getSwaps(e,t,l.SwapTypes.SwapExactIn,a,{gasPrice:n,maxPools:s})}async findRouteGivenOut({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s}){return this.sor.getSwaps(e,t,l.SwapTypes.SwapExactOut,a,{gasPrice:n,maxPools:s})}buildSwap({userAddress:e,recipient:t,swapInfo:a,kind:n,deadline:s,maxSlippage:i}){if(!this.chainId)throw"Missing network configuration";const r=a.swaps.length>1?new rs(a,n,this.chainId):new is(a,n,this.chainId);r.setFunds(e,t),r.setDeadline(s),r.setLimits(i);const o=r.to(),{functionName:d}=r;return{to:o,functionName:d,attributes:r.attributes(),data:r.data(),value:r.value(i)}}static encodeBatchSwap(e){return p.Vault__factory.createInterface().encodeFunctionData("batchSwap",[e.kind,e.swaps,e.assets,e.funds,e.limits,e.deadline])}static encodeSimpleFlashSwap(t){return this.encodeBatchSwap(function({poolIds:t,assets:a,flashLoanAmount:n,walletAddress:s}){Kn({poolIds:t,assets:a});const i=Zn(t,n),r={sender:s,fromInternalBalance:!1,recipient:s,toInternalBalance:!1};return{kind:e.SwapType.SwapExactIn,swaps:i,assets:a,funds:r,limits:["0","0"],deadline:"999999999999999999"}}(t))}async fetchPools(){return this.sor.fetchPools()}getPools(){return this.sor.getPools()}async queryBatchSwap(e){return await Vt(this.vaultContract,e.kind,e.swaps,e.assets)}async queryBatchSwapWithSor(e){return await Ht(this.sor,this.vaultContract,e)}async querySimpleFlashSwap(t){return await async function(t){Kn(t);const[a,n]=t.assets;try{const s=await Vt(t.vaultContract,e.SwapType.SwapExactIn,Zn(t.poolIds,t.flashLoanAmount),t.assets),i={[a]:Xn(s[0]).toString(),[n]:Xn(s[1]).toString()};return{profits:i,isProfitable:Jn([i[a],i[n]])>0}}catch(e){throw`Failed to querySimpleFlashSwap: ${e}`}}({...t,vaultContract:this.vaultContract})}async getSorSwap(e){return await jt(e.tokenIn,e.tokenOut,e.swapType,e.amount,this.sor)}}const ds=new t.Interface(Yn);class cs{constructor(e){this.swaps=e instanceof os?e:new os(e)}static isChainedReference(e){const t=n.BigNumber.from(e),a=n.BigNumber.from("0xfff0000000000000000000000000000000000000000000000000000000000000"),s=t.toBigInt()&a.toBigInt();return"0xba10000000000000000000000000000000000000000000000000000000000000"===n.BigNumber.from(s)._hex.toString()}static encodeApproveVault(e,t){return ds.encodeFunctionData("approveVault",[e,t])}static encodeSetRelayerApproval(e,t,a){return ds.encodeFunctionData("setRelayerApproval",[e,t,a])}static encodeGaugeWithdraw(e,t,a,n){return ds.encodeFunctionData("gaugeWithdraw",[e,t,a,n])}static encodeGaugeDeposit(e,t,a,n){return ds.encodeFunctionData("gaugeDeposit",[e,t,a,n])}static encodeBatchSwap(e){return ds.encodeFunctionData("batchSwap",[e.swapType,e.swaps,e.assets,e.funds,e.limits,e.deadline,e.value,e.outputReferences])}static encodeExitPool(e){return ds.encodeFunctionData("exitPool",[e.poolId,e.poolKind,e.sender,e.recipient,e.exitPoolRequest,e.outputReferences])}static encodeJoinPool(e){return ds.encodeFunctionData("joinPool",[e.poolId,e.kind,e.sender,e.recipient,e.joinPoolRequest,e.value,e.outputReference])}static encodeWrapAaveDynamicToken(e){return ds.encodeFunctionData("wrapAaveDynamicToken",[e.staticToken,e.sender,e.recipient,e.amount,e.fromUnderlying,e.outputReference])}static encodeUnwrapAaveStaticToken(e){return ds.encodeFunctionData("unwrapAaveStaticToken",[e.staticToken,e.sender,e.recipient,e.amount,e.toUnderlying,e.outputReferences])}static encodePeekChainedReferenceValue(e){return ds.encodeFunctionData("peekChainedReferenceValue",[e])}static toChainedReference(e,t=!0){const a=t?cs.CHAINED_REFERENCE_TEMP_PREFIX:cs.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${a}${"0".repeat(64-a.length)}`;return n.BigNumber.from(s).add(e)}static fromChainedReference(e,t=!0){const a=t?cs.CHAINED_REFERENCE_TEMP_PREFIX:cs.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${a}${"0".repeat(64-a.length)}`;return n.BigNumber.from(e).sub(n.BigNumber.from(s))}static constructExitCall(e){const{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s,poolId:i,poolKind:r,sender:o,recipient:d,outputReferences:c}=e,l={poolId:i,poolKind:r,sender:o,recipient:d,outputReferences:c,exitPoolRequest:{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s}};return cs.encodeExitPool(l)}static constructJoinCall(e){const{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s,poolId:i,kind:r,sender:o,recipient:d,value:c,outputReference:l}=e,p={poolId:i,kind:r,sender:o,recipient:d,value:c,outputReference:l,joinPoolRequest:{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s}};return cs.encodeJoinPool(p)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async exitPoolAndBatchSwap(t){const s=a.WeiPerEther.sub(n.BigNumber.from(t.slippage)),i=t.expectedAmountsOut.map((e=>n.BigNumber.from(e).mul(s).div(a.WeiPerEther).toString())),r=[];t.exitTokens.forEach(((e,t)=>{const a=cs.toChainedReference(t);r.push({index:t,key:a})}));const o=cs.constructExitCall({assets:t.exitTokens,minAmountsOut:i,userData:t.userData,toInternalBalance:!0,poolId:t.poolId,poolKind:0,sender:t.exiter,recipient:t.exiter,outputReferences:r,exitPoolRequest:{}}),d=await this.swaps.queryBatchSwapWithSor({tokensIn:t.exitTokens,tokensOut:t.finalTokensOut,swapType:e.SwapType.SwapExactIn,amounts:i,fetchPools:t.fetchPools});if(d.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);d.swaps.forEach((e=>{const a=d.assets[e.assetInIndex],n=t.exitTokens.indexOf(a);-1!==n&&(e.amount=r[n].key.toString())}));const c=a.WeiPerEther.add(t.slippage);t.exitTokens.forEach(((e,s)=>{const i=d.assets.map((e=>e.toLowerCase())).indexOf(e.toLowerCase());-1!==i&&(d.deltas[i]=n.BigNumber.from(t.expectedAmountsOut[s]).mul(c).div(a.WeiPerEther).toString())}));const l=os.getLimitsForSlippage(t.exitTokens,t.finalTokensOut,e.SwapType.SwapExactIn,d.deltas,d.assets,"0"),p={sender:t.exiter,recipient:t.swapRecipient,fromInternalBalance:!0,toInternalBalance:!1};return{function:"multicall",params:[o,cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:d.swaps,assets:d.assets,funds:p,limits:l.map((e=>e.toString())),deadline:a.MaxUint256,value:"0",outputReferences:[]})],outputs:{amountsOut:d.returnAmounts}}}async swapUnwrapAaveStaticExactIn(t,s,i,r,o,d,c={fetchPools:!0,fetchOnChain:!1}){const l=await this.swaps.queryBatchSwapWithSor({tokensIn:t,tokensOut:s,swapType:e.SwapType.SwapExactIn,amounts:i,fetchPools:c});if(l.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const p=os.getLimitsForSlippage(t,s,e.SwapType.SwapExactIn,l.deltas,l.assets,d);return{function:"multicall",params:this.encodeSwapUnwrap(s,e.SwapType.SwapExactIn,l.swaps,l.assets,o,p),outputs:{amountsOut:l.returnAmounts.map(((t,s)=>{const i=n.BigNumber.from(t).abs().mul(r[s]).div(a.WeiPerEther);if(!i.gt(a.Zero))throw new st(e.BalancerErrorCode.UNWRAP_ZERO_AMOUNT);return i.toString()}))}}}async swapUnwrapAaveStaticExactOut(t,s,i,r,o,d,c={fetchPools:!0,fetchOnChain:!1}){const l=i.map(((t,s)=>{const i=n.BigNumber.from(t).mul(a.WeiPerEther).div(r[s]);if(!i.gt(a.Zero))throw new st(e.BalancerErrorCode.WRAP_ZERO_AMOUNT);return i.toString()})),p=await this.swaps.queryBatchSwapWithSor({tokensIn:t,tokensOut:s,swapType:e.SwapType.SwapExactOut,amounts:l,fetchPools:c});if(p.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const u=os.getLimitsForSlippage(t,s,e.SwapType.SwapExactOut,p.deltas,p.assets,d);return{function:"multicall",params:this.encodeSwapUnwrap(s,e.SwapType.SwapExactOut,p.swaps,p.assets,o,u),outputs:{amountsIn:p.returnAmounts.map((e=>e.toString()))}}}encodeSwapUnwrap(e,t,n,s,i,r){const o=[],d=[];e.forEach(((e,t)=>{const a=s.findIndex((t=>t.toLowerCase()===e.toLowerCase()));if(-1===a)return;const n=cs.toChainedReference(t);o.push({index:a,key:n});const r=cs.encodeUnwrapAaveStaticToken({staticToken:e,sender:i.recipient,recipient:i.sender,amount:n,toUnderlying:!0,outputReferences:0});d.push(r)}));return[cs.encodeBatchSwap({swapType:t,swaps:n,assets:s,funds:i,limits:r.map((e=>e.toString())),deadline:a.MaxUint256,value:"0",outputReferences:o}),...d]}}cs.CHAINED_REFERENCE_TEMP_PREFIX="ba10",cs.CHAINED_REFERENCE_READONLY_PREFIX="ba11",cs.signRelayerApproval=async(e,t,n,s)=>{const i=s.interface.encodeFunctionData("setRelayerApproval",[t,e,!0]),r=await K.signSetRelayerApprovalAuthorization(s,n,e,i);return K.encodeCalldataAuthorization("0x",a.MaxUint256,r)};class ls{constructor(e){this.url=Hn(e).urls.subgraph,this.client=this.initClient()}initClient(){return rn(new y.GraphQLClient(this.url))}}class ps{constructor(e,t){this.swaps=t||new os(e)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async getSpotPrice(t,a,n=[]){0===n.length&&(await this.fetchPools(),n=this.getPools());const s=l.parseToPoolsDict(n,0),i=this.swaps.sor.routeProposer.getCandidatePathsFromDict(t,a,0,s,4);if(0===i.length)throw new st(e.BalancerErrorCode.UNSUPPORTED_PAIR);return l.getSpotPriceAfterSwapForPath(i[0],0,l.ZERO).toString()}}var us=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}];function ys(e){return Math.round(Date.now()/1e3)-e<86400}var bs=[{name:"Deposit",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1},{name:"locktime",type:"uint256",indexed:!0},{name:"type",type:"int128",indexed:!1},{name:"ts",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Withdraw",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1},{name:"ts",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Supply",inputs:[{name:"prevSupply",type:"uint256",indexed:!1},{name:"supply",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{stateMutability:"nonpayable",type:"constructor",inputs:[{name:"token_addr",type:"address"},{name:"_name",type:"string"},{name:"_symbol",type:"string"},{name:"_authorizer_adaptor",type:"address"}],outputs:[]},{stateMutability:"view",type:"function",name:"token",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"decimals",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"admin",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"nonpayable",type:"function",name:"commit_smart_wallet_checker",inputs:[{name:"addr",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"apply_smart_wallet_checker",inputs:[],outputs:[]},{stateMutability:"view",type:"function",name:"get_last_user_slope",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"int128"}]},{stateMutability:"view",type:"function",name:"user_point_history__ts",inputs:[{name:"_addr",type:"address"},{name:"_idx",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"locked__end",inputs:[{name:"_addr",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"nonpayable",type:"function",name:"checkpoint",inputs:[],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"deposit_for",inputs:[{name:"_addr",type:"address"},{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"create_lock",inputs:[{name:"_value",type:"uint256"},{name:"_unlock_time",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"increase_amount",inputs:[{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"increase_unlock_time",inputs:[{name:"_unlock_time",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"withdraw",inputs:[],outputs:[]},{stateMutability:"view",type:"function",name:"balanceOf",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"balanceOf",inputs:[{name:"addr",type:"address"},{name:"_t",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"balanceOfAt",inputs:[{name:"addr",type:"address"},{name:"_block",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupply",inputs:[{name:"t",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupplyAt",inputs:[{name:"_block",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"supply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"locked",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"tuple",components:[{name:"amount",type:"int128"},{name:"end",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"epoch",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"point_history",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"tuple",components:[{name:"bias",type:"int128"},{name:"slope",type:"int128"},{name:"ts",type:"uint256"},{name:"blk",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"user_point_history",inputs:[{name:"arg0",type:"address"},{name:"arg1",type:"uint256"}],outputs:[{name:"",type:"tuple",components:[{name:"bias",type:"int128"},{name:"slope",type:"int128"},{name:"ts",type:"uint256"},{name:"blk",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"user_point_epoch",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"slope_changes",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"int128"}]},{stateMutability:"view",type:"function",name:"future_smart_wallet_checker",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"smart_wallet_checker",inputs:[],outputs:[{name:"",type:"address"}]}];class ms{constructor(e,t){this.addresses=e,this.provider=t}async getLockInfo(e){if(!this.addresses.veBal)throw new Error("veBal address must be defined");const t=new Rn(this.addresses.multicall,this.provider,bs);t.call("locked",this.addresses.veBal,"locked",[e]),t.call("epoch",this.addresses.veBal,"epoch"),t.call("totalSupply",this.addresses.veBal,"totalSupply()");const a=await t.execute();return this.formatLockInfo(a)}formatLockInfo(e){const[t,a]=e.locked,n=t.gt(0),s=1e3*a.toNumber();const i=n&&Date.now()>s;return{lockedEndDate:s,lockedAmount:Pe(t),totalSupply:Pe(e.totalSupply),epoch:Pe(e.epoch,0),hasExistingLock:n,isExpired:i}}}var fs=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IERC20",name:"votingEscrow",type:"address"},{internalType:"contract IVeDelegation",name:"delegation",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newImplementation",type:"address"}],name:"DelegationImplementationUpdated",type:"event"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"adjustedBalanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"adjusted_balance_of",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDelegationImplementation",outputs:[{internalType:"contract IVeDelegation",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVotingEscrow",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"killDelegation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IVeDelegation",name:"delegation",type:"address"}],name:"setDelegation",outputs:[],stateMutability:"nonpayable",type:"function"}];class hs{constructor(e,t){if(!e.veBalProxy)throw new Error("veBalProxy address must be defined");this.instance=new i.Contract(e.veBalProxy,fs,t)}async getAdjustedBalance(e){return Pe(await this.instance.adjustedBalanceOf(e))}}var Ts=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"address",name:"libraryAddress",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"getLibrary",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}],gs=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"address",name:"libraryAddress",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"getLibrary",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}];const Is=(e,t,a)=>{switch(a){case 3:return new i.Contract(e,gs,t);case 4:return new i.Contract(e,Ts,t);default:throw new Error("relayer not supported")}};var ws=[{name:"Deposit",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Withdraw",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"UpdateLiquidityLimit",inputs:[{name:"user",type:"address",indexed:!0},{name:"original_balance",type:"uint256",indexed:!1},{name:"original_supply",type:"uint256",indexed:!1},{name:"working_balance",type:"uint256",indexed:!1},{name:"working_supply",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Transfer",inputs:[{name:"_from",type:"address",indexed:!0},{name:"_to",type:"address",indexed:!0},{name:"_value",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Approval",inputs:[{name:"_owner",type:"address",indexed:!0},{name:"_spender",type:"address",indexed:!0},{name:"_value",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{stateMutability:"nonpayable",type:"constructor",inputs:[{name:"minter",type:"address"},{name:"veBoostProxy",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"deposit",inputs:[{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"deposit",inputs:[{name:"_value",type:"uint256"},{name:"_addr",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"deposit",inputs:[{name:"_value",type:"uint256"},{name:"_addr",type:"address"},{name:"_claim_rewards",type:"bool"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"withdraw",inputs:[{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"withdraw",inputs:[{name:"_value",type:"uint256"},{name:"_claim_rewards",type:"bool"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"claim_rewards",inputs:[],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"claim_rewards",inputs:[{name:"_addr",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"claim_rewards",inputs:[{name:"_addr",type:"address"},{name:"_receiver",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"transferFrom",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{stateMutability:"nonpayable",type:"function",name:"transfer",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{stateMutability:"nonpayable",type:"function",name:"approve",inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{stateMutability:"nonpayable",type:"function",name:"permit",inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"},{name:"_value",type:"uint256"},{name:"_deadline",type:"uint256"},{name:"_v",type:"uint8"},{name:"_r",type:"bytes32"},{name:"_s",type:"bytes32"}],outputs:[{name:"",type:"bool"}]},{stateMutability:"nonpayable",type:"function",name:"increaseAllowance",inputs:[{name:"_spender",type:"address"},{name:"_added_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{stateMutability:"nonpayable",type:"function",name:"decreaseAllowance",inputs:[{name:"_spender",type:"address"},{name:"_subtracted_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{stateMutability:"nonpayable",type:"function",name:"user_checkpoint",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"bool"}]},{stateMutability:"nonpayable",type:"function",name:"set_rewards_receiver",inputs:[{name:"_receiver",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"kick",inputs:[{name:"addr",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"deposit_reward_token",inputs:[{name:"_reward_token",type:"address"},{name:"_amount",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"add_reward",inputs:[{name:"_reward_token",type:"address"},{name:"_distributor",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"set_reward_distributor",inputs:[{name:"_reward_token",type:"address"},{name:"_distributor",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"set_killed",inputs:[{name:"_is_killed",type:"bool"}],outputs:[]},{stateMutability:"view",type:"function",name:"claimed_reward",inputs:[{name:"_addr",type:"address"},{name:"_token",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"claimable_reward",inputs:[{name:"_user",type:"address"},{name:"_reward_token",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"claimable_reward_write",inputs:[{name:"_addr",type:"address"},{name:"_token",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"claimable_tokens",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"integrate_checkpoint",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"future_epoch_time",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"inflation_rate",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"decimals",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"version",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"allowance",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"nonpayable",type:"function",name:"initialize",inputs:[{name:"_lp_token",type:"address"}],outputs:[]},{stateMutability:"view",type:"function",name:"balanceOf",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"DOMAIN_SEPARATOR",inputs:[],outputs:[{name:"",type:"bytes32"}]},{stateMutability:"view",type:"function",name:"nonces",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"factory",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"lp_token",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"is_killed",inputs:[],outputs:[{name:"",type:"bool"}]},{stateMutability:"view",type:"function",name:"reward_count",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"reward_data",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"tuple",components:[{name:"token",type:"address"},{name:"distributor",type:"address"},{name:"period_finish",type:"uint256"},{name:"rate",type:"uint256"},{name:"last_update",type:"uint256"},{name:"integral",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"rewards_receiver",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"reward_integral_for",inputs:[{name:"arg0",type:"address"},{name:"arg1",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"working_balances",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"working_supply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"integrate_inv_supply_of",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"integrate_checkpoint_of",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"integrate_fraction",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"period",inputs:[],outputs:[{name:"",type:"int128"}]},{stateMutability:"view",type:"function",name:"reward_tokens",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"period_timestamp",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"integrate_inv_supply",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];class Es{constructor(e,t){this.contractAddresses="number"==typeof e?tt[e].addresses.contracts:e,this.vault=p.Vault__factory.connect(this.contractAddresses.vault,t),this.balancerHelpers=p.BalancerHelpers__factory.connect(this.contractAddresses.balancerHelpers,t),this.contractAddresses.lidoRelayer&&(this.lidoRelayer=p.LidoRelayer__factory.connect(this.contractAddresses.lidoRelayer,t)),this.multicall=Dn(this.contractAddresses.multicall,t),this.contractAddresses.relayerV3&&(this.relayerV3=Is(this.contractAddresses.relayerV3,t,3)),this.contractAddresses.relayerV4&&(this.relayerV4=Is(this.contractAddresses.relayerV4,t,4)),this.contractAddresses.veBal&&(this.veBal=new ms(this.contractAddresses,t)),this.contractAddresses.veBalProxy&&(this.veBalProxy=new hs(this.contractAddresses,t))}get contracts(){return{vault:this.vault,balancerHelpers:this.balancerHelpers,lidoRelayer:this.lidoRelayer,multicall:this.multicall,relayerV3:this.relayerV3,relayerV4:this.relayerV4,veBal:this.veBal,veBalProxy:this.veBalProxy,ERC20:this.getErc20,liquidityGauge:this.getLiquidityGauge}}getErc20(e,t){return((e,t)=>new i.Contract(e,us,t))(e,t)}getLiquidityGauge(e,t){return((e,t)=>new i.Contract(e,ws,t))(e,t)}}const xs={1:{relayer:"0x886A3Ec7bcC508B8795990B60Fa21f85F9dB7948",staBal3:{id:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063",address:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42",gauge:"0x34f33cdaed8ba0e1ceece80e5f4a73bcf234cfac",assetOrder:["DAI","USDC","USDT"]},bbausd1:{id:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe",address:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2",gauge:"0x68d019f64a7aa97e2d4e7363aee42251d08124fb",assetOrder:["bb-a-USDT","bb-a-DAI","bb-a-USDC"]},bbausd2:{id:"0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d",address:"0xa13a9247ea42d743238089903570127dda72fe44",gauge:"0xa6325e799d266632d347e41265a69af111b05403"},linearUsdc1:{id:"0x9210f1204b5a24742eba12f710636d76240df3d00000000000000000000000fc",address:"0x9210F1204b5a24742Eba12f710636D76240dF3d0"},linearDai1:{id:"0x804cdb9116a10bb78768d3252355a1b18067bf8f0000000000000000000000fb",address:"0x804CdB9116a10bB78768D3252355a1b18067bF8f"},linearUsdt1:{id:"0x2bbf681cc4eb09218bee85ea2a5d3d13fa40fc0c0000000000000000000000fd",address:"0x2BBf681cC4eb09218BEe85EA2a5d3D13Fa40fC0C"},linearUsdc2:{id:"0x82698AECC9E28E9BB27608BD52CF57F704BD1B83000000000000000000000336",address:"0x82698aeCc9E28e9Bb27608Bd52cF57f704BD1B83"},linearDai2:{id:"0xAE37D54AE477268B9997D4161B96B8200755935C000000000000000000000337",address:"0xae37D54Ae477268B9997d4161B96b8200755935c"},linearUsdt2:{id:"0x2F4EB100552EF93840D5ADC30560E5513DFFFACB000000000000000000000334",address:"0x2F4eb100552ef93840d5aDC30560E5513DFfFACb"},maiusd:{id:"",address:"",gauge:"",assetOrder:["USDT","miMATIC","DAI","USDC"]},maibbausd:{id:"",address:"",gauge:"",assetOrder:["bb-a-USD","miMATIC"]},DAI:"0x6b175474e89094c44da98b954eedeac495271d0f",USDC:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",waDAI:"0x02d60b84491589974263d922d9cc7a3152618ef6",waUSDC:"0xd093fa4fb80d09bb30817fdcd442d4d02ed3e5de",waUSDT:"0xf8fd466f12e236f4c96f7cce6c79eadb819abf58",miMATIC:""},5:{relayer:"0x7b9B6f094DC2Bd1c12024b0D9CC63d6993Be1888",staBal3:{id:"0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2000000000000000000000062",address:"0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2",gauge:"0xfd364cda96bb7db06b65706182c448a73f0a5f9a",assetOrder:["USDT","DAI","USDC"]},staBal3_2:{id:"0xff9d677474d4344379924e10b68c8fea67e03294000000000000000000000072",address:"0xff9d677474d4344379924e10b68c8fea67e03294",gauge:"0x4e4ebf2aa90e41174d716a5168895357762d68af",assetOrder:["USDT","DAI","USDC"]},staBal3_3:{id:"0x3bfc8a0509f1a68aefd446f6c19bf37b3c75a8fc0000000000000000000000a5",address:"0x3bfc8a0509f1a68aefd446f6c19bf37b3c75a8fc",gauge:"0x7776e1008d7c20ab54aa57a7c44fc7de602de29a",assetOrder:["USDT","DAI","USDC"]},bbausd1:{id:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f",address:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd",gauge:"0xa2d0ea81a47d68598922cd54c59249ff58c2a3ff",assetOrder:["bb-a-USDC","bb-a-DAI","bb-a-USDT"]},bbausd2:{id:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f",address:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd",gauge:"0xa2d0ea81a47d68598922cd54c59249ff58c2a3ff"},linearUsdc1:{id:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc8668100000000000000000000005c",address:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc86681"},linearDai1:{id:"0x5cea6a84ed13590ed14903925fa1a73c36297d9900000000000000000000005d",address:"0x5cea6a84ed13590ed14903925fa1a73c36297d99"},linearUsdt1:{id:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f00000000000000000000005e",address:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f"},linearUsdc2:{id:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc8668100000000000000000000005c",address:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc86681"},linearDai2:{id:"0x5cea6a84ed13590ed14903925fa1a73c36297d9900000000000000000000005d",address:"0x5cea6a84ed13590ed14903925fa1a73c36297d99"},linearUsdt2:{id:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f00000000000000000000005e",address:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f"},maiusd:{id:"0x6a8f9ab364b85725973d2a33cb9aae2dac43b5e30000000000000000000000a6",address:"0x6a8f9ab364b85725973d2a33cb9aae2dac43b5e3",gauge:"0x58141bdcecb7fbae006964f4131cf6f65c948357",assetOrder:["USDT","miMATIC","DAI","USDC"]},maibbausd:{id:"0xb04b03b78cf79788a1931545bd2744161029648f0000000000000000000000a8",address:"0xb04b03b78cf79788a1931545bd2744161029648f",gauge:"0xdc3f6fc8898830e53c777543fe252b14f22680d4",assetOrder:["bb-a-USD","miMATIC","MAI BSP"]},USDT:"0x1f1f156e0317167c11aa412e3d1435ea29dc3cce",DAI:"0x8c9e6c40d3402480ace624730524facc5482798c",USDC:"0xe0c9275e44ea80ef17579d33c55136b7da269aeb",waDAI:"0x89534a24450081aa267c79b07411e9617d984052",waUSDC:"0x811151066392fd641fe74a9b55a712670572d161",waUSDT:"0x4cb1892fddf14f772b2e39e299f44b2e5da90d04",miMATIC:"0x398106564948feeb1fedea0709ae7d969d62a391"},137:{relayer:"0xcf6a66E32dCa0e26AcC3426b851FD8aCbF12Dac7",staBal3:{id:"",address:"",gauge:"",assetOrder:["USDT","DAI","USDC"]},bbausd1:{id:"",address:"",gauge:"",assetOrder:["bb-a-USDC","bb-a-DAI","bb-a-USDT"]},bbausd2:{id:"0x48e6b98ef6329f8f0a30ebb8c7c960330d64808500000000000000000000075b",address:"0x48e6b98ef6329f8f0a30ebb8c7c960330d648085",gauge:""},linearUsdc1:{id:"",address:""},linearDai1:{id:"",address:""},linearUsdt1:{id:"",address:""},linearUsdc2:{id:"0xf93579002dbe8046c43fefe86ec78b1112247bb8000000000000000000000759",address:"0xf93579002dbe8046c43fefe86ec78b1112247bb8"},linearDai2:{id:"0x178e029173417b1f9c8bc16dcec6f697bc323746000000000000000000000758",address:"0x178e029173417b1f9c8bc16dcec6f697bc323746"},linearUsdt2:{id:"0xff4ce5aaab5a627bf82f4a571ab1ce94aa365ea600000000000000000000075a",address:"0xff4ce5aaab5a627bf82f4a571ab1ce94aa365ea6"},maiusd:{id:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012",address:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42",gauge:"0x72843281394e68de5d55bcf7072bb9b2ebc24150",assetOrder:["USDC","DAI","miMATIC","USDT"]},maibbausd:{id:"0xb54b2125b711cd183edd3dd09433439d5396165200000000000000000000075e",address:"0xb54b2125b711cd183edd3dd09433439d53961652",gauge:"0x9a105ef22a59484aa2731c357049f6a13d0891f5",assetOrder:["bb-a-USD","miMATIC"]},USDT:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",DAI:"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",USDC:"0x2791bca1f2de4661ed88a30c99a7a9449aa84174",waDAI:"0xEE029120c72b0607344f35B17cdD90025e647B00",waUSDC:"0x221836a597948Dce8F3568E044fF123108aCc42A",waUSDT:"0x19C60a251e525fa88Cd6f3768416a8024e98fC19",miMATIC:"0xa3fa99a148fa48d14ed51d610c367c61876997f1"}},As=new t.Interface(gs),Ss=cs.toChainedReference("21"),Ps=cs.toChainedReference("22"),_s=cs.toChainedReference("23"),Bs=cs.toChainedReference("24");class Os{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];r&&(d=[this.buildSetRelayerApproval(r)]),d=i?[...d,this.buildWithdraw(t,a),this.buildExit(o,a),this.buildSwap(s,o),this.buildDeposit(t)]:[...d,this.buildExit(t,a),this.buildSwap(s,t)];return{to:o,data:As.encodeFunctionData("multicall",[d])}}buildExit(e,t){const{assetOrder:a}=this.addresses.staBal3,n=a.map((e=>this.addresses[e])),s=S.exitExactBPTInForTokensOut(t),i=[{index:a.indexOf("DAI"),key:Ss},{index:a.indexOf("USDC"),key:Ps},{index:a.indexOf("USDT"),key:_s}];return cs.constructExitCall({assets:n,minAmountsOut:["0","0","0"],userData:s,toInternalBalance:!0,poolId:this.addresses.staBal3.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s){const i=[this.addresses.bbausd2.address,this.addresses.DAI,this.addresses.linearDai2.address,this.addresses.USDC,this.addresses.linearUsdc2.address,this.addresses.USDT,this.addresses.linearUsdt2.address],r=[{index:0,key:Bs}],o=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Ss.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:2,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:3,assetOutIndex:4,amount:Ps.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:4,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:5,assetOutIndex:6,amount:_s.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"}],d=[n.BigNumber.from(t).mul(-1).toString(),a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0"],c={sender:this.addresses.relayer,recipient:s,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:o,assets:i,funds:c,limits:d,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.staBal3.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,Bs.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const vs=new t.Interface(gs),ks=cs.toChainedReference("24");class Ns{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r,o){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const d=this.addresses.relayer;let c=[];o&&(c=[this.buildSetRelayerApproval(o)]),c=i?[...c,this.buildWithdraw(t,a),this.buildSwap(a,s,d,d,r),this.buildDeposit(t)]:[...c,this.buildSwap(a,s,t,t,r)];const l=vs.encodeFunctionData("multicall",[c]);return{to:this.addresses.relayer,data:l}}buildSwap(t,s,i,r,o){const d=[this.addresses.bbausd2.address,this.addresses.waDAI,this.addresses.linearDai1.address,this.addresses.linearDai2.address,this.addresses.waUSDC,this.addresses.linearUsdc1.address,this.addresses.linearUsdc2.address,this.addresses.waUSDT,this.addresses.linearUsdt1.address,this.addresses.linearUsdt2.address,this.addresses.bbausd1.address],c=[{index:0,key:ks}],l=o.reduce(((e,t)=>e.add(n.BigNumber.from(t))),a.Zero),{assetOrder:p}=this.addresses.bbausd1,u=n.BigNumber.from(t).mul(o[p.indexOf("bb-a-USDC")]).div(l).toString(),y=n.BigNumber.from(t).mul(o[p.indexOf("bb-a-DAI")]).div(l).toString(),b=n.BigNumber.from(t).sub(u).sub(y).toString(),m=[{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:2,amount:y,userData:"0x"},{poolId:this.addresses.linearDai1.id,assetInIndex:2,assetOutIndex:1,amount:"0",userData:"0x"},{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:3,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:3,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:5,amount:u,userData:"0x"},{poolId:this.addresses.linearUsdc1.id,assetInIndex:5,assetOutIndex:4,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:4,assetOutIndex:6,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:8,amount:b,userData:"0x"},{poolId:this.addresses.linearUsdt1.id,assetInIndex:8,assetOutIndex:7,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:7,assetOutIndex:9,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:9,assetOutIndex:0,amount:"0",userData:"0x"}],f=[n.BigNumber.from(s).mul(-1).toString(),"0","0","0","0","0","0","0","0","0",t],h={sender:i,recipient:r,fromInternalBalance:!1,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:m,assets:d,funds:h,limits:f,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:c})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.bbausd1.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,ks.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Cs=new t.Interface(gs),Ds=cs.toChainedReference("0"),Rs=[];class Fs{constructor(e){this.addresses=xs[e]}calldata(e,t,a,n,s,i,r,o){if(i&&(null==t.gauge||null==a.gauge))throw new Error("Staked flow migration requires gauge addresses to be provided");const d=this.addresses.relayer;let c=[];o&&(c=[this.buildSetRelayerApproval(o)]),c=i?[...c,this.buildWithdraw(e,n,t.gauge),this.buildExit(t.id,d,n,r),this.buildSwap(s,d,a.id,a.address,r),this.buildDeposit(e,a.gauge)]:[...c,this.buildExit(t.id,e,n,r),this.buildSwap(s,e,a.id,a.address,r)];const l=Cs.encodeFunctionData("multicall",[c]);return{to:this.addresses.relayer,data:l}}buildExit(e,t,a,n){const s=S.exitExactBPTInForTokensOut(a),i=[];for(let e=0;e<n.length;e++)i[e]={index:e,key:cs.toChainedReference(`${e+1}`)},Rs.push(i[e].key);const r=Array(n.length).fill("0");return cs.constructExitCall({assets:n,minAmountsOut:r,userData:s,toInternalBalance:!0,poolId:e,poolKind:0,sender:t,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s,i,r,o){const d=[r,...o],c=[{index:0,key:Ds}],l=[];for(let e=0;e<o.length;e++)l.push({poolId:i,assetInIndex:e+1,assetOutIndex:0,amount:Rs[e].toString(),userData:"0x"});const p=[n.BigNumber.from(t).mul(-1).toString()];for(let e=0;e<o.length;e++)p.push(a.MaxInt256.toString());const u={sender:this.addresses.relayer,recipient:s,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:l,assets:d,funds:u,limits:p,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:c})}buildWithdraw(e,t,a){return cs.encodeGaugeWithdraw(a,e,this.addresses.relayer,t)}buildDeposit(e,t){return cs.encodeGaugeDeposit(t,this.addresses.relayer,e,Ds.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Ms=new t.Interface(gs),Ls=cs.toChainedReference("20"),Us=cs.toChainedReference("21"),Gs=cs.toChainedReference("22"),qs=cs.toChainedReference("23"),Ws=cs.toChainedReference("24");class $s{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];r&&(d=[this.buildSetRelayerApproval(r)]),d=i?[...d,this.buildWithdraw(t,a),this.buildExit(o,a),this.buildSwap(o,s),this.buildDeposit(t)]:[...d,this.buildExit(t,a),this.buildSwap(t,s)];return{to:o,data:Ms.encodeFunctionData("multicall",[d])}}buildExit(e,t){const{assetOrder:a}=this.addresses.maiusd,n=a.map((e=>this.addresses[e])),s=S.exitExactBPTInForTokensOut(t),i=[{index:a.indexOf("miMATIC"),key:Ls},{index:a.indexOf("DAI"),key:Us},{index:a.indexOf("USDC"),key:Gs},{index:a.indexOf("USDT"),key:qs}],r=Array(n.length).fill("0");return cs.constructExitCall({assets:n,minAmountsOut:r,userData:s,toInternalBalance:!0,poolId:this.addresses.maiusd.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s){const i=[this.addresses.bbausd2.address,this.addresses.DAI,this.addresses.linearDai2.address,this.addresses.USDC,this.addresses.linearUsdc2.address,this.addresses.USDT,this.addresses.linearUsdt2.address,this.addresses.miMATIC,this.addresses.maibbausd.address],r=[{index:8,key:Ws}],o=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Us.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:2,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:3,assetOutIndex:4,amount:Gs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:4,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:5,assetOutIndex:6,amount:qs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:7,assetOutIndex:8,amount:Ls.toString(),userData:"0x"}],d=["0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),n.BigNumber.from(s).mul(-1).toString()],c={sender:this.addresses.relayer,recipient:t,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:o,assets:i,funds:c,limits:d,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.maiusd.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.maibbausd.gauge,this.addresses.relayer,e,Ws.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}class Vs{constructor(e){this.network=e}stabal3(e,a,n,s,i){const r=new Os(this.network).calldata(e,a,n,s,i);return{to:r.to,data:r.data,decode:(e,a)=>{let n=a?2:1;i&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}bbaUsd(e,a,n,s,i,r){const o=new Ns(this.network).calldata(e,a,n,s,i,r);return{to:o.to,data:o.data,decode:(e,a)=>{let n=a?1:0;r&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}stables(e,a,n,s,i,r,o,d){const c=new Fs(this.network).calldata(e,a,n,s,i,r,o,d);return{to:c.to,data:c.data,decode:(e,a)=>{let n=a?2:1;d&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}maiusd(e,a,n,s,i){const r=new $s(this.network).calldata(e,a,n,s,i);return{to:r.to,data:r.data,decode:(e,a)=>{let n=a?2:1;i&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][8].abs().toString()}}}}class Hs{constructor(e){this.network=e,this.migrations=new Vs(e)}}class js{constructor(e,t){this.tokenPrices=e,this.tokenHistoricalPrices=t}async calcImpLoss(t,a){if(1e3*t>=Date.now())throw console.error(`[ImpermanentLossService][calcImpLoss]Error: ${st.getMessage(e.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE)}`),new st(e.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE);const n=await this.prepareData(t,a),s=this.getPoolValueDelta(n),i=this.getHoldValueDelta(n);return this.calculateImpermanentLoss(s,i)}calculateImpermanentLoss(e,t){return Math.floor(100*Math.abs(e/t-1)*100)/100}getPoolValueDelta(e){return e.reduce(((e,t)=>e*Math.pow(Math.abs(t.priceDelta+1),t.weight)),1)}getHoldValueDelta(e){return e.reduce(((e,t)=>e+Math.abs(t.priceDelta+1)*t.weight),0)}async prepareData(e,t){const a=t.tokens.filter((e=>e.address!==t.address)),n=this.getWeights(a),s=a.map((e=>e.address)),i=await this.getEntryPrices(e,s),r=await this.getExitPrices(a);return this.getAssets(a,r,i,n)}getAssets(e,t,a,n){return e.map(((e,s)=>({priceDelta:this.getDelta(a[e.address],t[e.address]),weight:n[s]})))}getDelta(t,a){if(0===t)throw console.error(`[ImpermanentLossService][getDelta]Error: ${st.getMessage(e.BalancerErrorCode.ILLEGAL_PARAMETER)}: entry price is 0`),new st(e.BalancerErrorCode.ILLEGAL_PARAMETER);return(a-t)/t}getWeights(t){const a=t.every((e=>!e.weight)),n=Math.round(1/t.length*100)/100,s=a?t.map((()=>n)):t.map((e=>{var t;return Number(null!==(t=e.weight)&&void 0!==t?t:0)}));if(s.some((e=>0===e)))throw console.error(`[ImpermanentLossService][getWeights]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_WEIGHT)}`),new st(e.BalancerErrorCode.MISSING_WEIGHT);return s}async getExitPrices(t){var a;const n=await Promise.all(t.map((e=>this.tokenPrices.find(e.address)))).catch((()=>[]));if(!n.length||n.some((e=>void 0===(null==e?void 0:e.usd))))throw console.error(`[ImpermanentLossService][getExitPrices]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_PRICE_RATE)}`),new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const s=t.map(((e,t)=>({...e,price:n[t]}))),i={};for(const e of s)(null===(a=e.price)||void 0===a?void 0:a.usd)&&(i[e.address]=+e.price.usd);return i}async getEntryPrices(t,a){const n={};for(const s of a){const a=await this.tokenHistoricalPrices.findBy(s,t).catch((e=>{console.error(`[ImpermanentLossService][getEntryPrices]Error: ${e.message}`)}));if(!(null==a?void 0:a.usd))throw console.error(`[ImpermanentLossService][getEntryPrices]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_PRICE_RATE)}`),new st(e.BalancerErrorCode.MISSING_PRICE_RATE);n[s]=+a.usd}return n}}const Ks=335e3,Zs=1759363200,Xs=(e=Math.round((new Date).getTime()/1e3))=>Ks;var Js=Object.freeze({__proto__:null,INITIAL_RATE:Ks,START_EPOCH_TIME:Zs,weekly:Xs,total:e=>365*(Xs()/7),between:(e,t)=>{if(e<Zs)throw"start timestamp before emission schedule deployment";if(t<e)throw"cannot finish before starting";const a=t-e,n=Xs()/7;return Math.round(a/86400)*n}});class Ys{constructor(e,t){this.repository=e,this.tokenPrices=t}async data(e=Date.now()){const t=await this.repository.multicallData(e),a=await this.tokenPrices.find(t.balAddress);if(!a||!a.usd)throw"No BAL USD price found";return{lastWeekBalRevenue:t.balAmount*parseFloat(a.usd),lastWeekBBAUsdRevenue:t.bbAUsdAmount*t.bbAUsdPrice,veBalSupply:t.veBalSupply}}}class zs{constructor(e){this.yesterdaysPools=e}async last24h(e){let t;return this.yesterdaysPools&&(t=await this.yesterdaysPools.find(e.id)),e.totalSwapFee?(null==t?void 0:t.totalSwapFee)?parseFloat(e.totalSwapFee)-parseFloat(t.totalSwapFee):e.createTime&&ys(e.createTime)?parseFloat(e.totalSwapFee):0:0}}class Qs{constructor(e,t,a,n,s,i,r,o){this.pools=e,this.tokenPrices=t,this.tokenMeta=a,this.tokenYields=n,this.feeCollector=s,this.yesterdaysPools=i,this.liquidityGauges=r,this.feeDistributor=o}async swapFees(e){const t=await this.last24hFees(e),a=await this.totalLiquidity(e);if(!t||!a)return 0;const n=t*(1-await this.protocolSwapFeePercentage(e))/parseFloat(a)*1e4;return Math.round(365*n)}async tokenAprs(e){return{total:0,breakdown:{}}}async stakingApr(e,t=1){if(!this.liquidityGauges)return 0;const a=await this.liquidityGauges.findBy("poolId",e.id);if(!a||(248==e.chainId||9372==e.chainId)&&0==a.workingSupply||248!=e.chainId&&9372!=e.chainId&&e.chainId>1&&0==a.totalSupply)return 0;const n=tt[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,i]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const r=parseFloat(s.usd),o=Xs()/7*365*a.relativeWeight*r,d=(a.workingSupply+.4)/.4*i;return Math.round(1e4*t*o/d)}async stakingAprNextPeriod(e,t=1){if(!this.liquidityGauges)return 0;const a=await this.liquidityGauges.findBy("poolId",e.id);if(!a)return 0;if(0==a.workingSupply)return a.relativeWeightNextPeriod&&a.relativeWeightNextPeriod>0?-1:0;const n=tt[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,i]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const r=parseFloat(s.usd),o=Xs()/7*365*(a.relativeWeightNextPeriod||0)*r,d=(a.workingSupply+.4)/.4*i;return Math.round(1e4*t*o/d)}async rewardAprs(e){if(!this.liquidityGauges)return{total:0,breakdown:{}};const t=await this.liquidityGauges.findBy("poolId",e.id);if(!t)return{total:0,breakdown:{}};if(!t.rewardTokens)return{total:0,breakdown:{}};if(Object.keys(t.rewardTokens).length<1)return{total:0,breakdown:{}};const a=tt[e.chainId].addresses.tokens.bal,n=Object.keys(t.rewardTokens).filter((e=>e!=a)).map((async e=>{const a=t.rewardTokens[e];return this.rewardTokenApr(e,a)})),s=await this.bptPrice(e),i=t.totalSupply*s,r={};let o=0;for await(const e of Object.values(n)){const t=i>0?e.value/i:0,a=Math.round(1e4*t);o+=a,r[e.address]=a}return{total:o,breakdown:r}}async protocolApr(e){if(""!=e.id||!this.feeDistributor)return 0;const t=new Ys(this.feeDistributor,this.tokenPrices),{lastWeekBalRevenue:a,lastWeekBBAUsdRevenue:n,veBalSupply:s}=await t.data(),i=await this.bptPrice(e);if(!i)throw"bptPrice for veBal pool missing";const r=(a+n)/7;return Math.round(365*r*1e4/(i*s))}async apr(e){const[t,a,n,s,i,r]=await Promise.all([this.swapFees(e),this.tokenAprs(e),this.stakingApr(e),this.stakingApr(e,2.5),this.rewardAprs(e),this.protocolApr(e)]);return{swapFees:t,tokenAprs:a,stakingApr:{min:n,max:s},rewardAprs:i,protocolApr:r,min:t+a.total+i.total+n,max:t+a.total+i.total+r+s}}async aprNextPeriod(e){const[t,a,n,s,i,r]=await Promise.all([this.swapFees(e),this.tokenAprs(e),this.stakingAprNextPeriod(e),this.stakingAprNextPeriod(e,2.5),this.rewardAprs(e),this.protocolApr(e)]);return{swapFees:t,tokenAprs:a,stakingApr:{min:n,max:s},rewardAprs:i,protocolApr:r,min:t+a.total+i.total+n,max:t+a.total+i.total+r+s}}async last24hFees(e){return new zs(this.yesterdaysPools).last24h(e)}async totalLiquidity(e){try{const t=new $t(this.pools,this.tokenPrices);return await t.getLiquidity(e)}catch(t){return console.error("Liquidity calculcation failed, falling back to subgraph"),e.totalLiquidity}}async bptPrice(e){const t=await this.totalLiquidity(e),a=e.totalShares;return parseFloat(t)/parseFloat(a)}async protocolSwapFeePercentage(e){let t=0;return t="ComposableStable"==e.poolType||"Weighted"==e.poolType&&2==e.poolTypeVersion?0:e.protocolSwapFeeCache?parseFloat(e.protocolSwapFeeCache):await this.feeCollector.find("")||0,t}async rewardTokenApr(e,t){if(t.period_finish.toNumber()<Date.now()/1e3)return{address:e,value:0};{const a=t.rate.mul(86400).mul(365),n=await this.tokenPrices.find(e);if(n&&n.usd){let s=18;if(t.decimals)s=t.decimals;else{const t=await this.tokenMeta.find(e);t&&void 0!==t.decimals&&(s=t.decimals)}return{address:e,value:parseFloat(Pe(a,s))*parseFloat(n.usd)}}throw`No USD price for ${e}`}}}const ei=new Map;ei.set(e.PoolType.AaveLinear,"batchSwap"),ei.set(e.PoolType.EulerLinear,"batchSwap"),ei.set(e.PoolType.ERC4626Linear,"batchSwap"),ei.set(e.PoolType.Element,"batchSwap"),ei.set(e.PoolType.Investment,"joinPool"),ei.set(e.PoolType.LiquidityBootstrapping,"joinPool"),ei.set(e.PoolType.MetaStable,"joinPool"),ei.set(e.PoolType.Stable,"joinPool"),ei.set(e.PoolType.StablePhantom,"batchSwap"),ei.set(e.PoolType.Weighted,"joinPool"),ei.set(e.PoolType.ComposableStable,"joinPool");const ti=new Map;ti.set(e.PoolType.AaveLinear,"batchSwap"),ei.set(e.PoolType.EulerLinear,"batchSwap"),ti.set(e.PoolType.ERC4626Linear,"batchSwap"),ti.set(e.PoolType.Element,"batchSwap"),ti.set(e.PoolType.Investment,"exitPool"),ti.set(e.PoolType.LiquidityBootstrapping,"exitPool"),ti.set(e.PoolType.MetaStable,"exitPool"),ti.set(e.PoolType.Stable,"exitPool"),ti.set(e.PoolType.StablePhantom,"batchSwap"),ti.set(e.PoolType.Weighted,"exitPool"),ti.set(e.PoolType.ComposableStable,"exitPool");class ai{constructor(e){this.pools=e}async buildGraphFromRootPool(t,n){const s=await this.pools.find(t);if(!s)throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST);return(await this.buildGraphFromPool(s.address,0,void 0,a.WeiPerEther,n))[0]}getTokenTotal(e){const t=e.tokensList.indexOf(e.address);let n=a.Zero;const{parsedBalances:s}=se(e);return s.forEach(((e,a)=>{t!==a&&(n=n.add(e))})),n}async buildGraphFromPool(t,a,s,i,r){var o;const d=await this.pools.findBy("address",t);if(!d){if(s){const e=await this.pools.findBy("address",s.address),n=null!==(o=e.tokens[e.tokensList.indexOf(t)].decimals)&&void 0!==o?o:18;return ai.createInputTokenNode(a,t,n,s,i)}throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST)}const c=ei.get(d.poolType),l=ti.get(d.poolType);if(!c||!l)throw new st(e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);const p=this.getTokenTotal(d),{spotPriceCalculator:u}=Wt.from(d.poolType),y={};let b=18;d.tokens.forEach((e=>{if($e(e.address,d.address))return void(b=e.decimals?e.decimals:18);const t=u.calcPoolSpotPrice(e.address,d.address,d);y[e.address]=t}));let m={address:d.address,id:d.id,type:d.poolType,joinAction:c,exitAction:l,children:[],marked:!1,index:a.toString(),parent:s,proportionOfParent:i,isLeaf:!1,spotPrices:y,decimals:b};if(a++,d.poolType.toString().includes("Linear"))[m,a]=this.createLinearNodeChildren(m,a,d,r);else{const{parsedBalances:e}=se(d);for(let t=0;t<d.tokens.length;t++){if($e(d.tokens[t].address,d.address))continue;let s;if("Weighted"===d.poolType){const e=d.tokens[t].weight;s=n.parseFixed(e,18)}else s=n.BigNumber.from(e[t]).mul(1e18.toString()).div(p);const o=s.mul(i).div(1e18.toString()),c=await this.buildGraphFromPool(d.tokens[t].address,a,m,o,r);a=c[1],c[0]&&m.children.push(c[0])}}return[m,a]}createLinearNodeChildren(e,t,a,n){var s;if(n){const n=this.createWrappedTokenNode(a,t,e,e.proportionOfParent);return e.children.push(n[0]),[e,n[1]]}{if(void 0===a.mainIndex)throw new Error("Issue With Linear Pool");const n=null!==(s=a.tokens[a.mainIndex].decimals)&&void 0!==s?s:18,i=ai.createInputTokenNode(t,a.tokensList[a.mainIndex],n,e,e.proportionOfParent);return e.children.push(i[0]),[e,t=i[1]]}}createWrappedTokenNode(t,a,n,s){var i;if(void 0===t.wrappedIndex||void 0===t.mainIndex)throw new Error("Issue With Linear Pool");let r="wrapAaveDynamicToken";if(t.poolType===e.PoolType.ERC4626Linear)r="wrapERC4626";let o="unwrapAaveStaticToken";if(t.poolType===e.PoolType.ERC4626Linear)o="unwrapERC4626";const d={type:"WrappedToken",address:t.tokensList[t.wrappedIndex],id:"N/A",children:[],marked:!1,joinAction:r,exitAction:o,index:a.toString(),parent:n,proportionOfParent:s,isLeaf:!1,spotPrices:{},decimals:18};a++;const c=null!==(i=t.tokens[t.mainIndex].decimals)&&void 0!==i?i:18,l=ai.createInputTokenNode(a,t.tokensList[t.mainIndex],c,d,s);return d.children=[l[0]],[d,a=l[1]]}static createInputTokenNode(e,t,a,n,s){return[{address:t,id:"N/A",type:"Input",children:[],marked:!1,joinAction:"input",exitAction:"output",index:e.toString(),parent:n,proportionOfParent:s,isLeaf:!0,spotPrices:{},decimals:a},e+1]}static orderByBfs(e){const t=[],a=[];for(e.marked=!0,t.push(e);t.length>0;){const e=t.shift();e&&a.push(e),null==e||e.children.forEach((e=>{e.marked||(e.marked=!0,t.push(e))}))}return a}static getLeafAddresses(e){return e.filter((e=>e.isLeaf)).map((e=>e.address))}}ai.getGraphNodes=async(t,a,n,s)=>{if(!await n.find(a))throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST);const i=new ai(n),r=await i.buildGraphFromRootPool(a,s);if(r.id!==a)throw new Error("Error creating graph nodes");return t?ai.orderByBfs(r).reverse():ai.orderByBfs(r)};class ni{constructor(e,t){this.chainId=e,this.simulateMulticall=async(e,t,a,n)=>{const s={...await this.encodeBalanceAndAllowanceOverrides(a,n),...await this.encodeRelayerApprovalOverride(a,e)};return this.simulateTransaction(e,t,a,s)},this.simulateTransaction=async(e,t,a,n)=>{const s=Object.fromEntries(Object.keys(n).map((e=>[e,{storage:n[e].value}]))),i={network_id:this.chainId.toString(),block_number:this.blockNumber,from:a,to:e,input:t,save_if_fails:!0,simulation_type:"quick",state_objects:s},r=this.tenderlyUrl+"simulate";return(await x.default.post(r,i,this.opts)).data.transaction.transaction_info.call_trace.output},this.encodeRelayerApprovalOverride=async(e,t)=>{const a={[`${this.vaultAddress}`]:{value:{[`_approvedRelayers[${e}][${t}]`]:(!0).toString()}}};return await this.requestStateOverrides(a)},this.encodeBalanceAndAllowanceOverrides=async(e,t)=>{if(0===t.length)return{};let n={};t.forEach((t=>n={...n,[`${t}`]:{value:{[`_balances[${e}]`]:a.MaxInt256.toString(),[`_allowances[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString(),[`balanceOf[${e}]`]:a.MaxInt256.toString(),[`allowance[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString(),[`balances[${e}]`]:a.MaxInt256.toString(),[`allowed[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString()}}}));const s=await this.requestStateOverrides(n);if(Object.keys(s).some((e=>2!==Object.keys(s[e].value).length)))throw new Error("Couldn't encode state overrides - states should match the ones in the contracts");return s},this.requestStateOverrides=async e=>{const t=this.tenderlyUrl+"contracts/encode-states",a={networkID:this.chainId.toString(),stateOverrides:e},n=(await x.default.post(t,a,this.opts)).data.stateOverrides;if(!n||Object.keys(n).length!==Object.keys(e).length)throw new Error("Couldn't encode state overrides - contracts should be verified and whitelisted on Tenderly");return n};const{contracts:n}=at(this.chainId);this.vaultAddress=n.vault,(null==t?void 0:t.user)&&(null==t?void 0:t.project)?this.tenderlyUrl=`https://api.tenderly.co/api/v1/account/${t.user}/project/${t.project}/`:this.tenderlyUrl="https://api.balancer.fi/tenderly/",(null==t?void 0:t.accessKey)&&(this.opts={headers:{"X-Access-Key":t.accessKey}}),this.blockNumber=null==t?void 0:t.blockNumber}}var si;const ii=new t.Interface(Ts);class ri{constructor(s,i){this.pools=s,this.createCalls=async(e,t,a,n)=>{const{calls:s,outputIndexes:i,deltas:r}=this.createActionCalls(e,t,a);n&&s.unshift(this.createSetRelayerApproval(n));return{callData:ii.encodeFunctionData("multicall",[s]),outputIndexes:n?i.map((e=>e+1)):i,deltas:r}},this.amountsOutByJoinPath=async(e,a,s,i)=>{const r=[],o=await this.tenderlyHelper.simulateMulticall(this.relayer,a,e,s),d=t.defaultAbiCoder.decode(["bytes[]"],o)[0];let c=n.BigNumber.from("0");return i.forEach((e=>{const a=t.defaultAbiCoder.decode(["uint256"],d[e]);r.push(a.toString()),c=c.add(a.toString())})),{amountsOut:r,totalAmountOut:c.toString()}},this.minAmountsOutByJoinPath=(e,t,a)=>({minAmountsOut:t.map((t=>ze(n.BigNumber.from(t),n.BigNumber.from(e)).toString())),totalMinAmountOut:ze(n.BigNumber.from(a),n.BigNumber.from(e)).toString()}),this.createActionCalls=(e,t,a)=>{const n=[],s=[],i=!a,r={};return e.forEach(((e,o)=>{const d=e[0].isLeaf;if(e.forEach(((s,i)=>{let c;if(c=d?e.filter((e=>{var t;return s.children.map((e=>e.address)).includes(e.address)&&s.index===(null===(t=e.parent)||void 0===t?void 0:t.index)})):i>0?[e[i-1]]:[],c.length>0&&0===c.filter((e=>"0"!==e.index)).length)return void(s.index="0");c.some((e=>"input"===e.joinAction||"wrapAaveDynamicToken"===e.joinAction));const l=t,p=i===e.length-1,u=t,y=p&&a?a[o]:"0";switch(s.joinAction){case"wrapAaveDynamicToken":n.push(this.createAaveWrap(s,c,o,l,t));break;case"batchSwap":{const[e,t,a]=this.createBatchSwap(s,c,o,y,l,u);n.push(e),this.updateDeltas(r,t,a);break}case"joinPool":{const[e,t,a,i]=this.createJoinPool(s,c,o,y,l,u);n.push(e),this.updateDeltas(r,[s.address,...t],[i,...a]);break}}})),i){const e=100*o,t=cs.encodePeekChainedReferenceValue(cs.toChainedReference(e,!1));n.push(t),s.push(n.indexOf(t))}})),{calls:n,outputIndexes:s,deltas:r}},this.createSetRelayerApproval=e=>cs.encodeSetRelayerApproval(this.relayer,!0,e),this.createAaveWrap=(e,t,a,n,s)=>{if(1!==t.length)throw new Error("aaveWrap nodes should always have a single child node");const i=t[0],r=e.address,o=i.index;return cs.encodeWrapAaveDynamicToken({staticToken:r,sender:n,recipient:s,amount:o,fromUnderlying:!0,outputReference:this.getOutputRefValue(a,e).value})},this.createBatchSwap=(t,s,i,r,o,d)=>{if(1!==s.length)throw new Error("Unsupported batchswap");const c=s[0].address,l=this.getOutputRefValue(i,s[0]),p=[t.address,c],u=[n.BigNumber.from(r).mul(-1).toString(),l.isRef?a.MaxInt256.toString():l.value],y=[{poolId:t.id,assetInIndex:1,assetOutIndex:0,amount:l.value,userData:"0x"}],b={sender:o,recipient:d,fromInternalBalance:o===this.relayer,toInternalBalance:d===this.relayer},m=[{index:p.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase()),key:n.BigNumber.from(this.getOutputRefValue(i,t).value)}],f=cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:y,assets:p,funds:b,limits:u,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:m}),h=o===this.relayer?"0":u[1];return[f,p,[d===this.relayer?"0":u[0],h]]},this.createJoinPool=(t,n,s,i,r,o)=>{const d=[],c=[];t.children.forEach((e=>{d.push(e.address);const t=n.find((t=>$e(t.address,e.address)));t?c.push(this.getOutputRefValue(s,t).value):c.push("0")})),t.type===e.PoolType.ComposableStable&&(d.push(t.address),c.push("0"));const l=new W(this.wrappedNativeAsset),[p,u]=l.sortTokens(d,c);let y=[];const b=p.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase());let m;y=-1===b?u:[...u.slice(0,b),...u.slice(b+1)],m=t.type===e.PoolType.Weighted?P.joinExactTokensInForBPTOut(y,i):S.joinExactTokensInForBPTOut(y,i);const f=p.indexOf(a.AddressZero),h=-1===f?"0":u[f],T=cs.constructJoinCall({poolId:t.id,kind:0,sender:r,recipient:o,value:h,outputReference:this.getOutputRefValue(s,t).value,joinPoolRequest:{},assets:p,maxAmountsIn:u,userData:m,fromInternalBalance:r===this.relayer}),g=u.map((e=>cs.isChainedReference(e)?"0":e)),I=cs.isChainedReference(i)?"0":i;return[T,r===this.relayer?[]:p,r===this.relayer?[]:g,o===this.relayer?a.Zero.toString():a.Zero.sub(I).toString()]},this.getOutputRefValue=(e,t)=>"input"===t.joinAction?{value:t.index,isRef:!1}:"0"===t.index&&t.parent?{value:"0",isRef:!0}:{value:cs.toChainedReference(n.BigNumber.from(t.index).add(100*e)).toString(),isRef:!0};const{tokens:r,contracts:o}=at(i.chainId);this.relayer=o.relayerV4,this.wrappedNativeAsset=r.wrappedNativeAsset,this.tenderlyHelper=new ni(i.chainId,i.tenderly)}async joinPool(t,a,n,s,i,r,o){if(a.length!=n.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const d=await ai.getGraphNodes(!0,t,this.pools,i),c=ri.getJoinPaths(d,a,n),l=ri.totalBptZeroPriceImpact(c),{callData:p,outputIndexes:u}=await this.createCalls(c,s,void 0,o),{amountsOut:y,totalAmountOut:b}=await this.amountsOutByJoinPath(s,p,a,u),{minAmountsOut:m,totalMinAmountOut:f}=this.minAmountsOutByJoinPath(r,y,b),h=ct(BigInt(b),l.toBigInt(),!0).toString(),{callData:T,deltas:g}=await this.createCalls(c,s,m,o);return this.assertDeltas(t,g,a,n,f),{to:this.relayer,callData:T,expectedOut:b,minOut:f,priceImpact:h}}assertDeltas(t,a,s,i,r){var o;const d=D(t);if(a[d.toLowerCase()].add(r).abs().gt(3))throw console.error("join assertDeltas, bptOut: ",d,r,null===(o=a[d.toLowerCase()])||void 0===o?void 0:o.toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete a[d.toLowerCase()],s.forEach(((t,s)=>{var r,o;if(!n.BigNumber.from(i[s]).eq(0)&&(null===(r=a[t.toLowerCase()])||void 0===r?void 0:r.toString())!==i[s])throw console.error("join assertDeltas, tokenIn: ",t,i[s],null===(o=a[t.toLowerCase()])||void 0===o?void 0:o.toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete a[t.toLowerCase()]}));for(const t in a)if("0"!==a[t].toString())throw console.error("join assertDeltas, non-input token should be 0: ",t,a[t].toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS)}updateDeltas(e,t,n){return t.forEach(((t,s)=>{const i=t.toLowerCase();e[i]||(e[i]=a.Zero),e[i]=e[i].add(n[s])})),e}}si=ri,ri.getJoinPaths=(e,t,s)=>{const i=[],r=e.filter((e=>t.filter(((e,t)=>n.BigNumber.from(s[t]).gt(0))).map((e=>e.toLowerCase())).includes(e.address.toLowerCase())));r.some((e=>e.isLeaf))&&i.push(e);const o=r.filter((e=>!e.isLeaf));return o.forEach((e=>{const r=s.find(((a,n)=>$e(t[n],e.address))),d=o.filter((t=>$e(t.address,e.address))).reduce(((e,t)=>e.add(t.proportionOfParent)),n.BigNumber.from(0)),l=n.BigNumber.from(r).mul(e.proportionOfParent).div(d).toString(),[p]=ai.createInputTokenNode(0,e.address,e.decimals,e.parent,a.WeiPerEther);p.index=l,p.isLeaf=!1;const u=[p];let y=e.parent;for(;y;)u.push(c.cloneDeep(y)),y=y.parent;i.push(u)})),si.updateInputAmounts(i,t,s),i},ri.updateInputAmounts=(e,t,a)=>{const s=(e,t)=>{if(e.length>1){const a=e.reduce(((e,t)=>e.add(t.index)),n.BigNumber.from(0)),s=n.BigNumber.from(t).sub(a);e[0].index=s.add(e[0].index).toString()}},i=e.find((e=>e[0].isLeaf));if(i){const e=si.updateTotalProportions(i);i.forEach((n=>{"input"===n.joinAction&&(n=si.updateNodeAmount(n,t,a,e))})),t.forEach(((e,t)=>{const n=i.filter((t=>t.isLeaf&&$e(t.address,e)));s(n,a[t])}))}const r=e.filter((e=>!e[0].isLeaf));r.length>1&&t.forEach(((e,t)=>{const n=r.map((e=>e[0])).filter((t=>$e(t.address,e)));s(n,a[t])}))},ri.totalBptZeroPriceImpact=e=>{let t=n.BigNumber.from("0");return e.forEach((e=>{if(e[0].isLeaf){e.filter((e=>e.isLeaf)).forEach((e=>{const a=si.bptOutZeroPiForInputNode(e);t=t.add(a)}))}else{const a=si.bptOutZeroPiForInputNode(e[0]);t=t.add(a)}})),t},ri.bptOutZeroPiForInputNode=e=>{if("0"===e.index||"input"!==e.joinAction)return BigInt(0);let t=1,a=e.parent,s=e.address;for(;void 0!==a;){if("batchSwap"===a.joinAction||"joinPool"===a.joinAction){const e=a.spotPrices[s.toLowerCase()];t*=parseFloat(e),s=a.address}a=a.parent}const i=n.parseFixed(t.toFixed(18),18),r=Q(BigInt(e.decimals)),o=ee(BigInt(e.index),r);return ae.divDownFixed(o,i.toBigInt())},ri.updateTotalProportions=e=>{const t={};return e.forEach((e=>{t[e.address]?t[e.address]=t[e.address].add(e.proportionOfParent):t[e.address]=e.proportionOfParent})),t},ri.updateNodeAmount=(e,t,a,n)=>{const s=t.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase());if(-1===s)return e.index="0",e;const i=n[e.address],r=e.proportionOfParent.mul(1e18.toString()).div(i).mul(a[s]).div(1e18.toString());return e.index=r.toString(),e};const oi=new t.Interface(Ts);class di{constructor(e,s){this.pools=e,this.amountsOutByExitPath=async(e,a,s,i,r)=>{const o=await this.tenderlyHelper.simulateMulticall(this.relayer,a,e,[s]),d=t.defaultAbiCoder.decode(["bytes[]"],o)[0],c=i.map((e=>t.defaultAbiCoder.decode(["uint256"],d[e]).toString())),l=c.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(r)).toString()));return{expectedAmountsOutByExitPath:c,minAmountsOutByExitPath:l}},this.amountsOutByTokenOut=(e,t,s,i)=>{const r={};t.forEach(((e,t)=>{var n;return r[e]=(null!==(n=r[e])&&void 0!==n?n:a.Zero).add(s[t])}));const o=e.map((e=>r[e].toString())),d=o.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(i)).toString()));return{expectedAmountsOut:o,minAmountsOut:d}},this.getExitPaths=(e,t)=>{const s=e.map((e=>{const n=[e];for(;n[0].parent;)n.unshift(c.cloneDeep(n[0].parent));return n[0].index=n[n.length-1].proportionOfParent.mul(t).div(a.WeiPerEther).toString(),n})),i=s.reduce(((e,t)=>{const a=t[0].index;return n.BigNumber.from(a).add(e)}),a.Zero),r=n.BigNumber.from(t).sub(i);return s[s.length-1][0].index=r.add(s[s.length-1][0].index).toString(),s},this.getOutputRef=(e,t)=>100*e+parseInt(t);const{tokens:i,contracts:r}=at(s.chainId);this.wrappedNativeAsset=i.wrappedNativeAsset,this.relayer=r.relayerV4,this.tenderlyHelper=new ni(s.chainId,s.tenderly)}async exitPool(e,t,a,n,s){const i=await ai.getGraphNodes(!1,e,this.pools,!1),r=i.filter((e=>"output"===e.exitAction)),o=this.getExitPaths(r,t),d=r.map((e=>e.address.toLowerCase())),c=[...new Set(d)].sort(),l=await this.createCalls(o,a,void 0,s),{expectedAmountsOutByExitPath:p,minAmountsOutByExitPath:u}=await this.amountsOutByExitPath(a,l.callData,i[0].address,l.outputIndexes,n),{callData:y,deltas:b}=await this.createCalls(o,a,u,s),{expectedAmountsOut:m,minAmountsOut:f}=this.amountsOutByTokenOut(c,d,p,n);this.assertDeltas(e,b,t,c,f);const h=await this.calculatePriceImpact(e,c,m,t);return{to:this.relayer,callData:y,tokensOut:c,expectedAmountsOut:m,minAmountsOut:f,priceImpact:h}}async calculatePriceImpact(e,t,a,n){const s=await ai.getGraphNodes(!0,e,this.pools,!1),i=ri.getJoinPaths(s,t,a),r=ri.totalBptZeroPriceImpact(i);return ct(BigInt(n),r.toBigInt(),!1).toString()}assertDeltas(t,a,n,s,i){var r;const o=D(t);if(a[o.toLowerCase()].sub(n).abs().gt(3))throw console.error("exit assertDeltas, bptIn: ",o,n,null===(r=a[o.toLowerCase()])||void 0===r?void 0:r.toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete a[o.toLowerCase()],s.forEach(((t,n)=>{var s;if(a[t.toLowerCase()].add(i[n]).abs().gt(1))throw console.error("exit assertDeltas, tokenOut: ",t,i[n],null===(s=a[t.toLowerCase()])||void 0===s?void 0:s.toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete a[t.toLowerCase()]}));for(const t in a)if("0"!==a[t].toString())throw console.error("exit assertDeltas, non-input token should be 0: ",t,a[t].toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS)}async createCalls(e,t,a,n){const{calls:s,outputIndexes:i,deltas:r}=this.createActionCalls(c.cloneDeep(e),t,a);n&&s.unshift(cs.encodeSetRelayerApproval(this.relayer,!0,n));return{callData:oi.encodeFunctionData("multicall",[s]),outputIndexes:n?i.map((e=>e+1)):i,deltas:r}}updateDeltas(e,t,n){return t.forEach(((t,s)=>{const i=t.toLowerCase();e[i]||(e[i]=a.Zero),e[i]=e[i].add(n[s])})),e}createActionCalls(e,t,a){const n=[],s=[],i=!a,r={};return e.forEach(((e,o)=>{e.forEach((d=>{const c=!d.parent?t:this.relayer,l=d.children.find((t=>e.map((e=>e.index)).includes(t.index))),p="output"===(null==l?void 0:l.exitAction),u=p?t:this.relayer,y=p&&a?a[o]:"0";switch(d.exitAction){case"batchSwap":{const[e,t,a]=this.createBatchSwap(d,l,o,y,c,u);n.push(e),this.updateDeltas(r,t,a);break}case"exitPool":{const[e,t,a,s]=this.createExitPool(d,l,o,y,c,u);n.push(e),this.updateDeltas(r,[d.address,...a],[t,...s]);break}case"output":i&&(n.push(cs.encodePeekChainedReferenceValue(cs.toChainedReference(this.getOutputRef(o,d.index),!1))),s.push(n.length-1));break;default:return}}))})),{calls:n,outputIndexes:s,deltas:r}}createBatchSwap(t,s,i,r,o,d){const c=!t.parent?t.index:cs.toChainedReference(this.getOutputRef(i,t.index)).toString(),l=s.address,p=[l,t.address],u=[n.BigNumber.from(r).mul(-1).toString(),cs.isChainedReference(c)?a.MaxInt256.toString():c],y=[{poolId:t.id,assetInIndex:1,assetOutIndex:0,amount:c,userData:"0x"}],b={sender:o,recipient:d,fromInternalBalance:!1,toInternalBalance:!1},m=[{index:p.map((e=>e.toLowerCase())).indexOf(l.toLowerCase()),key:cs.toChainedReference(this.getOutputRef(i,s.index))}],f=cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:y,assets:p,funds:b,limits:u,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:m});let h=u[0];const T=u[1],g=o===this.relayer?"0":T;return h=d===this.relayer?"0":h,[f,p,[h,g]]}createExitPool(t,n,s,i,r,o){const d=n.address,c=!t.parent?t.index:cs.toChainedReference(this.getOutputRef(s,t.index)).toString(),l=[],p=[];t.children.forEach((e=>{l.push(e.address),p.push(e.address===d?i:"0")})),t.type===e.PoolType.ComposableStable&&(l.push(t.address),p.push("0"));const u=new W(this.wrappedNativeAsset),[y,b]=u.sortTokens(l,p);let m=[];const f=y.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase());let h;m=-1===f?y:[...y.slice(0,f),...y.slice(f+1)],h=t.type===e.PoolType.Weighted?P.exitExactBPTInForOneTokenOut(c,m.indexOf(d)):S.exitExactBPTInForOneTokenOut(c,m.indexOf(d));const T=[{index:y.map((e=>e.toLowerCase())).indexOf(d.toLowerCase()),key:cs.toChainedReference(this.getOutputRef(s,n.index))}],g=cs.constructExitCall({poolId:t.id,poolKind:0,sender:r,recipient:o,outputReferences:T,exitPoolRequest:{},assets:y,minAmountsOut:b,userData:h,toInternalBalance:!1}),I=b.map((e=>cs.isChainedReference(e)?"0":a.Zero.sub(e).toString())),w=cs.isChainedReference(c)?"0":c;return[g,r===this.relayer?a.Zero.toString():w,o===this.relayer?[]:y,o===this.relayer?[]:I]}}class ci{constructor(e){this.yesterdaysPools=e}async last24h(e){let t;return this.yesterdaysPools&&(t=await this.yesterdaysPools.find(e.id)),e.totalSwapVolume?(null==t?void 0:t.totalSwapVolume)?parseFloat(e.totalSwapVolume)-parseFloat(t.totalSwapVolume):e.createTime&&ys(e.createTime)?parseFloat(e.totalSwapVolume):0:0}}var li=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IProtocolFeePercentagesProvider",name:"protocolFeeProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[],name:"FactoryDisabled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"pool",type:"address"}],name:"PoolCreated",type:"event"},{inputs:[{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"contract IRateProvider[]",name:"rateProviders",type:"address[]"},{internalType:"uint256[]",name:"tokenRateCacheDurations",type:"uint256[]"},{internalType:"bool[]",name:"exemptFromYieldProtocolFeeFlags",type:"bool[]"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],name:"create",outputs:[{internalType:"contract ComposableStablePool",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"disable",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCreationCode",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCreationCodeContracts",outputs:[{internalType:"address",name:"contractA",type:"address"},{internalType:"address",name:"contractB",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPauseConfiguration",outputs:[{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"isDisabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"pool",type:"address"}],name:"isPoolFromFactory",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class pi{constructor(e){const{tokens:t}=at(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:a,name:n,symbol:s,tokenAddresses:i,amplificationParameter:r,rateProviders:o,tokenRateCacheDurations:d,exemptFromYieldProtocolFeeFlags:c,swapFee:l,owner:p}){const u=We(`${l}`),y=new W(this.wrappedNativeAsset),[b,m,f,h]=y.sortTokens(i,o,d,c),T=[n,s,b,r,m,f,h,u.toString(),p],g=new t.Interface(li),I=li.find((({name:e})=>"create"===e));if(!I)throw new st(e.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const w=t.FunctionFragment.from(I);return{to:a,data:g.encodeFunctionData(w,T)}}buildInitJoin({joiner:e,poolId:t,poolAddress:a,tokensIn:n,amountsIn:s}){throw new Error("To be implemented")}}class ui{constructor(e){const{tokens:t}=at(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:a,name:n,symbol:s,tokenAddresses:i,weights:r,swapFee:o,owner:d}){const c=We(`${o}`),l=new W(this.wrappedNativeAsset),[u,y]=l.sortTokens(i,r),b=[n,s,u,y,c.toString(),d],m=new t.Interface(p.WeightedPoolFactory__factory.abi),f=p.WeightedPoolFactory__factory.abi.find((({name:e})=>"create"===e));if(!f)throw new st(e.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const h=t.FunctionFragment.from(f);return{to:a,data:m.encodeFunctionData(h,b)}}buildInitJoin({joiner:e,poolId:t,tokensIn:a,amountsIn:n}){const s=new W(this.wrappedNativeAsset),[i,r]=s.sortTokens(a,n),o="joinPool",d={poolId:t,sender:e,recipient:e,joinPoolRequest:{assets:i,maxAmountsIn:r,userData:P.joinInit(r),fromInternalBalance:!1}},c=p.Vault__factory.createInterface().encodeFunctionData(o,[d.poolId,d.sender,d.recipient,d.joinPoolRequest]);return{to:et,functionName:o,attributes:d,data:c}}}class yi{constructor(e){this.networkConfig=e}of(t){switch(t){case"Weighted":return new ui(this.networkConfig);case"Investment":case"LiquidityBootstrapping":case"Stable":case"MetaStable":case"StablePhantom":case"AaveLinear":case"ERC4626Linear":default:throw new st(e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);case"ComposableStable":return new pi(this.networkConfig)}}}class bi{constructor(t){this.pool=t;const a=(t=>{switch(t){case e.PoolType.Weighted:return P;case e.PoolType.Stable:case e.PoolType.MetaStable:case e.PoolType.StablePhantom:case e.PoolType.AaveLinear:case e.PoolType.EulerLinear:case e.PoolType.ERC4626Linear:case e.PoolType.Element:case e.PoolType.Gyro2:case e.PoolType.Gyro3:return S;case e.PoolType.ComposableStable:return v}})(t.poolType);if(!a)throw"Pool type not supported";this.encoder=a}buildQueryJoinExactIn({sender:e=a.AddressZero,recipient:t=e,maxAmountsIn:n,minimumBPT:s=a.Zero,fromInternalBalance:i=!1}){const r=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e))),o=[...this.pool.tokensList];r&&r>-1&&n.splice(r,1);const d=this.encoder.joinExactTokensInForBPTOut(n,s);return[this.pool.id,e,t,{assets:o,maxAmountsIn:n,userData:d,fromInternalBalance:i}]}buildQueryJoinExactOut({sender:e=a.AddressZero,recipient:t=e,maxAmountsIn:n=[],bptOut:s,tokenIn:i,fromInternalBalance:r=!1}){const o=this.pool.tokensList.indexOf(i),d=this.encoder.joinTokenInForExactBPTOut(s,o);return[this.pool.id,e,t,{assets:this.pool.tokensList,maxAmountsIn:n,userData:d,fromInternalBalance:r}]}buildQueryExitToSingleToken({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n=[],bptIn:s,tokenOut:i,toInternalBalance:r=!1}){const o=this.pool.tokensList.indexOf(i),d=this.encoder.exitExactBPTInForOneTokenOut(s,o);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:d,toInternalBalance:r}]}buildQueryExitProportionally({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n=[],bptIn:s,toInternalBalance:i=!1}){if(!this.encoder.exitExactBPTInForTokensOut)throw"Proportional exit not implemented";const r=this.encoder.exitExactBPTInForTokensOut(s);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:r,toInternalBalance:i}]}buildQueryExitExactOut({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n,maxBptIn:s=a.MaxUint256,toInternalBalance:i=!1}){const r=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e)));r&&r>-1&&n.splice(r,1);const o=this.encoder.exitBPTInForExactTokensOut(n,s);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:o,toInternalBalance:i}]}}class mi{constructor(e){this.liquidityGaugesRepository=e}async relativeWeight(e){const t=await this.liquidityGaugesRepository.findBy("poolId",e);return t?t.relativeWeight:0}async weekly(e){return Xs()*await this.relativeWeight(e)}}const fi=(e,t,a)=>{const s=e.tokens.filter((t=>!e.id.toLowerCase().includes(t.address.toLowerCase()))),i=s.findIndex((e=>e.address.toLowerCase()===t.toLowerCase()));if(-1==i)throw new Error("Token not found in pool");const r=s.map((e=>_e(e.balance,e.decimals))),o=n.BigNumber.from(a),d=r.map((e=>e.mul(o).div(r[i])));return{tokens:s.map((e=>e.address)),amounts:d.map((e=>e.toString()))}},hi=(e,t)=>()=>{throw`${t} for poolType ${e} not implemented`};class Ti{constructor(e,t){this.networkConfig=e,this.repositories=t,this.aprService=new Qs(this.repositories.pools,this.repositories.tokenPrices,this.repositories.tokenMeta,this.repositories.tokenYields,this.repositories.feeCollector,this.repositories.yesterdaysPools,this.repositories.liquidityGauges,this.repositories.feeDistributor),this.liquidityService=new $t(t.pools,t.tokenPrices),this.joinService=new ri(this.repositories.poolsOnChain,e),this.exitService=new di(this.repositories.poolsOnChain,e),this.feesService=new zs(t.yesterdaysPools),this.volumeService=new ci(t.yesterdaysPools),this.poolFactory=new yi(e),this.impermanentLossService=new js(t.tokenPrices,t.tokenHistoricalPrices),t.liquidityGauges&&(this.emissionsService=new mi(t.liquidityGauges)),this.proportionalAmounts=fi}dataSource(){return this.repositories.pools}async apr(e){return this.aprService.apr(e)}async aprNextPeriod(e){return this.aprService.aprNextPeriod(e)}async impermanentLoss(e,t){return this.impermanentLossService.calcImpLoss(e,t)}async liquidity(e){return this.liquidityService.getLiquidity(e)}async generalisedJoin(e,t,a,n,s,i,r){return this.joinService.joinPool(e,t,a,n,s,i,r)}async generalisedExit(e,t,a,n,s){return this.exitService.exitPool(e,t,a,n,s)}async fees(e){return this.feesService.last24h(e)}async volume(e){return this.volumeService.last24h(e)}static wrap(e,t){let a,n,s;try{a=Wt.from(e.poolType),s={buildJoin:(t,n,s,r)=>a.join.buildJoin({joiner:t,pool:e,tokensIn:n,amountsIn:s,slippage:r,wrappedNativeAsset:i}),calcPriceImpact:async(t,n,s)=>a.priceImpactCalculator.calcPriceImpact(e,t,n,s),buildExitExactBPTIn:(t,n,s,r=!1,o)=>{if(a.exit.buildExitExactBPTIn)return a.exit.buildExitExactBPTIn({exiter:t,pool:e,bptIn:n,slippage:s,shouldUnwrapNativeAsset:r,wrappedNativeAsset:i,singleTokenMaxOut:o});throw"ExitExactBPTIn not supported"},buildExitExactTokensOut:(t,n,s,r)=>a.exit.buildExitExactTokensOut({exiter:t,pool:e,tokensOut:n,amountsOut:s,slippage:r,wrappedNativeAsset:i}),calcSpotPrice:(t,n)=>a.spotPriceCalculator.calcPoolSpotPrice(t,n,e),calcProportionalAmounts:(t,a)=>fi(e,t,a)}}catch(t){"UNSUPPORTED_POOL_TYPE"!=t.code&&console.error(t),s={buildJoin:hi(e.poolType,"buildJoin"),calcPriceImpact:hi(e.poolType,"calcPriceImpact"),buildExitExactBPTIn:hi(e.poolType,"buildExitExactBPTIn"),buildExitExactTokensOut:hi(e.poolType,"buildExitExactTokensOut"),calcSpotPrice:hi(e.poolType,"calcSpotPrice")}}try{n=new bi(e),s={...s,buildQueryJoinExactIn:n.buildQueryJoinExactIn.bind(n),buildQueryJoinExactOut:n.buildQueryJoinExactOut.bind(n),buildQueryExitExactOut:n.buildQueryExitExactOut.bind(n),buildQueryExitToSingleToken:n.buildQueryExitToSingleToken.bind(n),buildQueryExitProportionally:n.buildQueryExitProportionally.bind(n)}}catch(t){s={...s,buildQueryJoinExactIn:hi(e.poolType,"buildQueryJoinExactIn"),buildQueryJoinExactOut:hi(e.poolType,"buildQueryJoinExactOut"),buildQueryExitExactOut:hi(e.poolType,"buildQueryExitExactOut"),buildQueryExitToSingleToken:hi(e.poolType,"buildQueryExitToSingleToken"),buildQueryExitProportionally:hi(e.poolType,"buildQueryExitProportionally")}}const i=t.addresses.tokens.wrappedNativeAsset.toLowerCase();return{...e,...s}}async find(e){const t=await this.dataSource().find(e);if(t)return Ti.wrap(t,this.networkConfig)}async findBy(e,t){if("id"==e)return this.find(t);if("address"==e){const e=await this.dataSource().findBy("address",t);if(!e)return;return Ti.wrap(e,this.networkConfig)}throw`search by ${e} not implemented`}async all(){const e=await this.dataSource().all();return e?e.map((e=>Ti.wrap(e,this.networkConfig))).filter((e=>e)):[]}async where(e){const t=await this.dataSource().where(e);if(!t)return[];return t.map((e=>Ti.wrap(e,this.networkConfig))).filter((e=>e))}}const gi=new t.Interface(["function gauge_relative_weight(address gauge, uint timestamp) view returns (uint)","function gauge_relative_weight_write(address gauge, uint timestamp) returns (uint)"]);class Ii{constructor(e,t,a){this.gaugeControllerAddress=t,this.multicall=Dn(e,a)}async getRelativeWeights(e,t){const a=e.map((e=>[this.gaugeControllerAddress,gi.encodeFunctionData("gauge_relative_weight_write",[s.getAddress(e),t||Math.floor(Date.now()/1e3)])])),[,n]=await this.multicall.aggregate(a);return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}}class wi{async get(e){const t=await this.query(e);return(null==t?void 0:t.length)>0?t[0]:void 0}async find(e){return this.get({where:{id:e}})}async findBy(e,t){return this.get({where:{[String(e)]:t}})}async findAllBy(e,t,a=1e3,n=0){const s={where:{[String(e)]:t},first:a,skip:n};return this.query(s)}}class Ei extends wi{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=kn(e)}}class xi extends wi{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=Nn(e)}}class Ai extends xi{async query(e){e.orderBy||(e.orderBy=cn.Balance),e.orderDirection||(e.orderDirection=bn.Desc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{gaugeShares:t}=await this.client.GaugeShares(e);return t.map(this.mapType)}mapType(e){var t;return{id:e.id,balance:e.balance,userAddress:null===(t=e.user)||void 0===t?void 0:t.id,gauge:{id:e.gauge.id,poolId:e.gauge.poolId||void 0,isKilled:e.gauge.isKilled,totalSupply:e.gauge.totalSupply}}}async findByUser(t,a,n){return this.findAllBy(e.GaugeShareAttributes.UserAddress,t,a,n)}async findByGauge(t,a,n){return this.findAllBy(e.GaugeShareAttributes.GaugeId,t,a,n)}}const Si=new t.Interface(["function totalSupply() view returns (uint)","function working_supply() view returns (uint)","function reward_count() view returns (uint)","function reward_tokens(uint rewardIndex) view returns (address)","function reward_data(address rewardToken) view returns (tuple(address token, address distributor, uint period_finish, uint rate, uint last_update, uint integral) data)"]);class Pi{constructor(e,t,a){this.chainId=t,this.multicall=Dn(e,a)}async getTotalSupplies(e){const t=e.map((e=>[e,Si.encodeFunctionData("totalSupply",[])])),[,a]=await this.multicall.aggregate(t),n=a.map((e=>"0x"==e?"0x0":e));return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}async getWorkingSupplies(e){const t=e.map((e=>[e,Si.encodeFunctionData("working_supply",[])])),[,a]=await this.multicall.aggregate(t),n=a.map((e=>"0x"==e?"0x0":e));return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}async getRewardCounts(e){let t;if(1==this.chainId||248==this.chainId||9372==this.chainId){const a=e.map((e=>[e,Si.encodeFunctionData("reward_count",[])])),[,n]=await this.multicall.aggregate(a),s=n.map((e=>"0x"==e?"0x0":e));t=e.reduce(((e,t,a)=>(e[t]||(e[t]=parseInt(s[a])),e)),{})}else t=e.reduce(((e,t)=>(e[t]||(e[t]=1),e)),{});return t}async getRewardTokens(e,t){const a=t||await this.getRewardCounts(e),n=e.filter((e=>a[e]>0)),s=[0],i=n.map(((e,t)=>{const n=[];for(let t=0;t<a[e];t++)n.push([e,Si.encodeFunctionData("reward_tokens",[t])]);return s[t+1]=s[t]+a[e],n})).flat(),[,r]=await this.multicall.aggregate(i);return n.reduce(((e,t,a)=>{const n=s[a],i=s[a+1],o=[];for(let e=n;e<i;e++)o.push(Si.decodeFunctionResult("reward_tokens",r[e])[0]);return e[t]||(e[t]=o),e}),{})}async getRewardData(e,t){const a=t||await this.getRewardTokens(e),n=[0],s=Object.keys(a).map(((e,t)=>{const s=[];for(let t=0;t<a[e].length;t++)s.push([e,Si.encodeFunctionData("reward_data",[a[e][t]])]);return n[t+1]=n[t]+a[e].length,s})).flat(),[,i]=await this.multicall.aggregate(s),r=i.map((e=>Si.decodeFunctionResult("reward_data",e)[0]));return Object.keys(a).reduce(((e,t,s)=>{const i=n[s],o=a[t].reduce(((e,t,a)=>(e[t]||(e[t]=r[i+a]),e)),{});return e[t]||(e[t]=o),e}),{})}}class _i{constructor(e){this.gauges=[],this.client=Nn(e)}async fetch(){const e=(await this.client.Pools({where:{preferentialGauge_not:null},first:1e3})).pools.map((e=>e.preferentialGauge));return this.gauges=e,this.gauges}async find(e){return 0==this.gauges.length&&await this.fetch(),this.gauges.find((t=>t.id==e))}async findBy(e,t){if(0==this.gauges.length&&await this.fetch(),"id"==e)return this.find(t);if("poolId"==e)return this.gauges.find((e=>e.poolId==t));if("poolAddress"==e)return this.gauges.find((e=>e.poolAddress==t));throw`search by ${e} not implemented`}}const Bi=6048e5;class Oi{constructor(e,t,a,n,s){this.chainId=n,this.workingSupplies={},this.workingSuppliesNextPeriod={},this.relativeWeights={},this.relativeWeightsNextPeriod={},this.rewardData={},a&&(this.gaugeController=new Ii(t,a,s)),this.multicall=new Pi(t,n,s),this.subgraph=new _i(e)}async fetch(){const e=await this.subgraph.fetch(),t=e.map((e=>e.id));if(248!=this.chainId&&9372!=this.chainId||(this.workingSupplies=await this.multicall.getWorkingSupplies(t)),this.gaugeController){this.relativeWeights=await this.gaugeController.getRelativeWeights(t);const e=Math.round(Math.floor((Date.now()+Bi)/Bi)*Bi)/1e3;this.relativeWeightsNextPeriod=await this.gaugeController.getRelativeWeights(t,e)}let a=!1;return this.rewardData=e.reduce(((e,t)=>{var s;return e[s=t.id]||(e[s]=t.tokens?Object.fromEntries(t.tokens.map((e=>[e.id.split("-")[0],{distributor:"",last_update:n.BigNumber.from(0),integral:n.BigNumber.from(0),token:e.id.split("-")[0],decimals:e.decimals,rate:_e(e.rate||"0",e.decimals),period_finish:n.BigNumber.from(e.periodFinish||"0")}]))):{}),t.tokens&&t.tokens.length>0&&(a=!0),e}),{}),a||(this.rewardData=await this.multicall.getRewardData(t)),e.map(this.compose.bind(this))}async find(e){return this.gauges||(this.gauges=this.fetch()),(await this.gauges).find((t=>t.id==e))}async findBy(e,t){let a;if(this.gauges||(this.gauges=this.fetch()),"id"==e)return this.find(t);if("address"==e)return this.find(t);if("poolId"==e)a=(await this.gauges).find((e=>e.poolId==t));else{if("poolAddress"!=e)throw`search by ${e} not implemented`;a=(await this.gauges).find((e=>e.poolAddress==t))}return a}compose(e){return{id:e.id,address:e.id,name:e.symbol,poolId:e.poolId,poolAddress:e.poolAddress,totalSupply:parseFloat(e.totalSupply),workingSupply:this.workingSupplies[e.id],relativeWeight:this.relativeWeights[e.id],relativeWeightNextPeriod:this.relativeWeightsNextPeriod[e.id],rewardTokens:this.rewardData[e.id]}}}class vi{constructor(e,t){this.url=e,this.apiKey=t}async get(e){try{const t=this.toPayload(e),{data:a}=await x.default.post(this.url,t,{headers:{"x-api-key":this.apiKey}});if(a.errors)throw new Error(a.errors.map((e=>e.message)).join(","));return a.data}catch(e){throw console.error(e),e}return[]}toPayload(e){return JSON.stringify({query:m.jsonToGraphQLQuery({query:e})})}}class ki{constructor(e){var t,a;this.skip=0,this.client=kn(e.url),this.blockHeight=e.blockHeight,this.chainId=e.chainId;const n={orderBy:xa.TotalLiquidity,orderDirection:ha.Desc,where:{swapEnabled:{eq:!0}}},s=Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||n),i=Object.assign({},(null===(a=e.query)||void 0===a?void 0:a.attrs)||{});this.query={args:s,attrs:i}}async fetchDefault(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0},orderBy:xa.TotalLiquidity,orderDirection:ha.Desc,block:await this.block()});return[...e,...t,...a].map(this.mapType.bind(this))}async fetch(e){(null==e?void 0:e.skip)&&(this.query.args.skip=e.skip),this.blockHeight&&(this.query.args.block={number:await this.blockHeight()}),this.query.args.first=(null==e?void 0:e.first)||1e3;const t=new Ke(this.query.args).format(new je),{pools:a}=await this.client.Pools(t);return this.skip=((null==e?void 0:e.skip)||0)+a.length,a.map(this.mapType.bind(this))}async find(e){return await this.findBy("id",e)}async findBy(e,t){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).find((a=>a[e]==t))}async all(){return this.pools||(this.pools=this.fetchDefault()),this.pools}async block(){return this.blockHeight?{number:await this.blockHeight()}:void 0}async where(e){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).filter(e)}mapType(e){var t,a,n,s,i,r,o,d,c;return{id:e.id,name:e.name||"",address:e.address,chainId:this.chainId,poolType:e.poolType,poolTypeVersion:e.poolTypeVersion||1,swapFee:e.swapFee,swapEnabled:e.swapEnabled,protocolYieldFeeCache:e.protocolYieldFeeCache||"0",protocolSwapFeeCache:e.protocolSwapFeeCache||"0",amp:null!==(t=e.amp)&&void 0!==t?t:void 0,owner:null!==(a=e.owner)&&void 0!==a?a:void 0,factory:null!==(n=e.factory)&&void 0!==n?n:void 0,symbol:null!==(s=e.symbol)&&void 0!==s?s:void 0,tokens:(e.tokens||[]).map(this.mapToken.bind(this)),tokensList:e.tokensList,tokenAddresses:(e.tokens||[]).map((e=>e.address)),totalLiquidity:e.totalLiquidity,totalShares:e.totalShares,totalSwapFee:e.totalSwapFee,totalSwapVolume:e.totalSwapVolume,priceRateProviders:null!==(i=e.priceRateProviders)&&void 0!==i?i:void 0,createTime:e.createTime,mainIndex:null!==(r=e.mainIndex)&&void 0!==r?r:void 0,wrappedIndex:null!==(o=e.wrappedIndex)&&void 0!==o?o:void 0,totalWeight:e.totalWeight||"1",lowerTarget:null!==(d=e.lowerTarget)&&void 0!==d?d:"0",upperTarget:null!==(c=e.upperTarget)&&void 0!==c?c:"0"}}mapToken(e){const t=this.mapSubPools(e.token);return{...e,isExemptFromYieldProtocolFee:e.isExemptFromYieldProtocolFee||!1,token:t}}mapSubPools(e){let t=null;return e.pool&&(t={id:e.pool.id,address:e.pool.address,totalShares:e.pool.totalShares,poolType:e.pool.poolType,mainIndex:e.pool.mainIndex||0},(null==e?void 0:e.pool.tokens)&&(t.tokens=e.pool.tokens.map(this.mapSubPoolToken.bind(this)))),{pool:t,latestUSDPrice:e.latestUSDPrice||void 0}}mapSubPoolToken(e){return{address:e.address,decimals:e.decimals,symbol:e.symbol,balance:e.balance,priceRate:e.priceRate,weight:e.weight,isExemptFromYieldProtocolFee:e.isExemptFromYieldProtocolFee||void 0,token:e.token?this.mapSubPools(e.token):void 0}}}class Ni{constructor(e){this.skip=0,this.poolsSubgraph=new ki({url:e.url,chainId:e.chainId,blockHeight:e.blockHeight,query:e.query}),this.provider=e.provider,this.multicall=e.multicall,this.vault=e.vault}async fetchDefault(){const e=await this.poolsSubgraph.fetch();return await qn(e,this.multicall,this.vault,this.provider)}async fetch(e){const t=await this.poolsSubgraph.fetch(e);return await qn(t,this.multicall,this.vault,this.provider)}async find(e){return await this.findBy("id",e)}async findBy(e,t){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).find((a=>a[e]==t))}async all(){return this.pools||(this.pools=this.fetchDefault()),this.pools}async where(e){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).filter(e)}}class Ci extends xi{async query(e){!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{pools:t}=await this.client.PoolGauges(e);return t.map(this.mapType)}mapType(e){return e}}var Di;e.PoolJoinExitAttributes=void 0,(Di=e.PoolJoinExitAttributes||(e.PoolJoinExitAttributes={})).Pool="pool",Di.Sender="sender";class Ri extends Ei{async query(e){e.orderBy||(e.orderBy=ya.Timestamp),e.orderDirection||(e.orderDirection=ha.Asc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{joinExits:t}=await this.client.JoinExits(e);return t.map(this.mapType)}mapType(e){return{id:e.id,userAddress:e.user.id,poolId:e.pool.id,timestamp:e.timestamp,type:e.type,amounts:e.amounts,tokens:e.pool.tokensList}}async findByUser(t,a,n){return this.findAllBy(e.PoolJoinExitAttributes.Sender,t,a,n)}async findJoins(e,t){return this.query({where:{sender:e,pool:t,type:"Join"}})}async findExits(e,t){return this.query({where:{sender:e,pool:t,type:"Exit"}})}async findByPool(t,a,n){return this.findAllBy(e.PoolJoinExitAttributes.Pool,t,a,n)}}class Fi extends Ei{async query(e){e.orderBy||(e.orderBy=Ia.Balance),e.orderDirection||(e.orderDirection=ha.Desc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{poolShares:t}=await this.client.PoolShares(e);return t.map(this.mapType)}mapType(e){return{id:e.id,userAddress:e.userAddress.id,poolId:e.poolId.id,balance:e.balance}}async findByUser(t,a,n){return this.findAllBy(e.PoolShareAttributes.UserAddress,t,a,n)}async findByPool(t,a,n){return this.findAllBy(e.PoolShareAttributes.PoolId,t,a,n)}}class Mi{constructor(e){this.tokens=e}async find(e){return this.tokens.find((t=>t.address.toLowerCase()===e.toLowerCase()))}async findBy(e,t){return this.tokens.find((a=>a[e]===t))}}class Li{constructor(e,t=1){this.chainId=t,this.prices={},this.baseTokenAddresses=e.map(Fe),this.urlBase=`${tt[t].urls.priceUrl}/price/?vs_currencies=usd,eth`,this.debouncer=new Ue(this.fetch.bind(this),200)}fetch(e,{signal:t}={}){return e.length,x.default.get(this.url(e),{signal:t}).then((({data:e})=>e)).finally((()=>{e.length}))}fetchNative({signal:e}={}){let t;!function(e){e.ETH="ethereum",e.MATIC="matic-network",e.XDAI="xdai",e.OAS="oasys"}(t||(t={}));const a=t.OAS,n=this.url(["0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000"]);return x.default.get(n,{signal:e}).then((({data:e})=>e[a])).finally((()=>{}))}find(e){const t=e.toLowerCase();if(!this.prices[t]){if(0===Object.keys(this.prices).length)for(const e of this.baseTokenAddresses)this.prices[e]=this.debouncer.fetch(e).then((t=>t[e]));this.prices[t]=this.debouncer.fetch(t).then((e=>e[t]))}return this.prices[t]}async findBy(e,t){if("address"==e)return this.find(t)}platform(e){switch(e){case 1:case 5:case 42:case 31337:case 248:case 9372:case 16116:case 17117:return"ethereum";case 100:return"xdai";case 137:return"polygon-pos";case 42161:return"arbitrum-one"}return"3"}url(e){return`${this.urlBase}&contract_addresses=${e.join(",")}`}}class Ui{constructor(e=1){this.chainId=e,this.prices={},this.urlBase=`https://api.coingecko.com/api/v3/coins/${this.platform(e)}/contract/%TOKEN_ADDRESS%/market_chart/range?vs_currency=usd`}fetch(e,t,{signal:a}={}){const n=this.urlRange(e,t);return x.default.get(n,{signal:a}).then((({data:e})=>e)).finally((()=>{}))}async find(e){throw"Historic price requires point-in-time timestamp, please use findBy(address, timestamp)"}async findBy(e,t){const a=Fe(e,this.chainId);return{usd:`${(await this.fetch(a,t)).prices[0][1]}`}}platform(e){switch(e){case 1:case 5:case 42:case 31337:case 248:case 9372:case 16116:case 17117:return"ethereum";case 137:return"polygon-pos";case 42161:return"arbitrum-one";case 100:return"xdai"}return"2"}urlRange(e,t){const a=t-3600,n=t+3600;return`${this.urlBase.replace("%TOKEN_ADDRESS%",e)}&from=${a}&to=${n}`}}class Gi{constructor(e,t=1){this.subgraphUrl=e,this.chainId=t,this.prices={},this.debouncer=new Ue(this.fetch.bind(this),200)}async fetch(e,{signal:t}={}){return e.length,x.default.post(this.subgraphUrl,{variables:{addresses:e},query:"query($addresses: [String!]) {\n tokens(\n where: {\n id_in: $addresses\n }\n ) {\n address\n latestUSDPrice\n }\n }"},{signal:t}).then((e=>e.data.data)).then((({tokens:e})=>Object.fromEntries(e.map((e=>[e.address,{usd:e.latestUSDPrice||void 0}]))))).finally((()=>{e.length}))}async find(e){const t=Fe(e,this.chainId);return this.prices[t]||(this.prices[t]=this.debouncer.fetch(t).then((e=>e[t]))),this.prices[t]}async findBy(e,t){if("address"==e)return this.find(t)}}class qi{constructor(e,t,a){this.coingeckoRepository=e,this.subgraphRepository=t,this.aaveRates=a}async find(e){let t;try{try{if(t=await this.coingeckoRepository.find(e),!(null==t?void 0:t.usd))throw new Error(`Price not found:${e}`)}catch(a){console.error(`Coingecko API error: ${e} ${a}`),t=await this.subgraphRepository.find(e)}}catch(e){console.error(e),t={eth:"0",usd:"0.1"}}return t}async findBy(e,t){if("address"===e)return this.find(t);throw`Token price search by ${e} not implemented`}}class Wi{constructor(e,t){this.coingeckoRepository=e,this.aaveRates=t}async find(e){return this.findBy(e,Math.floor(Date.now()/1e3))}async findBy(e,t){const a=await this.coingeckoRepository.findBy(e,t),n=await this.aaveRates.getRate(e)||1;return a&&a.usd?{...a,usd:(parseFloat(a.usd)*n).toString()}:a}}const $i=new t.Interface(["function rate() view returns (uint256)"]);class Vi{constructor(e,t,a){this.network=a,this.multicall=Dn(e,t)}async fetch(e){const t=Object.values(Be[e]),a=t.map((e=>[e,$i.encodeFunctionData("rate",[])])),[,n]=await this.multicall.aggregate(a);return t.reduce(((e,t,a)=>(e[t]||(e[t]="0x"==n[a]?0:parseFloat(Pe(n[a],27))),e)),{})}async getRate(t){return this.network!=e.Network.MAINNET&&this.network!=e.Network.POLYGON?1:Object.values(Be[this.network]).includes(t)?(this.rates||(this.rates=this.fetch(this.network)),(await this.rates)[t]):1}}const Hi=new t.Interface(["function getTokensDistributedInWeek(address token, uint timestamp) view returns (uint)"]),ji=new t.Interface(["function totalSupply() view returns (uint)"]),Ki=new t.Interface(["function getRate() view returns (uint)"]);class Zi{constructor(e,t,a,n,s,i){this.feeDistributorAddress=t,this.balAddress=a,this.veBalAddress=n,this.bbAUsdAddress=s,this.multicall=Dn(e,i)}async fetch(e){const t=this.getPreviousWeek(e),a=[[this.feeDistributorAddress,Hi.encodeFunctionData("getTokensDistributedInWeek",[s.getAddress(this.balAddress),t])],[this.feeDistributorAddress,Hi.encodeFunctionData("getTokensDistributedInWeek",[s.getAddress(this.bbAUsdAddress),t])],[this.veBalAddress,ji.encodeFunctionData("totalSupply",[])],[this.bbAUsdAddress,Ki.encodeFunctionData("getRate",[])]],[,n]=await this.multicall.aggregate(a);return{balAmount:parseFloat(Pe(n[0],18)),bbAUsdAmount:parseFloat(Pe(n[1],18)),veBalSupply:parseFloat(Pe(n[2],18)),bbAUsdPrice:parseFloat(Pe(n[3],18)),balAddress:this.balAddress}}async multicallData(e){return this.data||(this.data=await this.fetch(e)),this.data}getPreviousWeek(e){const t=new Date(e);t.setUTCHours(0),t.setUTCMinutes(0),t.setUTCSeconds(0),t.setUTCMilliseconds(0);let a=t.getUTCDay()-4;return a<0&&(a+=7),a+=7,Math.floor(t.getTime()/1e3)-86400*a}}const Xi=new t.Interface(["function getProtocolFeesCollector() view returns (address)"]),Ji=new t.Interface(["function getSwapFeePercentage() view returns (uint)"]);let Yi;class zi{constructor(e,t){this.provider=t,this.vault=new i.Contract(e,Xi,this.provider)}async fetch(){const e=await this.vault.getProtocolFeesCollector(),t=new i.Contract(e,Ji,this.provider),a=await t.getSwapFeePercentage();return parseFloat(Pe(a,18))}async find(){return Yi||(Yi=this.fetch()),this.swapFeePercentage=await Yi,this.swapFeePercentage}async findBy(){return this.find()}}const Qi=new t.Interface(["function getSwapFeePercentage() view returns (uint)"]);let er;class tr{constructor(e,t,a){this.protocolFeePercentagesProviderAddress=t,this.multicall=Dn(e,a)}async fetch(){const e=[[this.protocolFeePercentagesProviderAddress,Qi.encodeFunctionData("getFeeTypePercentage",[0])],[this.protocolFeePercentagesProviderAddress,Qi.encodeFunctionData("getFeeTypePercentage",[2])]],[,t]=await this.multicall.aggregate(e);return{swapFee:parseFloat(Pe(t[0],18)),yieldFee:parseFloat(Pe(t[2],18))}}async getFees(){return er||(er=this.fetch()),this.protocolFees=await er,this.protocolFees}}const ar={stETH:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",wstETH:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",arbitrumStEth:"0x5979d7b546e38e414f7e9822514be443a4800529"},nr=async()=>{let e=0;try{const t=await x.default.get("https://lido-aprs-proxy.balancer.workers.dev/?network=1"),{data:a}=t.data;e=Math.round(100*parseFloat(a.smaApr))}catch(e){console.error("Failed to fetch stETH APR:",e)}return{[ar.stETH]:e,[ar.wstETH]:e,[ar.arbitrumStEth]:e}},sr={rETH:"0xae78736cd615f374d3085123a210448e74fc6393"},ir=async()=>{let e=0;try{const t=await x.default.get("https://api.rocketpool.net/api/apr"),{yearlyAPR:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[sr.rETH]:e}},rr={stMATIC:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4"},or=async()=>{let e=0;try{const t=await x.default.get("https://lido-aprs-proxy.balancer.workers.dev/?network=137"),{apr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch stMATIC APR:",e)}return{[rr.stMATIC]:e}},dr={usdcUSDplus:"0x1aafc31091d93c3ff003cff5d2d8f7ba2e728425",usdcUSDplus2:"0x6933ec1ca55c06a894107860c92acdfd2dd8512f"},cr=async()=>{let e=0;try{const{data:t}=await x.default.get("https://app.overnight.fi/api/balancer/week/apr");e=Math.round(1e4*parseFloat(t)/100)}catch(e){console.error("Failed to fetch USD+ APR:",e)}return Object.fromEntries(Object.values(dr).map((t=>[t,e])))},lr={sfrxETH:"0xac3e018457b222d93114458476f3e3416abbe38f"},pr=async()=>{let e=0;try{const t=await x.default.get("https://api.frax.finance/v2/frxeth/summary/latest"),{sfrxethApr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[lr.sfrxETH]:e}},ur={maticX:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6"},yr=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=stader"),{value:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[ur.maticX]:e}},br={qETH:"0x93ef1ea305d11a9b2a3ebb9bb4fcc34695292e7d"},mr=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=tranchess"),[{weeklyAveragePnlPercentage:a}]=t.data;e=Math.round(parseFloat(Pe(n.BigNumber.from(a).mul(365).mul(1e4),18)))}catch(e){console.error("Failed to fetch qETH APR:",e)}return{[br.qETH]:e}},fr={USDR:"0xaf0d9d65fc54de245cda37af3d18cbec860a4d4b"},hr=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=usdr"),{usdr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch USDR APR:",e)}return{[fr.USDR]:e}},Tr={rETH:"0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593"},gr=async()=>{let e=0;try{const t=await x.default.get("https://drop-api.stafi.io/reth/v1/poolData/"),{stakeApr:a}=t.data.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[Tr.rETH]:e}},Ir=new u.JsonRpcProvider("https://rpc.ankr.com/eth",1),wr={getPoolsUI:new i.Contract("0x5954aB967Bc958940b7EB73ee84797Dc8a2AFbb9",[{inputs:[],name:"getPoolsUI",outputs:[{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"}],stateMutability:"view",type:"function"}],Ir).getPoolsUI},Er={sApe:"0x7966c5bae631294d7cffcea5430b78c2f76db6fa"},xr=async(e=1,t=wr)=>{let a=0;try{const e=(await t.getPoolsUI())[0],n=e.stakedAmount,s=e.currentTimeRange.rewardsPerHour.mul(8760);a=Number(s.mul(1e4).div(n))}catch(e){console.error("Failed to fetch Tessera Ape Coin APR:",e)}return{[Er.sApe]:a}},Ar={eUSDC:"0xeb91861f8a4e1c12333f42dce8fb0ecdc28da716",eDAI:"0xe025e3ca2be02316033184551d4d3aa22024d9dc",eUSDT:"0x4d19f33948b99800b6113ff3e83bec9b537c85d2",eFRAX:"0x5484451a88a35cd0878a1be177435ca8a0e4054e"},Sr={[e.Network.MAINNET]:"https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet"},Pr=async()=>{const t=e.Network.MAINNET,a={operationName:"getAssetsAPY",query:"\n query getAssetsAPY($eTokenAddress_in: [String!]) {\n assets(\n where: {\n eTokenAddress_in: $eTokenAddress_in\n }\n ) {\n eTokenAddress\n supplyAPY\n }\n }\n",variables:{eTokenAddress_in:Object.values(Ar)}},s=await x.default.post(Sr[t],a),{data:{assets:i}}=s.data,r={eUSDT:0,eDAI:0,eUSDC:0,eFRAX:0};return i.forEach((({eTokenAddress:e,supplyAPY:t})=>{const a=Object.entries(Ar).filter((([,t])=>t.toLocaleLowerCase()===e.toLocaleLowerCase()))[0][0];r[a]=Math.round(1e4*parseFloat(Pe(n.BigNumber.from(t),27)))})),{[Ar.eUSDT]:r.eUSDT,[Ar.eDAI]:r.eDAI,[Ar.eUSDC]:r.eUSDC,[Ar.eFRAX]:r.eFRAX}},_r=Object.fromEntries([...Object.values(ar).map((e=>[e,nr])),...Object.values(rr).map((e=>[e,or])),...Object.values(Oe).map((e=>[e,Re])),...Object.values(dr).map((e=>[e,cr])),...Object.values(sr).map((e=>[e,ir])),...Object.values(lr).map((e=>[e,pr])),...Object.values(ur).map((e=>[e,yr])),...Object.values(br).map((e=>[e,mr])),...Object.values(fr).map((e=>[e,hr])),...Object.values(Tr).map((e=>[e,gr])),...Object.values(Er).map((e=>[e,xr])),...Object.values(Ar).map((e=>[e,Pr]))]);class Br{constructor(e,t=_r){this.network=e,this.sources=t,this.yields={}}async fetch(e){const t=await this.sources[e](this.network);this.yields={...this.yields,...t}}async find(e){const t=e.toLocaleLowerCase();return Object.keys(this.sources).includes(t)&&!Object.keys(this.yields).includes(t)&&await this.fetch(t),this.yields[t]}async findBy(e,t){if("address"==e)return this.find(t)}}const Or=e=>`{\n blocks(first: 1, orderBy: timestamp, orderDirection: asc, where: { timestamp_gt: ${e} }) {\n number\n }\n}`,vr=async(e,t)=>{const a={query:Or(t)},n=await x.default.post(e,a),{data:{blocks:s}}=n.data;return parseInt(s[0].number)};class kr{constructor(e){this.endpoint=e,this.blocks={}}async find(e){if("dayAgo"==e){const e=""+(Math.floor(Date.now()/1e3)-86400);return this.blocks[e]||(this.blocks={...this.blocks,[e]:vr(this.endpoint,e)}),this.blocks[e]}}async findBy(e="",t=""){}}var Nr,Cr,Dr=[{chainId:1,address:"0x8888801af4d980682e47f1a9036e589479e835c5",symbol:"mph"},{chainId:1,address:"0x27054b13b1b798b345b591a4d22e6562d47ea75a",symbol:"ast"},{chainId:1,address:"0x3301ee63fb29f863f2333bd4466acb46cd8323e6",symbol:"akita"},{chainId:1,address:"0x616e8bfa43f920657b3497dbf40d6b1a02d4608d",symbol:"aurabal"},{chainId:1,address:"0xc0c293ce456ff0ed870add98a0828dd4d2903dbf",symbol:"aura"},{chainId:1,address:"0x3472a5a71965499acd81997a54bba8d852c6e53d",symbol:"badger"},{chainId:1,address:"0xba100000625a3754423978a60c9317c58a424e3d",symbol:"bal"},{chainId:1,address:"0x804cdb9116a10bb78768d3252355a1b18067bf8f",symbol:"bb-a-dai"},{chainId:1,address:"0x9210f1204b5a24742eba12f710636d76240df3d0",symbol:"bb-a-usdc"},{chainId:1,address:"0x2bbf681cc4eb09218bee85ea2a5d3d13fa40fc0c",symbol:"bb-a-usdt"},{chainId:1,address:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2",symbol:"bb-a-usd"},{chainId:1,address:"0x2d94aa3e47d9d5024503ca8491fce9a2fb4da198",symbol:"bank"},{chainId:1,address:"0x0d8775f648430679a709e98d2b0cb6250d2887ef",symbol:"bat"},{chainId:1,address:"0xf17e65822b568b3903685a7c9f496cf7656cc6c2",symbol:"bico"},{chainId:1,address:"0x799ebfabe77a6e34311eeee9825190b9ece32824",symbol:"btrst"},{chainId:1,address:"0x514910771af9ca656af840dff83e8264ecf986ca",symbol:"link"},{chainId:1,address:"0x3506424f91fd33084466f402d5d97f05f8e3b4af",symbol:"chz"},{chainId:1,address:"0x41e5560054824ea6b0732e656e3ad64e20e94e45",symbol:"cvc"},{chainId:1,address:"0xc00e94cb662c3520282e6f5717214004a7f26888",symbol:"comp"},{chainId:1,address:"0xdef1ca1fb7fbcdc777520aa7f396b4e015f497ab",symbol:"cow"},{chainId:1,address:"0xd533a949740bb3306d119cc777fa900ba034cd52",symbol:"crv"},{chainId:1,address:"0x6b175474e89094c44da98b954eedeac495271d0f",symbol:"dai"},{chainId:1,address:"0xf2051511b9b121394fa75b8f7d4e7424337af687",symbol:"haus"},{chainId:1,address:"0x888888435fde8e7d4c54cab67f206e4199454c60",symbol:"dfx"},{chainId:1,address:"0x798d1be841a82a273720ce31c822c61a67a601c3",symbol:"digg"},{chainId:1,address:"0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c",symbol:"enj"},{chainId:1,address:"0xc18360217d8f7ab5e7c516566761ea12ce7f9d72",symbol:"ens"},{chainId:1,address:"0x4e15361fd6b4bb609fa63c81a2be19d873717870",symbol:"ftm"},{chainId:1,address:"0x956f47f50a910163d8bf957cf5846d573e7f87ca",symbol:"fei"},{chainId:1,address:"0xed1480d12be41d92f36f5f7bdd88212e381a3677",symbol:"fdt"},{chainId:1,address:"0x586aa273f262909eef8fa02d90ab65f5015e0516",symbol:"fiat"},{chainId:1,address:"0xde30da39c46104798bb5aa3fe8b9e0e1f348163f",symbol:"gtc"},{chainId:1,address:"0x900db999074d9277c5da2a43f252d74366230da0",symbol:"giv"},{chainId:1,address:"0x6810e776880c02933d47db1b9fc05908e5386b96",symbol:"gno"},{chainId:1,address:"0xba485b556399123261a5f9c95d413b4f93107407",symbol:"graviaura"},{chainId:1,address:"0x3ec8798b81485a254928b70cda1cf0a2bb0b74d7",symbol:"gro"},{chainId:1,address:"0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",symbol:"snx"},{chainId:1,address:"0x5a98fcbea516cf06857215779fd812ca3bef1b32",symbol:"ldo"},{chainId:1,address:"0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d",symbol:"lqty"},{chainId:1,address:"0x5f98805a4e8be255a32880fdec7f6728c6568ba0",symbol:"lusd"},{chainId:1,address:"0x965d79f1a1016b574a62986e13ca8ab04dfdd15c",symbol:"m2"},{chainId:1,address:"0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",symbol:"mkr"},{chainId:1,address:"0xd084944d3c05cd115c09d072b9f44ba3e0e45921",symbol:"fold"},{chainId:1,address:"0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",symbol:"matic"},{chainId:1,address:"0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",symbol:"mta"},{chainId:1,address:"0x4b13006980acb09645131b91d259eaa111eaf5ba",symbol:"myc"},{chainId:1,address:"0x333a4823466879eef910a04d473505da62142069",symbol:"nation"},{chainId:1,address:"0xcfeaead4947f0705a14ec42ac3d44129e1ef3ed5",symbol:"note"},{chainId:1,address:"0x967da4048cd07ab37855c090aaf366e4ce1b9f48",symbol:"ocean"},{chainId:1,address:"0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5",symbol:"ohm"},{chainId:1,address:"0xab846fb6c81370327e784ae7cbb6d6a6af6ff4bf",symbol:"pal"},{chainId:1,address:"0xcafe001067cdef266afb7eb5a286dcfd277f3de5",symbol:"psp"},{chainId:1,address:"0x68037790a0229e9ce6eaa8a99ea92964106c4703",symbol:"par"},{chainId:1,address:"0x45804880de22913dafe09f4980848ece6ecbaf78",symbol:"paxg"},{chainId:1,address:"0x89ab32156e46f46d02ade3fecbe5fc4243b9aaed",symbol:"pnt"},{chainId:1,address:"0x9992ec3cf6a55b00978cddf2b27bc6882d88d1ec",symbol:"poly"},{chainId:1,address:"0x43d4a3cd90ddd2f8f4f693170c9c8098163502ad",symbol:"d2d"},{chainId:1,address:"0xeb4c2781e4eba804ce9a9803c67d0893436bb27d",symbol:"renbtc"},{chainId:1,address:"0x408e41876cccdc0f92210600ef50372656052a38",symbol:"ren"},{chainId:1,address:"0xfb5453340c03db5ade474b27e68b6a9c6b2823eb",symbol:"robot"},{chainId:1,address:"0xd33526068d116ce69f19a9ee46f0bd304f21a51f",symbol:"rpl"},{chainId:1,address:"0xae78736cd615f374d3085123a210448e74fc6393",symbol:"reth"},{chainId:1,address:"0xfe18be6b3bd88a2d2a7f928d00292e7a9963cfc6",symbol:"sbtc"},{chainId:1,address:"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff",symbol:"srm"},{chainId:1,address:"0x35e78b3982e87ecfd5b3f3265b601c046cdbe232",symbol:"xai"},{chainId:1,address:"0x3affcca64c2a6f4e3b6bd9c64cd2c969efd1ecbe",symbol:"dsla"},{chainId:1,address:"0xf24d8651578a55b0c119b9910759a351a3458895",symbol:"sdbal"},{chainId:1,address:"0x11c1a6b3ed6bb362954b29d3183cfa97a0c806aa",symbol:"str"},{chainId:1,address:"0x8f693ca8d21b157107184d29d398a8d082b38b76",symbol:"data"},{chainId:1,address:"0x470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7",symbol:"temple"},{chainId:1,address:"0xa36fdbbae3c9d55a1d67ee5821d53b50b63a1ab9",symbol:"temp"},{chainId:1,address:"0xdac17f958d2ee523a2206206994597c13d831ec7",symbol:"usdt"},{chainId:1,address:"0x9c4a4204b79dd291d6b6571c5be8bbcd0622f050",symbol:"tcr"},{chainId:1,address:"0x226f7b842e0f0120b7e194d05432b3fd14773a9d",symbol:"unn"},{chainId:1,address:"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",symbol:"uni"},{chainId:1,address:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",symbol:"usdc"},{chainId:1,address:"0x81f8f0bb1cb2a06649e51913a151f0e7ef6fa321",symbol:"vita"},{chainId:1,address:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",symbol:"weth"},{chainId:1,address:"0xedb171c18ce90b633db442f2a6f72874093b49ef",symbol:"wampl"},{chainId:1,address:"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",symbol:"wbtc"},{chainId:1,address:"0xf203ca1769ca8e9e8fe1da9d147db68b6c919817",symbol:"wncg"},{chainId:1,address:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",symbol:"wsteth"},{chainId:1,address:"0x79c71d3436f39ce382d0f58f1b011d88100b9d91",symbol:"xns"},{chainId:1,address:"0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",symbol:"yfi"},{chainId:1,address:"0xbcca60bb61934080951369a648fb03df4f96263c",symbol:"ausdc"},{chainId:1,address:"0x028171bca77440897b824ca71d1c56cac55b68a3",symbol:"adai"},{chainId:1,address:"0x3ed3b47dd13ec9a98b44e6204a523e766b225811",symbol:"ausdt"},{chainId:137,address:"0x9c2c5fd7b07e95ee044ddeba0e97a665f142394f",symbol:"1inch"},{chainId:137,address:"0xd6df932a45c0f255f85145f286ea0b292b21c90b",symbol:"aave"},{chainId:137,address:"0xc3fdbadc7c795ef1d6ba111e06ff8f16a20ea539",symbol:"addy"},{chainId:137,address:"0xf84bd51eab957c2e7b7d646a3427c5a50848281d",symbol:"agar"},{chainId:137,address:"0x033d942a6b495c4071083f4cde1f17e986fe856c",symbol:"aga"},{chainId:137,address:"0x0e9b89007eee9c958c0eda24ef70723c2c93dd58",symbol:"amaticc"},{chainId:137,address:"0x034b2090b579228482520c589dbd397c53fc51cc",symbol:"vision"},{chainId:137,address:"0x2c89bbc92bd86f8075d1decc58c7f4e0107f286b",symbol:"avax"},{chainId:137,address:"0x49690541e3f6e933a9aa3cffee6010a7bb5b72d7",symbol:"axiav3"},{chainId:137,address:"0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",symbol:"bal"},{chainId:137,address:"0xdb7cb471dd0b49b29cab4a1c14d070f27216a0ab",symbol:"bank"},{chainId:137,address:"0xfbdd194376de19a88118e84e279b977f165d01b8",symbol:"bifi"},{chainId:137,address:"0xd6ca869a4ec9ed2c7e618062cdc45306d8dbbc14",symbol:"btc2x-fli-p"},{chainId:137,address:"0x53e0bca35ec356bd5dddfebbd1fc0fd03fabad39",symbol:"link"},{chainId:137,address:"0x172370d5cd63279efa6d502dab29171933a610af",symbol:"crv"},{chainId:137,address:"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",symbol:"dai"},{chainId:137,address:"0x1d607faa0a51518a7728580c238d912747e71f7a",symbol:"data"},{chainId:137,address:"0x85955046df4668e1dd369d2de9f3aeb98dd2a369",symbol:"dpi"},{chainId:137,address:"0xe7804d91dfcde7f776c90043e03eaa6df87e6395",symbol:"dfx"},{chainId:137,address:"0xf28164a485b0b2c90639e47b0f377b4a438a16b1",symbol:"dquick"},{chainId:137,address:"0x45c32fa6df82ead1e2ef74d17b76547eddfaff89",symbol:"frax"},{chainId:137,address:"0x50b728d8d964fd00c2d0aad81718b71311fef68a",symbol:"snx"},{chainId:137,address:"0x72928d5436ff65e57f72d5566dcd3baedc649a88",symbol:"hdao"},{chainId:137,address:"0x3ad707da309f3845cd602059901e39c4dcd66473",symbol:"eth2x-fli-p"},{chainId:137,address:"0x4f025829c4b13df652f38abd2ab901185ff1e609",symbol:"ieth-fli-p"},{chainId:137,address:"0x340f412860da7b7823df372a2b59ff78b7ae6abc",symbol:"imatic-fli-p"},{chainId:137,address:"0xf287d97b6345bad3d88856b26fb7c0ab3f2c7976",symbol:"matic2x-fli-p"},{chainId:137,address:"0x130ce4e4f76c2265f94a961d70618562de0bb8d2",symbol:"ibtc-fli-p"},{chainId:137,address:"0x596ebe76e2db4470966ea395b0d063ac6197a8c5",symbol:"jrt"},{chainId:137,address:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4",symbol:"stmatic"},{chainId:137,address:"0xf501dd45a1198c2e1b5aef5314a68b9006d842e0",symbol:"mta"},{chainId:137,address:"0xeaecc18198a475c921b24b8a6c1c1f0f5f3f7ea0",symbol:"seed"},{chainId:137,address:"0xfe712251173a2cd5f5be2b46bb528328ea3565e1",symbol:"mvi"},{chainId:137,address:"0xa3fa99a148fa48d14ed51d610c367c61876997f1",symbol:"mimatic"},{chainId:137,address:"0xa486c6bc102f409180ccb8a94ba045d39f8fc7cb",symbol:"nex"},{chainId:137,address:"0xe2aa7db6da1dae97c5f5c6914d285fbfcc32a128",symbol:"par"},{chainId:137,address:"0x580a84c73811e1839f75d86d75d88cca0c241ff4",symbol:"qi"},{chainId:137,address:"0x831753dd7087cac61ab5644b308642cc1c33dc13",symbol:"quick"},{chainId:137,address:"0xb5c064f955d8e7f38fe0460c556a72987494ee17",symbol:"quick"},{chainId:137,address:"0x00e5646f60ac6fb446f621d146b6e1886f002905",symbol:"rai"},{chainId:137,address:"0x431cd3c9ac9fc73644bf68bf5691f4b83f9e104f",symbol:"rbw"},{chainId:137,address:"0xdbf31df14b66535af65aac99c32e9ea844e14501",symbol:"renbtc"},{chainId:137,address:"0x501ace9c35e60f03a2af4d484f49f9b1efde9f40",symbol:"solace"},{chainId:137,address:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6",symbol:"maticx"},{chainId:137,address:"0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a",symbol:"sushi"},{chainId:137,address:"0xdf7837de1f2fa4631d716cf2502f8b230f1dcc32",symbol:"tel"},{chainId:137,address:"0xe6469ba6d2fd6130788e0ea9c0a0515900563b59",symbol:"ust"},{chainId:137,address:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",symbol:"usdt"},{chainId:137,address:"0x5fe2b58c013d7601147dcdd68c143a77499f5531",symbol:"grt"},{chainId:137,address:"0xbbba073c31bf03b8acf7c28ef0738decf3695683",symbol:"sand"},{chainId:137,address:"0x2934b36ca9a4b31e633c5be670c8c8b28b6aa015",symbol:"thx"},{chainId:137,address:"0x2f800db0fdb5223b3c3f354886d907a671414a7f",symbol:"bct"},{chainId:137,address:"0x2e1ad108ff1d8c782fcbbb89aad783ac49586756",symbol:"tusd"},{chainId:137,address:"0x3809dcdd5dde24b37abe64a5a339784c3323c44f",symbol:"swap"},{chainId:137,address:"0x7fbc10850cae055b27039af31bd258430e714c62",symbol:"ubt"},{chainId:137,address:"0x2791bca1f2de4661ed88a30c99a7a9449aa84174",symbol:"usdc"},{chainId:137,address:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",symbol:"weth"},{chainId:137,address:"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",symbol:"wmatic"},{chainId:137,address:"0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6",symbol:"wbtc"},{chainId:137,address:"0x24834bbec7e39ef42f4a75eaf8e5b6486d3f0e57",symbol:"lunc"},{chainId:137,address:"0xf153eff70dc0bf3b085134928daeea248d9b30d0",symbol:"xmark"},{chainId:42161,address:"0x9f20de1fc9b161b34089cbeae888168b44b03461",symbol:"arbis"},{chainId:42161,address:"0x040d1edc9569d4bab2d15287dc5a4f10f56a56b8",symbol:"bal"},{chainId:42161,address:"0x031d35296154279dc1984dcd93e392b1f946737b",symbol:"cap"},{chainId:42161,address:"0xf97f4df75117a78c1a5a0dbb814af92458539fb4",symbol:"link"},{chainId:42161,address:"0x354a6da3fcde098f8389cad84b0182725c6c91de",symbol:"comp"},{chainId:42161,address:"0xf4d48ce3ee1ac3651998971541badbb9a14d7234",symbol:"cream"},{chainId:42161,address:"0x11cdb42b0eb46d95f990bedd4695a6e3fa034978",symbol:"crv"},{chainId:42161,address:"0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",symbol:"dai"},{chainId:42161,address:"0x8038f3c971414fd1fc220ba727f2d4a0fc98cb65",symbol:"dht"},{chainId:42161,address:"0xf0b5ceefc89684889e5f7e0a7775bd100fcd3709",symbol:"dusd"},{chainId:42161,address:"0x6c2c06790b3e3e3c38e12ee22f8183b37a13ee55",symbol:"dpx"},{chainId:42161,address:"0x32eb7902d4134bf98a28b963d26de779af92a212",symbol:"rdpx"},{chainId:42161,address:"0xc3ae0333f0f34aa734d5493276223d95b8f9cb37",symbol:"dxd"},{chainId:42161,address:"0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a",symbol:"gmx"},{chainId:42161,address:"0xa0b862f60edef4452f25b4160f177db44deb6cf1",symbol:"gno"},{chainId:42161,address:"0xb965029343d55189c25a7f3e0c9394dc0f5d41b1",symbol:"ndx"},{chainId:42161,address:"0x539bde0d7dbd336b79148aa742883198bbf60342",symbol:"magic"},{chainId:42161,address:"0x4e352cf164e64adcbad318c3a1e222e9eba4ce42",symbol:"mcb"},{chainId:42161,address:"0x3f56e0c36d275367b8c502090edf38289b3dea0d",symbol:"mimatic"},{chainId:42161,address:"0x965772e0e9c84b6f359c8597c891108dcf1c5b1a",symbol:"pickle"},{chainId:42161,address:"0x6694340fc020c5e6b96567843da2df01b2ce1eb6",symbol:"stg"},{chainId:42161,address:"0xd4d42f0b6def4ce0383636770ef773390d85c61a",symbol:"sushi"},{chainId:42161,address:"0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",symbol:"usdt"},{chainId:42161,address:"0x23a941036ae778ac51ab04cea08ed6e2fe103614",symbol:"grt"},{chainId:42161,address:"0xa72159fc390f0e3c6d415e658264c7c4051e9b87",symbol:"tcr"},{chainId:42161,address:"0x4d15a3a2286d883af0aa1b3f21367843fac63e07",symbol:"tusd"},{chainId:42161,address:"0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0",symbol:"uni"},{chainId:42161,address:"0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",symbol:"usdc"},{chainId:42161,address:"0xa684cd057951541187f288294a1e1c2646aa2d24",symbol:"vsta"},{chainId:42161,address:"0x64343594ab9b56e99087bfa6f2335db24c2d1f17",symbol:"vst"},{chainId:42161,address:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",symbol:"weth"},{chainId:42161,address:"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",symbol:"wbtc"},{chainId:42161,address:"0x82e3a8f066a6989666b031d916c43672085b1582",symbol:"yfi"},{chainId:16116,address:"0x5a89E11Cb554E00c2f51C4bb7F05bc7Ab0Fa6351",symbol:"weth"},{chainId:9372,address:"0x5200000000000000000000000000000000000001",symbol:"weth"},{chainId:248,address:"0x5200000000000000000000000000000000000001",symbol:"weth"}];class Rr{constructor(e,t,a){this.pools=new ki({url:e.urls.subgraph,chainId:e.chainId}),this.poolsOnChain=new Ni({url:e.urls.subgraph,chainId:e.chainId,provider:t,multicall:e.addresses.contracts.multicall,vault:e.addresses.contracts.vault,query:a}),this.poolShares=new Fi(e.urls.subgraph,e.chainId),this.poolJoinExits=new Ri(e.urls.subgraph,e.chainId),e.urls.gaugesSubgraph&&(this.poolGauges=new Ci(e.urls.gaugesSubgraph,e.chainId),this.gaugeShares=new Ai(e.urls.gaugesSubgraph,e.chainId)),e.urls.blockNumberSubgraph&&(this.blockNumbers=new kr(e.urls.blockNumberSubgraph));this.yesterdaysPools=new ki({url:e.urls.subgraph,chainId:e.chainId,blockHeight:async()=>{const e=await t.getBlockNumber();return Number(e)-5e3}});const n=Dr.filter((t=>t.chainId==e.chainId)).map((e=>e.address)),s=new Li(n,e.chainId),i=new Gi(e.urls.subgraph,e.chainId),r=new Vi(e.addresses.contracts.multicall,t,e.chainId);this.tokenPrices=new qi(s,i,r);const o=new Ui(e.chainId);this.tokenHistoricalPrices=new Wi(o,r),this.tokenMeta=new Mi([]),e.urls.gaugesSubgraph&&(this.liquidityGauges=new Oi(e.urls.gaugesSubgraph,e.addresses.contracts.multicall,e.addresses.contracts.gaugeController||"",e.chainId,t)),e.addresses.contracts.feeDistributor&&e.addresses.tokens.bal&&e.addresses.tokens.veBal&&e.addresses.tokens.bbaUsd&&(this.feeDistributor=new Zi(e.addresses.contracts.multicall,e.addresses.contracts.feeDistributor,e.addresses.tokens.bal,e.addresses.tokens.veBal,e.addresses.tokens.bbaUsd,t)),this.feeCollector=new zi(e.addresses.contracts.vault,t),e.addresses.contracts.protocolFeePercentagesProvider&&(this.protocolFees=new tr(e.addresses.contracts.multicall,e.addresses.contracts.protocolFeePercentagesProvider,t)),this.tokenYields=new Br(e.chainId)}}!function(e){e[e.Direct=0]="Direct",e[e.TokenIn=1]="TokenIn",e[e.TokenOut=2]="TokenOut",e[e.Middle=3]="Middle"}(Nr||(Nr={})),function(e){e[e.Swap=0]="Swap",e[e.BatchSwap=1]="BatchSwap",e[e.Join=2]="Join",e[e.Exit=3]="Exit"}(Cr||(Cr={}));const Fr={type:Cr.BatchSwap,swaps:[],opRef:[],minOut:"0",assets:[],hasTokenIn:!1,hasTokenOut:!1,fromInternal:!1,toInternal:!1,limits:[],approveTokens:[],sender:"",receiver:""},Mr=new t.Interface(gs);function Lr(e,t){return e.some((e=>e.address.toLowerCase()===t.toLowerCase()))}function Ur(e,t){const a=t[e.assetOutIndex],n=D(e.poolId);return a.toLowerCase()===n.toLowerCase()}function Gr(e,t){const a=t[e.assetInIndex],n=D(e.poolId);return a.toLowerCase()===n.toLowerCase()}function qr(e,t,a){let n={};var s;return e!==Nr.TokenIn&&e!==Nr.Middle||(s=a,n={index:t,key:cs.toChainedReference(s)},a++),[n,a]}function Wr(e,t){return ze(n.BigNumber.from(e),n.BigNumber.from(t)).toString()}function $r(e,t,a,n){let s=e.amount;return(a===Nr.TokenOut||a===Nr.Middle&&t===Cr.Join||a===Nr.Middle&&t===Cr.Exit)&&(s=cs.toChainedReference(n-1).toString()),s}function Vr(e,t,a,n){let s;return s=a===e&&n===t?Nr.Direct:a===e?Nr.TokenIn:n===t?Nr.TokenOut:Nr.Middle,s}function Hr(e,t){const s=function(e){const t=[],a=[],n=[];for(const s of e)s.type===Cr.Exit||s.type===Cr.Join?s.hasTokenIn?t.push(s):s.hasTokenOut?a.push(s):n.push(s):n.push(s);return[...t,...n,...a]}(e),i=function(e,t){const s=[];let i=c.cloneDeep(Fr);i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"));let r=!0,o={};for(const d of e)d.type===Cr.Swap?(r&&(o=d,r=!1),d.isBptIn&&i.approveTokens.push(d.assets[d.swap.assetInIndex]),d.fromInternal===o.fromInternal&&d.toInternal===o.toInternal&&d.receiver===o.receiver&&d.sender===o.sender||i.swaps.length>0&&(s.push(i),i=c.cloneDeep(Fr),i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"))),i.swaps.push(d.swap),i.opRef.push(...d.opRef),i.fromInternal=d.fromInternal,i.toInternal=d.toInternal,i.sender=d.sender,i.receiver=d.receiver,d.hasTokenIn?(i.hasTokenIn=!0,i.limits[d.swap.assetInIndex]=i.limits[d.swap.assetInIndex].add(d.amountIn)):i.limits[d.swap.assetInIndex]=a.MaxInt256,d.hasTokenOut&&(i.hasTokenOut=!0,i.limits[d.swap.assetOutIndex]=i.limits[d.swap.assetOutIndex].sub(d.minOut)),o=d):(i.swaps.length>0&&(s.push(i),i=c.cloneDeep(Fr),i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"))),s.push(d));return i.swaps.length>0&&s.push(i),s}(s,t);return i}function jr(e,t,a,n,s,i,r,o){var d;const c=Vr(t,a,e.assetInIndex,e.assetOutIndex),l=$r(e,Cr.Join,c,n),p=Wr(null!==(d=e.returnAmount)&&void 0!==d?d:"0",i),[u,y]=qr(c,e.assetOutIndex,n);let b=o,m=!0,f=!1;c!==Nr.Direct&&c!==Nr.TokenIn||(b=r,m=!1,f=!0);let h=o,T=!1;c!==Nr.Direct&&c!==Nr.TokenOut||(h=r,T=!0);return[{type:Cr.Join,poolId:e.poolId,tokenIn:s[e.assetInIndex],bpt:s[e.assetOutIndex],opRef:u,minOut:p,amountIn:l,assets:s,actionStep:c,sender:b,receiver:h,fromInternal:m,hasTokenIn:f,hasTokenOut:T},y]}function Kr(e,t,a,n,s,i,r,o){var d;const c=Vr(t,a,e.assetInIndex,e.assetOutIndex),l=$r(e,Cr.Exit,c,n),p=Wr(null!==(d=e.returnAmount)&&void 0!==d?d:"0",i),[u,y]=qr(c,e.assetOutIndex,n);let b=o,m=!1;c!==Nr.Direct&&c!==Nr.TokenIn||(b=r,m=!0);let f=!1,h=!0,T=o;c!==Nr.Direct&&c!==Nr.TokenOut||(T=r,h=!1,f=!0);return[{type:Cr.Exit,poolId:e.poolId,tokenOut:s[e.assetOutIndex],bpt:s[e.assetInIndex],opRef:u.key?[u]:[],minOut:p,amountIn:l,assets:s,actionStep:c,sender:b,receiver:T,toInternal:h,hasTokenIn:m,hasTokenOut:f},y]}function Zr(e,t,a,n,s,i,r,o,d){var c;const l=Vr(t,a,e.assetInIndex,e.assetOutIndex),p=$r(e,Cr.Swap,l,n);e.amount=p;const u=Wr(null!==(c=e.returnAmount)&&void 0!==c?c:"0",i),[y,b]=qr(l,e.assetOutIndex,n),m=l===Nr.Direct||l===Nr.TokenIn,f=l===Nr.Direct||l===Nr.TokenOut,h=Lr(r,s[e.assetInIndex]);let T=!0;(m||h)&&(T=!1);let g,I,w=!0;(f||Lr(r,s[e.assetOutIndex]))&&(w=!1),g=m?o:d,I=f?o:d;return[{type:Cr.Swap,opRef:y.key?[y]:[],minOut:u,amountIn:p,assets:s,swap:e,hasTokenIn:m,hasTokenOut:f,fromInternal:T,toInternal:w,isBptIn:h,sender:g,receiver:I},b]}function Xr(e,t,a){const n=e.tokensList,s=new W(a),[i]=s.sortTokens(n),r=t.tokenOut,o=i.findIndex((e=>e.toLowerCase()===r.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.minOut;const c=t.amountIn,l={assets:i,minAmountsOut:d,userData:P.exitExactBPTInForOneTokenOut(c,o),toInternalBalance:t.toInternal,poolId:t.poolId,poolKind:0,sender:t.sender,recipient:t.receiver,outputReferences:t.opRef,exitPoolRequest:{}},p=cs.constructExitCall(l),u=t.hasTokenOut?d[o]:"0";return[p,t.hasTokenIn?c:"0",u]}function Jr(e,t,a){const n=e.tokensList,s=new W(a),[i]=s.sortTokens(n),r=t.tokenIn,o=i.findIndex((e=>e.toLowerCase()===r.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.amountIn;const c=t.minOut,l=P.joinExactTokensInForBPTOut(d,c),p={poolId:t.poolId,sender:t.sender,recipient:t.receiver,kind:0,joinPoolRequest:{assets:i,maxAmountsIn:d,userData:l,fromInternalBalance:t.fromInternal},value:"0",outputReference:t.opRef.key?t.opRef.key.toString():"0"},u=cs.encodeJoinPool(p),y=t.hasTokenOut?c:"0";return[u,t.hasTokenIn?d[o]:"0",y]}function Yr(t,s,i){const r=[];for(const e of t.approveTokens){const t=cs.encodeApproveVault(e,a.MaxUint256.toString());r.push(t)}const o={sender:t.sender,recipient:t.receiver,fromInternalBalance:t.fromInternal,toInternalBalance:t.toInternal},d={swapType:e.SwapType.SwapExactIn,swaps:t.swaps,assets:t.assets,funds:o,limits:t.limits.map((e=>e.toString())),deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:t.opRef},c=cs.encodeBatchSwap(d);r.push(c);const l=t.assets.findIndex((e=>e.toLowerCase()===s.toLowerCase())),p=t.assets.findIndex((e=>e.toLowerCase()===i.toLowerCase()));return[r,t.hasTokenIn?t.limits[l].toString():"0",t.hasTokenOut?t.limits[p].abs().toString():"0"]}Object.defineProperty(e,"PoolFilter",{enumerable:!0,get:function(){return l.PoolFilter}}),Object.defineProperty(e,"RouteProposer",{enumerable:!0,get:function(){return l.RouteProposer}}),Object.defineProperty(e,"SOR",{enumerable:!0,get:function(){return l.SOR}}),Object.defineProperty(e,"SwapTypes",{enumerable:!0,get:function(){return l.SwapTypes}}),Object.defineProperty(e,"formatSequence",{enumerable:!0,get:function(){return l.formatSequence}}),Object.defineProperty(e,"getTokenAddressesForSwap",{enumerable:!0,get:function(){return l.getTokenAddressesForSwap}}),Object.defineProperty(e,"parseToPoolsDict",{enumerable:!0,get:function(){return l.parseToPoolsDict}}),Object.defineProperty(e,"phantomStableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.phantomStableBPTForTokensZeroPriceImpact}}),Object.defineProperty(e,"queryBatchSwapTokensIn",{enumerable:!0,get:function(){return l.queryBatchSwapTokensIn}}),Object.defineProperty(e,"queryBatchSwapTokensOut",{enumerable:!0,get:function(){return l.queryBatchSwapTokensOut}}),Object.defineProperty(e,"stableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.stableBPTForTokensZeroPriceImpact}}),Object.defineProperty(e,"weightedBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.weightedBPTForTokensZeroPriceImpact}}),e.APR_THRESHOLD=1e4,e.AaveHelpers=class{static async getRate(e,t){const a=new i.Contract(e,G,t);return(await a.getRate()).toString()}},e.AaveRates=Vi,e.AssetHelpers=W,e.BalancerAPIArgsFormatter=He,e.BalancerError=st,e.BalancerErrors=V,e.BalancerMinterAuthorization=Z,e.BalancerSDK=class{constructor(e,t=new jn(e),a=new ls(e)){this.config=e,this.sor=t,this.subgraph=a,this.networkConfig=Hn(e),this.provider=t.provider,this.data=new Rr(this.networkConfig,t.provider,e.subgraphQuery),this.swaps=new os(this.config),this.relayer=new cs(this.swaps),this.pricing=new ps(e,this.swaps),this.pools=new Ti(this.networkConfig,this.data),this.balancerContracts=new Es(this.networkConfig.addresses.contracts,t.provider),this.zaps=new Hs(this.networkConfig.chainId)}get rpcProvider(){return this.sor.provider}get contracts(){return this.balancerContracts.contracts}},e.BlockNumberRepository=kr,e.CoingeckoHistoricalPriceRepository=Ui,e.CoingeckoPriceRepository=Li,e.ComposableStablePoolEncoder=v,e.Data=Rr,e.Debouncer=Ue,e.FeeCollectorRepository=zi,e.FeeDistributorRepository=Zi,e.GaugeControllerMulticallRepository=Ii,e.GaugeSharesRepository=Ai,e.GraphQLArgsBuilder=Ke,e.HistoricalPriceProvider=Wi,e.Liquidity=$t,e.LiquidityGaugeSubgraphRPCProvider=Oi,e.LiquidityGaugesMulticallRepository=Pi,e.LiquidityGaugesSubgraphRepository=_i,e.ManagedPoolEncoder=_,e.POOLS=function(e){return U[e]?U[e]:L},e.PoolGaugesRepository=Ci,e.PoolJoinExitRepository=Ri,e.PoolSharesRepository=Fi,e.Pools=Ti,e.PoolsBalancerAPIRepository=class{constructor(e){var t,a;this.pools=[],this.skip=0,this.client=new vi(e.url,e.apiKey);this.query={args:Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||{chainId:248,orderBy:"totalLiquidity",orderDirection:"desc",where:{swapEnabled:{eq:!0}}}),attrs:Object.assign({},(null===(a=e.query)||void 0===a?void 0:a.attrs)||{id:!0,address:!0})},delete this.query.args.skip}fetchFromCache(e){const t=(null==e?void 0:e.first)||10,a=(null==e?void 0:e.skip)||0,n=this.pools.slice(a,t+a);return this.skip=a+t,n}async fetch(e){if(this.pools.length>((null==e?void 0:e.first)||10)+((null==e?void 0:e.skip)||0))return this.fetchFromCache(e);this.nextToken&&(this.query.args.nextToken=this.nextToken),(null==e?void 0:e.first)&&(this.query.args.first=2*e.first);const t=new Ke(this.query.args).format(new He),a=this.query.attrs;a.nextToken=!0;const n={pools:{__args:t,...a}},s=(await this.client.get(n)).pools;return this.nextToken=s.nextToken,this.pools=this.pools.concat(s.pools.map(this.format)),this.skip=this.pools.length,this.fetchFromCache(e)}async find(e){return 0==this.pools.length&&await this.fetch(),this.findBy("id",e)}async findBy(e,t){0==this.pools.length&&await this.fetch();const a=this.pools.find((a=>a[e]==t));if(a)return this.format(a)}format(e){var t,a,n,s;if(null===(t=e.apr)||void 0===t?void 0:t.rewardAprs.breakdown){const t=JSON.parse(null===(a=e.apr)||void 0===a?void 0:a.rewardAprs.breakdown);e.apr.rewardAprs.breakdown=t}if(null===(n=e.apr)||void 0===n?void 0:n.tokenAprs.breakdown){const t=JSON.parse(null===(s=e.apr)||void 0===s?void 0:s.tokenAprs.breakdown);e.apr.tokenAprs.breakdown=t}return e}},e.PoolsFallbackRepository=class{constructor(e,t={}){this.providers=e,this.currentProviderIdx=0,this.timeout=t.timeout||1e4}async fetch(e){return this.fallbackQuery("fetch",[e])}get currentProvider(){if(this.providers.length&&!(this.currentProviderIdx>=this.providers.length))return this.providers[this.currentProviderIdx]}async find(e){return this.fallbackQuery("find",[e])}async findBy(e,t){return this.fallbackQuery("findBy",[e,t])}async fallbackQuery(e,t){if(this.currentProviderIdx>=this.providers.length)throw new Error("No working providers found");let a;try{const n=this.providers[this.currentProviderIdx];a=await Promise.race([n[e].apply(n,t),new Promise(((e,t)=>setTimeout((()=>t(new Error("timeout"))),this.timeout)))])}catch(n){const s=n.message;"timeout"===s?console.error("Provider "+this.currentProviderIdx+" timed out, falling back to next provider"):console.error("Provider "+this.currentProviderIdx+" failed with error: ",s,", falling back to next provider"),this.currentProviderIdx++,a=await this.fallbackQuery.call(this,e,t)}return a}},e.PoolsStaticRepository=class{constructor(e){this.pools=e}async find(e){return this.pools.find((t=>t.id.toLowerCase()===e.toLowerCase()))}async findBy(e,t){return this.pools.find((a=>a[e]===t))}async all(){return this.pools}async where(e){return(await this.all()).filter(e)}},e.PoolsSubgraphOnChainRepository=Ni,e.PoolsSubgraphRepository=ki,e.ProtocolFeesProvider=tr,e.Relayer=cs,e.RelayerAuthorization=K,e.SHALLOW_COMPOSABLE_STABLE_BUFFER=1e6,e.Sor=jn,e.StablePoolEncoder=S,e.StaticTokenPriceProvider=class{constructor(e){this.tokenPrices=Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLowerCase(),t])))}async find(e){const t=e.toLowerCase(),a=this.tokenPrices[t];if(a)return a}async findBy(e,t){if("address"==e)return this.find(t)}},e.StaticTokenProvider=Mi,e.Subgraph=ls,e.SubgraphArgsFormatter=je,e.SubgraphPriceRepository=Gi,e.Swaps=os,e.TokenPriceProvider=qi,e.TokenYieldsRepository=Br,e.WeightedPoolEncoder=P,e.accountToAddress=H,e.addressMapIn=Me,e.balEmissions=Js,e.bn=e=>n.parseFixed(`${e}`,18),e.buildRelayerCalls=function(t,a,s,i,r,o,d){const c=Hr(function(e,t,a,n,s,i,r,o){const d=n.findIndex((t=>t.toLowerCase()===e.toLowerCase())),c=n.findIndex((e=>e.toLowerCase()===t.toLowerCase())),l=[];let p=0,u={};for(const e of a)if(Ur(e,n)){const[t,a]=jr(e,d,c,p,n,s,r,o);p=a,l.push(t),u=t}else{if(!Gr(e,n)){const t=e.amount,[a,y]=Zr(e,d,c,p,n,s,i,r,o);u.type===Cr.Swap&&"0"===t&&(u.receiver=u.sender,u.toInternal=u.fromInternal,u.opRef=[],a.sender=u.receiver,a.fromInternal=u.fromInternal,a.amountIn="0",a.swap.amount="0"),p=y,l.push(a),u=a;continue}{const[t,a]=Kr(e,d,c,p,n,s,r,o);p=a,l.push(t),u=t}}return l}(t.tokenIn,t.tokenOut,t.swaps,t.tokenAddresses,o,a,s,i),t.tokenAddresses),l=[],p=[],u=[];d&&l.push(function(e,t){return cs.encodeSetRelayerApproval(t,!0,e)}(d,i));for(const s of c){if(s.type===Cr.Exit){const t=a.find((e=>e.id===s.poolId));if(void 0===t)throw new st(e.BalancerErrorCode.NO_POOL_DATA);const[i,o,d]=Xr(t,s,r);l.push(i),p.push(n.BigNumber.from(o)),u.push(n.BigNumber.from(d))}if(s.type===Cr.Join){const t=a.find((e=>e.id===s.poolId));if(void 0===t)throw new st(e.BalancerErrorCode.NO_POOL_DATA);const[i,o,d]=Jr(t,s,r);l.push(i),p.push(n.BigNumber.from(o)),u.push(n.BigNumber.from(d))}if(s.type===Cr.BatchSwap){const[e,a,i]=Yr(s,t.tokenIn,t.tokenOut);l.push(...e),p.push(n.BigNumber.from(a)),u.push(n.BigNumber.from(i))}}return function(t,a,s,i){const r=t.reduce(((e=n.BigNumber.from(0),t)=>e.add(t))),o=a.reduce(((e=n.BigNumber.from(0),t)=>e.add(t))),d=o.sub(ze(s.returnAmount,n.BigNumber.from(i)));if(!r.eq(s.swapAmount)||!d.lt("3"))throw new st(e.BalancerErrorCode.RELAY_SWAP_AMOUNTS)}(p,u,t,o),{to:i,data:Mr.encodeFunctionData("multicall",[l]),rawCalls:l}},e.canUseJoinExit=function(e,t,n){return e!==l.SwapTypes.SwapExactOut&&t.toLowerCase()!==a.AddressZero.toLowerCase()&&n.toLowerCase()!==a.AddressZero.toLowerCase()},e.formatFixed=qe,e.formatFromBigInt18=function(e){return n.formatFixed(n.BigNumber.from(e),18)},e.getLimitsForSlippage=Xe,e.getPoolAddress=D,e.getPoolNonce=F,e.getPoolSpecialization=R,e.insert=Ve,e.isNormalizedWeights=e=>{const t=e.reduce(((e,t)=>e.add(t)),a.Zero);return t.eq(a.WeiPerEther)},e.isSameAddress=$e,e.parseFixed=Ge,e.parsePoolInfo=se,e.parseToBigInt18=We,e.signPermit=async(e,t,s,i,o=a.MaxUint256,d)=>{const{chainId:c}=await e.provider.getNetwork(),l=await t.getAddress();d||(d=await e.nonces(l));const p={name:await e.name(),version:"1",chainId:c,verifyingContract:e.address},u={owner:l,spender:await H(s),value:i,nonce:d,deadline:o},y=await t._signTypedData(p,{Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u);return{...r.splitSignature(y),deadline:n.BigNumber.from(o),nonce:n.BigNumber.from(d)}},e.someJoinExit=function(e,t,a){return t.some((t=>function(e,t,a){const n=e.find((e=>e.id===t.poolId));return"Weighted"===(null==n?void 0:n.poolType)&&[a[t.assetInIndex],a[t.assetOutIndex]].includes(n.address)}(e,t,a)))},e.splitPoolId=e=>({address:D(e),specialization:R(e),nonce:F(e)}),e.toNormalizedWeights=function(e){if(100==e.length)return Array(100).fill(a.WeiPerEther.div(100));const t=e.reduce(((e,t)=>e.add(t)),a.Zero);if(t.eq(a.WeiPerEther))return e;const n=[];let s=a.Zero;for(let i=0;i<e.length;i++)i<e.length-1?(n[i]=e[i].mul(a.WeiPerEther).div(t),s=s.add(n[i])):n[i]=a.WeiPerEther.sub(s);return n},e.tokenAddressForPricing=Fe,e.tokensToTokenPrices=function(e){const t={};return e.forEach((e=>{e.price&&(t[e.address]=e.price)})),t},e.unwrapToken=Le,Object.defineProperty(e,"__esModule",{value:!0})}));
489
+ //# sourceMappingURL=index.umd.js.map