@defiverse/balancer-sdk-megaeth 0.1.259 → 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.umd.js
CHANGED
|
@@ -485,5 +485,5 @@ ${Fa`
|
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
`,vn=(e,t,a)=>e();function kn(e){return rn(new b.GraphQLClient(e))}function Nn(e){return function(e,t=vn){return{GaugeShare:(a,n)=>t((t=>e.request(Sn,a,{...n,...t})),"GaugeShare","query"),GaugeShares:(a,n)=>t((t=>e.request(Pn,a,{...n,...t})),"GaugeShares","query"),LiquidityGauges:(a,n)=>t((t=>e.request(Bn,a,{...n,...t})),"LiquidityGauges","query"),Pools:(a,n)=>t((t=>e.request(_n,a,{...n,...t})),"Pools","query"),PoolGauges:(a,n)=>t((t=>e.request(On,a,{...n,...t})),"PoolGauges","query")}}(new b.GraphQLClient(e))}const Cn=["function aggregate(tuple[](address target, bytes callData) memory calls) public view returns (uint256 blockNumber, bytes[] memory returnData)"],Dn=(e,t)=>new i.Contract(e,Cn,t);class Fn{constructor(e,a,n,s={}){this.options={},this.calls=[],this.paths=[],this.multiAddress=e,this.provider=a,this.interface=new t.Interface(n),this.options=s}call(e,t,a,n){return this.calls.push([t,a,n]),this.paths.push(e),this}async execute(e={}){const t=e;return(await this.executeMulticall()).forEach(((e,a)=>c.set(t,this.paths[a],e.length>1?e:e[0]))),this.calls=[],this.paths=[],t}async executeMulticall(){const e=Dn(this.multiAddress,this.provider),[,t]=await e.aggregate(this.calls.map((([e,t,a])=>[e,this.interface.encodeFunctionData(t,a)])),this.options);return t.map(((e,t)=>this.interface.decodeFunctionResult(this.calls[t][1],e)))}}var 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:"normalizedWeights",type:"uint256[]"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getNormalizedWeights",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"increaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"balanceTokenIn",type:"uint256"},{internalType:"uint256",name:"balanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Mn=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"startValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"}],name:"AmpUpdateStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"currentValue",type:"uint256"}],name:"AmpUpdateStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAmplificationParameter",outputs:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"isUpdating",type:"bool"},{internalType:"uint256",name:"precision",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"balanceTokenIn",type:"uint256"},{internalType:"uint256",name:"balanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"rawEndValue",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"}],name:"startAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"stopAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Ln=[{inputs:[{internalType:"contract IERC20",name:"_underlying",type:"address"},{internalType:"contract IERC20",name:"_bond",type:"address"},{internalType:"uint256",name:"_expiration",type:"uint256"},{internalType:"uint256",name:"_unitSeconds",type:"uint256"},{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"uint256",name:"_percentFee",type:"uint256"},{internalType:"uint256",name:"_percentFeeGov",type:"uint256"},{internalType:"address",name:"_governance",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"collectedBase",type:"uint256"},{indexed:!1,internalType:"uint256",name:"collectedBond",type:"uint256"},{indexed:!1,internalType:"uint256",name:"remainingBase",type:"uint256"},{indexed:!1,internalType:"uint256",name:"remainingBond",type:"uint256"}],name:"FeeCollection",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"FEE_BOUND",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"bond",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"bondDecimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"expiration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"feesBond",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"feesUnderlying",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"governance",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"increaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"currentBalances",type:"uint256[]"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"protocolSwapFee",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"},{internalType:"uint256[]",name:"dueProtocolFeeAmounts",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"currentBalances",type:"uint256[]"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"protocolSwapFee",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"},{internalType:"uint256[]",name:"dueProtocolFeeAmounts",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256",name:"currentBalanceTokenIn",type:"uint256"},{internalType:"uint256",name:"currentBalanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"percentFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"percentFeeGov",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountX",type:"uint256"},{internalType:"uint256",name:"reserveX",type:"uint256"},{internalType:"uint256",name:"reserveY",type:"uint256"},{internalType:"bool",name:"out",type:"bool"}],name:"solveTradeInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"underlying",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"underlyingDecimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"unitSeconds",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],Un=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20",name:"mainToken",type:"address"},{internalType:"contract IERC20",name:"wrappedToken",type:"address"},{internalType:"uint256",name:"upperTarget",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract IERC20",name:"token",type:"address"},{indexed:!1,internalType:"uint256",name:"lowerTarget",type:"uint256"},{indexed:!1,internalType:"uint256",name:"upperTarget",type:"uint256"}],name:"TargetsSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBptIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMainIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMainToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getScalingFactors",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getTargets",outputs:[{internalType:"uint256",name:"lowerTarget",type:"uint256"},{internalType:"uint256",name:"upperTarget",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVirtualSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedTokenRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newLowerTarget",type:"uint256"},{internalType:"uint256",name:"newUpperTarget",type:"uint256"}],name:"setTargets",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Gn=[{inputs:[{components:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IProtocolFeePercentagesProvider",name:"protocolFeeProvider",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"contract IRateProvider[]",name:"rateProviders",type:"address[]"},{internalType:"uint256[]",name:"tokenRateCacheDurations",type:"uint256[]"},{internalType:"bool[]",name:"exemptFromYieldProtocolFeeFlags",type:"bool[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],internalType:"struct ComposableStablePool.NewPoolParams",name:"params",type:"tuple"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"startValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"}],name:"AmpUpdateStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"currentValue",type:"uint256"}],name:"AmpUpdateStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"feeType",type:"uint256"},{indexed:!1,internalType:"uint256",name:"protocolFeePercentage",type:"uint256"}],name:"ProtocolFeePercentageCacheUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"enabled",type:"bool"}],name:"RecoveryModeStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenIndex",type:"uint256"},{indexed:!1,internalType:"uint256",name:"rate",type:"uint256"}],name:"TokenRateCacheUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenIndex",type:"uint256"},{indexed:!0,internalType:"contract IRateProvider",name:"provider",type:"address"},{indexed:!1,internalType:"uint256",name:"cacheDuration",type:"uint256"}],name:"TokenRateProviderSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"disableRecoveryMode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"enableRecoveryMode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getActualSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAmplificationParameter",outputs:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"isUpdating",type:"bool"},{internalType:"uint256",name:"precision",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBptIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDomainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastJoinExitData",outputs:[{internalType:"uint256",name:"lastJoinExitAmplification",type:"uint256"},{internalType:"uint256",name:"lastPostJoinExitInvariant",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMinimumBpt",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"getNextNonce",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"feeType",type:"uint256"}],name:"getProtocolFeePercentageCache",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProtocolFeesCollector",outputs:[{internalType:"contract IProtocolFeesCollector",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProtocolSwapFeeDelegation",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRateProviders",outputs:[{internalType:"contract IRateProvider[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getScalingFactors",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"getTokenRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"getTokenRateCache",outputs:[{internalType:"uint256",name:"rate",type:"uint256"},{internalType:"uint256",name:"oldRate",type:"uint256"},{internalType:"uint256",name:"duration",type:"uint256"},{internalType:"uint256",name:"expires",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"inRecoveryMode",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"isTokenExemptFromYieldProtocolFee",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"uint256",name:"duration",type:"uint256"}],name:"setTokenRateCacheDuration",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"rawEndValue",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"}],name:"startAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"stopAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"updateProtocolFeePercentageCache",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"updateTokenRateCache",outputs:[],stateMutability:"nonpayable",type:"function"}];async function qn(e,t,a,s){if(0===e.length)return e;const i=Object.values(Object.fromEntries([...p.Vault__factory.abi,...G,...Rn,...Mn,...Ln,...Un,...Gn].map((e=>[e.name,e])))),r=new Fn(t,s,i),o=Object.values(l.PoolFilter),d=[];e.forEach((e=>{o.includes(e.poolType)?(d.push(e),r.call(`${e.id}.poolTokens`,a,"getPoolTokens",[e.id]),r.call(`${e.id}.totalSupply`,e.address,"totalSupply"),(e.poolType.includes("Linear")||"StablePhantom"===e.poolType)&&r.call(`${e.id}.virtualSupply`,e.address,"getVirtualSupply"),"ComposableStable"===e.poolType&&r.call(`${e.id}.actualSupply`,e.address,"getActualSupply"),"Weighted"===e.poolType||"LiquidityBootstrapping"===e.poolType||"Investment"===e.poolType?(r.call(`${e.id}.weights`,e.address,"getNormalizedWeights"),r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Stable"===e.poolType||"MetaStable"===e.poolType||"StablePhantom"===e.poolType||"ComposableStable"===e.poolType?(r.call(`${e.id}.amp`,e.address,"getAmplificationParameter"),r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Element"===e.poolType?r.call(`${e.id}.swapFee`,e.address,"percentFee"):e.poolType.toString().includes("Linear")?(r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage"),r.call(`${e.id}.targets`,e.address,"getTargets"),r.call(`${e.id}.rate`,e.address,"getWrappedTokenRate")):e.poolType.toString().includes("Gyro")&&r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):console.error(`Unknown pool type: ${e.poolType} ${e.id}`)}));let c={};try{c=await r.execute()}catch(e){throw"Issue with multicall execution."}const u=[];return Object.entries(c).forEach((([e,t],a)=>{try{const{poolTokens:s,swapFee:i,weights:r,totalSupply:o,virtualSupply:c,actualSupply:l}=t;if("Stable"===d[a].poolType||"MetaStable"===d[a].poolType||"StablePhantom"===d[a].poolType||"ComposableStable"===d[a].poolType){if(!t.amp)return void console.error(`Stable Pool Missing Amp: ${e}`);d[a].amp=n.formatFixed(t.amp[0],3)}if(d[a].poolType.includes("Linear")){if(!t.targets)return void console.error(`Linear Pool Missing Targets: ${e}`);d[a].lowerTarget=n.formatFixed(t.targets[0],18),d[a].upperTarget=n.formatFixed(t.targets[1],18);const s=d[a].wrappedIndex;if(void 0===s||void 0===t.rate)return void console.error(`Linear Pool Missing WrappedIndex or PriceRate: ${e}`);d[a].tokens[s].priceRate=n.formatFixed(t.rate,18)}if(d[a].swapFee=n.formatFixed(i,18),s.tokens.forEach(((t,i)=>{const o=d[a].tokens.find((e=>$e(e.address,t)));if(!o)throw`Pool Missing Expected Token: ${e} ${t}`;o.balance=n.formatFixed(s.balances[i],o.decimals),r&&(o.weight=n.formatFixed(r[i],18))})),d[a].poolType.includes("Linear")||"StablePhantom"===d[a].poolType){if(void 0===c)return void console.error(`Pool with pre-minted BPT missing Virtual Supply: ${e}`);d[a].totalShares=n.formatFixed(c,18)}else if("ComposableStable"===d[a].poolType){if(void 0===l)return void console.error(`ComposableStable missing Actual Supply: ${e}`);d[a].totalShares=n.formatFixed(l,18)}else d[a].totalShares=n.formatFixed(o,18);u.push(d[a])}catch(e){throw`Issue with pool onchain data: ${e}`}})),u}class Wn{constructor(e,t,a,n){this.client=e,this.provider=t,this.network=a,this.sorConfig=n}async getPools(){const e=function(e){return e.map((e=>({...e,poolType:e.poolType||"",tokens:(e.tokens||[]).map((e=>({...e,weight:e.weight||null}))),totalWeight:e.totalWeight||void 0,amp:e.amp||void 0,expiryTime:e.expiryTime?c.parseInt(e.expiryTime):void 0,unitSeconds:e.unitSeconds?c.parseInt(e.unitSeconds):void 0,principalToken:e.principalToken||void 0,baseToken:e.baseToken||void 0})))}((await this.getSubgraphPools()).filter((e=>{if(!this.network.poolsToIgnore)return!0;return-1===this.network.poolsToIgnore.findIndex((t=>$e(t,e.address)))})));return!1===this.sorConfig.fetchOnChainBalances?e:qn(e,this.network.addresses.contracts.multicall,this.network.addresses.contracts.vault,this.provider)}async getSubgraphPools(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0,totalShares_gt:"1"},orderBy:xa.TotalLiquidity,orderDirection:ha.Desc});return[...e,...t,...a]}}class $n{constructor(e){this.chainId=e}async getNativeAssetPriceInToken(e){const t=await this.getTokenPriceInNativeAsset(e);return""+1/parseFloat(t)}async getTokenPriceInNativeAsset(e){const t=`https://api.coingecko.com/api/v3/simple/token_price/${this.platformId}?contract_addresses=${e}&vs_currencies=${this.nativeAssetId}`,{data:a}=await x.default.get(t,{headers:{Accept:"application/json","Content-Type":"application/json"}});if(void 0===a[e.toLowerCase()][this.nativeAssetId])throw Error("No price returned from Coingecko");return a[e.toLowerCase()][this.nativeAssetId]}get platformId(){switch(this.chainId){case 1:case 42:case 248:case 16116:case 17117:return"ethereum";case 137:return"polygon-pos";case 42161:return"arbitrum-one";case 100:return"xdai"}return"3"}get nativeAssetId(){switch(this.chainId){case 1:case 42:case 42161:case 248:case 16116:case 17117:return"eth";case 137:return"";case 100:return"xdai"}return""}}class Vn{constructor(e,t){this.client=e,this.weth=t.toLowerCase()}async getNativeAssetPriceInToken(e){const t=await this.getLatestPriceInEthFromSubgraph(e);if(!t)throw Error("No price found in the subgraph");return""+1/t}async getLatestPriceInEthFromSubgraph(e){e=e.toLowerCase();const{latestPrices:t}=await this.client.TokenLatestPrices({where:{asset_in:[e,this.weth]}}),a=c.keyBy(t,"id");if(a[`${e}-${this.weth}`])return parseFloat(a[`${e}-${this.weth}`].price);const n=t.filter((t=>t.asset===e));for(const e of n){const t=a[`${e.pricingAsset}-${this.weth}`];if(t)return parseFloat(e.price)*parseFloat(t.price)}return null}}function Hn(e){var t,a;if("number"==typeof e.network){const a=tt[e.network];return{...a,urls:{...a.urls,subgraph:null!==(t=e.customSubgraphUrl)&&void 0!==t?t:a.urls.subgraph},tenderly:e.tenderly}}return{...e.network,urls:{...e.network.urls,subgraph:null!==(a=e.customSubgraphUrl)&&void 0!==a?a:e.network.urls.subgraph},tenderly:e.network.tenderly}}class jn extends l.SOR{constructor(e){const t=Hn(e),a=jn.getSorConfig(e),n=jn.getSorNetworkConfig(t),s=new u.JsonRpcProvider(e.rpcUrl,e.network),i=kn(t.urls.subgraph);super(s,n,jn.getPoolDataService(t,a,s,i),jn.getTokenPriceService(t,a,i))}static getSorConfig(e){return{tokenPriceService:"coingecko",poolDataService:"subgraph",fetchOnChainBalances:!0,...e.sor}}static getSorNetworkConfig(e){var t;return{...e,vault:e.addresses.contracts.vault,weth:e.addresses.tokens.wrappedNativeAsset,lbpRaisingTokens:null===(t=e.addresses.tokens)||void 0===t?void 0:t.lbpRaisingTokens,wETHwstETH:e.pools.wETHwstETH,connectingTokens:e.sorConnectingTokens}}static getPoolDataService(e,t,a,n){return"object"==typeof t.poolDataService?t.poolDataService:new Wn(n,a,e,t)}static getTokenPriceService(e,t,a){return"object"==typeof t.tokenPriceService?t.tokenPriceService:("subgraph"===t.tokenPriceService&&new Vn(a,e.addresses.tokens.wrappedNativeAsset),new $n(e.chainId))}}function Kn(e){if(e.poolIds.length>2)throw new Error("Simple flash swap only supports a maximum of two pools");if(e.assets.length>2)throw new Error("Simple flash swap only supports a maximum of to two assets (tokens)")}function Zn(e,t){return[{poolId:e[0],assetInIndex:0,assetOutIndex:1,amount:t,userData:"0x"},{poolId:e[1],assetInIndex:1,assetOutIndex:0,amount:"0",userData:"0x"}]}function Xn(e){return-1*Number(e)}function Jn(e){return c.sum(e)}var Yn=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IERC20",name:"wstETH",type:"address"},{internalType:"contract IBalancerMinter",name:"minter",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approveVault",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"assetInIndex",type:"uint256"},{internalType:"uint256",name:"assetOutIndex",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.BatchSwapStep[]",name:"swaps",type:"tuple[]"},{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"int256[]",name:"limits",type:"int256[]"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{components:[{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"key",type:"uint256"}],internalType:"struct VaultActions.OutputReference[]",name:"outputReferences",type:"tuple[]"}],name:"batchSwap",outputs:[{internalType:"int256[]",name:"",type:"int256[]"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum VaultActions.PoolKind",name:"kind",type:"uint8"},{internalType:"address",name:"sender",type:"address"},{internalType:"address payable",name:"recipient",type:"address"},{components:[{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{internalType:"uint256[]",name:"minAmountsOut",type:"uint256[]"},{internalType:"bytes",name:"userData",type:"bytes"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.ExitPoolRequest",name:"request",type:"tuple"},{components:[{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"key",type:"uint256"}],internalType:"struct VaultActions.OutputReference[]",name:"outputReferences",type:"tuple[]"}],name:"exitPool",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge[]",name:"gauges",type:"address[]"}],name:"gaugeClaimRewards",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge",name:"gauge",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"gaugeDeposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address[]",name:"gauges",type:"address[]"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"gaugeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bool",name:"approval",type:"bool"},{internalType:"address",name:"user",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"gaugeSetMinterApproval",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge",name:"gauge",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"gaugeWithdraw",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"getEntrypoint",outputs:[{internalType:"contract IBalancerRelayer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum VaultActions.PoolKind",name:"kind",type:"uint8"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{components:[{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{internalType:"uint256[]",name:"maxAmountsIn",type:"uint256[]"},{internalType:"bytes",name:"userData",type:"bytes"},{internalType:"bool",name:"fromInternalBalance",type:"bool"}],internalType:"struct IVault.JoinPoolRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"joinPool",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.UserBalanceOpKind",name:"kind",type:"uint8"},{internalType:"contract IAsset",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"sender",type:"address"},{internalType:"address payable",name:"recipient",type:"address"}],internalType:"struct IVault.UserBalanceOp[]",name:"ops",type:"tuple[]"},{internalType:"uint256",name:"value",type:"uint256"}],name:"manageUserBalance",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"ref",type:"uint256"}],name:"peekChainedReferenceValue",outputs:[{internalType:"uint256",name:"value",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"relayer",type:"address"},{internalType:"bool",name:"approved",type:"bool"},{internalType:"bytes",name:"authorisation",type:"bytes"}],name:"setRelayerApproval",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"stakeETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"stakeETHAndWrap",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IAsset",name:"assetIn",type:"address"},{internalType:"contract IAsset",name:"assetOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.SingleSwap",name:"singleSwap",type:"tuple"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"uint256",name:"limit",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"swap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStaticATokenLM",name:"staticToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"toUnderlying",type:"bool"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapAaveStaticToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC4626",name:"wrappedToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapERC4626",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IUnbuttonToken",name:"wrapperToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapUnbuttonToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapWstETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC20Permit",name:"token",type:"address"},{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"vaultPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC20PermitDAI",name:"token",type:"address"},{internalType:"address",name:"holder",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"bool",name:"allowed",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"vaultPermitDAI",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStaticATokenLM",name:"staticToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"fromUnderlying",type:"bool"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapAaveDynamicToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC4626",name:"wrappedToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapERC4626",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapStETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IUnbuttonToken",name:"wrapperToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"uAmount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapUnbuttonToken",outputs:[],stateMutability:"payable",type:"function"}];const zn={"0xae7ab96520de3a18e5e111b5eaab095312d7fe84":"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0","0xd46ba6d942050d489dbd938a2c909a5d5039a161":"0xedb171c18ce90b633db442f2a6f72874093b49ef","0x1e6bb68acec8fefbd87d192be09bb274170a0548":"0xF03387d8d0FF326ab586A58E0ab4121d106147DF"};function Qn(e){let t=e;return zn.hasOwnProperty(e)&&(t=zn[e]),t}var es;function ts(e,t,a){const{tokens:n,contracts:s}=at(a);let i={id:es.vault,address:s.vault};return n.stETH&&s.lidoRelayer&&[e,t].includes(n.stETH)&&(i={id:es.lido,address:s.lidoRelayer}),i}function as(e){let t=p.Vault__factory.abi;e.id===es.lido&&(t=Yn);return t.filter((e=>e.name&&["swap","batchSwap"].includes(e.name)))}function ns(e){return{amount:e,max:t=>e.mul(1e3+t).div(1e3),min:t=>e.mul(1e3-t).div(1e3)}}function ss(t,a){const n=a===e.SwapType.SwapExactIn?t.swapAmount:t.returnAmount,s=a===e.SwapType.SwapExactIn?t.returnAmount:t.swapAmount,i=a===e.SwapType.SwapExactIn?t.swapAmountForSwaps||t.swapAmount:t.returnAmountFromSwaps||t.returnAmount,r=a===e.SwapType.SwapExactIn?t.returnAmountFromSwaps||t.returnAmount:t.swapAmountForSwaps||t.swapAmount,o=Qn(t.tokenIn),d=Qn(t.tokenOut);return{...t,amountIn:n,amountOut:s,amountInForLimits:ns(i),amountOutForLimits:ns(r),tokenInForSwaps:o,tokenOutFromSwaps:d}}!function(e){e[e.vault=1]="vault",e[e.lido=2]="lido"}(es||(es={}));class is{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="swap",this.swapInfo=ss(e,t),this.relayer=ts(this.swapInfo.tokenIn,this.swapInfo.tokenOut,this.chainId)}setFunds(e,t){this.funds={sender:e,recipient:t||e,fromInternalBalance:!1,toInternalBalance:!1}}setDeadline(e){this.deadline=e.toString()}get amount(){return this.kind===e.SwapType.SwapExactOut?this.swapInfo.amountOutForLimits.amount:this.swapInfo.amountInForLimits.amount}setLimits(t){this.limit=this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(t).toString():this.swapInfo.amountInForLimits.max(t).toString()}get singleSwap(){return{poolId:this.swapInfo.swaps[0].poolId,kind:this.kind,assetIn:this.swapInfo.tokenInForSwaps,assetOut:this.swapInfo.tokenOutFromSwaps,amount:this.amount.toString(),userData:"0x"}}attributes(){var e;if(!this.funds||!this.limit||!this.deadline)throw new Error("Uninitialized arguments");let t={request:this.singleSwap,funds:this.funds,limit:this.limit,deadline:this.deadline};const a=this.fragment();return a[0].inputs&&(null===(e=a[0].inputs)||void 0===e?void 0:e.length)>4&&(t={...t,value:"0",outputReference:"0"}),t}data(){return new t.Interface(this.fragment()).encodeFunctionData("swap",Object.values(this.attributes()))}value(t){let s=n.BigNumber.from(0);return this.swapInfo.tokenIn===a.AddressZero&&(s=this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountIn:this.swapInfo.amountInForLimits.max(t)),s}to(){return this.relayer.address}fragment(){return as(this.relayer).filter((e=>e.name===this.functionName))}}class rs{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="batchSwap",this.swapInfo=ss(e,t),this.relayer=ts(this.swapInfo.tokenIn,this.swapInfo.tokenOut,this.chainId)}setFunds(e,t){this.funds={sender:e,recipient:t||e,fromInternalBalance:!1,toInternalBalance:!1}}setDeadline(e){this.deadline=e}minAmountOut(t){return this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(t):this.swapInfo.amountOutForLimits.amount}maxAmountIn(t){return this.kind===e.SwapType.SwapExactOut?this.swapInfo.amountInForLimits.max(t):this.swapInfo.amountInForLimits.amount}setLimits(e){this.limits=this.swapInfo.tokenAddresses.map((t=>{let a=n.BigNumber.from(0);return t===this.swapInfo.tokenInForSwaps&&(a=this.maxAmountIn(e)),t===this.swapInfo.tokenOutFromSwaps&&(a=this.minAmountOut(e).mul(-1)),a})).map((e=>e.toString().split(".")[0]))}attributes(){var e;if(!this.funds||!this.limits||!this.deadline)throw new Error("Uninitialized arguments");let t={kind:this.kind,swaps:this.swapInfo.swaps,assets:this.swapInfo.tokenAddresses,funds:this.funds,limits:this.limits,deadline:this.deadline};const a=this.fragment();return a[0].inputs&&(null===(e=a[0].inputs)||void 0===e?void 0:e.length)>6&&(t={...t,value:"0",outputReferences:[]}),t}data(){return new t.Interface(this.fragment()).encodeFunctionData("batchSwap",Object.values(this.attributes()))}value(e){let t=n.BigNumber.from(0);return this.swapInfo.tokenIn===a.AddressZero&&(t=this.maxAmountIn(e)),t}to(){return this.relayer.address}fragment(){return as(this.relayer).filter((e=>e.name===this.functionName))}}class os{constructor(e){e instanceof l.SOR?(this.sor=e,this.chainId=this.sor.provider._network.chainId):(this.sor=new jn(e),this.chainId=e.network),this.vaultContract=p.Vault__factory.connect(et,this.sor.provider)}static getLimitsForSlippage(e,t,a,n,s,i){return Xe(e,t,a,n,s,i).map((e=>e.toString()))}async findRouteGivenIn({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s=4}){return this.sor.getSwaps(e,t,l.SwapTypes.SwapExactIn,a,{gasPrice:n,maxPools:s})}async findRouteGivenOut({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s}){return this.sor.getSwaps(e,t,l.SwapTypes.SwapExactOut,a,{gasPrice:n,maxPools:s})}buildSwap({userAddress:e,recipient:t,swapInfo:a,kind:n,deadline:s,maxSlippage:i}){if(!this.chainId)throw"Missing network configuration";const r=a.swaps.length>1?new rs(a,n,this.chainId):new is(a,n,this.chainId);r.setFunds(e,t),r.setDeadline(s),r.setLimits(i);const o=r.to(),{functionName:d}=r;return{to:o,functionName:d,attributes:r.attributes(),data:r.data(),value:r.value(i)}}static encodeBatchSwap(e){return p.Vault__factory.createInterface().encodeFunctionData("batchSwap",[e.kind,e.swaps,e.assets,e.funds,e.limits,e.deadline])}static encodeSimpleFlashSwap(t){return this.encodeBatchSwap(function({poolIds:t,assets:a,flashLoanAmount:n,walletAddress:s}){Kn({poolIds:t,assets:a});const i=Zn(t,n),r={sender:s,fromInternalBalance:!1,recipient:s,toInternalBalance:!1};return{kind:e.SwapType.SwapExactIn,swaps:i,assets:a,funds:r,limits:["0","0"],deadline:"999999999999999999"}}(t))}async fetchPools(){return this.sor.fetchPools()}getPools(){return this.sor.getPools()}async queryBatchSwap(e){return await Vt(this.vaultContract,e.kind,e.swaps,e.assets)}async queryBatchSwapWithSor(e){return await Ht(this.sor,this.vaultContract,e)}async querySimpleFlashSwap(t){return await async function(t){Kn(t);const[a,n]=t.assets;try{const s=await Vt(t.vaultContract,e.SwapType.SwapExactIn,Zn(t.poolIds,t.flashLoanAmount),t.assets),i={[a]:Xn(s[0]).toString(),[n]:Xn(s[1]).toString()};return{profits:i,isProfitable:Jn([i[a],i[n]])>0}}catch(e){throw`Failed to querySimpleFlashSwap: ${e}`}}({...t,vaultContract:this.vaultContract})}async getSorSwap(e){return await jt(e.tokenIn,e.tokenOut,e.swapType,e.amount,this.sor)}}const ds=new t.Interface(Yn);class cs{constructor(e){this.swaps=e instanceof os?e:new os(e)}static isChainedReference(e){const t=n.BigNumber.from(e),a=n.BigNumber.from("0xfff0000000000000000000000000000000000000000000000000000000000000"),s=t.toBigInt()&a.toBigInt();return"0xba10000000000000000000000000000000000000000000000000000000000000"===n.BigNumber.from(s)._hex.toString()}static encodeApproveVault(e,t){return ds.encodeFunctionData("approveVault",[e,t])}static encodeSetRelayerApproval(e,t,a){return ds.encodeFunctionData("setRelayerApproval",[e,t,a])}static encodeGaugeWithdraw(e,t,a,n){return ds.encodeFunctionData("gaugeWithdraw",[e,t,a,n])}static encodeGaugeDeposit(e,t,a,n){return ds.encodeFunctionData("gaugeDeposit",[e,t,a,n])}static encodeBatchSwap(e){return ds.encodeFunctionData("batchSwap",[e.swapType,e.swaps,e.assets,e.funds,e.limits,e.deadline,e.value,e.outputReferences])}static encodeExitPool(e){return ds.encodeFunctionData("exitPool",[e.poolId,e.poolKind,e.sender,e.recipient,e.exitPoolRequest,e.outputReferences])}static encodeJoinPool(e){return ds.encodeFunctionData("joinPool",[e.poolId,e.kind,e.sender,e.recipient,e.joinPoolRequest,e.value,e.outputReference])}static encodeWrapAaveDynamicToken(e){return ds.encodeFunctionData("wrapAaveDynamicToken",[e.staticToken,e.sender,e.recipient,e.amount,e.fromUnderlying,e.outputReference])}static encodeUnwrapAaveStaticToken(e){return ds.encodeFunctionData("unwrapAaveStaticToken",[e.staticToken,e.sender,e.recipient,e.amount,e.toUnderlying,e.outputReferences])}static encodePeekChainedReferenceValue(e){return ds.encodeFunctionData("peekChainedReferenceValue",[e])}static toChainedReference(e,t=!0){const a=t?cs.CHAINED_REFERENCE_TEMP_PREFIX:cs.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${a}${"0".repeat(64-a.length)}`;return n.BigNumber.from(s).add(e)}static fromChainedReference(e,t=!0){const a=t?cs.CHAINED_REFERENCE_TEMP_PREFIX:cs.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${a}${"0".repeat(64-a.length)}`;return n.BigNumber.from(e).sub(n.BigNumber.from(s))}static constructExitCall(e){const{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s,poolId:i,poolKind:r,sender:o,recipient:d,outputReferences:c}=e,l={poolId:i,poolKind:r,sender:o,recipient:d,outputReferences:c,exitPoolRequest:{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s}};return cs.encodeExitPool(l)}static constructJoinCall(e){const{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s,poolId:i,kind:r,sender:o,recipient:d,value:c,outputReference:l}=e,p={poolId:i,kind:r,sender:o,recipient:d,value:c,outputReference:l,joinPoolRequest:{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s}};return cs.encodeJoinPool(p)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async exitPoolAndBatchSwap(t){const s=a.WeiPerEther.sub(n.BigNumber.from(t.slippage)),i=t.expectedAmountsOut.map((e=>n.BigNumber.from(e).mul(s).div(a.WeiPerEther).toString())),r=[];t.exitTokens.forEach(((e,t)=>{const a=cs.toChainedReference(t);r.push({index:t,key:a})}));const o=cs.constructExitCall({assets:t.exitTokens,minAmountsOut:i,userData:t.userData,toInternalBalance:!0,poolId:t.poolId,poolKind:0,sender:t.exiter,recipient:t.exiter,outputReferences:r,exitPoolRequest:{}}),d=await this.swaps.queryBatchSwapWithSor({tokensIn:t.exitTokens,tokensOut:t.finalTokensOut,swapType:e.SwapType.SwapExactIn,amounts:i,fetchPools:t.fetchPools});if(d.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);d.swaps.forEach((e=>{const a=d.assets[e.assetInIndex],n=t.exitTokens.indexOf(a);-1!==n&&(e.amount=r[n].key.toString())}));const c=a.WeiPerEther.add(t.slippage);t.exitTokens.forEach(((e,s)=>{const i=d.assets.map((e=>e.toLowerCase())).indexOf(e.toLowerCase());-1!==i&&(d.deltas[i]=n.BigNumber.from(t.expectedAmountsOut[s]).mul(c).div(a.WeiPerEther).toString())}));const l=os.getLimitsForSlippage(t.exitTokens,t.finalTokensOut,e.SwapType.SwapExactIn,d.deltas,d.assets,"0"),p={sender:t.exiter,recipient:t.swapRecipient,fromInternalBalance:!0,toInternalBalance:!1};return{function:"multicall",params:[o,cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:d.swaps,assets:d.assets,funds:p,limits:l.map((e=>e.toString())),deadline:a.MaxUint256,value:"0",outputReferences:[]})],outputs:{amountsOut:d.returnAmounts}}}async swapUnwrapAaveStaticExactIn(t,s,i,r,o,d,c={fetchPools:!0,fetchOnChain:!1}){const l=await this.swaps.queryBatchSwapWithSor({tokensIn:t,tokensOut:s,swapType:e.SwapType.SwapExactIn,amounts:i,fetchPools:c});if(l.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const p=os.getLimitsForSlippage(t,s,e.SwapType.SwapExactIn,l.deltas,l.assets,d);return{function:"multicall",params:this.encodeSwapUnwrap(s,e.SwapType.SwapExactIn,l.swaps,l.assets,o,p),outputs:{amountsOut:l.returnAmounts.map(((t,s)=>{const i=n.BigNumber.from(t).abs().mul(r[s]).div(a.WeiPerEther);if(!i.gt(a.Zero))throw new st(e.BalancerErrorCode.UNWRAP_ZERO_AMOUNT);return i.toString()}))}}}async swapUnwrapAaveStaticExactOut(t,s,i,r,o,d,c={fetchPools:!0,fetchOnChain:!1}){const l=i.map(((t,s)=>{const i=n.BigNumber.from(t).mul(a.WeiPerEther).div(r[s]);if(!i.gt(a.Zero))throw new st(e.BalancerErrorCode.WRAP_ZERO_AMOUNT);return i.toString()})),p=await this.swaps.queryBatchSwapWithSor({tokensIn:t,tokensOut:s,swapType:e.SwapType.SwapExactOut,amounts:l,fetchPools:c});if(p.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const u=os.getLimitsForSlippage(t,s,e.SwapType.SwapExactOut,p.deltas,p.assets,d);return{function:"multicall",params:this.encodeSwapUnwrap(s,e.SwapType.SwapExactOut,p.swaps,p.assets,o,u),outputs:{amountsIn:p.returnAmounts.map((e=>e.toString()))}}}encodeSwapUnwrap(e,t,n,s,i,r){const o=[],d=[];e.forEach(((e,t)=>{const a=s.findIndex((t=>t.toLowerCase()===e.toLowerCase()));if(-1===a)return;const n=cs.toChainedReference(t);o.push({index:a,key:n});const r=cs.encodeUnwrapAaveStaticToken({staticToken:e,sender:i.recipient,recipient:i.sender,amount:n,toUnderlying:!0,outputReferences:0});d.push(r)}));return[cs.encodeBatchSwap({swapType:t,swaps:n,assets:s,funds:i,limits:r.map((e=>e.toString())),deadline:a.MaxUint256,value:"0",outputReferences:o}),...d]}}cs.CHAINED_REFERENCE_TEMP_PREFIX="ba10",cs.CHAINED_REFERENCE_READONLY_PREFIX="ba11",cs.signRelayerApproval=async(e,t,n,s)=>{const i=s.interface.encodeFunctionData("setRelayerApproval",[t,e,!0]),r=await K.signSetRelayerApprovalAuthorization(s,n,e,i);return K.encodeCalldataAuthorization("0x",a.MaxUint256,r)};class ls{constructor(e){this.url=Hn(e).urls.subgraph,this.client=this.initClient()}initClient(){return rn(new b.GraphQLClient(this.url))}}class ps{constructor(e,t){this.swaps=t||new os(e)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async getSpotPrice(t,a,n=[]){0===n.length&&(await this.fetchPools(),n=this.getPools());const s=l.parseToPoolsDict(n,0),i=this.swaps.sor.routeProposer.getCandidatePathsFromDict(t,a,0,s,4);if(0===i.length)throw new st(e.BalancerErrorCode.UNSUPPORTED_PAIR);return l.getSpotPriceAfterSwapForPath(i[0],0,l.ZERO).toString()}}var us=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}];function bs(e){return Math.round(Date.now()/1e3)-e<86400}var ys=[{name:"Deposit",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1},{name:"locktime",type:"uint256",indexed:!0},{name:"type",type:"int128",indexed:!1},{name:"ts",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Withdraw",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1},{name:"ts",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Supply",inputs:[{name:"prevSupply",type:"uint256",indexed:!1},{name:"supply",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{stateMutability:"nonpayable",type:"constructor",inputs:[{name:"token_addr",type:"address"},{name:"_name",type:"string"},{name:"_symbol",type:"string"},{name:"_authorizer_adaptor",type:"address"}],outputs:[]},{stateMutability:"view",type:"function",name:"token",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"decimals",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"admin",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"nonpayable",type:"function",name:"commit_smart_wallet_checker",inputs:[{name:"addr",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"apply_smart_wallet_checker",inputs:[],outputs:[]},{stateMutability:"view",type:"function",name:"get_last_user_slope",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"int128"}]},{stateMutability:"view",type:"function",name:"user_point_history__ts",inputs:[{name:"_addr",type:"address"},{name:"_idx",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"locked__end",inputs:[{name:"_addr",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"nonpayable",type:"function",name:"checkpoint",inputs:[],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"deposit_for",inputs:[{name:"_addr",type:"address"},{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"create_lock",inputs:[{name:"_value",type:"uint256"},{name:"_unlock_time",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"increase_amount",inputs:[{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"increase_unlock_time",inputs:[{name:"_unlock_time",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"withdraw",inputs:[],outputs:[]},{stateMutability:"view",type:"function",name:"balanceOf",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"balanceOf",inputs:[{name:"addr",type:"address"},{name:"_t",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"balanceOfAt",inputs:[{name:"addr",type:"address"},{name:"_block",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupply",inputs:[{name:"t",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupplyAt",inputs:[{name:"_block",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"supply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"locked",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"tuple",components:[{name:"amount",type:"int128"},{name:"end",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"epoch",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"point_history",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"tuple",components:[{name:"bias",type:"int128"},{name:"slope",type:"int128"},{name:"ts",type:"uint256"},{name:"blk",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"user_point_history",inputs:[{name:"arg0",type:"address"},{name:"arg1",type:"uint256"}],outputs:[{name:"",type:"tuple",components:[{name:"bias",type:"int128"},{name:"slope",type:"int128"},{name:"ts",type:"uint256"},{name:"blk",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"user_point_epoch",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"slope_changes",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"int128"}]},{stateMutability:"view",type:"function",name:"future_smart_wallet_checker",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"smart_wallet_checker",inputs:[],outputs:[{name:"",type:"address"}]}];class ms{constructor(e,t){this.addresses=e,this.provider=t}async getLockInfo(e){if(!this.addresses.veBal)throw new Error("veBal address must be defined");const t=new Fn(this.addresses.multicall,this.provider,ys);t.call("locked",this.addresses.veBal,"locked",[e]),t.call("epoch",this.addresses.veBal,"epoch"),t.call("totalSupply",this.addresses.veBal,"totalSupply()");const a=await t.execute();return this.formatLockInfo(a)}formatLockInfo(e){const[t,a]=e.locked,n=t.gt(0),s=1e3*a.toNumber();const i=n&&Date.now()>s;return{lockedEndDate:s,lockedAmount:Pe(t),totalSupply:Pe(e.totalSupply),epoch:Pe(e.epoch,0),hasExistingLock:n,isExpired:i}}}var fs=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IERC20",name:"votingEscrow",type:"address"},{internalType:"contract IVeDelegation",name:"delegation",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newImplementation",type:"address"}],name:"DelegationImplementationUpdated",type:"event"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"adjustedBalanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"adjusted_balance_of",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDelegationImplementation",outputs:[{internalType:"contract IVeDelegation",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVotingEscrow",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"killDelegation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IVeDelegation",name:"delegation",type:"address"}],name:"setDelegation",outputs:[],stateMutability:"nonpayable",type:"function"}];class hs{constructor(e,t){if(!e.veBalProxy)throw new Error("veBalProxy address must be defined");this.instance=new i.Contract(e.veBalProxy,fs,t)}async getAdjustedBalance(e){return Pe(await this.instance.adjustedBalanceOf(e))}}var Ts=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"address",name:"libraryAddress",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"getLibrary",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}],gs=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"address",name:"libraryAddress",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"getLibrary",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}];const Is=(e,t,a)=>{switch(a){case 3:return new i.Contract(e,gs,t);case 4:return new i.Contract(e,Ts,t);default:throw new Error("relayer not supported")}};var Es=[{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 ws{constructor(e,t){this.contractAddresses="number"==typeof e?tt[e].addresses.contracts:e,this.vault=p.Vault__factory.connect(this.contractAddresses.vault,t),this.balancerHelpers=p.BalancerHelpers__factory.connect(this.contractAddresses.balancerHelpers,t),this.contractAddresses.lidoRelayer&&(this.lidoRelayer=p.LidoRelayer__factory.connect(this.contractAddresses.lidoRelayer,t)),this.multicall=Dn(this.contractAddresses.multicall,t),this.contractAddresses.relayerV3&&(this.relayerV3=Is(this.contractAddresses.relayerV3,t,3)),this.contractAddresses.relayerV4&&(this.relayerV4=Is(this.contractAddresses.relayerV4,t,4)),this.contractAddresses.veBal&&(this.veBal=new ms(this.contractAddresses,t)),this.contractAddresses.veBalProxy&&(this.veBalProxy=new hs(this.contractAddresses,t))}get contracts(){return{vault:this.vault,balancerHelpers:this.balancerHelpers,lidoRelayer:this.lidoRelayer,multicall:this.multicall,relayerV3:this.relayerV3,relayerV4:this.relayerV4,veBal:this.veBal,veBalProxy:this.veBalProxy,ERC20:this.getErc20,liquidityGauge:this.getLiquidityGauge}}getErc20(e,t){return((e,t)=>new i.Contract(e,us,t))(e,t)}getLiquidityGauge(e,t){return((e,t)=>new i.Contract(e,Es,t))(e,t)}}const xs={1:{relayer:"0x886A3Ec7bcC508B8795990B60Fa21f85F9dB7948",staBal3:{id:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063",address:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42",gauge:"0x34f33cdaed8ba0e1ceece80e5f4a73bcf234cfac",assetOrder:["DAI","USDC","USDT"]},bbausd1:{id:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe",address:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2",gauge:"0x68d019f64a7aa97e2d4e7363aee42251d08124fb",assetOrder:["bb-a-USDT","bb-a-DAI","bb-a-USDC"]},bbausd2:{id:"0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d",address:"0xa13a9247ea42d743238089903570127dda72fe44",gauge:"0xa6325e799d266632d347e41265a69af111b05403"},linearUsdc1:{id:"0x9210f1204b5a24742eba12f710636d76240df3d00000000000000000000000fc",address:"0x9210F1204b5a24742Eba12f710636D76240dF3d0"},linearDai1:{id:"0x804cdb9116a10bb78768d3252355a1b18067bf8f0000000000000000000000fb",address:"0x804CdB9116a10bB78768D3252355a1b18067bF8f"},linearUsdt1:{id:"0x2bbf681cc4eb09218bee85ea2a5d3d13fa40fc0c0000000000000000000000fd",address:"0x2BBf681cC4eb09218BEe85EA2a5d3D13Fa40fC0C"},linearUsdc2:{id:"0x82698AECC9E28E9BB27608BD52CF57F704BD1B83000000000000000000000336",address:"0x82698aeCc9E28e9Bb27608Bd52cF57f704BD1B83"},linearDai2:{id:"0xAE37D54AE477268B9997D4161B96B8200755935C000000000000000000000337",address:"0xae37D54Ae477268B9997d4161B96b8200755935c"},linearUsdt2:{id:"0x2F4EB100552EF93840D5ADC30560E5513DFFFACB000000000000000000000334",address:"0x2F4eb100552ef93840d5aDC30560E5513DFfFACb"},maiusd:{id:"",address:"",gauge:"",assetOrder:["USDT","miMATIC","DAI","USDC"]},maibbausd:{id:"",address:"",gauge:"",assetOrder:["bb-a-USD","miMATIC"]},DAI:"0x6b175474e89094c44da98b954eedeac495271d0f",USDC:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",waDAI:"0x02d60b84491589974263d922d9cc7a3152618ef6",waUSDC:"0xd093fa4fb80d09bb30817fdcd442d4d02ed3e5de",waUSDT:"0xf8fd466f12e236f4c96f7cce6c79eadb819abf58",miMATIC:""},5:{relayer:"0x7b9B6f094DC2Bd1c12024b0D9CC63d6993Be1888",staBal3:{id:"0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2000000000000000000000062",address:"0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2",gauge:"0xfd364cda96bb7db06b65706182c448a73f0a5f9a",assetOrder:["USDT","DAI","USDC"]},staBal3_2:{id:"0xff9d677474d4344379924e10b68c8fea67e03294000000000000000000000072",address:"0xff9d677474d4344379924e10b68c8fea67e03294",gauge:"0x4e4ebf2aa90e41174d716a5168895357762d68af",assetOrder:["USDT","DAI","USDC"]},staBal3_3:{id:"0x3bfc8a0509f1a68aefd446f6c19bf37b3c75a8fc0000000000000000000000a5",address:"0x3bfc8a0509f1a68aefd446f6c19bf37b3c75a8fc",gauge:"0x7776e1008d7c20ab54aa57a7c44fc7de602de29a",assetOrder:["USDT","DAI","USDC"]},bbausd1:{id:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f",address:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd",gauge:"0xa2d0ea81a47d68598922cd54c59249ff58c2a3ff",assetOrder:["bb-a-USDC","bb-a-DAI","bb-a-USDT"]},bbausd2:{id:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f",address:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd",gauge:"0xa2d0ea81a47d68598922cd54c59249ff58c2a3ff"},linearUsdc1:{id:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc8668100000000000000000000005c",address:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc86681"},linearDai1:{id:"0x5cea6a84ed13590ed14903925fa1a73c36297d9900000000000000000000005d",address:"0x5cea6a84ed13590ed14903925fa1a73c36297d99"},linearUsdt1:{id:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f00000000000000000000005e",address:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f"},linearUsdc2:{id:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc8668100000000000000000000005c",address:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc86681"},linearDai2:{id:"0x5cea6a84ed13590ed14903925fa1a73c36297d9900000000000000000000005d",address:"0x5cea6a84ed13590ed14903925fa1a73c36297d99"},linearUsdt2:{id:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f00000000000000000000005e",address:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f"},maiusd:{id:"0x6a8f9ab364b85725973d2a33cb9aae2dac43b5e30000000000000000000000a6",address:"0x6a8f9ab364b85725973d2a33cb9aae2dac43b5e3",gauge:"0x58141bdcecb7fbae006964f4131cf6f65c948357",assetOrder:["USDT","miMATIC","DAI","USDC"]},maibbausd:{id:"0xb04b03b78cf79788a1931545bd2744161029648f0000000000000000000000a8",address:"0xb04b03b78cf79788a1931545bd2744161029648f",gauge:"0xdc3f6fc8898830e53c777543fe252b14f22680d4",assetOrder:["bb-a-USD","miMATIC","MAI BSP"]},USDT:"0x1f1f156e0317167c11aa412e3d1435ea29dc3cce",DAI:"0x8c9e6c40d3402480ace624730524facc5482798c",USDC:"0xe0c9275e44ea80ef17579d33c55136b7da269aeb",waDAI:"0x89534a24450081aa267c79b07411e9617d984052",waUSDC:"0x811151066392fd641fe74a9b55a712670572d161",waUSDT:"0x4cb1892fddf14f772b2e39e299f44b2e5da90d04",miMATIC:"0x398106564948feeb1fedea0709ae7d969d62a391"},137:{relayer:"0xcf6a66E32dCa0e26AcC3426b851FD8aCbF12Dac7",staBal3:{id:"",address:"",gauge:"",assetOrder:["USDT","DAI","USDC"]},bbausd1:{id:"",address:"",gauge:"",assetOrder:["bb-a-USDC","bb-a-DAI","bb-a-USDT"]},bbausd2:{id:"0x48e6b98ef6329f8f0a30ebb8c7c960330d64808500000000000000000000075b",address:"0x48e6b98ef6329f8f0a30ebb8c7c960330d648085",gauge:""},linearUsdc1:{id:"",address:""},linearDai1:{id:"",address:""},linearUsdt1:{id:"",address:""},linearUsdc2:{id:"0xf93579002dbe8046c43fefe86ec78b1112247bb8000000000000000000000759",address:"0xf93579002dbe8046c43fefe86ec78b1112247bb8"},linearDai2:{id:"0x178e029173417b1f9c8bc16dcec6f697bc323746000000000000000000000758",address:"0x178e029173417b1f9c8bc16dcec6f697bc323746"},linearUsdt2:{id:"0xff4ce5aaab5a627bf82f4a571ab1ce94aa365ea600000000000000000000075a",address:"0xff4ce5aaab5a627bf82f4a571ab1ce94aa365ea6"},maiusd:{id:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012",address:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42",gauge:"0x72843281394e68de5d55bcf7072bb9b2ebc24150",assetOrder:["USDC","DAI","miMATIC","USDT"]},maibbausd:{id:"0xb54b2125b711cd183edd3dd09433439d5396165200000000000000000000075e",address:"0xb54b2125b711cd183edd3dd09433439d53961652",gauge:"0x9a105ef22a59484aa2731c357049f6a13d0891f5",assetOrder:["bb-a-USD","miMATIC"]},USDT:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",DAI:"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",USDC:"0x2791bca1f2de4661ed88a30c99a7a9449aa84174",waDAI:"0xEE029120c72b0607344f35B17cdD90025e647B00",waUSDC:"0x221836a597948Dce8F3568E044fF123108aCc42A",waUSDT:"0x19C60a251e525fa88Cd6f3768416a8024e98fC19",miMATIC:"0xa3fa99a148fa48d14ed51d610c367c61876997f1"}},As=new t.Interface(gs),Ss=cs.toChainedReference("21"),Ps=cs.toChainedReference("22"),Bs=cs.toChainedReference("23"),_s=cs.toChainedReference("24");class Os{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];r&&(d=[this.buildSetRelayerApproval(r)]),d=i?[...d,this.buildWithdraw(t,a),this.buildExit(o,a),this.buildSwap(s,o),this.buildDeposit(t)]:[...d,this.buildExit(t,a),this.buildSwap(s,t)];return{to:o,data:As.encodeFunctionData("multicall",[d])}}buildExit(e,t){const{assetOrder:a}=this.addresses.staBal3,n=a.map((e=>this.addresses[e])),s=S.exitExactBPTInForTokensOut(t),i=[{index:a.indexOf("DAI"),key:Ss},{index:a.indexOf("USDC"),key:Ps},{index:a.indexOf("USDT"),key:Bs}];return cs.constructExitCall({assets:n,minAmountsOut:["0","0","0"],userData:s,toInternalBalance:!0,poolId:this.addresses.staBal3.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s){const i=[this.addresses.bbausd2.address,this.addresses.DAI,this.addresses.linearDai2.address,this.addresses.USDC,this.addresses.linearUsdc2.address,this.addresses.USDT,this.addresses.linearUsdt2.address],r=[{index:0,key:_s}],o=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Ss.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:2,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:3,assetOutIndex:4,amount:Ps.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:4,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:5,assetOutIndex:6,amount:Bs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"}],d=[n.BigNumber.from(t).mul(-1).toString(),a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0"],c={sender:this.addresses.relayer,recipient:s,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:o,assets:i,funds:c,limits:d,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.staBal3.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,_s.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const vs=new t.Interface(gs),ks=cs.toChainedReference("24");class Ns{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r,o){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const d=this.addresses.relayer;let c=[];o&&(c=[this.buildSetRelayerApproval(o)]),c=i?[...c,this.buildWithdraw(t,a),this.buildSwap(a,s,d,d,r),this.buildDeposit(t)]:[...c,this.buildSwap(a,s,t,t,r)];const l=vs.encodeFunctionData("multicall",[c]);return{to:this.addresses.relayer,data:l}}buildSwap(t,s,i,r,o){const d=[this.addresses.bbausd2.address,this.addresses.waDAI,this.addresses.linearDai1.address,this.addresses.linearDai2.address,this.addresses.waUSDC,this.addresses.linearUsdc1.address,this.addresses.linearUsdc2.address,this.addresses.waUSDT,this.addresses.linearUsdt1.address,this.addresses.linearUsdt2.address,this.addresses.bbausd1.address],c=[{index:0,key:ks}],l=o.reduce(((e,t)=>e.add(n.BigNumber.from(t))),a.Zero),{assetOrder:p}=this.addresses.bbausd1,u=n.BigNumber.from(t).mul(o[p.indexOf("bb-a-USDC")]).div(l).toString(),b=n.BigNumber.from(t).mul(o[p.indexOf("bb-a-DAI")]).div(l).toString(),y=n.BigNumber.from(t).sub(u).sub(b).toString(),m=[{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:2,amount:b,userData:"0x"},{poolId:this.addresses.linearDai1.id,assetInIndex:2,assetOutIndex:1,amount:"0",userData:"0x"},{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:3,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:3,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:5,amount:u,userData:"0x"},{poolId:this.addresses.linearUsdc1.id,assetInIndex:5,assetOutIndex:4,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:4,assetOutIndex:6,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:8,amount:y,userData:"0x"},{poolId:this.addresses.linearUsdt1.id,assetInIndex:8,assetOutIndex:7,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:7,assetOutIndex:9,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:9,assetOutIndex:0,amount:"0",userData:"0x"}],f=[n.BigNumber.from(s).mul(-1).toString(),"0","0","0","0","0","0","0","0","0",t],h={sender:i,recipient:r,fromInternalBalance:!1,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:m,assets:d,funds:h,limits:f,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:c})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.bbausd1.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,ks.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Cs=new t.Interface(gs),Ds=cs.toChainedReference("0"),Fs=[];class Rs{constructor(e){this.addresses=xs[e]}calldata(e,t,a,n,s,i,r,o){if(i&&(null==t.gauge||null==a.gauge))throw new Error("Staked flow migration requires gauge addresses to be provided");const d=this.addresses.relayer;let c=[];o&&(c=[this.buildSetRelayerApproval(o)]),c=i?[...c,this.buildWithdraw(e,n,t.gauge),this.buildExit(t.id,d,n,r),this.buildSwap(s,d,a.id,a.address,r),this.buildDeposit(e,a.gauge)]:[...c,this.buildExit(t.id,e,n,r),this.buildSwap(s,e,a.id,a.address,r)];const l=Cs.encodeFunctionData("multicall",[c]);return{to:this.addresses.relayer,data:l}}buildExit(e,t,a,n){const s=S.exitExactBPTInForTokensOut(a),i=[];for(let e=0;e<n.length;e++)i[e]={index:e,key:cs.toChainedReference(`${e+1}`)},Fs.push(i[e].key);const r=Array(n.length).fill("0");return cs.constructExitCall({assets:n,minAmountsOut:r,userData:s,toInternalBalance:!0,poolId:e,poolKind:0,sender:t,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s,i,r,o){const d=[r,...o],c=[{index:0,key:Ds}],l=[];for(let e=0;e<o.length;e++)l.push({poolId:i,assetInIndex:e+1,assetOutIndex:0,amount:Fs[e].toString(),userData:"0x"});const p=[n.BigNumber.from(t).mul(-1).toString()];for(let e=0;e<o.length;e++)p.push(a.MaxInt256.toString());const u={sender:this.addresses.relayer,recipient:s,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:l,assets:d,funds:u,limits:p,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:c})}buildWithdraw(e,t,a){return cs.encodeGaugeWithdraw(a,e,this.addresses.relayer,t)}buildDeposit(e,t){return cs.encodeGaugeDeposit(t,this.addresses.relayer,e,Ds.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Ms=new t.Interface(gs),Ls=cs.toChainedReference("20"),Us=cs.toChainedReference("21"),Gs=cs.toChainedReference("22"),qs=cs.toChainedReference("23"),Ws=cs.toChainedReference("24");class $s{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];r&&(d=[this.buildSetRelayerApproval(r)]),d=i?[...d,this.buildWithdraw(t,a),this.buildExit(o,a),this.buildSwap(o,s),this.buildDeposit(t)]:[...d,this.buildExit(t,a),this.buildSwap(t,s)];return{to:o,data:Ms.encodeFunctionData("multicall",[d])}}buildExit(e,t){const{assetOrder:a}=this.addresses.maiusd,n=a.map((e=>this.addresses[e])),s=S.exitExactBPTInForTokensOut(t),i=[{index:a.indexOf("miMATIC"),key:Ls},{index:a.indexOf("DAI"),key:Us},{index:a.indexOf("USDC"),key:Gs},{index:a.indexOf("USDT"),key:qs}],r=Array(n.length).fill("0");return cs.constructExitCall({assets:n,minAmountsOut:r,userData:s,toInternalBalance:!0,poolId:this.addresses.maiusd.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s){const i=[this.addresses.bbausd2.address,this.addresses.DAI,this.addresses.linearDai2.address,this.addresses.USDC,this.addresses.linearUsdc2.address,this.addresses.USDT,this.addresses.linearUsdt2.address,this.addresses.miMATIC,this.addresses.maibbausd.address],r=[{index:8,key:Ws}],o=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Us.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:2,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:3,assetOutIndex:4,amount:Gs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:4,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:5,assetOutIndex:6,amount:qs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:7,assetOutIndex:8,amount:Ls.toString(),userData:"0x"}],d=["0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),n.BigNumber.from(s).mul(-1).toString()],c={sender:this.addresses.relayer,recipient:t,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:o,assets:i,funds:c,limits:d,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.maiusd.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.maibbausd.gauge,this.addresses.relayer,e,Ws.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}class Vs{constructor(e){this.network=e}stabal3(e,a,n,s,i){const r=new Os(this.network).calldata(e,a,n,s,i);return{to:r.to,data:r.data,decode:(e,a)=>{let n=a?2:1;i&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}bbaUsd(e,a,n,s,i,r){const o=new Ns(this.network).calldata(e,a,n,s,i,r);return{to:o.to,data:o.data,decode:(e,a)=>{let n=a?1:0;r&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}stables(e,a,n,s,i,r,o,d){const c=new Rs(this.network).calldata(e,a,n,s,i,r,o,d);return{to:c.to,data:c.data,decode:(e,a)=>{let n=a?2:1;d&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}maiusd(e,a,n,s,i){const r=new $s(this.network).calldata(e,a,n,s,i);return{to:r.to,data:r.data,decode:(e,a)=>{let n=a?2:1;i&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][8].abs().toString()}}}}class Hs{constructor(e){this.network=e,this.migrations=new Vs(e)}}class js{constructor(e,t){this.tokenPrices=e,this.tokenHistoricalPrices=t}async calcImpLoss(t,a){if(1e3*t>=Date.now())throw console.error(`[ImpermanentLossService][calcImpLoss]Error: ${st.getMessage(e.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE)}`),new st(e.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE);const n=await this.prepareData(t,a),s=this.getPoolValueDelta(n),i=this.getHoldValueDelta(n);return this.calculateImpermanentLoss(s,i)}calculateImpermanentLoss(e,t){return Math.floor(100*Math.abs(e/t-1)*100)/100}getPoolValueDelta(e){return e.reduce(((e,t)=>e*Math.pow(Math.abs(t.priceDelta+1),t.weight)),1)}getHoldValueDelta(e){return e.reduce(((e,t)=>e+Math.abs(t.priceDelta+1)*t.weight),0)}async prepareData(e,t){const a=t.tokens.filter((e=>e.address!==t.address)),n=this.getWeights(a),s=a.map((e=>e.address)),i=await this.getEntryPrices(e,s),r=await this.getExitPrices(a);return this.getAssets(a,r,i,n)}getAssets(e,t,a,n){return e.map(((e,s)=>({priceDelta:this.getDelta(a[e.address],t[e.address]),weight:n[s]})))}getDelta(t,a){if(0===t)throw console.error(`[ImpermanentLossService][getDelta]Error: ${st.getMessage(e.BalancerErrorCode.ILLEGAL_PARAMETER)}: entry price is 0`),new st(e.BalancerErrorCode.ILLEGAL_PARAMETER);return(a-t)/t}getWeights(t){const a=t.every((e=>!e.weight)),n=Math.round(1/t.length*100)/100,s=a?t.map((()=>n)):t.map((e=>{var t;return Number(null!==(t=e.weight)&&void 0!==t?t:0)}));if(s.some((e=>0===e)))throw console.error(`[ImpermanentLossService][getWeights]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_WEIGHT)}`),new st(e.BalancerErrorCode.MISSING_WEIGHT);return s}async getExitPrices(t){var a;const n=await Promise.all(t.map((e=>this.tokenPrices.find(e.address)))).catch((()=>[]));if(!n.length||n.some((e=>void 0===(null==e?void 0:e.usd))))throw console.error(`[ImpermanentLossService][getExitPrices]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_PRICE_RATE)}`),new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const s=t.map(((e,t)=>({...e,price:n[t]}))),i={};for(const e of s)(null===(a=e.price)||void 0===a?void 0:a.usd)&&(i[e.address]=+e.price.usd);return i}async getEntryPrices(t,a){const n={};for(const s of a){const a=await this.tokenHistoricalPrices.findBy(s,t).catch((e=>{console.error(`[ImpermanentLossService][getEntryPrices]Error: ${e.message}`)}));if(!(null==a?void 0:a.usd))throw console.error(`[ImpermanentLossService][getEntryPrices]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_PRICE_RATE)}`),new st(e.BalancerErrorCode.MISSING_PRICE_RATE);n[s]=+a.usd}return n}}const Ks=335e3,Zs=1765411200,Xs=(e=Math.round((new Date).getTime()/1e3))=>Ks;var Js=Object.freeze({__proto__:null,INITIAL_RATE:Ks,START_EPOCH_TIME:Zs,weekly:Xs,total:e=>365*(Xs()/7),between:(e,t)=>{if(e<Zs)throw"start timestamp before emission schedule deployment";if(t<e)throw"cannot finish before starting";const a=t-e,n=Xs()/7;return Math.round(a/86400)*n}});class Ys{constructor(e,t){this.repository=e,this.tokenPrices=t}async data(e=Date.now()){const t=await this.repository.multicallData(e),a=await this.tokenPrices.find(t.balAddress);if(!a||!a.usd)throw"No BAL USD price found";return{lastWeekBalRevenue:t.balAmount*parseFloat(a.usd),lastWeekBBAUsdRevenue:t.bbAUsdAmount*t.bbAUsdPrice,veBalSupply:t.veBalSupply}}}class zs{constructor(e){this.yesterdaysPools=e}async last24h(e){let t;return this.yesterdaysPools&&(t=await this.yesterdaysPools.find(e.id)),e.totalSwapFee?(null==t?void 0:t.totalSwapFee)?parseFloat(e.totalSwapFee)-parseFloat(t.totalSwapFee):e.createTime&&bs(e.createTime)?parseFloat(e.totalSwapFee):0:0}}class Qs{constructor(e,t,a,n,s,i,r,o){this.pools=e,this.tokenPrices=t,this.tokenMeta=a,this.tokenYields=n,this.feeCollector=s,this.yesterdaysPools=i,this.liquidityGauges=r,this.feeDistributor=o}async swapFees(e){const t=await this.last24hFees(e),a=await this.totalLiquidity(e);if(!t||!a)return 0;const n=t*(1-await this.protocolSwapFeePercentage(e))/parseFloat(a)*1e4;return Math.round(365*n)}async tokenAprs(e){return{total:0,breakdown:{}}}async stakingApr(e,t=1){if(!this.liquidityGauges)return 0;const a=await this.liquidityGauges.findBy("poolId",e.id);if(!a||(248==e.chainId||9372==e.chainId||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=tt[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,i]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const r=parseFloat(s.usd),o=Xs()/7*365*a.relativeWeight*r,d=(a.workingSupply+.4)/.4*i;return Math.round(1e4*t*o/d)}async stakingAprNextPeriod(e,t=1){if(!this.liquidityGauges)return 0;const a=await this.liquidityGauges.findBy("poolId",e.id);if(!a)return 0;if(0==a.workingSupply)return a.relativeWeightNextPeriod&&a.relativeWeightNextPeriod>0?-1:0;const n=tt[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,i]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const r=parseFloat(s.usd),o=Xs()/7*365*(a.relativeWeightNextPeriod||0)*r,d=(a.workingSupply+.4)/.4*i;return Math.round(1e4*t*o/d)}async rewardAprs(e){if(!this.liquidityGauges)return{total:0,breakdown:{}};const t=await this.liquidityGauges.findBy("poolId",e.id);if(!t)return{total:0,breakdown:{}};if(!t.rewardTokens)return{total:0,breakdown:{}};if(Object.keys(t.rewardTokens).length<1)return{total:0,breakdown:{}};const a=tt[e.chainId].addresses.tokens.bal,n=Object.keys(t.rewardTokens).filter((e=>e!=a)).map((async e=>{const a=t.rewardTokens[e];return this.rewardTokenApr(e,a)})),s=await this.bptPrice(e),i=t.totalSupply*s,r={};let o=0;for await(const e of Object.values(n)){const t=i>0?e.value/i:0,a=Math.round(1e4*t);o+=a,r[e.address]=a}return{total:o,breakdown:r}}async protocolApr(e){if(""!=e.id||!this.feeDistributor)return 0;const t=new Ys(this.feeDistributor,this.tokenPrices),{lastWeekBalRevenue:a,lastWeekBBAUsdRevenue:n,veBalSupply:s}=await t.data(),i=await this.bptPrice(e);if(!i)throw"bptPrice for veBal pool missing";const r=(a+n)/7;return Math.round(365*r*1e4/(i*s))}async apr(e){const[t,a,n,s,i,r]=await Promise.all([this.swapFees(e),this.tokenAprs(e),this.stakingApr(e),this.stakingApr(e,2.5),this.rewardAprs(e),this.protocolApr(e)]);return{swapFees:t,tokenAprs:a,stakingApr:{min:n,max:s},rewardAprs:i,protocolApr:r,min:t+a.total+i.total+n,max:t+a.total+i.total+r+s}}async aprNextPeriod(e){const[t,a,n,s,i,r]=await Promise.all([this.swapFees(e),this.tokenAprs(e),this.stakingAprNextPeriod(e),this.stakingAprNextPeriod(e,2.5),this.rewardAprs(e),this.protocolApr(e)]);return{swapFees:t,tokenAprs:a,stakingApr:{min:n,max:s},rewardAprs:i,protocolApr:r,min:t+a.total+i.total+n,max:t+a.total+i.total+r+s}}async last24hFees(e){return new zs(this.yesterdaysPools).last24h(e)}async totalLiquidity(e){try{const t=new $t(this.pools,this.tokenPrices);return await t.getLiquidity(e)}catch(t){return console.error("Liquidity calculcation failed, falling back to subgraph"),e.totalLiquidity}}async bptPrice(e){const t=await this.totalLiquidity(e),a=e.totalShares;return parseFloat(t)/parseFloat(a)}async protocolSwapFeePercentage(e){let t=0;return t="ComposableStable"==e.poolType||"Weighted"==e.poolType&&2==e.poolTypeVersion?0:e.protocolSwapFeeCache?parseFloat(e.protocolSwapFeeCache):await this.feeCollector.find("")||0,t}async rewardTokenApr(e,t){if(t.period_finish.toNumber()<Date.now()/1e3)return{address:e,value:0};{const a=t.rate.mul(86400).mul(365),n=await this.tokenPrices.find(e);if(n&&n.usd){let s=18;if(t.decimals)s=t.decimals;else{const t=await this.tokenMeta.find(e);t&&void 0!==t.decimals&&(s=t.decimals)}return{address:e,value:parseFloat(Pe(a,s))*parseFloat(n.usd)}}throw`No USD price for ${e}`}}}const ei=new Map;ei.set(e.PoolType.AaveLinear,"batchSwap"),ei.set(e.PoolType.EulerLinear,"batchSwap"),ei.set(e.PoolType.ERC4626Linear,"batchSwap"),ei.set(e.PoolType.Element,"batchSwap"),ei.set(e.PoolType.Investment,"joinPool"),ei.set(e.PoolType.LiquidityBootstrapping,"joinPool"),ei.set(e.PoolType.MetaStable,"joinPool"),ei.set(e.PoolType.Stable,"joinPool"),ei.set(e.PoolType.StablePhantom,"batchSwap"),ei.set(e.PoolType.Weighted,"joinPool"),ei.set(e.PoolType.ComposableStable,"joinPool");const ti=new Map;ti.set(e.PoolType.AaveLinear,"batchSwap"),ei.set(e.PoolType.EulerLinear,"batchSwap"),ti.set(e.PoolType.ERC4626Linear,"batchSwap"),ti.set(e.PoolType.Element,"batchSwap"),ti.set(e.PoolType.Investment,"exitPool"),ti.set(e.PoolType.LiquidityBootstrapping,"exitPool"),ti.set(e.PoolType.MetaStable,"exitPool"),ti.set(e.PoolType.Stable,"exitPool"),ti.set(e.PoolType.StablePhantom,"batchSwap"),ti.set(e.PoolType.Weighted,"exitPool"),ti.set(e.PoolType.ComposableStable,"exitPool");class ai{constructor(e){this.pools=e}async buildGraphFromRootPool(t,n){const s=await this.pools.find(t);if(!s)throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST);return(await this.buildGraphFromPool(s.address,0,void 0,a.WeiPerEther,n))[0]}getTokenTotal(e){const t=e.tokensList.indexOf(e.address);let n=a.Zero;const{parsedBalances:s}=se(e);return s.forEach(((e,a)=>{t!==a&&(n=n.add(e))})),n}async buildGraphFromPool(t,a,s,i,r){var o;const d=await this.pools.findBy("address",t);if(!d){if(s){const e=await this.pools.findBy("address",s.address),n=null!==(o=e.tokens[e.tokensList.indexOf(t)].decimals)&&void 0!==o?o:18;return ai.createInputTokenNode(a,t,n,s,i)}throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST)}const c=ei.get(d.poolType),l=ti.get(d.poolType);if(!c||!l)throw new st(e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);const p=this.getTokenTotal(d),{spotPriceCalculator:u}=Wt.from(d.poolType),b={};let y=18;d.tokens.forEach((e=>{if($e(e.address,d.address))return void(y=e.decimals?e.decimals:18);const t=u.calcPoolSpotPrice(e.address,d.address,d);b[e.address]=t}));let m={address:d.address,id:d.id,type:d.poolType,joinAction:c,exitAction:l,children:[],marked:!1,index:a.toString(),parent:s,proportionOfParent:i,isLeaf:!1,spotPrices:b,decimals:y};if(a++,d.poolType.toString().includes("Linear"))[m,a]=this.createLinearNodeChildren(m,a,d,r);else{const{parsedBalances:e}=se(d);for(let t=0;t<d.tokens.length;t++){if($e(d.tokens[t].address,d.address))continue;let s;if("Weighted"===d.poolType){const e=d.tokens[t].weight;s=n.parseFixed(e,18)}else s=n.BigNumber.from(e[t]).mul(1e18.toString()).div(p);const o=s.mul(i).div(1e18.toString()),c=await this.buildGraphFromPool(d.tokens[t].address,a,m,o,r);a=c[1],c[0]&&m.children.push(c[0])}}return[m,a]}createLinearNodeChildren(e,t,a,n){var s;if(n){const n=this.createWrappedTokenNode(a,t,e,e.proportionOfParent);return e.children.push(n[0]),[e,n[1]]}{if(void 0===a.mainIndex)throw new Error("Issue With Linear Pool");const n=null!==(s=a.tokens[a.mainIndex].decimals)&&void 0!==s?s:18,i=ai.createInputTokenNode(t,a.tokensList[a.mainIndex],n,e,e.proportionOfParent);return e.children.push(i[0]),[e,t=i[1]]}}createWrappedTokenNode(t,a,n,s){var i;if(void 0===t.wrappedIndex||void 0===t.mainIndex)throw new Error("Issue With Linear Pool");let r="wrapAaveDynamicToken";if(t.poolType===e.PoolType.ERC4626Linear)r="wrapERC4626";let o="unwrapAaveStaticToken";if(t.poolType===e.PoolType.ERC4626Linear)o="unwrapERC4626";const d={type:"WrappedToken",address:t.tokensList[t.wrappedIndex],id:"N/A",children:[],marked:!1,joinAction:r,exitAction:o,index:a.toString(),parent:n,proportionOfParent:s,isLeaf:!1,spotPrices:{},decimals:18};a++;const c=null!==(i=t.tokens[t.mainIndex].decimals)&&void 0!==i?i:18,l=ai.createInputTokenNode(a,t.tokensList[t.mainIndex],c,d,s);return d.children=[l[0]],[d,a=l[1]]}static createInputTokenNode(e,t,a,n,s){return[{address:t,id:"N/A",type:"Input",children:[],marked:!1,joinAction:"input",exitAction:"output",index:e.toString(),parent:n,proportionOfParent:s,isLeaf:!0,spotPrices:{},decimals:a},e+1]}static orderByBfs(e){const t=[],a=[];for(e.marked=!0,t.push(e);t.length>0;){const e=t.shift();e&&a.push(e),null==e||e.children.forEach((e=>{e.marked||(e.marked=!0,t.push(e))}))}return a}static getLeafAddresses(e){return e.filter((e=>e.isLeaf)).map((e=>e.address))}}ai.getGraphNodes=async(t,a,n,s)=>{if(!await n.find(a))throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST);const i=new ai(n),r=await i.buildGraphFromRootPool(a,s);if(r.id!==a)throw new Error("Error creating graph nodes");return t?ai.orderByBfs(r).reverse():ai.orderByBfs(r)};class ni{constructor(e,t){this.chainId=e,this.simulateMulticall=async(e,t,a,n)=>{const s={...await this.encodeBalanceAndAllowanceOverrides(a,n),...await this.encodeRelayerApprovalOverride(a,e)};return this.simulateTransaction(e,t,a,s)},this.simulateTransaction=async(e,t,a,n)=>{const s=Object.fromEntries(Object.keys(n).map((e=>[e,{storage:n[e].value}]))),i={network_id:this.chainId.toString(),block_number:this.blockNumber,from:a,to:e,input:t,save_if_fails:!0,simulation_type:"quick",state_objects:s},r=this.tenderlyUrl+"simulate";return(await x.default.post(r,i,this.opts)).data.transaction.transaction_info.call_trace.output},this.encodeRelayerApprovalOverride=async(e,t)=>{const a={[`${this.vaultAddress}`]:{value:{[`_approvedRelayers[${e}][${t}]`]:(!0).toString()}}};return await this.requestStateOverrides(a)},this.encodeBalanceAndAllowanceOverrides=async(e,t)=>{if(0===t.length)return{};let n={};t.forEach((t=>n={...n,[`${t}`]:{value:{[`_balances[${e}]`]:a.MaxInt256.toString(),[`_allowances[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString(),[`balanceOf[${e}]`]:a.MaxInt256.toString(),[`allowance[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString(),[`balances[${e}]`]:a.MaxInt256.toString(),[`allowed[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString()}}}));const s=await this.requestStateOverrides(n);if(Object.keys(s).some((e=>2!==Object.keys(s[e].value).length)))throw new Error("Couldn't encode state overrides - states should match the ones in the contracts");return s},this.requestStateOverrides=async e=>{const t=this.tenderlyUrl+"contracts/encode-states",a={networkID:this.chainId.toString(),stateOverrides:e},n=(await x.default.post(t,a,this.opts)).data.stateOverrides;if(!n||Object.keys(n).length!==Object.keys(e).length)throw new Error("Couldn't encode state overrides - contracts should be verified and whitelisted on Tenderly");return n};const{contracts:n}=at(this.chainId);this.vaultAddress=n.vault,(null==t?void 0:t.user)&&(null==t?void 0:t.project)?this.tenderlyUrl=`https://api.tenderly.co/api/v1/account/${t.user}/project/${t.project}/`:this.tenderlyUrl="https://api.balancer.fi/tenderly/",(null==t?void 0:t.accessKey)&&(this.opts={headers:{"X-Access-Key":t.accessKey}}),this.blockNumber=null==t?void 0:t.blockNumber}}var si;const ii=new t.Interface(Ts);class ri{constructor(s,i){this.pools=s,this.createCalls=async(e,t,a,n)=>{const{calls:s,outputIndexes:i,deltas:r}=this.createActionCalls(e,t,a);n&&s.unshift(this.createSetRelayerApproval(n));return{callData:ii.encodeFunctionData("multicall",[s]),outputIndexes:n?i.map((e=>e+1)):i,deltas:r}},this.amountsOutByJoinPath=async(e,a,s,i)=>{const r=[],o=await this.tenderlyHelper.simulateMulticall(this.relayer,a,e,s),d=t.defaultAbiCoder.decode(["bytes[]"],o)[0];let c=n.BigNumber.from("0");return i.forEach((e=>{const a=t.defaultAbiCoder.decode(["uint256"],d[e]);r.push(a.toString()),c=c.add(a.toString())})),{amountsOut:r,totalAmountOut:c.toString()}},this.minAmountsOutByJoinPath=(e,t,a)=>({minAmountsOut:t.map((t=>ze(n.BigNumber.from(t),n.BigNumber.from(e)).toString())),totalMinAmountOut:ze(n.BigNumber.from(a),n.BigNumber.from(e)).toString()}),this.createActionCalls=(e,t,a)=>{const n=[],s=[],i=!a,r={};return e.forEach(((e,o)=>{const d=e[0].isLeaf;if(e.forEach(((s,i)=>{let c;if(c=d?e.filter((e=>{var t;return s.children.map((e=>e.address)).includes(e.address)&&s.index===(null===(t=e.parent)||void 0===t?void 0:t.index)})):i>0?[e[i-1]]:[],c.length>0&&0===c.filter((e=>"0"!==e.index)).length)return void(s.index="0");c.some((e=>"input"===e.joinAction||"wrapAaveDynamicToken"===e.joinAction));const l=t,p=i===e.length-1,u=t,b=p&&a?a[o]:"0";switch(s.joinAction){case"wrapAaveDynamicToken":n.push(this.createAaveWrap(s,c,o,l,t));break;case"batchSwap":{const[e,t,a]=this.createBatchSwap(s,c,o,b,l,u);n.push(e),this.updateDeltas(r,t,a);break}case"joinPool":{const[e,t,a,i]=this.createJoinPool(s,c,o,b,l,u);n.push(e),this.updateDeltas(r,[s.address,...t],[i,...a]);break}}})),i){const e=100*o,t=cs.encodePeekChainedReferenceValue(cs.toChainedReference(e,!1));n.push(t),s.push(n.indexOf(t))}})),{calls:n,outputIndexes:s,deltas:r}},this.createSetRelayerApproval=e=>cs.encodeSetRelayerApproval(this.relayer,!0,e),this.createAaveWrap=(e,t,a,n,s)=>{if(1!==t.length)throw new Error("aaveWrap nodes should always have a single child node");const i=t[0],r=e.address,o=i.index;return cs.encodeWrapAaveDynamicToken({staticToken:r,sender:n,recipient:s,amount:o,fromUnderlying:!0,outputReference:this.getOutputRefValue(a,e).value})},this.createBatchSwap=(t,s,i,r,o,d)=>{if(1!==s.length)throw new Error("Unsupported batchswap");const c=s[0].address,l=this.getOutputRefValue(i,s[0]),p=[t.address,c],u=[n.BigNumber.from(r).mul(-1).toString(),l.isRef?a.MaxInt256.toString():l.value],b=[{poolId:t.id,assetInIndex:1,assetOutIndex:0,amount:l.value,userData:"0x"}],y={sender:o,recipient:d,fromInternalBalance:o===this.relayer,toInternalBalance:d===this.relayer},m=[{index:p.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase()),key:n.BigNumber.from(this.getOutputRefValue(i,t).value)}],f=cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:b,assets:p,funds:y,limits:u,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:m}),h=o===this.relayer?"0":u[1];return[f,p,[d===this.relayer?"0":u[0],h]]},this.createJoinPool=(t,n,s,i,r,o)=>{const d=[],c=[];t.children.forEach((e=>{d.push(e.address);const t=n.find((t=>$e(t.address,e.address)));t?c.push(this.getOutputRefValue(s,t).value):c.push("0")})),t.type===e.PoolType.ComposableStable&&(d.push(t.address),c.push("0"));const l=new W(this.wrappedNativeAsset),[p,u]=l.sortTokens(d,c);let b=[];const y=p.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase());let m;b=-1===y?u:[...u.slice(0,y),...u.slice(y+1)],m=t.type===e.PoolType.Weighted?P.joinExactTokensInForBPTOut(b,i):S.joinExactTokensInForBPTOut(b,i);const f=p.indexOf(a.AddressZero),h=-1===f?"0":u[f],T=cs.constructJoinCall({poolId:t.id,kind:0,sender:r,recipient:o,value:h,outputReference:this.getOutputRefValue(s,t).value,joinPoolRequest:{},assets:p,maxAmountsIn:u,userData:m,fromInternalBalance:r===this.relayer}),g=u.map((e=>cs.isChainedReference(e)?"0":e)),I=cs.isChainedReference(i)?"0":i;return[T,r===this.relayer?[]:p,r===this.relayer?[]:g,o===this.relayer?a.Zero.toString():a.Zero.sub(I).toString()]},this.getOutputRefValue=(e,t)=>"input"===t.joinAction?{value:t.index,isRef:!1}:"0"===t.index&&t.parent?{value:"0",isRef:!0}:{value:cs.toChainedReference(n.BigNumber.from(t.index).add(100*e)).toString(),isRef:!0};const{tokens:r,contracts:o}=at(i.chainId);this.relayer=o.relayerV4,this.wrappedNativeAsset=r.wrappedNativeAsset,this.tenderlyHelper=new ni(i.chainId,i.tenderly)}async joinPool(t,a,n,s,i,r,o){if(a.length!=n.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const d=await ai.getGraphNodes(!0,t,this.pools,i),c=ri.getJoinPaths(d,a,n),l=ri.totalBptZeroPriceImpact(c),{callData:p,outputIndexes:u}=await this.createCalls(c,s,void 0,o),{amountsOut:b,totalAmountOut:y}=await this.amountsOutByJoinPath(s,p,a,u),{minAmountsOut:m,totalMinAmountOut:f}=this.minAmountsOutByJoinPath(r,b,y),h=ct(BigInt(y),l.toBigInt(),!0).toString(),{callData:T,deltas:g}=await this.createCalls(c,s,m,o);return this.assertDeltas(t,g,a,n,f),{to:this.relayer,callData:T,expectedOut:y,minOut:f,priceImpact:h}}assertDeltas(t,a,s,i,r){var o;const d=D(t);if(a[d.toLowerCase()].add(r).abs().gt(3))throw console.error("join assertDeltas, bptOut: ",d,r,null===(o=a[d.toLowerCase()])||void 0===o?void 0:o.toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete a[d.toLowerCase()],s.forEach(((t,s)=>{var r,o;if(!n.BigNumber.from(i[s]).eq(0)&&(null===(r=a[t.toLowerCase()])||void 0===r?void 0:r.toString())!==i[s])throw console.error("join assertDeltas, tokenIn: ",t,i[s],null===(o=a[t.toLowerCase()])||void 0===o?void 0:o.toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete a[t.toLowerCase()]}));for(const t in a)if("0"!==a[t].toString())throw console.error("join assertDeltas, non-input token should be 0: ",t,a[t].toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS)}updateDeltas(e,t,n){return t.forEach(((t,s)=>{const i=t.toLowerCase();e[i]||(e[i]=a.Zero),e[i]=e[i].add(n[s])})),e}}si=ri,ri.getJoinPaths=(e,t,s)=>{const i=[],r=e.filter((e=>t.filter(((e,t)=>n.BigNumber.from(s[t]).gt(0))).map((e=>e.toLowerCase())).includes(e.address.toLowerCase())));r.some((e=>e.isLeaf))&&i.push(e);const o=r.filter((e=>!e.isLeaf));return o.forEach((e=>{const r=s.find(((a,n)=>$e(t[n],e.address))),d=o.filter((t=>$e(t.address,e.address))).reduce(((e,t)=>e.add(t.proportionOfParent)),n.BigNumber.from(0)),l=n.BigNumber.from(r).mul(e.proportionOfParent).div(d).toString(),[p]=ai.createInputTokenNode(0,e.address,e.decimals,e.parent,a.WeiPerEther);p.index=l,p.isLeaf=!1;const u=[p];let b=e.parent;for(;b;)u.push(c.cloneDeep(b)),b=b.parent;i.push(u)})),si.updateInputAmounts(i,t,s),i},ri.updateInputAmounts=(e,t,a)=>{const s=(e,t)=>{if(e.length>1){const a=e.reduce(((e,t)=>e.add(t.index)),n.BigNumber.from(0)),s=n.BigNumber.from(t).sub(a);e[0].index=s.add(e[0].index).toString()}},i=e.find((e=>e[0].isLeaf));if(i){const e=si.updateTotalProportions(i);i.forEach((n=>{"input"===n.joinAction&&(n=si.updateNodeAmount(n,t,a,e))})),t.forEach(((e,t)=>{const n=i.filter((t=>t.isLeaf&&$e(t.address,e)));s(n,a[t])}))}const r=e.filter((e=>!e[0].isLeaf));r.length>1&&t.forEach(((e,t)=>{const n=r.map((e=>e[0])).filter((t=>$e(t.address,e)));s(n,a[t])}))},ri.totalBptZeroPriceImpact=e=>{let t=n.BigNumber.from("0");return e.forEach((e=>{if(e[0].isLeaf){e.filter((e=>e.isLeaf)).forEach((e=>{const a=si.bptOutZeroPiForInputNode(e);t=t.add(a)}))}else{const a=si.bptOutZeroPiForInputNode(e[0]);t=t.add(a)}})),t},ri.bptOutZeroPiForInputNode=e=>{if("0"===e.index||"input"!==e.joinAction)return BigInt(0);let t=1,a=e.parent,s=e.address;for(;void 0!==a;){if("batchSwap"===a.joinAction||"joinPool"===a.joinAction){const e=a.spotPrices[s.toLowerCase()];t*=parseFloat(e),s=a.address}a=a.parent}const i=n.parseFixed(t.toFixed(18),18),r=Q(BigInt(e.decimals)),o=ee(BigInt(e.index),r);return ae.divDownFixed(o,i.toBigInt())},ri.updateTotalProportions=e=>{const t={};return e.forEach((e=>{t[e.address]?t[e.address]=t[e.address].add(e.proportionOfParent):t[e.address]=e.proportionOfParent})),t},ri.updateNodeAmount=(e,t,a,n)=>{const s=t.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase());if(-1===s)return e.index="0",e;const i=n[e.address],r=e.proportionOfParent.mul(1e18.toString()).div(i).mul(a[s]).div(1e18.toString());return e.index=r.toString(),e};const oi=new t.Interface(Ts);class di{constructor(e,s){this.pools=e,this.amountsOutByExitPath=async(e,a,s,i,r)=>{const o=await this.tenderlyHelper.simulateMulticall(this.relayer,a,e,[s]),d=t.defaultAbiCoder.decode(["bytes[]"],o)[0],c=i.map((e=>t.defaultAbiCoder.decode(["uint256"],d[e]).toString())),l=c.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(r)).toString()));return{expectedAmountsOutByExitPath:c,minAmountsOutByExitPath:l}},this.amountsOutByTokenOut=(e,t,s,i)=>{const r={};t.forEach(((e,t)=>{var n;return r[e]=(null!==(n=r[e])&&void 0!==n?n:a.Zero).add(s[t])}));const o=e.map((e=>r[e].toString())),d=o.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(i)).toString()));return{expectedAmountsOut:o,minAmountsOut:d}},this.getExitPaths=(e,t)=>{const s=e.map((e=>{const n=[e];for(;n[0].parent;)n.unshift(c.cloneDeep(n[0].parent));return n[0].index=n[n.length-1].proportionOfParent.mul(t).div(a.WeiPerEther).toString(),n})),i=s.reduce(((e,t)=>{const a=t[0].index;return n.BigNumber.from(a).add(e)}),a.Zero),r=n.BigNumber.from(t).sub(i);return s[s.length-1][0].index=r.add(s[s.length-1][0].index).toString(),s},this.getOutputRef=(e,t)=>100*e+parseInt(t);const{tokens:i,contracts:r}=at(s.chainId);this.wrappedNativeAsset=i.wrappedNativeAsset,this.relayer=r.relayerV4,this.tenderlyHelper=new ni(s.chainId,s.tenderly)}async exitPool(e,t,a,n,s){const i=await ai.getGraphNodes(!1,e,this.pools,!1),r=i.filter((e=>"output"===e.exitAction)),o=this.getExitPaths(r,t),d=r.map((e=>e.address.toLowerCase())),c=[...new Set(d)].sort(),l=await this.createCalls(o,a,void 0,s),{expectedAmountsOutByExitPath:p,minAmountsOutByExitPath:u}=await this.amountsOutByExitPath(a,l.callData,i[0].address,l.outputIndexes,n),{callData:b,deltas:y}=await this.createCalls(o,a,u,s),{expectedAmountsOut:m,minAmountsOut:f}=this.amountsOutByTokenOut(c,d,p,n);this.assertDeltas(e,y,t,c,f);const h=await this.calculatePriceImpact(e,c,m,t);return{to:this.relayer,callData:b,tokensOut:c,expectedAmountsOut:m,minAmountsOut:f,priceImpact:h}}async calculatePriceImpact(e,t,a,n){const s=await ai.getGraphNodes(!0,e,this.pools,!1),i=ri.getJoinPaths(s,t,a),r=ri.totalBptZeroPriceImpact(i);return ct(BigInt(n),r.toBigInt(),!1).toString()}assertDeltas(t,a,n,s,i){var r;const o=D(t);if(a[o.toLowerCase()].sub(n).abs().gt(3))throw console.error("exit assertDeltas, bptIn: ",o,n,null===(r=a[o.toLowerCase()])||void 0===r?void 0:r.toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete a[o.toLowerCase()],s.forEach(((t,n)=>{var s;if(a[t.toLowerCase()].add(i[n]).abs().gt(1))throw console.error("exit assertDeltas, tokenOut: ",t,i[n],null===(s=a[t.toLowerCase()])||void 0===s?void 0:s.toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete a[t.toLowerCase()]}));for(const t in a)if("0"!==a[t].toString())throw console.error("exit assertDeltas, non-input token should be 0: ",t,a[t].toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS)}async createCalls(e,t,a,n){const{calls:s,outputIndexes:i,deltas:r}=this.createActionCalls(c.cloneDeep(e),t,a);n&&s.unshift(cs.encodeSetRelayerApproval(this.relayer,!0,n));return{callData:oi.encodeFunctionData("multicall",[s]),outputIndexes:n?i.map((e=>e+1)):i,deltas:r}}updateDeltas(e,t,n){return t.forEach(((t,s)=>{const i=t.toLowerCase();e[i]||(e[i]=a.Zero),e[i]=e[i].add(n[s])})),e}createActionCalls(e,t,a){const n=[],s=[],i=!a,r={};return e.forEach(((e,o)=>{e.forEach((d=>{const c=!d.parent?t:this.relayer,l=d.children.find((t=>e.map((e=>e.index)).includes(t.index))),p="output"===(null==l?void 0:l.exitAction),u=p?t:this.relayer,b=p&&a?a[o]:"0";switch(d.exitAction){case"batchSwap":{const[e,t,a]=this.createBatchSwap(d,l,o,b,c,u);n.push(e),this.updateDeltas(r,t,a);break}case"exitPool":{const[e,t,a,s]=this.createExitPool(d,l,o,b,c,u);n.push(e),this.updateDeltas(r,[d.address,...a],[t,...s]);break}case"output":i&&(n.push(cs.encodePeekChainedReferenceValue(cs.toChainedReference(this.getOutputRef(o,d.index),!1))),s.push(n.length-1));break;default:return}}))})),{calls:n,outputIndexes:s,deltas:r}}createBatchSwap(t,s,i,r,o,d){const c=!t.parent?t.index:cs.toChainedReference(this.getOutputRef(i,t.index)).toString(),l=s.address,p=[l,t.address],u=[n.BigNumber.from(r).mul(-1).toString(),cs.isChainedReference(c)?a.MaxInt256.toString():c],b=[{poolId:t.id,assetInIndex:1,assetOutIndex:0,amount:c,userData:"0x"}],y={sender:o,recipient:d,fromInternalBalance:!1,toInternalBalance:!1},m=[{index:p.map((e=>e.toLowerCase())).indexOf(l.toLowerCase()),key:cs.toChainedReference(this.getOutputRef(i,s.index))}],f=cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:b,assets:p,funds:y,limits:u,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:m});let h=u[0];const T=u[1],g=o===this.relayer?"0":T;return h=d===this.relayer?"0":h,[f,p,[h,g]]}createExitPool(t,n,s,i,r,o){const d=n.address,c=!t.parent?t.index:cs.toChainedReference(this.getOutputRef(s,t.index)).toString(),l=[],p=[];t.children.forEach((e=>{l.push(e.address),p.push(e.address===d?i:"0")})),t.type===e.PoolType.ComposableStable&&(l.push(t.address),p.push("0"));const u=new W(this.wrappedNativeAsset),[b,y]=u.sortTokens(l,p);let m=[];const f=b.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase());let h;m=-1===f?b:[...b.slice(0,f),...b.slice(f+1)],h=t.type===e.PoolType.Weighted?P.exitExactBPTInForOneTokenOut(c,m.indexOf(d)):S.exitExactBPTInForOneTokenOut(c,m.indexOf(d));const T=[{index:b.map((e=>e.toLowerCase())).indexOf(d.toLowerCase()),key:cs.toChainedReference(this.getOutputRef(s,n.index))}],g=cs.constructExitCall({poolId:t.id,poolKind:0,sender:r,recipient:o,outputReferences:T,exitPoolRequest:{},assets:b,minAmountsOut:y,userData:h,toInternalBalance:!1}),I=y.map((e=>cs.isChainedReference(e)?"0":a.Zero.sub(e).toString())),E=cs.isChainedReference(c)?"0":c;return[g,r===this.relayer?a.Zero.toString():E,o===this.relayer?[]:b,o===this.relayer?[]:I]}}class ci{constructor(e){this.yesterdaysPools=e}async last24h(e){let t;return this.yesterdaysPools&&(t=await this.yesterdaysPools.find(e.id)),e.totalSwapVolume?(null==t?void 0:t.totalSwapVolume)?parseFloat(e.totalSwapVolume)-parseFloat(t.totalSwapVolume):e.createTime&&bs(e.createTime)?parseFloat(e.totalSwapVolume):0:0}}var li=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IProtocolFeePercentagesProvider",name:"protocolFeeProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[],name:"FactoryDisabled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"pool",type:"address"}],name:"PoolCreated",type:"event"},{inputs:[{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"contract IRateProvider[]",name:"rateProviders",type:"address[]"},{internalType:"uint256[]",name:"tokenRateCacheDurations",type:"uint256[]"},{internalType:"bool[]",name:"exemptFromYieldProtocolFeeFlags",type:"bool[]"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],name:"create",outputs:[{internalType:"contract ComposableStablePool",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"disable",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCreationCode",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCreationCodeContracts",outputs:[{internalType:"address",name:"contractA",type:"address"},{internalType:"address",name:"contractB",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPauseConfiguration",outputs:[{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"isDisabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"pool",type:"address"}],name:"isPoolFromFactory",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class pi{constructor(e){const{tokens:t}=at(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:a,name:n,symbol:s,tokenAddresses:i,amplificationParameter:r,rateProviders:o,tokenRateCacheDurations:d,exemptFromYieldProtocolFeeFlags:c,swapFee:l,owner:p}){const u=We(`${l}`),b=new W(this.wrappedNativeAsset),[y,m,f,h]=b.sortTokens(i,o,d,c),T=[n,s,y,r,m,f,h,u.toString(),p],g=new t.Interface(li),I=li.find((({name:e})=>"create"===e));if(!I)throw new st(e.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const E=t.FunctionFragment.from(I);return{to:a,data:g.encodeFunctionData(E,T)}}buildInitJoin({joiner:e,poolId:t,poolAddress:a,tokensIn:n,amountsIn:s}){throw new Error("To be implemented")}}class ui{constructor(e){const{tokens:t}=at(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:a,name:n,symbol:s,tokenAddresses:i,weights:r,swapFee:o,owner:d}){const c=We(`${o}`),l=new W(this.wrappedNativeAsset),[u,b]=l.sortTokens(i,r),y=[n,s,u,b,c.toString(),d],m=new t.Interface(p.WeightedPoolFactory__factory.abi),f=p.WeightedPoolFactory__factory.abi.find((({name:e})=>"create"===e));if(!f)throw new st(e.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const h=t.FunctionFragment.from(f);return{to:a,data:m.encodeFunctionData(h,y)}}buildInitJoin({joiner:e,poolId:t,tokensIn:a,amountsIn:n}){const s=new W(this.wrappedNativeAsset),[i,r]=s.sortTokens(a,n),o="joinPool",d={poolId:t,sender:e,recipient:e,joinPoolRequest:{assets:i,maxAmountsIn:r,userData:P.joinInit(r),fromInternalBalance:!1}},c=p.Vault__factory.createInterface().encodeFunctionData(o,[d.poolId,d.sender,d.recipient,d.joinPoolRequest]);return{to:et,functionName:o,attributes:d,data:c}}}class bi{constructor(e){this.networkConfig=e}of(t){switch(t){case"Weighted":return new ui(this.networkConfig);case"Investment":case"LiquidityBootstrapping":case"Stable":case"MetaStable":case"StablePhantom":case"AaveLinear":case"ERC4626Linear":default:throw new st(e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);case"ComposableStable":return new pi(this.networkConfig)}}}class yi{constructor(t){this.pool=t;const a=(t=>{switch(t){case e.PoolType.Weighted:return P;case e.PoolType.Stable:case e.PoolType.MetaStable:case e.PoolType.StablePhantom:case e.PoolType.AaveLinear:case e.PoolType.EulerLinear:case e.PoolType.ERC4626Linear:case e.PoolType.Element:case e.PoolType.Gyro2:case e.PoolType.Gyro3:return S;case e.PoolType.ComposableStable:return v}})(t.poolType);if(!a)throw"Pool type not supported";this.encoder=a}buildQueryJoinExactIn({sender:e=a.AddressZero,recipient:t=e,maxAmountsIn:n,minimumBPT:s=a.Zero,fromInternalBalance:i=!1}){const r=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e))),o=[...this.pool.tokensList];r&&r>-1&&n.splice(r,1);const d=this.encoder.joinExactTokensInForBPTOut(n,s);return[this.pool.id,e,t,{assets:o,maxAmountsIn:n,userData:d,fromInternalBalance:i}]}buildQueryJoinExactOut({sender:e=a.AddressZero,recipient:t=e,maxAmountsIn:n=[],bptOut:s,tokenIn:i,fromInternalBalance:r=!1}){const o=this.pool.tokensList.indexOf(i),d=this.encoder.joinTokenInForExactBPTOut(s,o);return[this.pool.id,e,t,{assets:this.pool.tokensList,maxAmountsIn:n,userData:d,fromInternalBalance:r}]}buildQueryExitToSingleToken({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n=[],bptIn:s,tokenOut:i,toInternalBalance:r=!1}){const o=this.pool.tokensList.indexOf(i),d=this.encoder.exitExactBPTInForOneTokenOut(s,o);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:d,toInternalBalance:r}]}buildQueryExitProportionally({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n=[],bptIn:s,toInternalBalance:i=!1}){if(!this.encoder.exitExactBPTInForTokensOut)throw"Proportional exit not implemented";const r=this.encoder.exitExactBPTInForTokensOut(s);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:r,toInternalBalance:i}]}buildQueryExitExactOut({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n,maxBptIn:s=a.MaxUint256,toInternalBalance:i=!1}){const r=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e)));r&&r>-1&&n.splice(r,1);const o=this.encoder.exitBPTInForExactTokensOut(n,s);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:o,toInternalBalance:i}]}}class mi{constructor(e){this.liquidityGaugesRepository=e}async relativeWeight(e){const t=await this.liquidityGaugesRepository.findBy("poolId",e);return t?t.relativeWeight:0}async weekly(e){return Xs()*await this.relativeWeight(e)}}const fi=(e,t,a)=>{const s=e.tokens.filter((t=>!e.id.toLowerCase().includes(t.address.toLowerCase()))),i=s.findIndex((e=>e.address.toLowerCase()===t.toLowerCase()));if(-1==i)throw new Error("Token not found in pool");const r=s.map((e=>Be(e.balance,e.decimals))),o=n.BigNumber.from(a),d=r.map((e=>e.mul(o).div(r[i])));return{tokens:s.map((e=>e.address)),amounts:d.map((e=>e.toString()))}},hi=(e,t)=>()=>{throw`${t} for poolType ${e} not implemented`};class Ti{constructor(e,t){this.networkConfig=e,this.repositories=t,this.aprService=new Qs(this.repositories.pools,this.repositories.tokenPrices,this.repositories.tokenMeta,this.repositories.tokenYields,this.repositories.feeCollector,this.repositories.yesterdaysPools,this.repositories.liquidityGauges,this.repositories.feeDistributor),this.liquidityService=new $t(t.pools,t.tokenPrices),this.joinService=new ri(this.repositories.poolsOnChain,e),this.exitService=new di(this.repositories.poolsOnChain,e),this.feesService=new zs(t.yesterdaysPools),this.volumeService=new ci(t.yesterdaysPools),this.poolFactory=new bi(e),this.impermanentLossService=new js(t.tokenPrices,t.tokenHistoricalPrices),t.liquidityGauges&&(this.emissionsService=new mi(t.liquidityGauges)),this.proportionalAmounts=fi}dataSource(){return this.repositories.pools}async apr(e){return this.aprService.apr(e)}async aprNextPeriod(e){return this.aprService.aprNextPeriod(e)}async impermanentLoss(e,t){return this.impermanentLossService.calcImpLoss(e,t)}async liquidity(e){return this.liquidityService.getLiquidity(e)}async generalisedJoin(e,t,a,n,s,i,r){return this.joinService.joinPool(e,t,a,n,s,i,r)}async generalisedExit(e,t,a,n,s){return this.exitService.exitPool(e,t,a,n,s)}async fees(e){return this.feesService.last24h(e)}async volume(e){return this.volumeService.last24h(e)}static wrap(e,t){let a,n,s;try{a=Wt.from(e.poolType),s={buildJoin:(t,n,s,r)=>a.join.buildJoin({joiner:t,pool:e,tokensIn:n,amountsIn:s,slippage:r,wrappedNativeAsset:i}),calcPriceImpact:async(t,n,s)=>a.priceImpactCalculator.calcPriceImpact(e,t,n,s),buildExitExactBPTIn:(t,n,s,r=!1,o)=>{if(a.exit.buildExitExactBPTIn)return a.exit.buildExitExactBPTIn({exiter:t,pool:e,bptIn:n,slippage:s,shouldUnwrapNativeAsset:r,wrappedNativeAsset:i,singleTokenMaxOut:o});throw"ExitExactBPTIn not supported"},buildExitExactTokensOut:(t,n,s,r)=>a.exit.buildExitExactTokensOut({exiter:t,pool:e,tokensOut:n,amountsOut:s,slippage:r,wrappedNativeAsset:i}),calcSpotPrice:(t,n)=>a.spotPriceCalculator.calcPoolSpotPrice(t,n,e),calcProportionalAmounts:(t,a)=>fi(e,t,a)}}catch(t){"UNSUPPORTED_POOL_TYPE"!=t.code&&console.error(t),s={buildJoin:hi(e.poolType,"buildJoin"),calcPriceImpact:hi(e.poolType,"calcPriceImpact"),buildExitExactBPTIn:hi(e.poolType,"buildExitExactBPTIn"),buildExitExactTokensOut:hi(e.poolType,"buildExitExactTokensOut"),calcSpotPrice:hi(e.poolType,"calcSpotPrice")}}try{n=new yi(e),s={...s,buildQueryJoinExactIn:n.buildQueryJoinExactIn.bind(n),buildQueryJoinExactOut:n.buildQueryJoinExactOut.bind(n),buildQueryExitExactOut:n.buildQueryExitExactOut.bind(n),buildQueryExitToSingleToken:n.buildQueryExitToSingleToken.bind(n),buildQueryExitProportionally:n.buildQueryExitProportionally.bind(n)}}catch(t){s={...s,buildQueryJoinExactIn:hi(e.poolType,"buildQueryJoinExactIn"),buildQueryJoinExactOut:hi(e.poolType,"buildQueryJoinExactOut"),buildQueryExitExactOut:hi(e.poolType,"buildQueryExitExactOut"),buildQueryExitToSingleToken:hi(e.poolType,"buildQueryExitToSingleToken"),buildQueryExitProportionally:hi(e.poolType,"buildQueryExitProportionally")}}const i=t.addresses.tokens.wrappedNativeAsset.toLowerCase();return{...e,...s}}async find(e){const t=await this.dataSource().find(e);if(t)return Ti.wrap(t,this.networkConfig)}async findBy(e,t){if("id"==e)return this.find(t);if("address"==e){const e=await this.dataSource().findBy("address",t);if(!e)return;return Ti.wrap(e,this.networkConfig)}throw`search by ${e} not implemented`}async all(){const e=await this.dataSource().all();return e?e.map((e=>Ti.wrap(e,this.networkConfig))).filter((e=>e)):[]}async where(e){const t=await this.dataSource().where(e);if(!t)return[];return t.map((e=>Ti.wrap(e,this.networkConfig))).filter((e=>e))}}const gi=new t.Interface(["function gauge_relative_weight(address gauge, uint timestamp) view returns (uint)","function gauge_relative_weight_write(address gauge, uint timestamp) returns (uint)"]);class Ii{constructor(e,t,a){this.gaugeControllerAddress=t,this.multicall=Dn(e,a)}async getRelativeWeights(e,t){const a=e.map((e=>[this.gaugeControllerAddress,gi.encodeFunctionData("gauge_relative_weight_write",[s.getAddress(e),t||Math.floor(Date.now()/1e3)])])),[,n]=await this.multicall.aggregate(a);return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}}class Ei{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 wi extends Ei{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=kn(e)}}class xi extends Ei{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=Nn(e)}}class Ai extends xi{async query(e){e.orderBy||(e.orderBy=cn.Balance),e.orderDirection||(e.orderDirection=yn.Desc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{gaugeShares:t}=await this.client.GaugeShares(e);return t.map(this.mapType)}mapType(e){var t;return{id:e.id,balance:e.balance,userAddress:null===(t=e.user)||void 0===t?void 0:t.id,gauge:{id:e.gauge.id,poolId:e.gauge.poolId||void 0,isKilled:e.gauge.isKilled,totalSupply:e.gauge.totalSupply}}}async findByUser(t,a,n){return this.findAllBy(e.GaugeShareAttributes.UserAddress,t,a,n)}async findByGauge(t,a,n){return this.findAllBy(e.GaugeShareAttributes.GaugeId,t,a,n)}}const Si=new t.Interface(["function totalSupply() view returns (uint)","function working_supply() view returns (uint)","function reward_count() view returns (uint)","function reward_tokens(uint rewardIndex) view returns (address)","function reward_data(address rewardToken) view returns (tuple(address token, address distributor, uint period_finish, uint rate, uint last_update, uint integral) data)"]);class Pi{constructor(e,t,a){this.chainId=t,this.multicall=Dn(e,a)}async getTotalSupplies(e){const t=e.map((e=>[e,Si.encodeFunctionData("totalSupply",[])])),[,a]=await this.multicall.aggregate(t),n=a.map((e=>"0x"==e?"0x0":e));return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}async getWorkingSupplies(e){const t=e.map((e=>[e,Si.encodeFunctionData("working_supply",[])])),[,a]=await this.multicall.aggregate(t),n=a.map((e=>"0x"==e?"0x0":e));return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}async getRewardCounts(e){let t;if(248==this.chainId||9372==this.chainId||6343==this.chainId||4326==this.chainId){const a=e.map((e=>[e,Si.encodeFunctionData("reward_count",[])])),[,n]=await this.multicall.aggregate(a),s=n.map((e=>"0x"==e?"0x0":e));t=e.reduce(((e,t,a)=>(e[t]||(e[t]=parseInt(s[a])),e)),{})}else t=e.reduce(((e,t)=>(e[t]||(e[t]=1),e)),{});return t}async getRewardTokens(e,t){const a=t||await this.getRewardCounts(e),n=e.filter((e=>a[e]>0)),s=[0],i=n.map(((e,t)=>{const n=[];for(let t=0;t<a[e];t++)n.push([e,Si.encodeFunctionData("reward_tokens",[t])]);return s[t+1]=s[t]+a[e],n})).flat(),[,r]=await this.multicall.aggregate(i);return n.reduce(((e,t,a)=>{const n=s[a],i=s[a+1],o=[];for(let e=n;e<i;e++)o.push(Si.decodeFunctionResult("reward_tokens",r[e])[0]);return e[t]||(e[t]=o),e}),{})}async getRewardData(e,t){const a=t||await this.getRewardTokens(e),n=[0],s=Object.keys(a).map(((e,t)=>{const s=[];for(let t=0;t<a[e].length;t++)s.push([e,Si.encodeFunctionData("reward_data",[a[e][t]])]);return n[t+1]=n[t]+a[e].length,s})).flat(),[,i]=await this.multicall.aggregate(s),r=i.map((e=>Si.decodeFunctionResult("reward_data",e)[0]));return Object.keys(a).reduce(((e,t,s)=>{const i=n[s],o=a[t].reduce(((e,t,a)=>(e[t]||(e[t]=r[i+a]),e)),{});return e[t]||(e[t]=o),e}),{})}}class Bi{constructor(e){this.gauges=[],this.client=Nn(e)}async fetch(){const e=(await this.client.Pools({where:{preferentialGauge_not:null},first:1e3})).pools.map((e=>e.preferentialGauge));return this.gauges=e,this.gauges}async find(e){return 0==this.gauges.length&&await this.fetch(),this.gauges.find((t=>t.id==e))}async findBy(e,t){if(0==this.gauges.length&&await this.fetch(),"id"==e)return this.find(t);if("poolId"==e)return this.gauges.find((e=>e.poolId==t));if("poolAddress"==e)return this.gauges.find((e=>e.poolAddress==t));throw`search by ${e} not implemented`}}const _i=6048e5;class Oi{constructor(e,t,a,n,s){this.chainId=n,this.workingSupplies={},this.workingSuppliesNextPeriod={},this.relativeWeights={},this.relativeWeightsNextPeriod={},this.rewardData={},a&&(this.gaugeController=new Ii(t,a,s)),this.multicall=new Pi(t,n,s),this.subgraph=new Bi(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()+_i)/_i)*_i)/1e3;this.relativeWeightsNextPeriod=await this.gaugeController.getRelativeWeights(t,e)}let a=!1;return this.rewardData=e.reduce(((e,t)=>{var s;return e[s=t.id]||(e[s]=t.tokens?Object.fromEntries(t.tokens.map((e=>[e.id.split("-")[0],{distributor:"",last_update:n.BigNumber.from(0),integral:n.BigNumber.from(0),token:e.id.split("-")[0],decimals:e.decimals,rate:Be(e.rate||"0",e.decimals),period_finish:n.BigNumber.from(e.periodFinish||"0")}]))):{}),t.tokens&&t.tokens.length>0&&(a=!0),e}),{}),a||(this.rewardData=await this.multicall.getRewardData(t)),e.map(this.compose.bind(this))}async find(e){return this.gauges||(this.gauges=this.fetch()),(await this.gauges).find((t=>t.id==e))}async findBy(e,t){let a;if(this.gauges||(this.gauges=this.fetch()),"id"==e)return this.find(t);if("address"==e)return this.find(t);if("poolId"==e)a=(await this.gauges).find((e=>e.poolId==t));else{if("poolAddress"!=e)throw`search by ${e} not implemented`;a=(await this.gauges).find((e=>e.poolAddress==t))}return a}compose(e){return{id:e.id,address:e.id,name:e.symbol,poolId:e.poolId,poolAddress:e.poolAddress,totalSupply:parseFloat(e.totalSupply),workingSupply:this.workingSupplies[e.id],relativeWeight:this.relativeWeights[e.id],relativeWeightNextPeriod:this.relativeWeightsNextPeriod[e.id],rewardTokens:this.rewardData[e.id]}}}class vi{constructor(e,t){this.url=e,this.apiKey=t}async get(e){try{const t=this.toPayload(e),{data:a}=await x.default.post(this.url,t,{headers:{"x-api-key":this.apiKey}});if(a.errors)throw new Error(a.errors.map((e=>e.message)).join(","));return a.data}catch(e){throw console.error(e),e}return[]}toPayload(e){return JSON.stringify({query:m.jsonToGraphQLQuery({query:e})})}}class ki{constructor(e){var t,a;this.skip=0,this.client=kn(e.url),this.blockHeight=e.blockHeight,this.chainId=e.chainId;const n={orderBy:xa.TotalLiquidity,orderDirection:ha.Desc,where:{swapEnabled:{eq:!0}}},s=Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||n),i=Object.assign({},(null===(a=e.query)||void 0===a?void 0:a.attrs)||{});this.query={args:s,attrs:i}}async fetchDefault(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0},orderBy:xa.TotalLiquidity,orderDirection:ha.Desc,block:await this.block()});return[...e,...t,...a].map(this.mapType.bind(this))}async fetch(e){(null==e?void 0:e.skip)&&(this.query.args.skip=e.skip),this.blockHeight&&(this.query.args.block={number:await this.blockHeight()}),this.query.args.first=(null==e?void 0:e.first)||1e3;const t=new Ke(this.query.args).format(new je),{pools:a}=await this.client.Pools(t);return this.skip=((null==e?void 0:e.skip)||0)+a.length,a.map(this.mapType.bind(this))}async find(e){return await this.findBy("id",e)}async findBy(e,t){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).find((a=>a[e]==t))}async all(){return this.pools||(this.pools=this.fetchDefault()),this.pools}async block(){return this.blockHeight?{number:await this.blockHeight()}:void 0}async where(e){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).filter(e)}mapType(e){var t,a,n,s,i,r,o,d,c;return{id:e.id,name:e.name||"",address:e.address,chainId:this.chainId,poolType:e.poolType,poolTypeVersion:e.poolTypeVersion||1,swapFee:e.swapFee,swapEnabled:e.swapEnabled,protocolYieldFeeCache:e.protocolYieldFeeCache||"0",protocolSwapFeeCache:e.protocolSwapFeeCache||"0",amp:null!==(t=e.amp)&&void 0!==t?t:void 0,owner:null!==(a=e.owner)&&void 0!==a?a:void 0,factory:null!==(n=e.factory)&&void 0!==n?n:void 0,symbol:null!==(s=e.symbol)&&void 0!==s?s:void 0,tokens:(e.tokens||[]).map(this.mapToken.bind(this)),tokensList:e.tokensList,tokenAddresses:(e.tokens||[]).map((e=>e.address)),totalLiquidity:e.totalLiquidity,totalShares:e.totalShares,totalSwapFee:e.totalSwapFee,totalSwapVolume:e.totalSwapVolume,priceRateProviders:null!==(i=e.priceRateProviders)&&void 0!==i?i:void 0,createTime:e.createTime,mainIndex:null!==(r=e.mainIndex)&&void 0!==r?r:void 0,wrappedIndex:null!==(o=e.wrappedIndex)&&void 0!==o?o:void 0,totalWeight:e.totalWeight||"1",lowerTarget:null!==(d=e.lowerTarget)&&void 0!==d?d:"0",upperTarget:null!==(c=e.upperTarget)&&void 0!==c?c:"0"}}mapToken(e){const t=this.mapSubPools(e.token);return{...e,isExemptFromYieldProtocolFee:e.isExemptFromYieldProtocolFee||!1,token:t}}mapSubPools(e){let t=null;return e.pool&&(t={id:e.pool.id,address:e.pool.address,totalShares:e.pool.totalShares,poolType:e.pool.poolType,mainIndex:e.pool.mainIndex||0},(null==e?void 0:e.pool.tokens)&&(t.tokens=e.pool.tokens.map(this.mapSubPoolToken.bind(this)))),{pool:t,latestUSDPrice:e.latestUSDPrice||void 0}}mapSubPoolToken(e){return{address:e.address,decimals:e.decimals,symbol:e.symbol,balance:e.balance,priceRate:e.priceRate,weight:e.weight,isExemptFromYieldProtocolFee:e.isExemptFromYieldProtocolFee||void 0,token:e.token?this.mapSubPools(e.token):void 0}}}class Ni{constructor(e){this.skip=0,this.poolsSubgraph=new ki({url:e.url,chainId:e.chainId,blockHeight:e.blockHeight,query:e.query}),this.provider=e.provider,this.multicall=e.multicall,this.vault=e.vault}async fetchDefault(){const e=await this.poolsSubgraph.fetch();return await qn(e,this.multicall,this.vault,this.provider)}async fetch(e){const t=await this.poolsSubgraph.fetch(e);return await qn(t,this.multicall,this.vault,this.provider)}async find(e){return await this.findBy("id",e)}async findBy(e,t){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).find((a=>a[e]==t))}async all(){return this.pools||(this.pools=this.fetchDefault()),this.pools}async where(e){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).filter(e)}}class Ci extends xi{async query(e){!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{pools:t}=await this.client.PoolGauges(e);return t.map(this.mapType)}mapType(e){return e}}var Di;e.PoolJoinExitAttributes=void 0,(Di=e.PoolJoinExitAttributes||(e.PoolJoinExitAttributes={})).Pool="pool",Di.Sender="sender";class Fi extends wi{async query(e){e.orderBy||(e.orderBy=ba.Timestamp),e.orderDirection||(e.orderDirection=ha.Asc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{joinExits:t}=await this.client.JoinExits(e);return t.map(this.mapType)}mapType(e){return{id:e.id,userAddress:e.user.id,poolId:e.pool.id,timestamp:e.timestamp,type:e.type,amounts:e.amounts,tokens:e.pool.tokensList}}async findByUser(t,a,n){return this.findAllBy(e.PoolJoinExitAttributes.Sender,t,a,n)}async findJoins(e,t){return this.query({where:{sender:e,pool:t,type:"Join"}})}async findExits(e,t){return this.query({where:{sender:e,pool:t,type:"Exit"}})}async findByPool(t,a,n){return this.findAllBy(e.PoolJoinExitAttributes.Pool,t,a,n)}}class Ri extends wi{async query(e){e.orderBy||(e.orderBy=Ia.Balance),e.orderDirection||(e.orderDirection=ha.Desc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{poolShares:t}=await this.client.PoolShares(e);return t.map(this.mapType)}mapType(e){return{id:e.id,userAddress:e.userAddress.id,poolId:e.poolId.id,balance:e.balance}}async findByUser(t,a,n){return this.findAllBy(e.PoolShareAttributes.UserAddress,t,a,n)}async findByPool(t,a,n){return this.findAllBy(e.PoolShareAttributes.PoolId,t,a,n)}}class Mi{constructor(e){this.tokens=e}async find(e){return this.tokens.find((t=>t.address.toLowerCase()===e.toLowerCase()))}async findBy(e,t){return this.tokens.find((a=>a[e]===t))}}class Li{constructor(e,t=1){this.chainId=t,this.prices={},this.baseTokenAddresses=e.map(Re),this.urlBase=`${tt[t].urls.priceUrl}/price/?vs_currencies=usd,eth`,this.debouncer=new Ue(this.fetch.bind(this),200)}fetch(e,{signal:t}={}){return e.length,x.default.get(this.url(e),{signal:t}).then((({data:e})=>e)).finally((()=>{e.length}))}fetchNative({signal:e}={}){let t;!function(e){e.ETH="ethereum",e.MATIC="matic-network",e.XDAI="xdai",e.OAS="oasys"}(t||(t={}));const a=t.OAS,n=this.url(["0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000"]);return x.default.get(n,{signal:e}).then((({data:e})=>e[a])).finally((()=>{}))}find(e){const t=e.toLowerCase();if(!this.prices[t]){if(0===Object.keys(this.prices).length)for(const e of this.baseTokenAddresses)this.prices[e]=this.debouncer.fetch(e).then((t=>t[e]));this.prices[t]=this.debouncer.fetch(t).then((e=>e[t]))}return this.prices[t]}async findBy(e,t){if("address"==e)return this.find(t)}platform(e){switch(e){case 1:case 5:case 42:case 31337:case 248:case 9372:case 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 Ui{constructor(e=1){this.chainId=e,this.prices={},this.urlBase=`https://api.coingecko.com/api/v3/coins/${this.platform(e)}/contract/%TOKEN_ADDRESS%/market_chart/range?vs_currency=usd`}fetch(e,t,{signal:a}={}){const n=this.urlRange(e,t);return x.default.get(n,{signal:a}).then((({data:e})=>e)).finally((()=>{}))}async find(e){throw"Historic price requires point-in-time timestamp, please use findBy(address, timestamp)"}async findBy(e,t){const a=Re(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 Gi{constructor(e,t=1){this.subgraphUrl=e,this.chainId=t,this.prices={},this.debouncer=new Ue(this.fetch.bind(this),200)}async fetch(e,{signal:t}={}){return e.length,x.default.post(this.subgraphUrl,{variables:{addresses:e},query:"query($addresses: [String!]) {\n tokens(\n where: {\n id_in: $addresses\n }\n ) {\n address\n latestUSDPrice\n }\n }"},{signal:t}).then((e=>e.data.data)).then((({tokens:e})=>Object.fromEntries(e.map((e=>[e.address,{usd:e.latestUSDPrice||void 0}]))))).finally((()=>{e.length}))}async find(e){const t=Re(e,this.chainId);return this.prices[t]||(this.prices[t]=this.debouncer.fetch(t).then((e=>e[t]))),this.prices[t]}async findBy(e,t){if("address"==e)return this.find(t)}}class qi{constructor(e,t,a){this.coingeckoRepository=e,this.subgraphRepository=t,this.aaveRates=a}async find(e){let t;try{try{if(t=await this.coingeckoRepository.find(e),!(null==t?void 0:t.usd))throw new Error(`Price not found:${e}`)}catch(a){console.error(`Coingecko API error: ${e} ${a}`),t=await this.subgraphRepository.find(e)}}catch(e){console.error(e),t={eth:"0",usd:"0.1"}}return t}async findBy(e,t){if("address"===e)return this.find(t);throw`Token price search by ${e} not implemented`}}class Wi{constructor(e,t){this.coingeckoRepository=e,this.aaveRates=t}async find(e){return this.findBy(e,Math.floor(Date.now()/1e3))}async findBy(e,t){const a=await this.coingeckoRepository.findBy(e,t),n=await this.aaveRates.getRate(e)||1;return a&&a.usd?{...a,usd:(parseFloat(a.usd)*n).toString()}:a}}const $i=new t.Interface(["function rate() view returns (uint256)"]);class Vi{constructor(e,t,a){this.network=a,this.multicall=Dn(e,t)}async fetch(e){const t=Object.values(_e[e]),a=t.map((e=>[e,$i.encodeFunctionData("rate",[])])),[,n]=await this.multicall.aggregate(a);return t.reduce(((e,t,a)=>(e[t]||(e[t]="0x"==n[a]?0:parseFloat(Pe(n[a],27))),e)),{})}async getRate(t){return this.network!=e.Network.MAINNET&&this.network!=e.Network.POLYGON?1:Object.values(_e[this.network]).includes(t)?(this.rates||(this.rates=this.fetch(this.network)),(await this.rates)[t]):1}}const Hi=new t.Interface(["function getTokensDistributedInWeek(address token, uint timestamp) view returns (uint)"]),ji=new t.Interface(["function totalSupply() view returns (uint)"]),Ki=new t.Interface(["function getRate() view returns (uint)"]);class Zi{constructor(e,t,a,n,s,i){this.feeDistributorAddress=t,this.balAddress=a,this.veBalAddress=n,this.bbAUsdAddress=s,this.multicall=Dn(e,i)}async fetch(e){const t=this.getPreviousWeek(e),a=[[this.feeDistributorAddress,Hi.encodeFunctionData("getTokensDistributedInWeek",[s.getAddress(this.balAddress),t])],[this.feeDistributorAddress,Hi.encodeFunctionData("getTokensDistributedInWeek",[s.getAddress(this.bbAUsdAddress),t])],[this.veBalAddress,ji.encodeFunctionData("totalSupply",[])],[this.bbAUsdAddress,Ki.encodeFunctionData("getRate",[])]],[,n]=await this.multicall.aggregate(a);return{balAmount:parseFloat(Pe(n[0],18)),bbAUsdAmount:parseFloat(Pe(n[1],18)),veBalSupply:parseFloat(Pe(n[2],18)),bbAUsdPrice:parseFloat(Pe(n[3],18)),balAddress:this.balAddress}}async multicallData(e){return this.data||(this.data=await this.fetch(e)),this.data}getPreviousWeek(e){const t=new Date(e);t.setUTCHours(0),t.setUTCMinutes(0),t.setUTCSeconds(0),t.setUTCMilliseconds(0);let a=t.getUTCDay()-4;return a<0&&(a+=7),a+=7,Math.floor(t.getTime()/1e3)-86400*a}}const Xi=new t.Interface(["function getProtocolFeesCollector() view returns (address)"]),Ji=new t.Interface(["function getSwapFeePercentage() view returns (uint)"]);let Yi;class zi{constructor(e,t){this.provider=t,this.vault=new i.Contract(e,Xi,this.provider)}async fetch(){const e=await this.vault.getProtocolFeesCollector(),t=new i.Contract(e,Ji,this.provider),a=await t.getSwapFeePercentage();return parseFloat(Pe(a,18))}async find(){return Yi||(Yi=this.fetch()),this.swapFeePercentage=await Yi,this.swapFeePercentage}async findBy(){return this.find()}}const Qi=new t.Interface(["function getSwapFeePercentage() view returns (uint)"]);let er;class tr{constructor(e,t,a){this.protocolFeePercentagesProviderAddress=t,this.multicall=Dn(e,a)}async fetch(){const e=[[this.protocolFeePercentagesProviderAddress,Qi.encodeFunctionData("getFeeTypePercentage",[0])],[this.protocolFeePercentagesProviderAddress,Qi.encodeFunctionData("getFeeTypePercentage",[2])]],[,t]=await this.multicall.aggregate(e);return{swapFee:parseFloat(Pe(t[0],18)),yieldFee:parseFloat(Pe(t[2],18))}}async getFees(){return er||(er=this.fetch()),this.protocolFees=await er,this.protocolFees}}const ar={stETH:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",wstETH:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",arbitrumStEth:"0x5979d7b546e38e414f7e9822514be443a4800529"},nr=async()=>{let e=0;try{const t=await x.default.get("https://lido-aprs-proxy.balancer.workers.dev/?network=1"),{data:a}=t.data;e=Math.round(100*parseFloat(a.smaApr))}catch(e){console.error("Failed to fetch stETH APR:",e)}return{[ar.stETH]:e,[ar.wstETH]:e,[ar.arbitrumStEth]:e}},sr={rETH:"0xae78736cd615f374d3085123a210448e74fc6393"},ir=async()=>{let e=0;try{const t=await x.default.get("https://api.rocketpool.net/api/apr"),{yearlyAPR:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[sr.rETH]:e}},rr={stMATIC:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4"},or=async()=>{let e=0;try{const t=await x.default.get("https://lido-aprs-proxy.balancer.workers.dev/?network=137"),{apr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch stMATIC APR:",e)}return{[rr.stMATIC]:e}},dr={usdcUSDplus:"0x1aafc31091d93c3ff003cff5d2d8f7ba2e728425",usdcUSDplus2:"0x6933ec1ca55c06a894107860c92acdfd2dd8512f"},cr=async()=>{let e=0;try{const{data:t}=await x.default.get("https://app.overnight.fi/api/balancer/week/apr");e=Math.round(1e4*parseFloat(t)/100)}catch(e){console.error("Failed to fetch USD+ APR:",e)}return Object.fromEntries(Object.values(dr).map((t=>[t,e])))},lr={sfrxETH:"0xac3e018457b222d93114458476f3e3416abbe38f"},pr=async()=>{let e=0;try{const t=await x.default.get("https://api.frax.finance/v2/frxeth/summary/latest"),{sfrxethApr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[lr.sfrxETH]:e}},ur={maticX:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6"},br=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=stader"),{value:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[ur.maticX]:e}},yr={qETH:"0x93ef1ea305d11a9b2a3ebb9bb4fcc34695292e7d"},mr=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=tranchess"),[{weeklyAveragePnlPercentage:a}]=t.data;e=Math.round(parseFloat(Pe(n.BigNumber.from(a).mul(365).mul(1e4),18)))}catch(e){console.error("Failed to fetch qETH APR:",e)}return{[yr.qETH]:e}},fr={USDR:"0xaf0d9d65fc54de245cda37af3d18cbec860a4d4b"},hr=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=usdr"),{usdr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch USDR APR:",e)}return{[fr.USDR]:e}},Tr={rETH:"0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593"},gr=async()=>{let e=0;try{const t=await x.default.get("https://drop-api.stafi.io/reth/v1/poolData/"),{stakeApr:a}=t.data.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[Tr.rETH]:e}},Ir=new u.JsonRpcProvider("https://rpc.ankr.com/eth",1),Er={getPoolsUI:new i.Contract("0x5954aB967Bc958940b7EB73ee84797Dc8a2AFbb9",[{inputs:[],name:"getPoolsUI",outputs:[{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"}],stateMutability:"view",type:"function"}],Ir).getPoolsUI},wr={sApe:"0x7966c5bae631294d7cffcea5430b78c2f76db6fa"},xr=async(e=1,t=Er)=>{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{[wr.sApe]:a}},Ar={eUSDC:"0xeb91861f8a4e1c12333f42dce8fb0ecdc28da716",eDAI:"0xe025e3ca2be02316033184551d4d3aa22024d9dc",eUSDT:"0x4d19f33948b99800b6113ff3e83bec9b537c85d2",eFRAX:"0x5484451a88a35cd0878a1be177435ca8a0e4054e"},Sr={[e.Network.MAINNET]:"https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet"},Pr=async()=>{const t=e.Network.MAINNET,a={operationName:"getAssetsAPY",query:"\n query getAssetsAPY($eTokenAddress_in: [String!]) {\n assets(\n where: {\n eTokenAddress_in: $eTokenAddress_in\n }\n ) {\n eTokenAddress\n supplyAPY\n }\n }\n",variables:{eTokenAddress_in:Object.values(Ar)}},s=await x.default.post(Sr[t],a),{data:{assets:i}}=s.data,r={eUSDT:0,eDAI:0,eUSDC:0,eFRAX:0};return i.forEach((({eTokenAddress:e,supplyAPY:t})=>{const a=Object.entries(Ar).filter((([,t])=>t.toLocaleLowerCase()===e.toLocaleLowerCase()))[0][0];r[a]=Math.round(1e4*parseFloat(Pe(n.BigNumber.from(t),27)))})),{[Ar.eUSDT]:r.eUSDT,[Ar.eDAI]:r.eDAI,[Ar.eUSDC]:r.eUSDC,[Ar.eFRAX]:r.eFRAX}},Br=Object.fromEntries([...Object.values(ar).map((e=>[e,nr])),...Object.values(rr).map((e=>[e,or])),...Object.values(Oe).map((e=>[e,Fe])),...Object.values(dr).map((e=>[e,cr])),...Object.values(sr).map((e=>[e,ir])),...Object.values(lr).map((e=>[e,pr])),...Object.values(ur).map((e=>[e,br])),...Object.values(yr).map((e=>[e,mr])),...Object.values(fr).map((e=>[e,hr])),...Object.values(Tr).map((e=>[e,gr])),...Object.values(wr).map((e=>[e,xr])),...Object.values(Ar).map((e=>[e,Pr]))]);class _r{constructor(e,t=Br){this.network=e,this.sources=t,this.yields={}}async fetch(e){const t=await this.sources[e](this.network);this.yields={...this.yields,...t}}async find(e){const t=e.toLocaleLowerCase();return Object.keys(this.sources).includes(t)&&!Object.keys(this.yields).includes(t)&&await this.fetch(t),this.yields[t]}async findBy(e,t){if("address"==e)return this.find(t)}}const Or=e=>`{\n blocks(first: 1, orderBy: timestamp, orderDirection: asc, where: { timestamp_gt: ${e} }) {\n number\n }\n}`,vr=async(e,t)=>{const a={query:Or(t)},n=await x.default.post(e,a),{data:{blocks:s}}=n.data;return parseInt(s[0].number)};class kr{constructor(e){this.endpoint=e,this.blocks={}}async find(e){if("dayAgo"==e){const e=""+(Math.floor(Date.now()/1e3)-86400);return this.blocks[e]||(this.blocks={...this.blocks,[e]:vr(this.endpoint,e)}),this.blocks[e]}}async findBy(e="",t=""){}}var Nr,Cr,Dr=[{chainId:1,address:"0x8888801af4d980682e47f1a9036e589479e835c5",symbol:"mph"},{chainId:1,address:"0x27054b13b1b798b345b591a4d22e6562d47ea75a",symbol:"ast"},{chainId:1,address:"0x3301ee63fb29f863f2333bd4466acb46cd8323e6",symbol:"akita"},{chainId:1,address:"0x616e8bfa43f920657b3497dbf40d6b1a02d4608d",symbol:"aurabal"},{chainId:1,address:"0xc0c293ce456ff0ed870add98a0828dd4d2903dbf",symbol:"aura"},{chainId:1,address:"0x3472a5a71965499acd81997a54bba8d852c6e53d",symbol:"badger"},{chainId:1,address:"0xba100000625a3754423978a60c9317c58a424e3d",symbol:"bal"},{chainId:1,address:"0x804cdb9116a10bb78768d3252355a1b18067bf8f",symbol:"bb-a-dai"},{chainId:1,address:"0x9210f1204b5a24742eba12f710636d76240df3d0",symbol:"bb-a-usdc"},{chainId:1,address:"0x2bbf681cc4eb09218bee85ea2a5d3d13fa40fc0c",symbol:"bb-a-usdt"},{chainId:1,address:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2",symbol:"bb-a-usd"},{chainId:1,address:"0x2d94aa3e47d9d5024503ca8491fce9a2fb4da198",symbol:"bank"},{chainId:1,address:"0x0d8775f648430679a709e98d2b0cb6250d2887ef",symbol:"bat"},{chainId:1,address:"0xf17e65822b568b3903685a7c9f496cf7656cc6c2",symbol:"bico"},{chainId:1,address:"0x799ebfabe77a6e34311eeee9825190b9ece32824",symbol:"btrst"},{chainId:1,address:"0x514910771af9ca656af840dff83e8264ecf986ca",symbol:"link"},{chainId:1,address:"0x3506424f91fd33084466f402d5d97f05f8e3b4af",symbol:"chz"},{chainId:1,address:"0x41e5560054824ea6b0732e656e3ad64e20e94e45",symbol:"cvc"},{chainId:1,address:"0xc00e94cb662c3520282e6f5717214004a7f26888",symbol:"comp"},{chainId:1,address:"0xdef1ca1fb7fbcdc777520aa7f396b4e015f497ab",symbol:"cow"},{chainId:1,address:"0xd533a949740bb3306d119cc777fa900ba034cd52",symbol:"crv"},{chainId:1,address:"0x6b175474e89094c44da98b954eedeac495271d0f",symbol:"dai"},{chainId:1,address:"0xf2051511b9b121394fa75b8f7d4e7424337af687",symbol:"haus"},{chainId:1,address:"0x888888435fde8e7d4c54cab67f206e4199454c60",symbol:"dfx"},{chainId:1,address:"0x798d1be841a82a273720ce31c822c61a67a601c3",symbol:"digg"},{chainId:1,address:"0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c",symbol:"enj"},{chainId:1,address:"0xc18360217d8f7ab5e7c516566761ea12ce7f9d72",symbol:"ens"},{chainId:1,address:"0x4e15361fd6b4bb609fa63c81a2be19d873717870",symbol:"ftm"},{chainId:1,address:"0x956f47f50a910163d8bf957cf5846d573e7f87ca",symbol:"fei"},{chainId:1,address:"0xed1480d12be41d92f36f5f7bdd88212e381a3677",symbol:"fdt"},{chainId:1,address:"0x586aa273f262909eef8fa02d90ab65f5015e0516",symbol:"fiat"},{chainId:1,address:"0xde30da39c46104798bb5aa3fe8b9e0e1f348163f",symbol:"gtc"},{chainId:1,address:"0x900db999074d9277c5da2a43f252d74366230da0",symbol:"giv"},{chainId:1,address:"0x6810e776880c02933d47db1b9fc05908e5386b96",symbol:"gno"},{chainId:1,address:"0xba485b556399123261a5f9c95d413b4f93107407",symbol:"graviaura"},{chainId:1,address:"0x3ec8798b81485a254928b70cda1cf0a2bb0b74d7",symbol:"gro"},{chainId:1,address:"0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",symbol:"snx"},{chainId:1,address:"0x5a98fcbea516cf06857215779fd812ca3bef1b32",symbol:"ldo"},{chainId:1,address:"0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d",symbol:"lqty"},{chainId:1,address:"0x5f98805a4e8be255a32880fdec7f6728c6568ba0",symbol:"lusd"},{chainId:1,address:"0x965d79f1a1016b574a62986e13ca8ab04dfdd15c",symbol:"m2"},{chainId:1,address:"0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",symbol:"mkr"},{chainId:1,address:"0xd084944d3c05cd115c09d072b9f44ba3e0e45921",symbol:"fold"},{chainId:1,address:"0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",symbol:"matic"},{chainId:1,address:"0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",symbol:"mta"},{chainId:1,address:"0x4b13006980acb09645131b91d259eaa111eaf5ba",symbol:"myc"},{chainId:1,address:"0x333a4823466879eef910a04d473505da62142069",symbol:"nation"},{chainId:1,address:"0xcfeaead4947f0705a14ec42ac3d44129e1ef3ed5",symbol:"note"},{chainId:1,address:"0x967da4048cd07ab37855c090aaf366e4ce1b9f48",symbol:"ocean"},{chainId:1,address:"0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5",symbol:"ohm"},{chainId:1,address:"0xab846fb6c81370327e784ae7cbb6d6a6af6ff4bf",symbol:"pal"},{chainId:1,address:"0xcafe001067cdef266afb7eb5a286dcfd277f3de5",symbol:"psp"},{chainId:1,address:"0x68037790a0229e9ce6eaa8a99ea92964106c4703",symbol:"par"},{chainId:1,address:"0x45804880de22913dafe09f4980848ece6ecbaf78",symbol:"paxg"},{chainId:1,address:"0x89ab32156e46f46d02ade3fecbe5fc4243b9aaed",symbol:"pnt"},{chainId:1,address:"0x9992ec3cf6a55b00978cddf2b27bc6882d88d1ec",symbol:"poly"},{chainId:1,address:"0x43d4a3cd90ddd2f8f4f693170c9c8098163502ad",symbol:"d2d"},{chainId:1,address:"0xeb4c2781e4eba804ce9a9803c67d0893436bb27d",symbol:"renbtc"},{chainId:1,address:"0x408e41876cccdc0f92210600ef50372656052a38",symbol:"ren"},{chainId:1,address:"0xfb5453340c03db5ade474b27e68b6a9c6b2823eb",symbol:"robot"},{chainId:1,address:"0xd33526068d116ce69f19a9ee46f0bd304f21a51f",symbol:"rpl"},{chainId:1,address:"0xae78736cd615f374d3085123a210448e74fc6393",symbol:"reth"},{chainId:1,address:"0xfe18be6b3bd88a2d2a7f928d00292e7a9963cfc6",symbol:"sbtc"},{chainId:1,address:"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff",symbol:"srm"},{chainId:1,address:"0x35e78b3982e87ecfd5b3f3265b601c046cdbe232",symbol:"xai"},{chainId:1,address:"0x3affcca64c2a6f4e3b6bd9c64cd2c969efd1ecbe",symbol:"dsla"},{chainId:1,address:"0xf24d8651578a55b0c119b9910759a351a3458895",symbol:"sdbal"},{chainId:1,address:"0x11c1a6b3ed6bb362954b29d3183cfa97a0c806aa",symbol:"str"},{chainId:1,address:"0x8f693ca8d21b157107184d29d398a8d082b38b76",symbol:"data"},{chainId:1,address:"0x470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7",symbol:"temple"},{chainId:1,address:"0xa36fdbbae3c9d55a1d67ee5821d53b50b63a1ab9",symbol:"temp"},{chainId:1,address:"0xdac17f958d2ee523a2206206994597c13d831ec7",symbol:"usdt"},{chainId:1,address:"0x9c4a4204b79dd291d6b6571c5be8bbcd0622f050",symbol:"tcr"},{chainId:1,address:"0x226f7b842e0f0120b7e194d05432b3fd14773a9d",symbol:"unn"},{chainId:1,address:"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",symbol:"uni"},{chainId:1,address:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",symbol:"usdc"},{chainId:1,address:"0x81f8f0bb1cb2a06649e51913a151f0e7ef6fa321",symbol:"vita"},{chainId:1,address:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",symbol:"weth"},{chainId:1,address:"0xedb171c18ce90b633db442f2a6f72874093b49ef",symbol:"wampl"},{chainId:1,address:"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",symbol:"wbtc"},{chainId:1,address:"0xf203ca1769ca8e9e8fe1da9d147db68b6c919817",symbol:"wncg"},{chainId:1,address:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",symbol:"wsteth"},{chainId:1,address:"0x79c71d3436f39ce382d0f58f1b011d88100b9d91",symbol:"xns"},{chainId:1,address:"0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",symbol:"yfi"},{chainId:1,address:"0xbcca60bb61934080951369a648fb03df4f96263c",symbol:"ausdc"},{chainId:1,address:"0x028171bca77440897b824ca71d1c56cac55b68a3",symbol:"adai"},{chainId:1,address:"0x3ed3b47dd13ec9a98b44e6204a523e766b225811",symbol:"ausdt"},{chainId:137,address:"0x9c2c5fd7b07e95ee044ddeba0e97a665f142394f",symbol:"1inch"},{chainId:137,address:"0xd6df932a45c0f255f85145f286ea0b292b21c90b",symbol:"aave"},{chainId:137,address:"0xc3fdbadc7c795ef1d6ba111e06ff8f16a20ea539",symbol:"addy"},{chainId:137,address:"0xf84bd51eab957c2e7b7d646a3427c5a50848281d",symbol:"agar"},{chainId:137,address:"0x033d942a6b495c4071083f4cde1f17e986fe856c",symbol:"aga"},{chainId:137,address:"0x0e9b89007eee9c958c0eda24ef70723c2c93dd58",symbol:"amaticc"},{chainId:137,address:"0x034b2090b579228482520c589dbd397c53fc51cc",symbol:"vision"},{chainId:137,address:"0x2c89bbc92bd86f8075d1decc58c7f4e0107f286b",symbol:"avax"},{chainId:137,address:"0x49690541e3f6e933a9aa3cffee6010a7bb5b72d7",symbol:"axiav3"},{chainId:137,address:"0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",symbol:"bal"},{chainId:137,address:"0xdb7cb471dd0b49b29cab4a1c14d070f27216a0ab",symbol:"bank"},{chainId:137,address:"0xfbdd194376de19a88118e84e279b977f165d01b8",symbol:"bifi"},{chainId:137,address:"0xd6ca869a4ec9ed2c7e618062cdc45306d8dbbc14",symbol:"btc2x-fli-p"},{chainId:137,address:"0x53e0bca35ec356bd5dddfebbd1fc0fd03fabad39",symbol:"link"},{chainId:137,address:"0x172370d5cd63279efa6d502dab29171933a610af",symbol:"crv"},{chainId:137,address:"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",symbol:"dai"},{chainId:137,address:"0x1d607faa0a51518a7728580c238d912747e71f7a",symbol:"data"},{chainId:137,address:"0x85955046df4668e1dd369d2de9f3aeb98dd2a369",symbol:"dpi"},{chainId:137,address:"0xe7804d91dfcde7f776c90043e03eaa6df87e6395",symbol:"dfx"},{chainId:137,address:"0xf28164a485b0b2c90639e47b0f377b4a438a16b1",symbol:"dquick"},{chainId:137,address:"0x45c32fa6df82ead1e2ef74d17b76547eddfaff89",symbol:"frax"},{chainId:137,address:"0x50b728d8d964fd00c2d0aad81718b71311fef68a",symbol:"snx"},{chainId:137,address:"0x72928d5436ff65e57f72d5566dcd3baedc649a88",symbol:"hdao"},{chainId:137,address:"0x3ad707da309f3845cd602059901e39c4dcd66473",symbol:"eth2x-fli-p"},{chainId:137,address:"0x4f025829c4b13df652f38abd2ab901185ff1e609",symbol:"ieth-fli-p"},{chainId:137,address:"0x340f412860da7b7823df372a2b59ff78b7ae6abc",symbol:"imatic-fli-p"},{chainId:137,address:"0xf287d97b6345bad3d88856b26fb7c0ab3f2c7976",symbol:"matic2x-fli-p"},{chainId:137,address:"0x130ce4e4f76c2265f94a961d70618562de0bb8d2",symbol:"ibtc-fli-p"},{chainId:137,address:"0x596ebe76e2db4470966ea395b0d063ac6197a8c5",symbol:"jrt"},{chainId:137,address:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4",symbol:"stmatic"},{chainId:137,address:"0xf501dd45a1198c2e1b5aef5314a68b9006d842e0",symbol:"mta"},{chainId:137,address:"0xeaecc18198a475c921b24b8a6c1c1f0f5f3f7ea0",symbol:"seed"},{chainId:137,address:"0xfe712251173a2cd5f5be2b46bb528328ea3565e1",symbol:"mvi"},{chainId:137,address:"0xa3fa99a148fa48d14ed51d610c367c61876997f1",symbol:"mimatic"},{chainId:137,address:"0xa486c6bc102f409180ccb8a94ba045d39f8fc7cb",symbol:"nex"},{chainId:137,address:"0xe2aa7db6da1dae97c5f5c6914d285fbfcc32a128",symbol:"par"},{chainId:137,address:"0x580a84c73811e1839f75d86d75d88cca0c241ff4",symbol:"qi"},{chainId:137,address:"0x831753dd7087cac61ab5644b308642cc1c33dc13",symbol:"quick"},{chainId:137,address:"0xb5c064f955d8e7f38fe0460c556a72987494ee17",symbol:"quick"},{chainId:137,address:"0x00e5646f60ac6fb446f621d146b6e1886f002905",symbol:"rai"},{chainId:137,address:"0x431cd3c9ac9fc73644bf68bf5691f4b83f9e104f",symbol:"rbw"},{chainId:137,address:"0xdbf31df14b66535af65aac99c32e9ea844e14501",symbol:"renbtc"},{chainId:137,address:"0x501ace9c35e60f03a2af4d484f49f9b1efde9f40",symbol:"solace"},{chainId:137,address:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6",symbol:"maticx"},{chainId:137,address:"0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a",symbol:"sushi"},{chainId:137,address:"0xdf7837de1f2fa4631d716cf2502f8b230f1dcc32",symbol:"tel"},{chainId:137,address:"0xe6469ba6d2fd6130788e0ea9c0a0515900563b59",symbol:"ust"},{chainId:137,address:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",symbol:"usdt"},{chainId:137,address:"0x5fe2b58c013d7601147dcdd68c143a77499f5531",symbol:"grt"},{chainId:137,address:"0xbbba073c31bf03b8acf7c28ef0738decf3695683",symbol:"sand"},{chainId:137,address:"0x2934b36ca9a4b31e633c5be670c8c8b28b6aa015",symbol:"thx"},{chainId:137,address:"0x2f800db0fdb5223b3c3f354886d907a671414a7f",symbol:"bct"},{chainId:137,address:"0x2e1ad108ff1d8c782fcbbb89aad783ac49586756",symbol:"tusd"},{chainId:137,address:"0x3809dcdd5dde24b37abe64a5a339784c3323c44f",symbol:"swap"},{chainId:137,address:"0x7fbc10850cae055b27039af31bd258430e714c62",symbol:"ubt"},{chainId:137,address:"0x2791bca1f2de4661ed88a30c99a7a9449aa84174",symbol:"usdc"},{chainId:137,address:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",symbol:"weth"},{chainId:137,address:"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",symbol:"wmatic"},{chainId:137,address:"0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6",symbol:"wbtc"},{chainId:137,address:"0x24834bbec7e39ef42f4a75eaf8e5b6486d3f0e57",symbol:"lunc"},{chainId:137,address:"0xf153eff70dc0bf3b085134928daeea248d9b30d0",symbol:"xmark"},{chainId:42161,address:"0x9f20de1fc9b161b34089cbeae888168b44b03461",symbol:"arbis"},{chainId:42161,address:"0x040d1edc9569d4bab2d15287dc5a4f10f56a56b8",symbol:"bal"},{chainId:42161,address:"0x031d35296154279dc1984dcd93e392b1f946737b",symbol:"cap"},{chainId:42161,address:"0xf97f4df75117a78c1a5a0dbb814af92458539fb4",symbol:"link"},{chainId:42161,address:"0x354a6da3fcde098f8389cad84b0182725c6c91de",symbol:"comp"},{chainId:42161,address:"0xf4d48ce3ee1ac3651998971541badbb9a14d7234",symbol:"cream"},{chainId:42161,address:"0x11cdb42b0eb46d95f990bedd4695a6e3fa034978",symbol:"crv"},{chainId:42161,address:"0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",symbol:"dai"},{chainId:42161,address:"0x8038f3c971414fd1fc220ba727f2d4a0fc98cb65",symbol:"dht"},{chainId:42161,address:"0xf0b5ceefc89684889e5f7e0a7775bd100fcd3709",symbol:"dusd"},{chainId:42161,address:"0x6c2c06790b3e3e3c38e12ee22f8183b37a13ee55",symbol:"dpx"},{chainId:42161,address:"0x32eb7902d4134bf98a28b963d26de779af92a212",symbol:"rdpx"},{chainId:42161,address:"0xc3ae0333f0f34aa734d5493276223d95b8f9cb37",symbol:"dxd"},{chainId:42161,address:"0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a",symbol:"gmx"},{chainId:42161,address:"0xa0b862f60edef4452f25b4160f177db44deb6cf1",symbol:"gno"},{chainId:42161,address:"0xb965029343d55189c25a7f3e0c9394dc0f5d41b1",symbol:"ndx"},{chainId:42161,address:"0x539bde0d7dbd336b79148aa742883198bbf60342",symbol:"magic"},{chainId:42161,address:"0x4e352cf164e64adcbad318c3a1e222e9eba4ce42",symbol:"mcb"},{chainId:42161,address:"0x3f56e0c36d275367b8c502090edf38289b3dea0d",symbol:"mimatic"},{chainId:42161,address:"0x965772e0e9c84b6f359c8597c891108dcf1c5b1a",symbol:"pickle"},{chainId:42161,address:"0x6694340fc020c5e6b96567843da2df01b2ce1eb6",symbol:"stg"},{chainId:42161,address:"0xd4d42f0b6def4ce0383636770ef773390d85c61a",symbol:"sushi"},{chainId:42161,address:"0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",symbol:"usdt"},{chainId:42161,address:"0x23a941036ae778ac51ab04cea08ed6e2fe103614",symbol:"grt"},{chainId:42161,address:"0xa72159fc390f0e3c6d415e658264c7c4051e9b87",symbol:"tcr"},{chainId:42161,address:"0x4d15a3a2286d883af0aa1b3f21367843fac63e07",symbol:"tusd"},{chainId:42161,address:"0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0",symbol:"uni"},{chainId:42161,address:"0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",symbol:"usdc"},{chainId:42161,address:"0xa684cd057951541187f288294a1e1c2646aa2d24",symbol:"vsta"},{chainId:42161,address:"0x64343594ab9b56e99087bfa6f2335db24c2d1f17",symbol:"vst"},{chainId:42161,address:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",symbol:"weth"},{chainId:42161,address:"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",symbol:"wbtc"},{chainId:42161,address:"0x82e3a8f066a6989666b031d916c43672085b1582",symbol:"yfi"},{chainId:16116,address:"0x5a89E11Cb554E00c2f51C4bb7F05bc7Ab0Fa6351",symbol:"weth"},{chainId:9372,address:"0x5200000000000000000000000000000000000001",symbol:"weth"},{chainId:248,address:"0x5200000000000000000000000000000000000001",symbol:"weth"},{chainId:6343,address:"0xAba76Cdc5910F6627856EB75Bcce0171376999C7",symbol:"weth"},{chainId:4326,address:"0x4200000000000000000000000000000000000006",symbol:"weth"}];class Fr{constructor(e,t,a){this.pools=new ki({url:e.urls.subgraph,chainId:e.chainId}),this.poolsOnChain=new Ni({url:e.urls.subgraph,chainId:e.chainId,provider:t,multicall:e.addresses.contracts.multicall,vault:e.addresses.contracts.vault,query:a}),this.poolShares=new Ri(e.urls.subgraph,e.chainId),this.poolJoinExits=new Fi(e.urls.subgraph,e.chainId),e.urls.gaugesSubgraph&&(this.poolGauges=new Ci(e.urls.gaugesSubgraph,e.chainId),this.gaugeShares=new Ai(e.urls.gaugesSubgraph,e.chainId)),e.urls.blockNumberSubgraph&&(this.blockNumbers=new kr(e.urls.blockNumberSubgraph));this.yesterdaysPools=new ki({url:e.urls.subgraph,chainId:e.chainId,blockHeight:async()=>{const e=await t.getBlockNumber();return Number(e)-5e3}});const n=Dr.filter((t=>t.chainId==e.chainId)).map((e=>e.address)),s=new Li(n,e.chainId),i=new Gi(e.urls.subgraph,e.chainId),r=new Vi(e.addresses.contracts.multicall,t,e.chainId);this.tokenPrices=new qi(s,i,r);const o=new Ui(e.chainId);this.tokenHistoricalPrices=new Wi(o,r),this.tokenMeta=new Mi([]),e.urls.gaugesSubgraph&&(this.liquidityGauges=new Oi(e.urls.gaugesSubgraph,e.addresses.contracts.multicall,e.addresses.contracts.gaugeController||"",e.chainId,t)),e.addresses.contracts.feeDistributor&&e.addresses.tokens.bal&&e.addresses.tokens.veBal&&e.addresses.tokens.bbaUsd&&(this.feeDistributor=new Zi(e.addresses.contracts.multicall,e.addresses.contracts.feeDistributor,e.addresses.tokens.bal,e.addresses.tokens.veBal,e.addresses.tokens.bbaUsd,t)),this.feeCollector=new zi(e.addresses.contracts.vault,t),e.addresses.contracts.protocolFeePercentagesProvider&&(this.protocolFees=new tr(e.addresses.contracts.multicall,e.addresses.contracts.protocolFeePercentagesProvider,t)),this.tokenYields=new _r(e.chainId)}}!function(e){e[e.Direct=0]="Direct",e[e.TokenIn=1]="TokenIn",e[e.TokenOut=2]="TokenOut",e[e.Middle=3]="Middle"}(Nr||(Nr={})),function(e){e[e.Swap=0]="Swap",e[e.BatchSwap=1]="BatchSwap",e[e.Join=2]="Join",e[e.Exit=3]="Exit"}(Cr||(Cr={}));const Rr={type:Cr.BatchSwap,swaps:[],opRef:[],minOut:"0",assets:[],hasTokenIn:!1,hasTokenOut:!1,fromInternal:!1,toInternal:!1,limits:[],approveTokens:[],sender:"",receiver:""},Mr=new t.Interface(gs);function Lr(e,t){return e.some((e=>e.address.toLowerCase()===t.toLowerCase()))}function Ur(e,t){const a=t[e.assetOutIndex],n=D(e.poolId);return a.toLowerCase()===n.toLowerCase()}function Gr(e,t){const a=t[e.assetInIndex],n=D(e.poolId);return a.toLowerCase()===n.toLowerCase()}function qr(e,t,a){let n={};var s;return e!==Nr.TokenIn&&e!==Nr.Middle||(s=a,n={index:t,key:cs.toChainedReference(s)},a++),[n,a]}function Wr(e,t){return ze(n.BigNumber.from(e),n.BigNumber.from(t)).toString()}function $r(e,t,a,n){let s=e.amount;return(a===Nr.TokenOut||a===Nr.Middle&&t===Cr.Join||a===Nr.Middle&&t===Cr.Exit)&&(s=cs.toChainedReference(n-1).toString()),s}function Vr(e,t,a,n){let s;return s=a===e&&n===t?Nr.Direct:a===e?Nr.TokenIn:n===t?Nr.TokenOut:Nr.Middle,s}function Hr(e,t){const s=function(e){const t=[],a=[],n=[];for(const s of e)s.type===Cr.Exit||s.type===Cr.Join?s.hasTokenIn?t.push(s):s.hasTokenOut?a.push(s):n.push(s):n.push(s);return[...t,...n,...a]}(e),i=function(e,t){const s=[];let i=c.cloneDeep(Rr);i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"));let r=!0,o={};for(const d of e)d.type===Cr.Swap?(r&&(o=d,r=!1),d.isBptIn&&i.approveTokens.push(d.assets[d.swap.assetInIndex]),d.fromInternal===o.fromInternal&&d.toInternal===o.toInternal&&d.receiver===o.receiver&&d.sender===o.sender||i.swaps.length>0&&(s.push(i),i=c.cloneDeep(Rr),i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"))),i.swaps.push(d.swap),i.opRef.push(...d.opRef),i.fromInternal=d.fromInternal,i.toInternal=d.toInternal,i.sender=d.sender,i.receiver=d.receiver,d.hasTokenIn?(i.hasTokenIn=!0,i.limits[d.swap.assetInIndex]=i.limits[d.swap.assetInIndex].add(d.amountIn)):i.limits[d.swap.assetInIndex]=a.MaxInt256,d.hasTokenOut&&(i.hasTokenOut=!0,i.limits[d.swap.assetOutIndex]=i.limits[d.swap.assetOutIndex].sub(d.minOut)),o=d):(i.swaps.length>0&&(s.push(i),i=c.cloneDeep(Rr),i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"))),s.push(d));return i.swaps.length>0&&s.push(i),s}(s,t);return i}function jr(e,t,a,n,s,i,r,o){var d;const c=Vr(t,a,e.assetInIndex,e.assetOutIndex),l=$r(e,Cr.Join,c,n),p=Wr(null!==(d=e.returnAmount)&&void 0!==d?d:"0",i),[u,b]=qr(c,e.assetOutIndex,n);let y=o,m=!0,f=!1;c!==Nr.Direct&&c!==Nr.TokenIn||(y=r,m=!1,f=!0);let h=o,T=!1;c!==Nr.Direct&&c!==Nr.TokenOut||(h=r,T=!0);return[{type:Cr.Join,poolId:e.poolId,tokenIn:s[e.assetInIndex],bpt:s[e.assetOutIndex],opRef:u,minOut:p,amountIn:l,assets:s,actionStep:c,sender:y,receiver:h,fromInternal:m,hasTokenIn:f,hasTokenOut:T},b]}function Kr(e,t,a,n,s,i,r,o){var d;const c=Vr(t,a,e.assetInIndex,e.assetOutIndex),l=$r(e,Cr.Exit,c,n),p=Wr(null!==(d=e.returnAmount)&&void 0!==d?d:"0",i),[u,b]=qr(c,e.assetOutIndex,n);let y=o,m=!1;c!==Nr.Direct&&c!==Nr.TokenIn||(y=r,m=!0);let f=!1,h=!0,T=o;c!==Nr.Direct&&c!==Nr.TokenOut||(T=r,h=!1,f=!0);return[{type:Cr.Exit,poolId:e.poolId,tokenOut:s[e.assetOutIndex],bpt:s[e.assetInIndex],opRef:u.key?[u]:[],minOut:p,amountIn:l,assets:s,actionStep:c,sender:y,receiver:T,toInternal:h,hasTokenIn:m,hasTokenOut:f},b]}function Zr(e,t,a,n,s,i,r,o,d){var c;const l=Vr(t,a,e.assetInIndex,e.assetOutIndex),p=$r(e,Cr.Swap,l,n);e.amount=p;const u=Wr(null!==(c=e.returnAmount)&&void 0!==c?c:"0",i),[b,y]=qr(l,e.assetOutIndex,n),m=l===Nr.Direct||l===Nr.TokenIn,f=l===Nr.Direct||l===Nr.TokenOut,h=Lr(r,s[e.assetInIndex]);let T=!0;(m||h)&&(T=!1);let g,I,E=!0;(f||Lr(r,s[e.assetOutIndex]))&&(E=!1),g=m?o:d,I=f?o:d;return[{type:Cr.Swap,opRef:b.key?[b]:[],minOut:u,amountIn:p,assets:s,swap:e,hasTokenIn:m,hasTokenOut:f,fromInternal:T,toInternal:E,isBptIn:h,sender:g,receiver:I},y]}function Xr(e,t,a){const n=e.tokensList,s=new W(a),[i]=s.sortTokens(n),r=t.tokenOut,o=i.findIndex((e=>e.toLowerCase()===r.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.minOut;const c=t.amountIn,l={assets:i,minAmountsOut:d,userData:P.exitExactBPTInForOneTokenOut(c,o),toInternalBalance:t.toInternal,poolId:t.poolId,poolKind:0,sender:t.sender,recipient:t.receiver,outputReferences:t.opRef,exitPoolRequest:{}},p=cs.constructExitCall(l),u=t.hasTokenOut?d[o]:"0";return[p,t.hasTokenIn?c:"0",u]}function Jr(e,t,a){const n=e.tokensList,s=new W(a),[i]=s.sortTokens(n),r=t.tokenIn,o=i.findIndex((e=>e.toLowerCase()===r.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.amountIn;const c=t.minOut,l=P.joinExactTokensInForBPTOut(d,c),p={poolId:t.poolId,sender:t.sender,recipient:t.receiver,kind:0,joinPoolRequest:{assets:i,maxAmountsIn:d,userData:l,fromInternalBalance:t.fromInternal},value:"0",outputReference:t.opRef.key?t.opRef.key.toString():"0"},u=cs.encodeJoinPool(p),b=t.hasTokenOut?c:"0";return[u,t.hasTokenIn?d[o]:"0",b]}function Yr(t,s,i){const r=[];for(const e of t.approveTokens){const t=cs.encodeApproveVault(e,a.MaxUint256.toString());r.push(t)}const o={sender:t.sender,recipient:t.receiver,fromInternalBalance:t.fromInternal,toInternalBalance:t.toInternal},d={swapType:e.SwapType.SwapExactIn,swaps:t.swaps,assets:t.assets,funds:o,limits:t.limits.map((e=>e.toString())),deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:t.opRef},c=cs.encodeBatchSwap(d);r.push(c);const l=t.assets.findIndex((e=>e.toLowerCase()===s.toLowerCase())),p=t.assets.findIndex((e=>e.toLowerCase()===i.toLowerCase()));return[r,t.hasTokenIn?t.limits[l].toString():"0",t.hasTokenOut?t.limits[p].abs().toString():"0"]}Object.defineProperty(e,"PoolFilter",{enumerable:!0,get:function(){return l.PoolFilter}}),Object.defineProperty(e,"RouteProposer",{enumerable:!0,get:function(){return l.RouteProposer}}),Object.defineProperty(e,"SOR",{enumerable:!0,get:function(){return l.SOR}}),Object.defineProperty(e,"SwapTypes",{enumerable:!0,get:function(){return l.SwapTypes}}),Object.defineProperty(e,"formatSequence",{enumerable:!0,get:function(){return l.formatSequence}}),Object.defineProperty(e,"getTokenAddressesForSwap",{enumerable:!0,get:function(){return l.getTokenAddressesForSwap}}),Object.defineProperty(e,"parseToPoolsDict",{enumerable:!0,get:function(){return l.parseToPoolsDict}}),Object.defineProperty(e,"phantomStableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.phantomStableBPTForTokensZeroPriceImpact}}),Object.defineProperty(e,"queryBatchSwapTokensIn",{enumerable:!0,get:function(){return l.queryBatchSwapTokensIn}}),Object.defineProperty(e,"queryBatchSwapTokensOut",{enumerable:!0,get:function(){return l.queryBatchSwapTokensOut}}),Object.defineProperty(e,"stableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.stableBPTForTokensZeroPriceImpact}}),Object.defineProperty(e,"weightedBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.weightedBPTForTokensZeroPriceImpact}}),e.APR_THRESHOLD=1e4,e.AaveHelpers=class{static async getRate(e,t){const a=new i.Contract(e,G,t);return(await a.getRate()).toString()}},e.AaveRates=Vi,e.AssetHelpers=W,e.BalancerAPIArgsFormatter=He,e.BalancerError=st,e.BalancerErrors=V,e.BalancerMinterAuthorization=Z,e.BalancerSDK=class{constructor(e,t=new jn(e),a=new ls(e)){this.config=e,this.sor=t,this.subgraph=a,this.networkConfig=Hn(e),this.provider=t.provider,this.data=new Fr(this.networkConfig,t.provider,e.subgraphQuery),this.swaps=new os(this.config),this.relayer=new cs(this.swaps),this.pricing=new ps(e,this.swaps),this.pools=new Ti(this.networkConfig,this.data),this.balancerContracts=new ws(this.networkConfig.addresses.contracts,t.provider),this.zaps=new Hs(this.networkConfig.chainId)}get rpcProvider(){return this.sor.provider}get contracts(){return this.balancerContracts.contracts}},e.BlockNumberRepository=kr,e.CoingeckoHistoricalPriceRepository=Ui,e.CoingeckoPriceRepository=Li,e.ComposableStablePoolEncoder=v,e.Data=Fr,e.Debouncer=Ue,e.FeeCollectorRepository=zi,e.FeeDistributorRepository=Zi,e.GaugeControllerMulticallRepository=Ii,e.GaugeSharesRepository=Ai,e.GraphQLArgsBuilder=Ke,e.HistoricalPriceProvider=Wi,e.Liquidity=$t,e.LiquidityGaugeSubgraphRPCProvider=Oi,e.LiquidityGaugesMulticallRepository=Pi,e.LiquidityGaugesSubgraphRepository=Bi,e.ManagedPoolEncoder=B,e.POOLS=function(e){return U[e]?U[e]:L},e.PoolGaugesRepository=Ci,e.PoolJoinExitRepository=Fi,e.PoolSharesRepository=Ri,e.Pools=Ti,e.PoolsBalancerAPIRepository=class{constructor(e){var t,a;this.pools=[],this.skip=0,this.client=new vi(e.url,e.apiKey);this.query={args:Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||{orderBy:"totalLiquidity",orderDirection:"desc",where:{swapEnabled:{eq:!0}}}),attrs:Object.assign({},(null===(a=e.query)||void 0===a?void 0:a.attrs)||{id:!0,address:!0})},delete this.query.args.skip}fetchFromCache(e){const t=(null==e?void 0:e.first)||10,a=(null==e?void 0:e.skip)||0,n=this.pools.slice(a,t+a);return this.skip=a+t,n}async fetch(e){if(this.pools.length>((null==e?void 0:e.first)||10)+((null==e?void 0:e.skip)||0))return this.fetchFromCache(e);this.nextToken&&(this.query.args.nextToken=this.nextToken),(null==e?void 0:e.first)&&(this.query.args.first=2*e.first);const t=new Ke(this.query.args).format(new He),a=this.query.attrs;a.nextToken=!0;const n={pools:{__args:t,...a}},s=(await this.client.get(n)).pools;return this.nextToken=s.nextToken,this.pools=this.pools.concat(s.pools.map(this.format)),this.skip=this.pools.length,this.fetchFromCache(e)}async find(e){return 0==this.pools.length&&await this.fetch(),this.findBy("id",e)}async findBy(e,t){0==this.pools.length&&await this.fetch();const a=this.pools.find((a=>a[e]==t));if(a)return this.format(a)}format(e){var t,a,n,s;if(null===(t=e.apr)||void 0===t?void 0:t.rewardAprs.breakdown){const t=JSON.parse(null===(a=e.apr)||void 0===a?void 0:a.rewardAprs.breakdown);e.apr.rewardAprs.breakdown=t}if(null===(n=e.apr)||void 0===n?void 0:n.tokenAprs.breakdown){const t=JSON.parse(null===(s=e.apr)||void 0===s?void 0:s.tokenAprs.breakdown);e.apr.tokenAprs.breakdown=t}return e}},e.PoolsFallbackRepository=class{constructor(e,t={}){this.providers=e,this.currentProviderIdx=0,this.timeout=t.timeout||1e4}async fetch(e){return this.fallbackQuery("fetch",[e])}get currentProvider(){if(this.providers.length&&!(this.currentProviderIdx>=this.providers.length))return this.providers[this.currentProviderIdx]}async find(e){return this.fallbackQuery("find",[e])}async findBy(e,t){return this.fallbackQuery("findBy",[e,t])}async fallbackQuery(e,t){if(this.currentProviderIdx>=this.providers.length)throw new Error("No working providers found");let a;try{const n=this.providers[this.currentProviderIdx];a=await Promise.race([n[e].apply(n,t),new Promise(((e,t)=>setTimeout((()=>t(new Error("timeout"))),this.timeout)))])}catch(n){const s=n.message;"timeout"===s?console.error("Provider "+this.currentProviderIdx+" timed out, falling back to next provider"):console.error("Provider "+this.currentProviderIdx+" failed with error: ",s,", falling back to next provider"),this.currentProviderIdx++,a=await this.fallbackQuery.call(this,e,t)}return a}},e.PoolsStaticRepository=class{constructor(e){this.pools=e}async find(e){return this.pools.find((t=>t.id.toLowerCase()===e.toLowerCase()))}async findBy(e,t){return this.pools.find((a=>a[e]===t))}async all(){return this.pools}async where(e){return(await this.all()).filter(e)}},e.PoolsSubgraphOnChainRepository=Ni,e.PoolsSubgraphRepository=ki,e.ProtocolFeesProvider=tr,e.Relayer=cs,e.RelayerAuthorization=K,e.SHALLOW_COMPOSABLE_STABLE_BUFFER=1e6,e.Sor=jn,e.StablePoolEncoder=S,e.StaticTokenPriceProvider=class{constructor(e){this.tokenPrices=Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLowerCase(),t])))}async find(e){const t=e.toLowerCase(),a=this.tokenPrices[t];if(a)return a}async findBy(e,t){if("address"==e)return this.find(t)}},e.StaticTokenProvider=Mi,e.Subgraph=ls,e.SubgraphArgsFormatter=je,e.SubgraphPriceRepository=Gi,e.Swaps=os,e.TokenPriceProvider=qi,e.TokenYieldsRepository=_r,e.WeightedPoolEncoder=P,e.accountToAddress=H,e.addressMapIn=Me,e.balEmissions=Js,e.bn=e=>n.parseFixed(`${e}`,18),e.buildRelayerCalls=function(t,a,s,i,r,o,d){const c=Hr(function(e,t,a,n,s,i,r,o){const d=n.findIndex((t=>t.toLowerCase()===e.toLowerCase())),c=n.findIndex((e=>e.toLowerCase()===t.toLowerCase())),l=[];let p=0,u={};for(const e of a)if(Ur(e,n)){const[t,a]=jr(e,d,c,p,n,s,r,o);p=a,l.push(t),u=t}else{if(!Gr(e,n)){const t=e.amount,[a,b]=Zr(e,d,c,p,n,s,i,r,o);u.type===Cr.Swap&&"0"===t&&(u.receiver=u.sender,u.toInternal=u.fromInternal,u.opRef=[],a.sender=u.receiver,a.fromInternal=u.fromInternal,a.amountIn="0",a.swap.amount="0"),p=b,l.push(a),u=a;continue}{const[t,a]=Kr(e,d,c,p,n,s,r,o);p=a,l.push(t),u=t}}return l}(t.tokenIn,t.tokenOut,t.swaps,t.tokenAddresses,o,a,s,i),t.tokenAddresses),l=[],p=[],u=[];d&&l.push(function(e,t){return cs.encodeSetRelayerApproval(t,!0,e)}(d,i));for(const s of c){if(s.type===Cr.Exit){const t=a.find((e=>e.id===s.poolId));if(void 0===t)throw new st(e.BalancerErrorCode.NO_POOL_DATA);const[i,o,d]=Xr(t,s,r);l.push(i),p.push(n.BigNumber.from(o)),u.push(n.BigNumber.from(d))}if(s.type===Cr.Join){const t=a.find((e=>e.id===s.poolId));if(void 0===t)throw new st(e.BalancerErrorCode.NO_POOL_DATA);const[i,o,d]=Jr(t,s,r);l.push(i),p.push(n.BigNumber.from(o)),u.push(n.BigNumber.from(d))}if(s.type===Cr.BatchSwap){const[e,a,i]=Yr(s,t.tokenIn,t.tokenOut);l.push(...e),p.push(n.BigNumber.from(a)),u.push(n.BigNumber.from(i))}}return function(t,a,s,i){const r=t.reduce(((e=n.BigNumber.from(0),t)=>e.add(t))),o=a.reduce(((e=n.BigNumber.from(0),t)=>e.add(t))),d=o.sub(ze(s.returnAmount,n.BigNumber.from(i)));if(!r.eq(s.swapAmount)||!d.lt("3"))throw new st(e.BalancerErrorCode.RELAY_SWAP_AMOUNTS)}(p,u,t,o),{to:i,data:Mr.encodeFunctionData("multicall",[l]),rawCalls:l}},e.canUseJoinExit=function(e,t,n){return e!==l.SwapTypes.SwapExactOut&&t.toLowerCase()!==a.AddressZero.toLowerCase()&&n.toLowerCase()!==a.AddressZero.toLowerCase()},e.formatFixed=qe,e.formatFromBigInt18=function(e){return n.formatFixed(n.BigNumber.from(e),18)},e.getLimitsForSlippage=Xe,e.getPoolAddress=D,e.getPoolNonce=R,e.getPoolSpecialization=F,e.insert=Ve,e.isNormalizedWeights=e=>{const t=e.reduce(((e,t)=>e.add(t)),a.Zero);return t.eq(a.WeiPerEther)},e.isSameAddress=$e,e.parseFixed=Ge,e.parsePoolInfo=se,e.parseToBigInt18=We,e.signPermit=async(e,t,s,i,o=a.MaxUint256,d)=>{const{chainId:c}=await e.provider.getNetwork(),l=await t.getAddress();d||(d=await e.nonces(l));const p={name:await e.name(),version:"1",chainId:c,verifyingContract:e.address},u={owner:l,spender:await H(s),value:i,nonce:d,deadline:o},b=await t._signTypedData(p,{Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u);return{...r.splitSignature(b),deadline:n.BigNumber.from(o),nonce:n.BigNumber.from(d)}},e.someJoinExit=function(e,t,a){return t.some((t=>function(e,t,a){const n=e.find((e=>e.id===t.poolId));return"Weighted"===(null==n?void 0:n.poolType)&&[a[t.assetInIndex],a[t.assetOutIndex]].includes(n.address)}(e,t,a)))},e.splitPoolId=e=>({address:D(e),specialization:F(e),nonce:R(e)}),e.toNormalizedWeights=function(e){if(100==e.length)return Array(100).fill(a.WeiPerEther.div(100));const t=e.reduce(((e,t)=>e.add(t)),a.Zero);if(t.eq(a.WeiPerEther))return e;const n=[];let s=a.Zero;for(let i=0;i<e.length;i++)i<e.length-1?(n[i]=e[i].mul(a.WeiPerEther).div(t),s=s.add(n[i])):n[i]=a.WeiPerEther.sub(s);return n},e.tokenAddressForPricing=Re,e.tokensToTokenPrices=function(e){const t={};return e.forEach((e=>{e.price&&(t[e.address]=e.price)})),t},e.unwrapToken=Le,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
488
|
+
`,vn=(e,t,a)=>e();function kn(e){return rn(new b.GraphQLClient(e))}function Nn(e){return function(e,t=vn){return{GaugeShare:(a,n)=>t((t=>e.request(Sn,a,{...n,...t})),"GaugeShare","query"),GaugeShares:(a,n)=>t((t=>e.request(Pn,a,{...n,...t})),"GaugeShares","query"),LiquidityGauges:(a,n)=>t((t=>e.request(Bn,a,{...n,...t})),"LiquidityGauges","query"),Pools:(a,n)=>t((t=>e.request(_n,a,{...n,...t})),"Pools","query"),PoolGauges:(a,n)=>t((t=>e.request(On,a,{...n,...t})),"PoolGauges","query")}}(new b.GraphQLClient(e))}const Cn=["function aggregate(tuple[](address target, bytes callData) memory calls) public view returns (uint256 blockNumber, bytes[] memory returnData)"],Dn=(e,t)=>new i.Contract(e,Cn,t);class Fn{constructor(e,a,n,s={}){this.options={},this.calls=[],this.paths=[],this.multiAddress=e,this.provider=a,this.interface=new t.Interface(n),this.options=s}call(e,t,a,n){return this.calls.push([t,a,n]),this.paths.push(e),this}async execute(e={}){const t=e;return(await this.executeMulticall()).forEach(((e,a)=>c.set(t,this.paths[a],e.length>1?e:e[0]))),this.calls=[],this.paths=[],t}async executeMulticall(){const e=Dn(this.multiAddress,this.provider),[,t]=await e.aggregate(this.calls.map((([e,t,a])=>[e,this.interface.encodeFunctionData(t,a)])),this.options);return t.map(((e,t)=>this.interface.decodeFunctionResult(this.calls[t][1],e)))}}var 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:"normalizedWeights",type:"uint256[]"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getNormalizedWeights",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"increaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"balanceTokenIn",type:"uint256"},{internalType:"uint256",name:"balanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Mn=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"startValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"}],name:"AmpUpdateStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"currentValue",type:"uint256"}],name:"AmpUpdateStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAmplificationParameter",outputs:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"isUpdating",type:"bool"},{internalType:"uint256",name:"precision",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"balanceTokenIn",type:"uint256"},{internalType:"uint256",name:"balanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"rawEndValue",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"}],name:"startAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"stopAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Ln=[{inputs:[{internalType:"contract IERC20",name:"_underlying",type:"address"},{internalType:"contract IERC20",name:"_bond",type:"address"},{internalType:"uint256",name:"_expiration",type:"uint256"},{internalType:"uint256",name:"_unitSeconds",type:"uint256"},{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"uint256",name:"_percentFee",type:"uint256"},{internalType:"uint256",name:"_percentFeeGov",type:"uint256"},{internalType:"address",name:"_governance",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"collectedBase",type:"uint256"},{indexed:!1,internalType:"uint256",name:"collectedBond",type:"uint256"},{indexed:!1,internalType:"uint256",name:"remainingBase",type:"uint256"},{indexed:!1,internalType:"uint256",name:"remainingBond",type:"uint256"}],name:"FeeCollection",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"FEE_BOUND",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"bond",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"bondDecimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"expiration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"feesBond",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"feesUnderlying",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"governance",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"increaseApproval",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"currentBalances",type:"uint256[]"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"protocolSwapFee",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"},{internalType:"uint256[]",name:"dueProtocolFeeAmounts",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"currentBalances",type:"uint256[]"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"protocolSwapFee",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"},{internalType:"uint256[]",name:"dueProtocolFeeAmounts",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256",name:"currentBalanceTokenIn",type:"uint256"},{internalType:"uint256",name:"currentBalanceTokenOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"percentFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"percentFeeGov",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountX",type:"uint256"},{internalType:"uint256",name:"reserveX",type:"uint256"},{internalType:"uint256",name:"reserveY",type:"uint256"},{internalType:"bool",name:"out",type:"bool"}],name:"solveTradeInvariant",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"underlying",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"underlyingDecimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"unitSeconds",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],Un=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20",name:"mainToken",type:"address"},{internalType:"contract IERC20",name:"wrappedToken",type:"address"},{internalType:"uint256",name:"upperTarget",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract IERC20",name:"token",type:"address"},{indexed:!1,internalType:"uint256",name:"lowerTarget",type:"uint256"},{indexed:!1,internalType:"uint256",name:"upperTarget",type:"uint256"}],name:"TargetsSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBptIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMainIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMainToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getScalingFactors",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getTargets",outputs:[{internalType:"uint256",name:"lowerTarget",type:"uint256"},{internalType:"uint256",name:"upperTarget",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVirtualSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getWrappedTokenRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"request",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"paused",type:"bool"}],name:"setPaused",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newLowerTarget",type:"uint256"},{internalType:"uint256",name:"newUpperTarget",type:"uint256"}],name:"setTargets",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Gn=[{inputs:[{components:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IProtocolFeePercentagesProvider",name:"protocolFeeProvider",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"contract IRateProvider[]",name:"rateProviders",type:"address[]"},{internalType:"uint256[]",name:"tokenRateCacheDurations",type:"uint256[]"},{internalType:"bool[]",name:"exemptFromYieldProtocolFeeFlags",type:"bool[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],internalType:"struct ComposableStablePool.NewPoolParams",name:"params",type:"tuple"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"startValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endValue",type:"uint256"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"}],name:"AmpUpdateStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"currentValue",type:"uint256"}],name:"AmpUpdateStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"paused",type:"bool"}],name:"PausedStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"feeType",type:"uint256"},{indexed:!1,internalType:"uint256",name:"protocolFeePercentage",type:"uint256"}],name:"ProtocolFeePercentageCacheUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"enabled",type:"bool"}],name:"RecoveryModeStateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"SwapFeePercentageChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenIndex",type:"uint256"},{indexed:!1,internalType:"uint256",name:"rate",type:"uint256"}],name:"TokenRateCacheUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenIndex",type:"uint256"},{indexed:!0,internalType:"contract IRateProvider",name:"provider",type:"address"},{indexed:!1,internalType:"uint256",name:"cacheDuration",type:"uint256"}],name:"TokenRateProviderSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"disableRecoveryMode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"enableRecoveryMode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getActualSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAmplificationParameter",outputs:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"isUpdating",type:"bool"},{internalType:"uint256",name:"precision",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBptIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDomainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastJoinExitData",outputs:[{internalType:"uint256",name:"lastJoinExitAmplification",type:"uint256"},{internalType:"uint256",name:"lastPostJoinExitInvariant",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMinimumBpt",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"getNextNonce",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPausedState",outputs:[{internalType:"bool",name:"paused",type:"bool"},{internalType:"uint256",name:"pauseWindowEndTime",type:"uint256"},{internalType:"uint256",name:"bufferPeriodEndTime",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPoolId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"feeType",type:"uint256"}],name:"getProtocolFeePercentageCache",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProtocolFeesCollector",outputs:[{internalType:"contract IProtocolFeesCollector",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProtocolSwapFeeDelegation",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRateProviders",outputs:[{internalType:"contract IRateProvider[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getScalingFactors",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSwapFeePercentage",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"getTokenRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"getTokenRateCache",outputs:[{internalType:"uint256",name:"rate",type:"uint256"},{internalType:"uint256",name:"oldRate",type:"uint256"},{internalType:"uint256",name:"duration",type:"uint256"},{internalType:"uint256",name:"expires",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"inRecoveryMode",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"isTokenExemptFromYieldProtocolFee",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onExitPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"onJoinPool",outputs:[{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IERC20",name:"tokenIn",type:"address"},{internalType:"contract IERC20",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IPoolSwapStructs.SwapRequest",name:"swapRequest",type:"tuple"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"indexIn",type:"uint256"},{internalType:"uint256",name:"indexOut",type:"uint256"}],name:"onSwap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryExit",outputs:[{internalType:"uint256",name:"bptIn",type:"uint256"},{internalType:"uint256[]",name:"amountsOut",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256[]",name:"balances",type:"uint256[]"},{internalType:"uint256",name:"lastChangeBlock",type:"uint256"},{internalType:"uint256",name:"protocolSwapFeePercentage",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],name:"queryJoin",outputs:[{internalType:"uint256",name:"bptOut",type:"uint256"},{internalType:"uint256[]",name:"amountsIn",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"bytes",name:"poolConfig",type:"bytes"}],name:"setAssetManagerPoolConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"swapFeePercentage",type:"uint256"}],name:"setSwapFeePercentage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"uint256",name:"duration",type:"uint256"}],name:"setTokenRateCacheDuration",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"rawEndValue",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"}],name:"startAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"stopAmplificationParameterUpdate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"updateProtocolFeePercentageCache",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"}],name:"updateTokenRateCache",outputs:[],stateMutability:"nonpayable",type:"function"}];async function qn(e,t,a,s){if(0===e.length)return e;const i=Object.values(Object.fromEntries([...p.Vault__factory.abi,...G,...Rn,...Mn,...Ln,...Un,...Gn].map((e=>[e.name,e])))),r=new Fn(t,s,i),o=Object.values(l.PoolFilter),d=[];e.forEach((e=>{o.includes(e.poolType)?(d.push(e),r.call(`${e.id}.poolTokens`,a,"getPoolTokens",[e.id]),r.call(`${e.id}.totalSupply`,e.address,"totalSupply"),(e.poolType.includes("Linear")||"StablePhantom"===e.poolType)&&r.call(`${e.id}.virtualSupply`,e.address,"getVirtualSupply"),"ComposableStable"===e.poolType&&r.call(`${e.id}.actualSupply`,e.address,"getActualSupply"),"Weighted"===e.poolType||"LiquidityBootstrapping"===e.poolType||"Investment"===e.poolType?(r.call(`${e.id}.weights`,e.address,"getNormalizedWeights"),r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Stable"===e.poolType||"MetaStable"===e.poolType||"StablePhantom"===e.poolType||"ComposableStable"===e.poolType?(r.call(`${e.id}.amp`,e.address,"getAmplificationParameter"),r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):"Element"===e.poolType?r.call(`${e.id}.swapFee`,e.address,"percentFee"):e.poolType.toString().includes("Linear")?(r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage"),r.call(`${e.id}.targets`,e.address,"getTargets"),r.call(`${e.id}.rate`,e.address,"getWrappedTokenRate")):e.poolType.toString().includes("Gyro")&&r.call(`${e.id}.swapFee`,e.address,"getSwapFeePercentage")):console.error(`Unknown pool type: ${e.poolType} ${e.id}`)}));let c={};try{c=await r.execute()}catch(e){throw"Issue with multicall execution."}const u=[];return Object.entries(c).forEach((([e,t],a)=>{try{const{poolTokens:s,swapFee:i,weights:r,totalSupply:o,virtualSupply:c,actualSupply:l}=t;if("Stable"===d[a].poolType||"MetaStable"===d[a].poolType||"StablePhantom"===d[a].poolType||"ComposableStable"===d[a].poolType){if(!t.amp)return void console.error(`Stable Pool Missing Amp: ${e}`);d[a].amp=n.formatFixed(t.amp[0],3)}if(d[a].poolType.includes("Linear")){if(!t.targets)return void console.error(`Linear Pool Missing Targets: ${e}`);d[a].lowerTarget=n.formatFixed(t.targets[0],18),d[a].upperTarget=n.formatFixed(t.targets[1],18);const s=d[a].wrappedIndex;if(void 0===s||void 0===t.rate)return void console.error(`Linear Pool Missing WrappedIndex or PriceRate: ${e}`);d[a].tokens[s].priceRate=n.formatFixed(t.rate,18)}if(d[a].swapFee=n.formatFixed(i,18),s.tokens.forEach(((t,i)=>{const o=d[a].tokens.find((e=>$e(e.address,t)));if(!o)throw`Pool Missing Expected Token: ${e} ${t}`;o.balance=n.formatFixed(s.balances[i],o.decimals),r&&(o.weight=n.formatFixed(r[i],18))})),d[a].poolType.includes("Linear")||"StablePhantom"===d[a].poolType){if(void 0===c)return void console.error(`Pool with pre-minted BPT missing Virtual Supply: ${e}`);d[a].totalShares=n.formatFixed(c,18)}else if("ComposableStable"===d[a].poolType){if(void 0===l)return void console.error(`ComposableStable missing Actual Supply: ${e}`);d[a].totalShares=n.formatFixed(l,18)}else d[a].totalShares=n.formatFixed(o,18);u.push(d[a])}catch(e){throw`Issue with pool onchain data: ${e}`}})),u}class Wn{constructor(e,t,a,n){this.client=e,this.provider=t,this.network=a,this.sorConfig=n}async getPools(){const e=function(e){return e.map((e=>({...e,poolType:e.poolType||"",tokens:(e.tokens||[]).map((e=>({...e,weight:e.weight||null}))),totalWeight:e.totalWeight||void 0,amp:e.amp||void 0,expiryTime:e.expiryTime?c.parseInt(e.expiryTime):void 0,unitSeconds:e.unitSeconds?c.parseInt(e.unitSeconds):void 0,principalToken:e.principalToken||void 0,baseToken:e.baseToken||void 0})))}((await this.getSubgraphPools()).filter((e=>{if(!this.network.poolsToIgnore)return!0;return-1===this.network.poolsToIgnore.findIndex((t=>$e(t,e.address)))})));return!1===this.sorConfig.fetchOnChainBalances?e:qn(e,this.network.addresses.contracts.multicall,this.network.addresses.contracts.vault,this.provider)}async getSubgraphPools(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0,totalShares_gt:"0.000000000001"},orderBy:xa.TotalLiquidity,orderDirection:ha.Desc});return[...e,...t,...a]}}class $n{constructor(e){this.chainId=e}async getNativeAssetPriceInToken(e){const t=await this.getTokenPriceInNativeAsset(e);return""+1/parseFloat(t)}async getTokenPriceInNativeAsset(e){const t=`https://api.coingecko.com/api/v3/simple/token_price/${this.platformId}?contract_addresses=${e}&vs_currencies=${this.nativeAssetId}`,{data:a}=await x.default.get(t,{headers:{Accept:"application/json","Content-Type":"application/json"}});if(void 0===a[e.toLowerCase()][this.nativeAssetId])throw Error("No price returned from Coingecko");return a[e.toLowerCase()][this.nativeAssetId]}get platformId(){switch(this.chainId){case 1:case 42:case 248:case 16116:case 17117:return"ethereum";case 137:return"polygon-pos";case 42161:return"arbitrum-one";case 100:return"xdai"}return"3"}get nativeAssetId(){switch(this.chainId){case 1:case 42:case 42161:case 248:case 16116:case 17117:return"eth";case 137:return"";case 100:return"xdai"}return""}}class Vn{constructor(e,t){this.client=e,this.weth=t.toLowerCase()}async getNativeAssetPriceInToken(e){const t=await this.getLatestPriceInEthFromSubgraph(e);if(!t)throw Error("No price found in the subgraph");return""+1/t}async getLatestPriceInEthFromSubgraph(e){e=e.toLowerCase();const{latestPrices:t}=await this.client.TokenLatestPrices({where:{asset_in:[e,this.weth]}}),a=c.keyBy(t,"id");if(a[`${e}-${this.weth}`])return parseFloat(a[`${e}-${this.weth}`].price);const n=t.filter((t=>t.asset===e));for(const e of n){const t=a[`${e.pricingAsset}-${this.weth}`];if(t)return parseFloat(e.price)*parseFloat(t.price)}return null}}function Hn(e){var t,a;if("number"==typeof e.network){const a=tt[e.network];return{...a,urls:{...a.urls,subgraph:null!==(t=e.customSubgraphUrl)&&void 0!==t?t:a.urls.subgraph},tenderly:e.tenderly}}return{...e.network,urls:{...e.network.urls,subgraph:null!==(a=e.customSubgraphUrl)&&void 0!==a?a:e.network.urls.subgraph},tenderly:e.network.tenderly}}class jn extends l.SOR{constructor(e){const t=Hn(e),a=jn.getSorConfig(e),n=jn.getSorNetworkConfig(t),s=new u.JsonRpcProvider(e.rpcUrl,e.network),i=kn(t.urls.subgraph);super(s,n,jn.getPoolDataService(t,a,s,i),jn.getTokenPriceService(t,a,i))}static getSorConfig(e){return{tokenPriceService:"coingecko",poolDataService:"subgraph",fetchOnChainBalances:!0,...e.sor}}static getSorNetworkConfig(e){var t;return{...e,vault:e.addresses.contracts.vault,weth:e.addresses.tokens.wrappedNativeAsset,lbpRaisingTokens:null===(t=e.addresses.tokens)||void 0===t?void 0:t.lbpRaisingTokens,wETHwstETH:e.pools.wETHwstETH,connectingTokens:e.sorConnectingTokens}}static getPoolDataService(e,t,a,n){return"object"==typeof t.poolDataService?t.poolDataService:new Wn(n,a,e,t)}static getTokenPriceService(e,t,a){return"object"==typeof t.tokenPriceService?t.tokenPriceService:("subgraph"===t.tokenPriceService&&new Vn(a,e.addresses.tokens.wrappedNativeAsset),new $n(e.chainId))}}function Kn(e){if(e.poolIds.length>2)throw new Error("Simple flash swap only supports a maximum of two pools");if(e.assets.length>2)throw new Error("Simple flash swap only supports a maximum of to two assets (tokens)")}function Zn(e,t){return[{poolId:e[0],assetInIndex:0,assetOutIndex:1,amount:t,userData:"0x"},{poolId:e[1],assetInIndex:1,assetOutIndex:0,amount:"0",userData:"0x"}]}function Xn(e){return-1*Number(e)}function Jn(e){return c.sum(e)}var Yn=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IERC20",name:"wstETH",type:"address"},{internalType:"contract IBalancerMinter",name:"minter",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"contract IERC20",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approveVault",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"assetInIndex",type:"uint256"},{internalType:"uint256",name:"assetOutIndex",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.BatchSwapStep[]",name:"swaps",type:"tuple[]"},{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"int256[]",name:"limits",type:"int256[]"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{components:[{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"key",type:"uint256"}],internalType:"struct VaultActions.OutputReference[]",name:"outputReferences",type:"tuple[]"}],name:"batchSwap",outputs:[{internalType:"int256[]",name:"",type:"int256[]"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum VaultActions.PoolKind",name:"kind",type:"uint8"},{internalType:"address",name:"sender",type:"address"},{internalType:"address payable",name:"recipient",type:"address"},{components:[{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{internalType:"uint256[]",name:"minAmountsOut",type:"uint256[]"},{internalType:"bytes",name:"userData",type:"bytes"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.ExitPoolRequest",name:"request",type:"tuple"},{components:[{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"key",type:"uint256"}],internalType:"struct VaultActions.OutputReference[]",name:"outputReferences",type:"tuple[]"}],name:"exitPool",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge[]",name:"gauges",type:"address[]"}],name:"gaugeClaimRewards",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge",name:"gauge",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"gaugeDeposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address[]",name:"gauges",type:"address[]"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"gaugeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bool",name:"approval",type:"bool"},{internalType:"address",name:"user",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"gaugeSetMinterApproval",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStakingLiquidityGauge",name:"gauge",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"gaugeWithdraw",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"getEntrypoint",outputs:[{internalType:"contract IBalancerRelayer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum VaultActions.PoolKind",name:"kind",type:"uint8"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{components:[{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{internalType:"uint256[]",name:"maxAmountsIn",type:"uint256[]"},{internalType:"bytes",name:"userData",type:"bytes"},{internalType:"bool",name:"fromInternalBalance",type:"bool"}],internalType:"struct IVault.JoinPoolRequest",name:"request",type:"tuple"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"joinPool",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"enum IVault.UserBalanceOpKind",name:"kind",type:"uint8"},{internalType:"contract IAsset",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"sender",type:"address"},{internalType:"address payable",name:"recipient",type:"address"}],internalType:"struct IVault.UserBalanceOp[]",name:"ops",type:"tuple[]"},{internalType:"uint256",name:"value",type:"uint256"}],name:"manageUserBalance",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"ref",type:"uint256"}],name:"peekChainedReferenceValue",outputs:[{internalType:"uint256",name:"value",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"relayer",type:"address"},{internalType:"bool",name:"approved",type:"bool"},{internalType:"bytes",name:"authorisation",type:"bytes"}],name:"setRelayerApproval",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"stakeETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"stakeETHAndWrap",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IAsset",name:"assetIn",type:"address"},{internalType:"contract IAsset",name:"assetOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.SingleSwap",name:"singleSwap",type:"tuple"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"uint256",name:"limit",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"swap",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStaticATokenLM",name:"staticToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"toUnderlying",type:"bool"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapAaveStaticToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC4626",name:"wrappedToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapERC4626",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IUnbuttonToken",name:"wrapperToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapUnbuttonToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"unwrapWstETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC20Permit",name:"token",type:"address"},{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"vaultPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC20PermitDAI",name:"token",type:"address"},{internalType:"address",name:"holder",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"bool",name:"allowed",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"vaultPermitDAI",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IStaticATokenLM",name:"staticToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"fromUnderlying",type:"bool"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapAaveDynamicToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IERC4626",name:"wrappedToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapERC4626",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapStETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract IUnbuttonToken",name:"wrapperToken",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"uAmount",type:"uint256"},{internalType:"uint256",name:"outputReference",type:"uint256"}],name:"wrapUnbuttonToken",outputs:[],stateMutability:"payable",type:"function"}];const zn={"0xae7ab96520de3a18e5e111b5eaab095312d7fe84":"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0","0xd46ba6d942050d489dbd938a2c909a5d5039a161":"0xedb171c18ce90b633db442f2a6f72874093b49ef","0x1e6bb68acec8fefbd87d192be09bb274170a0548":"0xF03387d8d0FF326ab586A58E0ab4121d106147DF"};function Qn(e){let t=e;return zn.hasOwnProperty(e)&&(t=zn[e]),t}var es;function ts(e,t,a){const{tokens:n,contracts:s}=at(a);let i={id:es.vault,address:s.vault};return n.stETH&&s.lidoRelayer&&[e,t].includes(n.stETH)&&(i={id:es.lido,address:s.lidoRelayer}),i}function as(e){let t=p.Vault__factory.abi;e.id===es.lido&&(t=Yn);return t.filter((e=>e.name&&["swap","batchSwap"].includes(e.name)))}function ns(e){return{amount:e,max:t=>e.mul(1e3+t).div(1e3),min:t=>e.mul(1e3-t).div(1e3)}}function ss(t,a){const n=a===e.SwapType.SwapExactIn?t.swapAmount:t.returnAmount,s=a===e.SwapType.SwapExactIn?t.returnAmount:t.swapAmount,i=a===e.SwapType.SwapExactIn?t.swapAmountForSwaps||t.swapAmount:t.returnAmountFromSwaps||t.returnAmount,r=a===e.SwapType.SwapExactIn?t.returnAmountFromSwaps||t.returnAmount:t.swapAmountForSwaps||t.swapAmount,o=Qn(t.tokenIn),d=Qn(t.tokenOut);return{...t,amountIn:n,amountOut:s,amountInForLimits:ns(i),amountOutForLimits:ns(r),tokenInForSwaps:o,tokenOutFromSwaps:d}}!function(e){e[e.vault=1]="vault",e[e.lido=2]="lido"}(es||(es={}));class is{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="swap",this.swapInfo=ss(e,t),this.relayer=ts(this.swapInfo.tokenIn,this.swapInfo.tokenOut,this.chainId)}setFunds(e,t){this.funds={sender:e,recipient:t||e,fromInternalBalance:!1,toInternalBalance:!1}}setDeadline(e){this.deadline=e.toString()}get amount(){return this.kind===e.SwapType.SwapExactOut?this.swapInfo.amountOutForLimits.amount:this.swapInfo.amountInForLimits.amount}setLimits(t){this.limit=this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(t).toString():this.swapInfo.amountInForLimits.max(t).toString()}get singleSwap(){return{poolId:this.swapInfo.swaps[0].poolId,kind:this.kind,assetIn:this.swapInfo.tokenInForSwaps,assetOut:this.swapInfo.tokenOutFromSwaps,amount:this.amount.toString(),userData:"0x"}}attributes(){var e;if(!this.funds||!this.limit||!this.deadline)throw new Error("Uninitialized arguments");let t={request:this.singleSwap,funds:this.funds,limit:this.limit,deadline:this.deadline};const a=this.fragment();return a[0].inputs&&(null===(e=a[0].inputs)||void 0===e?void 0:e.length)>4&&(t={...t,value:"0",outputReference:"0"}),t}data(){return new t.Interface(this.fragment()).encodeFunctionData("swap",Object.values(this.attributes()))}value(t){let s=n.BigNumber.from(0);return this.swapInfo.tokenIn===a.AddressZero&&(s=this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountIn:this.swapInfo.amountInForLimits.max(t)),s}to(){return this.relayer.address}fragment(){return as(this.relayer).filter((e=>e.name===this.functionName))}}class rs{constructor(e,t,a){this.kind=t,this.chainId=a,this.functionName="batchSwap",this.swapInfo=ss(e,t),this.relayer=ts(this.swapInfo.tokenIn,this.swapInfo.tokenOut,this.chainId)}setFunds(e,t){this.funds={sender:e,recipient:t||e,fromInternalBalance:!1,toInternalBalance:!1}}setDeadline(e){this.deadline=e}minAmountOut(t){return this.kind===e.SwapType.SwapExactIn?this.swapInfo.amountOutForLimits.min(t):this.swapInfo.amountOutForLimits.amount}maxAmountIn(t){return this.kind===e.SwapType.SwapExactOut?this.swapInfo.amountInForLimits.max(t):this.swapInfo.amountInForLimits.amount}setLimits(e){this.limits=this.swapInfo.tokenAddresses.map((t=>{let a=n.BigNumber.from(0);return t===this.swapInfo.tokenInForSwaps&&(a=this.maxAmountIn(e)),t===this.swapInfo.tokenOutFromSwaps&&(a=this.minAmountOut(e).mul(-1)),a})).map((e=>e.toString().split(".")[0]))}attributes(){var e;if(!this.funds||!this.limits||!this.deadline)throw new Error("Uninitialized arguments");let t={kind:this.kind,swaps:this.swapInfo.swaps,assets:this.swapInfo.tokenAddresses,funds:this.funds,limits:this.limits,deadline:this.deadline};const a=this.fragment();return a[0].inputs&&(null===(e=a[0].inputs)||void 0===e?void 0:e.length)>6&&(t={...t,value:"0",outputReferences:[]}),t}data(){return new t.Interface(this.fragment()).encodeFunctionData("batchSwap",Object.values(this.attributes()))}value(e){let t=n.BigNumber.from(0);return this.swapInfo.tokenIn===a.AddressZero&&(t=this.maxAmountIn(e)),t}to(){return this.relayer.address}fragment(){return as(this.relayer).filter((e=>e.name===this.functionName))}}class os{constructor(e){e instanceof l.SOR?(this.sor=e,this.chainId=this.sor.provider._network.chainId):(this.sor=new jn(e),this.chainId=e.network),this.vaultContract=p.Vault__factory.connect(et,this.sor.provider)}static getLimitsForSlippage(e,t,a,n,s,i){return Xe(e,t,a,n,s,i).map((e=>e.toString()))}async findRouteGivenIn({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s=4}){return this.sor.getSwaps(e,t,l.SwapTypes.SwapExactIn,a,{gasPrice:n,maxPools:s})}async findRouteGivenOut({tokenIn:e,tokenOut:t,amount:a,gasPrice:n,maxPools:s}){return this.sor.getSwaps(e,t,l.SwapTypes.SwapExactOut,a,{gasPrice:n,maxPools:s})}buildSwap({userAddress:e,recipient:t,swapInfo:a,kind:n,deadline:s,maxSlippage:i}){if(!this.chainId)throw"Missing network configuration";const r=a.swaps.length>1?new rs(a,n,this.chainId):new is(a,n,this.chainId);r.setFunds(e,t),r.setDeadline(s),r.setLimits(i);const o=r.to(),{functionName:d}=r;return{to:o,functionName:d,attributes:r.attributes(),data:r.data(),value:r.value(i)}}static encodeBatchSwap(e){return p.Vault__factory.createInterface().encodeFunctionData("batchSwap",[e.kind,e.swaps,e.assets,e.funds,e.limits,e.deadline])}static encodeSimpleFlashSwap(t){return this.encodeBatchSwap(function({poolIds:t,assets:a,flashLoanAmount:n,walletAddress:s}){Kn({poolIds:t,assets:a});const i=Zn(t,n),r={sender:s,fromInternalBalance:!1,recipient:s,toInternalBalance:!1};return{kind:e.SwapType.SwapExactIn,swaps:i,assets:a,funds:r,limits:["0","0"],deadline:"999999999999999999"}}(t))}async fetchPools(){return this.sor.fetchPools()}getPools(){return this.sor.getPools()}async queryBatchSwap(e){return await Vt(this.vaultContract,e.kind,e.swaps,e.assets)}async queryBatchSwapWithSor(e){return await Ht(this.sor,this.vaultContract,e)}async querySimpleFlashSwap(t){return await async function(t){Kn(t);const[a,n]=t.assets;try{const s=await Vt(t.vaultContract,e.SwapType.SwapExactIn,Zn(t.poolIds,t.flashLoanAmount),t.assets),i={[a]:Xn(s[0]).toString(),[n]:Xn(s[1]).toString()};return{profits:i,isProfitable:Jn([i[a],i[n]])>0}}catch(e){throw`Failed to querySimpleFlashSwap: ${e}`}}({...t,vaultContract:this.vaultContract})}async getSorSwap(e){return await jt(e.tokenIn,e.tokenOut,e.swapType,e.amount,this.sor)}}const ds=new t.Interface(Yn);class cs{constructor(e){this.swaps=e instanceof os?e:new os(e)}static isChainedReference(e){const t=n.BigNumber.from(e),a=n.BigNumber.from("0xfff0000000000000000000000000000000000000000000000000000000000000"),s=t.toBigInt()&a.toBigInt();return"0xba10000000000000000000000000000000000000000000000000000000000000"===n.BigNumber.from(s)._hex.toString()}static encodeApproveVault(e,t){return ds.encodeFunctionData("approveVault",[e,t])}static encodeSetRelayerApproval(e,t,a){return ds.encodeFunctionData("setRelayerApproval",[e,t,a])}static encodeGaugeWithdraw(e,t,a,n){return ds.encodeFunctionData("gaugeWithdraw",[e,t,a,n])}static encodeGaugeDeposit(e,t,a,n){return ds.encodeFunctionData("gaugeDeposit",[e,t,a,n])}static encodeBatchSwap(e){return ds.encodeFunctionData("batchSwap",[e.swapType,e.swaps,e.assets,e.funds,e.limits,e.deadline,e.value,e.outputReferences])}static encodeExitPool(e){return ds.encodeFunctionData("exitPool",[e.poolId,e.poolKind,e.sender,e.recipient,e.exitPoolRequest,e.outputReferences])}static encodeJoinPool(e){return ds.encodeFunctionData("joinPool",[e.poolId,e.kind,e.sender,e.recipient,e.joinPoolRequest,e.value,e.outputReference])}static encodeWrapAaveDynamicToken(e){return ds.encodeFunctionData("wrapAaveDynamicToken",[e.staticToken,e.sender,e.recipient,e.amount,e.fromUnderlying,e.outputReference])}static encodeUnwrapAaveStaticToken(e){return ds.encodeFunctionData("unwrapAaveStaticToken",[e.staticToken,e.sender,e.recipient,e.amount,e.toUnderlying,e.outputReferences])}static encodePeekChainedReferenceValue(e){return ds.encodeFunctionData("peekChainedReferenceValue",[e])}static toChainedReference(e,t=!0){const a=t?cs.CHAINED_REFERENCE_TEMP_PREFIX:cs.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${a}${"0".repeat(64-a.length)}`;return n.BigNumber.from(s).add(e)}static fromChainedReference(e,t=!0){const a=t?cs.CHAINED_REFERENCE_TEMP_PREFIX:cs.CHAINED_REFERENCE_READONLY_PREFIX,s=`0x${a}${"0".repeat(64-a.length)}`;return n.BigNumber.from(e).sub(n.BigNumber.from(s))}static constructExitCall(e){const{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s,poolId:i,poolKind:r,sender:o,recipient:d,outputReferences:c}=e,l={poolId:i,poolKind:r,sender:o,recipient:d,outputReferences:c,exitPoolRequest:{assets:t,minAmountsOut:a,userData:n,toInternalBalance:s}};return cs.encodeExitPool(l)}static constructJoinCall(e){const{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s,poolId:i,kind:r,sender:o,recipient:d,value:c,outputReference:l}=e,p={poolId:i,kind:r,sender:o,recipient:d,value:c,outputReference:l,joinPoolRequest:{assets:t,maxAmountsIn:a,userData:n,fromInternalBalance:s}};return cs.encodeJoinPool(p)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async exitPoolAndBatchSwap(t){const s=a.WeiPerEther.sub(n.BigNumber.from(t.slippage)),i=t.expectedAmountsOut.map((e=>n.BigNumber.from(e).mul(s).div(a.WeiPerEther).toString())),r=[];t.exitTokens.forEach(((e,t)=>{const a=cs.toChainedReference(t);r.push({index:t,key:a})}));const o=cs.constructExitCall({assets:t.exitTokens,minAmountsOut:i,userData:t.userData,toInternalBalance:!0,poolId:t.poolId,poolKind:0,sender:t.exiter,recipient:t.exiter,outputReferences:r,exitPoolRequest:{}}),d=await this.swaps.queryBatchSwapWithSor({tokensIn:t.exitTokens,tokensOut:t.finalTokensOut,swapType:e.SwapType.SwapExactIn,amounts:i,fetchPools:t.fetchPools});if(d.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);d.swaps.forEach((e=>{const a=d.assets[e.assetInIndex],n=t.exitTokens.indexOf(a);-1!==n&&(e.amount=r[n].key.toString())}));const c=a.WeiPerEther.add(t.slippage);t.exitTokens.forEach(((e,s)=>{const i=d.assets.map((e=>e.toLowerCase())).indexOf(e.toLowerCase());-1!==i&&(d.deltas[i]=n.BigNumber.from(t.expectedAmountsOut[s]).mul(c).div(a.WeiPerEther).toString())}));const l=os.getLimitsForSlippage(t.exitTokens,t.finalTokensOut,e.SwapType.SwapExactIn,d.deltas,d.assets,"0"),p={sender:t.exiter,recipient:t.swapRecipient,fromInternalBalance:!0,toInternalBalance:!1};return{function:"multicall",params:[o,cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:d.swaps,assets:d.assets,funds:p,limits:l.map((e=>e.toString())),deadline:a.MaxUint256,value:"0",outputReferences:[]})],outputs:{amountsOut:d.returnAmounts}}}async swapUnwrapAaveStaticExactIn(t,s,i,r,o,d,c={fetchPools:!0,fetchOnChain:!1}){const l=await this.swaps.queryBatchSwapWithSor({tokensIn:t,tokensOut:s,swapType:e.SwapType.SwapExactIn,amounts:i,fetchPools:c});if(l.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const p=os.getLimitsForSlippage(t,s,e.SwapType.SwapExactIn,l.deltas,l.assets,d);return{function:"multicall",params:this.encodeSwapUnwrap(s,e.SwapType.SwapExactIn,l.swaps,l.assets,o,p),outputs:{amountsOut:l.returnAmounts.map(((t,s)=>{const i=n.BigNumber.from(t).abs().mul(r[s]).div(a.WeiPerEther);if(!i.gt(a.Zero))throw new st(e.BalancerErrorCode.UNWRAP_ZERO_AMOUNT);return i.toString()}))}}}async swapUnwrapAaveStaticExactOut(t,s,i,r,o,d,c={fetchPools:!0,fetchOnChain:!1}){const l=i.map(((t,s)=>{const i=n.BigNumber.from(t).mul(a.WeiPerEther).div(r[s]);if(!i.gt(a.Zero))throw new st(e.BalancerErrorCode.WRAP_ZERO_AMOUNT);return i.toString()})),p=await this.swaps.queryBatchSwapWithSor({tokensIn:t,tokensOut:s,swapType:e.SwapType.SwapExactOut,amounts:l,fetchPools:c});if(p.returnAmounts.includes("0"))throw new st(e.BalancerErrorCode.SWAP_ZERO_RETURN_AMOUNT);const u=os.getLimitsForSlippage(t,s,e.SwapType.SwapExactOut,p.deltas,p.assets,d);return{function:"multicall",params:this.encodeSwapUnwrap(s,e.SwapType.SwapExactOut,p.swaps,p.assets,o,u),outputs:{amountsIn:p.returnAmounts.map((e=>e.toString()))}}}encodeSwapUnwrap(e,t,n,s,i,r){const o=[],d=[];e.forEach(((e,t)=>{const a=s.findIndex((t=>t.toLowerCase()===e.toLowerCase()));if(-1===a)return;const n=cs.toChainedReference(t);o.push({index:a,key:n});const r=cs.encodeUnwrapAaveStaticToken({staticToken:e,sender:i.recipient,recipient:i.sender,amount:n,toUnderlying:!0,outputReferences:0});d.push(r)}));return[cs.encodeBatchSwap({swapType:t,swaps:n,assets:s,funds:i,limits:r.map((e=>e.toString())),deadline:a.MaxUint256,value:"0",outputReferences:o}),...d]}}cs.CHAINED_REFERENCE_TEMP_PREFIX="ba10",cs.CHAINED_REFERENCE_READONLY_PREFIX="ba11",cs.signRelayerApproval=async(e,t,n,s)=>{const i=s.interface.encodeFunctionData("setRelayerApproval",[t,e,!0]),r=await K.signSetRelayerApprovalAuthorization(s,n,e,i);return K.encodeCalldataAuthorization("0x",a.MaxUint256,r)};class ls{constructor(e){this.url=Hn(e).urls.subgraph,this.client=this.initClient()}initClient(){return rn(new b.GraphQLClient(this.url))}}class ps{constructor(e,t){this.swaps=t||new os(e)}async fetchPools(){return this.swaps.fetchPools()}getPools(){return this.swaps.getPools()}async getSpotPrice(t,a,n=[]){0===n.length&&(await this.fetchPools(),n=this.getPools());const s=l.parseToPoolsDict(n,0),i=this.swaps.sor.routeProposer.getCandidatePathsFromDict(t,a,0,s,4);if(0===i.length)throw new st(e.BalancerErrorCode.UNSUPPORTED_PAIR);return l.getSpotPriceAfterSwapForPath(i[0],0,l.ZERO).toString()}}var us=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}];function bs(e){return Math.round(Date.now()/1e3)-e<86400}var ys=[{name:"Deposit",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1},{name:"locktime",type:"uint256",indexed:!0},{name:"type",type:"int128",indexed:!1},{name:"ts",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Withdraw",inputs:[{name:"provider",type:"address",indexed:!0},{name:"value",type:"uint256",indexed:!1},{name:"ts",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{name:"Supply",inputs:[{name:"prevSupply",type:"uint256",indexed:!1},{name:"supply",type:"uint256",indexed:!1}],anonymous:!1,type:"event"},{stateMutability:"nonpayable",type:"constructor",inputs:[{name:"token_addr",type:"address"},{name:"_name",type:"string"},{name:"_symbol",type:"string"},{name:"_authorizer_adaptor",type:"address"}],outputs:[]},{stateMutability:"view",type:"function",name:"token",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string"}]},{stateMutability:"view",type:"function",name:"decimals",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"admin",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"nonpayable",type:"function",name:"commit_smart_wallet_checker",inputs:[{name:"addr",type:"address"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"apply_smart_wallet_checker",inputs:[],outputs:[]},{stateMutability:"view",type:"function",name:"get_last_user_slope",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"int128"}]},{stateMutability:"view",type:"function",name:"user_point_history__ts",inputs:[{name:"_addr",type:"address"},{name:"_idx",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"locked__end",inputs:[{name:"_addr",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"nonpayable",type:"function",name:"checkpoint",inputs:[],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"deposit_for",inputs:[{name:"_addr",type:"address"},{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"create_lock",inputs:[{name:"_value",type:"uint256"},{name:"_unlock_time",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"increase_amount",inputs:[{name:"_value",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"increase_unlock_time",inputs:[{name:"_unlock_time",type:"uint256"}],outputs:[]},{stateMutability:"nonpayable",type:"function",name:"withdraw",inputs:[],outputs:[]},{stateMutability:"view",type:"function",name:"balanceOf",inputs:[{name:"addr",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"balanceOf",inputs:[{name:"addr",type:"address"},{name:"_t",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"balanceOfAt",inputs:[{name:"addr",type:"address"},{name:"_block",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupply",inputs:[{name:"t",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"totalSupplyAt",inputs:[{name:"_block",type:"uint256"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"supply",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"locked",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"tuple",components:[{name:"amount",type:"int128"},{name:"end",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"epoch",inputs:[],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"point_history",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"tuple",components:[{name:"bias",type:"int128"},{name:"slope",type:"int128"},{name:"ts",type:"uint256"},{name:"blk",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"user_point_history",inputs:[{name:"arg0",type:"address"},{name:"arg1",type:"uint256"}],outputs:[{name:"",type:"tuple",components:[{name:"bias",type:"int128"},{name:"slope",type:"int128"},{name:"ts",type:"uint256"},{name:"blk",type:"uint256"}]}]},{stateMutability:"view",type:"function",name:"user_point_epoch",inputs:[{name:"arg0",type:"address"}],outputs:[{name:"",type:"uint256"}]},{stateMutability:"view",type:"function",name:"slope_changes",inputs:[{name:"arg0",type:"uint256"}],outputs:[{name:"",type:"int128"}]},{stateMutability:"view",type:"function",name:"future_smart_wallet_checker",inputs:[],outputs:[{name:"",type:"address"}]},{stateMutability:"view",type:"function",name:"smart_wallet_checker",inputs:[],outputs:[{name:"",type:"address"}]}];class ms{constructor(e,t){this.addresses=e,this.provider=t}async getLockInfo(e){if(!this.addresses.veBal)throw new Error("veBal address must be defined");const t=new Fn(this.addresses.multicall,this.provider,ys);t.call("locked",this.addresses.veBal,"locked",[e]),t.call("epoch",this.addresses.veBal,"epoch"),t.call("totalSupply",this.addresses.veBal,"totalSupply()");const a=await t.execute();return this.formatLockInfo(a)}formatLockInfo(e){const[t,a]=e.locked,n=t.gt(0),s=1e3*a.toNumber();const i=n&&Date.now()>s;return{lockedEndDate:s,lockedAmount:Pe(t),totalSupply:Pe(e.totalSupply),epoch:Pe(e.epoch,0),hasExistingLock:n,isExpired:i}}}var fs=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IERC20",name:"votingEscrow",type:"address"},{internalType:"contract IVeDelegation",name:"delegation",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newImplementation",type:"address"}],name:"DelegationImplementationUpdated",type:"event"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"adjustedBalanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"adjusted_balance_of",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDelegationImplementation",outputs:[{internalType:"contract IVeDelegation",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVotingEscrow",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"killDelegation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IVeDelegation",name:"delegation",type:"address"}],name:"setDelegation",outputs:[],stateMutability:"nonpayable",type:"function"}];class hs{constructor(e,t){if(!e.veBalProxy)throw new Error("veBalProxy address must be defined");this.instance=new i.Contract(e.veBalProxy,fs,t)}async getAdjustedBalance(e){return Pe(await this.instance.adjustedBalanceOf(e))}}var Ts=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"address",name:"libraryAddress",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"getLibrary",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}],gs=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"address",name:"libraryAddress",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"getLibrary",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}];const Is=(e,t,a)=>{switch(a){case 3:return new i.Contract(e,gs,t);case 4:return new i.Contract(e,Ts,t);default:throw new Error("relayer not supported")}};var Es=[{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 ws{constructor(e,t){this.contractAddresses="number"==typeof e?tt[e].addresses.contracts:e,this.vault=p.Vault__factory.connect(this.contractAddresses.vault,t),this.balancerHelpers=p.BalancerHelpers__factory.connect(this.contractAddresses.balancerHelpers,t),this.contractAddresses.lidoRelayer&&(this.lidoRelayer=p.LidoRelayer__factory.connect(this.contractAddresses.lidoRelayer,t)),this.multicall=Dn(this.contractAddresses.multicall,t),this.contractAddresses.relayerV3&&(this.relayerV3=Is(this.contractAddresses.relayerV3,t,3)),this.contractAddresses.relayerV4&&(this.relayerV4=Is(this.contractAddresses.relayerV4,t,4)),this.contractAddresses.veBal&&(this.veBal=new ms(this.contractAddresses,t)),this.contractAddresses.veBalProxy&&(this.veBalProxy=new hs(this.contractAddresses,t))}get contracts(){return{vault:this.vault,balancerHelpers:this.balancerHelpers,lidoRelayer:this.lidoRelayer,multicall:this.multicall,relayerV3:this.relayerV3,relayerV4:this.relayerV4,veBal:this.veBal,veBalProxy:this.veBalProxy,ERC20:this.getErc20,liquidityGauge:this.getLiquidityGauge}}getErc20(e,t){return((e,t)=>new i.Contract(e,us,t))(e,t)}getLiquidityGauge(e,t){return((e,t)=>new i.Contract(e,Es,t))(e,t)}}const xs={1:{relayer:"0x886A3Ec7bcC508B8795990B60Fa21f85F9dB7948",staBal3:{id:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063",address:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42",gauge:"0x34f33cdaed8ba0e1ceece80e5f4a73bcf234cfac",assetOrder:["DAI","USDC","USDT"]},bbausd1:{id:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe",address:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2",gauge:"0x68d019f64a7aa97e2d4e7363aee42251d08124fb",assetOrder:["bb-a-USDT","bb-a-DAI","bb-a-USDC"]},bbausd2:{id:"0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d",address:"0xa13a9247ea42d743238089903570127dda72fe44",gauge:"0xa6325e799d266632d347e41265a69af111b05403"},linearUsdc1:{id:"0x9210f1204b5a24742eba12f710636d76240df3d00000000000000000000000fc",address:"0x9210F1204b5a24742Eba12f710636D76240dF3d0"},linearDai1:{id:"0x804cdb9116a10bb78768d3252355a1b18067bf8f0000000000000000000000fb",address:"0x804CdB9116a10bB78768D3252355a1b18067bF8f"},linearUsdt1:{id:"0x2bbf681cc4eb09218bee85ea2a5d3d13fa40fc0c0000000000000000000000fd",address:"0x2BBf681cC4eb09218BEe85EA2a5d3D13Fa40fC0C"},linearUsdc2:{id:"0x82698AECC9E28E9BB27608BD52CF57F704BD1B83000000000000000000000336",address:"0x82698aeCc9E28e9Bb27608Bd52cF57f704BD1B83"},linearDai2:{id:"0xAE37D54AE477268B9997D4161B96B8200755935C000000000000000000000337",address:"0xae37D54Ae477268B9997d4161B96b8200755935c"},linearUsdt2:{id:"0x2F4EB100552EF93840D5ADC30560E5513DFFFACB000000000000000000000334",address:"0x2F4eb100552ef93840d5aDC30560E5513DFfFACb"},maiusd:{id:"",address:"",gauge:"",assetOrder:["USDT","miMATIC","DAI","USDC"]},maibbausd:{id:"",address:"",gauge:"",assetOrder:["bb-a-USD","miMATIC"]},DAI:"0x6b175474e89094c44da98b954eedeac495271d0f",USDC:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",waDAI:"0x02d60b84491589974263d922d9cc7a3152618ef6",waUSDC:"0xd093fa4fb80d09bb30817fdcd442d4d02ed3e5de",waUSDT:"0xf8fd466f12e236f4c96f7cce6c79eadb819abf58",miMATIC:""},5:{relayer:"0x7b9B6f094DC2Bd1c12024b0D9CC63d6993Be1888",staBal3:{id:"0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2000000000000000000000062",address:"0xdcdd4a3d36dec8d57594e89763d069a7e9b223e2",gauge:"0xfd364cda96bb7db06b65706182c448a73f0a5f9a",assetOrder:["USDT","DAI","USDC"]},staBal3_2:{id:"0xff9d677474d4344379924e10b68c8fea67e03294000000000000000000000072",address:"0xff9d677474d4344379924e10b68c8fea67e03294",gauge:"0x4e4ebf2aa90e41174d716a5168895357762d68af",assetOrder:["USDT","DAI","USDC"]},staBal3_3:{id:"0x3bfc8a0509f1a68aefd446f6c19bf37b3c75a8fc0000000000000000000000a5",address:"0x3bfc8a0509f1a68aefd446f6c19bf37b3c75a8fc",gauge:"0x7776e1008d7c20ab54aa57a7c44fc7de602de29a",assetOrder:["USDT","DAI","USDC"]},bbausd1:{id:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f",address:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd",gauge:"0xa2d0ea81a47d68598922cd54c59249ff58c2a3ff",assetOrder:["bb-a-USDC","bb-a-DAI","bb-a-USDT"]},bbausd2:{id:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd00000000000000000000005f",address:"0x13acd41c585d7ebb4a9460f7c8f50be60dc080cd",gauge:"0xa2d0ea81a47d68598922cd54c59249ff58c2a3ff"},linearUsdc1:{id:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc8668100000000000000000000005c",address:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc86681"},linearDai1:{id:"0x5cea6a84ed13590ed14903925fa1a73c36297d9900000000000000000000005d",address:"0x5cea6a84ed13590ed14903925fa1a73c36297d99"},linearUsdt1:{id:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f00000000000000000000005e",address:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f"},linearUsdc2:{id:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc8668100000000000000000000005c",address:"0x0595d1df64279ddb51f1bdc405fe2d0b4cc86681"},linearDai2:{id:"0x5cea6a84ed13590ed14903925fa1a73c36297d9900000000000000000000005d",address:"0x5cea6a84ed13590ed14903925fa1a73c36297d99"},linearUsdt2:{id:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f00000000000000000000005e",address:"0xefd681a82970ac5d980b9b2d40499735e7bf3f1f"},maiusd:{id:"0x6a8f9ab364b85725973d2a33cb9aae2dac43b5e30000000000000000000000a6",address:"0x6a8f9ab364b85725973d2a33cb9aae2dac43b5e3",gauge:"0x58141bdcecb7fbae006964f4131cf6f65c948357",assetOrder:["USDT","miMATIC","DAI","USDC"]},maibbausd:{id:"0xb04b03b78cf79788a1931545bd2744161029648f0000000000000000000000a8",address:"0xb04b03b78cf79788a1931545bd2744161029648f",gauge:"0xdc3f6fc8898830e53c777543fe252b14f22680d4",assetOrder:["bb-a-USD","miMATIC","MAI BSP"]},USDT:"0x1f1f156e0317167c11aa412e3d1435ea29dc3cce",DAI:"0x8c9e6c40d3402480ace624730524facc5482798c",USDC:"0xe0c9275e44ea80ef17579d33c55136b7da269aeb",waDAI:"0x89534a24450081aa267c79b07411e9617d984052",waUSDC:"0x811151066392fd641fe74a9b55a712670572d161",waUSDT:"0x4cb1892fddf14f772b2e39e299f44b2e5da90d04",miMATIC:"0x398106564948feeb1fedea0709ae7d969d62a391"},137:{relayer:"0xcf6a66E32dCa0e26AcC3426b851FD8aCbF12Dac7",staBal3:{id:"",address:"",gauge:"",assetOrder:["USDT","DAI","USDC"]},bbausd1:{id:"",address:"",gauge:"",assetOrder:["bb-a-USDC","bb-a-DAI","bb-a-USDT"]},bbausd2:{id:"0x48e6b98ef6329f8f0a30ebb8c7c960330d64808500000000000000000000075b",address:"0x48e6b98ef6329f8f0a30ebb8c7c960330d648085",gauge:""},linearUsdc1:{id:"",address:""},linearDai1:{id:"",address:""},linearUsdt1:{id:"",address:""},linearUsdc2:{id:"0xf93579002dbe8046c43fefe86ec78b1112247bb8000000000000000000000759",address:"0xf93579002dbe8046c43fefe86ec78b1112247bb8"},linearDai2:{id:"0x178e029173417b1f9c8bc16dcec6f697bc323746000000000000000000000758",address:"0x178e029173417b1f9c8bc16dcec6f697bc323746"},linearUsdt2:{id:"0xff4ce5aaab5a627bf82f4a571ab1ce94aa365ea600000000000000000000075a",address:"0xff4ce5aaab5a627bf82f4a571ab1ce94aa365ea6"},maiusd:{id:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012",address:"0x06df3b2bbb68adc8b0e302443692037ed9f91b42",gauge:"0x72843281394e68de5d55bcf7072bb9b2ebc24150",assetOrder:["USDC","DAI","miMATIC","USDT"]},maibbausd:{id:"0xb54b2125b711cd183edd3dd09433439d5396165200000000000000000000075e",address:"0xb54b2125b711cd183edd3dd09433439d53961652",gauge:"0x9a105ef22a59484aa2731c357049f6a13d0891f5",assetOrder:["bb-a-USD","miMATIC"]},USDT:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",DAI:"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",USDC:"0x2791bca1f2de4661ed88a30c99a7a9449aa84174",waDAI:"0xEE029120c72b0607344f35B17cdD90025e647B00",waUSDC:"0x221836a597948Dce8F3568E044fF123108aCc42A",waUSDT:"0x19C60a251e525fa88Cd6f3768416a8024e98fC19",miMATIC:"0xa3fa99a148fa48d14ed51d610c367c61876997f1"}},As=new t.Interface(gs),Ss=cs.toChainedReference("21"),Ps=cs.toChainedReference("22"),Bs=cs.toChainedReference("23"),_s=cs.toChainedReference("24");class Os{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];r&&(d=[this.buildSetRelayerApproval(r)]),d=i?[...d,this.buildWithdraw(t,a),this.buildExit(o,a),this.buildSwap(s,o),this.buildDeposit(t)]:[...d,this.buildExit(t,a),this.buildSwap(s,t)];return{to:o,data:As.encodeFunctionData("multicall",[d])}}buildExit(e,t){const{assetOrder:a}=this.addresses.staBal3,n=a.map((e=>this.addresses[e])),s=S.exitExactBPTInForTokensOut(t),i=[{index:a.indexOf("DAI"),key:Ss},{index:a.indexOf("USDC"),key:Ps},{index:a.indexOf("USDT"),key:Bs}];return cs.constructExitCall({assets:n,minAmountsOut:["0","0","0"],userData:s,toInternalBalance:!0,poolId:this.addresses.staBal3.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s){const i=[this.addresses.bbausd2.address,this.addresses.DAI,this.addresses.linearDai2.address,this.addresses.USDC,this.addresses.linearUsdc2.address,this.addresses.USDT,this.addresses.linearUsdt2.address],r=[{index:0,key:_s}],o=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Ss.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:2,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:3,assetOutIndex:4,amount:Ps.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:4,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:5,assetOutIndex:6,amount:Bs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"}],d=[n.BigNumber.from(t).mul(-1).toString(),a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0"],c={sender:this.addresses.relayer,recipient:s,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:o,assets:i,funds:c,limits:d,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.staBal3.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,_s.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const vs=new t.Interface(gs),ks=cs.toChainedReference("24");class Ns{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r,o){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const d=this.addresses.relayer;let c=[];o&&(c=[this.buildSetRelayerApproval(o)]),c=i?[...c,this.buildWithdraw(t,a),this.buildSwap(a,s,d,d,r),this.buildDeposit(t)]:[...c,this.buildSwap(a,s,t,t,r)];const l=vs.encodeFunctionData("multicall",[c]);return{to:this.addresses.relayer,data:l}}buildSwap(t,s,i,r,o){const d=[this.addresses.bbausd2.address,this.addresses.waDAI,this.addresses.linearDai1.address,this.addresses.linearDai2.address,this.addresses.waUSDC,this.addresses.linearUsdc1.address,this.addresses.linearUsdc2.address,this.addresses.waUSDT,this.addresses.linearUsdt1.address,this.addresses.linearUsdt2.address,this.addresses.bbausd1.address],c=[{index:0,key:ks}],l=o.reduce(((e,t)=>e.add(n.BigNumber.from(t))),a.Zero),{assetOrder:p}=this.addresses.bbausd1,u=n.BigNumber.from(t).mul(o[p.indexOf("bb-a-USDC")]).div(l).toString(),b=n.BigNumber.from(t).mul(o[p.indexOf("bb-a-DAI")]).div(l).toString(),y=n.BigNumber.from(t).sub(u).sub(b).toString(),m=[{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:2,amount:b,userData:"0x"},{poolId:this.addresses.linearDai1.id,assetInIndex:2,assetOutIndex:1,amount:"0",userData:"0x"},{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:3,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:3,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:5,amount:u,userData:"0x"},{poolId:this.addresses.linearUsdc1.id,assetInIndex:5,assetOutIndex:4,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:4,assetOutIndex:6,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd1.id,assetInIndex:10,assetOutIndex:8,amount:y,userData:"0x"},{poolId:this.addresses.linearUsdt1.id,assetInIndex:8,assetOutIndex:7,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:7,assetOutIndex:9,amount:"0",userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:9,assetOutIndex:0,amount:"0",userData:"0x"}],f=[n.BigNumber.from(s).mul(-1).toString(),"0","0","0","0","0","0","0","0","0",t],h={sender:i,recipient:r,fromInternalBalance:!1,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:m,assets:d,funds:h,limits:f,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:c})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.bbausd1.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.bbausd2.gauge,this.addresses.relayer,e,ks.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Cs=new t.Interface(gs),Ds=cs.toChainedReference("0"),Fs=[];class Rs{constructor(e){this.addresses=xs[e]}calldata(e,t,a,n,s,i,r,o){if(i&&(null==t.gauge||null==a.gauge))throw new Error("Staked flow migration requires gauge addresses to be provided");const d=this.addresses.relayer;let c=[];o&&(c=[this.buildSetRelayerApproval(o)]),c=i?[...c,this.buildWithdraw(e,n,t.gauge),this.buildExit(t.id,d,n,r),this.buildSwap(s,d,a.id,a.address,r),this.buildDeposit(e,a.gauge)]:[...c,this.buildExit(t.id,e,n,r),this.buildSwap(s,e,a.id,a.address,r)];const l=Cs.encodeFunctionData("multicall",[c]);return{to:this.addresses.relayer,data:l}}buildExit(e,t,a,n){const s=S.exitExactBPTInForTokensOut(a),i=[];for(let e=0;e<n.length;e++)i[e]={index:e,key:cs.toChainedReference(`${e+1}`)},Fs.push(i[e].key);const r=Array(n.length).fill("0");return cs.constructExitCall({assets:n,minAmountsOut:r,userData:s,toInternalBalance:!0,poolId:e,poolKind:0,sender:t,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s,i,r,o){const d=[r,...o],c=[{index:0,key:Ds}],l=[];for(let e=0;e<o.length;e++)l.push({poolId:i,assetInIndex:e+1,assetOutIndex:0,amount:Fs[e].toString(),userData:"0x"});const p=[n.BigNumber.from(t).mul(-1).toString()];for(let e=0;e<o.length;e++)p.push(a.MaxInt256.toString());const u={sender:this.addresses.relayer,recipient:s,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:l,assets:d,funds:u,limits:p,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:c})}buildWithdraw(e,t,a){return cs.encodeGaugeWithdraw(a,e,this.addresses.relayer,t)}buildDeposit(e,t){return cs.encodeGaugeDeposit(t,this.addresses.relayer,e,Ds.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}const Ms=new t.Interface(gs),Ls=cs.toChainedReference("20"),Us=cs.toChainedReference("21"),Gs=cs.toChainedReference("22"),qs=cs.toChainedReference("23"),Ws=cs.toChainedReference("24");class $s{constructor(e){this.addresses=xs[e]}calldata(t,a,s,i,r){if(n.BigNumber.from(a).lte(0))throw new st(e.BalancerErrorCode.INPUT_ZERO_NOT_ALLOWED);const o=this.addresses.relayer;let d=[];r&&(d=[this.buildSetRelayerApproval(r)]),d=i?[...d,this.buildWithdraw(t,a),this.buildExit(o,a),this.buildSwap(o,s),this.buildDeposit(t)]:[...d,this.buildExit(t,a),this.buildSwap(t,s)];return{to:o,data:Ms.encodeFunctionData("multicall",[d])}}buildExit(e,t){const{assetOrder:a}=this.addresses.maiusd,n=a.map((e=>this.addresses[e])),s=S.exitExactBPTInForTokensOut(t),i=[{index:a.indexOf("miMATIC"),key:Ls},{index:a.indexOf("DAI"),key:Us},{index:a.indexOf("USDC"),key:Gs},{index:a.indexOf("USDT"),key:qs}],r=Array(n.length).fill("0");return cs.constructExitCall({assets:n,minAmountsOut:r,userData:s,toInternalBalance:!0,poolId:this.addresses.maiusd.id,poolKind:0,sender:e,recipient:this.addresses.relayer,outputReferences:i,exitPoolRequest:{}})}buildSwap(t,s){const i=[this.addresses.bbausd2.address,this.addresses.DAI,this.addresses.linearDai2.address,this.addresses.USDC,this.addresses.linearUsdc2.address,this.addresses.USDT,this.addresses.linearUsdt2.address,this.addresses.miMATIC,this.addresses.maibbausd.address],r=[{index:8,key:Ws}],o=[{poolId:this.addresses.linearDai2.id,assetInIndex:1,assetOutIndex:2,amount:Us.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:2,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdc2.id,assetInIndex:3,assetOutIndex:4,amount:Gs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:4,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.linearUsdt2.id,assetInIndex:5,assetOutIndex:6,amount:qs.toString(),userData:"0x"},{poolId:this.addresses.bbausd2.id,assetInIndex:6,assetOutIndex:0,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:0,assetOutIndex:8,amount:"0",userData:"0x"},{poolId:this.addresses.maibbausd.id,assetInIndex:7,assetOutIndex:8,amount:Ls.toString(),userData:"0x"}],d=["0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),"0",a.MaxInt256.toString(),n.BigNumber.from(s).mul(-1).toString()],c={sender:this.addresses.relayer,recipient:t,fromInternalBalance:!0,toInternalBalance:!1};return cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:o,assets:i,funds:c,limits:d,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:r})}buildWithdraw(e,t){return cs.encodeGaugeWithdraw(this.addresses.maiusd.gauge,e,this.addresses.relayer,t)}buildDeposit(e){return cs.encodeGaugeDeposit(this.addresses.maibbausd.gauge,this.addresses.relayer,e,Ws.toString())}buildSetRelayerApproval(e){return cs.encodeSetRelayerApproval(this.addresses.relayer,!0,e)}}class Vs{constructor(e){this.network=e}stabal3(e,a,n,s,i){const r=new Os(this.network).calldata(e,a,n,s,i);return{to:r.to,data:r.data,decode:(e,a)=>{let n=a?2:1;i&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}bbaUsd(e,a,n,s,i,r){const o=new Ns(this.network).calldata(e,a,n,s,i,r);return{to:o.to,data:o.data,decode:(e,a)=>{let n=a?1:0;r&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}stables(e,a,n,s,i,r,o,d){const c=new Rs(this.network).calldata(e,a,n,s,i,r,o,d);return{to:c.to,data:c.data,decode:(e,a)=>{let n=a?2:1;d&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][0].abs().toString()}}}maiusd(e,a,n,s,i){const r=new $s(this.network).calldata(e,a,n,s,i);return{to:r.to,data:r.data,decode:(e,a)=>{let n=a?2:1;i&&(n+=1);const s=t.defaultAbiCoder.decode(["bytes[]"],e);return t.defaultAbiCoder.decode(["int256[]"],s[0][n])[0][8].abs().toString()}}}}class Hs{constructor(e){this.network=e,this.migrations=new Vs(e)}}class js{constructor(e,t){this.tokenPrices=e,this.tokenHistoricalPrices=t}async calcImpLoss(t,a){if(1e3*t>=Date.now())throw console.error(`[ImpermanentLossService][calcImpLoss]Error: ${st.getMessage(e.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE)}`),new st(e.BalancerErrorCode.TIMESTAMP_IN_THE_FUTURE);const n=await this.prepareData(t,a),s=this.getPoolValueDelta(n),i=this.getHoldValueDelta(n);return this.calculateImpermanentLoss(s,i)}calculateImpermanentLoss(e,t){return Math.floor(100*Math.abs(e/t-1)*100)/100}getPoolValueDelta(e){return e.reduce(((e,t)=>e*Math.pow(Math.abs(t.priceDelta+1),t.weight)),1)}getHoldValueDelta(e){return e.reduce(((e,t)=>e+Math.abs(t.priceDelta+1)*t.weight),0)}async prepareData(e,t){const a=t.tokens.filter((e=>e.address!==t.address)),n=this.getWeights(a),s=a.map((e=>e.address)),i=await this.getEntryPrices(e,s),r=await this.getExitPrices(a);return this.getAssets(a,r,i,n)}getAssets(e,t,a,n){return e.map(((e,s)=>({priceDelta:this.getDelta(a[e.address],t[e.address]),weight:n[s]})))}getDelta(t,a){if(0===t)throw console.error(`[ImpermanentLossService][getDelta]Error: ${st.getMessage(e.BalancerErrorCode.ILLEGAL_PARAMETER)}: entry price is 0`),new st(e.BalancerErrorCode.ILLEGAL_PARAMETER);return(a-t)/t}getWeights(t){const a=t.every((e=>!e.weight)),n=Math.round(1/t.length*100)/100,s=a?t.map((()=>n)):t.map((e=>{var t;return Number(null!==(t=e.weight)&&void 0!==t?t:0)}));if(s.some((e=>0===e)))throw console.error(`[ImpermanentLossService][getWeights]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_WEIGHT)}`),new st(e.BalancerErrorCode.MISSING_WEIGHT);return s}async getExitPrices(t){var a;const n=await Promise.all(t.map((e=>this.tokenPrices.find(e.address)))).catch((()=>[]));if(!n.length||n.some((e=>void 0===(null==e?void 0:e.usd))))throw console.error(`[ImpermanentLossService][getExitPrices]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_PRICE_RATE)}`),new st(e.BalancerErrorCode.MISSING_PRICE_RATE);const s=t.map(((e,t)=>({...e,price:n[t]}))),i={};for(const e of s)(null===(a=e.price)||void 0===a?void 0:a.usd)&&(i[e.address]=+e.price.usd);return i}async getEntryPrices(t,a){const n={};for(const s of a){const a=await this.tokenHistoricalPrices.findBy(s,t).catch((e=>{console.error(`[ImpermanentLossService][getEntryPrices]Error: ${e.message}`)}));if(!(null==a?void 0:a.usd))throw console.error(`[ImpermanentLossService][getEntryPrices]Error: ${st.getMessage(e.BalancerErrorCode.MISSING_PRICE_RATE)}`),new st(e.BalancerErrorCode.MISSING_PRICE_RATE);n[s]=+a.usd}return n}}const Ks=335e3,Zs=1765411200,Xs=(e=Math.round((new Date).getTime()/1e3))=>Ks;var Js=Object.freeze({__proto__:null,INITIAL_RATE:Ks,START_EPOCH_TIME:Zs,weekly:Xs,total:e=>365*(Xs()/7),between:(e,t)=>{if(e<Zs)throw"start timestamp before emission schedule deployment";if(t<e)throw"cannot finish before starting";const a=t-e,n=Xs()/7;return Math.round(a/86400)*n}});class Ys{constructor(e,t){this.repository=e,this.tokenPrices=t}async data(e=Date.now()){const t=await this.repository.multicallData(e),a=await this.tokenPrices.find(t.balAddress);if(!a||!a.usd)throw"No BAL USD price found";return{lastWeekBalRevenue:t.balAmount*parseFloat(a.usd),lastWeekBBAUsdRevenue:t.bbAUsdAmount*t.bbAUsdPrice,veBalSupply:t.veBalSupply}}}class zs{constructor(e){this.yesterdaysPools=e}async last24h(e){let t;return this.yesterdaysPools&&(t=await this.yesterdaysPools.find(e.id)),e.totalSwapFee?(null==t?void 0:t.totalSwapFee)?parseFloat(e.totalSwapFee)-parseFloat(t.totalSwapFee):e.createTime&&bs(e.createTime)?parseFloat(e.totalSwapFee):0:0}}class Qs{constructor(e,t,a,n,s,i,r,o){this.pools=e,this.tokenPrices=t,this.tokenMeta=a,this.tokenYields=n,this.feeCollector=s,this.yesterdaysPools=i,this.liquidityGauges=r,this.feeDistributor=o}async swapFees(e){const t=await this.last24hFees(e),a=await this.totalLiquidity(e);if(!t||!a)return 0;const n=t*(1-await this.protocolSwapFeePercentage(e))/parseFloat(a)*1e4;return Math.round(365*n)}async tokenAprs(e){return{total:0,breakdown:{}}}async stakingApr(e,t=1){if(!this.liquidityGauges)return 0;const a=await this.liquidityGauges.findBy("poolId",e.id);if(!a||(248==e.chainId||9372==e.chainId||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=tt[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,i]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const r=parseFloat(s.usd),o=Xs()/7*365*a.relativeWeight*r,d=(a.workingSupply+.4)/.4*i;return Math.round(1e4*t*o/d)}async stakingAprNextPeriod(e,t=1){if(!this.liquidityGauges)return 0;const a=await this.liquidityGauges.findBy("poolId",e.id);if(!a)return 0;if(0==a.workingSupply)return a.relativeWeightNextPeriod&&a.relativeWeightNextPeriod>0?-1:0;const n=tt[e.chainId].addresses.tokens.bal;if(!n)return 0;const[s,i]=await Promise.all([this.tokenPrices.find(n),this.bptPrice(e)]);if(!(null==s?void 0:s.usd))throw"Missing BAL price";const r=parseFloat(s.usd),o=Xs()/7*365*(a.relativeWeightNextPeriod||0)*r,d=(a.workingSupply+.4)/.4*i;return Math.round(1e4*t*o/d)}async rewardAprs(e){if(!this.liquidityGauges)return{total:0,breakdown:{}};const t=await this.liquidityGauges.findBy("poolId",e.id);if(!t)return{total:0,breakdown:{}};if(!t.rewardTokens)return{total:0,breakdown:{}};if(Object.keys(t.rewardTokens).length<1)return{total:0,breakdown:{}};const a=tt[e.chainId].addresses.tokens.bal,n=Object.keys(t.rewardTokens).filter((e=>e!=a)).map((async e=>{const a=t.rewardTokens[e];return this.rewardTokenApr(e,a)})),s=await this.bptPrice(e),i=t.totalSupply*s,r={};let o=0;for await(const e of Object.values(n)){const t=i>0?e.value/i:0,a=Math.round(1e4*t);o+=a,r[e.address]=a}return{total:o,breakdown:r}}async protocolApr(e){if(""!=e.id||!this.feeDistributor)return 0;const t=new Ys(this.feeDistributor,this.tokenPrices),{lastWeekBalRevenue:a,lastWeekBBAUsdRevenue:n,veBalSupply:s}=await t.data(),i=await this.bptPrice(e);if(!i)throw"bptPrice for veBal pool missing";const r=(a+n)/7;return Math.round(365*r*1e4/(i*s))}async apr(e){const[t,a,n,s,i,r]=await Promise.all([this.swapFees(e),this.tokenAprs(e),this.stakingApr(e),this.stakingApr(e,2.5),this.rewardAprs(e),this.protocolApr(e)]);return{swapFees:t,tokenAprs:a,stakingApr:{min:n,max:s},rewardAprs:i,protocolApr:r,min:t+a.total+i.total+n,max:t+a.total+i.total+r+s}}async aprNextPeriod(e){const[t,a,n,s,i,r]=await Promise.all([this.swapFees(e),this.tokenAprs(e),this.stakingAprNextPeriod(e),this.stakingAprNextPeriod(e,2.5),this.rewardAprs(e),this.protocolApr(e)]);return{swapFees:t,tokenAprs:a,stakingApr:{min:n,max:s},rewardAprs:i,protocolApr:r,min:t+a.total+i.total+n,max:t+a.total+i.total+r+s}}async last24hFees(e){return new zs(this.yesterdaysPools).last24h(e)}async totalLiquidity(e){try{const t=new $t(this.pools,this.tokenPrices);return await t.getLiquidity(e)}catch(t){return console.error("Liquidity calculcation failed, falling back to subgraph"),e.totalLiquidity}}async bptPrice(e){const t=await this.totalLiquidity(e),a=e.totalShares;return parseFloat(t)/parseFloat(a)}async protocolSwapFeePercentage(e){let t=0;return t="ComposableStable"==e.poolType||"Weighted"==e.poolType&&2==e.poolTypeVersion?0:e.protocolSwapFeeCache?parseFloat(e.protocolSwapFeeCache):await this.feeCollector.find("")||0,t}async rewardTokenApr(e,t){if(t.period_finish.toNumber()<Date.now()/1e3)return{address:e,value:0};{const a=t.rate.mul(86400).mul(365),n=await this.tokenPrices.find(e);if(n&&n.usd){let s=18;if(t.decimals)s=t.decimals;else{const t=await this.tokenMeta.find(e);t&&void 0!==t.decimals&&(s=t.decimals)}return{address:e,value:parseFloat(Pe(a,s))*parseFloat(n.usd)}}throw`No USD price for ${e}`}}}const ei=new Map;ei.set(e.PoolType.AaveLinear,"batchSwap"),ei.set(e.PoolType.EulerLinear,"batchSwap"),ei.set(e.PoolType.ERC4626Linear,"batchSwap"),ei.set(e.PoolType.Element,"batchSwap"),ei.set(e.PoolType.Investment,"joinPool"),ei.set(e.PoolType.LiquidityBootstrapping,"joinPool"),ei.set(e.PoolType.MetaStable,"joinPool"),ei.set(e.PoolType.Stable,"joinPool"),ei.set(e.PoolType.StablePhantom,"batchSwap"),ei.set(e.PoolType.Weighted,"joinPool"),ei.set(e.PoolType.ComposableStable,"joinPool");const ti=new Map;ti.set(e.PoolType.AaveLinear,"batchSwap"),ei.set(e.PoolType.EulerLinear,"batchSwap"),ti.set(e.PoolType.ERC4626Linear,"batchSwap"),ti.set(e.PoolType.Element,"batchSwap"),ti.set(e.PoolType.Investment,"exitPool"),ti.set(e.PoolType.LiquidityBootstrapping,"exitPool"),ti.set(e.PoolType.MetaStable,"exitPool"),ti.set(e.PoolType.Stable,"exitPool"),ti.set(e.PoolType.StablePhantom,"batchSwap"),ti.set(e.PoolType.Weighted,"exitPool"),ti.set(e.PoolType.ComposableStable,"exitPool");class ai{constructor(e){this.pools=e}async buildGraphFromRootPool(t,n){const s=await this.pools.find(t);if(!s)throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST);return(await this.buildGraphFromPool(s.address,0,void 0,a.WeiPerEther,n))[0]}getTokenTotal(e){const t=e.tokensList.indexOf(e.address);let n=a.Zero;const{parsedBalances:s}=se(e);return s.forEach(((e,a)=>{t!==a&&(n=n.add(e))})),n}async buildGraphFromPool(t,a,s,i,r){var o;const d=await this.pools.findBy("address",t);if(!d){if(s){const e=await this.pools.findBy("address",s.address),n=null!==(o=e.tokens[e.tokensList.indexOf(t)].decimals)&&void 0!==o?o:18;return ai.createInputTokenNode(a,t,n,s,i)}throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST)}const c=ei.get(d.poolType),l=ti.get(d.poolType);if(!c||!l)throw new st(e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);const p=this.getTokenTotal(d),{spotPriceCalculator:u}=Wt.from(d.poolType),b={};let y=18;d.tokens.forEach((e=>{if($e(e.address,d.address))return void(y=e.decimals?e.decimals:18);const t=u.calcPoolSpotPrice(e.address,d.address,d);b[e.address]=t}));let m={address:d.address,id:d.id,type:d.poolType,joinAction:c,exitAction:l,children:[],marked:!1,index:a.toString(),parent:s,proportionOfParent:i,isLeaf:!1,spotPrices:b,decimals:y};if(a++,d.poolType.toString().includes("Linear"))[m,a]=this.createLinearNodeChildren(m,a,d,r);else{const{parsedBalances:e}=se(d);for(let t=0;t<d.tokens.length;t++){if($e(d.tokens[t].address,d.address))continue;let s;if("Weighted"===d.poolType){const e=d.tokens[t].weight;s=n.parseFixed(e,18)}else s=n.BigNumber.from(e[t]).mul(1e18.toString()).div(p);const o=s.mul(i).div(1e18.toString()),c=await this.buildGraphFromPool(d.tokens[t].address,a,m,o,r);a=c[1],c[0]&&m.children.push(c[0])}}return[m,a]}createLinearNodeChildren(e,t,a,n){var s;if(n){const n=this.createWrappedTokenNode(a,t,e,e.proportionOfParent);return e.children.push(n[0]),[e,n[1]]}{if(void 0===a.mainIndex)throw new Error("Issue With Linear Pool");const n=null!==(s=a.tokens[a.mainIndex].decimals)&&void 0!==s?s:18,i=ai.createInputTokenNode(t,a.tokensList[a.mainIndex],n,e,e.proportionOfParent);return e.children.push(i[0]),[e,t=i[1]]}}createWrappedTokenNode(t,a,n,s){var i;if(void 0===t.wrappedIndex||void 0===t.mainIndex)throw new Error("Issue With Linear Pool");let r="wrapAaveDynamicToken";if(t.poolType===e.PoolType.ERC4626Linear)r="wrapERC4626";let o="unwrapAaveStaticToken";if(t.poolType===e.PoolType.ERC4626Linear)o="unwrapERC4626";const d={type:"WrappedToken",address:t.tokensList[t.wrappedIndex],id:"N/A",children:[],marked:!1,joinAction:r,exitAction:o,index:a.toString(),parent:n,proportionOfParent:s,isLeaf:!1,spotPrices:{},decimals:18};a++;const c=null!==(i=t.tokens[t.mainIndex].decimals)&&void 0!==i?i:18,l=ai.createInputTokenNode(a,t.tokensList[t.mainIndex],c,d,s);return d.children=[l[0]],[d,a=l[1]]}static createInputTokenNode(e,t,a,n,s){return[{address:t,id:"N/A",type:"Input",children:[],marked:!1,joinAction:"input",exitAction:"output",index:e.toString(),parent:n,proportionOfParent:s,isLeaf:!0,spotPrices:{},decimals:a},e+1]}static orderByBfs(e){const t=[],a=[];for(e.marked=!0,t.push(e);t.length>0;){const e=t.shift();e&&a.push(e),null==e||e.children.forEach((e=>{e.marked||(e.marked=!0,t.push(e))}))}return a}static getLeafAddresses(e){return e.filter((e=>e.isLeaf)).map((e=>e.address))}}ai.getGraphNodes=async(t,a,n,s)=>{if(!await n.find(a))throw new st(e.BalancerErrorCode.POOL_DOESNT_EXIST);const i=new ai(n),r=await i.buildGraphFromRootPool(a,s);if(r.id!==a)throw new Error("Error creating graph nodes");return t?ai.orderByBfs(r).reverse():ai.orderByBfs(r)};class ni{constructor(e,t){this.chainId=e,this.simulateMulticall=async(e,t,a,n)=>{const s={...await this.encodeBalanceAndAllowanceOverrides(a,n),...await this.encodeRelayerApprovalOverride(a,e)};return this.simulateTransaction(e,t,a,s)},this.simulateTransaction=async(e,t,a,n)=>{const s=Object.fromEntries(Object.keys(n).map((e=>[e,{storage:n[e].value}]))),i={network_id:this.chainId.toString(),block_number:this.blockNumber,from:a,to:e,input:t,save_if_fails:!0,simulation_type:"quick",state_objects:s},r=this.tenderlyUrl+"simulate";return(await x.default.post(r,i,this.opts)).data.transaction.transaction_info.call_trace.output},this.encodeRelayerApprovalOverride=async(e,t)=>{const a={[`${this.vaultAddress}`]:{value:{[`_approvedRelayers[${e}][${t}]`]:(!0).toString()}}};return await this.requestStateOverrides(a)},this.encodeBalanceAndAllowanceOverrides=async(e,t)=>{if(0===t.length)return{};let n={};t.forEach((t=>n={...n,[`${t}`]:{value:{[`_balances[${e}]`]:a.MaxInt256.toString(),[`_allowances[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString(),[`balanceOf[${e}]`]:a.MaxInt256.toString(),[`allowance[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString(),[`balances[${e}]`]:a.MaxInt256.toString(),[`allowed[${e}][${this.vaultAddress}]`]:a.MaxInt256.toString()}}}));const s=await this.requestStateOverrides(n);if(Object.keys(s).some((e=>2!==Object.keys(s[e].value).length)))throw new Error("Couldn't encode state overrides - states should match the ones in the contracts");return s},this.requestStateOverrides=async e=>{const t=this.tenderlyUrl+"contracts/encode-states",a={networkID:this.chainId.toString(),stateOverrides:e},n=(await x.default.post(t,a,this.opts)).data.stateOverrides;if(!n||Object.keys(n).length!==Object.keys(e).length)throw new Error("Couldn't encode state overrides - contracts should be verified and whitelisted on Tenderly");return n};const{contracts:n}=at(this.chainId);this.vaultAddress=n.vault,(null==t?void 0:t.user)&&(null==t?void 0:t.project)?this.tenderlyUrl=`https://api.tenderly.co/api/v1/account/${t.user}/project/${t.project}/`:this.tenderlyUrl="https://api.balancer.fi/tenderly/",(null==t?void 0:t.accessKey)&&(this.opts={headers:{"X-Access-Key":t.accessKey}}),this.blockNumber=null==t?void 0:t.blockNumber}}var si;const ii=new t.Interface(Ts);class ri{constructor(s,i){this.pools=s,this.createCalls=async(e,t,a,n)=>{const{calls:s,outputIndexes:i,deltas:r}=this.createActionCalls(e,t,a);n&&s.unshift(this.createSetRelayerApproval(n));return{callData:ii.encodeFunctionData("multicall",[s]),outputIndexes:n?i.map((e=>e+1)):i,deltas:r}},this.amountsOutByJoinPath=async(e,a,s,i)=>{const r=[],o=await this.tenderlyHelper.simulateMulticall(this.relayer,a,e,s),d=t.defaultAbiCoder.decode(["bytes[]"],o)[0];let c=n.BigNumber.from("0");return i.forEach((e=>{const a=t.defaultAbiCoder.decode(["uint256"],d[e]);r.push(a.toString()),c=c.add(a.toString())})),{amountsOut:r,totalAmountOut:c.toString()}},this.minAmountsOutByJoinPath=(e,t,a)=>({minAmountsOut:t.map((t=>ze(n.BigNumber.from(t),n.BigNumber.from(e)).toString())),totalMinAmountOut:ze(n.BigNumber.from(a),n.BigNumber.from(e)).toString()}),this.createActionCalls=(e,t,a)=>{const n=[],s=[],i=!a,r={};return e.forEach(((e,o)=>{const d=e[0].isLeaf;if(e.forEach(((s,i)=>{let c;if(c=d?e.filter((e=>{var t;return s.children.map((e=>e.address)).includes(e.address)&&s.index===(null===(t=e.parent)||void 0===t?void 0:t.index)})):i>0?[e[i-1]]:[],c.length>0&&0===c.filter((e=>"0"!==e.index)).length)return void(s.index="0");c.some((e=>"input"===e.joinAction||"wrapAaveDynamicToken"===e.joinAction));const l=t,p=i===e.length-1,u=t,b=p&&a?a[o]:"0";switch(s.joinAction){case"wrapAaveDynamicToken":n.push(this.createAaveWrap(s,c,o,l,t));break;case"batchSwap":{const[e,t,a]=this.createBatchSwap(s,c,o,b,l,u);n.push(e),this.updateDeltas(r,t,a);break}case"joinPool":{const[e,t,a,i]=this.createJoinPool(s,c,o,b,l,u);n.push(e),this.updateDeltas(r,[s.address,...t],[i,...a]);break}}})),i){const e=100*o,t=cs.encodePeekChainedReferenceValue(cs.toChainedReference(e,!1));n.push(t),s.push(n.indexOf(t))}})),{calls:n,outputIndexes:s,deltas:r}},this.createSetRelayerApproval=e=>cs.encodeSetRelayerApproval(this.relayer,!0,e),this.createAaveWrap=(e,t,a,n,s)=>{if(1!==t.length)throw new Error("aaveWrap nodes should always have a single child node");const i=t[0],r=e.address,o=i.index;return cs.encodeWrapAaveDynamicToken({staticToken:r,sender:n,recipient:s,amount:o,fromUnderlying:!0,outputReference:this.getOutputRefValue(a,e).value})},this.createBatchSwap=(t,s,i,r,o,d)=>{if(1!==s.length)throw new Error("Unsupported batchswap");const c=s[0].address,l=this.getOutputRefValue(i,s[0]),p=[t.address,c],u=[n.BigNumber.from(r).mul(-1).toString(),l.isRef?a.MaxInt256.toString():l.value],b=[{poolId:t.id,assetInIndex:1,assetOutIndex:0,amount:l.value,userData:"0x"}],y={sender:o,recipient:d,fromInternalBalance:o===this.relayer,toInternalBalance:d===this.relayer},m=[{index:p.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase()),key:n.BigNumber.from(this.getOutputRefValue(i,t).value)}],f=cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:b,assets:p,funds:y,limits:u,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:m}),h=o===this.relayer?"0":u[1];return[f,p,[d===this.relayer?"0":u[0],h]]},this.createJoinPool=(t,n,s,i,r,o)=>{const d=[],c=[];t.children.forEach((e=>{d.push(e.address);const t=n.find((t=>$e(t.address,e.address)));t?c.push(this.getOutputRefValue(s,t).value):c.push("0")})),t.type===e.PoolType.ComposableStable&&(d.push(t.address),c.push("0"));const l=new W(this.wrappedNativeAsset),[p,u]=l.sortTokens(d,c);let b=[];const y=p.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase());let m;b=-1===y?u:[...u.slice(0,y),...u.slice(y+1)],m=t.type===e.PoolType.Weighted?P.joinExactTokensInForBPTOut(b,i):S.joinExactTokensInForBPTOut(b,i);const f=p.indexOf(a.AddressZero),h=-1===f?"0":u[f],T=cs.constructJoinCall({poolId:t.id,kind:0,sender:r,recipient:o,value:h,outputReference:this.getOutputRefValue(s,t).value,joinPoolRequest:{},assets:p,maxAmountsIn:u,userData:m,fromInternalBalance:r===this.relayer}),g=u.map((e=>cs.isChainedReference(e)?"0":e)),I=cs.isChainedReference(i)?"0":i;return[T,r===this.relayer?[]:p,r===this.relayer?[]:g,o===this.relayer?a.Zero.toString():a.Zero.sub(I).toString()]},this.getOutputRefValue=(e,t)=>"input"===t.joinAction?{value:t.index,isRef:!1}:"0"===t.index&&t.parent?{value:"0",isRef:!0}:{value:cs.toChainedReference(n.BigNumber.from(t.index).add(100*e)).toString(),isRef:!0};const{tokens:r,contracts:o}=at(i.chainId);this.relayer=o.relayerV4,this.wrappedNativeAsset=r.wrappedNativeAsset,this.tenderlyHelper=new ni(i.chainId,i.tenderly)}async joinPool(t,a,n,s,i,r,o){if(a.length!=n.length)throw new st(e.BalancerErrorCode.INPUT_LENGTH_MISMATCH);const d=await ai.getGraphNodes(!0,t,this.pools,i),c=ri.getJoinPaths(d,a,n),l=ri.totalBptZeroPriceImpact(c),{callData:p,outputIndexes:u}=await this.createCalls(c,s,void 0,o),{amountsOut:b,totalAmountOut:y}=await this.amountsOutByJoinPath(s,p,a,u),{minAmountsOut:m,totalMinAmountOut:f}=this.minAmountsOutByJoinPath(r,b,y),h=ct(BigInt(y),l.toBigInt(),!0).toString(),{callData:T,deltas:g}=await this.createCalls(c,s,m,o);return this.assertDeltas(t,g,a,n,f),{to:this.relayer,callData:T,expectedOut:y,minOut:f,priceImpact:h}}assertDeltas(t,a,s,i,r){var o;const d=D(t);if(a[d.toLowerCase()].add(r).abs().gt(3))throw console.error("join assertDeltas, bptOut: ",d,r,null===(o=a[d.toLowerCase()])||void 0===o?void 0:o.toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete a[d.toLowerCase()],s.forEach(((t,s)=>{var r,o;if(!n.BigNumber.from(i[s]).eq(0)&&(null===(r=a[t.toLowerCase()])||void 0===r?void 0:r.toString())!==i[s])throw console.error("join assertDeltas, tokenIn: ",t,i[s],null===(o=a[t.toLowerCase()])||void 0===o?void 0:o.toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS);delete a[t.toLowerCase()]}));for(const t in a)if("0"!==a[t].toString())throw console.error("join assertDeltas, non-input token should be 0: ",t,a[t].toString()),new st(e.BalancerErrorCode.JOIN_DELTA_AMOUNTS)}updateDeltas(e,t,n){return t.forEach(((t,s)=>{const i=t.toLowerCase();e[i]||(e[i]=a.Zero),e[i]=e[i].add(n[s])})),e}}si=ri,ri.getJoinPaths=(e,t,s)=>{const i=[],r=e.filter((e=>t.filter(((e,t)=>n.BigNumber.from(s[t]).gt(0))).map((e=>e.toLowerCase())).includes(e.address.toLowerCase())));r.some((e=>e.isLeaf))&&i.push(e);const o=r.filter((e=>!e.isLeaf));return o.forEach((e=>{const r=s.find(((a,n)=>$e(t[n],e.address))),d=o.filter((t=>$e(t.address,e.address))).reduce(((e,t)=>e.add(t.proportionOfParent)),n.BigNumber.from(0)),l=n.BigNumber.from(r).mul(e.proportionOfParent).div(d).toString(),[p]=ai.createInputTokenNode(0,e.address,e.decimals,e.parent,a.WeiPerEther);p.index=l,p.isLeaf=!1;const u=[p];let b=e.parent;for(;b;)u.push(c.cloneDeep(b)),b=b.parent;i.push(u)})),si.updateInputAmounts(i,t,s),i},ri.updateInputAmounts=(e,t,a)=>{const s=(e,t)=>{if(e.length>1){const a=e.reduce(((e,t)=>e.add(t.index)),n.BigNumber.from(0)),s=n.BigNumber.from(t).sub(a);e[0].index=s.add(e[0].index).toString()}},i=e.find((e=>e[0].isLeaf));if(i){const e=si.updateTotalProportions(i);i.forEach((n=>{"input"===n.joinAction&&(n=si.updateNodeAmount(n,t,a,e))})),t.forEach(((e,t)=>{const n=i.filter((t=>t.isLeaf&&$e(t.address,e)));s(n,a[t])}))}const r=e.filter((e=>!e[0].isLeaf));r.length>1&&t.forEach(((e,t)=>{const n=r.map((e=>e[0])).filter((t=>$e(t.address,e)));s(n,a[t])}))},ri.totalBptZeroPriceImpact=e=>{let t=n.BigNumber.from("0");return e.forEach((e=>{if(e[0].isLeaf){e.filter((e=>e.isLeaf)).forEach((e=>{const a=si.bptOutZeroPiForInputNode(e);t=t.add(a)}))}else{const a=si.bptOutZeroPiForInputNode(e[0]);t=t.add(a)}})),t},ri.bptOutZeroPiForInputNode=e=>{if("0"===e.index||"input"!==e.joinAction)return BigInt(0);let t=1,a=e.parent,s=e.address;for(;void 0!==a;){if("batchSwap"===a.joinAction||"joinPool"===a.joinAction){const e=a.spotPrices[s.toLowerCase()];t*=parseFloat(e),s=a.address}a=a.parent}const i=n.parseFixed(t.toFixed(18),18),r=Q(BigInt(e.decimals)),o=ee(BigInt(e.index),r);return ae.divDownFixed(o,i.toBigInt())},ri.updateTotalProportions=e=>{const t={};return e.forEach((e=>{t[e.address]?t[e.address]=t[e.address].add(e.proportionOfParent):t[e.address]=e.proportionOfParent})),t},ri.updateNodeAmount=(e,t,a,n)=>{const s=t.map((e=>e.toLowerCase())).indexOf(e.address.toLowerCase());if(-1===s)return e.index="0",e;const i=n[e.address],r=e.proportionOfParent.mul(1e18.toString()).div(i).mul(a[s]).div(1e18.toString());return e.index=r.toString(),e};const oi=new t.Interface(Ts);class di{constructor(e,s){this.pools=e,this.amountsOutByExitPath=async(e,a,s,i,r)=>{const o=await this.tenderlyHelper.simulateMulticall(this.relayer,a,e,[s]),d=t.defaultAbiCoder.decode(["bytes[]"],o)[0],c=i.map((e=>t.defaultAbiCoder.decode(["uint256"],d[e]).toString())),l=c.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(r)).toString()));return{expectedAmountsOutByExitPath:c,minAmountsOutByExitPath:l}},this.amountsOutByTokenOut=(e,t,s,i)=>{const r={};t.forEach(((e,t)=>{var n;return r[e]=(null!==(n=r[e])&&void 0!==n?n:a.Zero).add(s[t])}));const o=e.map((e=>r[e].toString())),d=o.map((e=>ze(n.BigNumber.from(e),n.BigNumber.from(i)).toString()));return{expectedAmountsOut:o,minAmountsOut:d}},this.getExitPaths=(e,t)=>{const s=e.map((e=>{const n=[e];for(;n[0].parent;)n.unshift(c.cloneDeep(n[0].parent));return n[0].index=n[n.length-1].proportionOfParent.mul(t).div(a.WeiPerEther).toString(),n})),i=s.reduce(((e,t)=>{const a=t[0].index;return n.BigNumber.from(a).add(e)}),a.Zero),r=n.BigNumber.from(t).sub(i);return s[s.length-1][0].index=r.add(s[s.length-1][0].index).toString(),s},this.getOutputRef=(e,t)=>100*e+parseInt(t);const{tokens:i,contracts:r}=at(s.chainId);this.wrappedNativeAsset=i.wrappedNativeAsset,this.relayer=r.relayerV4,this.tenderlyHelper=new ni(s.chainId,s.tenderly)}async exitPool(e,t,a,n,s){const i=await ai.getGraphNodes(!1,e,this.pools,!1),r=i.filter((e=>"output"===e.exitAction)),o=this.getExitPaths(r,t),d=r.map((e=>e.address.toLowerCase())),c=[...new Set(d)].sort(),l=await this.createCalls(o,a,void 0,s),{expectedAmountsOutByExitPath:p,minAmountsOutByExitPath:u}=await this.amountsOutByExitPath(a,l.callData,i[0].address,l.outputIndexes,n),{callData:b,deltas:y}=await this.createCalls(o,a,u,s),{expectedAmountsOut:m,minAmountsOut:f}=this.amountsOutByTokenOut(c,d,p,n);this.assertDeltas(e,y,t,c,f);const h=await this.calculatePriceImpact(e,c,m,t);return{to:this.relayer,callData:b,tokensOut:c,expectedAmountsOut:m,minAmountsOut:f,priceImpact:h}}async calculatePriceImpact(e,t,a,n){const s=await ai.getGraphNodes(!0,e,this.pools,!1),i=ri.getJoinPaths(s,t,a),r=ri.totalBptZeroPriceImpact(i);return ct(BigInt(n),r.toBigInt(),!1).toString()}assertDeltas(t,a,n,s,i){var r;const o=D(t);if(a[o.toLowerCase()].sub(n).abs().gt(3))throw console.error("exit assertDeltas, bptIn: ",o,n,null===(r=a[o.toLowerCase()])||void 0===r?void 0:r.toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete a[o.toLowerCase()],s.forEach(((t,n)=>{var s;if(a[t.toLowerCase()].add(i[n]).abs().gt(1))throw console.error("exit assertDeltas, tokenOut: ",t,i[n],null===(s=a[t.toLowerCase()])||void 0===s?void 0:s.toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS);delete a[t.toLowerCase()]}));for(const t in a)if("0"!==a[t].toString())throw console.error("exit assertDeltas, non-input token should be 0: ",t,a[t].toString()),new st(e.BalancerErrorCode.EXIT_DELTA_AMOUNTS)}async createCalls(e,t,a,n){const{calls:s,outputIndexes:i,deltas:r}=this.createActionCalls(c.cloneDeep(e),t,a);n&&s.unshift(cs.encodeSetRelayerApproval(this.relayer,!0,n));return{callData:oi.encodeFunctionData("multicall",[s]),outputIndexes:n?i.map((e=>e+1)):i,deltas:r}}updateDeltas(e,t,n){return t.forEach(((t,s)=>{const i=t.toLowerCase();e[i]||(e[i]=a.Zero),e[i]=e[i].add(n[s])})),e}createActionCalls(e,t,a){const n=[],s=[],i=!a,r={};return e.forEach(((e,o)=>{e.forEach((d=>{const c=!d.parent?t:this.relayer,l=d.children.find((t=>e.map((e=>e.index)).includes(t.index))),p="output"===(null==l?void 0:l.exitAction),u=p?t:this.relayer,b=p&&a?a[o]:"0";switch(d.exitAction){case"batchSwap":{const[e,t,a]=this.createBatchSwap(d,l,o,b,c,u);n.push(e),this.updateDeltas(r,t,a);break}case"exitPool":{const[e,t,a,s]=this.createExitPool(d,l,o,b,c,u);n.push(e),this.updateDeltas(r,[d.address,...a],[t,...s]);break}case"output":i&&(n.push(cs.encodePeekChainedReferenceValue(cs.toChainedReference(this.getOutputRef(o,d.index),!1))),s.push(n.length-1));break;default:return}}))})),{calls:n,outputIndexes:s,deltas:r}}createBatchSwap(t,s,i,r,o,d){const c=!t.parent?t.index:cs.toChainedReference(this.getOutputRef(i,t.index)).toString(),l=s.address,p=[l,t.address],u=[n.BigNumber.from(r).mul(-1).toString(),cs.isChainedReference(c)?a.MaxInt256.toString():c],b=[{poolId:t.id,assetInIndex:1,assetOutIndex:0,amount:c,userData:"0x"}],y={sender:o,recipient:d,fromInternalBalance:!1,toInternalBalance:!1},m=[{index:p.map((e=>e.toLowerCase())).indexOf(l.toLowerCase()),key:cs.toChainedReference(this.getOutputRef(i,s.index))}],f=cs.encodeBatchSwap({swapType:e.SwapType.SwapExactIn,swaps:b,assets:p,funds:y,limits:u,deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:m});let h=u[0];const T=u[1],g=o===this.relayer?"0":T;return h=d===this.relayer?"0":h,[f,p,[h,g]]}createExitPool(t,n,s,i,r,o){const d=n.address,c=!t.parent?t.index:cs.toChainedReference(this.getOutputRef(s,t.index)).toString(),l=[],p=[];t.children.forEach((e=>{l.push(e.address),p.push(e.address===d?i:"0")})),t.type===e.PoolType.ComposableStable&&(l.push(t.address),p.push("0"));const u=new W(this.wrappedNativeAsset),[b,y]=u.sortTokens(l,p);let m=[];const f=b.map((e=>e.toLowerCase())).indexOf(t.address.toLowerCase());let h;m=-1===f?b:[...b.slice(0,f),...b.slice(f+1)],h=t.type===e.PoolType.Weighted?P.exitExactBPTInForOneTokenOut(c,m.indexOf(d)):S.exitExactBPTInForOneTokenOut(c,m.indexOf(d));const T=[{index:b.map((e=>e.toLowerCase())).indexOf(d.toLowerCase()),key:cs.toChainedReference(this.getOutputRef(s,n.index))}],g=cs.constructExitCall({poolId:t.id,poolKind:0,sender:r,recipient:o,outputReferences:T,exitPoolRequest:{},assets:b,minAmountsOut:y,userData:h,toInternalBalance:!1}),I=y.map((e=>cs.isChainedReference(e)?"0":a.Zero.sub(e).toString())),E=cs.isChainedReference(c)?"0":c;return[g,r===this.relayer?a.Zero.toString():E,o===this.relayer?[]:b,o===this.relayer?[]:I]}}class ci{constructor(e){this.yesterdaysPools=e}async last24h(e){let t;return this.yesterdaysPools&&(t=await this.yesterdaysPools.find(e.id)),e.totalSwapVolume?(null==t?void 0:t.totalSwapVolume)?parseFloat(e.totalSwapVolume)-parseFloat(t.totalSwapVolume):e.createTime&&bs(e.createTime)?parseFloat(e.totalSwapVolume):0:0}}var li=[{inputs:[{internalType:"contract IVault",name:"vault",type:"address"},{internalType:"contract IProtocolFeePercentagesProvider",name:"protocolFeeProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[],name:"FactoryDisabled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"pool",type:"address"}],name:"PoolCreated",type:"event"},{inputs:[{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"symbol",type:"string"},{internalType:"contract IERC20[]",name:"tokens",type:"address[]"},{internalType:"uint256",name:"amplificationParameter",type:"uint256"},{internalType:"contract IRateProvider[]",name:"rateProviders",type:"address[]"},{internalType:"uint256[]",name:"tokenRateCacheDurations",type:"uint256[]"},{internalType:"bool[]",name:"exemptFromYieldProtocolFeeFlags",type:"bool[]"},{internalType:"uint256",name:"swapFeePercentage",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],name:"create",outputs:[{internalType:"contract ComposableStablePool",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"disable",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"getActionId",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAuthorizer",outputs:[{internalType:"contract IAuthorizer",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCreationCode",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCreationCodeContracts",outputs:[{internalType:"address",name:"contractA",type:"address"},{internalType:"address",name:"contractB",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getPauseConfiguration",outputs:[{internalType:"uint256",name:"pauseWindowDuration",type:"uint256"},{internalType:"uint256",name:"bufferPeriodDuration",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVault",outputs:[{internalType:"contract IVault",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"isDisabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"pool",type:"address"}],name:"isPoolFromFactory",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class pi{constructor(e){const{tokens:t}=at(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:a,name:n,symbol:s,tokenAddresses:i,amplificationParameter:r,rateProviders:o,tokenRateCacheDurations:d,exemptFromYieldProtocolFeeFlags:c,swapFee:l,owner:p}){const u=We(`${l}`),b=new W(this.wrappedNativeAsset),[y,m,f,h]=b.sortTokens(i,o,d,c),T=[n,s,y,r,m,f,h,u.toString(),p],g=new t.Interface(li),I=li.find((({name:e})=>"create"===e));if(!I)throw new st(e.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const E=t.FunctionFragment.from(I);return{to:a,data:g.encodeFunctionData(E,T)}}buildInitJoin({joiner:e,poolId:t,poolAddress:a,tokensIn:n,amountsIn:s}){throw new Error("To be implemented")}}class ui{constructor(e){const{tokens:t}=at(e.chainId);this.wrappedNativeAsset=t.wrappedNativeAsset}create({factoryAddress:a,name:n,symbol:s,tokenAddresses:i,weights:r,swapFee:o,owner:d}){const c=We(`${o}`),l=new W(this.wrappedNativeAsset),[u,b]=l.sortTokens(i,r),y=[n,s,u,b,c.toString(),d],m=new t.Interface(p.WeightedPoolFactory__factory.abi),f=p.WeightedPoolFactory__factory.abi.find((({name:e})=>"create"===e));if(!f)throw new st(e.BalancerErrorCode.INTERNAL_ERROR_INVALID_ABI);const h=t.FunctionFragment.from(f);return{to:a,data:m.encodeFunctionData(h,y)}}buildInitJoin({joiner:e,poolId:t,tokensIn:a,amountsIn:n}){const s=new W(this.wrappedNativeAsset),[i,r]=s.sortTokens(a,n),o="joinPool",d={poolId:t,sender:e,recipient:e,joinPoolRequest:{assets:i,maxAmountsIn:r,userData:P.joinInit(r),fromInternalBalance:!1}},c=p.Vault__factory.createInterface().encodeFunctionData(o,[d.poolId,d.sender,d.recipient,d.joinPoolRequest]);return{to:et,functionName:o,attributes:d,data:c}}}class bi{constructor(e){this.networkConfig=e}of(t){switch(t){case"Weighted":return new ui(this.networkConfig);case"Investment":case"LiquidityBootstrapping":case"Stable":case"MetaStable":case"StablePhantom":case"AaveLinear":case"ERC4626Linear":default:throw new st(e.BalancerErrorCode.UNSUPPORTED_POOL_TYPE);case"ComposableStable":return new pi(this.networkConfig)}}}class yi{constructor(t){this.pool=t;const a=(t=>{switch(t){case e.PoolType.Weighted:return P;case e.PoolType.Stable:case e.PoolType.MetaStable:case e.PoolType.StablePhantom:case e.PoolType.AaveLinear:case e.PoolType.EulerLinear:case e.PoolType.ERC4626Linear:case e.PoolType.Element:case e.PoolType.Gyro2:case e.PoolType.Gyro3:return S;case e.PoolType.ComposableStable:return v}})(t.poolType);if(!a)throw"Pool type not supported";this.encoder=a}buildQueryJoinExactIn({sender:e=a.AddressZero,recipient:t=e,maxAmountsIn:n,minimumBPT:s=a.Zero,fromInternalBalance:i=!1}){const r=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e))),o=[...this.pool.tokensList];r&&r>-1&&n.splice(r,1);const d=this.encoder.joinExactTokensInForBPTOut(n,s);return[this.pool.id,e,t,{assets:o,maxAmountsIn:n,userData:d,fromInternalBalance:i}]}buildQueryJoinExactOut({sender:e=a.AddressZero,recipient:t=e,maxAmountsIn:n=[],bptOut:s,tokenIn:i,fromInternalBalance:r=!1}){const o=this.pool.tokensList.indexOf(i),d=this.encoder.joinTokenInForExactBPTOut(s,o);return[this.pool.id,e,t,{assets:this.pool.tokensList,maxAmountsIn:n,userData:d,fromInternalBalance:r}]}buildQueryExitToSingleToken({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n=[],bptIn:s,tokenOut:i,toInternalBalance:r=!1}){const o=this.pool.tokensList.indexOf(i),d=this.encoder.exitExactBPTInForOneTokenOut(s,o);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:d,toInternalBalance:r}]}buildQueryExitProportionally({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n=[],bptIn:s,toInternalBalance:i=!1}){if(!this.encoder.exitExactBPTInForTokensOut)throw"Proportional exit not implemented";const r=this.encoder.exitExactBPTInForTokensOut(s);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:r,toInternalBalance:i}]}buildQueryExitExactOut({sender:e=a.AddressZero,recipient:t=e,minAmountsOut:n,maxBptIn:s=a.MaxUint256,toInternalBalance:i=!1}){const r=this.pool.tokensList.findIndex((e=>this.pool.id.includes(e)));r&&r>-1&&n.splice(r,1);const o=this.encoder.exitBPTInForExactTokensOut(n,s);return[this.pool.id,e,t,{assets:this.pool.tokensList,minAmountsOut:n,userData:o,toInternalBalance:i}]}}class mi{constructor(e){this.liquidityGaugesRepository=e}async relativeWeight(e){const t=await this.liquidityGaugesRepository.findBy("poolId",e);return t?t.relativeWeight:0}async weekly(e){return Xs()*await this.relativeWeight(e)}}const fi=(e,t,a)=>{const s=e.tokens.filter((t=>!e.id.toLowerCase().includes(t.address.toLowerCase()))),i=s.findIndex((e=>e.address.toLowerCase()===t.toLowerCase()));if(-1==i)throw new Error("Token not found in pool");const r=s.map((e=>Be(e.balance,e.decimals))),o=n.BigNumber.from(a),d=r.map((e=>e.mul(o).div(r[i])));return{tokens:s.map((e=>e.address)),amounts:d.map((e=>e.toString()))}},hi=(e,t)=>()=>{throw`${t} for poolType ${e} not implemented`};class Ti{constructor(e,t){this.networkConfig=e,this.repositories=t,this.aprService=new Qs(this.repositories.pools,this.repositories.tokenPrices,this.repositories.tokenMeta,this.repositories.tokenYields,this.repositories.feeCollector,this.repositories.yesterdaysPools,this.repositories.liquidityGauges,this.repositories.feeDistributor),this.liquidityService=new $t(t.pools,t.tokenPrices),this.joinService=new ri(this.repositories.poolsOnChain,e),this.exitService=new di(this.repositories.poolsOnChain,e),this.feesService=new zs(t.yesterdaysPools),this.volumeService=new ci(t.yesterdaysPools),this.poolFactory=new bi(e),this.impermanentLossService=new js(t.tokenPrices,t.tokenHistoricalPrices),t.liquidityGauges&&(this.emissionsService=new mi(t.liquidityGauges)),this.proportionalAmounts=fi}dataSource(){return this.repositories.pools}async apr(e){return this.aprService.apr(e)}async aprNextPeriod(e){return this.aprService.aprNextPeriod(e)}async impermanentLoss(e,t){return this.impermanentLossService.calcImpLoss(e,t)}async liquidity(e){return this.liquidityService.getLiquidity(e)}async generalisedJoin(e,t,a,n,s,i,r){return this.joinService.joinPool(e,t,a,n,s,i,r)}async generalisedExit(e,t,a,n,s){return this.exitService.exitPool(e,t,a,n,s)}async fees(e){return this.feesService.last24h(e)}async volume(e){return this.volumeService.last24h(e)}static wrap(e,t){let a,n,s;try{a=Wt.from(e.poolType),s={buildJoin:(t,n,s,r)=>a.join.buildJoin({joiner:t,pool:e,tokensIn:n,amountsIn:s,slippage:r,wrappedNativeAsset:i}),calcPriceImpact:async(t,n,s)=>a.priceImpactCalculator.calcPriceImpact(e,t,n,s),buildExitExactBPTIn:(t,n,s,r=!1,o)=>{if(a.exit.buildExitExactBPTIn)return a.exit.buildExitExactBPTIn({exiter:t,pool:e,bptIn:n,slippage:s,shouldUnwrapNativeAsset:r,wrappedNativeAsset:i,singleTokenMaxOut:o});throw"ExitExactBPTIn not supported"},buildExitExactTokensOut:(t,n,s,r)=>a.exit.buildExitExactTokensOut({exiter:t,pool:e,tokensOut:n,amountsOut:s,slippage:r,wrappedNativeAsset:i}),calcSpotPrice:(t,n)=>a.spotPriceCalculator.calcPoolSpotPrice(t,n,e),calcProportionalAmounts:(t,a)=>fi(e,t,a)}}catch(t){"UNSUPPORTED_POOL_TYPE"!=t.code&&console.error(t),s={buildJoin:hi(e.poolType,"buildJoin"),calcPriceImpact:hi(e.poolType,"calcPriceImpact"),buildExitExactBPTIn:hi(e.poolType,"buildExitExactBPTIn"),buildExitExactTokensOut:hi(e.poolType,"buildExitExactTokensOut"),calcSpotPrice:hi(e.poolType,"calcSpotPrice")}}try{n=new yi(e),s={...s,buildQueryJoinExactIn:n.buildQueryJoinExactIn.bind(n),buildQueryJoinExactOut:n.buildQueryJoinExactOut.bind(n),buildQueryExitExactOut:n.buildQueryExitExactOut.bind(n),buildQueryExitToSingleToken:n.buildQueryExitToSingleToken.bind(n),buildQueryExitProportionally:n.buildQueryExitProportionally.bind(n)}}catch(t){s={...s,buildQueryJoinExactIn:hi(e.poolType,"buildQueryJoinExactIn"),buildQueryJoinExactOut:hi(e.poolType,"buildQueryJoinExactOut"),buildQueryExitExactOut:hi(e.poolType,"buildQueryExitExactOut"),buildQueryExitToSingleToken:hi(e.poolType,"buildQueryExitToSingleToken"),buildQueryExitProportionally:hi(e.poolType,"buildQueryExitProportionally")}}const i=t.addresses.tokens.wrappedNativeAsset.toLowerCase();return{...e,...s}}async find(e){const t=await this.dataSource().find(e);if(t)return Ti.wrap(t,this.networkConfig)}async findBy(e,t){if("id"==e)return this.find(t);if("address"==e){const e=await this.dataSource().findBy("address",t);if(!e)return;return Ti.wrap(e,this.networkConfig)}throw`search by ${e} not implemented`}async all(){const e=await this.dataSource().all();return e?e.map((e=>Ti.wrap(e,this.networkConfig))).filter((e=>e)):[]}async where(e){const t=await this.dataSource().where(e);if(!t)return[];return t.map((e=>Ti.wrap(e,this.networkConfig))).filter((e=>e))}}const gi=new t.Interface(["function gauge_relative_weight(address gauge, uint timestamp) view returns (uint)","function gauge_relative_weight_write(address gauge, uint timestamp) returns (uint)"]);class Ii{constructor(e,t,a){this.gaugeControllerAddress=t,this.multicall=Dn(e,a)}async getRelativeWeights(e,t){const a=e.map((e=>[this.gaugeControllerAddress,gi.encodeFunctionData("gauge_relative_weight_write",[s.getAddress(e),t||Math.floor(Date.now()/1e3)])])),[,n]=await this.multicall.aggregate(a);return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}}class Ei{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 wi extends Ei{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=kn(e)}}class xi extends Ei{constructor(e,t,a){super(),this.chainId=t,this.blockHeight=a,this.client=Nn(e)}}class Ai extends xi{async query(e){e.orderBy||(e.orderBy=cn.Balance),e.orderDirection||(e.orderDirection=yn.Desc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{gaugeShares:t}=await this.client.GaugeShares(e);return t.map(this.mapType)}mapType(e){var t;return{id:e.id,balance:e.balance,userAddress:null===(t=e.user)||void 0===t?void 0:t.id,gauge:{id:e.gauge.id,poolId:e.gauge.poolId||void 0,isKilled:e.gauge.isKilled,totalSupply:e.gauge.totalSupply}}}async findByUser(t,a,n){return this.findAllBy(e.GaugeShareAttributes.UserAddress,t,a,n)}async findByGauge(t,a,n){return this.findAllBy(e.GaugeShareAttributes.GaugeId,t,a,n)}}const Si=new t.Interface(["function totalSupply() view returns (uint)","function working_supply() view returns (uint)","function reward_count() view returns (uint)","function reward_tokens(uint rewardIndex) view returns (address)","function reward_data(address rewardToken) view returns (tuple(address token, address distributor, uint period_finish, uint rate, uint last_update, uint integral) data)"]);class Pi{constructor(e,t,a){this.chainId=t,this.multicall=Dn(e,a)}async getTotalSupplies(e){const t=e.map((e=>[e,Si.encodeFunctionData("totalSupply",[])])),[,a]=await this.multicall.aggregate(t),n=a.map((e=>"0x"==e?"0x0":e));return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}async getWorkingSupplies(e){const t=e.map((e=>[e,Si.encodeFunctionData("working_supply",[])])),[,a]=await this.multicall.aggregate(t),n=a.map((e=>"0x"==e?"0x0":e));return e.reduce(((e,t,a)=>(e[t]||(e[t]=parseFloat(Pe(n[a],18))),e)),{})}async getRewardCounts(e){let t;if(248==this.chainId||9372==this.chainId||6343==this.chainId||4326==this.chainId){const a=e.map((e=>[e,Si.encodeFunctionData("reward_count",[])])),[,n]=await this.multicall.aggregate(a),s=n.map((e=>"0x"==e?"0x0":e));t=e.reduce(((e,t,a)=>(e[t]||(e[t]=parseInt(s[a])),e)),{})}else t=e.reduce(((e,t)=>(e[t]||(e[t]=1),e)),{});return t}async getRewardTokens(e,t){const a=t||await this.getRewardCounts(e),n=e.filter((e=>a[e]>0)),s=[0],i=n.map(((e,t)=>{const n=[];for(let t=0;t<a[e];t++)n.push([e,Si.encodeFunctionData("reward_tokens",[t])]);return s[t+1]=s[t]+a[e],n})).flat(),[,r]=await this.multicall.aggregate(i);return n.reduce(((e,t,a)=>{const n=s[a],i=s[a+1],o=[];for(let e=n;e<i;e++)o.push(Si.decodeFunctionResult("reward_tokens",r[e])[0]);return e[t]||(e[t]=o),e}),{})}async getRewardData(e,t){const a=t||await this.getRewardTokens(e),n=[0],s=Object.keys(a).map(((e,t)=>{const s=[];for(let t=0;t<a[e].length;t++)s.push([e,Si.encodeFunctionData("reward_data",[a[e][t]])]);return n[t+1]=n[t]+a[e].length,s})).flat(),[,i]=await this.multicall.aggregate(s),r=i.map((e=>Si.decodeFunctionResult("reward_data",e)[0]));return Object.keys(a).reduce(((e,t,s)=>{const i=n[s],o=a[t].reduce(((e,t,a)=>(e[t]||(e[t]=r[i+a]),e)),{});return e[t]||(e[t]=o),e}),{})}}class Bi{constructor(e){this.gauges=[],this.client=Nn(e)}async fetch(){const e=(await this.client.Pools({where:{preferentialGauge_not:null},first:1e3})).pools.map((e=>e.preferentialGauge));return this.gauges=e,this.gauges}async find(e){return 0==this.gauges.length&&await this.fetch(),this.gauges.find((t=>t.id==e))}async findBy(e,t){if(0==this.gauges.length&&await this.fetch(),"id"==e)return this.find(t);if("poolId"==e)return this.gauges.find((e=>e.poolId==t));if("poolAddress"==e)return this.gauges.find((e=>e.poolAddress==t));throw`search by ${e} not implemented`}}const _i=6048e5;class Oi{constructor(e,t,a,n,s){this.chainId=n,this.workingSupplies={},this.workingSuppliesNextPeriod={},this.relativeWeights={},this.relativeWeightsNextPeriod={},this.rewardData={},a&&(this.gaugeController=new Ii(t,a,s)),this.multicall=new Pi(t,n,s),this.subgraph=new Bi(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()+_i)/_i)*_i)/1e3;this.relativeWeightsNextPeriod=await this.gaugeController.getRelativeWeights(t,e)}let a=!1;return this.rewardData=e.reduce(((e,t)=>{var s;return e[s=t.id]||(e[s]=t.tokens?Object.fromEntries(t.tokens.map((e=>[e.id.split("-")[0],{distributor:"",last_update:n.BigNumber.from(0),integral:n.BigNumber.from(0),token:e.id.split("-")[0],decimals:e.decimals,rate:Be(e.rate||"0",e.decimals),period_finish:n.BigNumber.from(e.periodFinish||"0")}]))):{}),t.tokens&&t.tokens.length>0&&(a=!0),e}),{}),a||(this.rewardData=await this.multicall.getRewardData(t)),e.map(this.compose.bind(this))}async find(e){return this.gauges||(this.gauges=this.fetch()),(await this.gauges).find((t=>t.id==e))}async findBy(e,t){let a;if(this.gauges||(this.gauges=this.fetch()),"id"==e)return this.find(t);if("address"==e)return this.find(t);if("poolId"==e)a=(await this.gauges).find((e=>e.poolId==t));else{if("poolAddress"!=e)throw`search by ${e} not implemented`;a=(await this.gauges).find((e=>e.poolAddress==t))}return a}compose(e){return{id:e.id,address:e.id,name:e.symbol,poolId:e.poolId,poolAddress:e.poolAddress,totalSupply:parseFloat(e.totalSupply),workingSupply:this.workingSupplies[e.id],relativeWeight:this.relativeWeights[e.id],relativeWeightNextPeriod:this.relativeWeightsNextPeriod[e.id],rewardTokens:this.rewardData[e.id]}}}class vi{constructor(e,t){this.url=e,this.apiKey=t}async get(e){try{const t=this.toPayload(e),{data:a}=await x.default.post(this.url,t,{headers:{"x-api-key":this.apiKey}});if(a.errors)throw new Error(a.errors.map((e=>e.message)).join(","));return a.data}catch(e){throw console.error(e),e}return[]}toPayload(e){return JSON.stringify({query:m.jsonToGraphQLQuery({query:e})})}}class ki{constructor(e){var t,a;this.skip=0,this.client=kn(e.url),this.blockHeight=e.blockHeight,this.chainId=e.chainId;const n={orderBy:xa.TotalLiquidity,orderDirection:ha.Desc,where:{swapEnabled:{eq:!0}}},s=Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||n),i=Object.assign({},(null===(a=e.query)||void 0===a?void 0:a.attrs)||{});this.query={args:s,attrs:i}}async fetchDefault(){const{pool0:e,pool1000:t,pool2000:a}=await this.client.AllPools({where:{swapEnabled:!0},orderBy:xa.TotalLiquidity,orderDirection:ha.Desc,block:await this.block()});return[...e,...t,...a].map(this.mapType.bind(this))}async fetch(e){(null==e?void 0:e.skip)&&(this.query.args.skip=e.skip),this.blockHeight&&(this.query.args.block={number:await this.blockHeight()}),this.query.args.first=(null==e?void 0:e.first)||1e3;const t=new Ke(this.query.args).format(new je),{pools:a}=await this.client.Pools(t);return this.skip=((null==e?void 0:e.skip)||0)+a.length,a.map(this.mapType.bind(this))}async find(e){return await this.findBy("id",e)}async findBy(e,t){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).find((a=>a[e]==t))}async all(){return this.pools||(this.pools=this.fetchDefault()),this.pools}async block(){return this.blockHeight?{number:await this.blockHeight()}:void 0}async where(e){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).filter(e)}mapType(e){var t,a,n,s,i,r,o,d,c;return{id:e.id,name:e.name||"",address:e.address,chainId:this.chainId,poolType:e.poolType,poolTypeVersion:e.poolTypeVersion||1,swapFee:e.swapFee,swapEnabled:e.swapEnabled,protocolYieldFeeCache:e.protocolYieldFeeCache||"0",protocolSwapFeeCache:e.protocolSwapFeeCache||"0",amp:null!==(t=e.amp)&&void 0!==t?t:void 0,owner:null!==(a=e.owner)&&void 0!==a?a:void 0,factory:null!==(n=e.factory)&&void 0!==n?n:void 0,symbol:null!==(s=e.symbol)&&void 0!==s?s:void 0,tokens:(e.tokens||[]).map(this.mapToken.bind(this)),tokensList:e.tokensList,tokenAddresses:(e.tokens||[]).map((e=>e.address)),totalLiquidity:e.totalLiquidity,totalShares:e.totalShares,totalSwapFee:e.totalSwapFee,totalSwapVolume:e.totalSwapVolume,priceRateProviders:null!==(i=e.priceRateProviders)&&void 0!==i?i:void 0,createTime:e.createTime,mainIndex:null!==(r=e.mainIndex)&&void 0!==r?r:void 0,wrappedIndex:null!==(o=e.wrappedIndex)&&void 0!==o?o:void 0,totalWeight:e.totalWeight||"1",lowerTarget:null!==(d=e.lowerTarget)&&void 0!==d?d:"0",upperTarget:null!==(c=e.upperTarget)&&void 0!==c?c:"0"}}mapToken(e){const t=this.mapSubPools(e.token);return{...e,isExemptFromYieldProtocolFee:e.isExemptFromYieldProtocolFee||!1,token:t}}mapSubPools(e){let t=null;return e.pool&&(t={id:e.pool.id,address:e.pool.address,totalShares:e.pool.totalShares,poolType:e.pool.poolType,mainIndex:e.pool.mainIndex||0},(null==e?void 0:e.pool.tokens)&&(t.tokens=e.pool.tokens.map(this.mapSubPoolToken.bind(this)))),{pool:t,latestUSDPrice:e.latestUSDPrice||void 0}}mapSubPoolToken(e){return{address:e.address,decimals:e.decimals,symbol:e.symbol,balance:e.balance,priceRate:e.priceRate,weight:e.weight,isExemptFromYieldProtocolFee:e.isExemptFromYieldProtocolFee||void 0,token:e.token?this.mapSubPools(e.token):void 0}}}class Ni{constructor(e){this.skip=0,this.poolsSubgraph=new ki({url:e.url,chainId:e.chainId,blockHeight:e.blockHeight,query:e.query}),this.provider=e.provider,this.multicall=e.multicall,this.vault=e.vault}async fetchDefault(){const e=await this.poolsSubgraph.fetch();return await qn(e,this.multicall,this.vault,this.provider)}async fetch(e){const t=await this.poolsSubgraph.fetch(e);return await qn(t,this.multicall,this.vault,this.provider)}async find(e){return await this.findBy("id",e)}async findBy(e,t){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).find((a=>a[e]==t))}async all(){return this.pools||(this.pools=this.fetchDefault()),this.pools}async where(e){return this.pools||(this.pools=this.fetchDefault()),(await this.pools).filter(e)}}class Ci extends xi{async query(e){!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{pools:t}=await this.client.PoolGauges(e);return t.map(this.mapType)}mapType(e){return e}}var Di;e.PoolJoinExitAttributes=void 0,(Di=e.PoolJoinExitAttributes||(e.PoolJoinExitAttributes={})).Pool="pool",Di.Sender="sender";class Fi extends wi{async query(e){e.orderBy||(e.orderBy=ba.Timestamp),e.orderDirection||(e.orderDirection=ha.Asc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{joinExits:t}=await this.client.JoinExits(e);return t.map(this.mapType)}mapType(e){return{id:e.id,userAddress:e.user.id,poolId:e.pool.id,timestamp:e.timestamp,type:e.type,amounts:e.amounts,tokens:e.pool.tokensList}}async findByUser(t,a,n){return this.findAllBy(e.PoolJoinExitAttributes.Sender,t,a,n)}async findJoins(e,t){return this.query({where:{sender:e,pool:t,type:"Join"}})}async findExits(e,t){return this.query({where:{sender:e,pool:t,type:"Exit"}})}async findByPool(t,a,n){return this.findAllBy(e.PoolJoinExitAttributes.Pool,t,a,n)}}class Ri extends wi{async query(e){e.orderBy||(e.orderBy=Ia.Balance),e.orderDirection||(e.orderDirection=ha.Desc),!e.block&&this.blockHeight&&(e.block={number:await this.blockHeight()});const{poolShares:t}=await this.client.PoolShares(e);return t.map(this.mapType)}mapType(e){return{id:e.id,userAddress:e.userAddress.id,poolId:e.poolId.id,balance:e.balance}}async findByUser(t,a,n){return this.findAllBy(e.PoolShareAttributes.UserAddress,t,a,n)}async findByPool(t,a,n){return this.findAllBy(e.PoolShareAttributes.PoolId,t,a,n)}}class Mi{constructor(e){this.tokens=e}async find(e){return this.tokens.find((t=>t.address.toLowerCase()===e.toLowerCase()))}async findBy(e,t){return this.tokens.find((a=>a[e]===t))}}class Li{constructor(e,t=1){this.chainId=t,this.prices={},this.baseTokenAddresses=e.map(Re),this.urlBase=`${tt[t].urls.priceUrl}/price/?vs_currencies=usd,eth`,this.debouncer=new Ue(this.fetch.bind(this),200)}fetch(e,{signal:t}={}){return e.length,x.default.get(this.url(e),{signal:t}).then((({data:e})=>e)).finally((()=>{e.length}))}fetchNative({signal:e}={}){let t;!function(e){e.ETH="ethereum",e.MATIC="matic-network",e.XDAI="xdai",e.OAS="oasys"}(t||(t={}));const a=t.OAS,n=this.url(["0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000"]);return x.default.get(n,{signal:e}).then((({data:e})=>e[a])).finally((()=>{}))}find(e){const t=e.toLowerCase();if(!this.prices[t]){if(0===Object.keys(this.prices).length)for(const e of this.baseTokenAddresses)this.prices[e]=this.debouncer.fetch(e).then((t=>t[e]));this.prices[t]=this.debouncer.fetch(t).then((e=>e[t]))}return this.prices[t]}async findBy(e,t){if("address"==e)return this.find(t)}platform(e){switch(e){case 1:case 5:case 42:case 31337:case 248:case 9372:case 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 Ui{constructor(e=1){this.chainId=e,this.prices={},this.urlBase=`https://api.coingecko.com/api/v3/coins/${this.platform(e)}/contract/%TOKEN_ADDRESS%/market_chart/range?vs_currency=usd`}fetch(e,t,{signal:a}={}){const n=this.urlRange(e,t);return x.default.get(n,{signal:a}).then((({data:e})=>e)).finally((()=>{}))}async find(e){throw"Historic price requires point-in-time timestamp, please use findBy(address, timestamp)"}async findBy(e,t){const a=Re(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 Gi{constructor(e,t=1){this.subgraphUrl=e,this.chainId=t,this.prices={},this.debouncer=new Ue(this.fetch.bind(this),200)}async fetch(e,{signal:t}={}){return e.length,x.default.post(this.subgraphUrl,{variables:{addresses:e},query:"query($addresses: [String!]) {\n tokens(\n where: {\n id_in: $addresses\n }\n ) {\n address\n latestUSDPrice\n }\n }"},{signal:t}).then((e=>e.data.data)).then((({tokens:e})=>Object.fromEntries(e.map((e=>[e.address,{usd:e.latestUSDPrice||void 0}]))))).finally((()=>{e.length}))}async find(e){const t=Re(e,this.chainId);return this.prices[t]||(this.prices[t]=this.debouncer.fetch(t).then((e=>e[t]))),this.prices[t]}async findBy(e,t){if("address"==e)return this.find(t)}}class qi{constructor(e,t,a){this.coingeckoRepository=e,this.subgraphRepository=t,this.aaveRates=a}async find(e){let t;try{try{if(t=await this.coingeckoRepository.find(e),!(null==t?void 0:t.usd))throw new Error(`Price not found:${e}`)}catch(a){console.error(`Coingecko API error: ${e} ${a}`),t=await this.subgraphRepository.find(e)}}catch(e){console.error(e),t={eth:"0",usd:"0.1"}}return t}async findBy(e,t){if("address"===e)return this.find(t);throw`Token price search by ${e} not implemented`}}class Wi{constructor(e,t){this.coingeckoRepository=e,this.aaveRates=t}async find(e){return this.findBy(e,Math.floor(Date.now()/1e3))}async findBy(e,t){const a=await this.coingeckoRepository.findBy(e,t),n=await this.aaveRates.getRate(e)||1;return a&&a.usd?{...a,usd:(parseFloat(a.usd)*n).toString()}:a}}const $i=new t.Interface(["function rate() view returns (uint256)"]);class Vi{constructor(e,t,a){this.network=a,this.multicall=Dn(e,t)}async fetch(e){const t=Object.values(_e[e]),a=t.map((e=>[e,$i.encodeFunctionData("rate",[])])),[,n]=await this.multicall.aggregate(a);return t.reduce(((e,t,a)=>(e[t]||(e[t]="0x"==n[a]?0:parseFloat(Pe(n[a],27))),e)),{})}async getRate(t){return this.network!=e.Network.MAINNET&&this.network!=e.Network.POLYGON?1:Object.values(_e[this.network]).includes(t)?(this.rates||(this.rates=this.fetch(this.network)),(await this.rates)[t]):1}}const Hi=new t.Interface(["function getTokensDistributedInWeek(address token, uint timestamp) view returns (uint)"]),ji=new t.Interface(["function totalSupply() view returns (uint)"]),Ki=new t.Interface(["function getRate() view returns (uint)"]);class Zi{constructor(e,t,a,n,s,i){this.feeDistributorAddress=t,this.balAddress=a,this.veBalAddress=n,this.bbAUsdAddress=s,this.multicall=Dn(e,i)}async fetch(e){const t=this.getPreviousWeek(e),a=[[this.feeDistributorAddress,Hi.encodeFunctionData("getTokensDistributedInWeek",[s.getAddress(this.balAddress),t])],[this.feeDistributorAddress,Hi.encodeFunctionData("getTokensDistributedInWeek",[s.getAddress(this.bbAUsdAddress),t])],[this.veBalAddress,ji.encodeFunctionData("totalSupply",[])],[this.bbAUsdAddress,Ki.encodeFunctionData("getRate",[])]],[,n]=await this.multicall.aggregate(a);return{balAmount:parseFloat(Pe(n[0],18)),bbAUsdAmount:parseFloat(Pe(n[1],18)),veBalSupply:parseFloat(Pe(n[2],18)),bbAUsdPrice:parseFloat(Pe(n[3],18)),balAddress:this.balAddress}}async multicallData(e){return this.data||(this.data=await this.fetch(e)),this.data}getPreviousWeek(e){const t=new Date(e);t.setUTCHours(0),t.setUTCMinutes(0),t.setUTCSeconds(0),t.setUTCMilliseconds(0);let a=t.getUTCDay()-4;return a<0&&(a+=7),a+=7,Math.floor(t.getTime()/1e3)-86400*a}}const Xi=new t.Interface(["function getProtocolFeesCollector() view returns (address)"]),Ji=new t.Interface(["function getSwapFeePercentage() view returns (uint)"]);let Yi;class zi{constructor(e,t){this.provider=t,this.vault=new i.Contract(e,Xi,this.provider)}async fetch(){const e=await this.vault.getProtocolFeesCollector(),t=new i.Contract(e,Ji,this.provider),a=await t.getSwapFeePercentage();return parseFloat(Pe(a,18))}async find(){return Yi||(Yi=this.fetch()),this.swapFeePercentage=await Yi,this.swapFeePercentage}async findBy(){return this.find()}}const Qi=new t.Interface(["function getSwapFeePercentage() view returns (uint)"]);let er;class tr{constructor(e,t,a){this.protocolFeePercentagesProviderAddress=t,this.multicall=Dn(e,a)}async fetch(){const e=[[this.protocolFeePercentagesProviderAddress,Qi.encodeFunctionData("getFeeTypePercentage",[0])],[this.protocolFeePercentagesProviderAddress,Qi.encodeFunctionData("getFeeTypePercentage",[2])]],[,t]=await this.multicall.aggregate(e);return{swapFee:parseFloat(Pe(t[0],18)),yieldFee:parseFloat(Pe(t[2],18))}}async getFees(){return er||(er=this.fetch()),this.protocolFees=await er,this.protocolFees}}const ar={stETH:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",wstETH:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",arbitrumStEth:"0x5979d7b546e38e414f7e9822514be443a4800529"},nr=async()=>{let e=0;try{const t=await x.default.get("https://lido-aprs-proxy.balancer.workers.dev/?network=1"),{data:a}=t.data;e=Math.round(100*parseFloat(a.smaApr))}catch(e){console.error("Failed to fetch stETH APR:",e)}return{[ar.stETH]:e,[ar.wstETH]:e,[ar.arbitrumStEth]:e}},sr={rETH:"0xae78736cd615f374d3085123a210448e74fc6393"},ir=async()=>{let e=0;try{const t=await x.default.get("https://api.rocketpool.net/api/apr"),{yearlyAPR:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[sr.rETH]:e}},rr={stMATIC:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4"},or=async()=>{let e=0;try{const t=await x.default.get("https://lido-aprs-proxy.balancer.workers.dev/?network=137"),{apr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch stMATIC APR:",e)}return{[rr.stMATIC]:e}},dr={usdcUSDplus:"0x1aafc31091d93c3ff003cff5d2d8f7ba2e728425",usdcUSDplus2:"0x6933ec1ca55c06a894107860c92acdfd2dd8512f"},cr=async()=>{let e=0;try{const{data:t}=await x.default.get("https://app.overnight.fi/api/balancer/week/apr");e=Math.round(1e4*parseFloat(t)/100)}catch(e){console.error("Failed to fetch USD+ APR:",e)}return Object.fromEntries(Object.values(dr).map((t=>[t,e])))},lr={sfrxETH:"0xac3e018457b222d93114458476f3e3416abbe38f"},pr=async()=>{let e=0;try{const t=await x.default.get("https://api.frax.finance/v2/frxeth/summary/latest"),{sfrxethApr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[lr.sfrxETH]:e}},ur={maticX:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6"},br=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=stader"),{value:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[ur.maticX]:e}},yr={qETH:"0x93ef1ea305d11a9b2a3ebb9bb4fcc34695292e7d"},mr=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=tranchess"),[{weeklyAveragePnlPercentage:a}]=t.data;e=Math.round(parseFloat(Pe(n.BigNumber.from(a).mul(365).mul(1e4),18)))}catch(e){console.error("Failed to fetch qETH APR:",e)}return{[yr.qETH]:e}},fr={USDR:"0xaf0d9d65fc54de245cda37af3d18cbec860a4d4b"},hr=async()=>{let e=0;try{const t=await x.default.get("https://generic-apr-proxy.balancer.workers.dev/?provider=usdr"),{usdr:a}=t.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch USDR APR:",e)}return{[fr.USDR]:e}},Tr={rETH:"0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593"},gr=async()=>{let e=0;try{const t=await x.default.get("https://drop-api.stafi.io/reth/v1/poolData/"),{stakeApr:a}=t.data.data;e=Math.round(100*parseFloat(a))}catch(e){console.error("Failed to fetch APR:",e)}return{[Tr.rETH]:e}},Ir=new u.JsonRpcProvider("https://rpc.ankr.com/eth",1),Er={getPoolsUI:new i.Contract("0x5954aB967Bc958940b7EB73ee84797Dc8a2AFbb9",[{inputs:[],name:"getPoolsUI",outputs:[{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"},{components:[{internalType:"uint256",name:"poolId",type:"uint256"},{internalType:"uint256",name:"stakedAmount",type:"uint256"},{components:[{internalType:"uint48",name:"startTimestampHour",type:"uint48"},{internalType:"uint48",name:"endTimestampHour",type:"uint48"},{internalType:"uint96",name:"rewardsPerHour",type:"uint96"},{internalType:"uint96",name:"capPerPosition",type:"uint96"}],internalType:"struct ApeCoinStaking.TimeRange",name:"currentTimeRange",type:"tuple"}],internalType:"struct ApeCoinStaking.PoolUI",name:"",type:"tuple"}],stateMutability:"view",type:"function"}],Ir).getPoolsUI},wr={sApe:"0x7966c5bae631294d7cffcea5430b78c2f76db6fa"},xr=async(e=1,t=Er)=>{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{[wr.sApe]:a}},Ar={eUSDC:"0xeb91861f8a4e1c12333f42dce8fb0ecdc28da716",eDAI:"0xe025e3ca2be02316033184551d4d3aa22024d9dc",eUSDT:"0x4d19f33948b99800b6113ff3e83bec9b537c85d2",eFRAX:"0x5484451a88a35cd0878a1be177435ca8a0e4054e"},Sr={[e.Network.MAINNET]:"https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet"},Pr=async()=>{const t=e.Network.MAINNET,a={operationName:"getAssetsAPY",query:"\n query getAssetsAPY($eTokenAddress_in: [String!]) {\n assets(\n where: {\n eTokenAddress_in: $eTokenAddress_in\n }\n ) {\n eTokenAddress\n supplyAPY\n }\n }\n",variables:{eTokenAddress_in:Object.values(Ar)}},s=await x.default.post(Sr[t],a),{data:{assets:i}}=s.data,r={eUSDT:0,eDAI:0,eUSDC:0,eFRAX:0};return i.forEach((({eTokenAddress:e,supplyAPY:t})=>{const a=Object.entries(Ar).filter((([,t])=>t.toLocaleLowerCase()===e.toLocaleLowerCase()))[0][0];r[a]=Math.round(1e4*parseFloat(Pe(n.BigNumber.from(t),27)))})),{[Ar.eUSDT]:r.eUSDT,[Ar.eDAI]:r.eDAI,[Ar.eUSDC]:r.eUSDC,[Ar.eFRAX]:r.eFRAX}},Br=Object.fromEntries([...Object.values(ar).map((e=>[e,nr])),...Object.values(rr).map((e=>[e,or])),...Object.values(Oe).map((e=>[e,Fe])),...Object.values(dr).map((e=>[e,cr])),...Object.values(sr).map((e=>[e,ir])),...Object.values(lr).map((e=>[e,pr])),...Object.values(ur).map((e=>[e,br])),...Object.values(yr).map((e=>[e,mr])),...Object.values(fr).map((e=>[e,hr])),...Object.values(Tr).map((e=>[e,gr])),...Object.values(wr).map((e=>[e,xr])),...Object.values(Ar).map((e=>[e,Pr]))]);class _r{constructor(e,t=Br){this.network=e,this.sources=t,this.yields={}}async fetch(e){const t=await this.sources[e](this.network);this.yields={...this.yields,...t}}async find(e){const t=e.toLocaleLowerCase();return Object.keys(this.sources).includes(t)&&!Object.keys(this.yields).includes(t)&&await this.fetch(t),this.yields[t]}async findBy(e,t){if("address"==e)return this.find(t)}}const Or=e=>`{\n blocks(first: 1, orderBy: timestamp, orderDirection: asc, where: { timestamp_gt: ${e} }) {\n number\n }\n}`,vr=async(e,t)=>{const a={query:Or(t)},n=await x.default.post(e,a),{data:{blocks:s}}=n.data;return parseInt(s[0].number)};class kr{constructor(e){this.endpoint=e,this.blocks={}}async find(e){if("dayAgo"==e){const e=""+(Math.floor(Date.now()/1e3)-86400);return this.blocks[e]||(this.blocks={...this.blocks,[e]:vr(this.endpoint,e)}),this.blocks[e]}}async findBy(e="",t=""){}}var Nr,Cr,Dr=[{chainId:1,address:"0x8888801af4d980682e47f1a9036e589479e835c5",symbol:"mph"},{chainId:1,address:"0x27054b13b1b798b345b591a4d22e6562d47ea75a",symbol:"ast"},{chainId:1,address:"0x3301ee63fb29f863f2333bd4466acb46cd8323e6",symbol:"akita"},{chainId:1,address:"0x616e8bfa43f920657b3497dbf40d6b1a02d4608d",symbol:"aurabal"},{chainId:1,address:"0xc0c293ce456ff0ed870add98a0828dd4d2903dbf",symbol:"aura"},{chainId:1,address:"0x3472a5a71965499acd81997a54bba8d852c6e53d",symbol:"badger"},{chainId:1,address:"0xba100000625a3754423978a60c9317c58a424e3d",symbol:"bal"},{chainId:1,address:"0x804cdb9116a10bb78768d3252355a1b18067bf8f",symbol:"bb-a-dai"},{chainId:1,address:"0x9210f1204b5a24742eba12f710636d76240df3d0",symbol:"bb-a-usdc"},{chainId:1,address:"0x2bbf681cc4eb09218bee85ea2a5d3d13fa40fc0c",symbol:"bb-a-usdt"},{chainId:1,address:"0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2",symbol:"bb-a-usd"},{chainId:1,address:"0x2d94aa3e47d9d5024503ca8491fce9a2fb4da198",symbol:"bank"},{chainId:1,address:"0x0d8775f648430679a709e98d2b0cb6250d2887ef",symbol:"bat"},{chainId:1,address:"0xf17e65822b568b3903685a7c9f496cf7656cc6c2",symbol:"bico"},{chainId:1,address:"0x799ebfabe77a6e34311eeee9825190b9ece32824",symbol:"btrst"},{chainId:1,address:"0x514910771af9ca656af840dff83e8264ecf986ca",symbol:"link"},{chainId:1,address:"0x3506424f91fd33084466f402d5d97f05f8e3b4af",symbol:"chz"},{chainId:1,address:"0x41e5560054824ea6b0732e656e3ad64e20e94e45",symbol:"cvc"},{chainId:1,address:"0xc00e94cb662c3520282e6f5717214004a7f26888",symbol:"comp"},{chainId:1,address:"0xdef1ca1fb7fbcdc777520aa7f396b4e015f497ab",symbol:"cow"},{chainId:1,address:"0xd533a949740bb3306d119cc777fa900ba034cd52",symbol:"crv"},{chainId:1,address:"0x6b175474e89094c44da98b954eedeac495271d0f",symbol:"dai"},{chainId:1,address:"0xf2051511b9b121394fa75b8f7d4e7424337af687",symbol:"haus"},{chainId:1,address:"0x888888435fde8e7d4c54cab67f206e4199454c60",symbol:"dfx"},{chainId:1,address:"0x798d1be841a82a273720ce31c822c61a67a601c3",symbol:"digg"},{chainId:1,address:"0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c",symbol:"enj"},{chainId:1,address:"0xc18360217d8f7ab5e7c516566761ea12ce7f9d72",symbol:"ens"},{chainId:1,address:"0x4e15361fd6b4bb609fa63c81a2be19d873717870",symbol:"ftm"},{chainId:1,address:"0x956f47f50a910163d8bf957cf5846d573e7f87ca",symbol:"fei"},{chainId:1,address:"0xed1480d12be41d92f36f5f7bdd88212e381a3677",symbol:"fdt"},{chainId:1,address:"0x586aa273f262909eef8fa02d90ab65f5015e0516",symbol:"fiat"},{chainId:1,address:"0xde30da39c46104798bb5aa3fe8b9e0e1f348163f",symbol:"gtc"},{chainId:1,address:"0x900db999074d9277c5da2a43f252d74366230da0",symbol:"giv"},{chainId:1,address:"0x6810e776880c02933d47db1b9fc05908e5386b96",symbol:"gno"},{chainId:1,address:"0xba485b556399123261a5f9c95d413b4f93107407",symbol:"graviaura"},{chainId:1,address:"0x3ec8798b81485a254928b70cda1cf0a2bb0b74d7",symbol:"gro"},{chainId:1,address:"0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",symbol:"snx"},{chainId:1,address:"0x5a98fcbea516cf06857215779fd812ca3bef1b32",symbol:"ldo"},{chainId:1,address:"0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d",symbol:"lqty"},{chainId:1,address:"0x5f98805a4e8be255a32880fdec7f6728c6568ba0",symbol:"lusd"},{chainId:1,address:"0x965d79f1a1016b574a62986e13ca8ab04dfdd15c",symbol:"m2"},{chainId:1,address:"0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",symbol:"mkr"},{chainId:1,address:"0xd084944d3c05cd115c09d072b9f44ba3e0e45921",symbol:"fold"},{chainId:1,address:"0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",symbol:"matic"},{chainId:1,address:"0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",symbol:"mta"},{chainId:1,address:"0x4b13006980acb09645131b91d259eaa111eaf5ba",symbol:"myc"},{chainId:1,address:"0x333a4823466879eef910a04d473505da62142069",symbol:"nation"},{chainId:1,address:"0xcfeaead4947f0705a14ec42ac3d44129e1ef3ed5",symbol:"note"},{chainId:1,address:"0x967da4048cd07ab37855c090aaf366e4ce1b9f48",symbol:"ocean"},{chainId:1,address:"0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5",symbol:"ohm"},{chainId:1,address:"0xab846fb6c81370327e784ae7cbb6d6a6af6ff4bf",symbol:"pal"},{chainId:1,address:"0xcafe001067cdef266afb7eb5a286dcfd277f3de5",symbol:"psp"},{chainId:1,address:"0x68037790a0229e9ce6eaa8a99ea92964106c4703",symbol:"par"},{chainId:1,address:"0x45804880de22913dafe09f4980848ece6ecbaf78",symbol:"paxg"},{chainId:1,address:"0x89ab32156e46f46d02ade3fecbe5fc4243b9aaed",symbol:"pnt"},{chainId:1,address:"0x9992ec3cf6a55b00978cddf2b27bc6882d88d1ec",symbol:"poly"},{chainId:1,address:"0x43d4a3cd90ddd2f8f4f693170c9c8098163502ad",symbol:"d2d"},{chainId:1,address:"0xeb4c2781e4eba804ce9a9803c67d0893436bb27d",symbol:"renbtc"},{chainId:1,address:"0x408e41876cccdc0f92210600ef50372656052a38",symbol:"ren"},{chainId:1,address:"0xfb5453340c03db5ade474b27e68b6a9c6b2823eb",symbol:"robot"},{chainId:1,address:"0xd33526068d116ce69f19a9ee46f0bd304f21a51f",symbol:"rpl"},{chainId:1,address:"0xae78736cd615f374d3085123a210448e74fc6393",symbol:"reth"},{chainId:1,address:"0xfe18be6b3bd88a2d2a7f928d00292e7a9963cfc6",symbol:"sbtc"},{chainId:1,address:"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff",symbol:"srm"},{chainId:1,address:"0x35e78b3982e87ecfd5b3f3265b601c046cdbe232",symbol:"xai"},{chainId:1,address:"0x3affcca64c2a6f4e3b6bd9c64cd2c969efd1ecbe",symbol:"dsla"},{chainId:1,address:"0xf24d8651578a55b0c119b9910759a351a3458895",symbol:"sdbal"},{chainId:1,address:"0x11c1a6b3ed6bb362954b29d3183cfa97a0c806aa",symbol:"str"},{chainId:1,address:"0x8f693ca8d21b157107184d29d398a8d082b38b76",symbol:"data"},{chainId:1,address:"0x470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7",symbol:"temple"},{chainId:1,address:"0xa36fdbbae3c9d55a1d67ee5821d53b50b63a1ab9",symbol:"temp"},{chainId:1,address:"0xdac17f958d2ee523a2206206994597c13d831ec7",symbol:"usdt"},{chainId:1,address:"0x9c4a4204b79dd291d6b6571c5be8bbcd0622f050",symbol:"tcr"},{chainId:1,address:"0x226f7b842e0f0120b7e194d05432b3fd14773a9d",symbol:"unn"},{chainId:1,address:"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",symbol:"uni"},{chainId:1,address:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",symbol:"usdc"},{chainId:1,address:"0x81f8f0bb1cb2a06649e51913a151f0e7ef6fa321",symbol:"vita"},{chainId:1,address:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",symbol:"weth"},{chainId:1,address:"0xedb171c18ce90b633db442f2a6f72874093b49ef",symbol:"wampl"},{chainId:1,address:"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",symbol:"wbtc"},{chainId:1,address:"0xf203ca1769ca8e9e8fe1da9d147db68b6c919817",symbol:"wncg"},{chainId:1,address:"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",symbol:"wsteth"},{chainId:1,address:"0x79c71d3436f39ce382d0f58f1b011d88100b9d91",symbol:"xns"},{chainId:1,address:"0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",symbol:"yfi"},{chainId:1,address:"0xbcca60bb61934080951369a648fb03df4f96263c",symbol:"ausdc"},{chainId:1,address:"0x028171bca77440897b824ca71d1c56cac55b68a3",symbol:"adai"},{chainId:1,address:"0x3ed3b47dd13ec9a98b44e6204a523e766b225811",symbol:"ausdt"},{chainId:137,address:"0x9c2c5fd7b07e95ee044ddeba0e97a665f142394f",symbol:"1inch"},{chainId:137,address:"0xd6df932a45c0f255f85145f286ea0b292b21c90b",symbol:"aave"},{chainId:137,address:"0xc3fdbadc7c795ef1d6ba111e06ff8f16a20ea539",symbol:"addy"},{chainId:137,address:"0xf84bd51eab957c2e7b7d646a3427c5a50848281d",symbol:"agar"},{chainId:137,address:"0x033d942a6b495c4071083f4cde1f17e986fe856c",symbol:"aga"},{chainId:137,address:"0x0e9b89007eee9c958c0eda24ef70723c2c93dd58",symbol:"amaticc"},{chainId:137,address:"0x034b2090b579228482520c589dbd397c53fc51cc",symbol:"vision"},{chainId:137,address:"0x2c89bbc92bd86f8075d1decc58c7f4e0107f286b",symbol:"avax"},{chainId:137,address:"0x49690541e3f6e933a9aa3cffee6010a7bb5b72d7",symbol:"axiav3"},{chainId:137,address:"0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",symbol:"bal"},{chainId:137,address:"0xdb7cb471dd0b49b29cab4a1c14d070f27216a0ab",symbol:"bank"},{chainId:137,address:"0xfbdd194376de19a88118e84e279b977f165d01b8",symbol:"bifi"},{chainId:137,address:"0xd6ca869a4ec9ed2c7e618062cdc45306d8dbbc14",symbol:"btc2x-fli-p"},{chainId:137,address:"0x53e0bca35ec356bd5dddfebbd1fc0fd03fabad39",symbol:"link"},{chainId:137,address:"0x172370d5cd63279efa6d502dab29171933a610af",symbol:"crv"},{chainId:137,address:"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",symbol:"dai"},{chainId:137,address:"0x1d607faa0a51518a7728580c238d912747e71f7a",symbol:"data"},{chainId:137,address:"0x85955046df4668e1dd369d2de9f3aeb98dd2a369",symbol:"dpi"},{chainId:137,address:"0xe7804d91dfcde7f776c90043e03eaa6df87e6395",symbol:"dfx"},{chainId:137,address:"0xf28164a485b0b2c90639e47b0f377b4a438a16b1",symbol:"dquick"},{chainId:137,address:"0x45c32fa6df82ead1e2ef74d17b76547eddfaff89",symbol:"frax"},{chainId:137,address:"0x50b728d8d964fd00c2d0aad81718b71311fef68a",symbol:"snx"},{chainId:137,address:"0x72928d5436ff65e57f72d5566dcd3baedc649a88",symbol:"hdao"},{chainId:137,address:"0x3ad707da309f3845cd602059901e39c4dcd66473",symbol:"eth2x-fli-p"},{chainId:137,address:"0x4f025829c4b13df652f38abd2ab901185ff1e609",symbol:"ieth-fli-p"},{chainId:137,address:"0x340f412860da7b7823df372a2b59ff78b7ae6abc",symbol:"imatic-fli-p"},{chainId:137,address:"0xf287d97b6345bad3d88856b26fb7c0ab3f2c7976",symbol:"matic2x-fli-p"},{chainId:137,address:"0x130ce4e4f76c2265f94a961d70618562de0bb8d2",symbol:"ibtc-fli-p"},{chainId:137,address:"0x596ebe76e2db4470966ea395b0d063ac6197a8c5",symbol:"jrt"},{chainId:137,address:"0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4",symbol:"stmatic"},{chainId:137,address:"0xf501dd45a1198c2e1b5aef5314a68b9006d842e0",symbol:"mta"},{chainId:137,address:"0xeaecc18198a475c921b24b8a6c1c1f0f5f3f7ea0",symbol:"seed"},{chainId:137,address:"0xfe712251173a2cd5f5be2b46bb528328ea3565e1",symbol:"mvi"},{chainId:137,address:"0xa3fa99a148fa48d14ed51d610c367c61876997f1",symbol:"mimatic"},{chainId:137,address:"0xa486c6bc102f409180ccb8a94ba045d39f8fc7cb",symbol:"nex"},{chainId:137,address:"0xe2aa7db6da1dae97c5f5c6914d285fbfcc32a128",symbol:"par"},{chainId:137,address:"0x580a84c73811e1839f75d86d75d88cca0c241ff4",symbol:"qi"},{chainId:137,address:"0x831753dd7087cac61ab5644b308642cc1c33dc13",symbol:"quick"},{chainId:137,address:"0xb5c064f955d8e7f38fe0460c556a72987494ee17",symbol:"quick"},{chainId:137,address:"0x00e5646f60ac6fb446f621d146b6e1886f002905",symbol:"rai"},{chainId:137,address:"0x431cd3c9ac9fc73644bf68bf5691f4b83f9e104f",symbol:"rbw"},{chainId:137,address:"0xdbf31df14b66535af65aac99c32e9ea844e14501",symbol:"renbtc"},{chainId:137,address:"0x501ace9c35e60f03a2af4d484f49f9b1efde9f40",symbol:"solace"},{chainId:137,address:"0xfa68fb4628dff1028cfec22b4162fccd0d45efb6",symbol:"maticx"},{chainId:137,address:"0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a",symbol:"sushi"},{chainId:137,address:"0xdf7837de1f2fa4631d716cf2502f8b230f1dcc32",symbol:"tel"},{chainId:137,address:"0xe6469ba6d2fd6130788e0ea9c0a0515900563b59",symbol:"ust"},{chainId:137,address:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",symbol:"usdt"},{chainId:137,address:"0x5fe2b58c013d7601147dcdd68c143a77499f5531",symbol:"grt"},{chainId:137,address:"0xbbba073c31bf03b8acf7c28ef0738decf3695683",symbol:"sand"},{chainId:137,address:"0x2934b36ca9a4b31e633c5be670c8c8b28b6aa015",symbol:"thx"},{chainId:137,address:"0x2f800db0fdb5223b3c3f354886d907a671414a7f",symbol:"bct"},{chainId:137,address:"0x2e1ad108ff1d8c782fcbbb89aad783ac49586756",symbol:"tusd"},{chainId:137,address:"0x3809dcdd5dde24b37abe64a5a339784c3323c44f",symbol:"swap"},{chainId:137,address:"0x7fbc10850cae055b27039af31bd258430e714c62",symbol:"ubt"},{chainId:137,address:"0x2791bca1f2de4661ed88a30c99a7a9449aa84174",symbol:"usdc"},{chainId:137,address:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",symbol:"weth"},{chainId:137,address:"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",symbol:"wmatic"},{chainId:137,address:"0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6",symbol:"wbtc"},{chainId:137,address:"0x24834bbec7e39ef42f4a75eaf8e5b6486d3f0e57",symbol:"lunc"},{chainId:137,address:"0xf153eff70dc0bf3b085134928daeea248d9b30d0",symbol:"xmark"},{chainId:42161,address:"0x9f20de1fc9b161b34089cbeae888168b44b03461",symbol:"arbis"},{chainId:42161,address:"0x040d1edc9569d4bab2d15287dc5a4f10f56a56b8",symbol:"bal"},{chainId:42161,address:"0x031d35296154279dc1984dcd93e392b1f946737b",symbol:"cap"},{chainId:42161,address:"0xf97f4df75117a78c1a5a0dbb814af92458539fb4",symbol:"link"},{chainId:42161,address:"0x354a6da3fcde098f8389cad84b0182725c6c91de",symbol:"comp"},{chainId:42161,address:"0xf4d48ce3ee1ac3651998971541badbb9a14d7234",symbol:"cream"},{chainId:42161,address:"0x11cdb42b0eb46d95f990bedd4695a6e3fa034978",symbol:"crv"},{chainId:42161,address:"0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",symbol:"dai"},{chainId:42161,address:"0x8038f3c971414fd1fc220ba727f2d4a0fc98cb65",symbol:"dht"},{chainId:42161,address:"0xf0b5ceefc89684889e5f7e0a7775bd100fcd3709",symbol:"dusd"},{chainId:42161,address:"0x6c2c06790b3e3e3c38e12ee22f8183b37a13ee55",symbol:"dpx"},{chainId:42161,address:"0x32eb7902d4134bf98a28b963d26de779af92a212",symbol:"rdpx"},{chainId:42161,address:"0xc3ae0333f0f34aa734d5493276223d95b8f9cb37",symbol:"dxd"},{chainId:42161,address:"0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a",symbol:"gmx"},{chainId:42161,address:"0xa0b862f60edef4452f25b4160f177db44deb6cf1",symbol:"gno"},{chainId:42161,address:"0xb965029343d55189c25a7f3e0c9394dc0f5d41b1",symbol:"ndx"},{chainId:42161,address:"0x539bde0d7dbd336b79148aa742883198bbf60342",symbol:"magic"},{chainId:42161,address:"0x4e352cf164e64adcbad318c3a1e222e9eba4ce42",symbol:"mcb"},{chainId:42161,address:"0x3f56e0c36d275367b8c502090edf38289b3dea0d",symbol:"mimatic"},{chainId:42161,address:"0x965772e0e9c84b6f359c8597c891108dcf1c5b1a",symbol:"pickle"},{chainId:42161,address:"0x6694340fc020c5e6b96567843da2df01b2ce1eb6",symbol:"stg"},{chainId:42161,address:"0xd4d42f0b6def4ce0383636770ef773390d85c61a",symbol:"sushi"},{chainId:42161,address:"0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",symbol:"usdt"},{chainId:42161,address:"0x23a941036ae778ac51ab04cea08ed6e2fe103614",symbol:"grt"},{chainId:42161,address:"0xa72159fc390f0e3c6d415e658264c7c4051e9b87",symbol:"tcr"},{chainId:42161,address:"0x4d15a3a2286d883af0aa1b3f21367843fac63e07",symbol:"tusd"},{chainId:42161,address:"0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0",symbol:"uni"},{chainId:42161,address:"0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",symbol:"usdc"},{chainId:42161,address:"0xa684cd057951541187f288294a1e1c2646aa2d24",symbol:"vsta"},{chainId:42161,address:"0x64343594ab9b56e99087bfa6f2335db24c2d1f17",symbol:"vst"},{chainId:42161,address:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",symbol:"weth"},{chainId:42161,address:"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",symbol:"wbtc"},{chainId:42161,address:"0x82e3a8f066a6989666b031d916c43672085b1582",symbol:"yfi"},{chainId:16116,address:"0x5a89E11Cb554E00c2f51C4bb7F05bc7Ab0Fa6351",symbol:"weth"},{chainId:9372,address:"0x5200000000000000000000000000000000000001",symbol:"weth"},{chainId:248,address:"0x5200000000000000000000000000000000000001",symbol:"weth"},{chainId:6343,address:"0xAba76Cdc5910F6627856EB75Bcce0171376999C7",symbol:"weth"},{chainId:4326,address:"0x4200000000000000000000000000000000000006",symbol:"weth"}];class Fr{constructor(e,t,a){this.pools=new ki({url:e.urls.subgraph,chainId:e.chainId}),this.poolsOnChain=new Ni({url:e.urls.subgraph,chainId:e.chainId,provider:t,multicall:e.addresses.contracts.multicall,vault:e.addresses.contracts.vault,query:a}),this.poolShares=new Ri(e.urls.subgraph,e.chainId),this.poolJoinExits=new Fi(e.urls.subgraph,e.chainId),e.urls.gaugesSubgraph&&(this.poolGauges=new Ci(e.urls.gaugesSubgraph,e.chainId),this.gaugeShares=new Ai(e.urls.gaugesSubgraph,e.chainId)),e.urls.blockNumberSubgraph&&(this.blockNumbers=new kr(e.urls.blockNumberSubgraph));this.yesterdaysPools=new ki({url:e.urls.subgraph,chainId:e.chainId,blockHeight:async()=>{const e=await t.getBlockNumber();return Number(e)-5e3}});const n=Dr.filter((t=>t.chainId==e.chainId)).map((e=>e.address)),s=new Li(n,e.chainId),i=new Gi(e.urls.subgraph,e.chainId),r=new Vi(e.addresses.contracts.multicall,t,e.chainId);this.tokenPrices=new qi(s,i,r);const o=new Ui(e.chainId);this.tokenHistoricalPrices=new Wi(o,r),this.tokenMeta=new Mi([]),e.urls.gaugesSubgraph&&(this.liquidityGauges=new Oi(e.urls.gaugesSubgraph,e.addresses.contracts.multicall,e.addresses.contracts.gaugeController||"",e.chainId,t)),e.addresses.contracts.feeDistributor&&e.addresses.tokens.bal&&e.addresses.tokens.veBal&&e.addresses.tokens.bbaUsd&&(this.feeDistributor=new Zi(e.addresses.contracts.multicall,e.addresses.contracts.feeDistributor,e.addresses.tokens.bal,e.addresses.tokens.veBal,e.addresses.tokens.bbaUsd,t)),this.feeCollector=new zi(e.addresses.contracts.vault,t),e.addresses.contracts.protocolFeePercentagesProvider&&(this.protocolFees=new tr(e.addresses.contracts.multicall,e.addresses.contracts.protocolFeePercentagesProvider,t)),this.tokenYields=new _r(e.chainId)}}!function(e){e[e.Direct=0]="Direct",e[e.TokenIn=1]="TokenIn",e[e.TokenOut=2]="TokenOut",e[e.Middle=3]="Middle"}(Nr||(Nr={})),function(e){e[e.Swap=0]="Swap",e[e.BatchSwap=1]="BatchSwap",e[e.Join=2]="Join",e[e.Exit=3]="Exit"}(Cr||(Cr={}));const Rr={type:Cr.BatchSwap,swaps:[],opRef:[],minOut:"0",assets:[],hasTokenIn:!1,hasTokenOut:!1,fromInternal:!1,toInternal:!1,limits:[],approveTokens:[],sender:"",receiver:""},Mr=new t.Interface(gs);function Lr(e,t){return e.some((e=>e.address.toLowerCase()===t.toLowerCase()))}function Ur(e,t){const a=t[e.assetOutIndex],n=D(e.poolId);return a.toLowerCase()===n.toLowerCase()}function Gr(e,t){const a=t[e.assetInIndex],n=D(e.poolId);return a.toLowerCase()===n.toLowerCase()}function qr(e,t,a){let n={};var s;return e!==Nr.TokenIn&&e!==Nr.Middle||(s=a,n={index:t,key:cs.toChainedReference(s)},a++),[n,a]}function Wr(e,t){return ze(n.BigNumber.from(e),n.BigNumber.from(t)).toString()}function $r(e,t,a,n){let s=e.amount;return(a===Nr.TokenOut||a===Nr.Middle&&t===Cr.Join||a===Nr.Middle&&t===Cr.Exit)&&(s=cs.toChainedReference(n-1).toString()),s}function Vr(e,t,a,n){let s;return s=a===e&&n===t?Nr.Direct:a===e?Nr.TokenIn:n===t?Nr.TokenOut:Nr.Middle,s}function Hr(e,t){const s=function(e){const t=[],a=[],n=[];for(const s of e)s.type===Cr.Exit||s.type===Cr.Join?s.hasTokenIn?t.push(s):s.hasTokenOut?a.push(s):n.push(s):n.push(s);return[...t,...n,...a]}(e),i=function(e,t){const s=[];let i=c.cloneDeep(Rr);i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"));let r=!0,o={};for(const d of e)d.type===Cr.Swap?(r&&(o=d,r=!1),d.isBptIn&&i.approveTokens.push(d.assets[d.swap.assetInIndex]),d.fromInternal===o.fromInternal&&d.toInternal===o.toInternal&&d.receiver===o.receiver&&d.sender===o.sender||i.swaps.length>0&&(s.push(i),i=c.cloneDeep(Rr),i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"))),i.swaps.push(d.swap),i.opRef.push(...d.opRef),i.fromInternal=d.fromInternal,i.toInternal=d.toInternal,i.sender=d.sender,i.receiver=d.receiver,d.hasTokenIn?(i.hasTokenIn=!0,i.limits[d.swap.assetInIndex]=i.limits[d.swap.assetInIndex].add(d.amountIn)):i.limits[d.swap.assetInIndex]=a.MaxInt256,d.hasTokenOut&&(i.hasTokenOut=!0,i.limits[d.swap.assetOutIndex]=i.limits[d.swap.assetOutIndex].sub(d.minOut)),o=d):(i.swaps.length>0&&(s.push(i),i=c.cloneDeep(Rr),i.assets=t,i.limits=Array(t.length).fill(n.BigNumber.from("0"))),s.push(d));return i.swaps.length>0&&s.push(i),s}(s,t);return i}function jr(e,t,a,n,s,i,r,o){var d;const c=Vr(t,a,e.assetInIndex,e.assetOutIndex),l=$r(e,Cr.Join,c,n),p=Wr(null!==(d=e.returnAmount)&&void 0!==d?d:"0",i),[u,b]=qr(c,e.assetOutIndex,n);let y=o,m=!0,f=!1;c!==Nr.Direct&&c!==Nr.TokenIn||(y=r,m=!1,f=!0);let h=o,T=!1;c!==Nr.Direct&&c!==Nr.TokenOut||(h=r,T=!0);return[{type:Cr.Join,poolId:e.poolId,tokenIn:s[e.assetInIndex],bpt:s[e.assetOutIndex],opRef:u,minOut:p,amountIn:l,assets:s,actionStep:c,sender:y,receiver:h,fromInternal:m,hasTokenIn:f,hasTokenOut:T},b]}function Kr(e,t,a,n,s,i,r,o){var d;const c=Vr(t,a,e.assetInIndex,e.assetOutIndex),l=$r(e,Cr.Exit,c,n),p=Wr(null!==(d=e.returnAmount)&&void 0!==d?d:"0",i),[u,b]=qr(c,e.assetOutIndex,n);let y=o,m=!1;c!==Nr.Direct&&c!==Nr.TokenIn||(y=r,m=!0);let f=!1,h=!0,T=o;c!==Nr.Direct&&c!==Nr.TokenOut||(T=r,h=!1,f=!0);return[{type:Cr.Exit,poolId:e.poolId,tokenOut:s[e.assetOutIndex],bpt:s[e.assetInIndex],opRef:u.key?[u]:[],minOut:p,amountIn:l,assets:s,actionStep:c,sender:y,receiver:T,toInternal:h,hasTokenIn:m,hasTokenOut:f},b]}function Zr(e,t,a,n,s,i,r,o,d){var c;const l=Vr(t,a,e.assetInIndex,e.assetOutIndex),p=$r(e,Cr.Swap,l,n);e.amount=p;const u=Wr(null!==(c=e.returnAmount)&&void 0!==c?c:"0",i),[b,y]=qr(l,e.assetOutIndex,n),m=l===Nr.Direct||l===Nr.TokenIn,f=l===Nr.Direct||l===Nr.TokenOut,h=Lr(r,s[e.assetInIndex]);let T=!0;(m||h)&&(T=!1);let g,I,E=!0;(f||Lr(r,s[e.assetOutIndex]))&&(E=!1),g=m?o:d,I=f?o:d;return[{type:Cr.Swap,opRef:b.key?[b]:[],minOut:u,amountIn:p,assets:s,swap:e,hasTokenIn:m,hasTokenOut:f,fromInternal:T,toInternal:E,isBptIn:h,sender:g,receiver:I},y]}function Xr(e,t,a){const n=e.tokensList,s=new W(a),[i]=s.sortTokens(n),r=t.tokenOut,o=i.findIndex((e=>e.toLowerCase()===r.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.minOut;const c=t.amountIn,l={assets:i,minAmountsOut:d,userData:P.exitExactBPTInForOneTokenOut(c,o),toInternalBalance:t.toInternal,poolId:t.poolId,poolKind:0,sender:t.sender,recipient:t.receiver,outputReferences:t.opRef,exitPoolRequest:{}},p=cs.constructExitCall(l),u=t.hasTokenOut?d[o]:"0";return[p,t.hasTokenIn?c:"0",u]}function Jr(e,t,a){const n=e.tokensList,s=new W(a),[i]=s.sortTokens(n),r=t.tokenIn,o=i.findIndex((e=>e.toLowerCase()===r.toLowerCase())),d=Array(n.length).fill("0");d[o]=t.amountIn;const c=t.minOut,l=P.joinExactTokensInForBPTOut(d,c),p={poolId:t.poolId,sender:t.sender,recipient:t.receiver,kind:0,joinPoolRequest:{assets:i,maxAmountsIn:d,userData:l,fromInternalBalance:t.fromInternal},value:"0",outputReference:t.opRef.key?t.opRef.key.toString():"0"},u=cs.encodeJoinPool(p),b=t.hasTokenOut?c:"0";return[u,t.hasTokenIn?d[o]:"0",b]}function Yr(t,s,i){const r=[];for(const e of t.approveTokens){const t=cs.encodeApproveVault(e,a.MaxUint256.toString());r.push(t)}const o={sender:t.sender,recipient:t.receiver,fromInternalBalance:t.fromInternal,toInternalBalance:t.toInternal},d={swapType:e.SwapType.SwapExactIn,swaps:t.swaps,assets:t.assets,funds:o,limits:t.limits.map((e=>e.toString())),deadline:n.BigNumber.from(Math.ceil(Date.now()/1e3)+3600),value:"0",outputReferences:t.opRef},c=cs.encodeBatchSwap(d);r.push(c);const l=t.assets.findIndex((e=>e.toLowerCase()===s.toLowerCase())),p=t.assets.findIndex((e=>e.toLowerCase()===i.toLowerCase()));return[r,t.hasTokenIn?t.limits[l].toString():"0",t.hasTokenOut?t.limits[p].abs().toString():"0"]}Object.defineProperty(e,"PoolFilter",{enumerable:!0,get:function(){return l.PoolFilter}}),Object.defineProperty(e,"RouteProposer",{enumerable:!0,get:function(){return l.RouteProposer}}),Object.defineProperty(e,"SOR",{enumerable:!0,get:function(){return l.SOR}}),Object.defineProperty(e,"SwapTypes",{enumerable:!0,get:function(){return l.SwapTypes}}),Object.defineProperty(e,"formatSequence",{enumerable:!0,get:function(){return l.formatSequence}}),Object.defineProperty(e,"getTokenAddressesForSwap",{enumerable:!0,get:function(){return l.getTokenAddressesForSwap}}),Object.defineProperty(e,"parseToPoolsDict",{enumerable:!0,get:function(){return l.parseToPoolsDict}}),Object.defineProperty(e,"phantomStableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.phantomStableBPTForTokensZeroPriceImpact}}),Object.defineProperty(e,"queryBatchSwapTokensIn",{enumerable:!0,get:function(){return l.queryBatchSwapTokensIn}}),Object.defineProperty(e,"queryBatchSwapTokensOut",{enumerable:!0,get:function(){return l.queryBatchSwapTokensOut}}),Object.defineProperty(e,"stableBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.stableBPTForTokensZeroPriceImpact}}),Object.defineProperty(e,"weightedBPTForTokensZeroPriceImpact",{enumerable:!0,get:function(){return l.weightedBPTForTokensZeroPriceImpact}}),e.APR_THRESHOLD=1e4,e.AaveHelpers=class{static async getRate(e,t){const a=new i.Contract(e,G,t);return(await a.getRate()).toString()}},e.AaveRates=Vi,e.AssetHelpers=W,e.BalancerAPIArgsFormatter=He,e.BalancerError=st,e.BalancerErrors=V,e.BalancerMinterAuthorization=Z,e.BalancerSDK=class{constructor(e,t=new jn(e),a=new ls(e)){this.config=e,this.sor=t,this.subgraph=a,this.networkConfig=Hn(e),this.provider=t.provider,this.data=new Fr(this.networkConfig,t.provider,e.subgraphQuery),this.swaps=new os(this.config),this.relayer=new cs(this.swaps),this.pricing=new ps(e,this.swaps),this.pools=new Ti(this.networkConfig,this.data),this.balancerContracts=new ws(this.networkConfig.addresses.contracts,t.provider),this.zaps=new Hs(this.networkConfig.chainId)}get rpcProvider(){return this.sor.provider}get contracts(){return this.balancerContracts.contracts}},e.BlockNumberRepository=kr,e.CoingeckoHistoricalPriceRepository=Ui,e.CoingeckoPriceRepository=Li,e.ComposableStablePoolEncoder=v,e.Data=Fr,e.Debouncer=Ue,e.FeeCollectorRepository=zi,e.FeeDistributorRepository=Zi,e.GaugeControllerMulticallRepository=Ii,e.GaugeSharesRepository=Ai,e.GraphQLArgsBuilder=Ke,e.HistoricalPriceProvider=Wi,e.Liquidity=$t,e.LiquidityGaugeSubgraphRPCProvider=Oi,e.LiquidityGaugesMulticallRepository=Pi,e.LiquidityGaugesSubgraphRepository=Bi,e.ManagedPoolEncoder=B,e.POOLS=function(e){return U[e]?U[e]:L},e.PoolGaugesRepository=Ci,e.PoolJoinExitRepository=Fi,e.PoolSharesRepository=Ri,e.Pools=Ti,e.PoolsBalancerAPIRepository=class{constructor(e){var t,a;this.pools=[],this.skip=0,this.client=new vi(e.url,e.apiKey);this.query={args:Object.assign({},(null===(t=e.query)||void 0===t?void 0:t.args)||{chainId: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 Ke(this.query.args).format(new He),a=this.query.attrs;a.nextToken=!0;const n={pools:{__args:t,...a}},s=(await this.client.get(n)).pools;return this.nextToken=s.nextToken,this.pools=this.pools.concat(s.pools.map(this.format)),this.skip=this.pools.length,this.fetchFromCache(e)}async find(e){return 0==this.pools.length&&await this.fetch(),this.findBy("id",e)}async findBy(e,t){0==this.pools.length&&await this.fetch();const a=this.pools.find((a=>a[e]==t));if(a)return this.format(a)}format(e){var t,a,n,s;if(null===(t=e.apr)||void 0===t?void 0:t.rewardAprs.breakdown){const t=JSON.parse(null===(a=e.apr)||void 0===a?void 0:a.rewardAprs.breakdown);e.apr.rewardAprs.breakdown=t}if(null===(n=e.apr)||void 0===n?void 0:n.tokenAprs.breakdown){const t=JSON.parse(null===(s=e.apr)||void 0===s?void 0:s.tokenAprs.breakdown);e.apr.tokenAprs.breakdown=t}return e}},e.PoolsFallbackRepository=class{constructor(e,t={}){this.providers=e,this.currentProviderIdx=0,this.timeout=t.timeout||1e4}async fetch(e){return this.fallbackQuery("fetch",[e])}get currentProvider(){if(this.providers.length&&!(this.currentProviderIdx>=this.providers.length))return this.providers[this.currentProviderIdx]}async find(e){return this.fallbackQuery("find",[e])}async findBy(e,t){return this.fallbackQuery("findBy",[e,t])}async fallbackQuery(e,t){if(this.currentProviderIdx>=this.providers.length)throw new Error(`No working providers found ${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}},e.PoolsStaticRepository=class{constructor(e){this.pools=e}async find(e){return this.pools.find((t=>t.id.toLowerCase()===e.toLowerCase()))}async findBy(e,t){return this.pools.find((a=>a[e]===t))}async all(){return this.pools}async where(e){return(await this.all()).filter(e)}},e.PoolsSubgraphOnChainRepository=Ni,e.PoolsSubgraphRepository=ki,e.ProtocolFeesProvider=tr,e.Relayer=cs,e.RelayerAuthorization=K,e.SHALLOW_COMPOSABLE_STABLE_BUFFER=1e6,e.Sor=jn,e.StablePoolEncoder=S,e.StaticTokenPriceProvider=class{constructor(e){this.tokenPrices=Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLowerCase(),t])))}async find(e){const t=e.toLowerCase(),a=this.tokenPrices[t];if(a)return a}async findBy(e,t){if("address"==e)return this.find(t)}},e.StaticTokenProvider=Mi,e.Subgraph=ls,e.SubgraphArgsFormatter=je,e.SubgraphPriceRepository=Gi,e.Swaps=os,e.TokenPriceProvider=qi,e.TokenYieldsRepository=_r,e.WeightedPoolEncoder=P,e.accountToAddress=H,e.addressMapIn=Me,e.balEmissions=Js,e.bn=e=>n.parseFixed(`${e}`,18),e.buildRelayerCalls=function(t,a,s,i,r,o,d){const c=Hr(function(e,t,a,n,s,i,r,o){const d=n.findIndex((t=>t.toLowerCase()===e.toLowerCase())),c=n.findIndex((e=>e.toLowerCase()===t.toLowerCase())),l=[];let p=0,u={};for(const e of a)if(Ur(e,n)){const[t,a]=jr(e,d,c,p,n,s,r,o);p=a,l.push(t),u=t}else{if(!Gr(e,n)){const t=e.amount,[a,b]=Zr(e,d,c,p,n,s,i,r,o);u.type===Cr.Swap&&"0"===t&&(u.receiver=u.sender,u.toInternal=u.fromInternal,u.opRef=[],a.sender=u.receiver,a.fromInternal=u.fromInternal,a.amountIn="0",a.swap.amount="0"),p=b,l.push(a),u=a;continue}{const[t,a]=Kr(e,d,c,p,n,s,r,o);p=a,l.push(t),u=t}}return l}(t.tokenIn,t.tokenOut,t.swaps,t.tokenAddresses,o,a,s,i),t.tokenAddresses),l=[],p=[],u=[];d&&l.push(function(e,t){return cs.encodeSetRelayerApproval(t,!0,e)}(d,i));for(const s of c){if(s.type===Cr.Exit){const t=a.find((e=>e.id===s.poolId));if(void 0===t)throw new st(e.BalancerErrorCode.NO_POOL_DATA);const[i,o,d]=Xr(t,s,r);l.push(i),p.push(n.BigNumber.from(o)),u.push(n.BigNumber.from(d))}if(s.type===Cr.Join){const t=a.find((e=>e.id===s.poolId));if(void 0===t)throw new st(e.BalancerErrorCode.NO_POOL_DATA);const[i,o,d]=Jr(t,s,r);l.push(i),p.push(n.BigNumber.from(o)),u.push(n.BigNumber.from(d))}if(s.type===Cr.BatchSwap){const[e,a,i]=Yr(s,t.tokenIn,t.tokenOut);l.push(...e),p.push(n.BigNumber.from(a)),u.push(n.BigNumber.from(i))}}return function(t,a,s,i){const r=t.reduce(((e=n.BigNumber.from(0),t)=>e.add(t))),o=a.reduce(((e=n.BigNumber.from(0),t)=>e.add(t))),d=o.sub(ze(s.returnAmount,n.BigNumber.from(i)));if(!r.eq(s.swapAmount)||!d.lt("3"))throw new st(e.BalancerErrorCode.RELAY_SWAP_AMOUNTS)}(p,u,t,o),{to:i,data:Mr.encodeFunctionData("multicall",[l]),rawCalls:l}},e.canUseJoinExit=function(e,t,n){return e!==l.SwapTypes.SwapExactOut&&t.toLowerCase()!==a.AddressZero.toLowerCase()&&n.toLowerCase()!==a.AddressZero.toLowerCase()},e.formatFixed=qe,e.formatFromBigInt18=function(e){return n.formatFixed(n.BigNumber.from(e),18)},e.getLimitsForSlippage=Xe,e.getPoolAddress=D,e.getPoolNonce=R,e.getPoolSpecialization=F,e.insert=Ve,e.isNormalizedWeights=e=>{const t=e.reduce(((e,t)=>e.add(t)),a.Zero);return t.eq(a.WeiPerEther)},e.isSameAddress=$e,e.parseFixed=Ge,e.parsePoolInfo=se,e.parseToBigInt18=We,e.signPermit=async(e,t,s,i,o=a.MaxUint256,d)=>{const{chainId:c}=await e.provider.getNetwork(),l=await t.getAddress();d||(d=await e.nonces(l));const p={name:await e.name(),version:"1",chainId:c,verifyingContract:e.address},u={owner:l,spender:await H(s),value:i,nonce:d,deadline:o},b=await t._signTypedData(p,{Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u);return{...r.splitSignature(b),deadline:n.BigNumber.from(o),nonce:n.BigNumber.from(d)}},e.someJoinExit=function(e,t,a){return t.some((t=>function(e,t,a){const n=e.find((e=>e.id===t.poolId));return"Weighted"===(null==n?void 0:n.poolType)&&[a[t.assetInIndex],a[t.assetOutIndex]].includes(n.address)}(e,t,a)))},e.splitPoolId=e=>({address:D(e),specialization:F(e),nonce:R(e)}),e.toNormalizedWeights=function(e){if(100==e.length)return Array(100).fill(a.WeiPerEther.div(100));const t=e.reduce(((e,t)=>e.add(t)),a.Zero);if(t.eq(a.WeiPerEther))return e;const n=[];let s=a.Zero;for(let i=0;i<e.length;i++)i<e.length-1?(n[i]=e[i].mul(a.WeiPerEther).div(t),s=s.add(n[i])):n[i]=a.WeiPerEther.sub(s);return n},e.tokenAddressForPricing=Re,e.tokensToTokenPrices=function(e){const t={};return e.forEach((e=>{e.price&&(t[e.address]=e.price)})),t},e.unwrapToken=Le,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
489
489
|
//# sourceMappingURL=index.umd.js.map
|