@defiverse/balancer-sdk-megaeth 0.1.260 → 0.1.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -485,5 +485,5 @@ ${Da`
|
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
`,On=(e,t,a)=>e();function vn(e){return sn(new u.GraphQLClient(e))}function kn(e){return function(e,t=On){return{GaugeShare:(a,n)=>t((t=>e.request(An,a,{...n,...t})),"GaugeShare","query"),GaugeShares:(a,n)=>t((t=>e.request(Sn,a,{...n,...t})),"GaugeShares","query"),LiquidityGauges:(a,n)=>t((t=>e.request(Pn,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(_n,a,{...n,...t})),"PoolGauges","query")}}(new u.GraphQLClient(e))}const Nn=["function aggregate(tuple[](address target, bytes callData) memory calls) public view returns (uint256 blockNumber, bytes[] memory returnData)"],Cn=(e,t)=>new s.Contract(e,Nn,t);class Dn{constructor(t,a,n,s={}){this.options={},this.calls=[],this.paths=[],this.multiAddress=t,this.provider=a,this.interface=new e.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)=>d.set(t,this.paths[a],e.length>1?e:e[0]))),this.calls=[],this.paths=[],t}async executeMulticall(){const e=Cn(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"}],Rn=[{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"}],Mn=[{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"}],Ln=[{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"}],Un=[{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 Gn(e,t,n,s){if(0===e.length)return e;const r=Object.values(Object.fromEntries([...c.Vault__factory.abi,...U,...Fn,...Rn,...Mn,...Ln,...Un].map((e=>[e.name,e])))),i=new Dn(t,s,r),o=Object.values(p.PoolFilter),d=[];e.forEach((e=>{o.includes(e.poolType)?(d.push(e),i.call(`${e.id}.poolTokens`,n,"getPoolTokens",[e.id]),i.call(`${e.id}.totalSupply`,e.address,"totalSupply"),(e.poolType.includes("Linear")||"StablePhantom"===e.poolType)&&i.call(`${e.id}.virtualSupply`,e.address,"getVirtualSupply"),"ComposableStable"===e.poolType&&i.call(`${e.id}.actualSupply`,e.address,"getActualSupply"),"Weighted"===e.poolType||"LiquidityBootstrapping"===e.poolType||"Investment"===e.poolType?(i.call(`${e.id}.weights`,e.address,"getNormalizedWeights"),i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Stable"===e.poolType||"MetaStable"===e.poolType||"StablePhantom"===e.poolType||"ComposableStable"===e.poolType?(i.call(`${e.id}.amp`,e.address,"getAmplificationParameter"),i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Element"===e.poolType?i.call(`${e.id}.swapFee`,e.address,"percentFee"):e.poolType.toString().includes("Linear")?(i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage"),i.call(`${e.id}.targets`,e.address,"getTargets"),i.call(`${e.id}.rate`,e.address,"getWrappedTokenRate")):e.poolType.toString().includes("Gyro")&&i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):console.error(`Unknown pool type: ${e.poolType} ${e.id}`)}));let l={};try{l=await i.execute()}catch(e){throw"Issue with multicall execution."}const u=[];return Object.entries(l).forEach((([e,t],n)=>{try{const{poolTokens:s,swapFee:r,weights:i,totalSupply:o,virtualSupply:p,actualSupply:c}=t;if("Stable"===d[n].poolType||"MetaStable"===d[n].poolType||"StablePhantom"===d[n].poolType||"ComposableStable"===d[n].poolType){if(!t.amp)return void console.error(`Stable Pool Missing Amp: ${e}`);d[n].amp=a.formatFixed(t.amp[0],3)}if(d[n].poolType.includes("Linear")){if(!t.targets)return void console.error(`Linear Pool Missing Targets: ${e}`);d[n].lowerTarget=a.formatFixed(t.targets[0],18),d[n].upperTarget=a.formatFixed(t.targets[1],18);const s=d[n].wrappedIndex;if(void 0===s||void 0===t.rate)return void console.error(`Linear Pool Missing WrappedIndex or PriceRate: ${e}`);d[n].tokens[s].priceRate=a.formatFixed(t.rate,18)}if(d[n].swapFee=a.formatFixed(r,18),s.tokens.forEach(((t,r)=>{const o=d[n].tokens.find((e=>We(e.address,t)));if(!o)throw`Pool Missing Expected Token: ${e} ${t}`;o.balance=a.formatFixed(s.balances[r],o.decimals),i&&(o.weight=a.formatFixed(i[r],18))})),d[n].poolType.includes("Linear")||"StablePhantom"===d[n].poolType){if(void 0===p)return void console.error(`Pool with pre-minted BPT missing Virtual Supply: ${e}`);d[n].totalShares=a.formatFixed(p,18)}else if("ComposableStable"===d[n].poolType){if(void 0===c)return void console.error(`ComposableStable missing Actual Supply: ${e}`);d[n].totalShares=a.formatFixed(c,18)}else d[n].totalShares=a.formatFixed(o,18);u.push(d[n])}catch(e){throw`Issue with pool onchain data: ${e}`}})),u}class qn{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?d.parseInt(e.expiryTime):void 0,unitSeconds:e.unitSeconds?d.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=>We(t,e.address)))})));return!1===this.sorConfig.fetchOnChainBalances?e:Gn(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:"0.000000000001"},orderBy:Ea.TotalLiquidity,orderDirection:fa.Desc});return[...e,...t,...a]}}class Wn{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 E.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 $n{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=d.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 Vn(e){var t,a;if("number"==typeof e.network){const a=et[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 Hn extends p.SOR{constructor(e){const t=Vn(e),a=Hn.getSorConfig(e),n=Hn.getSorNetworkConfig(t),s=new l.JsonRpcProvider(e.rpcUrl,e.network),r=vn(t.urls.subgraph);super(s,n,Hn.getPoolDataService(t,a,s,r),Hn.getTokenPriceService(t,a,r))}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 qn(n,a,e,t)}static getTokenPriceService(e,t,a){return"object"==typeof t.tokenPriceService?t.tokenPriceService:("subgraph"===t.tokenPriceService&&new $n(a,e.addresses.tokens.wrappedNativeAsset),new Wn(e.chainId))}}function jn(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 Kn(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 Zn(e){return-1*Number(e)}function Xn(e){return d.sum(e)}var Jn=[{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 Yn={"0xae7ab96520de3a18e5e111b5eaab095312d7fe84":"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0","0xd46ba6d942050d489dbd938a2c909a5d5039a161":"0xedb171c18ce90b633db442f2a6f72874093b49ef","0x1e6bb68acec8fefbd87d192be09bb274170a0548":"0xF03387d8d0FF326ab586A58E0ab4121d106147DF"};function zn(e){let t=e;return Yn.hasOwnProperty(e)&&(t=Yn[e]),t}var Qn;function es(e,t,a){const{tokens:n,contracts:s}=tt(a);let r={id:Qn.vault,address:s.vault};return n.stETH&&s.lidoRelayer&&[e,t].includes(n.stETH)&&(r={id:Qn.lido,address:s.lidoRelayer}),r}function ts(e){let t=c.Vault__factory.abi;e.id===Qn.lido&&(t=Jn);return t.filter((e=>e.name&&["swap","batchSwap"].includes(e.name)))}function as(e){return{amount:e,max:t=>e.mul(1e3+t).div(1e3),min:t=>e.mul(1e3-t).div(1e3)}}function ns(e,t){const a=t===exports.SwapType.SwapExactIn?e.swapAmount:e.returnAmount,n=t===exports.SwapType.SwapExactIn?e.returnAmount:e.swapAmount,s=t===exports.SwapType.SwapExactIn?e.swapAmountForSwaps||e.swapAmount:e.returnAmountFromSwaps||e.returnAmount,r=t===exports.SwapType.SwapExactIn?e.returnAmountFromSwaps||e.returnAmount:e.swapAmountForSwaps||e.swapAmount,i=zn(e.tokenIn),o=zn(e.tokenOut);return{...e,amountIn:a,amountOut:n,amountInForLimits:as(s),amountOutForLimits:as(r),tokenInForSwaps:i,tokenOutFromSwaps:o}}!function(e){e[e.vault=1]="vault",e[e.lido=2]="lido"}(Qn||(Qn={}));class ss{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="swap",this.swapInfo=ns(e,t),this.relayer=es(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===exports.SwapType.SwapExactOut?this.swapInfo.amountOutForLimits.amount:this.swapInfo.amountInForLimits.amount}setLimits(e){this.limit=this.kind===exports.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(e).toString():this.swapInfo.amountInForLimits.max(e).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 e.Interface(this.fragment()).encodeFunctionData("swap",Object.values(this.attributes()))}value(e){let n=a.BigNumber.from(0);return this.swapInfo.tokenIn===t.AddressZero&&(n=this.kind===exports.SwapType.SwapExactIn?this.swapInfo.amountIn:this.swapInfo.amountInForLimits.max(e)),n}to(){return this.relayer.address}fragment(){return ts(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=ns(e,t),this.relayer=es(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(e){return this.kind===exports.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(e):this.swapInfo.amountOutForLimits.amount}maxAmountIn(e){return this.kind===exports.SwapType.SwapExactOut?this.swapInfo.amountInForLimits.max(e):this.swapInfo.amountInForLimits.amount}setLimits(e){this.limits=this.swapInfo.tokenAddresses.map((t=>{let n=a.BigNumber.from(0);return t===this.swapInfo.tokenInForSwaps&&(n=this.maxAmountIn(e)),t===this.swapInfo.tokenOutFromSwaps&&(n=this.minAmountOut(e).mul(-1)),n})).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 e.Interface(this.fragment()).encodeFunctionData("batchSwap",Object.values(this.attributes()))}value(e){let n=a.BigNumber.from(0);return this.swapInfo.tokenIn===t.AddressZero&&(n=this.maxAmountIn(e)),n}to(){return this.relayer.address}fragment(){return ts(this.relayer).filter((e=>e.name===this.functionName))}}class is{constructor(e){e instanceof p.SOR?(this.sor=e,this.chainId=this.sor.provider._network.chainId):(this.sor=new Hn(e),this.chainId=e.network),this.vaultContract=c.Vault__factory.connect(Qe,this.sor.provider)}static getLimitsForSlippage(e,t,a,n,s,r){return Ze(e,t,a,n,s,r).map((e=>e.toString()))}async findRouteGivenIn({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s=4}){return this.sor.getSwaps(e,t,p.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,p.SwapTypes.SwapExactOut,a,{gasPrice:n,maxPools:s})}buildSwap({userAddress:e,recipient:t,swapInfo:a,kind:n,deadline:s,maxSlippage:r}){if(!this.chainId)throw"Missing network configuration";const i=a.swaps.length>1?new rs(a,n,this.chainId):new ss(a,n,this.chainId);i.setFunds(e,t),i.setDeadline(s),i.setLimits(r);const o=i.to(),{functionName:d}=i;return{to:o,functionName:d,attributes:i.attributes(),data:i.data(),value:i.value(r)}}static encodeBatchSwap(e){return c.Vault__factory.createInterface().encodeFunctionData("batchSwap",[e.kind,e.swaps,e.assets,e.funds,e.limits,e.deadline])}static encodeSimpleFlashSwap(e){return this.encodeBatchSwap(function({poolIds:e,assets:t,flashLoanAmount:a,walletAddress:n}){jn({poolIds:e,assets:t});const s=Kn(e,a),r={sender:n,fromInternalBalance:!1,recipient:n,toInternalBalance:!1};return{kind:exports.SwapType.SwapExactIn,swaps:s,assets:t,funds:r,limits:["0","0"],deadline:"999999999999999999"}}(e))}async fetchPools(){return this.sor.fetchPools()}getPools(){return this.sor.getPools()}async queryBatchSwap(e){return await $t(this.vaultContract,e.kind,e.swaps,e.assets)}async queryBatchSwapWithSor(e){return await Vt(this.sor,this.vaultContract,e)}async querySimpleFlashSwap(e){return await async function(e){jn(e);const[t,a]=e.assets;try{const n=await $t(e.vaultContract,exports.SwapType.SwapExactIn,Kn(e.poolIds,e.flashLoanAmount),e.assets),s={[t]:Zn(n[0]).toString(),[a]:Zn(n[1]).toString()};return{profits:s,isProfitable:Xn([s[t],s[a]])>0}}catch(e){throw`Failed to querySimpleFlashSwap: ${e}`}}({...e,vaultContract:this.vaultContract})}async getSorSwap(e){return await Ht(e.tokenIn,e.tokenOut,e.swapType,e.amount,this.sor)}}const os=new e.Interface(Jn);class ds{constructor(e){this.swaps=e instanceof is?e:new is(e)}static isChainedReference(e){const t=a.BigNumber.from(e),n=a.BigNumber.from("0xfff0000000000000000000000000000000000000000000000000000000000000"),s=t.toBigInt()&n.toBigInt();return"0xba10000000000000000000000000000000000000000000000000000000000000"===a.BigNumber.from(s)._hex.toString()}static encodeApproveVault(e,t){return os.encodeFunctionData("approveVault",[e,t])}static encodeSetRelayerApproval(e,t,a){return os.encodeFunctionData("setRelayerApproval",[e,t,a])}static encodeGaugeWithdraw(e,t,a,n){return os.encodeFunctionData("gaugeWithdraw",[e,t,a,n])}static encodeGaugeDeposit(e,t,a,n){return os.encodeFunctionData("gaugeDeposit",[e,t,a,n])}static encodeBatchSwap(e){return os.encodeFunctionData("batchSwap",[e.swapType,e.swaps,e.assets,e.funds,e.limits,e.deadline,e.value,e.outputReferences])}static encodeExitPool(e){return os.encodeFunctionData("exitPool",[e.poolId,e.poolKind,e.sender,e.recipient,e.exitPoolRequest,e.outputReferences])}static encodeJoinPool(e){return os.encodeFunctionData("joinPool",[e.poolId,e.kind,e.sender,e.recipient,e.joinPoolRequest,e.value,e.outputReference])}static encodeWrapAaveDynamicToken(e){return os.encodeFunctionData("wrapAaveDynamicToken",[e.staticToken,e.sender,e.recipient,e.amount,e.fromUnderlying,e.outputReference])}static encodeUnwrapAaveStaticToken(e){return os.encodeFunctionData("unwrapAaveStaticToken",[e.staticToken,e.sender,e.recipient,e.amount,e.toUnderlying,e.outputReferences])}static encodePeekChainedReferenceValue(e){return os.encodeFunctionData("peekChainedReferenceValue",[e])}static toChainedReference(e,t=!0){const n=t?ds.CHAINED_REFERENCE_TEMP_PREFIX:ds.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${n}${"0".repeat(64-n.length)}`;return a.BigNumber.from(s).add(e)}static fromChainedReference(e,t=!0){const n=t?ds.CHAINED_REFERENCE_TEMP_PREFIX:ds.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${n}${"0".repeat(64-n.length)}`;return a.BigNumber.from(e).sub(a.BigNumber.from(s))}static constructExitCall(e){const{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s,poolId:r,poolKind:i,sender:o,recipient:d,outputReferences:p}=e,c={poolId:r,poolKind:i,sender:o,recipient:d,outputReferences:p,exitPoolRequest:{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s}};return ds.encodeExitPool(c)}static constructJoinCall(e){const{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s,poolId:r,kind:i,sender:o,recipient:d,value:p,outputReference:c}=e,l={poolId:r,kind:i,sender:o,recipient:d,value:p,outputReference:c,joinPoolRequest:{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s}};return ds.encodeJoinPool(l)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async exitPoolAndBatchSwap(e){const n=t.WeiPerEther.sub(a.BigNumber.from(e.slippage)),s=e.expectedAmountsOut.map((e=>a.BigNumber.from(e).mul(n).div(t.WeiPerEther).toString())),r=[];e.exitTokens.forEach(((e,t)=>{const a=ds.toChainedReference(t);r.push({index:t,key:a})}));const i=ds.constructExitCall({assets:e.exitTokens,minAmountsOut:s,userData:e.userData,toInternalBalance:!0,poolId:e.poolId,poolKind:0,sender:e.exiter,recipient:e.exiter,outputReferences:r,exitPoolRequest:{}}),o=await this.swaps.queryBatchSwapWithSor({tokensIn:e.exitTokens,tokensOut:e.finalTokensOut,swapType:exports.SwapType.SwapExactIn,amounts:s,fetchPools:e.fetchPools});if(o.returnAmounts.includes("0"))throw new nt(exports.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);o.swaps.forEach((t=>{const a=o.assets[t.assetInIndex],n=e.exitTokens.indexOf(a);-1!==n&&(t.amount=r[n].key.toString())}));const d=t.WeiPerEther.add(e.slippage);e.exitTokens.forEach(((n,s)=>{const r=o.assets.map((e=>e.toLowerCase())).indexOf(n.toLowerCase());-1!==r&&(o.deltas[r]=a.BigNumber.from(e.expectedAmountsOut[s]).mul(d).div(t.WeiPerEther).toString())}));const p=is.getLimitsForSlippage(e.exitTokens,e.finalTokensOut,exports.SwapType.SwapExactIn,o.deltas,o.assets,"0"),c={sender:e.exiter,recipient:e.swapRecipient,fromInternalBalance:!0,toInternalBalance:!1};return{function:"multicall",params:[i,ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:o.swaps,assets:o.assets,funds:c,limits:p.map((e=>e.toString())),deadline:t.MaxUint256,value:"0",outputReferences:[]})],outputs:{amountsOut:o.returnAmounts}}}async swapUnwrapAaveStaticExactIn(e,n,s,r,i,o,d={fetchPools:!0,fetchOnChain:!1}){const p=await this.swaps.queryBatchSwapWithSor({tokensIn:e,tokensOut:n,swapType:exports.SwapType.SwapExactIn,amounts:s,fetchPools:d});if(p.returnAmounts.includes("0"))throw new nt(exports.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const c=is.getLimitsForSlippage(e,n,exports.SwapType.SwapExactIn,p.deltas,p.assets,o);return{function:"multicall",params:this.encodeSwapUnwrap(n,exports.SwapType.SwapExactIn,p.swaps,p.assets,i,c),outputs:{amountsOut:p.returnAmounts.map(((e,n)=>{const s=a.BigNumber.from(e).abs().mul(r[n]).div(t.WeiPerEther);if(!s.gt(t.Zero))throw new nt(exports.BalancerErrorCode.UNWRAP_ZERO_AMOUNT);return s.toString()}))}}}async swapUnwrapAaveStaticExactOut(e,n,s,r,i,o,d={fetchPools:!0,fetchOnChain:!1}){const p=s.map(((e,n)=>{const s=a.BigNumber.from(e).mul(t.WeiPerEther).div(r[n]);if(!s.gt(t.Zero))throw new nt(exports.BalancerErrorCode.WRAP_ZERO_AMOUNT);return s.toString()})),c=await this.swaps.queryBatchSwapWithSor({tokensIn:e,tokensOut:n,swapType:exports.SwapType.SwapExactOut,amounts:p,fetchPools:d});if(c.returnAmounts.includes("0"))throw new nt(exports.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const l=is.getLimitsForSlippage(e,n,exports.SwapType.SwapExactOut,c.deltas,c.assets,o);return{function:"multicall",params:this.encodeSwapUnwrap(n,exports.SwapType.SwapExactOut,c.swaps,c.assets,i,l),outputs:{amountsIn:c.returnAmounts.map((e=>e.toString()))}}}encodeSwapUnwrap(e,a,n,s,r,i){const o=[],d=[];e.forEach(((e,t)=>{const a=s.findIndex((t=>t.toLowerCase()===e.toLowerCase()));if(-1===a)return;const n=ds.toChainedReference(t);o.push({index:a,key:n});const i=ds.encodeUnwrapAaveStaticToken({staticToken:e,sender:r.recipient,recipient:r.sender,amount:n,toUnderlying:!0,outputReferences:0});d.push(i)}));return[ds.encodeBatchSwap({swapType:a,swaps:n,assets:s,funds:r,limits:i.map((e=>e.toString())),deadline:t.MaxUint256,value:"0",outputReferences:o}),...d]}}ds.CHAINED_REFERENCE_TEMP_PREFIX="ba10",ds.CHAINED_REFERENCE_READONLY_PREFIX="ba11",ds.signRelayerApproval=async(e,a,n,s)=>{const r=s.interface.encodeFunctionData("setRelayerApproval",[a,e,!0]),i=await j.signSetRelayerApprovalAuthorization(s,n,e,r);return j.encodeCalldataAuthorization("0x",t.MaxUint256,i)};class ps{constructor(e){this.url=Vn(e).urls.subgraph,this.client=this.initClient()}initClient(){return sn(new u.GraphQLClient(this.url))}}class cs{constructor(e,t){this.swaps=t||new is(e)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async getSpotPrice(e,t,a=[]){0===a.length&&(await this.fetchPools(),a=this.getPools());const n=p.parseToPoolsDict(a,0),s=this.swaps.sor.routeProposer.getCandidatePathsFromDict(e,t,0,n,4);if(0===s.length)throw new nt(exports.BalancerErrorCode.UNSUPPORTED_PAIR);return p.getSpotPriceAfterSwapForPath(s[0],0,p.ZERO).toString()}}var ls=[{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 us(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 ys{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 Dn(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 r=n&&Date.now()>s;return{lockedEndDate:s,lockedAmount:Se(t),totalSupply:Se(e.totalSupply),epoch:Se(e.epoch,0),hasExistingLock:n,isExpired:r}}}var ms=[{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 fs{constructor(e,t){if(!e.veBalProxy)throw new Error("veBalProxy address must be defined");this.instance=new s.Contract(e.veBalProxy,ms,t)}async getAdjustedBalance(e){return Se(await this.instance.adjustedBalanceOf(e))}}var hs=[{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"}],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"}];const gs=(e,t,a)=>{switch(a){case 3:return new s.Contract(e,Ts,t);case 4:return new s.Contract(e,hs,t);default:throw new Error("relayer not supported")}};var xs=[{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 Is{constructor(e,t){this.contractAddresses="number"==typeof e?et[e].addresses.contracts:e,this.vault=c.Vault__factory.connect(this.contractAddresses.vault,t),this.balancerHelpers=c.BalancerHelpers__factory.connect(this.contractAddresses.balancerHelpers,t),this.contractAddresses.lidoRelayer&&(this.lidoRelayer=c.LidoRelayer__factory.connect(this.contractAddresses.lidoRelayer,t)),this.multicall=Cn(this.contractAddresses.multicall,t),this.contractAddresses.relayerV3&&(this.relayerV3=gs(this.contractAddresses.relayerV3,t,3)),this.contractAddresses.relayerV4&&(this.relayerV4=gs(this.contractAddresses.relayerV4,t,4)),this.contractAddresses.veBal&&(this.veBal=new ys(this.contractAddresses,t)),this.contractAddresses.veBalProxy&&(this.veBalProxy=new fs(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 s.Contract(e,ls,t))(e,t)}getLiquidityGauge(e,t){return((e,t)=>new s.Contract(e,xs,t))(e,t)}}const Es={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"}},ws=new e.Interface(Ts),As=ds.toChainedReference("21"),Ss=ds.toChainedReference("22"),Ps=ds.toChainedReference("23"),Bs=ds.toChainedReference("24");class _s{constructor(e){this.addresses=Es[e]}calldata(e,t,n,s,r){if(a.BigNumber.from(t).lte(0))throw new nt(exports.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const i=this.addresses.relayer;let o=[];r&&(o=[this.buildSetRelayerApproval(r)]),o=s?[...o,this.buildWithdraw(e,t),this.buildExit(i,t),this.buildSwap(n,i),this.buildDeposit(e)]:[...o,this.buildExit(e,t),this.buildSwap(n,e)];return{to:i,data:ws.encodeFunctionData("multicall",[o])}}buildExit(e,t){const{assetOrder:a}=this.addresses.staBal3,n=a.map((e=>this.addresses[e])),s=A.exitExactBPTInForTokensOut(t),r=[{index:a.indexOf("DAI"),key:As},{index:a.indexOf("USDC"),key:Ss},{index:a.indexOf("USDT"),key:Ps}];return ds.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:r,exitPoolRequest:{}})}buildSwap(e,n){const s=[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}],i=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:As.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:Ss.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:Ps.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"}],o=[a.BigNumber.from(e).mul(-1).toString(),t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0"],d={sender:this.addresses.relayer,recipient:n,fromInternalBalance:!0,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:i,assets:s,funds:d,limits:o,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return ds.encodeGaugeWithdraw(this.addresses.staBal3.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return ds.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,Bs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Os=new e.Interface(Ts),vs=ds.toChainedReference("24");class ks{constructor(e){this.addresses=Es[e]}calldata(e,t,n,s,r,i){if(a.BigNumber.from(t).lte(0))throw new nt(exports.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];i&&(d=[this.buildSetRelayerApproval(i)]),d=s?[...d,this.buildWithdraw(e,t),this.buildSwap(t,n,o,o,r),this.buildDeposit(e)]:[...d,this.buildSwap(t,n,e,e,r)];const p=Os.encodeFunctionData("multicall",[d]);return{to:this.addresses.relayer,data:p}}buildSwap(e,n,s,r,i){const o=[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],d=[{index:0,key:vs}],p=i.reduce(((e,t)=>e.add(a.BigNumber.from(t))),t.Zero),{assetOrder:c}=this.addresses.bbausd1,l=a.BigNumber.from(e).mul(i[c.indexOf("bb-a-USDC")]).div(p).toString(),u=a.BigNumber.from(e).mul(i[c.indexOf("bb-a-DAI")]).div(p).toString(),b=a.BigNumber.from(e).sub(l).sub(u).toString(),y=[{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:2,amount:u,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:l,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"}],m=[a.BigNumber.from(n).mul(-1).toString(),"0","0","0","0","0","0","0","0","0",e],f={sender:s,recipient:r,fromInternalBalance:!1,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:y,assets:o,funds:f,limits:m,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:d})}buildWithdraw(e,t){return ds.encodeGaugeWithdraw(this.addresses.bbausd1.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return ds.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,vs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Ns=new e.Interface(Ts),Cs=ds.toChainedReference("0"),Ds=[];class Fs{constructor(e){this.addresses=Es[e]}calldata(e,t,a,n,s,r,i,o){if(r&&(null==t.gauge||null==a.gauge))throw new Error("Staked flow migration requires gauge addresses to be provided");const d=this.addresses.relayer;let p=[];o&&(p=[this.buildSetRelayerApproval(o)]),p=r?[...p,this.buildWithdraw(e,n,t.gauge),this.buildExit(t.id,d,n,i),this.buildSwap(s,d,a.id,a.address,i),this.buildDeposit(e,a.gauge)]:[...p,this.buildExit(t.id,e,n,i),this.buildSwap(s,e,a.id,a.address,i)];const c=Ns.encodeFunctionData("multicall",[p]);return{to:this.addresses.relayer,data:c}}buildExit(e,t,a,n){const s=A.exitExactBPTInForTokensOut(a),r=[];for(let e=0;e<n.length;e++)r[e]={index:e,key:ds.toChainedReference(`${e+1}`)},Ds.push(r[e].key);const i=Array(n.length).fill("0");return ds.constructExitCall({assets:n,minAmountsOut:i,userData:s,toInternalBalance:!0,poolId:e,poolKind:0,sender:t,recipient:this.addresses.relayer,outputReferences:r,exitPoolRequest:{}})}buildSwap(e,n,s,r,i){const o=[r,...i],d=[{index:0,key:Cs}],p=[];for(let e=0;e<i.length;e++)p.push({poolId:s,assetInIndex:e+1,assetOutIndex:0,amount:Ds[e].toString(),userData:"0x"});const c=[a.BigNumber.from(e).mul(-1).toString()];for(let e=0;e<i.length;e++)c.push(t.MaxInt256.toString());const l={sender:this.addresses.relayer,recipient:n,fromInternalBalance:!0,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:p,assets:o,funds:l,limits:c,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:d})}buildWithdraw(e,t,a){return ds.encodeGaugeWithdraw(a,e,this.addresses.relayer,t)}buildDeposit(e,t){return ds.encodeGaugeDeposit(t,this.addresses.relayer,e,Cs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Rs=new e.Interface(Ts),Ms=ds.toChainedReference("20"),Ls=ds.toChainedReference("21"),Us=ds.toChainedReference("22"),Gs=ds.toChainedReference("23"),qs=ds.toChainedReference("24");class Ws{constructor(e){this.addresses=Es[e]}calldata(e,t,n,s,r){if(a.BigNumber.from(t).lte(0))throw new nt(exports.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const i=this.addresses.relayer;let o=[];r&&(o=[this.buildSetRelayerApproval(r)]),o=s?[...o,this.buildWithdraw(e,t),this.buildExit(i,t),this.buildSwap(i,n),this.buildDeposit(e)]:[...o,this.buildExit(e,t),this.buildSwap(e,n)];return{to:i,data:Rs.encodeFunctionData("multicall",[o])}}buildExit(e,t){const{assetOrder:a}=this.addresses.maiusd,n=a.map((e=>this.addresses[e])),s=A.exitExactBPTInForTokensOut(t),r=[{index:a.indexOf("miMATIC"),key:Ms},{index:a.indexOf("DAI"),key:Ls},{index:a.indexOf("USDC"),key:Us},{index:a.indexOf("USDT"),key:Gs}],i=Array(n.length).fill("0");return ds.constructExitCall({assets:n,minAmountsOut:i,userData:s,toInternalBalance:!0,poolId:this.addresses.maiusd.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:r,exitPoolRequest:{}})}buildSwap(e,n){const s=[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:qs}],i=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Ls.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:Us.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:Gs.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:Ms.toString(),userData:"0x"}],o=["0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),a.BigNumber.from(n).mul(-1).toString()],d={sender:this.addresses.relayer,recipient:e,fromInternalBalance:!0,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:i,assets:s,funds:d,limits:o,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return ds.encodeGaugeWithdraw(this.addresses.maiusd.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return ds.encodeGaugeDeposit(this.addresses.maibbausd.gauge,this.addresses.relayer,e,qs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}class $s{constructor(e){this.network=e}stabal3(t,a,n,s,r){const i=new _s(this.network).calldata(t,a,n,s,r);return{to:i.to,data:i.data,decode:(t,a)=>{let n=a?2:1;r&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}bbaUsd(t,a,n,s,r,i){const o=new ks(this.network).calldata(t,a,n,s,r,i);return{to:o.to,data:o.data,decode:(t,a)=>{let n=a?1:0;i&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}stables(t,a,n,s,r,i,o,d){const p=new Fs(this.network).calldata(t,a,n,s,r,i,o,d);return{to:p.to,data:p.data,decode:(t,a)=>{let n=a?2:1;d&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}maiusd(t,a,n,s,r){const i=new Ws(this.network).calldata(t,a,n,s,r);return{to:i.to,data:i.data,decode:(t,a)=>{let n=a?2:1;r&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][8].abs().toString()}}}}class Vs{constructor(e){this.network=e,this.migrations=new $s(e)}}class Hs{constructor(e,t){this.tokenPrices=e,this.tokenHistoricalPrices=t}async calcImpLoss(e,t){if(1e3*e>=Date.now())throw console.error(`[ImpermanentLossService][calcImpLoss]Error: ${nt.getMessage(exports.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE)}`),new nt(exports.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE);const a=await this.prepareData(e,t),n=this.getPoolValueDelta(a),s=this.getHoldValueDelta(a);return this.calculateImpermanentLoss(n,s)}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)),r=await this.getEntryPrices(e,s),i=await this.getExitPrices(a);return this.getAssets(a,i,r,n)}getAssets(e,t,a,n){return e.map(((e,s)=>({priceDelta:this.getDelta(a[e.address],t[e.address]),weight:n[s]})))}getDelta(e,t){if(0===e)throw console.error(`[ImpermanentLossService][getDelta]Error: ${nt.getMessage(exports.BalancerErrorCode.ILLEGAL_PARAMETER)}: entry price is 0`),new nt(exports.BalancerErrorCode.ILLEGAL_PARAMETER);return(t-e)/e}getWeights(e){const t=e.every((e=>!e.weight)),a=Math.round(1/e.length*100)/100,n=t?e.map((()=>a)):e.map((e=>{var t;return Number(null!==(t=e.weight)&&void 0!==t?t:0)}));if(n.some((e=>0===e)))throw console.error(`[ImpermanentLossService][getWeights]Error: ${nt.getMessage(exports.BalancerErrorCode.MISSING_WEIGHT)}`),new nt(exports.BalancerErrorCode.MISSING_WEIGHT);return n}async getExitPrices(e){var t;const a=await Promise.all(e.map((e=>this.tokenPrices.find(e.address)))).catch((()=>[]));if(!a.length||a.some((e=>void 0===(null==e?void 0:e.usd))))throw console.error(`[ImpermanentLossService][getExitPrices]Error: ${nt.getMessage(exports.BalancerErrorCode.MISSING_PRICE_RATE)}`),new nt(exports.BalancerErrorCode.MISSING_PRICE_RATE);const n=e.map(((e,t)=>({...e,price:a[t]}))),s={};for(const e of n)(null===(t=e.price)||void 0===t?void 0:t.usd)&&(s[e.address]=+e.price.usd);return s}async getEntryPrices(e,t){const a={};for(const n of t){const t=await this.tokenHistoricalPrices.findBy(n,e).catch((e=>{console.error(`[ImpermanentLossService][getEntryPrices]Error: ${e.message}`)}));if(!(null==t?void 0:t.usd))throw console.error(`[ImpermanentLossService][getEntryPrices]Error: ${nt.getMessage(exports.BalancerErrorCode.MISSING_PRICE_RATE)}`),new nt(exports.BalancerErrorCode.MISSING_PRICE_RATE);a[n]=+t.usd}return a}}const js=335e3,Ks=1765411200,Zs=(e=Math.round((new Date).getTime()/1e3))=>js;var Xs=Object.freeze({__proto__:null,INITIAL_RATE:js,START_EPOCH_TIME:Ks,weekly:Zs,total:e=>365*(Zs()/7),between:(e,t)=>{if(e<Ks)throw"start timestamp before emission schedule deployment";if(t<e)throw"cannot finish before starting";const a=t-e,n=Zs()/7;return Math.round(a/86400)*n}});class Js{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 Ys{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&&us(e.createTime)?parseFloat(e.totalSwapFee):0:0}}class zs{constructor(e,t,a,n,s,r,i,o){this.pools=e,this.tokenPrices=t,this.tokenMeta=a,this.tokenYields=n,this.feeCollector=s,this.yesterdaysPools=r,this.liquidityGauges=i,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||6343==e.chainId||4326==e.chainId)&&0==a.workingSupply||248!=e.chainId&&9372!=e.chainId&&6343!=e.chainId&&4326!=e.chainId&&0==a.totalSupply)return 0;const n=et[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,r]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const i=parseFloat(s.usd),o=Zs()/7*365*a.relativeWeight*i,d=(a.workingSupply+.4)/.4*r;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=et[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,r]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const i=parseFloat(s.usd),o=Zs()/7*365*(a.relativeWeightNextPeriod||0)*i,d=(a.workingSupply+.4)/.4*r;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=et[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),r=t.totalSupply*s,i={};let o=0;for await(const e of Object.values(n)){const t=r>0?e.value/r:0,a=Math.round(1e4*t);o+=a,i[e.address]=a}return{total:o,breakdown:i}}async protocolApr(e){if(""!=e.id||!this.feeDistributor)return 0;const t=new Js(this.feeDistributor,this.tokenPrices),{lastWeekBalRevenue:a,lastWeekBBAUsdRevenue:n,veBalSupply:s}=await t.data(),r=await this.bptPrice(e);if(!r)throw"bptPrice for veBal pool missing";const i=(a+n)/7;return Math.round(365*i*1e4/(r*s))}async apr(e){const[t,a,n,s,r,i]=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:r,protocolApr:i,min:t+a.total+r.total+n,max:t+a.total+r.total+i+s}}async aprNextPeriod(e){const[t,a,n,s,r,i]=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:r,protocolApr:i,min:t+a.total+r.total+n,max:t+a.total+r.total+i+s}}async last24hFees(e){return new Ys(this.yesterdaysPools).last24h(e)}async totalLiquidity(e){try{const t=new Wt(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(Se(a,s))*parseFloat(n.usd)}}throw`No USD price for ${e}`}}}const Qs=new Map;Qs.set(exports.PoolType.AaveLinear,"batchSwap"),Qs.set(exports.PoolType.EulerLinear,"batchSwap"),Qs.set(exports.PoolType.ERC4626Linear,"batchSwap"),Qs.set(exports.PoolType.Element,"batchSwap"),Qs.set(exports.PoolType.Investment,"joinPool"),Qs.set(exports.PoolType.LiquidityBootstrapping,"joinPool"),Qs.set(exports.PoolType.MetaStable,"joinPool"),Qs.set(exports.PoolType.Stable,"joinPool"),Qs.set(exports.PoolType.StablePhantom,"batchSwap"),Qs.set(exports.PoolType.Weighted,"joinPool"),Qs.set(exports.PoolType.ComposableStable,"joinPool");const er=new Map;er.set(exports.PoolType.AaveLinear,"batchSwap"),Qs.set(exports.PoolType.EulerLinear,"batchSwap"),er.set(exports.PoolType.ERC4626Linear,"batchSwap"),er.set(exports.PoolType.Element,"batchSwap"),er.set(exports.PoolType.Investment,"exitPool"),er.set(exports.PoolType.LiquidityBootstrapping,"exitPool"),er.set(exports.PoolType.MetaStable,"exitPool"),er.set(exports.PoolType.Stable,"exitPool"),er.set(exports.PoolType.StablePhantom,"batchSwap"),er.set(exports.PoolType.Weighted,"exitPool"),er.set(exports.PoolType.ComposableStable,"exitPool");class tr{constructor(e){this.pools=e}async buildGraphFromRootPool(e,a){const n=await this.pools.find(e);if(!n)throw new nt(exports.BalancerErrorCode.POOL_DOESNT_EXIST);return(await this.buildGraphFromPool(n.address,0,void 0,t.WeiPerEther,a))[0]}getTokenTotal(e){const a=e.tokensList.indexOf(e.address);let n=t.Zero;const{parsedBalances:s}=ne(e);return s.forEach(((e,t)=>{a!==t&&(n=n.add(e))})),n}async buildGraphFromPool(e,t,n,s,r){var i;const o=await this.pools.findBy("address",e);if(!o){if(n){const a=await this.pools.findBy("address",n.address),r=null!==(i=a.tokens[a.tokensList.indexOf(e)].decimals)&&void 0!==i?i:18;return tr.createInputTokenNode(t,e,r,n,s)}throw new nt(exports.BalancerErrorCode.POOL_DOESNT_EXIST)}const d=Qs.get(o.poolType),p=er.get(o.poolType);if(!d||!p)throw new nt(exports.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);const c=this.getTokenTotal(o),{spotPriceCalculator:l}=qt.from(o.poolType),u={};let b=18;o.tokens.forEach((e=>{if(We(e.address,o.address))return void(b=e.decimals?e.decimals:18);const t=l.calcPoolSpotPrice(e.address,o.address,o);u[e.address]=t}));let y={address:o.address,id:o.id,type:o.poolType,joinAction:d,exitAction:p,children:[],marked:!1,index:t.toString(),parent:n,proportionOfParent:s,isLeaf:!1,spotPrices:u,decimals:b};if(t++,o.poolType.toString().includes("Linear"))[y,t]=this.createLinearNodeChildren(y,t,o,r);else{const{parsedBalances:e}=ne(o);for(let n=0;n<o.tokens.length;n++){if(We(o.tokens[n].address,o.address))continue;let i;if("Weighted"===o.poolType){const e=o.tokens[n].weight;i=a.parseFixed(e,18)}else i=a.BigNumber.from(e[n]).mul(1e18.toString()).div(c);const d=i.mul(s).div(1e18.toString()),p=await this.buildGraphFromPool(o.tokens[n].address,t,y,d,r);t=p[1],p[0]&&y.children.push(p[0])}}return[y,t]}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,r=tr.createInputTokenNode(t,a.tokensList[a.mainIndex],n,e,e.proportionOfParent);return e.children.push(r[0]),[e,t=r[1]]}}createWrappedTokenNode(e,t,a,n){var s;if(void 0===e.wrappedIndex||void 0===e.mainIndex)throw new Error("Issue With Linear Pool");let r="wrapAaveDynamicToken";if(e.poolType===exports.PoolType.ERC4626Linear)r="wrapERC4626";let i="unwrapAaveStaticToken";if(e.poolType===exports.PoolType.ERC4626Linear)i="unwrapERC4626";const o={type:"WrappedToken",address:e.tokensList[e.wrappedIndex],id:"N/A",children:[],marked:!1,joinAction:r,exitAction:i,index:t.toString(),parent:a,proportionOfParent:n,isLeaf:!1,spotPrices:{},decimals:18};t++;const d=null!==(s=e.tokens[e.mainIndex].decimals)&&void 0!==s?s:18,p=tr.createInputTokenNode(t,e.tokensList[e.mainIndex],d,o,n);return o.children=[p[0]],[o,t=p[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))}}tr.getGraphNodes=async(e,t,a,n)=>{if(!await a.find(t))throw new nt(exports.BalancerErrorCode.POOL_DOESNT_EXIST);const s=new tr(a),r=await s.buildGraphFromRootPool(t,n);if(r.id!==t)throw new Error("Error creating graph nodes");return e?tr.orderByBfs(r).reverse():tr.orderByBfs(r)};class ar{constructor(e,a){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}]))),r={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},i=this.tenderlyUrl+"simulate";return(await E.default.post(i,r,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,a)=>{if(0===a.length)return{};let n={};a.forEach((a=>n={...n,[`${a}`]:{value:{[`_balances[${e}]`]:t.MaxInt256.toString(),[`_allowances[${e}][${this.vaultAddress}]`]:t.MaxInt256.toString(),[`balanceOf[${e}]`]:t.MaxInt256.toString(),[`allowance[${e}][${this.vaultAddress}]`]:t.MaxInt256.toString(),[`balances[${e}]`]:t.MaxInt256.toString(),[`allowed[${e}][${this.vaultAddress}]`]:t.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 E.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}=tt(this.chainId);this.vaultAddress=n.vault,(null==a?void 0:a.user)&&(null==a?void 0:a.project)?this.tenderlyUrl=`https://api.tenderly.co/api/v1/account/${a.user}/project/${a.project}/`:this.tenderlyUrl="https://api.balancer.fi/tenderly/",(null==a?void 0:a.accessKey)&&(this.opts={headers:{"X-Access-Key":a.accessKey}}),this.blockNumber=null==a?void 0:a.blockNumber}}var nr;const sr=new e.Interface(hs);class rr{constructor(n,s){this.pools=n,this.createCalls=async(e,t,a,n)=>{const{calls:s,outputIndexes:r,deltas:i}=this.createActionCalls(e,t,a);n&&s.unshift(this.createSetRelayerApproval(n));return{callData:sr.encodeFunctionData("multicall",[s]),outputIndexes:n?r.map((e=>e+1)):r,deltas:i}},this.amountsOutByJoinPath=async(t,n,s,r)=>{const i=[],o=await this.tenderlyHelper.simulateMulticall(this.relayer,n,t,s),d=e.defaultAbiCoder.decode(["bytes[]"],o)[0];let p=a.BigNumber.from("0");return r.forEach((t=>{const a=e.defaultAbiCoder.decode(["uint256"],d[t]);i.push(a.toString()),p=p.add(a.toString())})),{amountsOut:i,totalAmountOut:p.toString()}},this.minAmountsOutByJoinPath=(e,t,n)=>({minAmountsOut:t.map((t=>Ye(a.BigNumber.from(t),a.BigNumber.from(e)).toString())),totalMinAmountOut:Ye(a.BigNumber.from(n),a.BigNumber.from(e)).toString()}),this.createActionCalls=(e,t,a)=>{const n=[],s=[],r=!a,i={};return e.forEach(((e,o)=>{const d=e[0].isLeaf;if(e.forEach(((s,r)=>{let p;if(p=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)})):r>0?[e[r-1]]:[],p.length>0&&0===p.filter((e=>"0"!==e.index)).length)return void(s.index="0");p.some((e=>"input"===e.joinAction||"wrapAaveDynamicToken"===e.joinAction));const c=t,l=r===e.length-1,u=t,b=l&&a?a[o]:"0";switch(s.joinAction){case"wrapAaveDynamicToken":n.push(this.createAaveWrap(s,p,o,c,t));break;case"batchSwap":{const[e,t,a]=this.createBatchSwap(s,p,o,b,c,u);n.push(e),this.updateDeltas(i,t,a);break}case"joinPool":{const[e,t,a,r]=this.createJoinPool(s,p,o,b,c,u);n.push(e),this.updateDeltas(i,[s.address,...t],[r,...a]);break}}})),r){const e=100*o,t=ds.encodePeekChainedReferenceValue(ds.toChainedReference(e,!1));n.push(t),s.push(n.indexOf(t))}})),{calls:n,outputIndexes:s,deltas:i}},this.createSetRelayerApproval=e=>ds.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 r=t[0],i=e.address,o=r.index;return ds.encodeWrapAaveDynamicToken({staticToken:i,sender:n,recipient:s,amount:o,fromUnderlying:!0,outputReference:this.getOutputRefValue(a,e).value})},this.createBatchSwap=(e,n,s,r,i,o)=>{if(1!==n.length)throw new Error("Unsupported batchswap");const d=n[0].address,p=this.getOutputRefValue(s,n[0]),c=[e.address,d],l=[a.BigNumber.from(r).mul(-1).toString(),p.isRef?t.MaxInt256.toString():p.value],u=[{poolId:e.id,assetInIndex:1,assetOutIndex:0,amount:p.value,userData:"0x"}],b={sender:i,recipient:o,fromInternalBalance:i===this.relayer,toInternalBalance:o===this.relayer},y=[{index:c.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase()),key:a.BigNumber.from(this.getOutputRefValue(s,e).value)}],m=ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:u,assets:c,funds:b,limits:l,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:y}),f=i===this.relayer?"0":l[1];return[m,c,[o===this.relayer?"0":l[0],f]]},this.createJoinPool=(e,a,n,s,r,i)=>{const o=[],d=[];e.children.forEach((e=>{o.push(e.address);const t=a.find((t=>We(t.address,e.address)));t?d.push(this.getOutputRefValue(n,t).value):d.push("0")})),e.type===exports.PoolType.ComposableStable&&(o.push(e.address),d.push("0"));const p=new q(this.wrappedNativeAsset),[c,l]=p.sortTokens(o,d);let u=[];const b=c.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase());let y;u=-1===b?l:[...l.slice(0,b),...l.slice(b+1)],y=e.type===exports.PoolType.Weighted?S.joinExactTokensInForBPTOut(u,s):A.joinExactTokensInForBPTOut(u,s);const m=c.indexOf(t.AddressZero),f=-1===m?"0":l[m],h=ds.constructJoinCall({poolId:e.id,kind:0,sender:r,recipient:i,value:f,outputReference:this.getOutputRefValue(n,e).value,joinPoolRequest:{},assets:c,maxAmountsIn:l,userData:y,fromInternalBalance:r===this.relayer}),T=l.map((e=>ds.isChainedReference(e)?"0":e)),g=ds.isChainedReference(s)?"0":s;return[h,r===this.relayer?[]:c,r===this.relayer?[]:T,i===this.relayer?t.Zero.toString():t.Zero.sub(g).toString()]},this.getOutputRefValue=(e,t)=>"input"===t.joinAction?{value:t.index,isRef:!1}:"0"===t.index&&t.parent?{value:"0",isRef:!0}:{value:ds.toChainedReference(a.BigNumber.from(t.index).add(100*e)).toString(),isRef:!0};const{tokens:r,contracts:i}=tt(s.chainId);this.relayer=i.relayerV4,this.wrappedNativeAsset=r.wrappedNativeAsset,this.tenderlyHelper=new ar(s.chainId,s.tenderly)}async joinPool(e,t,a,n,s,r,i){if(t.length!=a.length)throw new nt(exports.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const o=await tr.getGraphNodes(!0,e,this.pools,s),d=rr.getJoinPaths(o,t,a),p=rr.totalBptZeroPriceImpact(d),{callData:c,outputIndexes:l}=await this.createCalls(d,n,void 0,i),{amountsOut:u,totalAmountOut:b}=await this.amountsOutByJoinPath(n,c,t,l),{minAmountsOut:y,totalMinAmountOut:m}=this.minAmountsOutByJoinPath(r,u,b),f=dt(BigInt(b),p.toBigInt(),!0).toString(),{callData:h,deltas:T}=await this.createCalls(d,n,y,i);return this.assertDeltas(e,T,t,a,m),{to:this.relayer,callData:h,expectedOut:b,minOut:m,priceImpact:f}}assertDeltas(e,t,n,s,r){var i;const o=C(e);if(t[o.toLowerCase()].add(r).abs().gt(3))throw console.error("join assertDeltas, bptOut: ",o,r,null===(i=t[o.toLowerCase()])||void 0===i?void 0:i.toString()),new nt(exports.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete t[o.toLowerCase()],n.forEach(((e,n)=>{var r,i;if(!a.BigNumber.from(s[n]).eq(0)&&(null===(r=t[e.toLowerCase()])||void 0===r?void 0:r.toString())!==s[n])throw console.error("join assertDeltas, tokenIn: ",e,s[n],null===(i=t[e.toLowerCase()])||void 0===i?void 0:i.toString()),new nt(exports.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete t[e.toLowerCase()]}));for(const e in t)if("0"!==t[e].toString())throw console.error("join assertDeltas, non-input token should be 0: ",e,t[e].toString()),new nt(exports.BalancerErrorCode.JOIN_DELTA_AMOUNTS)}updateDeltas(e,a,n){return a.forEach(((a,s)=>{const r=a.toLowerCase();e[r]||(e[r]=t.Zero),e[r]=e[r].add(n[s])})),e}}nr=rr,rr.getJoinPaths=(e,n,s)=>{const r=[],i=e.filter((e=>n.filter(((e,t)=>a.BigNumber.from(s[t]).gt(0))).map((e=>e.toLowerCase())).includes(e.address.toLowerCase())));i.some((e=>e.isLeaf))&&r.push(e);const o=i.filter((e=>!e.isLeaf));return o.forEach((e=>{const i=s.find(((t,a)=>We(n[a],e.address))),p=o.filter((t=>We(t.address,e.address))).reduce(((e,t)=>e.add(t.proportionOfParent)),a.BigNumber.from(0)),c=a.BigNumber.from(i).mul(e.proportionOfParent).div(p).toString(),[l]=tr.createInputTokenNode(0,e.address,e.decimals,e.parent,t.WeiPerEther);l.index=c,l.isLeaf=!1;const u=[l];let b=e.parent;for(;b;)u.push(d.cloneDeep(b)),b=b.parent;r.push(u)})),nr.updateInputAmounts(r,n,s),r},rr.updateInputAmounts=(e,t,n)=>{const s=(e,t)=>{if(e.length>1){const n=e.reduce(((e,t)=>e.add(t.index)),a.BigNumber.from(0)),s=a.BigNumber.from(t).sub(n);e[0].index=s.add(e[0].index).toString()}},r=e.find((e=>e[0].isLeaf));if(r){const e=nr.updateTotalProportions(r);r.forEach((a=>{"input"===a.joinAction&&(a=nr.updateNodeAmount(a,t,n,e))})),t.forEach(((e,t)=>{const a=r.filter((t=>t.isLeaf&&We(t.address,e)));s(a,n[t])}))}const i=e.filter((e=>!e[0].isLeaf));i.length>1&&t.forEach(((e,t)=>{const a=i.map((e=>e[0])).filter((t=>We(t.address,e)));s(a,n[t])}))},rr.totalBptZeroPriceImpact=e=>{let t=a.BigNumber.from("0");return e.forEach((e=>{if(e[0].isLeaf){e.filter((e=>e.isLeaf)).forEach((e=>{const a=nr.bptOutZeroPiForInputNode(e);t=t.add(a)}))}else{const a=nr.bptOutZeroPiForInputNode(e[0]);t=t.add(a)}})),t},rr.bptOutZeroPiForInputNode=e=>{if("0"===e.index||"input"!==e.joinAction)return BigInt(0);let t=1,n=e.parent,s=e.address;for(;void 0!==n;){if("batchSwap"===n.joinAction||"joinPool"===n.joinAction){const e=n.spotPrices[s.toLowerCase()];t*=parseFloat(e),s=n.address}n=n.parent}const r=a.parseFixed(t.toFixed(18),18),i=z(BigInt(e.decimals)),o=Q(BigInt(e.index),i);return te.divDownFixed(o,r.toBigInt())},rr.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},rr.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 r=n[e.address],i=e.proportionOfParent.mul(1e18.toString()).div(r).mul(a[s]).div(1e18.toString());return e.index=i.toString(),e};const ir=new e.Interface(hs);class or{constructor(n,s){this.pools=n,this.amountsOutByExitPath=async(t,n,s,r,i)=>{const o=await this.tenderlyHelper.simulateMulticall(this.relayer,n,t,[s]),d=e.defaultAbiCoder.decode(["bytes[]"],o)[0],p=r.map((t=>e.defaultAbiCoder.decode(["uint256"],d[t]).toString())),c=p.map((e=>Ye(a.BigNumber.from(e),a.BigNumber.from(i)).toString()));return{expectedAmountsOutByExitPath:p,minAmountsOutByExitPath:c}},this.amountsOutByTokenOut=(e,n,s,r)=>{const i={};n.forEach(((e,a)=>{var n;return i[e]=(null!==(n=i[e])&&void 0!==n?n:t.Zero).add(s[a])}));const o=e.map((e=>i[e].toString())),d=o.map((e=>Ye(a.BigNumber.from(e),a.BigNumber.from(r)).toString()));return{expectedAmountsOut:o,minAmountsOut:d}},this.getExitPaths=(e,n)=>{const s=e.map((e=>{const a=[e];for(;a[0].parent;)a.unshift(d.cloneDeep(a[0].parent));return a[0].index=a[a.length-1].proportionOfParent.mul(n).div(t.WeiPerEther).toString(),a})),r=s.reduce(((e,t)=>{const n=t[0].index;return a.BigNumber.from(n).add(e)}),t.Zero),i=a.BigNumber.from(n).sub(r);return s[s.length-1][0].index=i.add(s[s.length-1][0].index).toString(),s},this.getOutputRef=(e,t)=>100*e+parseInt(t);const{tokens:r,contracts:i}=tt(s.chainId);this.wrappedNativeAsset=r.wrappedNativeAsset,this.relayer=i.relayerV4,this.tenderlyHelper=new ar(s.chainId,s.tenderly)}async exitPool(e,t,a,n,s){const r=await tr.getGraphNodes(!1,e,this.pools,!1),i=r.filter((e=>"output"===e.exitAction)),o=this.getExitPaths(i,t),d=i.map((e=>e.address.toLowerCase())),p=[...new Set(d)].sort(),c=await this.createCalls(o,a,void 0,s),{expectedAmountsOutByExitPath:l,minAmountsOutByExitPath:u}=await this.amountsOutByExitPath(a,c.callData,r[0].address,c.outputIndexes,n),{callData:b,deltas:y}=await this.createCalls(o,a,u,s),{expectedAmountsOut:m,minAmountsOut:f}=this.amountsOutByTokenOut(p,d,l,n);this.assertDeltas(e,y,t,p,f);const h=await this.calculatePriceImpact(e,p,m,t);return{to:this.relayer,callData:b,tokensOut:p,expectedAmountsOut:m,minAmountsOut:f,priceImpact:h}}async calculatePriceImpact(e,t,a,n){const s=await tr.getGraphNodes(!0,e,this.pools,!1),r=rr.getJoinPaths(s,t,a),i=rr.totalBptZeroPriceImpact(r);return dt(BigInt(n),i.toBigInt(),!1).toString()}assertDeltas(e,t,a,n,s){var r;const i=C(e);if(t[i.toLowerCase()].sub(a).abs().gt(3))throw console.error("exit assertDeltas, bptIn: ",i,a,null===(r=t[i.toLowerCase()])||void 0===r?void 0:r.toString()),new nt(exports.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete t[i.toLowerCase()],n.forEach(((e,a)=>{var n;if(t[e.toLowerCase()].add(s[a]).abs().gt(1))throw console.error("exit assertDeltas, tokenOut: ",e,s[a],null===(n=t[e.toLowerCase()])||void 0===n?void 0:n.toString()),new nt(exports.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete t[e.toLowerCase()]}));for(const e in t)if("0"!==t[e].toString())throw console.error("exit assertDeltas, non-input token should be 0: ",e,t[e].toString()),new nt(exports.BalancerErrorCode.EXIT_DELTA_AMOUNTS)}async createCalls(e,t,a,n){const{calls:s,outputIndexes:r,deltas:i}=this.createActionCalls(d.cloneDeep(e),t,a);n&&s.unshift(ds.encodeSetRelayerApproval(this.relayer,!0,n));return{callData:ir.encodeFunctionData("multicall",[s]),outputIndexes:n?r.map((e=>e+1)):r,deltas:i}}updateDeltas(e,a,n){return a.forEach(((a,s)=>{const r=a.toLowerCase();e[r]||(e[r]=t.Zero),e[r]=e[r].add(n[s])})),e}createActionCalls(e,t,a){const n=[],s=[],r=!a,i={};return e.forEach(((e,o)=>{e.forEach((d=>{const p=!d.parent?t:this.relayer,c=d.children.find((t=>e.map((e=>e.index)).includes(t.index))),l="output"===(null==c?void 0:c.exitAction),u=l?t:this.relayer,b=l&&a?a[o]:"0";switch(d.exitAction){case"batchSwap":{const[e,t,a]=this.createBatchSwap(d,c,o,b,p,u);n.push(e),this.updateDeltas(i,t,a);break}case"exitPool":{const[e,t,a,s]=this.createExitPool(d,c,o,b,p,u);n.push(e),this.updateDeltas(i,[d.address,...a],[t,...s]);break}case"output":r&&(n.push(ds.encodePeekChainedReferenceValue(ds.toChainedReference(this.getOutputRef(o,d.index),!1))),s.push(n.length-1));break;default:return}}))})),{calls:n,outputIndexes:s,deltas:i}}createBatchSwap(e,n,s,r,i,o){const d=!e.parent?e.index:ds.toChainedReference(this.getOutputRef(s,e.index)).toString(),p=n.address,c=[p,e.address],l=[a.BigNumber.from(r).mul(-1).toString(),ds.isChainedReference(d)?t.MaxInt256.toString():d],u=[{poolId:e.id,assetInIndex:1,assetOutIndex:0,amount:d,userData:"0x"}],b={sender:i,recipient:o,fromInternalBalance:!1,toInternalBalance:!1},y=[{index:c.map((e=>e.toLowerCase())).indexOf(p.toLowerCase()),key:ds.toChainedReference(this.getOutputRef(s,n.index))}],m=ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:u,assets:c,funds:b,limits:l,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:y});let f=l[0];const h=l[1],T=i===this.relayer?"0":h;return f=o===this.relayer?"0":f,[m,c,[f,T]]}createExitPool(e,a,n,s,r,i){const o=a.address,d=!e.parent?e.index:ds.toChainedReference(this.getOutputRef(n,e.index)).toString(),p=[],c=[];e.children.forEach((e=>{p.push(e.address),c.push(e.address===o?s:"0")})),e.type===exports.PoolType.ComposableStable&&(p.push(e.address),c.push("0"));const l=new q(this.wrappedNativeAsset),[u,b]=l.sortTokens(p,c);let y=[];const m=u.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase());let f;y=-1===m?u:[...u.slice(0,m),...u.slice(m+1)],f=e.type===exports.PoolType.Weighted?S.exitExactBPTInForOneTokenOut(d,y.indexOf(o)):A.exitExactBPTInForOneTokenOut(d,y.indexOf(o));const h=[{index:u.map((e=>e.toLowerCase())).indexOf(o.toLowerCase()),key:ds.toChainedReference(this.getOutputRef(n,a.index))}],T=ds.constructExitCall({poolId:e.id,poolKind:0,sender:r,recipient:i,outputReferences:h,exitPoolRequest:{},assets:u,minAmountsOut:b,userData:f,toInternalBalance:!1}),g=b.map((e=>ds.isChainedReference(e)?"0":t.Zero.sub(e).toString())),x=ds.isChainedReference(d)?"0":d;return[T,r===this.relayer?t.Zero.toString():x,i===this.relayer?[]:u,i===this.relayer?[]:g]}}class dr{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&&us(e.createTime)?parseFloat(e.totalSwapVolume):0:0}}var pr=[{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 cr{constructor(e){const{tokens:t}=tt(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:t,name:a,symbol:n,tokenAddresses:s,amplificationParameter:r,rateProviders:i,tokenRateCacheDurations:o,exemptFromYieldProtocolFeeFlags:d,swapFee:p,owner:c}){const l=qe(`${p}`),u=new q(this.wrappedNativeAsset),[b,y,m,f]=u.sortTokens(s,i,o,d),h=[a,n,b,r,y,m,f,l.toString(),c],T=new e.Interface(pr),g=pr.find((({name:e})=>"create"===e));if(!g)throw new nt(exports.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const x=e.FunctionFragment.from(g);return{to:t,data:T.encodeFunctionData(x,h)}}buildInitJoin({joiner:e,poolId:t,poolAddress:a,tokensIn:n,amountsIn:s}){throw new Error("To be implemented")}}class lr{constructor(e){const{tokens:t}=tt(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:t,name:a,symbol:n,tokenAddresses:s,weights:r,swapFee:i,owner:o}){const d=qe(`${i}`),p=new q(this.wrappedNativeAsset),[l,u]=p.sortTokens(s,r),b=[a,n,l,u,d.toString(),o],y=new e.Interface(c.WeightedPoolFactory__factory.abi),m=c.WeightedPoolFactory__factory.abi.find((({name:e})=>"create"===e));if(!m)throw new nt(exports.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const f=e.FunctionFragment.from(m);return{to:t,data:y.encodeFunctionData(f,b)}}buildInitJoin({joiner:e,poolId:t,tokensIn:a,amountsIn:n}){const s=new q(this.wrappedNativeAsset),[r,i]=s.sortTokens(a,n),o="joinPool",d={poolId:t,sender:e,recipient:e,joinPoolRequest:{assets:r,maxAmountsIn:i,userData:S.joinInit(i),fromInternalBalance:!1}},p=c.Vault__factory.createInterface().encodeFunctionData(o,[d.poolId,d.sender,d.recipient,d.joinPoolRequest]);return{to:Qe,functionName:o,attributes:d,data:p}}}class ur{constructor(e){this.networkConfig=e}of(e){switch(e){case"Weighted":return new lr(this.networkConfig);case"Investment":case"LiquidityBootstrapping":case"Stable":case"MetaStable":case"StablePhantom":case"AaveLinear":case"ERC4626Linear":default:throw new nt(exports.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);case"ComposableStable":return new cr(this.networkConfig)}}}class br{constructor(e){this.pool=e;const t=(e=>{switch(e){case exports.PoolType.Weighted:return S;case exports.PoolType.Stable:case exports.PoolType.MetaStable:case exports.PoolType.StablePhantom:case exports.PoolType.AaveLinear:case exports.PoolType.EulerLinear:case exports.PoolType.ERC4626Linear:case exports.PoolType.Element:case exports.PoolType.Gyro2:case exports.PoolType.Gyro3:return A;case exports.PoolType.ComposableStable:return O}})(e.poolType);if(!t)throw"Pool type not supported";this.encoder=t}buildQueryJoinExactIn({sender:e=t.AddressZero,recipient:a=e,maxAmountsIn:n,minimumBPT:s=t.Zero,fromInternalBalance:r=!1}){const i=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e))),o=[...this.pool.tokensList];i&&i>-1&&n.splice(i,1);const d=this.encoder.joinExactTokensInForBPTOut(n,s);return[this.pool.id,e,a,{assets:o,maxAmountsIn:n,userData:d,fromInternalBalance:r}]}buildQueryJoinExactOut({sender:e=t.AddressZero,recipient:a=e,maxAmountsIn:n=[],bptOut:s,tokenIn:r,fromInternalBalance:i=!1}){const o=this.pool.tokensList.indexOf(r),d=this.encoder.joinTokenInForExactBPTOut(s,o);return[this.pool.id,e,a,{assets:this.pool.tokensList,maxAmountsIn:n,userData:d,fromInternalBalance:i}]}buildQueryExitToSingleToken({sender:e=t.AddressZero,recipient:a=e,minAmountsOut:n=[],bptIn:s,tokenOut:r,toInternalBalance:i=!1}){const o=this.pool.tokensList.indexOf(r),d=this.encoder.exitExactBPTInForOneTokenOut(s,o);return[this.pool.id,e,a,{assets:this.pool.tokensList,minAmountsOut:n,userData:d,toInternalBalance:i}]}buildQueryExitProportionally({sender:e=t.AddressZero,recipient:a=e,minAmountsOut:n=[],bptIn:s,toInternalBalance:r=!1}){if(!this.encoder.exitExactBPTInForTokensOut)throw"Proportional exit not implemented";const i=this.encoder.exitExactBPTInForTokensOut(s);return[this.pool.id,e,a,{assets:this.pool.tokensList,minAmountsOut:n,userData:i,toInternalBalance:r}]}buildQueryExitExactOut({sender:e=t.AddressZero,recipient:a=e,minAmountsOut:n,maxBptIn:s=t.MaxUint256,toInternalBalance:r=!1}){const i=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e)));i&&i>-1&&n.splice(i,1);const o=this.encoder.exitBPTInForExactTokensOut(n,s);return[this.pool.id,e,a,{assets:this.pool.tokensList,minAmountsOut:n,userData:o,toInternalBalance:r}]}}class yr{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 Zs()*await this.relativeWeight(e)}}const mr=(e,t,n)=>{const s=e.tokens.filter((t=>!e.id.toLowerCase().includes(t.address.toLowerCase()))),r=s.findIndex((e=>e.address.toLowerCase()===t.toLowerCase()));if(-1==r)throw new Error("Token not found in pool");const i=s.map((e=>Pe(e.balance,e.decimals))),o=a.BigNumber.from(n),d=i.map((e=>e.mul(o).div(i[r])));return{tokens:s.map((e=>e.address)),amounts:d.map((e=>e.toString()))}},fr=(e,t)=>()=>{throw`${t} for poolType ${e} not implemented`};class hr{constructor(e,t){this.networkConfig=e,this.repositories=t,this.aprService=new zs(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 Wt(t.pools,t.tokenPrices),this.joinService=new rr(this.repositories.poolsOnChain,e),this.exitService=new or(this.repositories.poolsOnChain,e),this.feesService=new Ys(t.yesterdaysPools),this.volumeService=new dr(t.yesterdaysPools),this.poolFactory=new ur(e),this.impermanentLossService=new Hs(t.tokenPrices,t.tokenHistoricalPrices),t.liquidityGauges&&(this.emissionsService=new yr(t.liquidityGauges)),this.proportionalAmounts=mr}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,r,i){return this.joinService.joinPool(e,t,a,n,s,r,i)}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=qt.from(e.poolType),s={buildJoin:(t,n,s,i)=>a.join.buildJoin({joiner:t,pool:e,tokensIn:n,amountsIn:s,slippage:i,wrappedNativeAsset:r}),calcPriceImpact:async(t,n,s)=>a.priceImpactCalculator.calcPriceImpact(e,t,n,s),buildExitExactBPTIn:(t,n,s,i=!1,o)=>{if(a.exit.buildExitExactBPTIn)return a.exit.buildExitExactBPTIn({exiter:t,pool:e,bptIn:n,slippage:s,shouldUnwrapNativeAsset:i,wrappedNativeAsset:r,singleTokenMaxOut:o});throw"ExitExactBPTIn not supported"},buildExitExactTokensOut:(t,n,s,i)=>a.exit.buildExitExactTokensOut({exiter:t,pool:e,tokensOut:n,amountsOut:s,slippage:i,wrappedNativeAsset:r}),calcSpotPrice:(t,n)=>a.spotPriceCalculator.calcPoolSpotPrice(t,n,e),calcProportionalAmounts:(t,a)=>mr(e,t,a)}}catch(t){"UNSUPPORTED_POOL_TYPE"!=t.code&&console.error(t),s={buildJoin:fr(e.poolType,"buildJoin"),calcPriceImpact:fr(e.poolType,"calcPriceImpact"),buildExitExactBPTIn:fr(e.poolType,"buildExitExactBPTIn"),buildExitExactTokensOut:fr(e.poolType,"buildExitExactTokensOut"),calcSpotPrice:fr(e.poolType,"calcSpotPrice")}}try{n=new br(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:fr(e.poolType,"buildQueryJoinExactIn"),buildQueryJoinExactOut:fr(e.poolType,"buildQueryJoinExactOut"),buildQueryExitExactOut:fr(e.poolType,"buildQueryExitExactOut"),buildQueryExitToSingleToken:fr(e.poolType,"buildQueryExitToSingleToken"),buildQueryExitProportionally:fr(e.poolType,"buildQueryExitProportionally")}}const r=t.addresses.tokens.wrappedNativeAsset.toLowerCase();return{...e,...s}}async find(e){const t=await this.dataSource().find(e);if(t)return hr.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 hr.wrap(e,this.networkConfig)}throw`search by ${e} not implemented`}async all(){const e=await this.dataSource().all();return e?e.map((e=>hr.wrap(e,this.networkConfig))).filter((e=>e)):[]}async where(e){const t=await this.dataSource().where(e);if(!t)return[];return t.map((e=>hr.wrap(e,this.networkConfig))).filter((e=>e))}}const Tr=new e.Interface(["function gauge_relative_weight(address gauge, uint timestamp) view returns (uint)","function gauge_relative_weight_write(address gauge, uint timestamp) returns (uint)"]);class gr{constructor(e,t,a){this.gaugeControllerAddress=t,this.multicall=Cn(e,a)}async getRelativeWeights(e,t){const a=e.map((e=>[this.gaugeControllerAddress,Tr.encodeFunctionData("gauge_relative_weight_write",[n.getAddress(e),t||Math.floor(Date.now()/1e3)])])),[,s]=await this.multicall.aggregate(a);return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Se(s[a],18))),e)),{})}}class xr{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 Ir extends xr{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=vn(e)}}class Er extends xr{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=kn(e)}}class wr extends Er{async query(e){e.orderBy||(e.orderBy=dn.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(e,t,a){return this.findAllBy(exports.GaugeShareAttributes.UserAddress,e,t,a)}async findByGauge(e,t,a){return this.findAllBy(exports.GaugeShareAttributes.GaugeId,e,t,a)}}const Ar=new e.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 Sr{constructor(e,t,a){this.chainId=t,this.multicall=Cn(e,a)}async getTotalSupplies(e){const t=e.map((e=>[e,Ar.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(Se(n[a],18))),e)),{})}async getWorkingSupplies(e){const t=e.map((e=>[e,Ar.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(Se(n[a],18))),e)),{})}async getRewardCounts(e){let t;if(248==this.chainId||9372==this.chainId||6343==this.chainId||4326==this.chainId){const a=e.map((e=>[e,Ar.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],r=n.map(((e,t)=>{const n=[];for(let t=0;t<a[e];t++)n.push([e,Ar.encodeFunctionData("reward_tokens",[t])]);return s[t+1]=s[t]+a[e],n})).flat(),[,i]=await this.multicall.aggregate(r);return n.reduce(((e,t,a)=>{const n=s[a],r=s[a+1],o=[];for(let e=n;e<r;e++)o.push(Ar.decodeFunctionResult("reward_tokens",i[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,Ar.encodeFunctionData("reward_data",[a[e][t]])]);return n[t+1]=n[t]+a[e].length,s})).flat(),[,r]=await this.multicall.aggregate(s),i=r.map((e=>Ar.decodeFunctionResult("reward_data",e)[0]));return Object.keys(a).reduce(((e,t,s)=>{const r=n[s],o=a[t].reduce(((e,t,a)=>(e[t]||(e[t]=i[r+a]),e)),{});return e[t]||(e[t]=o),e}),{})}}class Pr{constructor(e){this.gauges=[],this.client=kn(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 Br=6048e5;class _r{constructor(e,t,a,n,s){this.chainId=n,this.workingSupplies={},this.workingSuppliesNextPeriod={},this.relativeWeights={},this.relativeWeightsNextPeriod={},this.rewardData={},a&&(this.gaugeController=new gr(t,a,s)),this.multicall=new Sr(t,n,s),this.subgraph=new Pr(e)}async fetch(){const e=await this.subgraph.fetch(),t=e.map((e=>e.id));if(248!=this.chainId&&9372!=this.chainId&&6343!=this.chainId&&4326!=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()+Br)/Br)*Br)/1e3;this.relativeWeightsNextPeriod=await this.gaugeController.getRelativeWeights(t,e)}let n=!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:a.BigNumber.from(0),integral:a.BigNumber.from(0),token:e.id.split("-")[0],decimals:e.decimals,rate:Pe(e.rate||"0",e.decimals),period_finish:a.BigNumber.from(e.periodFinish||"0")}]))):{}),t.tokens&&t.tokens.length>0&&(n=!0),e}),{}),n||(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 Or{constructor(e,t){this.url=e,this.apiKey=t}async get(e){try{const t=this.toPayload(e),{data:a}=await E.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:y.jsonToGraphQLQuery({query:e})})}}class vr{constructor(e){var t,a;this.skip=0,this.client=vn(e.url),this.blockHeight=e.blockHeight,this.chainId=e.chainId;const n={orderBy:Ea.TotalLiquidity,orderDirection:fa.Desc,where:{swapEnabled:{eq:!0}}},s=Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||n),r=Object.assign({},(null===(a=e.query)||void 0===a?void 0:a.attrs)||{});this.query={args:s,attrs:r}}async fetchDefault(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0},orderBy:Ea.TotalLiquidity,orderDirection:fa.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 je(this.query.args).format(new He),{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,r,i,o,d,p;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!==(r=e.priceRateProviders)&&void 0!==r?r:void 0,createTime:e.createTime,mainIndex:null!==(i=e.mainIndex)&&void 0!==i?i: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!==(p=e.upperTarget)&&void 0!==p?p:"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 kr{constructor(e){this.skip=0,this.poolsSubgraph=new vr({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 Gn(e,this.multicall,this.vault,this.provider)}async fetch(e){const t=await this.poolsSubgraph.fetch(e);return await Gn(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 Nr extends Er{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 Cr;exports.PoolJoinExitAttributes=void 0,(Cr=exports.PoolJoinExitAttributes||(exports.PoolJoinExitAttributes={})).Pool="pool",Cr.Sender="sender";class Dr extends Ir{async query(e){e.orderBy||(e.orderBy=ua.Timestamp),e.orderDirection||(e.orderDirection=fa.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(e,t,a){return this.findAllBy(exports.PoolJoinExitAttributes.Sender,e,t,a)}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(e,t,a){return this.findAllBy(exports.PoolJoinExitAttributes.Pool,e,t,a)}}class Fr extends Ir{async query(e){e.orderBy||(e.orderBy=ga.Balance),e.orderDirection||(e.orderDirection=fa.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(e,t,a){return this.findAllBy(exports.PoolShareAttributes.UserAddress,e,t,a)}async findByPool(e,t,a){return this.findAllBy(exports.PoolShareAttributes.PoolId,e,t,a)}}class Rr{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 Mr{constructor(e,t=1){this.chainId=t,this.prices={},this.baseTokenAddresses=e.map(Fe),this.urlBase=`${et[t].urls.priceUrl}/price/?vs_currencies=usd,eth`,this.debouncer=new Le(this.fetch.bind(this),200)}fetch(e,{signal:t}={}){return e.length,E.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 E.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 6343:case 4326: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 Lr{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 E.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 6343:case 4326: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 Ur{constructor(e,t=1){this.subgraphUrl=e,this.chainId=t,this.prices={},this.debouncer=new Le(this.fetch.bind(this),200)}async fetch(e,{signal:t}={}){return e.length,E.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 Gr{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 qr{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 Wr=new e.Interface(["function rate() view returns (uint256)"]);class $r{constructor(e,t,a){this.network=a,this.multicall=Cn(e,t)}async fetch(e){const t=Object.values(Be[e]),a=t.map((e=>[e,Wr.encodeFunctionData("rate",[])])),[,n]=await this.multicall.aggregate(a);return t.reduce(((e,t,a)=>(e[t]||(e[t]="0x"==n[a]?0:parseFloat(Se(n[a],27))),e)),{})}async getRate(e){return this.network!=exports.Network.MAINNET&&this.network!=exports.Network.POLYGON?1:Object.values(Be[this.network]).includes(e)?(this.rates||(this.rates=this.fetch(this.network)),(await this.rates)[e]):1}}const Vr=new e.Interface(["function getTokensDistributedInWeek(address token, uint timestamp) view returns (uint)"]),Hr=new e.Interface(["function totalSupply() view returns (uint)"]),jr=new e.Interface(["function getRate() view returns (uint)"]);class Kr{constructor(e,t,a,n,s,r){this.feeDistributorAddress=t,this.balAddress=a,this.veBalAddress=n,this.bbAUsdAddress=s,this.multicall=Cn(e,r)}async fetch(e){const t=this.getPreviousWeek(e),a=[[this.feeDistributorAddress,Vr.encodeFunctionData("getTokensDistributedInWeek",[n.getAddress(this.balAddress),t])],[this.feeDistributorAddress,Vr.encodeFunctionData("getTokensDistributedInWeek",[n.getAddress(this.bbAUsdAddress),t])],[this.veBalAddress,Hr.encodeFunctionData("totalSupply",[])],[this.bbAUsdAddress,jr.encodeFunctionData("getRate",[])]],[,s]=await this.multicall.aggregate(a);return{balAmount:parseFloat(Se(s[0],18)),bbAUsdAmount:parseFloat(Se(s[1],18)),veBalSupply:parseFloat(Se(s[2],18)),bbAUsdPrice:parseFloat(Se(s[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 Zr=new e.Interface(["function getProtocolFeesCollector() view returns (address)"]),Xr=new e.Interface(["function getSwapFeePercentage() view returns (uint)"]);let Jr;class Yr{constructor(e,t){this.provider=t,this.vault=new s.Contract(e,Zr,this.provider)}async fetch(){const e=await this.vault.getProtocolFeesCollector(),t=new s.Contract(e,Xr,this.provider),a=await t.getSwapFeePercentage();return parseFloat(Se(a,18))}async find(){return Jr||(Jr=this.fetch()),this.swapFeePercentage=await Jr,this.swapFeePercentage}async findBy(){return this.find()}}const zr=new e.Interface(["function getSwapFeePercentage() view returns (uint)"]);let Qr;class ei{constructor(e,t,a){this.protocolFeePercentagesProviderAddress=t,this.multicall=Cn(e,a)}async fetch(){const e=[[this.protocolFeePercentagesProviderAddress,zr.encodeFunctionData("getFeeTypePercentage",[0])],[this.protocolFeePercentagesProviderAddress,zr.encodeFunctionData("getFeeTypePercentage",[2])]],[,t]=await this.multicall.aggregate(e);return{swapFee:parseFloat(Se(t[0],18)),yieldFee:parseFloat(Se(t[2],18))}}async getFees(){return Qr||(Qr=this.fetch()),this.protocolFees=await Qr,this.protocolFees}}const ti={stETH:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",wstETH:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",arbitrumStEth:"0x5979d7b546e38e414f7e9822514be443a4800529"},ai=async()=>{let e=0;try{const t=await E.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{[ti.stETH]:e,[ti.wstETH]:e,[ti.arbitrumStEth]:e}},ni={rETH:"0xae78736cd615f374d3085123a210448e74fc6393"},si=async()=>{let e=0;try{const t=await E.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{[ni.rETH]:e}},ri={stMATIC:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4"},ii=async()=>{let e=0;try{const t=await E.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{[ri.stMATIC]:e}},oi={usdcUSDplus:"0x1aafc31091d93c3ff003cff5d2d8f7ba2e728425",usdcUSDplus2:"0x6933ec1ca55c06a894107860c92acdfd2dd8512f"},di=async()=>{let e=0;try{const{data:t}=await E.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(oi).map((t=>[t,e])))},pi={sfrxETH:"0xac3e018457b222d93114458476f3e3416abbe38f"},ci=async()=>{let e=0;try{const t=await E.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{[pi.sfrxETH]:e}},li={maticX:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6"},ui=async()=>{let e=0;try{const t=await E.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{[li.maticX]:e}},bi={qETH:"0x93ef1ea305d11a9b2a3ebb9bb4fcc34695292e7d"},yi=async()=>{let e=0;try{const t=await E.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=tranchess"),[{weeklyAveragePnlPercentage:n}]=t.data;e=Math.round(parseFloat(Se(a.BigNumber.from(n).mul(365).mul(1e4),18)))}catch(e){console.error("Failed to fetch qETH APR:",e)}return{[bi.qETH]:e}},mi={USDR:"0xaf0d9d65fc54de245cda37af3d18cbec860a4d4b"},fi=async()=>{let e=0;try{const t=await E.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{[mi.USDR]:e}},hi={rETH:"0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593"},Ti=async()=>{let e=0;try{const t=await E.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{[hi.rETH]:e}},gi=new l.JsonRpcProvider("https://rpc.ankr.com/eth",1),xi={getPoolsUI:new s.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"}],gi).getPoolsUI},Ii={sApe:"0x7966c5bae631294d7cffcea5430b78c2f76db6fa"},Ei=async(e=1,t=xi)=>{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{[Ii.sApe]:a}},wi={eUSDC:"0xeb91861f8a4e1c12333f42dce8fb0ecdc28da716",eDAI:"0xe025e3ca2be02316033184551d4d3aa22024d9dc",eUSDT:"0x4d19f33948b99800b6113ff3e83bec9b537c85d2",eFRAX:"0x5484451a88a35cd0878a1be177435ca8a0e4054e"},Ai={[exports.Network.MAINNET]:"https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet"},Si=async()=>{const e=exports.Network.MAINNET,t={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(wi)}},n=await E.default.post(Ai[e],t),{data:{assets:s}}=n.data,r={eUSDT:0,eDAI:0,eUSDC:0,eFRAX:0};return s.forEach((({eTokenAddress:e,supplyAPY:t})=>{const n=Object.entries(wi).filter((([,t])=>t.toLocaleLowerCase()===e.toLocaleLowerCase()))[0][0];r[n]=Math.round(1e4*parseFloat(Se(a.BigNumber.from(t),27)))})),{[wi.eUSDT]:r.eUSDT,[wi.eDAI]:r.eDAI,[wi.eUSDC]:r.eUSDC,[wi.eFRAX]:r.eFRAX}},Pi=Object.fromEntries([...Object.values(ti).map((e=>[e,ai])),...Object.values(ri).map((e=>[e,ii])),...Object.values(_e).map((e=>[e,De])),...Object.values(oi).map((e=>[e,di])),...Object.values(ni).map((e=>[e,si])),...Object.values(pi).map((e=>[e,ci])),...Object.values(li).map((e=>[e,ui])),...Object.values(bi).map((e=>[e,yi])),...Object.values(mi).map((e=>[e,fi])),...Object.values(hi).map((e=>[e,Ti])),...Object.values(Ii).map((e=>[e,Ei])),...Object.values(wi).map((e=>[e,Si]))]);class Bi{constructor(e,t=Pi){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 _i=e=>`{\n blocks(first: 1, orderBy: timestamp, orderDirection: asc, where: { timestamp_gt: ${e} }) {\n number\n }\n}`,Oi=async(e,t)=>{const a={query:_i(t)},n=await E.default.post(e,a),{data:{blocks:s}}=n.data;return parseInt(s[0].number)};class vi{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]:Oi(this.endpoint,e)}),this.blocks[e]}}async findBy(e="",t=""){}}var ki,Ni,Ci=[{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"},{chainId:6343,address:"0xAba76Cdc5910F6627856EB75Bcce0171376999C7",symbol:"weth"},{chainId:4326,address:"0x4200000000000000000000000000000000000006",symbol:"weth"}];class Di{constructor(e,t,a){this.pools=new vr({url:e.urls.subgraph,chainId:e.chainId}),this.poolsOnChain=new kr({url:e.urls.subgraph,chainId:e.chainId,provider:t,multicall:e.addresses.contracts.multicall,vault:e.addresses.contracts.vault,query:a}),this.poolShares=new Fr(e.urls.subgraph,e.chainId),this.poolJoinExits=new Dr(e.urls.subgraph,e.chainId),e.urls.gaugesSubgraph&&(this.poolGauges=new Nr(e.urls.gaugesSubgraph,e.chainId),this.gaugeShares=new wr(e.urls.gaugesSubgraph,e.chainId)),e.urls.blockNumberSubgraph&&(this.blockNumbers=new vi(e.urls.blockNumberSubgraph));this.yesterdaysPools=new vr({url:e.urls.subgraph,chainId:e.chainId,blockHeight:async()=>{const e=await t.getBlockNumber();return Number(e)-5e3}});const n=Ci.filter((t=>t.chainId==e.chainId)).map((e=>e.address)),s=new Mr(n,e.chainId),r=new Ur(e.urls.subgraph,e.chainId),i=new $r(e.addresses.contracts.multicall,t,e.chainId);this.tokenPrices=new Gr(s,r,i);const o=new Lr(e.chainId);this.tokenHistoricalPrices=new qr(o,i),this.tokenMeta=new Rr([]),e.urls.gaugesSubgraph&&(this.liquidityGauges=new _r(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 Kr(e.addresses.contracts.multicall,e.addresses.contracts.feeDistributor,e.addresses.tokens.bal,e.addresses.tokens.veBal,e.addresses.tokens.bbaUsd,t)),this.feeCollector=new Yr(e.addresses.contracts.vault,t),e.addresses.contracts.protocolFeePercentagesProvider&&(this.protocolFees=new ei(e.addresses.contracts.multicall,e.addresses.contracts.protocolFeePercentagesProvider,t)),this.tokenYields=new Bi(e.chainId)}}!function(e){e[e.Direct=0]="Direct",e[e.TokenIn=1]="TokenIn",e[e.TokenOut=2]="TokenOut",e[e.Middle=3]="Middle"}(ki||(ki={})),function(e){e[e.Swap=0]="Swap",e[e.BatchSwap=1]="BatchSwap",e[e.Join=2]="Join",e[e.Exit=3]="Exit"}(Ni||(Ni={}));const Fi={type:Ni.BatchSwap,swaps:[],opRef:[],minOut:"0",assets:[],hasTokenIn:!1,hasTokenOut:!1,fromInternal:!1,toInternal:!1,limits:[],approveTokens:[],sender:"",receiver:""},Ri=new e.Interface(Ts);function Mi(e,t){return e.some((e=>e.address.toLowerCase()===t.toLowerCase()))}function Li(e,t){const a=t[e.assetOutIndex],n=C(e.poolId);return a.toLowerCase()===n.toLowerCase()}function Ui(e,t){const a=t[e.assetInIndex],n=C(e.poolId);return a.toLowerCase()===n.toLowerCase()}function Gi(e,t,a){let n={};var s;return e!==ki.TokenIn&&e!==ki.Middle||(s=a,n={index:t,key:ds.toChainedReference(s)},a++),[n,a]}function qi(e,t){return Ye(a.BigNumber.from(e),a.BigNumber.from(t)).toString()}function Wi(e,t,a,n){let s=e.amount;return(a===ki.TokenOut||a===ki.Middle&&t===Ni.Join||a===ki.Middle&&t===Ni.Exit)&&(s=ds.toChainedReference(n-1).toString()),s}function $i(e,t,a,n){let s;return s=a===e&&n===t?ki.Direct:a===e?ki.TokenIn:n===t?ki.TokenOut:ki.Middle,s}function Vi(e,n){const s=function(e){const t=[],a=[],n=[];for(const s of e)s.type===Ni.Exit||s.type===Ni.Join?s.hasTokenIn?t.push(s):s.hasTokenOut?a.push(s):n.push(s):n.push(s);return[...t,...n,...a]}(e),r=function(e,n){const s=[];let r=d.cloneDeep(Fi);r.assets=n,r.limits=Array(n.length).fill(a.BigNumber.from("0"));let i=!0,o={};for(const p of e)p.type===Ni.Swap?(i&&(o=p,i=!1),p.isBptIn&&r.approveTokens.push(p.assets[p.swap.assetInIndex]),p.fromInternal===o.fromInternal&&p.toInternal===o.toInternal&&p.receiver===o.receiver&&p.sender===o.sender||r.swaps.length>0&&(s.push(r),r=d.cloneDeep(Fi),r.assets=n,r.limits=Array(n.length).fill(a.BigNumber.from("0"))),r.swaps.push(p.swap),r.opRef.push(...p.opRef),r.fromInternal=p.fromInternal,r.toInternal=p.toInternal,r.sender=p.sender,r.receiver=p.receiver,p.hasTokenIn?(r.hasTokenIn=!0,r.limits[p.swap.assetInIndex]=r.limits[p.swap.assetInIndex].add(p.amountIn)):r.limits[p.swap.assetInIndex]=t.MaxInt256,p.hasTokenOut&&(r.hasTokenOut=!0,r.limits[p.swap.assetOutIndex]=r.limits[p.swap.assetOutIndex].sub(p.minOut)),o=p):(r.swaps.length>0&&(s.push(r),r=d.cloneDeep(Fi),r.assets=n,r.limits=Array(n.length).fill(a.BigNumber.from("0"))),s.push(p));return r.swaps.length>0&&s.push(r),s}(s,n);return r}function Hi(e,t,a,n,s,r,i,o){var d;const p=$i(t,a,e.assetInIndex,e.assetOutIndex),c=Wi(e,Ni.Join,p,n),l=qi(null!==(d=e.returnAmount)&&void 0!==d?d:"0",r),[u,b]=Gi(p,e.assetOutIndex,n);let y=o,m=!0,f=!1;p!==ki.Direct&&p!==ki.TokenIn||(y=i,m=!1,f=!0);let h=o,T=!1;p!==ki.Direct&&p!==ki.TokenOut||(h=i,T=!0);return[{type:Ni.Join,poolId:e.poolId,tokenIn:s[e.assetInIndex],bpt:s[e.assetOutIndex],opRef:u,minOut:l,amountIn:c,assets:s,actionStep:p,sender:y,receiver:h,fromInternal:m,hasTokenIn:f,hasTokenOut:T},b]}function ji(e,t,a,n,s,r,i,o){var d;const p=$i(t,a,e.assetInIndex,e.assetOutIndex),c=Wi(e,Ni.Exit,p,n),l=qi(null!==(d=e.returnAmount)&&void 0!==d?d:"0",r),[u,b]=Gi(p,e.assetOutIndex,n);let y=o,m=!1;p!==ki.Direct&&p!==ki.TokenIn||(y=i,m=!0);let f=!1,h=!0,T=o;p!==ki.Direct&&p!==ki.TokenOut||(T=i,h=!1,f=!0);return[{type:Ni.Exit,poolId:e.poolId,tokenOut:s[e.assetOutIndex],bpt:s[e.assetInIndex],opRef:u.key?[u]:[],minOut:l,amountIn:c,assets:s,actionStep:p,sender:y,receiver:T,toInternal:h,hasTokenIn:m,hasTokenOut:f},b]}function Ki(e,t,a,n,s,r,i,o,d){var p;const c=$i(t,a,e.assetInIndex,e.assetOutIndex),l=Wi(e,Ni.Swap,c,n);e.amount=l;const u=qi(null!==(p=e.returnAmount)&&void 0!==p?p:"0",r),[b,y]=Gi(c,e.assetOutIndex,n),m=c===ki.Direct||c===ki.TokenIn,f=c===ki.Direct||c===ki.TokenOut,h=Mi(i,s[e.assetInIndex]);let T=!0;(m||h)&&(T=!1);let g,x,I=!0;(f||Mi(i,s[e.assetOutIndex]))&&(I=!1),g=m?o:d,x=f?o:d;return[{type:Ni.Swap,opRef:b.key?[b]:[],minOut:u,amountIn:l,assets:s,swap:e,hasTokenIn:m,hasTokenOut:f,fromInternal:T,toInternal:I,isBptIn:h,sender:g,receiver:x},y]}function Zi(e,t,a){const n=e.tokensList,s=new q(a),[r]=s.sortTokens(n),i=t.tokenOut,o=r.findIndex((e=>e.toLowerCase()===i.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.minOut;const p=t.amountIn,c={assets:r,minAmountsOut:d,userData:S.exitExactBPTInForOneTokenOut(p,o),toInternalBalance:t.toInternal,poolId:t.poolId,poolKind:0,sender:t.sender,recipient:t.receiver,outputReferences:t.opRef,exitPoolRequest:{}},l=ds.constructExitCall(c),u=t.hasTokenOut?d[o]:"0";return[l,t.hasTokenIn?p:"0",u]}function Xi(e,t,a){const n=e.tokensList,s=new q(a),[r]=s.sortTokens(n),i=t.tokenIn,o=r.findIndex((e=>e.toLowerCase()===i.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.amountIn;const p=t.minOut,c=S.joinExactTokensInForBPTOut(d,p),l={poolId:t.poolId,sender:t.sender,recipient:t.receiver,kind:0,joinPoolRequest:{assets:r,maxAmountsIn:d,userData:c,fromInternalBalance:t.fromInternal},value:"0",outputReference:t.opRef.key?t.opRef.key.toString():"0"},u=ds.encodeJoinPool(l),b=t.hasTokenOut?p:"0";return[u,t.hasTokenIn?d[o]:"0",b]}function Ji(e,n,s){const r=[];for(const a of e.approveTokens){const e=ds.encodeApproveVault(a,t.MaxUint256.toString());r.push(e)}const i={sender:e.sender,recipient:e.receiver,fromInternalBalance:e.fromInternal,toInternalBalance:e.toInternal},o={swapType:exports.SwapType.SwapExactIn,swaps:e.swaps,assets:e.assets,funds:i,limits:e.limits.map((e=>e.toString())),deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:e.opRef},d=ds.encodeBatchSwap(o);r.push(d);const p=e.assets.findIndex((e=>e.toLowerCase()===n.toLowerCase())),c=e.assets.findIndex((e=>e.toLowerCase()===s.toLowerCase()));return[r,e.hasTokenIn?e.limits[p].toString():"0",e.hasTokenOut?e.limits[c].abs().toString():"0"]}Object.defineProperty(exports,"PoolFilter",{enumerable:!0,get:function(){return p.PoolFilter}}),Object.defineProperty(exports,"RouteProposer",{enumerable:!0,get:function(){return p.RouteProposer}}),Object.defineProperty(exports,"SOR",{enumerable:!0,get:function(){return p.SOR}}),Object.defineProperty(exports,"SwapTypes",{enumerable:!0,get:function(){return p.SwapTypes}}),Object.defineProperty(exports,"formatSequence",{enumerable:!0,get:function(){return p.formatSequence}}),Object.defineProperty(exports,"getTokenAddressesForSwap",{enumerable:!0,get:function(){return p.getTokenAddressesForSwap}}),Object.defineProperty(exports,"parseToPoolsDict",{enumerable:!0,get:function(){return p.parseToPoolsDict}}),Object.defineProperty(exports,"phantomStableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return p.phantomStableBPTForTokensZeroPriceImpact}}),Object.defineProperty(exports,"queryBatchSwapTokensIn",{enumerable:!0,get:function(){return p.queryBatchSwapTokensIn}}),Object.defineProperty(exports,"queryBatchSwapTokensOut",{enumerable:!0,get:function(){return p.queryBatchSwapTokensOut}}),Object.defineProperty(exports,"stableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return p.stableBPTForTokensZeroPriceImpact}}),Object.defineProperty(exports,"weightedBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return p.weightedBPTForTokensZeroPriceImpact}}),exports.APR_THRESHOLD=1e4,exports.AaveHelpers=class{static async getRate(e,t){const a=new s.Contract(e,U,t);return(await a.getRate()).toString()}},exports.AaveRates=$r,exports.AssetHelpers=q,exports.BalancerAPIArgsFormatter=Ve,exports.BalancerError=nt,exports.BalancerErrors=$,exports.BalancerMinterAuthorization=K,exports.BalancerSDK=class{constructor(e,t=new Hn(e),a=new ps(e)){this.config=e,this.sor=t,this.subgraph=a,this.networkConfig=Vn(e),this.provider=t.provider,this.data=new Di(this.networkConfig,t.provider,e.subgraphQuery),this.swaps=new is(this.config),this.relayer=new ds(this.swaps),this.pricing=new cs(e,this.swaps),this.pools=new hr(this.networkConfig,this.data),this.balancerContracts=new Is(this.networkConfig.addresses.contracts,t.provider),this.zaps=new Vs(this.networkConfig.chainId)}get rpcProvider(){return this.sor.provider}get contracts(){return this.balancerContracts.contracts}},exports.BlockNumberRepository=vi,exports.CoingeckoHistoricalPriceRepository=Lr,exports.CoingeckoPriceRepository=Mr,exports.ComposableStablePoolEncoder=O,exports.Data=Di,exports.Debouncer=Le,exports.FeeCollectorRepository=Yr,exports.FeeDistributorRepository=Kr,exports.GaugeControllerMulticallRepository=gr,exports.GaugeSharesRepository=wr,exports.GraphQLArgsBuilder=je,exports.HistoricalPriceProvider=qr,exports.Liquidity=Wt,exports.LiquidityGaugeSubgraphRPCProvider=_r,exports.LiquidityGaugesMulticallRepository=Sr,exports.LiquidityGaugesSubgraphRepository=Pr,exports.ManagedPoolEncoder=P,exports.POOLS=function(e){return L[e]?L[e]:M},exports.PoolGaugesRepository=Nr,exports.PoolJoinExitRepository=Dr,exports.PoolSharesRepository=Fr,exports.Pools=hr,exports.PoolsBalancerAPIRepository=class{constructor(e){var t,a;this.pools=[],this.skip=0,this.client=new Or(e.url,e.apiKey);this.query={args:Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||{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 je(this.query.args).format(new Ve),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}},exports.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}},exports.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)}},exports.PoolsSubgraphOnChainRepository=kr,exports.PoolsSubgraphRepository=vr,exports.ProtocolFeesProvider=ei,exports.Relayer=ds,exports.RelayerAuthorization=j,exports.SHALLOW_COMPOSABLE_STABLE_BUFFER=1e6,exports.Sor=Hn,exports.StablePoolEncoder=A,exports.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)}},exports.StaticTokenProvider=Rr,exports.Subgraph=ps,exports.SubgraphArgsFormatter=He,exports.SubgraphPriceRepository=Ur,exports.Swaps=is,exports.TokenPriceProvider=Gr,exports.TokenYieldsRepository=Bi,exports.WeightedPoolEncoder=S,exports.accountToAddress=V,exports.addressMapIn=Re,exports.balEmissions=Xs,exports.bn=e=>a.parseFixed(`${e}`,18),exports.buildRelayerCalls=function(e,t,n,s,r,i,o){const d=Vi(function(e,t,a,n,s,r,i,o){const d=n.findIndex((t=>t.toLowerCase()===e.toLowerCase())),p=n.findIndex((e=>e.toLowerCase()===t.toLowerCase())),c=[];let l=0,u={};for(const e of a)if(Li(e,n)){const[t,a]=Hi(e,d,p,l,n,s,i,o);l=a,c.push(t),u=t}else{if(!Ui(e,n)){const t=e.amount,[a,b]=Ki(e,d,p,l,n,s,r,i,o);u.type===Ni.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"),l=b,c.push(a),u=a;continue}{const[t,a]=ji(e,d,p,l,n,s,i,o);l=a,c.push(t),u=t}}return c}(e.tokenIn,e.tokenOut,e.swaps,e.tokenAddresses,i,t,n,s),e.tokenAddresses),p=[],c=[],l=[];o&&p.push(function(e,t){return ds.encodeSetRelayerApproval(t,!0,e)}(o,s));for(const n of d){if(n.type===Ni.Exit){const e=t.find((e=>e.id===n.poolId));if(void 0===e)throw new nt(exports.BalancerErrorCode.NO_POOL_DATA);const[s,i,o]=Zi(e,n,r);p.push(s),c.push(a.BigNumber.from(i)),l.push(a.BigNumber.from(o))}if(n.type===Ni.Join){const e=t.find((e=>e.id===n.poolId));if(void 0===e)throw new nt(exports.BalancerErrorCode.NO_POOL_DATA);const[s,i,o]=Xi(e,n,r);p.push(s),c.push(a.BigNumber.from(i)),l.push(a.BigNumber.from(o))}if(n.type===Ni.BatchSwap){const[t,s,r]=Ji(n,e.tokenIn,e.tokenOut);p.push(...t),c.push(a.BigNumber.from(s)),l.push(a.BigNumber.from(r))}}return function(e,t,n,s){const r=e.reduce(((e=a.BigNumber.from(0),t)=>e.add(t))),i=t.reduce(((e=a.BigNumber.from(0),t)=>e.add(t))),o=i.sub(Ye(n.returnAmount,a.BigNumber.from(s)));if(!r.eq(n.swapAmount)||!o.lt("3"))throw new nt(exports.BalancerErrorCode.RELAY_SWAP_AMOUNTS)}(c,l,e,i),{to:s,data:Ri.encodeFunctionData("multicall",[p]),rawCalls:p}},exports.canUseJoinExit=function(e,a,n){return e!==p.SwapTypes.SwapExactOut&&a.toLowerCase()!==t.AddressZero.toLowerCase()&&n.toLowerCase()!==t.AddressZero.toLowerCase()},exports.formatFixed=Ge,exports.formatFromBigInt18=function(e){return a.formatFixed(a.BigNumber.from(e),18)},exports.getLimitsForSlippage=Ze,exports.getPoolAddress=C,exports.getPoolNonce=F,exports.getPoolSpecialization=D,exports.insert=$e,exports.isNormalizedWeights=e=>{const a=e.reduce(((e,t)=>e.add(t)),t.Zero);return a.eq(t.WeiPerEther)},exports.isSameAddress=We,exports.parseFixed=Ue,exports.parsePoolInfo=ne,exports.parseToBigInt18=qe,exports.signPermit=async(e,n,s,i,o=t.MaxUint256,d)=>{const{chainId:p}=await e.provider.getNetwork(),c=await n.getAddress();d||(d=await e.nonces(c));const l={name:await e.name(),version:"1",chainId:p,verifyingContract:e.address},u={owner:c,spender:await V(s),value:i,nonce:d,deadline:o},b=await n._signTypedData(l,{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(b),deadline:a.BigNumber.from(o),nonce:a.BigNumber.from(d)}},exports.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)))},exports.splitPoolId=e=>({address:C(e),specialization:D(e),nonce:F(e)}),exports.toNormalizedWeights=function(e){if(100==e.length)return Array(100).fill(t.WeiPerEther.div(100));const a=e.reduce(((e,t)=>e.add(t)),t.Zero);if(a.eq(t.WeiPerEther))return e;const n=[];let s=t.Zero;for(let r=0;r<e.length;r++)r<e.length-1?(n[r]=e[r].mul(t.WeiPerEther).div(a),s=s.add(n[r])):n[r]=t.WeiPerEther.sub(s);return n},exports.tokenAddressForPricing=Fe,exports.tokensToTokenPrices=function(e){const t={};return e.forEach((e=>{e.price&&(t[e.address]=e.price)})),t},exports.unwrapToken=Me;
|
|
488
|
+
`,On=(e,t,a)=>e();function vn(e){return sn(new u.GraphQLClient(e))}function kn(e){return function(e,t=On){return{GaugeShare:(a,n)=>t((t=>e.request(An,a,{...n,...t})),"GaugeShare","query"),GaugeShares:(a,n)=>t((t=>e.request(Sn,a,{...n,...t})),"GaugeShares","query"),LiquidityGauges:(a,n)=>t((t=>e.request(Pn,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(_n,a,{...n,...t})),"PoolGauges","query")}}(new u.GraphQLClient(e))}const Nn=["function aggregate(tuple[](address target, bytes callData) memory calls) public view returns (uint256 blockNumber, bytes[] memory returnData)"],Cn=(e,t)=>new s.Contract(e,Nn,t);class Dn{constructor(t,a,n,s={}){this.options={},this.calls=[],this.paths=[],this.multiAddress=t,this.provider=a,this.interface=new e.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)=>d.set(t,this.paths[a],e.length>1?e:e[0]))),this.calls=[],this.paths=[],t}async executeMulticall(){const e=Cn(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"}],Rn=[{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"}],Mn=[{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"}],Ln=[{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"}],Un=[{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 Gn(e,t,n,s){if(0===e.length)return e;const r=Object.values(Object.fromEntries([...c.Vault__factory.abi,...U,...Fn,...Rn,...Mn,...Ln,...Un].map((e=>[e.name,e])))),i=new Dn(t,s,r),o=Object.values(p.PoolFilter),d=[];e.forEach((e=>{o.includes(e.poolType)?(d.push(e),i.call(`${e.id}.poolTokens`,n,"getPoolTokens",[e.id]),i.call(`${e.id}.totalSupply`,e.address,"totalSupply"),(e.poolType.includes("Linear")||"StablePhantom"===e.poolType)&&i.call(`${e.id}.virtualSupply`,e.address,"getVirtualSupply"),"ComposableStable"===e.poolType&&i.call(`${e.id}.actualSupply`,e.address,"getActualSupply"),"Weighted"===e.poolType||"LiquidityBootstrapping"===e.poolType||"Investment"===e.poolType?(i.call(`${e.id}.weights`,e.address,"getNormalizedWeights"),i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Stable"===e.poolType||"MetaStable"===e.poolType||"StablePhantom"===e.poolType||"ComposableStable"===e.poolType?(i.call(`${e.id}.amp`,e.address,"getAmplificationParameter"),i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Element"===e.poolType?i.call(`${e.id}.swapFee`,e.address,"percentFee"):e.poolType.toString().includes("Linear")?(i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage"),i.call(`${e.id}.targets`,e.address,"getTargets"),i.call(`${e.id}.rate`,e.address,"getWrappedTokenRate")):e.poolType.toString().includes("Gyro")&&i.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):console.error(`Unknown pool type: ${e.poolType} ${e.id}`)}));let l={};try{l=await i.execute()}catch(e){throw"Issue with multicall execution."}const u=[];return Object.entries(l).forEach((([e,t],n)=>{try{const{poolTokens:s,swapFee:r,weights:i,totalSupply:o,virtualSupply:p,actualSupply:c}=t;if("Stable"===d[n].poolType||"MetaStable"===d[n].poolType||"StablePhantom"===d[n].poolType||"ComposableStable"===d[n].poolType){if(!t.amp)return void console.error(`Stable Pool Missing Amp: ${e}`);d[n].amp=a.formatFixed(t.amp[0],3)}if(d[n].poolType.includes("Linear")){if(!t.targets)return void console.error(`Linear Pool Missing Targets: ${e}`);d[n].lowerTarget=a.formatFixed(t.targets[0],18),d[n].upperTarget=a.formatFixed(t.targets[1],18);const s=d[n].wrappedIndex;if(void 0===s||void 0===t.rate)return void console.error(`Linear Pool Missing WrappedIndex or PriceRate: ${e}`);d[n].tokens[s].priceRate=a.formatFixed(t.rate,18)}if(d[n].swapFee=a.formatFixed(r,18),s.tokens.forEach(((t,r)=>{const o=d[n].tokens.find((e=>We(e.address,t)));if(!o)throw`Pool Missing Expected Token: ${e} ${t}`;o.balance=a.formatFixed(s.balances[r],o.decimals),i&&(o.weight=a.formatFixed(i[r],18))})),d[n].poolType.includes("Linear")||"StablePhantom"===d[n].poolType){if(void 0===p)return void console.error(`Pool with pre-minted BPT missing Virtual Supply: ${e}`);d[n].totalShares=a.formatFixed(p,18)}else if("ComposableStable"===d[n].poolType){if(void 0===c)return void console.error(`ComposableStable missing Actual Supply: ${e}`);d[n].totalShares=a.formatFixed(c,18)}else d[n].totalShares=a.formatFixed(o,18);u.push(d[n])}catch(e){throw`Issue with pool onchain data: ${e}`}})),u}class qn{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?d.parseInt(e.expiryTime):void 0,unitSeconds:e.unitSeconds?d.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=>We(t,e.address)))})));return!1===this.sorConfig.fetchOnChainBalances?e:Gn(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:"0.000000000001"},orderBy:Ea.TotalLiquidity,orderDirection:fa.Desc});return[...e,...t,...a]}}class Wn{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 E.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 $n{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=d.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 Vn(e){var t,a;if("number"==typeof e.network){const a=et[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 Hn extends p.SOR{constructor(e){const t=Vn(e),a=Hn.getSorConfig(e),n=Hn.getSorNetworkConfig(t),s=new l.JsonRpcProvider(e.rpcUrl,e.network),r=vn(t.urls.subgraph);super(s,n,Hn.getPoolDataService(t,a,s,r),Hn.getTokenPriceService(t,a,r))}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 qn(n,a,e,t)}static getTokenPriceService(e,t,a){return"object"==typeof t.tokenPriceService?t.tokenPriceService:("subgraph"===t.tokenPriceService&&new $n(a,e.addresses.tokens.wrappedNativeAsset),new Wn(e.chainId))}}function jn(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 Kn(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 Zn(e){return-1*Number(e)}function Xn(e){return d.sum(e)}var Jn=[{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 Yn={"0xae7ab96520de3a18e5e111b5eaab095312d7fe84":"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0","0xd46ba6d942050d489dbd938a2c909a5d5039a161":"0xedb171c18ce90b633db442f2a6f72874093b49ef","0x1e6bb68acec8fefbd87d192be09bb274170a0548":"0xF03387d8d0FF326ab586A58E0ab4121d106147DF"};function zn(e){let t=e;return Yn.hasOwnProperty(e)&&(t=Yn[e]),t}var Qn;function es(e,t,a){const{tokens:n,contracts:s}=tt(a);let r={id:Qn.vault,address:s.vault};return n.stETH&&s.lidoRelayer&&[e,t].includes(n.stETH)&&(r={id:Qn.lido,address:s.lidoRelayer}),r}function ts(e){let t=c.Vault__factory.abi;e.id===Qn.lido&&(t=Jn);return t.filter((e=>e.name&&["swap","batchSwap"].includes(e.name)))}function as(e){return{amount:e,max:t=>e.mul(1e3+t).div(1e3),min:t=>e.mul(1e3-t).div(1e3)}}function ns(e,t){const a=t===exports.SwapType.SwapExactIn?e.swapAmount:e.returnAmount,n=t===exports.SwapType.SwapExactIn?e.returnAmount:e.swapAmount,s=t===exports.SwapType.SwapExactIn?e.swapAmountForSwaps||e.swapAmount:e.returnAmountFromSwaps||e.returnAmount,r=t===exports.SwapType.SwapExactIn?e.returnAmountFromSwaps||e.returnAmount:e.swapAmountForSwaps||e.swapAmount,i=zn(e.tokenIn),o=zn(e.tokenOut);return{...e,amountIn:a,amountOut:n,amountInForLimits:as(s),amountOutForLimits:as(r),tokenInForSwaps:i,tokenOutFromSwaps:o}}!function(e){e[e.vault=1]="vault",e[e.lido=2]="lido"}(Qn||(Qn={}));class ss{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="swap",this.swapInfo=ns(e,t),this.relayer=es(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===exports.SwapType.SwapExactOut?this.swapInfo.amountOutForLimits.amount:this.swapInfo.amountInForLimits.amount}setLimits(e){this.limit=this.kind===exports.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(e).toString():this.swapInfo.amountInForLimits.max(e).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 e.Interface(this.fragment()).encodeFunctionData("swap",Object.values(this.attributes()))}value(e){let n=a.BigNumber.from(0);return this.swapInfo.tokenIn===t.AddressZero&&(n=this.kind===exports.SwapType.SwapExactIn?this.swapInfo.amountIn:this.swapInfo.amountInForLimits.max(e)),n}to(){return this.relayer.address}fragment(){return ts(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=ns(e,t),this.relayer=es(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(e){return this.kind===exports.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(e):this.swapInfo.amountOutForLimits.amount}maxAmountIn(e){return this.kind===exports.SwapType.SwapExactOut?this.swapInfo.amountInForLimits.max(e):this.swapInfo.amountInForLimits.amount}setLimits(e){this.limits=this.swapInfo.tokenAddresses.map((t=>{let n=a.BigNumber.from(0);return t===this.swapInfo.tokenInForSwaps&&(n=this.maxAmountIn(e)),t===this.swapInfo.tokenOutFromSwaps&&(n=this.minAmountOut(e).mul(-1)),n})).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 e.Interface(this.fragment()).encodeFunctionData("batchSwap",Object.values(this.attributes()))}value(e){let n=a.BigNumber.from(0);return this.swapInfo.tokenIn===t.AddressZero&&(n=this.maxAmountIn(e)),n}to(){return this.relayer.address}fragment(){return ts(this.relayer).filter((e=>e.name===this.functionName))}}class is{constructor(e){e instanceof p.SOR?(this.sor=e,this.chainId=this.sor.provider._network.chainId):(this.sor=new Hn(e),this.chainId=e.network),this.vaultContract=c.Vault__factory.connect(Qe,this.sor.provider)}static getLimitsForSlippage(e,t,a,n,s,r){return Ze(e,t,a,n,s,r).map((e=>e.toString()))}async findRouteGivenIn({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s=4}){return this.sor.getSwaps(e,t,p.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,p.SwapTypes.SwapExactOut,a,{gasPrice:n,maxPools:s})}buildSwap({userAddress:e,recipient:t,swapInfo:a,kind:n,deadline:s,maxSlippage:r}){if(!this.chainId)throw"Missing network configuration";const i=a.swaps.length>1?new rs(a,n,this.chainId):new ss(a,n,this.chainId);i.setFunds(e,t),i.setDeadline(s),i.setLimits(r);const o=i.to(),{functionName:d}=i;return{to:o,functionName:d,attributes:i.attributes(),data:i.data(),value:i.value(r)}}static encodeBatchSwap(e){return c.Vault__factory.createInterface().encodeFunctionData("batchSwap",[e.kind,e.swaps,e.assets,e.funds,e.limits,e.deadline])}static encodeSimpleFlashSwap(e){return this.encodeBatchSwap(function({poolIds:e,assets:t,flashLoanAmount:a,walletAddress:n}){jn({poolIds:e,assets:t});const s=Kn(e,a),r={sender:n,fromInternalBalance:!1,recipient:n,toInternalBalance:!1};return{kind:exports.SwapType.SwapExactIn,swaps:s,assets:t,funds:r,limits:["0","0"],deadline:"999999999999999999"}}(e))}async fetchPools(){return this.sor.fetchPools()}getPools(){return this.sor.getPools()}async queryBatchSwap(e){return await $t(this.vaultContract,e.kind,e.swaps,e.assets)}async queryBatchSwapWithSor(e){return await Vt(this.sor,this.vaultContract,e)}async querySimpleFlashSwap(e){return await async function(e){jn(e);const[t,a]=e.assets;try{const n=await $t(e.vaultContract,exports.SwapType.SwapExactIn,Kn(e.poolIds,e.flashLoanAmount),e.assets),s={[t]:Zn(n[0]).toString(),[a]:Zn(n[1]).toString()};return{profits:s,isProfitable:Xn([s[t],s[a]])>0}}catch(e){throw`Failed to querySimpleFlashSwap: ${e}`}}({...e,vaultContract:this.vaultContract})}async getSorSwap(e){return await Ht(e.tokenIn,e.tokenOut,e.swapType,e.amount,this.sor)}}const os=new e.Interface(Jn);class ds{constructor(e){this.swaps=e instanceof is?e:new is(e)}static isChainedReference(e){const t=a.BigNumber.from(e),n=a.BigNumber.from("0xfff0000000000000000000000000000000000000000000000000000000000000"),s=t.toBigInt()&n.toBigInt();return"0xba10000000000000000000000000000000000000000000000000000000000000"===a.BigNumber.from(s)._hex.toString()}static encodeApproveVault(e,t){return os.encodeFunctionData("approveVault",[e,t])}static encodeSetRelayerApproval(e,t,a){return os.encodeFunctionData("setRelayerApproval",[e,t,a])}static encodeGaugeWithdraw(e,t,a,n){return os.encodeFunctionData("gaugeWithdraw",[e,t,a,n])}static encodeGaugeDeposit(e,t,a,n){return os.encodeFunctionData("gaugeDeposit",[e,t,a,n])}static encodeBatchSwap(e){return os.encodeFunctionData("batchSwap",[e.swapType,e.swaps,e.assets,e.funds,e.limits,e.deadline,e.value,e.outputReferences])}static encodeExitPool(e){return os.encodeFunctionData("exitPool",[e.poolId,e.poolKind,e.sender,e.recipient,e.exitPoolRequest,e.outputReferences])}static encodeJoinPool(e){return os.encodeFunctionData("joinPool",[e.poolId,e.kind,e.sender,e.recipient,e.joinPoolRequest,e.value,e.outputReference])}static encodeWrapAaveDynamicToken(e){return os.encodeFunctionData("wrapAaveDynamicToken",[e.staticToken,e.sender,e.recipient,e.amount,e.fromUnderlying,e.outputReference])}static encodeUnwrapAaveStaticToken(e){return os.encodeFunctionData("unwrapAaveStaticToken",[e.staticToken,e.sender,e.recipient,e.amount,e.toUnderlying,e.outputReferences])}static encodePeekChainedReferenceValue(e){return os.encodeFunctionData("peekChainedReferenceValue",[e])}static toChainedReference(e,t=!0){const n=t?ds.CHAINED_REFERENCE_TEMP_PREFIX:ds.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${n}${"0".repeat(64-n.length)}`;return a.BigNumber.from(s).add(e)}static fromChainedReference(e,t=!0){const n=t?ds.CHAINED_REFERENCE_TEMP_PREFIX:ds.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${n}${"0".repeat(64-n.length)}`;return a.BigNumber.from(e).sub(a.BigNumber.from(s))}static constructExitCall(e){const{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s,poolId:r,poolKind:i,sender:o,recipient:d,outputReferences:p}=e,c={poolId:r,poolKind:i,sender:o,recipient:d,outputReferences:p,exitPoolRequest:{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s}};return ds.encodeExitPool(c)}static constructJoinCall(e){const{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s,poolId:r,kind:i,sender:o,recipient:d,value:p,outputReference:c}=e,l={poolId:r,kind:i,sender:o,recipient:d,value:p,outputReference:c,joinPoolRequest:{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s}};return ds.encodeJoinPool(l)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async exitPoolAndBatchSwap(e){const n=t.WeiPerEther.sub(a.BigNumber.from(e.slippage)),s=e.expectedAmountsOut.map((e=>a.BigNumber.from(e).mul(n).div(t.WeiPerEther).toString())),r=[];e.exitTokens.forEach(((e,t)=>{const a=ds.toChainedReference(t);r.push({index:t,key:a})}));const i=ds.constructExitCall({assets:e.exitTokens,minAmountsOut:s,userData:e.userData,toInternalBalance:!0,poolId:e.poolId,poolKind:0,sender:e.exiter,recipient:e.exiter,outputReferences:r,exitPoolRequest:{}}),o=await this.swaps.queryBatchSwapWithSor({tokensIn:e.exitTokens,tokensOut:e.finalTokensOut,swapType:exports.SwapType.SwapExactIn,amounts:s,fetchPools:e.fetchPools});if(o.returnAmounts.includes("0"))throw new nt(exports.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);o.swaps.forEach((t=>{const a=o.assets[t.assetInIndex],n=e.exitTokens.indexOf(a);-1!==n&&(t.amount=r[n].key.toString())}));const d=t.WeiPerEther.add(e.slippage);e.exitTokens.forEach(((n,s)=>{const r=o.assets.map((e=>e.toLowerCase())).indexOf(n.toLowerCase());-1!==r&&(o.deltas[r]=a.BigNumber.from(e.expectedAmountsOut[s]).mul(d).div(t.WeiPerEther).toString())}));const p=is.getLimitsForSlippage(e.exitTokens,e.finalTokensOut,exports.SwapType.SwapExactIn,o.deltas,o.assets,"0"),c={sender:e.exiter,recipient:e.swapRecipient,fromInternalBalance:!0,toInternalBalance:!1};return{function:"multicall",params:[i,ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:o.swaps,assets:o.assets,funds:c,limits:p.map((e=>e.toString())),deadline:t.MaxUint256,value:"0",outputReferences:[]})],outputs:{amountsOut:o.returnAmounts}}}async swapUnwrapAaveStaticExactIn(e,n,s,r,i,o,d={fetchPools:!0,fetchOnChain:!1}){const p=await this.swaps.queryBatchSwapWithSor({tokensIn:e,tokensOut:n,swapType:exports.SwapType.SwapExactIn,amounts:s,fetchPools:d});if(p.returnAmounts.includes("0"))throw new nt(exports.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const c=is.getLimitsForSlippage(e,n,exports.SwapType.SwapExactIn,p.deltas,p.assets,o);return{function:"multicall",params:this.encodeSwapUnwrap(n,exports.SwapType.SwapExactIn,p.swaps,p.assets,i,c),outputs:{amountsOut:p.returnAmounts.map(((e,n)=>{const s=a.BigNumber.from(e).abs().mul(r[n]).div(t.WeiPerEther);if(!s.gt(t.Zero))throw new nt(exports.BalancerErrorCode.UNWRAP_ZERO_AMOUNT);return s.toString()}))}}}async swapUnwrapAaveStaticExactOut(e,n,s,r,i,o,d={fetchPools:!0,fetchOnChain:!1}){const p=s.map(((e,n)=>{const s=a.BigNumber.from(e).mul(t.WeiPerEther).div(r[n]);if(!s.gt(t.Zero))throw new nt(exports.BalancerErrorCode.WRAP_ZERO_AMOUNT);return s.toString()})),c=await this.swaps.queryBatchSwapWithSor({tokensIn:e,tokensOut:n,swapType:exports.SwapType.SwapExactOut,amounts:p,fetchPools:d});if(c.returnAmounts.includes("0"))throw new nt(exports.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const l=is.getLimitsForSlippage(e,n,exports.SwapType.SwapExactOut,c.deltas,c.assets,o);return{function:"multicall",params:this.encodeSwapUnwrap(n,exports.SwapType.SwapExactOut,c.swaps,c.assets,i,l),outputs:{amountsIn:c.returnAmounts.map((e=>e.toString()))}}}encodeSwapUnwrap(e,a,n,s,r,i){const o=[],d=[];e.forEach(((e,t)=>{const a=s.findIndex((t=>t.toLowerCase()===e.toLowerCase()));if(-1===a)return;const n=ds.toChainedReference(t);o.push({index:a,key:n});const i=ds.encodeUnwrapAaveStaticToken({staticToken:e,sender:r.recipient,recipient:r.sender,amount:n,toUnderlying:!0,outputReferences:0});d.push(i)}));return[ds.encodeBatchSwap({swapType:a,swaps:n,assets:s,funds:r,limits:i.map((e=>e.toString())),deadline:t.MaxUint256,value:"0",outputReferences:o}),...d]}}ds.CHAINED_REFERENCE_TEMP_PREFIX="ba10",ds.CHAINED_REFERENCE_READONLY_PREFIX="ba11",ds.signRelayerApproval=async(e,a,n,s)=>{const r=s.interface.encodeFunctionData("setRelayerApproval",[a,e,!0]),i=await j.signSetRelayerApprovalAuthorization(s,n,e,r);return j.encodeCalldataAuthorization("0x",t.MaxUint256,i)};class ps{constructor(e){this.url=Vn(e).urls.subgraph,this.client=this.initClient()}initClient(){return sn(new u.GraphQLClient(this.url))}}class cs{constructor(e,t){this.swaps=t||new is(e)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async getSpotPrice(e,t,a=[]){0===a.length&&(await this.fetchPools(),a=this.getPools());const n=p.parseToPoolsDict(a,0),s=this.swaps.sor.routeProposer.getCandidatePathsFromDict(e,t,0,n,4);if(0===s.length)throw new nt(exports.BalancerErrorCode.UNSUPPORTED_PAIR);return p.getSpotPriceAfterSwapForPath(s[0],0,p.ZERO).toString()}}var ls=[{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 us(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 ys{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 Dn(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 r=n&&Date.now()>s;return{lockedEndDate:s,lockedAmount:Se(t),totalSupply:Se(e.totalSupply),epoch:Se(e.epoch,0),hasExistingLock:n,isExpired:r}}}var ms=[{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 fs{constructor(e,t){if(!e.veBalProxy)throw new Error("veBalProxy address must be defined");this.instance=new s.Contract(e.veBalProxy,ms,t)}async getAdjustedBalance(e){return Se(await this.instance.adjustedBalanceOf(e))}}var hs=[{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"}],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"}];const gs=(e,t,a)=>{switch(a){case 3:return new s.Contract(e,Ts,t);case 4:return new s.Contract(e,hs,t);default:throw new Error("relayer not supported")}};var xs=[{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 Is{constructor(e,t){this.contractAddresses="number"==typeof e?et[e].addresses.contracts:e,this.vault=c.Vault__factory.connect(this.contractAddresses.vault,t),this.balancerHelpers=c.BalancerHelpers__factory.connect(this.contractAddresses.balancerHelpers,t),this.contractAddresses.lidoRelayer&&(this.lidoRelayer=c.LidoRelayer__factory.connect(this.contractAddresses.lidoRelayer,t)),this.multicall=Cn(this.contractAddresses.multicall,t),this.contractAddresses.relayerV3&&(this.relayerV3=gs(this.contractAddresses.relayerV3,t,3)),this.contractAddresses.relayerV4&&(this.relayerV4=gs(this.contractAddresses.relayerV4,t,4)),this.contractAddresses.veBal&&(this.veBal=new ys(this.contractAddresses,t)),this.contractAddresses.veBalProxy&&(this.veBalProxy=new fs(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 s.Contract(e,ls,t))(e,t)}getLiquidityGauge(e,t){return((e,t)=>new s.Contract(e,xs,t))(e,t)}}const Es={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"}},ws=new e.Interface(Ts),As=ds.toChainedReference("21"),Ss=ds.toChainedReference("22"),Ps=ds.toChainedReference("23"),Bs=ds.toChainedReference("24");class _s{constructor(e){this.addresses=Es[e]}calldata(e,t,n,s,r){if(a.BigNumber.from(t).lte(0))throw new nt(exports.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const i=this.addresses.relayer;let o=[];r&&(o=[this.buildSetRelayerApproval(r)]),o=s?[...o,this.buildWithdraw(e,t),this.buildExit(i,t),this.buildSwap(n,i),this.buildDeposit(e)]:[...o,this.buildExit(e,t),this.buildSwap(n,e)];return{to:i,data:ws.encodeFunctionData("multicall",[o])}}buildExit(e,t){const{assetOrder:a}=this.addresses.staBal3,n=a.map((e=>this.addresses[e])),s=A.exitExactBPTInForTokensOut(t),r=[{index:a.indexOf("DAI"),key:As},{index:a.indexOf("USDC"),key:Ss},{index:a.indexOf("USDT"),key:Ps}];return ds.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:r,exitPoolRequest:{}})}buildSwap(e,n){const s=[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}],i=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:As.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:Ss.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:Ps.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"}],o=[a.BigNumber.from(e).mul(-1).toString(),t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0"],d={sender:this.addresses.relayer,recipient:n,fromInternalBalance:!0,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:i,assets:s,funds:d,limits:o,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return ds.encodeGaugeWithdraw(this.addresses.staBal3.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return ds.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,Bs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Os=new e.Interface(Ts),vs=ds.toChainedReference("24");class ks{constructor(e){this.addresses=Es[e]}calldata(e,t,n,s,r,i){if(a.BigNumber.from(t).lte(0))throw new nt(exports.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];i&&(d=[this.buildSetRelayerApproval(i)]),d=s?[...d,this.buildWithdraw(e,t),this.buildSwap(t,n,o,o,r),this.buildDeposit(e)]:[...d,this.buildSwap(t,n,e,e,r)];const p=Os.encodeFunctionData("multicall",[d]);return{to:this.addresses.relayer,data:p}}buildSwap(e,n,s,r,i){const o=[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],d=[{index:0,key:vs}],p=i.reduce(((e,t)=>e.add(a.BigNumber.from(t))),t.Zero),{assetOrder:c}=this.addresses.bbausd1,l=a.BigNumber.from(e).mul(i[c.indexOf("bb-a-USDC")]).div(p).toString(),u=a.BigNumber.from(e).mul(i[c.indexOf("bb-a-DAI")]).div(p).toString(),b=a.BigNumber.from(e).sub(l).sub(u).toString(),y=[{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:2,amount:u,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:l,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"}],m=[a.BigNumber.from(n).mul(-1).toString(),"0","0","0","0","0","0","0","0","0",e],f={sender:s,recipient:r,fromInternalBalance:!1,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:y,assets:o,funds:f,limits:m,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:d})}buildWithdraw(e,t){return ds.encodeGaugeWithdraw(this.addresses.bbausd1.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return ds.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,vs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Ns=new e.Interface(Ts),Cs=ds.toChainedReference("0"),Ds=[];class Fs{constructor(e){this.addresses=Es[e]}calldata(e,t,a,n,s,r,i,o){if(r&&(null==t.gauge||null==a.gauge))throw new Error("Staked flow migration requires gauge addresses to be provided");const d=this.addresses.relayer;let p=[];o&&(p=[this.buildSetRelayerApproval(o)]),p=r?[...p,this.buildWithdraw(e,n,t.gauge),this.buildExit(t.id,d,n,i),this.buildSwap(s,d,a.id,a.address,i),this.buildDeposit(e,a.gauge)]:[...p,this.buildExit(t.id,e,n,i),this.buildSwap(s,e,a.id,a.address,i)];const c=Ns.encodeFunctionData("multicall",[p]);return{to:this.addresses.relayer,data:c}}buildExit(e,t,a,n){const s=A.exitExactBPTInForTokensOut(a),r=[];for(let e=0;e<n.length;e++)r[e]={index:e,key:ds.toChainedReference(`${e+1}`)},Ds.push(r[e].key);const i=Array(n.length).fill("0");return ds.constructExitCall({assets:n,minAmountsOut:i,userData:s,toInternalBalance:!0,poolId:e,poolKind:0,sender:t,recipient:this.addresses.relayer,outputReferences:r,exitPoolRequest:{}})}buildSwap(e,n,s,r,i){const o=[r,...i],d=[{index:0,key:Cs}],p=[];for(let e=0;e<i.length;e++)p.push({poolId:s,assetInIndex:e+1,assetOutIndex:0,amount:Ds[e].toString(),userData:"0x"});const c=[a.BigNumber.from(e).mul(-1).toString()];for(let e=0;e<i.length;e++)c.push(t.MaxInt256.toString());const l={sender:this.addresses.relayer,recipient:n,fromInternalBalance:!0,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:p,assets:o,funds:l,limits:c,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:d})}buildWithdraw(e,t,a){return ds.encodeGaugeWithdraw(a,e,this.addresses.relayer,t)}buildDeposit(e,t){return ds.encodeGaugeDeposit(t,this.addresses.relayer,e,Cs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Rs=new e.Interface(Ts),Ms=ds.toChainedReference("20"),Ls=ds.toChainedReference("21"),Us=ds.toChainedReference("22"),Gs=ds.toChainedReference("23"),qs=ds.toChainedReference("24");class Ws{constructor(e){this.addresses=Es[e]}calldata(e,t,n,s,r){if(a.BigNumber.from(t).lte(0))throw new nt(exports.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const i=this.addresses.relayer;let o=[];r&&(o=[this.buildSetRelayerApproval(r)]),o=s?[...o,this.buildWithdraw(e,t),this.buildExit(i,t),this.buildSwap(i,n),this.buildDeposit(e)]:[...o,this.buildExit(e,t),this.buildSwap(e,n)];return{to:i,data:Rs.encodeFunctionData("multicall",[o])}}buildExit(e,t){const{assetOrder:a}=this.addresses.maiusd,n=a.map((e=>this.addresses[e])),s=A.exitExactBPTInForTokensOut(t),r=[{index:a.indexOf("miMATIC"),key:Ms},{index:a.indexOf("DAI"),key:Ls},{index:a.indexOf("USDC"),key:Us},{index:a.indexOf("USDT"),key:Gs}],i=Array(n.length).fill("0");return ds.constructExitCall({assets:n,minAmountsOut:i,userData:s,toInternalBalance:!0,poolId:this.addresses.maiusd.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:r,exitPoolRequest:{}})}buildSwap(e,n){const s=[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:qs}],i=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Ls.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:Us.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:Gs.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:Ms.toString(),userData:"0x"}],o=["0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),"0",t.MaxInt256.toString(),a.BigNumber.from(n).mul(-1).toString()],d={sender:this.addresses.relayer,recipient:e,fromInternalBalance:!0,toInternalBalance:!1};return ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:i,assets:s,funds:d,limits:o,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return ds.encodeGaugeWithdraw(this.addresses.maiusd.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return ds.encodeGaugeDeposit(this.addresses.maibbausd.gauge,this.addresses.relayer,e,qs.toString())}buildSetRelayerApproval(e){return ds.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}class $s{constructor(e){this.network=e}stabal3(t,a,n,s,r){const i=new _s(this.network).calldata(t,a,n,s,r);return{to:i.to,data:i.data,decode:(t,a)=>{let n=a?2:1;r&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}bbaUsd(t,a,n,s,r,i){const o=new ks(this.network).calldata(t,a,n,s,r,i);return{to:o.to,data:o.data,decode:(t,a)=>{let n=a?1:0;i&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}stables(t,a,n,s,r,i,o,d){const p=new Fs(this.network).calldata(t,a,n,s,r,i,o,d);return{to:p.to,data:p.data,decode:(t,a)=>{let n=a?2:1;d&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}maiusd(t,a,n,s,r){const i=new Ws(this.network).calldata(t,a,n,s,r);return{to:i.to,data:i.data,decode:(t,a)=>{let n=a?2:1;r&&(n+=1);const s=e.defaultAbiCoder.decode(["bytes[]"],t);return e.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][8].abs().toString()}}}}class Vs{constructor(e){this.network=e,this.migrations=new $s(e)}}class Hs{constructor(e,t){this.tokenPrices=e,this.tokenHistoricalPrices=t}async calcImpLoss(e,t){if(1e3*e>=Date.now())throw console.error(`[ImpermanentLossService][calcImpLoss]Error: ${nt.getMessage(exports.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE)}`),new nt(exports.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE);const a=await this.prepareData(e,t),n=this.getPoolValueDelta(a),s=this.getHoldValueDelta(a);return this.calculateImpermanentLoss(n,s)}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)),r=await this.getEntryPrices(e,s),i=await this.getExitPrices(a);return this.getAssets(a,i,r,n)}getAssets(e,t,a,n){return e.map(((e,s)=>({priceDelta:this.getDelta(a[e.address],t[e.address]),weight:n[s]})))}getDelta(e,t){if(0===e)throw console.error(`[ImpermanentLossService][getDelta]Error: ${nt.getMessage(exports.BalancerErrorCode.ILLEGAL_PARAMETER)}: entry price is 0`),new nt(exports.BalancerErrorCode.ILLEGAL_PARAMETER);return(t-e)/e}getWeights(e){const t=e.every((e=>!e.weight)),a=Math.round(1/e.length*100)/100,n=t?e.map((()=>a)):e.map((e=>{var t;return Number(null!==(t=e.weight)&&void 0!==t?t:0)}));if(n.some((e=>0===e)))throw console.error(`[ImpermanentLossService][getWeights]Error: ${nt.getMessage(exports.BalancerErrorCode.MISSING_WEIGHT)}`),new nt(exports.BalancerErrorCode.MISSING_WEIGHT);return n}async getExitPrices(e){var t;const a=await Promise.all(e.map((e=>this.tokenPrices.find(e.address)))).catch((()=>[]));if(!a.length||a.some((e=>void 0===(null==e?void 0:e.usd))))throw console.error(`[ImpermanentLossService][getExitPrices]Error: ${nt.getMessage(exports.BalancerErrorCode.MISSING_PRICE_RATE)}`),new nt(exports.BalancerErrorCode.MISSING_PRICE_RATE);const n=e.map(((e,t)=>({...e,price:a[t]}))),s={};for(const e of n)(null===(t=e.price)||void 0===t?void 0:t.usd)&&(s[e.address]=+e.price.usd);return s}async getEntryPrices(e,t){const a={};for(const n of t){const t=await this.tokenHistoricalPrices.findBy(n,e).catch((e=>{console.error(`[ImpermanentLossService][getEntryPrices]Error: ${e.message}`)}));if(!(null==t?void 0:t.usd))throw console.error(`[ImpermanentLossService][getEntryPrices]Error: ${nt.getMessage(exports.BalancerErrorCode.MISSING_PRICE_RATE)}`),new nt(exports.BalancerErrorCode.MISSING_PRICE_RATE);a[n]=+t.usd}return a}}const js=335e3,Ks=1765411200,Zs=(e=Math.round((new Date).getTime()/1e3))=>js;var Xs=Object.freeze({__proto__:null,INITIAL_RATE:js,START_EPOCH_TIME:Ks,weekly:Zs,total:e=>365*(Zs()/7),between:(e,t)=>{if(e<Ks)throw"start timestamp before emission schedule deployment";if(t<e)throw"cannot finish before starting";const a=t-e,n=Zs()/7;return Math.round(a/86400)*n}});class Js{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 Ys{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&&us(e.createTime)?parseFloat(e.totalSwapFee):0:0}}class zs{constructor(e,t,a,n,s,r,i,o){this.pools=e,this.tokenPrices=t,this.tokenMeta=a,this.tokenYields=n,this.feeCollector=s,this.yesterdaysPools=r,this.liquidityGauges=i,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||6343==e.chainId||4326==e.chainId)&&0==a.workingSupply||248!=e.chainId&&9372!=e.chainId&&6343!=e.chainId&&4326!=e.chainId&&0==a.totalSupply)return 0;const n=et[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,r]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const i=parseFloat(s.usd),o=Zs()/7*365*a.relativeWeight*i,d=(a.workingSupply+.4)/.4*r;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=et[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,r]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const i=parseFloat(s.usd),o=Zs()/7*365*(a.relativeWeightNextPeriod||0)*i,d=(a.workingSupply+.4)/.4*r;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=et[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),r=t.totalSupply*s,i={};let o=0;for await(const e of Object.values(n)){const t=r>0?e.value/r:0,a=Math.round(1e4*t);o+=a,i[e.address]=a}return{total:o,breakdown:i}}async protocolApr(e){if(""!=e.id||!this.feeDistributor)return 0;const t=new Js(this.feeDistributor,this.tokenPrices),{lastWeekBalRevenue:a,lastWeekBBAUsdRevenue:n,veBalSupply:s}=await t.data(),r=await this.bptPrice(e);if(!r)throw"bptPrice for veBal pool missing";const i=(a+n)/7;return Math.round(365*i*1e4/(r*s))}async apr(e){const[t,a,n,s,r,i]=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:r,protocolApr:i,min:t+a.total+r.total+n,max:t+a.total+r.total+i+s}}async aprNextPeriod(e){const[t,a,n,s,r,i]=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:r,protocolApr:i,min:t+a.total+r.total+n,max:t+a.total+r.total+i+s}}async last24hFees(e){return new Ys(this.yesterdaysPools).last24h(e)}async totalLiquidity(e){try{const t=new Wt(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(Se(a,s))*parseFloat(n.usd)}}throw`No USD price for ${e}`}}}const Qs=new Map;Qs.set(exports.PoolType.AaveLinear,"batchSwap"),Qs.set(exports.PoolType.EulerLinear,"batchSwap"),Qs.set(exports.PoolType.ERC4626Linear,"batchSwap"),Qs.set(exports.PoolType.Element,"batchSwap"),Qs.set(exports.PoolType.Investment,"joinPool"),Qs.set(exports.PoolType.LiquidityBootstrapping,"joinPool"),Qs.set(exports.PoolType.MetaStable,"joinPool"),Qs.set(exports.PoolType.Stable,"joinPool"),Qs.set(exports.PoolType.StablePhantom,"batchSwap"),Qs.set(exports.PoolType.Weighted,"joinPool"),Qs.set(exports.PoolType.ComposableStable,"joinPool");const er=new Map;er.set(exports.PoolType.AaveLinear,"batchSwap"),Qs.set(exports.PoolType.EulerLinear,"batchSwap"),er.set(exports.PoolType.ERC4626Linear,"batchSwap"),er.set(exports.PoolType.Element,"batchSwap"),er.set(exports.PoolType.Investment,"exitPool"),er.set(exports.PoolType.LiquidityBootstrapping,"exitPool"),er.set(exports.PoolType.MetaStable,"exitPool"),er.set(exports.PoolType.Stable,"exitPool"),er.set(exports.PoolType.StablePhantom,"batchSwap"),er.set(exports.PoolType.Weighted,"exitPool"),er.set(exports.PoolType.ComposableStable,"exitPool");class tr{constructor(e){this.pools=e}async buildGraphFromRootPool(e,a){const n=await this.pools.find(e);if(!n)throw new nt(exports.BalancerErrorCode.POOL_DOESNT_EXIST);return(await this.buildGraphFromPool(n.address,0,void 0,t.WeiPerEther,a))[0]}getTokenTotal(e){const a=e.tokensList.indexOf(e.address);let n=t.Zero;const{parsedBalances:s}=ne(e);return s.forEach(((e,t)=>{a!==t&&(n=n.add(e))})),n}async buildGraphFromPool(e,t,n,s,r){var i;const o=await this.pools.findBy("address",e);if(!o){if(n){const a=await this.pools.findBy("address",n.address),r=null!==(i=a.tokens[a.tokensList.indexOf(e)].decimals)&&void 0!==i?i:18;return tr.createInputTokenNode(t,e,r,n,s)}throw new nt(exports.BalancerErrorCode.POOL_DOESNT_EXIST)}const d=Qs.get(o.poolType),p=er.get(o.poolType);if(!d||!p)throw new nt(exports.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);const c=this.getTokenTotal(o),{spotPriceCalculator:l}=qt.from(o.poolType),u={};let b=18;o.tokens.forEach((e=>{if(We(e.address,o.address))return void(b=e.decimals?e.decimals:18);const t=l.calcPoolSpotPrice(e.address,o.address,o);u[e.address]=t}));let y={address:o.address,id:o.id,type:o.poolType,joinAction:d,exitAction:p,children:[],marked:!1,index:t.toString(),parent:n,proportionOfParent:s,isLeaf:!1,spotPrices:u,decimals:b};if(t++,o.poolType.toString().includes("Linear"))[y,t]=this.createLinearNodeChildren(y,t,o,r);else{const{parsedBalances:e}=ne(o);for(let n=0;n<o.tokens.length;n++){if(We(o.tokens[n].address,o.address))continue;let i;if("Weighted"===o.poolType){const e=o.tokens[n].weight;i=a.parseFixed(e,18)}else i=a.BigNumber.from(e[n]).mul(1e18.toString()).div(c);const d=i.mul(s).div(1e18.toString()),p=await this.buildGraphFromPool(o.tokens[n].address,t,y,d,r);t=p[1],p[0]&&y.children.push(p[0])}}return[y,t]}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,r=tr.createInputTokenNode(t,a.tokensList[a.mainIndex],n,e,e.proportionOfParent);return e.children.push(r[0]),[e,t=r[1]]}}createWrappedTokenNode(e,t,a,n){var s;if(void 0===e.wrappedIndex||void 0===e.mainIndex)throw new Error("Issue With Linear Pool");let r="wrapAaveDynamicToken";if(e.poolType===exports.PoolType.ERC4626Linear)r="wrapERC4626";let i="unwrapAaveStaticToken";if(e.poolType===exports.PoolType.ERC4626Linear)i="unwrapERC4626";const o={type:"WrappedToken",address:e.tokensList[e.wrappedIndex],id:"N/A",children:[],marked:!1,joinAction:r,exitAction:i,index:t.toString(),parent:a,proportionOfParent:n,isLeaf:!1,spotPrices:{},decimals:18};t++;const d=null!==(s=e.tokens[e.mainIndex].decimals)&&void 0!==s?s:18,p=tr.createInputTokenNode(t,e.tokensList[e.mainIndex],d,o,n);return o.children=[p[0]],[o,t=p[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))}}tr.getGraphNodes=async(e,t,a,n)=>{if(!await a.find(t))throw new nt(exports.BalancerErrorCode.POOL_DOESNT_EXIST);const s=new tr(a),r=await s.buildGraphFromRootPool(t,n);if(r.id!==t)throw new Error("Error creating graph nodes");return e?tr.orderByBfs(r).reverse():tr.orderByBfs(r)};class ar{constructor(e,a){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}]))),r={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},i=this.tenderlyUrl+"simulate";return(await E.default.post(i,r,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,a)=>{if(0===a.length)return{};let n={};a.forEach((a=>n={...n,[`${a}`]:{value:{[`_balances[${e}]`]:t.MaxInt256.toString(),[`_allowances[${e}][${this.vaultAddress}]`]:t.MaxInt256.toString(),[`balanceOf[${e}]`]:t.MaxInt256.toString(),[`allowance[${e}][${this.vaultAddress}]`]:t.MaxInt256.toString(),[`balances[${e}]`]:t.MaxInt256.toString(),[`allowed[${e}][${this.vaultAddress}]`]:t.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 E.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}=tt(this.chainId);this.vaultAddress=n.vault,(null==a?void 0:a.user)&&(null==a?void 0:a.project)?this.tenderlyUrl=`https://api.tenderly.co/api/v1/account/${a.user}/project/${a.project}/`:this.tenderlyUrl="https://api.balancer.fi/tenderly/",(null==a?void 0:a.accessKey)&&(this.opts={headers:{"X-Access-Key":a.accessKey}}),this.blockNumber=null==a?void 0:a.blockNumber}}var nr;const sr=new e.Interface(hs);class rr{constructor(n,s){this.pools=n,this.createCalls=async(e,t,a,n)=>{const{calls:s,outputIndexes:r,deltas:i}=this.createActionCalls(e,t,a);n&&s.unshift(this.createSetRelayerApproval(n));return{callData:sr.encodeFunctionData("multicall",[s]),outputIndexes:n?r.map((e=>e+1)):r,deltas:i}},this.amountsOutByJoinPath=async(t,n,s,r)=>{const i=[],o=await this.tenderlyHelper.simulateMulticall(this.relayer,n,t,s),d=e.defaultAbiCoder.decode(["bytes[]"],o)[0];let p=a.BigNumber.from("0");return r.forEach((t=>{const a=e.defaultAbiCoder.decode(["uint256"],d[t]);i.push(a.toString()),p=p.add(a.toString())})),{amountsOut:i,totalAmountOut:p.toString()}},this.minAmountsOutByJoinPath=(e,t,n)=>({minAmountsOut:t.map((t=>Ye(a.BigNumber.from(t),a.BigNumber.from(e)).toString())),totalMinAmountOut:Ye(a.BigNumber.from(n),a.BigNumber.from(e)).toString()}),this.createActionCalls=(e,t,a)=>{const n=[],s=[],r=!a,i={};return e.forEach(((e,o)=>{const d=e[0].isLeaf;if(e.forEach(((s,r)=>{let p;if(p=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)})):r>0?[e[r-1]]:[],p.length>0&&0===p.filter((e=>"0"!==e.index)).length)return void(s.index="0");p.some((e=>"input"===e.joinAction||"wrapAaveDynamicToken"===e.joinAction));const c=t,l=r===e.length-1,u=t,b=l&&a?a[o]:"0";switch(s.joinAction){case"wrapAaveDynamicToken":n.push(this.createAaveWrap(s,p,o,c,t));break;case"batchSwap":{const[e,t,a]=this.createBatchSwap(s,p,o,b,c,u);n.push(e),this.updateDeltas(i,t,a);break}case"joinPool":{const[e,t,a,r]=this.createJoinPool(s,p,o,b,c,u);n.push(e),this.updateDeltas(i,[s.address,...t],[r,...a]);break}}})),r){const e=100*o,t=ds.encodePeekChainedReferenceValue(ds.toChainedReference(e,!1));n.push(t),s.push(n.indexOf(t))}})),{calls:n,outputIndexes:s,deltas:i}},this.createSetRelayerApproval=e=>ds.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 r=t[0],i=e.address,o=r.index;return ds.encodeWrapAaveDynamicToken({staticToken:i,sender:n,recipient:s,amount:o,fromUnderlying:!0,outputReference:this.getOutputRefValue(a,e).value})},this.createBatchSwap=(e,n,s,r,i,o)=>{if(1!==n.length)throw new Error("Unsupported batchswap");const d=n[0].address,p=this.getOutputRefValue(s,n[0]),c=[e.address,d],l=[a.BigNumber.from(r).mul(-1).toString(),p.isRef?t.MaxInt256.toString():p.value],u=[{poolId:e.id,assetInIndex:1,assetOutIndex:0,amount:p.value,userData:"0x"}],b={sender:i,recipient:o,fromInternalBalance:i===this.relayer,toInternalBalance:o===this.relayer},y=[{index:c.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase()),key:a.BigNumber.from(this.getOutputRefValue(s,e).value)}],m=ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:u,assets:c,funds:b,limits:l,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:y}),f=i===this.relayer?"0":l[1];return[m,c,[o===this.relayer?"0":l[0],f]]},this.createJoinPool=(e,a,n,s,r,i)=>{const o=[],d=[];e.children.forEach((e=>{o.push(e.address);const t=a.find((t=>We(t.address,e.address)));t?d.push(this.getOutputRefValue(n,t).value):d.push("0")})),e.type===exports.PoolType.ComposableStable&&(o.push(e.address),d.push("0"));const p=new q(this.wrappedNativeAsset),[c,l]=p.sortTokens(o,d);let u=[];const b=c.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase());let y;u=-1===b?l:[...l.slice(0,b),...l.slice(b+1)],y=e.type===exports.PoolType.Weighted?S.joinExactTokensInForBPTOut(u,s):A.joinExactTokensInForBPTOut(u,s);const m=c.indexOf(t.AddressZero),f=-1===m?"0":l[m],h=ds.constructJoinCall({poolId:e.id,kind:0,sender:r,recipient:i,value:f,outputReference:this.getOutputRefValue(n,e).value,joinPoolRequest:{},assets:c,maxAmountsIn:l,userData:y,fromInternalBalance:r===this.relayer}),T=l.map((e=>ds.isChainedReference(e)?"0":e)),g=ds.isChainedReference(s)?"0":s;return[h,r===this.relayer?[]:c,r===this.relayer?[]:T,i===this.relayer?t.Zero.toString():t.Zero.sub(g).toString()]},this.getOutputRefValue=(e,t)=>"input"===t.joinAction?{value:t.index,isRef:!1}:"0"===t.index&&t.parent?{value:"0",isRef:!0}:{value:ds.toChainedReference(a.BigNumber.from(t.index).add(100*e)).toString(),isRef:!0};const{tokens:r,contracts:i}=tt(s.chainId);this.relayer=i.relayerV4,this.wrappedNativeAsset=r.wrappedNativeAsset,this.tenderlyHelper=new ar(s.chainId,s.tenderly)}async joinPool(e,t,a,n,s,r,i){if(t.length!=a.length)throw new nt(exports.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const o=await tr.getGraphNodes(!0,e,this.pools,s),d=rr.getJoinPaths(o,t,a),p=rr.totalBptZeroPriceImpact(d),{callData:c,outputIndexes:l}=await this.createCalls(d,n,void 0,i),{amountsOut:u,totalAmountOut:b}=await this.amountsOutByJoinPath(n,c,t,l),{minAmountsOut:y,totalMinAmountOut:m}=this.minAmountsOutByJoinPath(r,u,b),f=dt(BigInt(b),p.toBigInt(),!0).toString(),{callData:h,deltas:T}=await this.createCalls(d,n,y,i);return this.assertDeltas(e,T,t,a,m),{to:this.relayer,callData:h,expectedOut:b,minOut:m,priceImpact:f}}assertDeltas(e,t,n,s,r){var i;const o=C(e);if(t[o.toLowerCase()].add(r).abs().gt(3))throw console.error("join assertDeltas, bptOut: ",o,r,null===(i=t[o.toLowerCase()])||void 0===i?void 0:i.toString()),new nt(exports.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete t[o.toLowerCase()],n.forEach(((e,n)=>{var r,i;if(!a.BigNumber.from(s[n]).eq(0)&&(null===(r=t[e.toLowerCase()])||void 0===r?void 0:r.toString())!==s[n])throw console.error("join assertDeltas, tokenIn: ",e,s[n],null===(i=t[e.toLowerCase()])||void 0===i?void 0:i.toString()),new nt(exports.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete t[e.toLowerCase()]}));for(const e in t)if("0"!==t[e].toString())throw console.error("join assertDeltas, non-input token should be 0: ",e,t[e].toString()),new nt(exports.BalancerErrorCode.JOIN_DELTA_AMOUNTS)}updateDeltas(e,a,n){return a.forEach(((a,s)=>{const r=a.toLowerCase();e[r]||(e[r]=t.Zero),e[r]=e[r].add(n[s])})),e}}nr=rr,rr.getJoinPaths=(e,n,s)=>{const r=[],i=e.filter((e=>n.filter(((e,t)=>a.BigNumber.from(s[t]).gt(0))).map((e=>e.toLowerCase())).includes(e.address.toLowerCase())));i.some((e=>e.isLeaf))&&r.push(e);const o=i.filter((e=>!e.isLeaf));return o.forEach((e=>{const i=s.find(((t,a)=>We(n[a],e.address))),p=o.filter((t=>We(t.address,e.address))).reduce(((e,t)=>e.add(t.proportionOfParent)),a.BigNumber.from(0)),c=a.BigNumber.from(i).mul(e.proportionOfParent).div(p).toString(),[l]=tr.createInputTokenNode(0,e.address,e.decimals,e.parent,t.WeiPerEther);l.index=c,l.isLeaf=!1;const u=[l];let b=e.parent;for(;b;)u.push(d.cloneDeep(b)),b=b.parent;r.push(u)})),nr.updateInputAmounts(r,n,s),r},rr.updateInputAmounts=(e,t,n)=>{const s=(e,t)=>{if(e.length>1){const n=e.reduce(((e,t)=>e.add(t.index)),a.BigNumber.from(0)),s=a.BigNumber.from(t).sub(n);e[0].index=s.add(e[0].index).toString()}},r=e.find((e=>e[0].isLeaf));if(r){const e=nr.updateTotalProportions(r);r.forEach((a=>{"input"===a.joinAction&&(a=nr.updateNodeAmount(a,t,n,e))})),t.forEach(((e,t)=>{const a=r.filter((t=>t.isLeaf&&We(t.address,e)));s(a,n[t])}))}const i=e.filter((e=>!e[0].isLeaf));i.length>1&&t.forEach(((e,t)=>{const a=i.map((e=>e[0])).filter((t=>We(t.address,e)));s(a,n[t])}))},rr.totalBptZeroPriceImpact=e=>{let t=a.BigNumber.from("0");return e.forEach((e=>{if(e[0].isLeaf){e.filter((e=>e.isLeaf)).forEach((e=>{const a=nr.bptOutZeroPiForInputNode(e);t=t.add(a)}))}else{const a=nr.bptOutZeroPiForInputNode(e[0]);t=t.add(a)}})),t},rr.bptOutZeroPiForInputNode=e=>{if("0"===e.index||"input"!==e.joinAction)return BigInt(0);let t=1,n=e.parent,s=e.address;for(;void 0!==n;){if("batchSwap"===n.joinAction||"joinPool"===n.joinAction){const e=n.spotPrices[s.toLowerCase()];t*=parseFloat(e),s=n.address}n=n.parent}const r=a.parseFixed(t.toFixed(18),18),i=z(BigInt(e.decimals)),o=Q(BigInt(e.index),i);return te.divDownFixed(o,r.toBigInt())},rr.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},rr.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 r=n[e.address],i=e.proportionOfParent.mul(1e18.toString()).div(r).mul(a[s]).div(1e18.toString());return e.index=i.toString(),e};const ir=new e.Interface(hs);class or{constructor(n,s){this.pools=n,this.amountsOutByExitPath=async(t,n,s,r,i)=>{const o=await this.tenderlyHelper.simulateMulticall(this.relayer,n,t,[s]),d=e.defaultAbiCoder.decode(["bytes[]"],o)[0],p=r.map((t=>e.defaultAbiCoder.decode(["uint256"],d[t]).toString())),c=p.map((e=>Ye(a.BigNumber.from(e),a.BigNumber.from(i)).toString()));return{expectedAmountsOutByExitPath:p,minAmountsOutByExitPath:c}},this.amountsOutByTokenOut=(e,n,s,r)=>{const i={};n.forEach(((e,a)=>{var n;return i[e]=(null!==(n=i[e])&&void 0!==n?n:t.Zero).add(s[a])}));const o=e.map((e=>i[e].toString())),d=o.map((e=>Ye(a.BigNumber.from(e),a.BigNumber.from(r)).toString()));return{expectedAmountsOut:o,minAmountsOut:d}},this.getExitPaths=(e,n)=>{const s=e.map((e=>{const a=[e];for(;a[0].parent;)a.unshift(d.cloneDeep(a[0].parent));return a[0].index=a[a.length-1].proportionOfParent.mul(n).div(t.WeiPerEther).toString(),a})),r=s.reduce(((e,t)=>{const n=t[0].index;return a.BigNumber.from(n).add(e)}),t.Zero),i=a.BigNumber.from(n).sub(r);return s[s.length-1][0].index=i.add(s[s.length-1][0].index).toString(),s},this.getOutputRef=(e,t)=>100*e+parseInt(t);const{tokens:r,contracts:i}=tt(s.chainId);this.wrappedNativeAsset=r.wrappedNativeAsset,this.relayer=i.relayerV4,this.tenderlyHelper=new ar(s.chainId,s.tenderly)}async exitPool(e,t,a,n,s){const r=await tr.getGraphNodes(!1,e,this.pools,!1),i=r.filter((e=>"output"===e.exitAction)),o=this.getExitPaths(i,t),d=i.map((e=>e.address.toLowerCase())),p=[...new Set(d)].sort(),c=await this.createCalls(o,a,void 0,s),{expectedAmountsOutByExitPath:l,minAmountsOutByExitPath:u}=await this.amountsOutByExitPath(a,c.callData,r[0].address,c.outputIndexes,n),{callData:b,deltas:y}=await this.createCalls(o,a,u,s),{expectedAmountsOut:m,minAmountsOut:f}=this.amountsOutByTokenOut(p,d,l,n);this.assertDeltas(e,y,t,p,f);const h=await this.calculatePriceImpact(e,p,m,t);return{to:this.relayer,callData:b,tokensOut:p,expectedAmountsOut:m,minAmountsOut:f,priceImpact:h}}async calculatePriceImpact(e,t,a,n){const s=await tr.getGraphNodes(!0,e,this.pools,!1),r=rr.getJoinPaths(s,t,a),i=rr.totalBptZeroPriceImpact(r);return dt(BigInt(n),i.toBigInt(),!1).toString()}assertDeltas(e,t,a,n,s){var r;const i=C(e);if(t[i.toLowerCase()].sub(a).abs().gt(3))throw console.error("exit assertDeltas, bptIn: ",i,a,null===(r=t[i.toLowerCase()])||void 0===r?void 0:r.toString()),new nt(exports.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete t[i.toLowerCase()],n.forEach(((e,a)=>{var n;if(t[e.toLowerCase()].add(s[a]).abs().gt(1))throw console.error("exit assertDeltas, tokenOut: ",e,s[a],null===(n=t[e.toLowerCase()])||void 0===n?void 0:n.toString()),new nt(exports.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete t[e.toLowerCase()]}));for(const e in t)if("0"!==t[e].toString())throw console.error("exit assertDeltas, non-input token should be 0: ",e,t[e].toString()),new nt(exports.BalancerErrorCode.EXIT_DELTA_AMOUNTS)}async createCalls(e,t,a,n){const{calls:s,outputIndexes:r,deltas:i}=this.createActionCalls(d.cloneDeep(e),t,a);n&&s.unshift(ds.encodeSetRelayerApproval(this.relayer,!0,n));return{callData:ir.encodeFunctionData("multicall",[s]),outputIndexes:n?r.map((e=>e+1)):r,deltas:i}}updateDeltas(e,a,n){return a.forEach(((a,s)=>{const r=a.toLowerCase();e[r]||(e[r]=t.Zero),e[r]=e[r].add(n[s])})),e}createActionCalls(e,t,a){const n=[],s=[],r=!a,i={};return e.forEach(((e,o)=>{e.forEach((d=>{const p=!d.parent?t:this.relayer,c=d.children.find((t=>e.map((e=>e.index)).includes(t.index))),l="output"===(null==c?void 0:c.exitAction),u=l?t:this.relayer,b=l&&a?a[o]:"0";switch(d.exitAction){case"batchSwap":{const[e,t,a]=this.createBatchSwap(d,c,o,b,p,u);n.push(e),this.updateDeltas(i,t,a);break}case"exitPool":{const[e,t,a,s]=this.createExitPool(d,c,o,b,p,u);n.push(e),this.updateDeltas(i,[d.address,...a],[t,...s]);break}case"output":r&&(n.push(ds.encodePeekChainedReferenceValue(ds.toChainedReference(this.getOutputRef(o,d.index),!1))),s.push(n.length-1));break;default:return}}))})),{calls:n,outputIndexes:s,deltas:i}}createBatchSwap(e,n,s,r,i,o){const d=!e.parent?e.index:ds.toChainedReference(this.getOutputRef(s,e.index)).toString(),p=n.address,c=[p,e.address],l=[a.BigNumber.from(r).mul(-1).toString(),ds.isChainedReference(d)?t.MaxInt256.toString():d],u=[{poolId:e.id,assetInIndex:1,assetOutIndex:0,amount:d,userData:"0x"}],b={sender:i,recipient:o,fromInternalBalance:!1,toInternalBalance:!1},y=[{index:c.map((e=>e.toLowerCase())).indexOf(p.toLowerCase()),key:ds.toChainedReference(this.getOutputRef(s,n.index))}],m=ds.encodeBatchSwap({swapType:exports.SwapType.SwapExactIn,swaps:u,assets:c,funds:b,limits:l,deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:y});let f=l[0];const h=l[1],T=i===this.relayer?"0":h;return f=o===this.relayer?"0":f,[m,c,[f,T]]}createExitPool(e,a,n,s,r,i){const o=a.address,d=!e.parent?e.index:ds.toChainedReference(this.getOutputRef(n,e.index)).toString(),p=[],c=[];e.children.forEach((e=>{p.push(e.address),c.push(e.address===o?s:"0")})),e.type===exports.PoolType.ComposableStable&&(p.push(e.address),c.push("0"));const l=new q(this.wrappedNativeAsset),[u,b]=l.sortTokens(p,c);let y=[];const m=u.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase());let f;y=-1===m?u:[...u.slice(0,m),...u.slice(m+1)],f=e.type===exports.PoolType.Weighted?S.exitExactBPTInForOneTokenOut(d,y.indexOf(o)):A.exitExactBPTInForOneTokenOut(d,y.indexOf(o));const h=[{index:u.map((e=>e.toLowerCase())).indexOf(o.toLowerCase()),key:ds.toChainedReference(this.getOutputRef(n,a.index))}],T=ds.constructExitCall({poolId:e.id,poolKind:0,sender:r,recipient:i,outputReferences:h,exitPoolRequest:{},assets:u,minAmountsOut:b,userData:f,toInternalBalance:!1}),g=b.map((e=>ds.isChainedReference(e)?"0":t.Zero.sub(e).toString())),x=ds.isChainedReference(d)?"0":d;return[T,r===this.relayer?t.Zero.toString():x,i===this.relayer?[]:u,i===this.relayer?[]:g]}}class dr{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&&us(e.createTime)?parseFloat(e.totalSwapVolume):0:0}}var pr=[{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 cr{constructor(e){const{tokens:t}=tt(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:t,name:a,symbol:n,tokenAddresses:s,amplificationParameter:r,rateProviders:i,tokenRateCacheDurations:o,exemptFromYieldProtocolFeeFlags:d,swapFee:p,owner:c}){const l=qe(`${p}`),u=new q(this.wrappedNativeAsset),[b,y,m,f]=u.sortTokens(s,i,o,d),h=[a,n,b,r,y,m,f,l.toString(),c],T=new e.Interface(pr),g=pr.find((({name:e})=>"create"===e));if(!g)throw new nt(exports.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const x=e.FunctionFragment.from(g);return{to:t,data:T.encodeFunctionData(x,h)}}buildInitJoin({joiner:e,poolId:t,poolAddress:a,tokensIn:n,amountsIn:s}){throw new Error("To be implemented")}}class lr{constructor(e){const{tokens:t}=tt(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:t,name:a,symbol:n,tokenAddresses:s,weights:r,swapFee:i,owner:o}){const d=qe(`${i}`),p=new q(this.wrappedNativeAsset),[l,u]=p.sortTokens(s,r),b=[a,n,l,u,d.toString(),o],y=new e.Interface(c.WeightedPoolFactory__factory.abi),m=c.WeightedPoolFactory__factory.abi.find((({name:e})=>"create"===e));if(!m)throw new nt(exports.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const f=e.FunctionFragment.from(m);return{to:t,data:y.encodeFunctionData(f,b)}}buildInitJoin({joiner:e,poolId:t,tokensIn:a,amountsIn:n}){const s=new q(this.wrappedNativeAsset),[r,i]=s.sortTokens(a,n),o="joinPool",d={poolId:t,sender:e,recipient:e,joinPoolRequest:{assets:r,maxAmountsIn:i,userData:S.joinInit(i),fromInternalBalance:!1}},p=c.Vault__factory.createInterface().encodeFunctionData(o,[d.poolId,d.sender,d.recipient,d.joinPoolRequest]);return{to:Qe,functionName:o,attributes:d,data:p}}}class ur{constructor(e){this.networkConfig=e}of(e){switch(e){case"Weighted":return new lr(this.networkConfig);case"Investment":case"LiquidityBootstrapping":case"Stable":case"MetaStable":case"StablePhantom":case"AaveLinear":case"ERC4626Linear":default:throw new nt(exports.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);case"ComposableStable":return new cr(this.networkConfig)}}}class br{constructor(e){this.pool=e;const t=(e=>{switch(e){case exports.PoolType.Weighted:return S;case exports.PoolType.Stable:case exports.PoolType.MetaStable:case exports.PoolType.StablePhantom:case exports.PoolType.AaveLinear:case exports.PoolType.EulerLinear:case exports.PoolType.ERC4626Linear:case exports.PoolType.Element:case exports.PoolType.Gyro2:case exports.PoolType.Gyro3:return A;case exports.PoolType.ComposableStable:return O}})(e.poolType);if(!t)throw"Pool type not supported";this.encoder=t}buildQueryJoinExactIn({sender:e=t.AddressZero,recipient:a=e,maxAmountsIn:n,minimumBPT:s=t.Zero,fromInternalBalance:r=!1}){const i=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e))),o=[...this.pool.tokensList];i&&i>-1&&n.splice(i,1);const d=this.encoder.joinExactTokensInForBPTOut(n,s);return[this.pool.id,e,a,{assets:o,maxAmountsIn:n,userData:d,fromInternalBalance:r}]}buildQueryJoinExactOut({sender:e=t.AddressZero,recipient:a=e,maxAmountsIn:n=[],bptOut:s,tokenIn:r,fromInternalBalance:i=!1}){const o=this.pool.tokensList.indexOf(r),d=this.encoder.joinTokenInForExactBPTOut(s,o);return[this.pool.id,e,a,{assets:this.pool.tokensList,maxAmountsIn:n,userData:d,fromInternalBalance:i}]}buildQueryExitToSingleToken({sender:e=t.AddressZero,recipient:a=e,minAmountsOut:n=[],bptIn:s,tokenOut:r,toInternalBalance:i=!1}){const o=this.pool.tokensList.indexOf(r),d=this.encoder.exitExactBPTInForOneTokenOut(s,o);return[this.pool.id,e,a,{assets:this.pool.tokensList,minAmountsOut:n,userData:d,toInternalBalance:i}]}buildQueryExitProportionally({sender:e=t.AddressZero,recipient:a=e,minAmountsOut:n=[],bptIn:s,toInternalBalance:r=!1}){if(!this.encoder.exitExactBPTInForTokensOut)throw"Proportional exit not implemented";const i=this.encoder.exitExactBPTInForTokensOut(s);return[this.pool.id,e,a,{assets:this.pool.tokensList,minAmountsOut:n,userData:i,toInternalBalance:r}]}buildQueryExitExactOut({sender:e=t.AddressZero,recipient:a=e,minAmountsOut:n,maxBptIn:s=t.MaxUint256,toInternalBalance:r=!1}){const i=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e)));i&&i>-1&&n.splice(i,1);const o=this.encoder.exitBPTInForExactTokensOut(n,s);return[this.pool.id,e,a,{assets:this.pool.tokensList,minAmountsOut:n,userData:o,toInternalBalance:r}]}}class yr{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 Zs()*await this.relativeWeight(e)}}const mr=(e,t,n)=>{const s=e.tokens.filter((t=>!e.id.toLowerCase().includes(t.address.toLowerCase()))),r=s.findIndex((e=>e.address.toLowerCase()===t.toLowerCase()));if(-1==r)throw new Error("Token not found in pool");const i=s.map((e=>Pe(e.balance,e.decimals))),o=a.BigNumber.from(n),d=i.map((e=>e.mul(o).div(i[r])));return{tokens:s.map((e=>e.address)),amounts:d.map((e=>e.toString()))}},fr=(e,t)=>()=>{throw`${t} for poolType ${e} not implemented`};class hr{constructor(e,t){this.networkConfig=e,this.repositories=t,this.aprService=new zs(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 Wt(t.pools,t.tokenPrices),this.joinService=new rr(this.repositories.poolsOnChain,e),this.exitService=new or(this.repositories.poolsOnChain,e),this.feesService=new Ys(t.yesterdaysPools),this.volumeService=new dr(t.yesterdaysPools),this.poolFactory=new ur(e),this.impermanentLossService=new Hs(t.tokenPrices,t.tokenHistoricalPrices),t.liquidityGauges&&(this.emissionsService=new yr(t.liquidityGauges)),this.proportionalAmounts=mr}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,r,i){return this.joinService.joinPool(e,t,a,n,s,r,i)}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=qt.from(e.poolType),s={buildJoin:(t,n,s,i)=>a.join.buildJoin({joiner:t,pool:e,tokensIn:n,amountsIn:s,slippage:i,wrappedNativeAsset:r}),calcPriceImpact:async(t,n,s)=>a.priceImpactCalculator.calcPriceImpact(e,t,n,s),buildExitExactBPTIn:(t,n,s,i=!1,o)=>{if(a.exit.buildExitExactBPTIn)return a.exit.buildExitExactBPTIn({exiter:t,pool:e,bptIn:n,slippage:s,shouldUnwrapNativeAsset:i,wrappedNativeAsset:r,singleTokenMaxOut:o});throw"ExitExactBPTIn not supported"},buildExitExactTokensOut:(t,n,s,i)=>a.exit.buildExitExactTokensOut({exiter:t,pool:e,tokensOut:n,amountsOut:s,slippage:i,wrappedNativeAsset:r}),calcSpotPrice:(t,n)=>a.spotPriceCalculator.calcPoolSpotPrice(t,n,e),calcProportionalAmounts:(t,a)=>mr(e,t,a)}}catch(t){"UNSUPPORTED_POOL_TYPE"!=t.code&&console.error(t),s={buildJoin:fr(e.poolType,"buildJoin"),calcPriceImpact:fr(e.poolType,"calcPriceImpact"),buildExitExactBPTIn:fr(e.poolType,"buildExitExactBPTIn"),buildExitExactTokensOut:fr(e.poolType,"buildExitExactTokensOut"),calcSpotPrice:fr(e.poolType,"calcSpotPrice")}}try{n=new br(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:fr(e.poolType,"buildQueryJoinExactIn"),buildQueryJoinExactOut:fr(e.poolType,"buildQueryJoinExactOut"),buildQueryExitExactOut:fr(e.poolType,"buildQueryExitExactOut"),buildQueryExitToSingleToken:fr(e.poolType,"buildQueryExitToSingleToken"),buildQueryExitProportionally:fr(e.poolType,"buildQueryExitProportionally")}}const r=t.addresses.tokens.wrappedNativeAsset.toLowerCase();return{...e,...s}}async find(e){const t=await this.dataSource().find(e);if(t)return hr.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 hr.wrap(e,this.networkConfig)}throw`search by ${e} not implemented`}async all(){const e=await this.dataSource().all();return e?e.map((e=>hr.wrap(e,this.networkConfig))).filter((e=>e)):[]}async where(e){const t=await this.dataSource().where(e);if(!t)return[];return t.map((e=>hr.wrap(e,this.networkConfig))).filter((e=>e))}}const Tr=new e.Interface(["function gauge_relative_weight(address gauge, uint timestamp) view returns (uint)","function gauge_relative_weight_write(address gauge, uint timestamp) returns (uint)"]);class gr{constructor(e,t,a){this.gaugeControllerAddress=t,this.multicall=Cn(e,a)}async getRelativeWeights(e,t){const a=e.map((e=>[this.gaugeControllerAddress,Tr.encodeFunctionData("gauge_relative_weight_write",[n.getAddress(e),t||Math.floor(Date.now()/1e3)])])),[,s]=await this.multicall.aggregate(a);return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Se(s[a],18))),e)),{})}}class xr{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 Ir extends xr{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=vn(e)}}class Er extends xr{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=kn(e)}}class wr extends Er{async query(e){e.orderBy||(e.orderBy=dn.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(e,t,a){return this.findAllBy(exports.GaugeShareAttributes.UserAddress,e,t,a)}async findByGauge(e,t,a){return this.findAllBy(exports.GaugeShareAttributes.GaugeId,e,t,a)}}const Ar=new e.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 Sr{constructor(e,t,a){this.chainId=t,this.multicall=Cn(e,a)}async getTotalSupplies(e){const t=e.map((e=>[e,Ar.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(Se(n[a],18))),e)),{})}async getWorkingSupplies(e){const t=e.map((e=>[e,Ar.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(Se(n[a],18))),e)),{})}async getRewardCounts(e){let t;if(248==this.chainId||9372==this.chainId||6343==this.chainId||4326==this.chainId){const a=e.map((e=>[e,Ar.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],r=n.map(((e,t)=>{const n=[];for(let t=0;t<a[e];t++)n.push([e,Ar.encodeFunctionData("reward_tokens",[t])]);return s[t+1]=s[t]+a[e],n})).flat(),[,i]=await this.multicall.aggregate(r);return n.reduce(((e,t,a)=>{const n=s[a],r=s[a+1],o=[];for(let e=n;e<r;e++)o.push(Ar.decodeFunctionResult("reward_tokens",i[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,Ar.encodeFunctionData("reward_data",[a[e][t]])]);return n[t+1]=n[t]+a[e].length,s})).flat(),[,r]=await this.multicall.aggregate(s),i=r.map((e=>Ar.decodeFunctionResult("reward_data",e)[0]));return Object.keys(a).reduce(((e,t,s)=>{const r=n[s],o=a[t].reduce(((e,t,a)=>(e[t]||(e[t]=i[r+a]),e)),{});return e[t]||(e[t]=o),e}),{})}}class Pr{constructor(e){this.gauges=[],this.client=kn(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 Br=6048e5;class _r{constructor(e,t,a,n,s){this.chainId=n,this.workingSupplies={},this.workingSuppliesNextPeriod={},this.relativeWeights={},this.relativeWeightsNextPeriod={},this.rewardData={},a&&(this.gaugeController=new gr(t,a,s)),this.multicall=new Sr(t,n,s),this.subgraph=new Pr(e)}async fetch(){const e=await this.subgraph.fetch(),t=e.map((e=>e.id));if(248!=this.chainId&&9372!=this.chainId&&6343!=this.chainId&&4326!=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()+Br)/Br)*Br)/1e3;this.relativeWeightsNextPeriod=await this.gaugeController.getRelativeWeights(t,e)}let n=!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:a.BigNumber.from(0),integral:a.BigNumber.from(0),token:e.id.split("-")[0],decimals:e.decimals,rate:Pe(e.rate||"0",e.decimals),period_finish:a.BigNumber.from(e.periodFinish||"0")}]))):{}),t.tokens&&t.tokens.length>0&&(n=!0),e}),{}),n||(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 Or{constructor(e,t){this.url=e,this.apiKey=t}async get(e){try{const t=this.toPayload(e),{data:a}=await E.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:y.jsonToGraphQLQuery({query:e})})}}class vr{constructor(e){var t,a;this.skip=0,this.client=vn(e.url),this.blockHeight=e.blockHeight,this.chainId=e.chainId;const n={orderBy:Ea.TotalLiquidity,orderDirection:fa.Desc,where:{swapEnabled:{eq:!0}}},s=Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||n),r=Object.assign({},(null===(a=e.query)||void 0===a?void 0:a.attrs)||{});this.query={args:s,attrs:r}}async fetchDefault(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0},orderBy:Ea.TotalLiquidity,orderDirection:fa.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 je(this.query.args).format(new He),{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,r,i,o,d,p;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!==(r=e.priceRateProviders)&&void 0!==r?r:void 0,createTime:e.createTime,mainIndex:null!==(i=e.mainIndex)&&void 0!==i?i: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!==(p=e.upperTarget)&&void 0!==p?p:"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 kr{constructor(e){this.skip=0,this.poolsSubgraph=new vr({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 Gn(e,this.multicall,this.vault,this.provider)}async fetch(e){const t=await this.poolsSubgraph.fetch(e);return await Gn(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 Nr extends Er{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 Cr;exports.PoolJoinExitAttributes=void 0,(Cr=exports.PoolJoinExitAttributes||(exports.PoolJoinExitAttributes={})).Pool="pool",Cr.Sender="sender";class Dr extends Ir{async query(e){e.orderBy||(e.orderBy=ua.Timestamp),e.orderDirection||(e.orderDirection=fa.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(e,t,a){return this.findAllBy(exports.PoolJoinExitAttributes.Sender,e,t,a)}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(e,t,a){return this.findAllBy(exports.PoolJoinExitAttributes.Pool,e,t,a)}}class Fr extends Ir{async query(e){e.orderBy||(e.orderBy=ga.Balance),e.orderDirection||(e.orderDirection=fa.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(e,t,a){return this.findAllBy(exports.PoolShareAttributes.UserAddress,e,t,a)}async findByPool(e,t,a){return this.findAllBy(exports.PoolShareAttributes.PoolId,e,t,a)}}class Rr{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 Mr{constructor(e,t=1){this.chainId=t,this.prices={},this.baseTokenAddresses=e.map(Fe),this.urlBase=`${et[t].urls.priceUrl}/price/?vs_currencies=usd,eth`,this.debouncer=new Le(this.fetch.bind(this),200)}fetch(e,{signal:t}={}){return e.length,E.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 E.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 6343:case 4326: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 Lr{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 E.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 6343:case 4326: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 Ur{constructor(e,t=1){this.subgraphUrl=e,this.chainId=t,this.prices={},this.debouncer=new Le(this.fetch.bind(this),200)}async fetch(e,{signal:t}={}){return e.length,E.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 Gr{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 qr{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 Wr=new e.Interface(["function rate() view returns (uint256)"]);class $r{constructor(e,t,a){this.network=a,this.multicall=Cn(e,t)}async fetch(e){const t=Object.values(Be[e]),a=t.map((e=>[e,Wr.encodeFunctionData("rate",[])])),[,n]=await this.multicall.aggregate(a);return t.reduce(((e,t,a)=>(e[t]||(e[t]="0x"==n[a]?0:parseFloat(Se(n[a],27))),e)),{})}async getRate(e){return this.network!=exports.Network.MAINNET&&this.network!=exports.Network.POLYGON?1:Object.values(Be[this.network]).includes(e)?(this.rates||(this.rates=this.fetch(this.network)),(await this.rates)[e]):1}}const Vr=new e.Interface(["function getTokensDistributedInWeek(address token, uint timestamp) view returns (uint)"]),Hr=new e.Interface(["function totalSupply() view returns (uint)"]),jr=new e.Interface(["function getRate() view returns (uint)"]);class Kr{constructor(e,t,a,n,s,r){this.feeDistributorAddress=t,this.balAddress=a,this.veBalAddress=n,this.bbAUsdAddress=s,this.multicall=Cn(e,r)}async fetch(e){const t=this.getPreviousWeek(e),a=[[this.feeDistributorAddress,Vr.encodeFunctionData("getTokensDistributedInWeek",[n.getAddress(this.balAddress),t])],[this.feeDistributorAddress,Vr.encodeFunctionData("getTokensDistributedInWeek",[n.getAddress(this.bbAUsdAddress),t])],[this.veBalAddress,Hr.encodeFunctionData("totalSupply",[])],[this.bbAUsdAddress,jr.encodeFunctionData("getRate",[])]],[,s]=await this.multicall.aggregate(a);return{balAmount:parseFloat(Se(s[0],18)),bbAUsdAmount:parseFloat(Se(s[1],18)),veBalSupply:parseFloat(Se(s[2],18)),bbAUsdPrice:parseFloat(Se(s[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 Zr=new e.Interface(["function getProtocolFeesCollector() view returns (address)"]),Xr=new e.Interface(["function getSwapFeePercentage() view returns (uint)"]);let Jr;class Yr{constructor(e,t){this.provider=t,this.vault=new s.Contract(e,Zr,this.provider)}async fetch(){const e=await this.vault.getProtocolFeesCollector(),t=new s.Contract(e,Xr,this.provider),a=await t.getSwapFeePercentage();return parseFloat(Se(a,18))}async find(){return Jr||(Jr=this.fetch()),this.swapFeePercentage=await Jr,this.swapFeePercentage}async findBy(){return this.find()}}const zr=new e.Interface(["function getSwapFeePercentage() view returns (uint)"]);let Qr;class ei{constructor(e,t,a){this.protocolFeePercentagesProviderAddress=t,this.multicall=Cn(e,a)}async fetch(){const e=[[this.protocolFeePercentagesProviderAddress,zr.encodeFunctionData("getFeeTypePercentage",[0])],[this.protocolFeePercentagesProviderAddress,zr.encodeFunctionData("getFeeTypePercentage",[2])]],[,t]=await this.multicall.aggregate(e);return{swapFee:parseFloat(Se(t[0],18)),yieldFee:parseFloat(Se(t[2],18))}}async getFees(){return Qr||(Qr=this.fetch()),this.protocolFees=await Qr,this.protocolFees}}const ti={stETH:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",wstETH:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",arbitrumStEth:"0x5979d7b546e38e414f7e9822514be443a4800529"},ai=async()=>{let e=0;try{const t=await E.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{[ti.stETH]:e,[ti.wstETH]:e,[ti.arbitrumStEth]:e}},ni={rETH:"0xae78736cd615f374d3085123a210448e74fc6393"},si=async()=>{let e=0;try{const t=await E.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{[ni.rETH]:e}},ri={stMATIC:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4"},ii=async()=>{let e=0;try{const t=await E.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{[ri.stMATIC]:e}},oi={usdcUSDplus:"0x1aafc31091d93c3ff003cff5d2d8f7ba2e728425",usdcUSDplus2:"0x6933ec1ca55c06a894107860c92acdfd2dd8512f"},di=async()=>{let e=0;try{const{data:t}=await E.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(oi).map((t=>[t,e])))},pi={sfrxETH:"0xac3e018457b222d93114458476f3e3416abbe38f"},ci=async()=>{let e=0;try{const t=await E.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{[pi.sfrxETH]:e}},li={maticX:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6"},ui=async()=>{let e=0;try{const t=await E.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{[li.maticX]:e}},bi={qETH:"0x93ef1ea305d11a9b2a3ebb9bb4fcc34695292e7d"},yi=async()=>{let e=0;try{const t=await E.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=tranchess"),[{weeklyAveragePnlPercentage:n}]=t.data;e=Math.round(parseFloat(Se(a.BigNumber.from(n).mul(365).mul(1e4),18)))}catch(e){console.error("Failed to fetch qETH APR:",e)}return{[bi.qETH]:e}},mi={USDR:"0xaf0d9d65fc54de245cda37af3d18cbec860a4d4b"},fi=async()=>{let e=0;try{const t=await E.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{[mi.USDR]:e}},hi={rETH:"0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593"},Ti=async()=>{let e=0;try{const t=await E.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{[hi.rETH]:e}},gi=new l.JsonRpcProvider("https://rpc.ankr.com/eth",1),xi={getPoolsUI:new s.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"}],gi).getPoolsUI},Ii={sApe:"0x7966c5bae631294d7cffcea5430b78c2f76db6fa"},Ei=async(e=1,t=xi)=>{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{[Ii.sApe]:a}},wi={eUSDC:"0xeb91861f8a4e1c12333f42dce8fb0ecdc28da716",eDAI:"0xe025e3ca2be02316033184551d4d3aa22024d9dc",eUSDT:"0x4d19f33948b99800b6113ff3e83bec9b537c85d2",eFRAX:"0x5484451a88a35cd0878a1be177435ca8a0e4054e"},Ai={[exports.Network.MAINNET]:"https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet"},Si=async()=>{const e=exports.Network.MAINNET,t={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(wi)}},n=await E.default.post(Ai[e],t),{data:{assets:s}}=n.data,r={eUSDT:0,eDAI:0,eUSDC:0,eFRAX:0};return s.forEach((({eTokenAddress:e,supplyAPY:t})=>{const n=Object.entries(wi).filter((([,t])=>t.toLocaleLowerCase()===e.toLocaleLowerCase()))[0][0];r[n]=Math.round(1e4*parseFloat(Se(a.BigNumber.from(t),27)))})),{[wi.eUSDT]:r.eUSDT,[wi.eDAI]:r.eDAI,[wi.eUSDC]:r.eUSDC,[wi.eFRAX]:r.eFRAX}},Pi=Object.fromEntries([...Object.values(ti).map((e=>[e,ai])),...Object.values(ri).map((e=>[e,ii])),...Object.values(_e).map((e=>[e,De])),...Object.values(oi).map((e=>[e,di])),...Object.values(ni).map((e=>[e,si])),...Object.values(pi).map((e=>[e,ci])),...Object.values(li).map((e=>[e,ui])),...Object.values(bi).map((e=>[e,yi])),...Object.values(mi).map((e=>[e,fi])),...Object.values(hi).map((e=>[e,Ti])),...Object.values(Ii).map((e=>[e,Ei])),...Object.values(wi).map((e=>[e,Si]))]);class Bi{constructor(e,t=Pi){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 _i=e=>`{\n blocks(first: 1, orderBy: timestamp, orderDirection: asc, where: { timestamp_gt: ${e} }) {\n number\n }\n}`,Oi=async(e,t)=>{const a={query:_i(t)},n=await E.default.post(e,a),{data:{blocks:s}}=n.data;return parseInt(s[0].number)};class vi{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]:Oi(this.endpoint,e)}),this.blocks[e]}}async findBy(e="",t=""){}}var ki,Ni,Ci=[{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"},{chainId:6343,address:"0xAba76Cdc5910F6627856EB75Bcce0171376999C7",symbol:"weth"},{chainId:4326,address:"0x4200000000000000000000000000000000000006",symbol:"weth"}];class Di{constructor(e,t,a){this.pools=new vr({url:e.urls.subgraph,chainId:e.chainId}),this.poolsOnChain=new kr({url:e.urls.subgraph,chainId:e.chainId,provider:t,multicall:e.addresses.contracts.multicall,vault:e.addresses.contracts.vault,query:a}),this.poolShares=new Fr(e.urls.subgraph,e.chainId),this.poolJoinExits=new Dr(e.urls.subgraph,e.chainId),e.urls.gaugesSubgraph&&(this.poolGauges=new Nr(e.urls.gaugesSubgraph,e.chainId),this.gaugeShares=new wr(e.urls.gaugesSubgraph,e.chainId)),e.urls.blockNumberSubgraph&&(this.blockNumbers=new vi(e.urls.blockNumberSubgraph));this.yesterdaysPools=new vr({url:e.urls.subgraph,chainId:e.chainId,blockHeight:async()=>{const e=await t.getBlockNumber();return Number(e)-5e3}});const n=Ci.filter((t=>t.chainId==e.chainId)).map((e=>e.address)),s=new Mr(n,e.chainId),r=new Ur(e.urls.subgraph,e.chainId),i=new $r(e.addresses.contracts.multicall,t,e.chainId);this.tokenPrices=new Gr(s,r,i);const o=new Lr(e.chainId);this.tokenHistoricalPrices=new qr(o,i),this.tokenMeta=new Rr([]),e.urls.gaugesSubgraph&&(this.liquidityGauges=new _r(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 Kr(e.addresses.contracts.multicall,e.addresses.contracts.feeDistributor,e.addresses.tokens.bal,e.addresses.tokens.veBal,e.addresses.tokens.bbaUsd,t)),this.feeCollector=new Yr(e.addresses.contracts.vault,t),e.addresses.contracts.protocolFeePercentagesProvider&&(this.protocolFees=new ei(e.addresses.contracts.multicall,e.addresses.contracts.protocolFeePercentagesProvider,t)),this.tokenYields=new Bi(e.chainId)}}!function(e){e[e.Direct=0]="Direct",e[e.TokenIn=1]="TokenIn",e[e.TokenOut=2]="TokenOut",e[e.Middle=3]="Middle"}(ki||(ki={})),function(e){e[e.Swap=0]="Swap",e[e.BatchSwap=1]="BatchSwap",e[e.Join=2]="Join",e[e.Exit=3]="Exit"}(Ni||(Ni={}));const Fi={type:Ni.BatchSwap,swaps:[],opRef:[],minOut:"0",assets:[],hasTokenIn:!1,hasTokenOut:!1,fromInternal:!1,toInternal:!1,limits:[],approveTokens:[],sender:"",receiver:""},Ri=new e.Interface(Ts);function Mi(e,t){return e.some((e=>e.address.toLowerCase()===t.toLowerCase()))}function Li(e,t){const a=t[e.assetOutIndex],n=C(e.poolId);return a.toLowerCase()===n.toLowerCase()}function Ui(e,t){const a=t[e.assetInIndex],n=C(e.poolId);return a.toLowerCase()===n.toLowerCase()}function Gi(e,t,a){let n={};var s;return e!==ki.TokenIn&&e!==ki.Middle||(s=a,n={index:t,key:ds.toChainedReference(s)},a++),[n,a]}function qi(e,t){return Ye(a.BigNumber.from(e),a.BigNumber.from(t)).toString()}function Wi(e,t,a,n){let s=e.amount;return(a===ki.TokenOut||a===ki.Middle&&t===Ni.Join||a===ki.Middle&&t===Ni.Exit)&&(s=ds.toChainedReference(n-1).toString()),s}function $i(e,t,a,n){let s;return s=a===e&&n===t?ki.Direct:a===e?ki.TokenIn:n===t?ki.TokenOut:ki.Middle,s}function Vi(e,n){const s=function(e){const t=[],a=[],n=[];for(const s of e)s.type===Ni.Exit||s.type===Ni.Join?s.hasTokenIn?t.push(s):s.hasTokenOut?a.push(s):n.push(s):n.push(s);return[...t,...n,...a]}(e),r=function(e,n){const s=[];let r=d.cloneDeep(Fi);r.assets=n,r.limits=Array(n.length).fill(a.BigNumber.from("0"));let i=!0,o={};for(const p of e)p.type===Ni.Swap?(i&&(o=p,i=!1),p.isBptIn&&r.approveTokens.push(p.assets[p.swap.assetInIndex]),p.fromInternal===o.fromInternal&&p.toInternal===o.toInternal&&p.receiver===o.receiver&&p.sender===o.sender||r.swaps.length>0&&(s.push(r),r=d.cloneDeep(Fi),r.assets=n,r.limits=Array(n.length).fill(a.BigNumber.from("0"))),r.swaps.push(p.swap),r.opRef.push(...p.opRef),r.fromInternal=p.fromInternal,r.toInternal=p.toInternal,r.sender=p.sender,r.receiver=p.receiver,p.hasTokenIn?(r.hasTokenIn=!0,r.limits[p.swap.assetInIndex]=r.limits[p.swap.assetInIndex].add(p.amountIn)):r.limits[p.swap.assetInIndex]=t.MaxInt256,p.hasTokenOut&&(r.hasTokenOut=!0,r.limits[p.swap.assetOutIndex]=r.limits[p.swap.assetOutIndex].sub(p.minOut)),o=p):(r.swaps.length>0&&(s.push(r),r=d.cloneDeep(Fi),r.assets=n,r.limits=Array(n.length).fill(a.BigNumber.from("0"))),s.push(p));return r.swaps.length>0&&s.push(r),s}(s,n);return r}function Hi(e,t,a,n,s,r,i,o){var d;const p=$i(t,a,e.assetInIndex,e.assetOutIndex),c=Wi(e,Ni.Join,p,n),l=qi(null!==(d=e.returnAmount)&&void 0!==d?d:"0",r),[u,b]=Gi(p,e.assetOutIndex,n);let y=o,m=!0,f=!1;p!==ki.Direct&&p!==ki.TokenIn||(y=i,m=!1,f=!0);let h=o,T=!1;p!==ki.Direct&&p!==ki.TokenOut||(h=i,T=!0);return[{type:Ni.Join,poolId:e.poolId,tokenIn:s[e.assetInIndex],bpt:s[e.assetOutIndex],opRef:u,minOut:l,amountIn:c,assets:s,actionStep:p,sender:y,receiver:h,fromInternal:m,hasTokenIn:f,hasTokenOut:T},b]}function ji(e,t,a,n,s,r,i,o){var d;const p=$i(t,a,e.assetInIndex,e.assetOutIndex),c=Wi(e,Ni.Exit,p,n),l=qi(null!==(d=e.returnAmount)&&void 0!==d?d:"0",r),[u,b]=Gi(p,e.assetOutIndex,n);let y=o,m=!1;p!==ki.Direct&&p!==ki.TokenIn||(y=i,m=!0);let f=!1,h=!0,T=o;p!==ki.Direct&&p!==ki.TokenOut||(T=i,h=!1,f=!0);return[{type:Ni.Exit,poolId:e.poolId,tokenOut:s[e.assetOutIndex],bpt:s[e.assetInIndex],opRef:u.key?[u]:[],minOut:l,amountIn:c,assets:s,actionStep:p,sender:y,receiver:T,toInternal:h,hasTokenIn:m,hasTokenOut:f},b]}function Ki(e,t,a,n,s,r,i,o,d){var p;const c=$i(t,a,e.assetInIndex,e.assetOutIndex),l=Wi(e,Ni.Swap,c,n);e.amount=l;const u=qi(null!==(p=e.returnAmount)&&void 0!==p?p:"0",r),[b,y]=Gi(c,e.assetOutIndex,n),m=c===ki.Direct||c===ki.TokenIn,f=c===ki.Direct||c===ki.TokenOut,h=Mi(i,s[e.assetInIndex]);let T=!0;(m||h)&&(T=!1);let g,x,I=!0;(f||Mi(i,s[e.assetOutIndex]))&&(I=!1),g=m?o:d,x=f?o:d;return[{type:Ni.Swap,opRef:b.key?[b]:[],minOut:u,amountIn:l,assets:s,swap:e,hasTokenIn:m,hasTokenOut:f,fromInternal:T,toInternal:I,isBptIn:h,sender:g,receiver:x},y]}function Zi(e,t,a){const n=e.tokensList,s=new q(a),[r]=s.sortTokens(n),i=t.tokenOut,o=r.findIndex((e=>e.toLowerCase()===i.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.minOut;const p=t.amountIn,c={assets:r,minAmountsOut:d,userData:S.exitExactBPTInForOneTokenOut(p,o),toInternalBalance:t.toInternal,poolId:t.poolId,poolKind:0,sender:t.sender,recipient:t.receiver,outputReferences:t.opRef,exitPoolRequest:{}},l=ds.constructExitCall(c),u=t.hasTokenOut?d[o]:"0";return[l,t.hasTokenIn?p:"0",u]}function Xi(e,t,a){const n=e.tokensList,s=new q(a),[r]=s.sortTokens(n),i=t.tokenIn,o=r.findIndex((e=>e.toLowerCase()===i.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.amountIn;const p=t.minOut,c=S.joinExactTokensInForBPTOut(d,p),l={poolId:t.poolId,sender:t.sender,recipient:t.receiver,kind:0,joinPoolRequest:{assets:r,maxAmountsIn:d,userData:c,fromInternalBalance:t.fromInternal},value:"0",outputReference:t.opRef.key?t.opRef.key.toString():"0"},u=ds.encodeJoinPool(l),b=t.hasTokenOut?p:"0";return[u,t.hasTokenIn?d[o]:"0",b]}function Ji(e,n,s){const r=[];for(const a of e.approveTokens){const e=ds.encodeApproveVault(a,t.MaxUint256.toString());r.push(e)}const i={sender:e.sender,recipient:e.receiver,fromInternalBalance:e.fromInternal,toInternalBalance:e.toInternal},o={swapType:exports.SwapType.SwapExactIn,swaps:e.swaps,assets:e.assets,funds:i,limits:e.limits.map((e=>e.toString())),deadline:a.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:e.opRef},d=ds.encodeBatchSwap(o);r.push(d);const p=e.assets.findIndex((e=>e.toLowerCase()===n.toLowerCase())),c=e.assets.findIndex((e=>e.toLowerCase()===s.toLowerCase()));return[r,e.hasTokenIn?e.limits[p].toString():"0",e.hasTokenOut?e.limits[c].abs().toString():"0"]}Object.defineProperty(exports,"PoolFilter",{enumerable:!0,get:function(){return p.PoolFilter}}),Object.defineProperty(exports,"RouteProposer",{enumerable:!0,get:function(){return p.RouteProposer}}),Object.defineProperty(exports,"SOR",{enumerable:!0,get:function(){return p.SOR}}),Object.defineProperty(exports,"SwapTypes",{enumerable:!0,get:function(){return p.SwapTypes}}),Object.defineProperty(exports,"formatSequence",{enumerable:!0,get:function(){return p.formatSequence}}),Object.defineProperty(exports,"getTokenAddressesForSwap",{enumerable:!0,get:function(){return p.getTokenAddressesForSwap}}),Object.defineProperty(exports,"parseToPoolsDict",{enumerable:!0,get:function(){return p.parseToPoolsDict}}),Object.defineProperty(exports,"phantomStableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return p.phantomStableBPTForTokensZeroPriceImpact}}),Object.defineProperty(exports,"queryBatchSwapTokensIn",{enumerable:!0,get:function(){return p.queryBatchSwapTokensIn}}),Object.defineProperty(exports,"queryBatchSwapTokensOut",{enumerable:!0,get:function(){return p.queryBatchSwapTokensOut}}),Object.defineProperty(exports,"stableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return p.stableBPTForTokensZeroPriceImpact}}),Object.defineProperty(exports,"weightedBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return p.weightedBPTForTokensZeroPriceImpact}}),exports.APR_THRESHOLD=1e4,exports.AaveHelpers=class{static async getRate(e,t){const a=new s.Contract(e,U,t);return(await a.getRate()).toString()}},exports.AaveRates=$r,exports.AssetHelpers=q,exports.BalancerAPIArgsFormatter=Ve,exports.BalancerError=nt,exports.BalancerErrors=$,exports.BalancerMinterAuthorization=K,exports.BalancerSDK=class{constructor(e,t=new Hn(e),a=new ps(e)){this.config=e,this.sor=t,this.subgraph=a,this.networkConfig=Vn(e),this.provider=t.provider,this.data=new Di(this.networkConfig,t.provider,e.subgraphQuery),this.swaps=new is(this.config),this.relayer=new ds(this.swaps),this.pricing=new cs(e,this.swaps),this.pools=new hr(this.networkConfig,this.data),this.balancerContracts=new Is(this.networkConfig.addresses.contracts,t.provider),this.zaps=new Vs(this.networkConfig.chainId)}get rpcProvider(){return this.sor.provider}get contracts(){return this.balancerContracts.contracts}},exports.BlockNumberRepository=vi,exports.CoingeckoHistoricalPriceRepository=Lr,exports.CoingeckoPriceRepository=Mr,exports.ComposableStablePoolEncoder=O,exports.Data=Di,exports.Debouncer=Le,exports.FeeCollectorRepository=Yr,exports.FeeDistributorRepository=Kr,exports.GaugeControllerMulticallRepository=gr,exports.GaugeSharesRepository=wr,exports.GraphQLArgsBuilder=je,exports.HistoricalPriceProvider=qr,exports.Liquidity=Wt,exports.LiquidityGaugeSubgraphRPCProvider=_r,exports.LiquidityGaugesMulticallRepository=Sr,exports.LiquidityGaugesSubgraphRepository=Pr,exports.ManagedPoolEncoder=P,exports.POOLS=function(e){return L[e]?L[e]:M},exports.PoolGaugesRepository=Nr,exports.PoolJoinExitRepository=Dr,exports.PoolSharesRepository=Fr,exports.Pools=hr,exports.PoolsBalancerAPIRepository=class{constructor(e){var t,a;this.pools=[],this.skip=0,this.client=new Or(e.url,e.apiKey);this.query={args:Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||{chainId:4326,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 je(this.query.args).format(new Ve),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}},exports.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 ${this.currentProviderIdx}/${this.providers.length}`);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}},exports.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)}},exports.PoolsSubgraphOnChainRepository=kr,exports.PoolsSubgraphRepository=vr,exports.ProtocolFeesProvider=ei,exports.Relayer=ds,exports.RelayerAuthorization=j,exports.SHALLOW_COMPOSABLE_STABLE_BUFFER=1e6,exports.Sor=Hn,exports.StablePoolEncoder=A,exports.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)}},exports.StaticTokenProvider=Rr,exports.Subgraph=ps,exports.SubgraphArgsFormatter=He,exports.SubgraphPriceRepository=Ur,exports.Swaps=is,exports.TokenPriceProvider=Gr,exports.TokenYieldsRepository=Bi,exports.WeightedPoolEncoder=S,exports.accountToAddress=V,exports.addressMapIn=Re,exports.balEmissions=Xs,exports.bn=e=>a.parseFixed(`${e}`,18),exports.buildRelayerCalls=function(e,t,n,s,r,i,o){const d=Vi(function(e,t,a,n,s,r,i,o){const d=n.findIndex((t=>t.toLowerCase()===e.toLowerCase())),p=n.findIndex((e=>e.toLowerCase()===t.toLowerCase())),c=[];let l=0,u={};for(const e of a)if(Li(e,n)){const[t,a]=Hi(e,d,p,l,n,s,i,o);l=a,c.push(t),u=t}else{if(!Ui(e,n)){const t=e.amount,[a,b]=Ki(e,d,p,l,n,s,r,i,o);u.type===Ni.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"),l=b,c.push(a),u=a;continue}{const[t,a]=ji(e,d,p,l,n,s,i,o);l=a,c.push(t),u=t}}return c}(e.tokenIn,e.tokenOut,e.swaps,e.tokenAddresses,i,t,n,s),e.tokenAddresses),p=[],c=[],l=[];o&&p.push(function(e,t){return ds.encodeSetRelayerApproval(t,!0,e)}(o,s));for(const n of d){if(n.type===Ni.Exit){const e=t.find((e=>e.id===n.poolId));if(void 0===e)throw new nt(exports.BalancerErrorCode.NO_POOL_DATA);const[s,i,o]=Zi(e,n,r);p.push(s),c.push(a.BigNumber.from(i)),l.push(a.BigNumber.from(o))}if(n.type===Ni.Join){const e=t.find((e=>e.id===n.poolId));if(void 0===e)throw new nt(exports.BalancerErrorCode.NO_POOL_DATA);const[s,i,o]=Xi(e,n,r);p.push(s),c.push(a.BigNumber.from(i)),l.push(a.BigNumber.from(o))}if(n.type===Ni.BatchSwap){const[t,s,r]=Ji(n,e.tokenIn,e.tokenOut);p.push(...t),c.push(a.BigNumber.from(s)),l.push(a.BigNumber.from(r))}}return function(e,t,n,s){const r=e.reduce(((e=a.BigNumber.from(0),t)=>e.add(t))),i=t.reduce(((e=a.BigNumber.from(0),t)=>e.add(t))),o=i.sub(Ye(n.returnAmount,a.BigNumber.from(s)));if(!r.eq(n.swapAmount)||!o.lt("3"))throw new nt(exports.BalancerErrorCode.RELAY_SWAP_AMOUNTS)}(c,l,e,i),{to:s,data:Ri.encodeFunctionData("multicall",[p]),rawCalls:p}},exports.canUseJoinExit=function(e,a,n){return e!==p.SwapTypes.SwapExactOut&&a.toLowerCase()!==t.AddressZero.toLowerCase()&&n.toLowerCase()!==t.AddressZero.toLowerCase()},exports.formatFixed=Ge,exports.formatFromBigInt18=function(e){return a.formatFixed(a.BigNumber.from(e),18)},exports.getLimitsForSlippage=Ze,exports.getPoolAddress=C,exports.getPoolNonce=F,exports.getPoolSpecialization=D,exports.insert=$e,exports.isNormalizedWeights=e=>{const a=e.reduce(((e,t)=>e.add(t)),t.Zero);return a.eq(t.WeiPerEther)},exports.isSameAddress=We,exports.parseFixed=Ue,exports.parsePoolInfo=ne,exports.parseToBigInt18=qe,exports.signPermit=async(e,n,s,i,o=t.MaxUint256,d)=>{const{chainId:p}=await e.provider.getNetwork(),c=await n.getAddress();d||(d=await e.nonces(c));const l={name:await e.name(),version:"1",chainId:p,verifyingContract:e.address},u={owner:c,spender:await V(s),value:i,nonce:d,deadline:o},b=await n._signTypedData(l,{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(b),deadline:a.BigNumber.from(o),nonce:a.BigNumber.from(d)}},exports.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)))},exports.splitPoolId=e=>({address:C(e),specialization:D(e),nonce:F(e)}),exports.toNormalizedWeights=function(e){if(100==e.length)return Array(100).fill(t.WeiPerEther.div(100));const a=e.reduce(((e,t)=>e.add(t)),t.Zero);if(a.eq(t.WeiPerEther))return e;const n=[];let s=t.Zero;for(let r=0;r<e.length;r++)r<e.length-1?(n[r]=e[r].mul(t.WeiPerEther).div(a),s=s.add(n[r])):n[r]=t.WeiPerEther.sub(s);return n},exports.tokenAddressForPricing=Fe,exports.tokensToTokenPrices=function(e){const t={};return e.forEach((e=>{e.price&&(t[e.address]=e.price)})),t},exports.unwrapToken=Me;
|
|
489
489
|
//# sourceMappingURL=index.js.map
|