@cowprotocol/cow-sdk
Advanced tools
Comparing version 4.0.0 to 4.0.3
@@ -0,1 +1,2 @@ | ||
import { OrderBookApi } from '../order-book'; | ||
import { SupportedChainId } from '../common'; | ||
@@ -75,3 +76,8 @@ import { GPv2Order } from './generated/ComposableCoW'; | ||
blockInfo?: BlockInfo; | ||
/** | ||
* Allows to optional pass the config of the orderbook API | ||
*/ | ||
orderbookApiConfig?: OrderBookApiConfig; | ||
}; | ||
export type OrderBookApiConfig = Omit<ConstructorParameters<typeof OrderBookApi>[0], 'chainId'>; | ||
export type BlockInfo = { | ||
@@ -78,0 +84,0 @@ blockNumber: number; |
@@ -28,3 +28,3 @@ require("cross-fetch/polyfill");var e,t=require("limiter"),r=require("exponential-backoff"),n=require("graphql-request"),a=require("ethers"),o=require("@cowprotocol/contracts"),s=require("@openzeppelin/merkle-tree");function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}exports.SupportedChainId=void 0,(e=exports.SupportedChainId||(exports.SupportedChainId={}))[e.MAINNET=1]="MAINNET",e[e.GOERLI=5]="GOERLI",e[e.GNOSIS_CHAIN=100]="GNOSIS_CHAIN";const d=["prod","staging"],p={env:"prod",chainId:exports.SupportedChainId.MAINNET};class u extends Error{constructor(e,t){super(e),this.error_code=void 0,this.error_code=t}}const{GPv2Settlement:c}=JSON.parse('{\n "GPv2AllowListAuthentication_Implementation": {\n "1": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0x58340aa44119c74e48635fab0ac344170c6d6e8b42e5714baa4ba4e1651f63ad"\n },\n "4": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67"\n },\n "5": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0x24f4f80b46a17345011065f9ea2af823f582db56be81098b3b66cc2db9659ea7"\n },\n "100": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0xe52d425fe34d6d5215ccfc9ddfa485d490b3018f0ee5bbed708f2d172044d60d"\n }\n },\n "GPv2AllowListAuthentication_Proxy": {\n "1": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0xb84bf720364f94c749f1ec1cdf0d4c44c70411b716459aaccfd24fc677013375"\n },\n "4": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x57b2278fd3a13ab1b132031024475ba1a4e28d7d4d37f556134c84512b742c1f"\n },\n "5": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x39dcf30baf887a5db54551a84de8bfdb6cf418bb284b09680d13aed17d5fa0c1"\n },\n "100": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x1a2d87a05a94bc6680a4faee31bbafbd74e9ddb63dd3941c717b5c609c08b957"\n }\n },\n "GPv2AllowListAuthentication": {\n "1": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0xb84bf720364f94c749f1ec1cdf0d4c44c70411b716459aaccfd24fc677013375"\n },\n "4": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x57b2278fd3a13ab1b132031024475ba1a4e28d7d4d37f556134c84512b742c1f"\n },\n "5": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x39dcf30baf887a5db54551a84de8bfdb6cf418bb284b09680d13aed17d5fa0c1"\n },\n "100": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x1a2d87a05a94bc6680a4faee31bbafbd74e9ddb63dd3941c717b5c609c08b957"\n }\n },\n "GPv2Settlement": {\n "1": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0xf49f90aa5a268c40001d1227b76bb4dd8247f18361fcad9fffd4a7a44f1320d3"\n },\n "4": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x609fa2e8f32c73c1f5dc21ff60a26238dacb50d4674d336c90d6950bdda17a21"\n },\n "5": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x982f089060ff66e19d0683ef1cc6a637297331a9ba95b65d8eb84b9f8dc64b04"\n },\n "100": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x9ddc538f89cd8433f4a19bc4de0de27e7c68a1d04a14b327185e4bba9af87133"\n }\n },\n "GPv2VaultRelayer": {\n "1": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0xf49f90aa5a268c40001d1227b76bb4dd8247f18361fcad9fffd4a7a44f1320d3"\n },\n "4": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x609fa2e8f32c73c1f5dc21ff60a26238dacb50d4674d336c90d6950bdda17a21"\n },\n "5": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x982f089060ff66e19d0683ef1cc6a637297331a9ba95b65d8eb84b9f8dc64b04"\n },\n "100": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x9ddc538f89cd8433f4a19bc4de0de27e7c68a1d04a14b327185e4bba9af87133"\n }\n }\n}'),l="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",y="0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",m="0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",T=[exports.SupportedChainId.MAINNET,exports.SupportedChainId.GOERLI,exports.SupportedChainId.GNOSIS_CHAIN],f=T.reduce((e,t)=>({...e,[t]:c[t].address}),{}),h=T.reduce((e,t)=>({...e,[t]:y}),{}),b=T.reduce((e,t)=>({...e,[t]:m}),{});function E(e){return function(e){const{ethflowData:t}=e;if(!t)return e;const{userValidTo:r}=t,n=e.onchainUser||e.owner,a=l;return{...e,validTo:r,owner:n,sellToken:a}}(function(e){const{executedFeeAmount:t,executedSurplusFee:r}=e,n=null!=r?r:t;return{...e,totalFee:n}}(e))}const I=function(e,{path:t,query:n,method:a,body:o},s,i){try{const d={Accept:"application/json","Content-Type":"application/json"},p=`${e}${t}${n?"?"+n:""}`,u={method:a,body:(()=>{if(o)return"string"==typeof o?o:JSON.stringify(o)})(),headers:d};return Promise.resolve(r.backOff(function(){try{return Promise.resolve(s.removeTokens(1)).then(function(){return Promise.resolve(fetch(p,u)).then(function(e){return Promise.resolve(P(e)).then(function(t){return e.status>=200&&e.status<300?t:Promise.reject(new O(e,t))})})})}catch(e){return Promise.reject(e)}},i))}catch(e){return Promise.reject(e)}};class O extends Error{constructor(e,t){super("string"==typeof t?t:e.statusText),this.response=void 0,this.body=void 0,this.response=e,this.body=t}}const A=[408,425,429,500,502,503,504],S={numOfAttempts:10,maxDelay:Infinity,jitter:"none",retry:e=>!(e instanceof O)||A.includes(e.response.status)},x={tokensPerInterval:5,interval:"second"},P=function(e){try{let t;const r=function(){if(204!==e.status)return function(r,n){try{var a=function(){const r=e.headers.get("Content-Type");return function(){if(r)return r.toLowerCase().startsWith("application/json")?Promise.resolve(e.json()).then(function(e){return t=1,e}):Promise.resolve(e.text()).then(function(e){return t=1,e})}()}()}catch(e){return n(e)}return a&&a.then?a.then(void 0,n):a}(0,function(e){console.error(e)})}();return Promise.resolve(r&&r.then?r.then(function(e){return t?e:void 0}):t?r:void 0)}catch(e){return Promise.reject(e)}},_={[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/mainnet",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.cow.fi/xdai",[exports.SupportedChainId.GOERLI]:"https://api.cow.fi/goerli"},N={[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/mainnet",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai",[exports.SupportedChainId.GOERLI]:"https://barn.api.cow.fi/goerli"};function C(e){return Object.keys(e).reduce((t,r)=>{const n=e[r];return void 0!==n&&(t[r]=n),t},{})}class v{constructor(e={}){this.context=void 0,this.rateLimiter=void 0,this.context={...p,...e},this.rateLimiter=new t.RateLimiter(e.limiterOpts||x)}getVersion(e={}){return this.fetch({path:"/api/v1/version",method:"GET"},e)}getTrades(e,t={}){if(e.owner&&e.orderUid)return Promise.reject(new u("Cannot specify both owner and orderId"));if(!e.owner&&!e.orderUid)return Promise.reject(new u("Must specify either owner or orderId"));const r=new URLSearchParams(C(e));return this.fetch({path:"/api/v1/trades",method:"GET",query:r},t)}getOrders({owner:e,offset:t=0,limit:r=1e3},n={}){const a=new URLSearchParams(C({offset:t.toString(),limit:r.toString()}));return this.fetch({path:`/api/v1/account/${e}/orders`,method:"GET",query:a},n).then(e=>e.map(E))}getTxOrders(e,t={}){return this.fetch({path:`/api/v1/transactions/${e}/orders`,method:"GET"},t).then(e=>e.map(E))}getOrder(e,t={}){return this.fetch({path:`/api/v1/orders/${e}`,method:"GET"},t).then(e=>E(e))}getOrderMultiEnv(e,t={}){const{env:r}=this.getContextWithOverride(t),n=d.filter(e=>e!==r);let a=0;const o=r=>{const s=n[a];return r instanceof O&&404===r.response.status&&s?(a++,this.getOrder(e,{...t,env:s}).catch(o)):Promise.reject(r)};return this.getOrder(e,{...t,env:r}).catch(o)}getQuote(e,t={}){return this.fetch({path:"/api/v1/quote",method:"POST",body:e},t)}sendSignedOrderCancellations(e,t={}){return this.fetch({path:"/api/v1/orders",method:"DELETE",body:e},t)}sendOrder(e,t={}){return this.fetch({path:"/api/v1/orders",method:"POST",body:e},t)}getNativePrice(e,t={}){return this.fetch({path:`/api/v1/token/${e}/native_price`,method:"GET"},t)}getTotalSurplus(e,t={}){return this.fetch({path:`/api/v1/users/${e}/total_surplus`,method:"GET"},t)}getAppData(e,t={}){return this.fetch({path:`/api/v1/app_data/${e}`,method:"GET"},t)}uploadAppData(e,t,r={}){return this.fetch({path:`/api/v1/app_data/${e}`,method:"PUT",body:{fullAppData:t}},r)}getSolverCompetition(e,t={}){return this.fetch({path:`/api/v1/solver_competition${"string"==typeof e?"/by_tx_hash":""}/${e}`,method:"GET"},t)}getOrderLink(e,t){const{chainId:r,env:n}=this.getContextWithOverride(t);return this.getApiBaseUrls(n)[r]+`/api/v1/orders/${e}`}getContextWithOverride(e={}){return{...this.context,...e}}getApiBaseUrls(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?_:N}fetch(e,t={}){const{chainId:r,env:n}=this.getContextWithOverride(t),a=this.getApiBaseUrls(n)[r];return I(a,e,this.rateLimiter,this.context.backoffOpts||S)}}var D,R,g,U,w,L,M,F,B,k,G,V,H,$,W;exports.BuyTokenDestination=void 0,(D=exports.BuyTokenDestination||(exports.BuyTokenDestination={})).ERC20="erc20",D.INTERNAL="internal",exports.EcdsaSigningScheme=void 0,(R=exports.EcdsaSigningScheme||(exports.EcdsaSigningScheme={})).EIP712="eip712",R.ETHSIGN="ethsign",exports.OnchainOrderData=void 0,(U=(g=exports.OnchainOrderData||(exports.OnchainOrderData={})).placementError||(g.placementError={})).QUOTE_NOT_FOUND="QuoteNotFound",U.VALID_TO_TOO_FAR_IN_FUTURE="ValidToTooFarInFuture",U.PRE_VALIDATION_ERROR="PreValidationError",exports.OrderCancellationError=void 0,(L=(w=exports.OrderCancellationError||(exports.OrderCancellationError={})).errorType||(w.errorType={})).INVALID_SIGNATURE="InvalidSignature",L.WRONG_OWNER="WrongOwner",L.ORDER_NOT_FOUND="OrderNotFound",L.ALREADY_CANCELLED="AlreadyCancelled",L.ORDER_FULLY_EXECUTED="OrderFullyExecuted",L.ORDER_EXPIRED="OrderExpired",L.ON_CHAIN_ORDER="OnChainOrder",exports.OrderClass=void 0,(M=exports.OrderClass||(exports.OrderClass={})).MARKET="market",M.LIMIT="limit",M.LIQUIDITY="liquidity",exports.OrderKind=void 0,(F=exports.OrderKind||(exports.OrderKind={})).BUY="buy",F.SELL="sell",exports.OrderPostError=void 0,function(e){e.DUPLICATED_ORDER="DuplicatedOrder",e.QUOTE_NOT_FOUND="QuoteNotFound",e.INVALID_QUOTE="InvalidQuote",e.MISSING_FROM="MissingFrom",e.WRONG_OWNER="WrongOwner",e.INVALID_EIP1271SIGNATURE="InvalidEip1271Signature",e.INSUFFICIENT_BALANCE="InsufficientBalance",e.INSUFFICIENT_ALLOWANCE="InsufficientAllowance",e.INVALID_SIGNATURE="InvalidSignature",e.INSUFFICIENT_FEE="InsufficientFee",e.SELL_AMOUNT_OVERFLOW="SellAmountOverflow",e.TRANSFER_SIMULATION_FAILED="TransferSimulationFailed",e.ZERO_AMOUNT="ZeroAmount",e.INCOMPATIBLE_SIGNING_SCHEME="IncompatibleSigningScheme",e.TOO_MANY_LIMIT_ORDERS_UNSUPPORTED_BUY_TOKEN_DESTINATION="TooManyLimitOrders UnsupportedBuyTokenDestination",e.UNSUPPORTED_SELL_TOKEN_SOURCE="UnsupportedSellTokenSource",e.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType",e.INSUFFICIENT_VALID_TO="InsufficientValidTo",e.EXCESSIVE_VALID_TO="ExcessiveValidTo",e.TRANSFER_ETH_TO_CONTRACT="TransferEthToContract",e.INVALID_NATIVE_SELL_TOKEN_SAME_BUY_AND_SELL_TOKEN="InvalidNativeSellToken SameBuyAndSellToken",e.UNSUPPORTED_SIGNATURE="UnsupportedSignature",e.UNSUPPORTED_TOKEN="UnsupportedToken",e.UNSUPPORTED_CUSTOM_INTERACTION_INVALID_APP_DATA="UnsupportedCustomInteraction InvalidAppData",e.APP_DATA_HASH_MISMATCH="AppDataHashMismatch"}((B=exports.OrderPostError||(exports.OrderPostError={})).errorType||(B.errorType={})),exports.OrderQuoteSideKindBuy=void 0,(exports.OrderQuoteSideKindBuy||(exports.OrderQuoteSideKindBuy={})).BUY="buy",exports.OrderQuoteSideKindSell=void 0,(exports.OrderQuoteSideKindSell||(exports.OrderQuoteSideKindSell={})).SELL="sell",exports.OrderStatus=void 0,(k=exports.OrderStatus||(exports.OrderStatus={})).PRESIGNATURE_PENDING="presignaturePending",k.OPEN="open",k.FULFILLED="fulfilled",k.CANCELLED="cancelled",k.EXPIRED="expired",exports.PriceEstimationError=void 0,function(e){e.UNSUPPORTED_TOKEN="UnsupportedToken",e.ZERO_AMOUNT="ZeroAmount",e.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType"}((G=exports.PriceEstimationError||(exports.PriceEstimationError={})).errorType||(G.errorType={})),exports.PriceQuality=void 0,(V=exports.PriceQuality||(exports.PriceQuality={})).FAST="fast",V.OPTIMAL="optimal",V.VERIFIED="verified",exports.ReplaceOrderError=void 0,function(e){e.ALREADY_CANCELLED="AlreadyCancelled",e.ORDER_FULLY_EXECUTED="OrderFullyExecuted",e.ORDER_EXPIRED="OrderExpired",e.ON_CHAIN_ORDER="OnChainOrder",e.DUPLICATED_ORDER="DuplicatedOrder",e.INSUFFICIENT_FEE="InsufficientFee",e.INSUFFICIENT_ALLOWANCE="InsufficientAllowance",e.INSUFFICIENT_BALANCE="InsufficientBalance",e.INSUFFICIENT_VALID_TO="InsufficientValidTo",e.EXCESSIVE_VALID_TO="ExcessiveValidTo",e.INVALID_SIGNATURE="InvalidSignature",e.TRANSFER_ETH_TO_CONTRACT="TransferEthToContract",e.TRANSFER_SIMULATION_FAILED="TransferSimulationFailed",e.UNSUPPORTED_TOKEN="UnsupportedToken",e.WRONG_OWNER="WrongOwner",e.SAME_BUY_AND_SELL_TOKEN="SameBuyAndSellToken",e.ZERO_AMOUNT="ZeroAmount",e.UNSUPPORTED_BUY_TOKEN_DESTINATION="UnsupportedBuyTokenDestination",e.UNSUPPORTED_SELL_TOKEN_SOURCE="UnsupportedSellTokenSource",e.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType",e.UNSUPPORTED_SIGNATURE="UnsupportedSignature"}((H=exports.ReplaceOrderError||(exports.ReplaceOrderError={})).errorType||(H.errorType={})),exports.SellTokenSource=void 0,($=exports.SellTokenSource||(exports.SellTokenSource={})).ERC20="erc20",$.INTERNAL="internal",$.EXTERNAL="external",exports.SigningScheme=void 0,(W=exports.SigningScheme||(exports.SigningScheme={})).EIP712="eip712",W.ETHSIGN="ethsign",W.PRESIGN="presign",W.EIP1271="eip1271";const j=n.gql` | ||
} | ||
`,q="https://api.thegraph.com/subgraphs/name/cowprotocol",X={[exports.SupportedChainId.MAINNET]:q+"/cow",[exports.SupportedChainId.GNOSIS_CHAIN]:q+"/cow-gc",[exports.SupportedChainId.GOERLI]:q+"/cow-goerli"},Q={[exports.SupportedChainId.MAINNET]:q+"/cow-staging",[exports.SupportedChainId.GNOSIS_CHAIN]:q+"/cow-gc-staging",[exports.SupportedChainId.GOERLI]:""},Z=()=>Promise.resolve().then(function(){return require("./utils-6af328d0.js")});class z{static signOrder(e,t,r){try{return Promise.resolve(Z()).then(function({signOrder:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,r){try{return Promise.resolve(Z()).then(function({signOrderCancellation:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,r){try{return Promise.resolve(Z()).then(function({signOrderCancellations:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(Z()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(Z()).then(function({getDomain:t}){return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return i(require("ethers/lib/utils"))})).then(function({_TypedDataEncoder:r}){return r.hashDomain(t(e))})})}catch(e){return Promise.reject(e)}}static getEIP712Types(){return{Order:[{name:"sellToken",type:"address"},{name:"buyToken",type:"address"},{name:"receiver",type:"address"},{name:"sellAmount",type:"uint256"},{name:"buyAmount",type:"uint256"},{name:"validTo",type:"uint32"},{name:"appData",type:"bytes32"},{name:"feeAmount",type:"uint256"},{name:"kind",type:"string"},{name:"partiallyFillable",type:"bool"},{name:"sellTokenBalance",type:"string"},{name:"buyTokenBalance",type:"string"}]}}}var J,ee;exports.ProofLocation=void 0,(J=exports.ProofLocation||(exports.ProofLocation={}))[J.PRIVATE=0]="PRIVATE",J[J.EMITTED=1]="EMITTED",J[J.SWARM=2]="SWARM",J[J.WAKU=3]="WAKU",J[J.RESERVED=4]="RESERVED",J[J.IPFS=5]="IPFS",exports.PollResultCode=void 0,(ee=exports.PollResultCode||(exports.PollResultCode={})).SUCCESS="SUCCESS",ee.UNEXPECTED_ERROR="UNEXPECTED_ERROR",ee.TRY_NEXT_BLOCK="TRY_NEXT_BLOCK",ee.TRY_ON_BLOCK="TRY_ON_BLOCK",ee.TRY_AT_EPOCH="TRY_AT_EPOCH",ee.DONT_TRY_AGAIN="DONT_TRY_AGAIN";const te=[{inputs:[{internalType:"address",name:"_settlement",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InterfaceNotSupported",type:"error"},{inputs:[],name:"InvalidHandler",type:"error"},{inputs:[],name:"ProofNotAuthed",type:"error"},{inputs:[],name:"SingleOrderNotAuthed",type:"error"},{inputs:[],name:"SwapGuardRestricted",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],indexed:!1,internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"ConditionalOrderCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],indexed:!1,internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"MerkleRootSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"SwapGuardSet",type:"event"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"cabinet",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"create",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"createWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bytes",name:"offchainInput",type:"bytes"},{internalType:"bytes32[]",name:"proof",type:"bytes32[]"}],name:"getTradeableOrderWithSignature",outputs:[{components:[{internalType:"contract IERC20",name:"sellToken",type:"address"},{internalType:"contract IERC20",name:"buyToken",type:"address"},{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"buyAmount",type:"uint256"},{internalType:"uint32",name:"validTo",type:"uint32"},{internalType:"bytes32",name:"appData",type:"bytes32"},{internalType:"uint256",name:"feeAmount",type:"uint256"},{internalType:"bytes32",name:"kind",type:"bytes32"},{internalType:"bool",name:"partiallyFillable",type:"bool"},{internalType:"bytes32",name:"sellTokenBalance",type:"bytes32"},{internalType:"bytes32",name:"buyTokenBalance",type:"bytes32"}],internalType:"struct GPv2Order.Data",name:"order",type:"tuple"},{internalType:"bytes",name:"signature",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"hash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"safe",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes32",name:"_domainSeparator",type:"bytes32"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"encodeData",type:"bytes"},{internalType:"bytes",name:"payload",type:"bytes"}],name:"isValidSafeSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"singleOrderHash",type:"bytes32"}],name:"remove",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"roots",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"setRoot",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"setRootWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"setSwapGuard",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"singleOrders",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"swapGuards",outputs:[{internalType:"contract ISwapGuard",name:"",type:"address"}],stateMutability:"view",type:"function"}];class re{static createInterface(){return new a.utils.Interface(te)}static connect(e,t){return new a.Contract(e,te,t)}}re.abi=te;const ne=[{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"verifier",type:"address"}],name:"AddedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"AddedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"method",type:"bytes32"}],name:"AddedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"oldVerifier",type:"address"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"ChangedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"oldMethod",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"ChangedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"}],name:"RemovedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"RemovedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"}],name:"RemovedSafeMethod",type:"event"},{stateMutability:"nonpayable",type:"fallback"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"domainVerifiers",outputs:[{internalType:"contract ISafeSignatureVerifier",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeInterfaces",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeMethods",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"setDomainVerifier",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"},{internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"setSafeMethod",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"},{internalType:"bool",name:"supported",type:"bool"}],name:"setSupportedInterface",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"_interfaceId",type:"bytes4"},{internalType:"bytes32[]",name:"handlerWithSelectors",type:"bytes32[]"}],name:"setSupportedInterfaceBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class ae{static createInterface(){return new a.utils.Interface(ne)}static connect(e,t){return new a.Contract(e,ne,t)}}ae.abi=ne;const oe=function(e){try{return Promise.resolve(e.getBlock("latest")).then(function(e){return{blockNumber:e.number,blockTimestamp:e.timestamp}})}catch(e){return Promise.reject(e)}},se=["erc20","0x5a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc9"],ie=["external","0xabee3b73373acd583a130924aad6dc38cfdc44ba0555ba94ce2ff63980ea0632"],de=["internal","0x4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce"],pe=["sell","0xf3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee346775"],ue=["buy","0x6ed88e868af0a1983e3886d5f3e95a2fafbd6c3450bc229e27342283dc429ccc"],ce=["tuple(address handler, bytes32 salt, bytes staticInput)"];function le(e){return a.utils.defaultAbiCoder.encode(ce,[e])}function ye(e){const{handler:t,salt:r,staticInput:n}=a.utils.defaultAbiCoder.decode(ce,e)[0];return{handler:t,salt:r,staticInput:n}}function me(e,t){try{a.utils.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}function Te(e){return new Date(1e3*e).toISOString()}function fe(e){if(se.includes(e))return o.OrderBalance.ERC20;if(ie.includes(e))return o.OrderBalance.EXTERNAL;if(de.includes(e))return o.OrderBalance.INTERNAL;throw new Error(`Unknown balance type: ${e}`)}function he(e){if(pe.includes(e))return o.OrderKind.SELL;if(ue.includes(e))return o.OrderKind.BUY;throw new Error(`Unknown kind: ${e}`)}function be(e){const{sellToken:t,sellAmount:r,buyToken:n,buyAmount:a,buyTokenBalance:o,sellTokenBalance:s,feeAmount:i,kind:d,receiver:p,validTo:u,partiallyFillable:c,appData:l}=e;return{sellToken:t,sellAmount:r,buyToken:n,buyAmount:a,feeAmount:i,receiver:p,partiallyFillable:c,appData:l,validTo:Number(u),kind:he(d.toString()),sellTokenBalance:fe(s.toString()),buyTokenBalance:fe(o.toString())}}let Ee,Ie;function Oe(){return Ee||(Ee=re.createInterface()),Ee}function Ae(e,t){return Ie||(Ie=re.connect(b[e],t)),Ie}const Se={};class xe{constructor(e){this.handler=void 0,this.salt=void 0,this.data=void 0,this.staticInput=void 0,this.hasOffChainInput=void 0;const{handler:t,salt:r=a.utils.keccak256(a.utils.randomBytes(32)),data:n,hasOffChainInput:o=!1}=e;if(!a.ethers.utils.isAddress(t))throw new Error(`Invalid handler: ${t}`);if(!a.ethers.utils.isHexString(r)||32!==a.ethers.utils.hexDataLength(r))throw new Error(`Invalid salt: ${r}`);this.handler=t,this.salt=r,this.data=n,this.staticInput=this.transformDataToStruct(n),this.hasOffChainInput=o}get context(){}assertIsValid(){const e=this.isValid();if(!e.isValid)throw new Error(`Invalid order: ${e.reason}`)}get createCalldata(){this.assertIsValid();const e=this.context,t=Oe(),r={handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()};if(e){const n=e.factoryArgs?a.utils.defaultAbiCoder.encode(e.factoryArgs.argsType,e.factoryArgs.args):"0x";return t.encodeFunctionData("createWithContext",[r,e.address,n,!0])}return t.encodeFunctionData("create",[r,!0])}get removeCalldata(){return this.assertIsValid(),Oe().encodeFunctionData("remove",[this.id])}get id(){return a.utils.keccak256(this.serialize())}get ctx(){return this.isSingleOrder?this.id:a.constants.HashZero}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.utils.keccak256(le(e))}get offChainInput(){return"0x"}encodeStaticInputHelper(e,t){return a.utils.defaultAbiCoder.encode(e,[t])}poll(e){try{const t=this,{chainId:r,owner:n,provider:a}=e,o=Ae(r,a);return Promise.resolve(function(a,s){try{var d=function(){const a=t.isValid();return a.isValid?Promise.resolve(t.pollValidate(e)).then(function(a){return a||Promise.resolve(t.isAuthorized(e)).then(function(a){return a?Promise.resolve(o.getTradeableOrderWithSignature(n,t.leaf,t.offChainInput,[])).then(function([a,o]){let s=Se[r];return s||(s=new v({chainId:r}),Se[r]=s),Promise.resolve(function(e,t,r){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return i(require("@cowprotocol/contracts"))})).then(function({computeOrderUid:n}){return Promise.resolve(z.getDomain(e)).then(function(e){return n(e,r,t)})})}catch(e){return Promise.reject(e)}}(r,n,be(a))).then(function(r){return Promise.resolve(s.getOrder(r).then(()=>!0).catch(()=>!1)).then(function(n){let s;function i(e){return s?e:{result:exports.PollResultCode.SUCCESS,order:a,signature:o}}const d=function(){if(n)return Promise.resolve(t.handlePollFailedAlreadyPresent(r,a,e)).then(function(e){if(e)return s=1,e;const t={result:exports.PollResultCode.TRY_NEXT_BLOCK,reason:"Order already in orderbook"};return s=1,t})}();return d&&d.then?d.then(i):i(d)})})}):{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`NotAuthorized: Order ${t.id} is not authorized for ${n} on chain ${r}`}})}):{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`InvalidConditionalOrder. Reason: ${a.reason}`}}()}catch(e){return s(e)}return d&&d.then?d.then(void 0,s):d}(0,function(e){return{result:exports.PollResultCode.UNEXPECTED_ERROR,error:e}}))}catch(e){return Promise.reject(e)}}isAuthorized(e){const{chainId:t,owner:r,provider:n}=e;return Ae(t,n).callStatic.singleOrders(r,this.id)}cabinet(e){const{chainId:t,owner:r,provider:n}=e;return Ae(t,n).callStatic.cabinet(r,this.ctx)}static deserializeHelper(e,t,r,n){try{const{handler:o,salt:s,staticInput:i}=ye(e);if(o!=t)throw new Error("HandlerMismatch");const[d]=a.utils.defaultAbiCoder.decode(r,i);return n(d,s)}catch(e){throw"HandlerMismatch"===e.message?e:new Error("InvalidSerializedConditionalOrder")}}}const Pe=["address","bytes32","bytes"],_e=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];class Ne{constructor(e,t,r,n=exports.ProofLocation.PRIVATE){if(this.chain=void 0,this.location=void 0,this.orders={},this.tree=void 0,this.ctx=void 0,this.chain=e,this.location=n,t&&0===Object.keys(t).length)throw new Error("orders must have non-zero length");if(t&&!r||!t&&r)throw new Error("orders cannot have undefined root");for(const e in t)if(t.hasOwnProperty(e)){const r=t[e];if(!Ne.orderTypeRegistry.hasOwnProperty(r.orderType))throw new Error(`Unknown order type: ${r.orderType}`)}if(t&&(this.orders=t,this.getOrGenerateTree().root!==r))throw new Error("root mismatch")}static fromJSON(e){const{chain:t,orders:r,root:n,location:o}=JSON.parse(e,(e,t)=>{if("orders"===e&&"object"==typeof t&&null!==t){const e={};for(const r in t)if(t.hasOwnProperty(r)){const{orderType:n,...a}=t[r];if(!Ne.orderTypeRegistry.hasOwnProperty(n))throw new Error(`Unknown order type: ${n}`);e[r]=new(0,Ne.orderTypeRegistry[n])(a)}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?a.BigNumber.from(t):t}),s=new Ne(t,r,n);return s.location=o,s}toJSON(){const e=this.getOrGenerateTree().root;return JSON.stringify({...this,root:e},(e,t)=>{if("tree"!==e){if("object"==typeof t&&null!==t&&"orderType"in t){const e=t;return{...e,orderType:e.orderType}}return t}})}add(e){e.assertIsValid(),this.orders[e.id]=e,this.reset()}remove(e){delete this.orders[e],this.reset()}update(e,t){const r=t(this.orders[e],this.ctx);delete this.orders[e],this.orders[r.id]=r,this.reset()}getById(e){return this.orders[e]}getByIndex(e){return this.orders[this.orderIds[e]]}get orderIds(){return Object.keys(this.orders)}get root(){return this.getOrGenerateTree().root}getOrGenerateTree(){return this.tree||(this.tree=s.StandardMerkleTree.of(Object.values(this.orders).map(e=>[...Object.values(e.leaf)]),Pe)),this.tree}static decodeFromJSON(e){return JSON.parse(e)}prepareProofStruct(e,t,r){try{const n=this;void 0===e&&(e=n.location);const o=function(){try{switch(e){case exports.ProofLocation.PRIVATE:return Promise.resolve("0x");case exports.ProofLocation.EMITTED:return Promise.resolve(n.encodeToABI(t));case exports.ProofLocation.SWARM:case exports.ProofLocation.WAKU:case exports.ProofLocation.IPFS:if(!r)throw new Error("Must provide an uploader function");return Promise.resolve(function(e,a){try{var o=Promise.resolve(r(n.encodeToJSON(t)))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(t){throw new Error(`Error uploading to decentralized storage ${e}: ${t}`)}));default:throw new Error("Unsupported location")}}catch(e){return Promise.reject(e)}};return Promise.resolve(o().then(t=>{try{return a.utils.hexlify(a.utils.arrayify(t)),n.location=e,{location:e,data:t}}catch(e){throw new Error("data returned by uploader is invalid")}}).catch(e=>{throw new Error(`Error preparing proof struct: ${e}`)}))}catch(e){return Promise.reject(e)}}static poll(e,t,r,n,a){try{function o(r){return Promise.resolve(s.getTradeableOrderWithSignature(e,t.params,r,t.proof))}const s=Ae(r,n);return Promise.resolve(a?Promise.resolve(a(e,t.params)).then(o):o("0x"))}catch(i){return Promise.reject(i)}}dumpProofs(e){return this.encodeToJSON(e)}dumpProofsAndParams(e){return this.getProofs(e)}getProofs(e){return[...this.getOrGenerateTree().entries()].map(([t,r])=>e&&e(r)||void 0===e?{idx:t,value:r}:void 0).reduce((e,t)=>{if(t){const r={handler:t.value[0],salt:t.value[1],staticInput:t.value[2]};e.push({proof:this.getOrGenerateTree().getProof(t.idx),params:r})}return e},[])}encodeToABI(e){return a.utils.defaultAbiCoder.encode(_e,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){Ne.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){Ne.orderTypeRegistry={}}}Ne.orderTypeRegistry={};const Ce="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",ve="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",De=a.BigNumber.from(2).pow(32).sub(1),Re=a.BigNumber.from(31536e3),ge=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"];var Ue,we;exports.DurationType=void 0,(Ue=exports.DurationType||(exports.DurationType={})).AUTO="AUTO",Ue.LIMIT_DURATION="LIMIT_DURATION",exports.StartTimeValue=void 0,(we=exports.StartTimeValue||(exports.StartTimeValue={})).AT_MINING_TIME="AT_MINING_TIME",we.AT_EPOCH="AT_EPOCH";const Le={startType:exports.StartTimeValue.AT_MINING_TIME},Me={durationType:exports.DurationType.AUTO};class Fe extends xe{constructor(e){const{handler:t,salt:r,data:n,hasOffChainInput:a}=e;if(t!==Ce)throw new Error(`InvalidHandler: Expected: ${Ce}, provided: ${t}`);super({handler:Ce,salt:r,data:n,hasOffChainInput:a}),this.isSingleOrder=!0}static fromData(e,t){return new Fe({handler:Ce,data:e,salt:t})}static fromParams(e){return Fe.deserialize(le(e))}get context(){return this.staticInput.t0.gt(0)?super.context:{address:ve,factoryArgs:void 0}}get orderType(){return"twap"}isValid(){const e=(()=>{const{sellToken:e,sellAmount:t,buyToken:r,buyAmount:n,startTime:o=Le,numberOfParts:s,timeBetweenParts:i,durationOfPart:d=Me}=this.data;if(e==r)return"InvalidSameToken";if(e==a.constants.AddressZero||r==a.constants.AddressZero)return"InvalidToken";if(!t.gt(a.constants.Zero))return"InvalidSellAmount";if(!n.gt(a.constants.Zero))return"InvalidMinBuyAmount";if(o.startType===exports.StartTimeValue.AT_EPOCH){const e=o.epoch;if(!e.gte(a.constants.Zero)||!e.lt(De))return"InvalidStartTime"}return s.gt(a.constants.One)&&s.lte(De)?i.gt(a.constants.Zero)&&i.lte(Re)?d.durationType!==exports.DurationType.LIMIT_DURATION||d.duration.lte(i)?me(ge,[this.staticInput])?void 0:"InvalidData":"InvalidSpan":"InvalidFrequency":"InvalidNumParts"})();return e?{isValid:!1,reason:e}:{isValid:!0}}startTimestamp(e){try{const t=this,{startTime:r}=t.data;return r?.startType===exports.StartTimeValue.AT_EPOCH?Promise.resolve(r.epoch.toNumber()):Promise.resolve(t.cabinet(e)).then(function(e){const t=a.utils.defaultAbiCoder.decode(["uint256"],e)[0];if(t.gt(De))throw new Error(`Cabinet epoch out of range: ${t.toString()}`);const r=t.toNumber();if(0===r)throw new Error("Cabinet is not set. Required for TWAP orders that start at mining time.");return r})}catch(e){return Promise.reject(e)}}endTimestamp(e){const{numberOfParts:t,timeBetweenParts:r,durationOfPart:n}=this.data;return n&&n.durationType===exports.DurationType.LIMIT_DURATION?e+t.sub(1).mul(r).add(n.duration).toNumber():e+t.mul(r).toNumber()}pollValidate(e){try{const t=this;return Promise.resolve(oe(e.provider)).then(function(r){const{blockInfo:n=r}=e,{blockTimestamp:a}=n;return function(r,n){try{var o=Promise.resolve(t.startTimestamp(e)).then(function(e){if(e>a)return{result:exports.PollResultCode.TRY_AT_EPOCH,epoch:e,reason:`TWAP hasn't started yet. Starts at ${e} (${Te(e)})`};const r=t.endTimestamp(e);return a>=r?{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`TWAP has expired. Expired at ${r} (${Te(r)})`}:void 0})}catch(e){return n(e)}return o&&o.then?o.then(void 0,n):o}(0,function(e){return e?.message?.includes("Cabinet is not set")?{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`${e?.message}. User likely removed the order.`}:e?.message?.includes("Cabinet epoch out of range")?{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`${e?.message}`}:{result:exports.PollResultCode.UNEXPECTED_ERROR,reason:`Unexpected error: ${e.message}`,error:e}})})}catch(e){return Promise.reject(e)}}handlePollFailedAlreadyPresent(e,t,r){try{const e=this;return Promise.resolve(oe(r.provider)).then(function(t){const{blockInfo:n=t}=r,{blockTimestamp:a}=n,o=e.data.timeBetweenParts.toNumber(),{numberOfParts:s}=e.data;return Promise.resolve(e.startTimestamp(r)).then(function(e){if(a<e)return{result:exports.PollResultCode.UNEXPECTED_ERROR,reason:`TWAP part hash't started. First TWAP part start at ${e} (${Te(e)})`,error:void 0};const t=s.mul(o).add(e).toNumber();if(a>=t)return{result:exports.PollResultCode.UNEXPECTED_ERROR,reason:`TWAP is expired. Expired at ${t} (${Te(t)})`,error:void 0};const r=Math.floor((a-e)/o);if(r===s.toNumber()-1)return{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`Current active TWAP part (${r+1}/${s}) is already in the Order Book. This was the last TWAP part, no more orders need to be placed`};const n=e+(r+1)*o;return{result:exports.PollResultCode.TRY_AT_EPOCH,epoch:n,reason:`Current active TWAP part (${r+1}/${s}) is already in the Order Book. TWAP part ${r+2} doesn't start until ${n} (${Te(n)})`}})})}catch(e){return Promise.reject(e)}}serialize(){return le(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(ge,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,Ce,ge,(e,t)=>new Fe({handler:Ce,salt:t,data:ke(e)}))}toString(){const{sellAmount:e,sellToken:t,buyAmount:r,buyToken:n,numberOfParts:a,startTime:o=Le,timeBetweenParts:s,durationOfPart:i=Me,receiver:d,appData:p}=this.data,u=o.startType===exports.StartTimeValue.AT_MINING_TIME?"AT_MINING_TIME":o.epoch.toNumber(),c=i.durationType===exports.DurationType.AUTO?"AUTO":i.duration.toNumber(),l={sellAmount:e.toString(),sellToken:t,buyAmount:r.toString(),buyToken:n,numberOfParts:a.toString(),startTime:u,timeBetweenParts:s.toNumber(),durationOfPart:c,receiver:d,appData:p};return`${this.orderType} (${this.id}): ${JSON.stringify(l)}`}transformDataToStruct(e){return Be(e)}transformStructToData(e){return ke(e)}}function Be(e){const{sellAmount:t,buyAmount:r,numberOfParts:n,startTime:o=Le,timeBetweenParts:s,durationOfPart:i=Me,...d}=e,{partSellAmount:p,minPartLimit:u}=n&&!n.isZero()?{partSellAmount:t.div(n),minPartLimit:r.div(n)}:{partSellAmount:a.constants.Zero,minPartLimit:a.constants.Zero},c=i.durationType===exports.DurationType.AUTO?a.constants.Zero:i.duration;return{partSellAmount:p,minPartLimit:u,t0:o.startType===exports.StartTimeValue.AT_MINING_TIME?a.constants.Zero:o.epoch,n:n,t:s,span:c,...d}}function ke(e){const{n:t,partSellAmount:r,minPartLimit:n,t:a,t0:o,span:s,...i}=e,d=s.isZero()?{durationType:exports.DurationType.AUTO}:{durationType:exports.DurationType.LIMIT_DURATION,duration:s},p=s.isZero()?{startType:exports.StartTimeValue.AT_MINING_TIME}:{startType:exports.StartTimeValue.AT_EPOCH,epoch:o};return{sellAmount:r.mul(t),buyAmount:n.mul(t),startTime:p,numberOfParts:t,timeBetweenParts:a,durationOfPart:d,...i}}const Ge={[Ce]:e=>Fe.fromParams(e)};exports.ALL_SUPPORTED_CHAIN_IDS=T,exports.BUY_ETH_ADDRESS=l,exports.COMPOSABLE_COW=m,exports.COMPOSABLE_COW_CONTRACT_ADDRESS=b,exports.CONDITIONAL_ORDER_PARAMS_ABI=ce,exports.COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS=f,exports.CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS=ve,exports.ConditionalOrder=xe,exports.ConditionalOrderFactory=class{constructor(e){this.knownOrderTypes=void 0,this.knownOrderTypes=e}fromParams(e){const{handler:t}=e,r=this.knownOrderTypes[t];if(r)return r(e)}},exports.CowError=u,exports.DEFAULT_BACKOFF_OPTIONS=S,exports.DEFAULT_CONDITIONAL_ORDER_REGISTRY=Ge,exports.DEFAULT_COW_API_CONTEXT=p,exports.DEFAULT_IPFS_READ_URI="https://gnosis.mypinata.cloud/ipfs",exports.DEFAULT_IPFS_WRITE_URI="https://api.pinata.cloud",exports.DEFAULT_LIMITER_OPTIONS=x,exports.DEFAULT_TOKEN_FORMATTER=(e,t)=>`${t}@${e}`,exports.ENVS_LIST=d,exports.EXTENSIBLE_FALLBACK_HANDLER=y,exports.EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS=h,exports.MAX_FREQUENCY=Re,exports.MAX_UINT32=De,exports.Multiplexer=Ne,exports.ORDER_BOOK_PROD_CONFIG=_,exports.ORDER_BOOK_STAGING_CONFIG=N,exports.OrderBookApi=v,exports.OrderBookApiError=O,exports.OrderSigningUtils=z,exports.SUBGRAPH_PROD_CONFIG=X,exports.SUBGRAPH_STAGING_CONFIG=Q,exports.SubgraphApi=class{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context={...p,...e}}getTotals(e={}){try{return Promise.resolve(this.runQuery(j,void 0,e)).then(function(e){return e.totals[0]})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e,t={}){try{return Promise.resolve(this.runQuery(K,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(Y,{hours:e},t))}catch(e){return Promise.reject(e)}}runQuery(e,t=undefined,r={}){try{const a=this,{chainId:o,env:s}=a.getContextWithOverride(r),i=a.getEnvConfigs(s)[o];return Promise.resolve(function(r,a){try{var o=Promise.resolve(n.request(i,e,t))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(r){throw console.error(`[subgraph:${a.API_NAME}]`,r),new u(`Error running query: ${e}. Variables: ${JSON.stringify(t)}. API: ${i}. Inner Error: ${r}`)}))}catch(e){return Promise.reject(e)}}getContextWithOverride(e={}){return{...this.context,...e}}getEnvConfigs(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?X:Q}},exports.TWAP_ADDRESS=Ce,exports.Twap=Fe,exports.createSetDomainVerifierTx=function(e,t){return ae.createInterface().encodeFunctionData("setDomainVerifier",[e,t])},exports.decodeParams=ye,exports.encodeParams=le,exports.formatEpoch=Te,exports.fromStructToOrder=be,exports.getBlockInfo=oe,exports.getDomainVerifier=function(e,t,r,n){try{const a=ae.connect(h[r],n);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}},exports.isComposableCow=function(e,t){return e===b[t]},exports.isExtensibleFallbackHandler=function(e,t){return e===h[t]},exports.isValidAbi=me,exports.logPrefix="cow-sdk:",exports.request=I,exports.transformDataToStruct=Be,exports.transformStructToData=ke; | ||
`,q="https://api.thegraph.com/subgraphs/name/cowprotocol",X={[exports.SupportedChainId.MAINNET]:q+"/cow",[exports.SupportedChainId.GNOSIS_CHAIN]:q+"/cow-gc",[exports.SupportedChainId.GOERLI]:q+"/cow-goerli"},Q={[exports.SupportedChainId.MAINNET]:q+"/cow-staging",[exports.SupportedChainId.GNOSIS_CHAIN]:q+"/cow-gc-staging",[exports.SupportedChainId.GOERLI]:""},Z=()=>Promise.resolve().then(function(){return require("./utils-b252e647.js")});class z{static signOrder(e,t,r){try{return Promise.resolve(Z()).then(function({signOrder:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,r){try{return Promise.resolve(Z()).then(function({signOrderCancellation:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,r){try{return Promise.resolve(Z()).then(function({signOrderCancellations:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(Z()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(Z()).then(function({getDomain:t}){return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return i(require("ethers/lib/utils"))})).then(function({_TypedDataEncoder:r}){return r.hashDomain(t(e))})})}catch(e){return Promise.reject(e)}}static getEIP712Types(){return{Order:[{name:"sellToken",type:"address"},{name:"buyToken",type:"address"},{name:"receiver",type:"address"},{name:"sellAmount",type:"uint256"},{name:"buyAmount",type:"uint256"},{name:"validTo",type:"uint32"},{name:"appData",type:"bytes32"},{name:"feeAmount",type:"uint256"},{name:"kind",type:"string"},{name:"partiallyFillable",type:"bool"},{name:"sellTokenBalance",type:"string"},{name:"buyTokenBalance",type:"string"}]}}}var J,ee;exports.ProofLocation=void 0,(J=exports.ProofLocation||(exports.ProofLocation={}))[J.PRIVATE=0]="PRIVATE",J[J.EMITTED=1]="EMITTED",J[J.SWARM=2]="SWARM",J[J.WAKU=3]="WAKU",J[J.RESERVED=4]="RESERVED",J[J.IPFS=5]="IPFS",exports.PollResultCode=void 0,(ee=exports.PollResultCode||(exports.PollResultCode={})).SUCCESS="SUCCESS",ee.UNEXPECTED_ERROR="UNEXPECTED_ERROR",ee.TRY_NEXT_BLOCK="TRY_NEXT_BLOCK",ee.TRY_ON_BLOCK="TRY_ON_BLOCK",ee.TRY_AT_EPOCH="TRY_AT_EPOCH",ee.DONT_TRY_AGAIN="DONT_TRY_AGAIN";const te=[{inputs:[{internalType:"address",name:"_settlement",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InterfaceNotSupported",type:"error"},{inputs:[],name:"InvalidHandler",type:"error"},{inputs:[],name:"ProofNotAuthed",type:"error"},{inputs:[],name:"SingleOrderNotAuthed",type:"error"},{inputs:[],name:"SwapGuardRestricted",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],indexed:!1,internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"ConditionalOrderCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],indexed:!1,internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"MerkleRootSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"SwapGuardSet",type:"event"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"cabinet",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"create",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"createWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bytes",name:"offchainInput",type:"bytes"},{internalType:"bytes32[]",name:"proof",type:"bytes32[]"}],name:"getTradeableOrderWithSignature",outputs:[{components:[{internalType:"contract IERC20",name:"sellToken",type:"address"},{internalType:"contract IERC20",name:"buyToken",type:"address"},{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"buyAmount",type:"uint256"},{internalType:"uint32",name:"validTo",type:"uint32"},{internalType:"bytes32",name:"appData",type:"bytes32"},{internalType:"uint256",name:"feeAmount",type:"uint256"},{internalType:"bytes32",name:"kind",type:"bytes32"},{internalType:"bool",name:"partiallyFillable",type:"bool"},{internalType:"bytes32",name:"sellTokenBalance",type:"bytes32"},{internalType:"bytes32",name:"buyTokenBalance",type:"bytes32"}],internalType:"struct GPv2Order.Data",name:"order",type:"tuple"},{internalType:"bytes",name:"signature",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"hash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"safe",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes32",name:"_domainSeparator",type:"bytes32"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"encodeData",type:"bytes"},{internalType:"bytes",name:"payload",type:"bytes"}],name:"isValidSafeSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"singleOrderHash",type:"bytes32"}],name:"remove",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"roots",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"setRoot",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"setRootWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"setSwapGuard",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"singleOrders",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"swapGuards",outputs:[{internalType:"contract ISwapGuard",name:"",type:"address"}],stateMutability:"view",type:"function"}];class re{static createInterface(){return new a.utils.Interface(te)}static connect(e,t){return new a.Contract(e,te,t)}}re.abi=te;const ne=[{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"verifier",type:"address"}],name:"AddedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"AddedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"method",type:"bytes32"}],name:"AddedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"oldVerifier",type:"address"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"ChangedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"oldMethod",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"ChangedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"}],name:"RemovedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"RemovedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"}],name:"RemovedSafeMethod",type:"event"},{stateMutability:"nonpayable",type:"fallback"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"domainVerifiers",outputs:[{internalType:"contract ISafeSignatureVerifier",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeInterfaces",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeMethods",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"setDomainVerifier",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"},{internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"setSafeMethod",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"},{internalType:"bool",name:"supported",type:"bool"}],name:"setSupportedInterface",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"_interfaceId",type:"bytes4"},{internalType:"bytes32[]",name:"handlerWithSelectors",type:"bytes32[]"}],name:"setSupportedInterfaceBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class ae{static createInterface(){return new a.utils.Interface(ne)}static connect(e,t){return new a.Contract(e,ne,t)}}ae.abi=ne;const oe=function(e){try{return Promise.resolve(e.getBlock("latest")).then(function(e){return{blockNumber:e.number,blockTimestamp:e.timestamp}})}catch(e){return Promise.reject(e)}},se=["erc20","0x5a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc9"],ie=["external","0xabee3b73373acd583a130924aad6dc38cfdc44ba0555ba94ce2ff63980ea0632"],de=["internal","0x4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce"],pe=["sell","0xf3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee346775"],ue=["buy","0x6ed88e868af0a1983e3886d5f3e95a2fafbd6c3450bc229e27342283dc429ccc"],ce=["tuple(address handler, bytes32 salt, bytes staticInput)"];function le(e){return a.utils.defaultAbiCoder.encode(ce,[e])}function ye(e){const{handler:t,salt:r,staticInput:n}=a.utils.defaultAbiCoder.decode(ce,e)[0];return{handler:t,salt:r,staticInput:n}}function me(e,t){try{a.utils.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}function Te(e){return new Date(1e3*e).toISOString()}function fe(e){if(se.includes(e))return o.OrderBalance.ERC20;if(ie.includes(e))return o.OrderBalance.EXTERNAL;if(de.includes(e))return o.OrderBalance.INTERNAL;throw new Error(`Unknown balance type: ${e}`)}function he(e){if(pe.includes(e))return o.OrderKind.SELL;if(ue.includes(e))return o.OrderKind.BUY;throw new Error(`Unknown kind: ${e}`)}function be(e){const{sellToken:t,sellAmount:r,buyToken:n,buyAmount:a,buyTokenBalance:o,sellTokenBalance:s,feeAmount:i,kind:d,receiver:p,validTo:u,partiallyFillable:c,appData:l}=e;return{sellToken:t,sellAmount:r,buyToken:n,buyAmount:a,feeAmount:i,receiver:p,partiallyFillable:c,appData:l,validTo:Number(u),kind:he(d.toString()),sellTokenBalance:fe(s.toString()),buyTokenBalance:fe(o.toString())}}let Ee,Ie;function Oe(){return Ee||(Ee=re.createInterface()),Ee}function Ae(e,t){return Ie||(Ie=re.connect(b[e],t)),Ie}const Se={};class xe{constructor(e){this.handler=void 0,this.salt=void 0,this.data=void 0,this.staticInput=void 0,this.hasOffChainInput=void 0;const{handler:t,salt:r=a.utils.keccak256(a.utils.randomBytes(32)),data:n,hasOffChainInput:o=!1}=e;if(!a.ethers.utils.isAddress(t))throw new Error(`Invalid handler: ${t}`);if(!a.ethers.utils.isHexString(r)||32!==a.ethers.utils.hexDataLength(r))throw new Error(`Invalid salt: ${r}`);this.handler=t,this.salt=r,this.data=n,this.staticInput=this.transformDataToStruct(n),this.hasOffChainInput=o}get context(){}assertIsValid(){const e=this.isValid();if(!e.isValid)throw new Error(`Invalid order: ${e.reason}`)}get createCalldata(){this.assertIsValid();const e=this.context,t=Oe(),r={handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()};if(e){const n=e.factoryArgs?a.utils.defaultAbiCoder.encode(e.factoryArgs.argsType,e.factoryArgs.args):"0x";return t.encodeFunctionData("createWithContext",[r,e.address,n,!0])}return t.encodeFunctionData("create",[r,!0])}get removeCalldata(){return this.assertIsValid(),Oe().encodeFunctionData("remove",[this.id])}get id(){return a.utils.keccak256(this.serialize())}get ctx(){return this.isSingleOrder?this.id:a.constants.HashZero}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.utils.keccak256(le(e))}get offChainInput(){return"0x"}encodeStaticInputHelper(e,t){return a.utils.defaultAbiCoder.encode(e,[t])}poll(e){try{const t=this,{chainId:r,owner:n,provider:a,orderbookApiConfig:o}=e,s=Ae(r,a);return Promise.resolve(function(a,d){try{var p=function(){const a=t.isValid();return a.isValid?Promise.resolve(t.pollValidate(e)).then(function(a){return a||Promise.resolve(t.isAuthorized(e)).then(function(a){return a?Promise.resolve(s.getTradeableOrderWithSignature(n,t.leaf,t.offChainInput,[])).then(function([a,s]){let d=Se[r];return d||(d=new v({...o,chainId:r}),Se[r]=d),Promise.resolve(function(e,t,r){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return i(require("@cowprotocol/contracts"))})).then(function({computeOrderUid:n}){return Promise.resolve(z.getDomain(e)).then(function(e){return n(e,r,t)})})}catch(e){return Promise.reject(e)}}(r,n,be(a))).then(function(r){return Promise.resolve(d.getOrder(r).then(()=>!0).catch(()=>!1)).then(function(n){let o;function i(e){return o?e:{result:exports.PollResultCode.SUCCESS,order:a,signature:s}}const d=function(){if(n)return Promise.resolve(t.handlePollFailedAlreadyPresent(r,a,e)).then(function(e){if(e)return o=1,e;const t={result:exports.PollResultCode.TRY_NEXT_BLOCK,reason:"Order already in orderbook"};return o=1,t})}();return d&&d.then?d.then(i):i(d)})})}):{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`NotAuthorized: Order ${t.id} is not authorized for ${n} on chain ${r}`}})}):{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`InvalidConditionalOrder. Reason: ${a.reason}`}}()}catch(e){return d(e)}return p&&p.then?p.then(void 0,d):p}(0,function(e){return{result:exports.PollResultCode.UNEXPECTED_ERROR,error:e}}))}catch(e){return Promise.reject(e)}}isAuthorized(e){const{chainId:t,owner:r,provider:n}=e;return Ae(t,n).callStatic.singleOrders(r,this.id)}cabinet(e){const{chainId:t,owner:r,provider:n}=e;return Ae(t,n).callStatic.cabinet(r,this.ctx)}static deserializeHelper(e,t,r,n){try{const{handler:o,salt:s,staticInput:i}=ye(e);if(o!=t)throw new Error("HandlerMismatch");const[d]=a.utils.defaultAbiCoder.decode(r,i);return n(d,s)}catch(e){throw"HandlerMismatch"===e.message?e:new Error("InvalidSerializedConditionalOrder")}}}const Pe=["address","bytes32","bytes"],_e=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];class Ne{constructor(e,t,r,n=exports.ProofLocation.PRIVATE){if(this.chain=void 0,this.location=void 0,this.orders={},this.tree=void 0,this.ctx=void 0,this.chain=e,this.location=n,t&&0===Object.keys(t).length)throw new Error("orders must have non-zero length");if(t&&!r||!t&&r)throw new Error("orders cannot have undefined root");for(const e in t)if(t.hasOwnProperty(e)){const r=t[e];if(!Ne.orderTypeRegistry.hasOwnProperty(r.orderType))throw new Error(`Unknown order type: ${r.orderType}`)}if(t&&(this.orders=t,this.getOrGenerateTree().root!==r))throw new Error("root mismatch")}static fromJSON(e){const{chain:t,orders:r,root:n,location:o}=JSON.parse(e,(e,t)=>{if("orders"===e&&"object"==typeof t&&null!==t){const e={};for(const r in t)if(t.hasOwnProperty(r)){const{orderType:n,...a}=t[r];if(!Ne.orderTypeRegistry.hasOwnProperty(n))throw new Error(`Unknown order type: ${n}`);e[r]=new(0,Ne.orderTypeRegistry[n])(a)}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?a.BigNumber.from(t):t}),s=new Ne(t,r,n);return s.location=o,s}toJSON(){const e=this.getOrGenerateTree().root;return JSON.stringify({...this,root:e},(e,t)=>{if("tree"!==e){if("object"==typeof t&&null!==t&&"orderType"in t){const e=t;return{...e,orderType:e.orderType}}return t}})}add(e){e.assertIsValid(),this.orders[e.id]=e,this.reset()}remove(e){delete this.orders[e],this.reset()}update(e,t){const r=t(this.orders[e],this.ctx);delete this.orders[e],this.orders[r.id]=r,this.reset()}getById(e){return this.orders[e]}getByIndex(e){return this.orders[this.orderIds[e]]}get orderIds(){return Object.keys(this.orders)}get root(){return this.getOrGenerateTree().root}getOrGenerateTree(){return this.tree||(this.tree=s.StandardMerkleTree.of(Object.values(this.orders).map(e=>[...Object.values(e.leaf)]),Pe)),this.tree}static decodeFromJSON(e){return JSON.parse(e)}prepareProofStruct(e,t,r){try{const n=this;void 0===e&&(e=n.location);const o=function(){try{switch(e){case exports.ProofLocation.PRIVATE:return Promise.resolve("0x");case exports.ProofLocation.EMITTED:return Promise.resolve(n.encodeToABI(t));case exports.ProofLocation.SWARM:case exports.ProofLocation.WAKU:case exports.ProofLocation.IPFS:if(!r)throw new Error("Must provide an uploader function");return Promise.resolve(function(e,a){try{var o=Promise.resolve(r(n.encodeToJSON(t)))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(t){throw new Error(`Error uploading to decentralized storage ${e}: ${t}`)}));default:throw new Error("Unsupported location")}}catch(e){return Promise.reject(e)}};return Promise.resolve(o().then(t=>{try{return a.utils.hexlify(a.utils.arrayify(t)),n.location=e,{location:e,data:t}}catch(e){throw new Error("data returned by uploader is invalid")}}).catch(e=>{throw new Error(`Error preparing proof struct: ${e}`)}))}catch(e){return Promise.reject(e)}}static poll(e,t,r,n,a){try{function o(r){return Promise.resolve(s.getTradeableOrderWithSignature(e,t.params,r,t.proof))}const s=Ae(r,n);return Promise.resolve(a?Promise.resolve(a(e,t.params)).then(o):o("0x"))}catch(i){return Promise.reject(i)}}dumpProofs(e){return this.encodeToJSON(e)}dumpProofsAndParams(e){return this.getProofs(e)}getProofs(e){return[...this.getOrGenerateTree().entries()].map(([t,r])=>e&&e(r)||void 0===e?{idx:t,value:r}:void 0).reduce((e,t)=>{if(t){const r={handler:t.value[0],salt:t.value[1],staticInput:t.value[2]};e.push({proof:this.getOrGenerateTree().getProof(t.idx),params:r})}return e},[])}encodeToABI(e){return a.utils.defaultAbiCoder.encode(_e,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){Ne.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){Ne.orderTypeRegistry={}}}Ne.orderTypeRegistry={};const Ce="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",ve="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",De=a.BigNumber.from(2).pow(32).sub(1),Re=a.BigNumber.from(31536e3),ge=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"];var Ue,we;exports.DurationType=void 0,(Ue=exports.DurationType||(exports.DurationType={})).AUTO="AUTO",Ue.LIMIT_DURATION="LIMIT_DURATION",exports.StartTimeValue=void 0,(we=exports.StartTimeValue||(exports.StartTimeValue={})).AT_MINING_TIME="AT_MINING_TIME",we.AT_EPOCH="AT_EPOCH";const Le={startType:exports.StartTimeValue.AT_MINING_TIME},Me={durationType:exports.DurationType.AUTO};class Fe extends xe{constructor(e){const{handler:t,salt:r,data:n,hasOffChainInput:a}=e;if(t!==Ce)throw new Error(`InvalidHandler: Expected: ${Ce}, provided: ${t}`);super({handler:Ce,salt:r,data:n,hasOffChainInput:a}),this.isSingleOrder=!0}static fromData(e,t){return new Fe({handler:Ce,data:e,salt:t})}static fromParams(e){return Fe.deserialize(le(e))}get context(){return this.staticInput.t0.gt(0)?super.context:{address:ve,factoryArgs:void 0}}get orderType(){return"twap"}isValid(){const e=(()=>{const{sellToken:e,sellAmount:t,buyToken:r,buyAmount:n,startTime:o=Le,numberOfParts:s,timeBetweenParts:i,durationOfPart:d=Me}=this.data;if(e==r)return"InvalidSameToken";if(e==a.constants.AddressZero||r==a.constants.AddressZero)return"InvalidToken";if(!t.gt(a.constants.Zero))return"InvalidSellAmount";if(!n.gt(a.constants.Zero))return"InvalidMinBuyAmount";if(o.startType===exports.StartTimeValue.AT_EPOCH){const e=o.epoch;if(!e.gte(a.constants.Zero)||!e.lt(De))return"InvalidStartTime"}return s.gt(a.constants.One)&&s.lte(De)?i.gt(a.constants.Zero)&&i.lte(Re)?d.durationType!==exports.DurationType.LIMIT_DURATION||d.duration.lte(i)?me(ge,[this.staticInput])?void 0:"InvalidData":"InvalidSpan":"InvalidFrequency":"InvalidNumParts"})();return e?{isValid:!1,reason:e}:{isValid:!0}}startTimestamp(e){try{const t=this,{startTime:r}=t.data;return r?.startType===exports.StartTimeValue.AT_EPOCH?Promise.resolve(r.epoch.toNumber()):Promise.resolve(t.cabinet(e)).then(function(e){const t=a.utils.defaultAbiCoder.decode(["uint256"],e)[0];if(t.gt(De))throw new Error(`Cabinet epoch out of range: ${t.toString()}`);const r=t.toNumber();if(0===r)throw new Error("Cabinet is not set. Required for TWAP orders that start at mining time.");return r})}catch(e){return Promise.reject(e)}}endTimestamp(e){const{numberOfParts:t,timeBetweenParts:r,durationOfPart:n}=this.data;return n&&n.durationType===exports.DurationType.LIMIT_DURATION?e+t.sub(1).mul(r).add(n.duration).toNumber():e+t.mul(r).toNumber()}pollValidate(e){try{const t=this;return Promise.resolve(oe(e.provider)).then(function(r){const{blockInfo:n=r}=e,{blockTimestamp:a}=n;return function(r,n){try{var o=Promise.resolve(t.startTimestamp(e)).then(function(e){if(e>a)return{result:exports.PollResultCode.TRY_AT_EPOCH,epoch:e,reason:`TWAP hasn't started yet. Starts at ${e} (${Te(e)})`};const r=t.endTimestamp(e);return a>=r?{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`TWAP has expired. Expired at ${r} (${Te(r)})`}:void 0})}catch(e){return n(e)}return o&&o.then?o.then(void 0,n):o}(0,function(e){return e?.message?.includes("Cabinet is not set")?{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`${e?.message}. User likely removed the order.`}:e?.message?.includes("Cabinet epoch out of range")?{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`${e?.message}`}:{result:exports.PollResultCode.UNEXPECTED_ERROR,reason:`Unexpected error: ${e.message}`,error:e}})})}catch(e){return Promise.reject(e)}}handlePollFailedAlreadyPresent(e,t,r){try{const e=this;return Promise.resolve(oe(r.provider)).then(function(t){const{blockInfo:n=t}=r,{blockTimestamp:a}=n,o=e.data.timeBetweenParts.toNumber(),{numberOfParts:s}=e.data;return Promise.resolve(e.startTimestamp(r)).then(function(e){if(a<e)return{result:exports.PollResultCode.UNEXPECTED_ERROR,reason:`TWAP part hash't started. First TWAP part start at ${e} (${Te(e)})`,error:void 0};const t=s.mul(o).add(e).toNumber();if(a>=t)return{result:exports.PollResultCode.UNEXPECTED_ERROR,reason:`TWAP is expired. Expired at ${t} (${Te(t)})`,error:void 0};const r=Math.floor((a-e)/o);if(r===s.toNumber()-1)return{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`Current active TWAP part (${r+1}/${s}) is already in the Order Book. This was the last TWAP part, no more orders need to be placed`};const n=e+(r+1)*o;return{result:exports.PollResultCode.TRY_AT_EPOCH,epoch:n,reason:`Current active TWAP part (${r+1}/${s}) is already in the Order Book. TWAP part ${r+2} doesn't start until ${n} (${Te(n)})`}})})}catch(e){return Promise.reject(e)}}serialize(){return le(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(ge,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,Ce,ge,(e,t)=>new Fe({handler:Ce,salt:t,data:ke(e)}))}toString(){const{sellAmount:e,sellToken:t,buyAmount:r,buyToken:n,numberOfParts:a,startTime:o=Le,timeBetweenParts:s,durationOfPart:i=Me,receiver:d,appData:p}=this.data,u=o.startType===exports.StartTimeValue.AT_MINING_TIME?"AT_MINING_TIME":o.epoch.toNumber(),c=i.durationType===exports.DurationType.AUTO?"AUTO":i.duration.toNumber(),l={sellAmount:e.toString(),sellToken:t,buyAmount:r.toString(),buyToken:n,numberOfParts:a.toString(),startTime:u,timeBetweenParts:s.toNumber(),durationOfPart:c,receiver:d,appData:p};return`${this.orderType} (${this.id}): ${JSON.stringify(l)}`}transformDataToStruct(e){return Be(e)}transformStructToData(e){return ke(e)}}function Be(e){const{sellAmount:t,buyAmount:r,numberOfParts:n,startTime:o=Le,timeBetweenParts:s,durationOfPart:i=Me,...d}=e,{partSellAmount:p,minPartLimit:u}=n&&!n.isZero()?{partSellAmount:t.div(n),minPartLimit:r.div(n)}:{partSellAmount:a.constants.Zero,minPartLimit:a.constants.Zero},c=i.durationType===exports.DurationType.AUTO?a.constants.Zero:i.duration;return{partSellAmount:p,minPartLimit:u,t0:o.startType===exports.StartTimeValue.AT_MINING_TIME?a.constants.Zero:o.epoch,n:n,t:s,span:c,...d}}function ke(e){const{n:t,partSellAmount:r,minPartLimit:n,t:a,t0:o,span:s,...i}=e,d=s.isZero()?{durationType:exports.DurationType.AUTO}:{durationType:exports.DurationType.LIMIT_DURATION,duration:s},p=s.isZero()?{startType:exports.StartTimeValue.AT_MINING_TIME}:{startType:exports.StartTimeValue.AT_EPOCH,epoch:o};return{sellAmount:r.mul(t),buyAmount:n.mul(t),startTime:p,numberOfParts:t,timeBetweenParts:a,durationOfPart:d,...i}}const Ge={[Ce]:e=>Fe.fromParams(e)};exports.ALL_SUPPORTED_CHAIN_IDS=T,exports.BUY_ETH_ADDRESS=l,exports.COMPOSABLE_COW=m,exports.COMPOSABLE_COW_CONTRACT_ADDRESS=b,exports.CONDITIONAL_ORDER_PARAMS_ABI=ce,exports.COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS=f,exports.CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS=ve,exports.ConditionalOrder=xe,exports.ConditionalOrderFactory=class{constructor(e){this.knownOrderTypes=void 0,this.knownOrderTypes=e}fromParams(e){const{handler:t}=e,r=this.knownOrderTypes[t];if(r)return r(e)}},exports.CowError=u,exports.DEFAULT_BACKOFF_OPTIONS=S,exports.DEFAULT_CONDITIONAL_ORDER_REGISTRY=Ge,exports.DEFAULT_COW_API_CONTEXT=p,exports.DEFAULT_IPFS_READ_URI="https://gnosis.mypinata.cloud/ipfs",exports.DEFAULT_IPFS_WRITE_URI="https://api.pinata.cloud",exports.DEFAULT_LIMITER_OPTIONS=x,exports.DEFAULT_TOKEN_FORMATTER=(e,t)=>`${t}@${e}`,exports.ENVS_LIST=d,exports.EXTENSIBLE_FALLBACK_HANDLER=y,exports.EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS=h,exports.MAX_FREQUENCY=Re,exports.MAX_UINT32=De,exports.Multiplexer=Ne,exports.ORDER_BOOK_PROD_CONFIG=_,exports.ORDER_BOOK_STAGING_CONFIG=N,exports.OrderBookApi=v,exports.OrderBookApiError=O,exports.OrderSigningUtils=z,exports.SUBGRAPH_PROD_CONFIG=X,exports.SUBGRAPH_STAGING_CONFIG=Q,exports.SubgraphApi=class{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context={...p,...e}}getTotals(e={}){try{return Promise.resolve(this.runQuery(j,void 0,e)).then(function(e){return e.totals[0]})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e,t={}){try{return Promise.resolve(this.runQuery(K,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(Y,{hours:e},t))}catch(e){return Promise.reject(e)}}runQuery(e,t=undefined,r={}){try{const a=this,{chainId:o,env:s}=a.getContextWithOverride(r),i=a.getEnvConfigs(s)[o];return Promise.resolve(function(r,a){try{var o=Promise.resolve(n.request(i,e,t))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(r){throw console.error(`[subgraph:${a.API_NAME}]`,r),new u(`Error running query: ${e}. Variables: ${JSON.stringify(t)}. API: ${i}. Inner Error: ${r}`)}))}catch(e){return Promise.reject(e)}}getContextWithOverride(e={}){return{...this.context,...e}}getEnvConfigs(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?X:Q}},exports.TWAP_ADDRESS=Ce,exports.Twap=Fe,exports.createSetDomainVerifierTx=function(e,t){return ae.createInterface().encodeFunctionData("setDomainVerifier",[e,t])},exports.decodeParams=ye,exports.encodeParams=le,exports.formatEpoch=Te,exports.fromStructToOrder=be,exports.getBlockInfo=oe,exports.getDomainVerifier=function(e,t,r,n){try{const a=ae.connect(h[r],n);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}},exports.isComposableCow=function(e,t){return e===b[t]},exports.isExtensibleFallbackHandler=function(e,t){return e===h[t]},exports.isValidAbi=me,exports.logPrefix="cow-sdk:",exports.request=I,exports.transformDataToStruct=Be,exports.transformStructToData=ke; | ||
//# sourceMappingURL=index.js.map |
@@ -28,3 +28,3 @@ import"cross-fetch/polyfill";import{RateLimiter as e}from"limiter";import{backOff as t}from"exponential-backoff";import{gql as n,request as r}from"graphql-request";import{utils as a,Contract as s,ethers as i,constants as o,BigNumber as d}from"ethers";import{OrderBalance as c,OrderKind as u}from"@cowprotocol/contracts";import{StandardMerkleTree as p}from"@openzeppelin/merkle-tree";var l;!function(e){e[e.MAINNET=1]="MAINNET",e[e.GOERLI=5]="GOERLI",e[e.GNOSIS_CHAIN=100]="GNOSIS_CHAIN"}(l||(l={}));const y=["prod","staging"],m={env:"prod",chainId:l.MAINNET};class f extends Error{constructor(e,t){super(e),this.error_code=void 0,this.error_code=t}}const T="cow-sdk:",b="https://gnosis.mypinata.cloud/ipfs",h="https://api.pinata.cloud",{GPv2Settlement:E}=JSON.parse('{\n "GPv2AllowListAuthentication_Implementation": {\n "1": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0x58340aa44119c74e48635fab0ac344170c6d6e8b42e5714baa4ba4e1651f63ad"\n },\n "4": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67"\n },\n "5": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0x24f4f80b46a17345011065f9ea2af823f582db56be81098b3b66cc2db9659ea7"\n },\n "100": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0xe52d425fe34d6d5215ccfc9ddfa485d490b3018f0ee5bbed708f2d172044d60d"\n }\n },\n "GPv2AllowListAuthentication_Proxy": {\n "1": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0xb84bf720364f94c749f1ec1cdf0d4c44c70411b716459aaccfd24fc677013375"\n },\n "4": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x57b2278fd3a13ab1b132031024475ba1a4e28d7d4d37f556134c84512b742c1f"\n },\n "5": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x39dcf30baf887a5db54551a84de8bfdb6cf418bb284b09680d13aed17d5fa0c1"\n },\n "100": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x1a2d87a05a94bc6680a4faee31bbafbd74e9ddb63dd3941c717b5c609c08b957"\n }\n },\n "GPv2AllowListAuthentication": {\n "1": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0xb84bf720364f94c749f1ec1cdf0d4c44c70411b716459aaccfd24fc677013375"\n },\n "4": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x57b2278fd3a13ab1b132031024475ba1a4e28d7d4d37f556134c84512b742c1f"\n },\n "5": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x39dcf30baf887a5db54551a84de8bfdb6cf418bb284b09680d13aed17d5fa0c1"\n },\n "100": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x1a2d87a05a94bc6680a4faee31bbafbd74e9ddb63dd3941c717b5c609c08b957"\n }\n },\n "GPv2Settlement": {\n "1": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0xf49f90aa5a268c40001d1227b76bb4dd8247f18361fcad9fffd4a7a44f1320d3"\n },\n "4": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x609fa2e8f32c73c1f5dc21ff60a26238dacb50d4674d336c90d6950bdda17a21"\n },\n "5": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x982f089060ff66e19d0683ef1cc6a637297331a9ba95b65d8eb84b9f8dc64b04"\n },\n "100": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x9ddc538f89cd8433f4a19bc4de0de27e7c68a1d04a14b327185e4bba9af87133"\n }\n },\n "GPv2VaultRelayer": {\n "1": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0xf49f90aa5a268c40001d1227b76bb4dd8247f18361fcad9fffd4a7a44f1320d3"\n },\n "4": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x609fa2e8f32c73c1f5dc21ff60a26238dacb50d4674d336c90d6950bdda17a21"\n },\n "5": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x982f089060ff66e19d0683ef1cc6a637297331a9ba95b65d8eb84b9f8dc64b04"\n },\n "100": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x9ddc538f89cd8433f4a19bc4de0de27e7c68a1d04a14b327185e4bba9af87133"\n }\n }\n}'),I="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",A="0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",O="0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",v=[l.MAINNET,l.GOERLI,l.GNOSIS_CHAIN],N=v.reduce((e,t)=>({...e,[t]:E[t].address}),{}),S=v.reduce((e,t)=>({...e,[t]:A}),{}),P=v.reduce((e,t)=>({...e,[t]:O}),{});function _(e){return function(e){const{ethflowData:t}=e;if(!t)return e;const{userValidTo:n}=t,r=e.onchainUser||e.owner,a=I;return{...e,validTo:n,owner:r,sellToken:a}}(function(e){const{executedFeeAmount:t,executedSurplusFee:n}=e,r=null!=n?n:t;return{...e,totalFee:r}}(e))}const g=function(e,{path:n,query:r,method:a,body:s},i,o){try{const d={Accept:"application/json","Content-Type":"application/json"},c=`${e}${n}${r?"?"+r:""}`,u={method:a,body:(()=>{if(s)return"string"==typeof s?s:JSON.stringify(s)})(),headers:d};return Promise.resolve(t(function(){try{return Promise.resolve(i.removeTokens(1)).then(function(){return Promise.resolve(fetch(c,u)).then(function(e){return Promise.resolve(x(e)).then(function(t){return e.status>=200&&e.status<300?t:Promise.reject(new D(e,t))})})})}catch(e){return Promise.reject(e)}},o))}catch(e){return Promise.reject(e)}};class D extends Error{constructor(e,t){super("string"==typeof t?t:e.statusText),this.response=void 0,this.body=void 0,this.response=e,this.body=t}}const C=[408,425,429,500,502,503,504],R={numOfAttempts:10,maxDelay:Infinity,jitter:"none",retry:e=>!(e instanceof D)||C.includes(e.response.status)},w={tokensPerInterval:5,interval:"second"},x=function(e){try{let t;const n=function(){if(204!==e.status)return function(n,r){try{var a=function(){const n=e.headers.get("Content-Type");return function(){if(n)return n.toLowerCase().startsWith("application/json")?Promise.resolve(e.json()).then(function(e){return t=1,e}):Promise.resolve(e.text()).then(function(e){return t=1,e})}()}()}catch(e){return r(e)}return a&&a.then?a.then(void 0,r):a}(0,function(e){console.error(e)})}();return Promise.resolve(n&&n.then?n.then(function(e){return t?e:void 0}):t?n:void 0)}catch(e){return Promise.reject(e)}},U={[l.MAINNET]:"https://api.cow.fi/mainnet",[l.GNOSIS_CHAIN]:"https://api.cow.fi/xdai",[l.GOERLI]:"https://api.cow.fi/goerli"},L={[l.MAINNET]:"https://barn.api.cow.fi/mainnet",[l.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai",[l.GOERLI]:"https://barn.api.cow.fi/goerli"};function M(e){return Object.keys(e).reduce((t,n)=>{const r=e[n];return void 0!==r&&(t[n]=r),t},{})}class F{constructor(t={}){this.context=void 0,this.rateLimiter=void 0,this.context={...m,...t},this.rateLimiter=new e(t.limiterOpts||w)}getVersion(e={}){return this.fetch({path:"/api/v1/version",method:"GET"},e)}getTrades(e,t={}){if(e.owner&&e.orderUid)return Promise.reject(new f("Cannot specify both owner and orderId"));if(!e.owner&&!e.orderUid)return Promise.reject(new f("Must specify either owner or orderId"));const n=new URLSearchParams(M(e));return this.fetch({path:"/api/v1/trades",method:"GET",query:n},t)}getOrders({owner:e,offset:t=0,limit:n=1e3},r={}){const a=new URLSearchParams(M({offset:t.toString(),limit:n.toString()}));return this.fetch({path:`/api/v1/account/${e}/orders`,method:"GET",query:a},r).then(e=>e.map(_))}getTxOrders(e,t={}){return this.fetch({path:`/api/v1/transactions/${e}/orders`,method:"GET"},t).then(e=>e.map(_))}getOrder(e,t={}){return this.fetch({path:`/api/v1/orders/${e}`,method:"GET"},t).then(e=>_(e))}getOrderMultiEnv(e,t={}){const{env:n}=this.getContextWithOverride(t),r=y.filter(e=>e!==n);let a=0;const s=n=>{const i=r[a];return n instanceof D&&404===n.response.status&&i?(a++,this.getOrder(e,{...t,env:i}).catch(s)):Promise.reject(n)};return this.getOrder(e,{...t,env:n}).catch(s)}getQuote(e,t={}){return this.fetch({path:"/api/v1/quote",method:"POST",body:e},t)}sendSignedOrderCancellations(e,t={}){return this.fetch({path:"/api/v1/orders",method:"DELETE",body:e},t)}sendOrder(e,t={}){return this.fetch({path:"/api/v1/orders",method:"POST",body:e},t)}getNativePrice(e,t={}){return this.fetch({path:`/api/v1/token/${e}/native_price`,method:"GET"},t)}getTotalSurplus(e,t={}){return this.fetch({path:`/api/v1/users/${e}/total_surplus`,method:"GET"},t)}getAppData(e,t={}){return this.fetch({path:`/api/v1/app_data/${e}`,method:"GET"},t)}uploadAppData(e,t,n={}){return this.fetch({path:`/api/v1/app_data/${e}`,method:"PUT",body:{fullAppData:t}},n)}getSolverCompetition(e,t={}){return this.fetch({path:`/api/v1/solver_competition${"string"==typeof e?"/by_tx_hash":""}/${e}`,method:"GET"},t)}getOrderLink(e,t){const{chainId:n,env:r}=this.getContextWithOverride(t);return this.getApiBaseUrls(r)[n]+`/api/v1/orders/${e}`}getContextWithOverride(e={}){return{...this.context,...e}}getApiBaseUrls(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?U:L}fetch(e,t={}){const{chainId:n,env:r}=this.getContextWithOverride(t),a=this.getApiBaseUrls(r)[n];return g(a,e,this.rateLimiter,this.context.backoffOpts||R)}}var k,G,B,V,$,H,W,j,Y,K,Z,X,q,z,J;!function(e){e.ERC20="erc20",e.INTERNAL="internal"}(k||(k={})),function(e){e.EIP712="eip712",e.ETHSIGN="ethsign"}(G||(G={})),function(e){var t;(t=e.placementError||(e.placementError={})).QUOTE_NOT_FOUND="QuoteNotFound",t.VALID_TO_TOO_FAR_IN_FUTURE="ValidToTooFarInFuture",t.PRE_VALIDATION_ERROR="PreValidationError"}(B||(B={})),function(e){var t;(t=e.errorType||(e.errorType={})).INVALID_SIGNATURE="InvalidSignature",t.WRONG_OWNER="WrongOwner",t.ORDER_NOT_FOUND="OrderNotFound",t.ALREADY_CANCELLED="AlreadyCancelled",t.ORDER_FULLY_EXECUTED="OrderFullyExecuted",t.ORDER_EXPIRED="OrderExpired",t.ON_CHAIN_ORDER="OnChainOrder"}(V||(V={})),function(e){e.MARKET="market",e.LIMIT="limit",e.LIQUIDITY="liquidity"}($||($={})),function(e){e.BUY="buy",e.SELL="sell"}(H||(H={})),function(e){var t;(t=e.errorType||(e.errorType={})).DUPLICATED_ORDER="DuplicatedOrder",t.QUOTE_NOT_FOUND="QuoteNotFound",t.INVALID_QUOTE="InvalidQuote",t.MISSING_FROM="MissingFrom",t.WRONG_OWNER="WrongOwner",t.INVALID_EIP1271SIGNATURE="InvalidEip1271Signature",t.INSUFFICIENT_BALANCE="InsufficientBalance",t.INSUFFICIENT_ALLOWANCE="InsufficientAllowance",t.INVALID_SIGNATURE="InvalidSignature",t.INSUFFICIENT_FEE="InsufficientFee",t.SELL_AMOUNT_OVERFLOW="SellAmountOverflow",t.TRANSFER_SIMULATION_FAILED="TransferSimulationFailed",t.ZERO_AMOUNT="ZeroAmount",t.INCOMPATIBLE_SIGNING_SCHEME="IncompatibleSigningScheme",t.TOO_MANY_LIMIT_ORDERS_UNSUPPORTED_BUY_TOKEN_DESTINATION="TooManyLimitOrders UnsupportedBuyTokenDestination",t.UNSUPPORTED_SELL_TOKEN_SOURCE="UnsupportedSellTokenSource",t.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType",t.INSUFFICIENT_VALID_TO="InsufficientValidTo",t.EXCESSIVE_VALID_TO="ExcessiveValidTo",t.TRANSFER_ETH_TO_CONTRACT="TransferEthToContract",t.INVALID_NATIVE_SELL_TOKEN_SAME_BUY_AND_SELL_TOKEN="InvalidNativeSellToken SameBuyAndSellToken",t.UNSUPPORTED_SIGNATURE="UnsupportedSignature",t.UNSUPPORTED_TOKEN="UnsupportedToken",t.UNSUPPORTED_CUSTOM_INTERACTION_INVALID_APP_DATA="UnsupportedCustomInteraction InvalidAppData",t.APP_DATA_HASH_MISMATCH="AppDataHashMismatch"}(W||(W={})),function(e){e.BUY="buy"}(j||(j={})),function(e){e.SELL="sell"}(Y||(Y={})),function(e){e.PRESIGNATURE_PENDING="presignaturePending",e.OPEN="open",e.FULFILLED="fulfilled",e.CANCELLED="cancelled",e.EXPIRED="expired"}(K||(K={})),function(e){var t;(t=e.errorType||(e.errorType={})).UNSUPPORTED_TOKEN="UnsupportedToken",t.ZERO_AMOUNT="ZeroAmount",t.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType"}(Z||(Z={})),function(e){e.FAST="fast",e.OPTIMAL="optimal",e.VERIFIED="verified"}(X||(X={})),function(e){var t;(t=e.errorType||(e.errorType={})).ALREADY_CANCELLED="AlreadyCancelled",t.ORDER_FULLY_EXECUTED="OrderFullyExecuted",t.ORDER_EXPIRED="OrderExpired",t.ON_CHAIN_ORDER="OnChainOrder",t.DUPLICATED_ORDER="DuplicatedOrder",t.INSUFFICIENT_FEE="InsufficientFee",t.INSUFFICIENT_ALLOWANCE="InsufficientAllowance",t.INSUFFICIENT_BALANCE="InsufficientBalance",t.INSUFFICIENT_VALID_TO="InsufficientValidTo",t.EXCESSIVE_VALID_TO="ExcessiveValidTo",t.INVALID_SIGNATURE="InvalidSignature",t.TRANSFER_ETH_TO_CONTRACT="TransferEthToContract",t.TRANSFER_SIMULATION_FAILED="TransferSimulationFailed",t.UNSUPPORTED_TOKEN="UnsupportedToken",t.WRONG_OWNER="WrongOwner",t.SAME_BUY_AND_SELL_TOKEN="SameBuyAndSellToken",t.ZERO_AMOUNT="ZeroAmount",t.UNSUPPORTED_BUY_TOKEN_DESTINATION="UnsupportedBuyTokenDestination",t.UNSUPPORTED_SELL_TOKEN_SOURCE="UnsupportedSellTokenSource",t.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType",t.UNSUPPORTED_SIGNATURE="UnsupportedSignature"}(q||(q={})),function(e){e.ERC20="erc20",e.INTERNAL="internal",e.EXTERNAL="external"}(z||(z={})),function(e){e.EIP712="eip712",e.ETHSIGN="ethsign",e.PRESIGN="presign",e.EIP1271="eip1271"}(J||(J={}));const Q=n` | ||
} | ||
`,ne="https://api.thegraph.com/subgraphs/name/cowprotocol",re={[l.MAINNET]:ne+"/cow",[l.GNOSIS_CHAIN]:ne+"/cow-gc",[l.GOERLI]:ne+"/cow-goerli"},ae={[l.MAINNET]:ne+"/cow-staging",[l.GNOSIS_CHAIN]:ne+"/cow-gc-staging",[l.GOERLI]:""};class se{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context={...m,...e}}getTotals(e={}){try{return Promise.resolve(this.runQuery(Q,void 0,e)).then(function(e){return e.totals[0]})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e,t={}){try{return Promise.resolve(this.runQuery(ee,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(te,{hours:e},t))}catch(e){return Promise.reject(e)}}runQuery(e,t=undefined,n={}){try{const a=this,{chainId:s,env:i}=a.getContextWithOverride(n),o=a.getEnvConfigs(i)[s];return Promise.resolve(function(n,a){try{var s=Promise.resolve(r(o,e,t))}catch(e){return a(e)}return s&&s.then?s.then(void 0,a):s}(0,function(n){throw console.error(`[subgraph:${a.API_NAME}]`,n),new f(`Error running query: ${e}. Variables: ${JSON.stringify(t)}. API: ${o}. Inner Error: ${n}`)}))}catch(e){return Promise.reject(e)}}getContextWithOverride(e={}){return{...this.context,...e}}getEnvConfigs(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?re:ae}}const ie=()=>import("./utils-3504a100.js");class oe{static signOrder(e,t,n){try{return Promise.resolve(ie()).then(function({signOrder:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,n){try{return Promise.resolve(ie()).then(function({signOrderCancellation:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,n){try{return Promise.resolve(ie()).then(function({signOrderCancellations:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(ie()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(ie()).then(function({getDomain:t}){return Promise.resolve(import("ethers/lib/utils")).then(function({_TypedDataEncoder:n}){return n.hashDomain(t(e))})})}catch(e){return Promise.reject(e)}}static getEIP712Types(){return{Order:[{name:"sellToken",type:"address"},{name:"buyToken",type:"address"},{name:"receiver",type:"address"},{name:"sellAmount",type:"uint256"},{name:"buyAmount",type:"uint256"},{name:"validTo",type:"uint32"},{name:"appData",type:"bytes32"},{name:"feeAmount",type:"uint256"},{name:"kind",type:"string"},{name:"partiallyFillable",type:"bool"},{name:"sellTokenBalance",type:"string"},{name:"buyTokenBalance",type:"string"}]}}}var de,ce;!function(e){e[e.PRIVATE=0]="PRIVATE",e[e.EMITTED=1]="EMITTED",e[e.SWARM=2]="SWARM",e[e.WAKU=3]="WAKU",e[e.RESERVED=4]="RESERVED",e[e.IPFS=5]="IPFS"}(de||(de={})),function(e){e.SUCCESS="SUCCESS",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.TRY_NEXT_BLOCK="TRY_NEXT_BLOCK",e.TRY_ON_BLOCK="TRY_ON_BLOCK",e.TRY_AT_EPOCH="TRY_AT_EPOCH",e.DONT_TRY_AGAIN="DONT_TRY_AGAIN"}(ce||(ce={}));const ue=[{inputs:[{internalType:"address",name:"_settlement",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InterfaceNotSupported",type:"error"},{inputs:[],name:"InvalidHandler",type:"error"},{inputs:[],name:"ProofNotAuthed",type:"error"},{inputs:[],name:"SingleOrderNotAuthed",type:"error"},{inputs:[],name:"SwapGuardRestricted",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],indexed:!1,internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"ConditionalOrderCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],indexed:!1,internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"MerkleRootSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"SwapGuardSet",type:"event"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"cabinet",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"create",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"createWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bytes",name:"offchainInput",type:"bytes"},{internalType:"bytes32[]",name:"proof",type:"bytes32[]"}],name:"getTradeableOrderWithSignature",outputs:[{components:[{internalType:"contract IERC20",name:"sellToken",type:"address"},{internalType:"contract IERC20",name:"buyToken",type:"address"},{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"buyAmount",type:"uint256"},{internalType:"uint32",name:"validTo",type:"uint32"},{internalType:"bytes32",name:"appData",type:"bytes32"},{internalType:"uint256",name:"feeAmount",type:"uint256"},{internalType:"bytes32",name:"kind",type:"bytes32"},{internalType:"bool",name:"partiallyFillable",type:"bool"},{internalType:"bytes32",name:"sellTokenBalance",type:"bytes32"},{internalType:"bytes32",name:"buyTokenBalance",type:"bytes32"}],internalType:"struct GPv2Order.Data",name:"order",type:"tuple"},{internalType:"bytes",name:"signature",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"hash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"safe",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes32",name:"_domainSeparator",type:"bytes32"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"encodeData",type:"bytes"},{internalType:"bytes",name:"payload",type:"bytes"}],name:"isValidSafeSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"singleOrderHash",type:"bytes32"}],name:"remove",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"roots",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"setRoot",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"setRootWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"setSwapGuard",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"singleOrders",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"swapGuards",outputs:[{internalType:"contract ISwapGuard",name:"",type:"address"}],stateMutability:"view",type:"function"}];class pe{static createInterface(){return new a.Interface(ue)}static connect(e,t){return new s(e,ue,t)}}pe.abi=ue;const le=[{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"verifier",type:"address"}],name:"AddedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"AddedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"method",type:"bytes32"}],name:"AddedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"oldVerifier",type:"address"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"ChangedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"oldMethod",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"ChangedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"}],name:"RemovedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"RemovedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"}],name:"RemovedSafeMethod",type:"event"},{stateMutability:"nonpayable",type:"fallback"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"domainVerifiers",outputs:[{internalType:"contract ISafeSignatureVerifier",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeInterfaces",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeMethods",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"setDomainVerifier",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"},{internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"setSafeMethod",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"},{internalType:"bool",name:"supported",type:"bool"}],name:"setSupportedInterface",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"_interfaceId",type:"bytes4"},{internalType:"bytes32[]",name:"handlerWithSelectors",type:"bytes32[]"}],name:"setSupportedInterfaceBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class ye{static createInterface(){return new a.Interface(le)}static connect(e,t){return new s(e,le,t)}}ye.abi=le;const me=function(e){try{return Promise.resolve(e.getBlock("latest")).then(function(e){return{blockNumber:e.number,blockTimestamp:e.timestamp}})}catch(e){return Promise.reject(e)}},fe=function(e,t,n,r){try{const a=ye.connect(S[n],r);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}},Te=["erc20","0x5a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc9"],be=["external","0xabee3b73373acd583a130924aad6dc38cfdc44ba0555ba94ce2ff63980ea0632"],he=["internal","0x4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce"],Ee=["sell","0xf3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee346775"],Ie=["buy","0x6ed88e868af0a1983e3886d5f3e95a2fafbd6c3450bc229e27342283dc429ccc"],Ae=["tuple(address handler, bytes32 salt, bytes staticInput)"],Oe=(e,t)=>`${t}@${e}`;function ve(e,t){return e===S[t]}function Ne(e,t){return e===P[t]}function Se(e,t){return ye.createInterface().encodeFunctionData("setDomainVerifier",[e,t])}function Pe(e){return a.defaultAbiCoder.encode(Ae,[e])}function _e(e){const{handler:t,salt:n,staticInput:r}=a.defaultAbiCoder.decode(Ae,e)[0];return{handler:t,salt:n,staticInput:r}}function ge(e,t){try{a.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}function De(e){return new Date(1e3*e).toISOString()}function Ce(e){if(Te.includes(e))return c.ERC20;if(be.includes(e))return c.EXTERNAL;if(he.includes(e))return c.INTERNAL;throw new Error(`Unknown balance type: ${e}`)}function Re(e){if(Ee.includes(e))return u.SELL;if(Ie.includes(e))return u.BUY;throw new Error(`Unknown kind: ${e}`)}function we(e){const{sellToken:t,sellAmount:n,buyToken:r,buyAmount:a,buyTokenBalance:s,sellTokenBalance:i,feeAmount:o,kind:d,receiver:c,validTo:u,partiallyFillable:p,appData:l}=e;return{sellToken:t,sellAmount:n,buyToken:r,buyAmount:a,feeAmount:o,receiver:c,partiallyFillable:p,appData:l,validTo:Number(u),kind:Re(d.toString()),sellTokenBalance:Ce(i.toString()),buyTokenBalance:Ce(s.toString())}}let xe,Ue;function Le(){return xe||(xe=pe.createInterface()),xe}function Me(e,t){return Ue||(Ue=pe.connect(P[e],t)),Ue}const Fe={};class ke{constructor(e){this.handler=void 0,this.salt=void 0,this.data=void 0,this.staticInput=void 0,this.hasOffChainInput=void 0;const{handler:t,salt:n=a.keccak256(a.randomBytes(32)),data:r,hasOffChainInput:s=!1}=e;if(!i.utils.isAddress(t))throw new Error(`Invalid handler: ${t}`);if(!i.utils.isHexString(n)||32!==i.utils.hexDataLength(n))throw new Error(`Invalid salt: ${n}`);this.handler=t,this.salt=n,this.data=r,this.staticInput=this.transformDataToStruct(r),this.hasOffChainInput=s}get context(){}assertIsValid(){const e=this.isValid();if(!e.isValid)throw new Error(`Invalid order: ${e.reason}`)}get createCalldata(){this.assertIsValid();const e=this.context,t=Le(),n={handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()};if(e){const r=e.factoryArgs?a.defaultAbiCoder.encode(e.factoryArgs.argsType,e.factoryArgs.args):"0x";return t.encodeFunctionData("createWithContext",[n,e.address,r,!0])}return t.encodeFunctionData("create",[n,!0])}get removeCalldata(){return this.assertIsValid(),Le().encodeFunctionData("remove",[this.id])}get id(){return a.keccak256(this.serialize())}get ctx(){return this.isSingleOrder?this.id:o.HashZero}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.keccak256(Pe(e))}get offChainInput(){return"0x"}encodeStaticInputHelper(e,t){return a.defaultAbiCoder.encode(e,[t])}poll(e){try{const t=this,{chainId:n,owner:r,provider:a}=e,s=Me(n,a);return Promise.resolve(function(a,i){try{var o=function(){const a=t.isValid();return a.isValid?Promise.resolve(t.pollValidate(e)).then(function(a){return a||Promise.resolve(t.isAuthorized(e)).then(function(a){return a?Promise.resolve(s.getTradeableOrderWithSignature(r,t.leaf,t.offChainInput,[])).then(function([a,s]){let i=Fe[n];return i||(i=new F({chainId:n}),Fe[n]=i),Promise.resolve(function(e,t,n){try{return Promise.resolve(import("@cowprotocol/contracts")).then(function({computeOrderUid:r}){return Promise.resolve(oe.getDomain(e)).then(function(e){return r(e,n,t)})})}catch(e){return Promise.reject(e)}}(n,r,we(a))).then(function(n){return Promise.resolve(i.getOrder(n).then(()=>!0).catch(()=>!1)).then(function(r){let i;function o(e){return i?e:{result:ce.SUCCESS,order:a,signature:s}}const d=function(){if(r)return Promise.resolve(t.handlePollFailedAlreadyPresent(n,a,e)).then(function(e){return e?(i=1,e):(i=1,{result:ce.TRY_NEXT_BLOCK,reason:"Order already in orderbook"})})}();return d&&d.then?d.then(o):o(d)})})}):{result:ce.DONT_TRY_AGAIN,reason:`NotAuthorized: Order ${t.id} is not authorized for ${r} on chain ${n}`}})}):{result:ce.DONT_TRY_AGAIN,reason:`InvalidConditionalOrder. Reason: ${a.reason}`}}()}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(e){return{result:ce.UNEXPECTED_ERROR,error:e}}))}catch(e){return Promise.reject(e)}}isAuthorized(e){const{chainId:t,owner:n,provider:r}=e;return Me(t,r).callStatic.singleOrders(n,this.id)}cabinet(e){const{chainId:t,owner:n,provider:r}=e;return Me(t,r).callStatic.cabinet(n,this.ctx)}static deserializeHelper(e,t,n,r){try{const{handler:s,salt:i,staticInput:o}=_e(e);if(s!=t)throw new Error("HandlerMismatch");const[d]=a.defaultAbiCoder.decode(n,o);return r(d,i)}catch(e){throw"HandlerMismatch"===e.message?e:new Error("InvalidSerializedConditionalOrder")}}}const Ge=["address","bytes32","bytes"],Be=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];class Ve{constructor(e,t,n,r=de.PRIVATE){if(this.chain=void 0,this.location=void 0,this.orders={},this.tree=void 0,this.ctx=void 0,this.chain=e,this.location=r,t&&0===Object.keys(t).length)throw new Error("orders must have non-zero length");if(t&&!n||!t&&n)throw new Error("orders cannot have undefined root");for(const e in t)if(t.hasOwnProperty(e)){const n=t[e];if(!Ve.orderTypeRegistry.hasOwnProperty(n.orderType))throw new Error(`Unknown order type: ${n.orderType}`)}if(t&&(this.orders=t,this.getOrGenerateTree().root!==n))throw new Error("root mismatch")}static fromJSON(e){const{chain:t,orders:n,root:r,location:a}=JSON.parse(e,(e,t)=>{if("orders"===e&&"object"==typeof t&&null!==t){const e={};for(const n in t)if(t.hasOwnProperty(n)){const{orderType:r,...a}=t[n];if(!Ve.orderTypeRegistry.hasOwnProperty(r))throw new Error(`Unknown order type: ${r}`);e[n]=new(0,Ve.orderTypeRegistry[r])(a)}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?d.from(t):t}),s=new Ve(t,n,r);return s.location=a,s}toJSON(){const e=this.getOrGenerateTree().root;return JSON.stringify({...this,root:e},(e,t)=>{if("tree"!==e){if("object"==typeof t&&null!==t&&"orderType"in t){const e=t;return{...e,orderType:e.orderType}}return t}})}add(e){e.assertIsValid(),this.orders[e.id]=e,this.reset()}remove(e){delete this.orders[e],this.reset()}update(e,t){const n=t(this.orders[e],this.ctx);delete this.orders[e],this.orders[n.id]=n,this.reset()}getById(e){return this.orders[e]}getByIndex(e){return this.orders[this.orderIds[e]]}get orderIds(){return Object.keys(this.orders)}get root(){return this.getOrGenerateTree().root}getOrGenerateTree(){return this.tree||(this.tree=p.of(Object.values(this.orders).map(e=>[...Object.values(e.leaf)]),Ge)),this.tree}static decodeFromJSON(e){return JSON.parse(e)}prepareProofStruct(e,t,n){try{const r=this;void 0===e&&(e=r.location);const s=function(){try{switch(e){case de.PRIVATE:return Promise.resolve("0x");case de.EMITTED:return Promise.resolve(r.encodeToABI(t));case de.SWARM:case de.WAKU:case de.IPFS:if(!n)throw new Error("Must provide an uploader function");return Promise.resolve(function(e,a){try{var s=Promise.resolve(n(r.encodeToJSON(t)))}catch(e){return a(e)}return s&&s.then?s.then(void 0,a):s}(0,function(t){throw new Error(`Error uploading to decentralized storage ${e}: ${t}`)}));default:throw new Error("Unsupported location")}}catch(e){return Promise.reject(e)}};return Promise.resolve(s().then(t=>{try{return a.hexlify(a.arrayify(t)),r.location=e,{location:e,data:t}}catch(e){throw new Error("data returned by uploader is invalid")}}).catch(e=>{throw new Error(`Error preparing proof struct: ${e}`)}))}catch(e){return Promise.reject(e)}}static poll(e,t,n,r,a){try{function s(n){return Promise.resolve(i.getTradeableOrderWithSignature(e,t.params,n,t.proof))}const i=Me(n,r);return Promise.resolve(a?Promise.resolve(a(e,t.params)).then(s):s("0x"))}catch(o){return Promise.reject(o)}}dumpProofs(e){return this.encodeToJSON(e)}dumpProofsAndParams(e){return this.getProofs(e)}getProofs(e){return[...this.getOrGenerateTree().entries()].map(([t,n])=>e&&e(n)||void 0===e?{idx:t,value:n}:void 0).reduce((e,t)=>{if(t){const n={handler:t.value[0],salt:t.value[1],staticInput:t.value[2]};e.push({proof:this.getOrGenerateTree().getProof(t.idx),params:n})}return e},[])}encodeToABI(e){return a.defaultAbiCoder.encode(Be,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){Ve.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){Ve.orderTypeRegistry={}}}Ve.orderTypeRegistry={};class $e{constructor(e){this.knownOrderTypes=void 0,this.knownOrderTypes=e}fromParams(e){const{handler:t}=e,n=this.knownOrderTypes[t];if(n)return n(e)}}const He="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",We="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",je=d.from(2).pow(32).sub(1),Ye=d.from(31536e3),Ke=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"];var Ze,Xe;!function(e){e.AUTO="AUTO",e.LIMIT_DURATION="LIMIT_DURATION"}(Ze||(Ze={})),function(e){e.AT_MINING_TIME="AT_MINING_TIME",e.AT_EPOCH="AT_EPOCH"}(Xe||(Xe={}));const qe={startType:Xe.AT_MINING_TIME},ze={durationType:Ze.AUTO};class Je extends ke{constructor(e){const{handler:t,salt:n,data:r,hasOffChainInput:a}=e;if(t!==He)throw new Error(`InvalidHandler: Expected: ${He}, provided: ${t}`);super({handler:He,salt:n,data:r,hasOffChainInput:a}),this.isSingleOrder=!0}static fromData(e,t){return new Je({handler:He,data:e,salt:t})}static fromParams(e){return Je.deserialize(Pe(e))}get context(){return this.staticInput.t0.gt(0)?super.context:{address:We,factoryArgs:void 0}}get orderType(){return"twap"}isValid(){const e=(()=>{const{sellToken:e,sellAmount:t,buyToken:n,buyAmount:r,startTime:a=qe,numberOfParts:s,timeBetweenParts:i,durationOfPart:d=ze}=this.data;if(e==n)return"InvalidSameToken";if(e==o.AddressZero||n==o.AddressZero)return"InvalidToken";if(!t.gt(o.Zero))return"InvalidSellAmount";if(!r.gt(o.Zero))return"InvalidMinBuyAmount";if(a.startType===Xe.AT_EPOCH){const e=a.epoch;if(!e.gte(o.Zero)||!e.lt(je))return"InvalidStartTime"}return s.gt(o.One)&&s.lte(je)?i.gt(o.Zero)&&i.lte(Ye)?d.durationType!==Ze.LIMIT_DURATION||d.duration.lte(i)?ge(Ke,[this.staticInput])?void 0:"InvalidData":"InvalidSpan":"InvalidFrequency":"InvalidNumParts"})();return e?{isValid:!1,reason:e}:{isValid:!0}}startTimestamp(e){try{const t=this,{startTime:n}=t.data;return n?.startType===Xe.AT_EPOCH?Promise.resolve(n.epoch.toNumber()):Promise.resolve(t.cabinet(e)).then(function(e){const t=a.defaultAbiCoder.decode(["uint256"],e)[0];if(t.gt(je))throw new Error(`Cabinet epoch out of range: ${t.toString()}`);const n=t.toNumber();if(0===n)throw new Error("Cabinet is not set. Required for TWAP orders that start at mining time.");return n})}catch(e){return Promise.reject(e)}}endTimestamp(e){const{numberOfParts:t,timeBetweenParts:n,durationOfPart:r}=this.data;return r&&r.durationType===Ze.LIMIT_DURATION?e+t.sub(1).mul(n).add(r.duration).toNumber():e+t.mul(n).toNumber()}pollValidate(e){try{const t=this;return Promise.resolve(me(e.provider)).then(function(n){const{blockInfo:r=n}=e,{blockTimestamp:a}=r;return function(n,r){try{var s=Promise.resolve(t.startTimestamp(e)).then(function(e){if(e>a)return{result:ce.TRY_AT_EPOCH,epoch:e,reason:`TWAP hasn't started yet. Starts at ${e} (${De(e)})`};const n=t.endTimestamp(e);return a>=n?{result:ce.DONT_TRY_AGAIN,reason:`TWAP has expired. Expired at ${n} (${De(n)})`}:void 0})}catch(e){return r(e)}return s&&s.then?s.then(void 0,r):s}(0,function(e){return e?.message?.includes("Cabinet is not set")?{result:ce.DONT_TRY_AGAIN,reason:`${e?.message}. User likely removed the order.`}:e?.message?.includes("Cabinet epoch out of range")?{result:ce.DONT_TRY_AGAIN,reason:`${e?.message}`}:{result:ce.UNEXPECTED_ERROR,reason:`Unexpected error: ${e.message}`,error:e}})})}catch(e){return Promise.reject(e)}}handlePollFailedAlreadyPresent(e,t,n){try{const e=this;return Promise.resolve(me(n.provider)).then(function(t){const{blockInfo:r=t}=n,{blockTimestamp:a}=r,s=e.data.timeBetweenParts.toNumber(),{numberOfParts:i}=e.data;return Promise.resolve(e.startTimestamp(n)).then(function(e){if(a<e)return{result:ce.UNEXPECTED_ERROR,reason:`TWAP part hash't started. First TWAP part start at ${e} (${De(e)})`,error:void 0};const t=i.mul(s).add(e).toNumber();if(a>=t)return{result:ce.UNEXPECTED_ERROR,reason:`TWAP is expired. Expired at ${t} (${De(t)})`,error:void 0};const n=Math.floor((a-e)/s);if(n===i.toNumber()-1)return{result:ce.DONT_TRY_AGAIN,reason:`Current active TWAP part (${n+1}/${i}) is already in the Order Book. This was the last TWAP part, no more orders need to be placed`};const r=e+(n+1)*s;return{result:ce.TRY_AT_EPOCH,epoch:r,reason:`Current active TWAP part (${n+1}/${i}) is already in the Order Book. TWAP part ${n+2} doesn't start until ${r} (${De(r)})`}})})}catch(e){return Promise.reject(e)}}serialize(){return Pe(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(Ke,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,He,Ke,(e,t)=>new Je({handler:He,salt:t,data:et(e)}))}toString(){const{sellAmount:e,sellToken:t,buyAmount:n,buyToken:r,numberOfParts:a,startTime:s=qe,timeBetweenParts:i,durationOfPart:o=ze,receiver:d,appData:c}=this.data,u=s.startType===Xe.AT_MINING_TIME?"AT_MINING_TIME":s.epoch.toNumber(),p=o.durationType===Ze.AUTO?"AUTO":o.duration.toNumber(),l={sellAmount:e.toString(),sellToken:t,buyAmount:n.toString(),buyToken:r,numberOfParts:a.toString(),startTime:u,timeBetweenParts:i.toNumber(),durationOfPart:p,receiver:d,appData:c};return`${this.orderType} (${this.id}): ${JSON.stringify(l)}`}transformDataToStruct(e){return Qe(e)}transformStructToData(e){return et(e)}}function Qe(e){const{sellAmount:t,buyAmount:n,numberOfParts:r,startTime:a=qe,timeBetweenParts:s,durationOfPart:i=ze,...d}=e,{partSellAmount:c,minPartLimit:u}=r&&!r.isZero()?{partSellAmount:t.div(r),minPartLimit:n.div(r)}:{partSellAmount:o.Zero,minPartLimit:o.Zero};return{partSellAmount:c,minPartLimit:u,t0:a.startType===Xe.AT_MINING_TIME?o.Zero:a.epoch,n:r,t:s,span:i.durationType===Ze.AUTO?o.Zero:i.duration,...d}}function et(e){const{n:t,partSellAmount:n,minPartLimit:r,t:a,t0:s,span:i,...o}=e,d=i.isZero()?{durationType:Ze.AUTO}:{durationType:Ze.LIMIT_DURATION,duration:i},c=i.isZero()?{startType:Xe.AT_MINING_TIME}:{startType:Xe.AT_EPOCH,epoch:s};return{sellAmount:n.mul(t),buyAmount:r.mul(t),startTime:c,numberOfParts:t,timeBetweenParts:a,durationOfPart:d,...o}}const tt={[He]:e=>Je.fromParams(e)};export{v as ALL_SUPPORTED_CHAIN_IDS,I as BUY_ETH_ADDRESS,k as BuyTokenDestination,O as COMPOSABLE_COW,P as COMPOSABLE_COW_CONTRACT_ADDRESS,Ae as CONDITIONAL_ORDER_PARAMS_ABI,N as COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS,We as CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS,ke as ConditionalOrder,$e as ConditionalOrderFactory,f as CowError,R as DEFAULT_BACKOFF_OPTIONS,tt as DEFAULT_CONDITIONAL_ORDER_REGISTRY,m as DEFAULT_COW_API_CONTEXT,b as DEFAULT_IPFS_READ_URI,h as DEFAULT_IPFS_WRITE_URI,w as DEFAULT_LIMITER_OPTIONS,Oe as DEFAULT_TOKEN_FORMATTER,Ze as DurationType,y as ENVS_LIST,A as EXTENSIBLE_FALLBACK_HANDLER,S as EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS,G as EcdsaSigningScheme,Ye as MAX_FREQUENCY,je as MAX_UINT32,Ve as Multiplexer,U as ORDER_BOOK_PROD_CONFIG,L as ORDER_BOOK_STAGING_CONFIG,B as OnchainOrderData,F as OrderBookApi,D as OrderBookApiError,V as OrderCancellationError,$ as OrderClass,H as OrderKind,W as OrderPostError,j as OrderQuoteSideKindBuy,Y as OrderQuoteSideKindSell,oe as OrderSigningUtils,K as OrderStatus,ce as PollResultCode,Z as PriceEstimationError,X as PriceQuality,de as ProofLocation,q as ReplaceOrderError,re as SUBGRAPH_PROD_CONFIG,ae as SUBGRAPH_STAGING_CONFIG,z as SellTokenSource,J as SigningScheme,Xe as StartTimeValue,se as SubgraphApi,l as SupportedChainId,He as TWAP_ADDRESS,Je as Twap,Se as createSetDomainVerifierTx,_e as decodeParams,Pe as encodeParams,De as formatEpoch,we as fromStructToOrder,me as getBlockInfo,fe as getDomainVerifier,Ne as isComposableCow,ve as isExtensibleFallbackHandler,ge as isValidAbi,T as logPrefix,g as request,Qe as transformDataToStruct,et as transformStructToData}; | ||
`,ne="https://api.thegraph.com/subgraphs/name/cowprotocol",re={[l.MAINNET]:ne+"/cow",[l.GNOSIS_CHAIN]:ne+"/cow-gc",[l.GOERLI]:ne+"/cow-goerli"},ae={[l.MAINNET]:ne+"/cow-staging",[l.GNOSIS_CHAIN]:ne+"/cow-gc-staging",[l.GOERLI]:""};class se{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context={...m,...e}}getTotals(e={}){try{return Promise.resolve(this.runQuery(Q,void 0,e)).then(function(e){return e.totals[0]})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e,t={}){try{return Promise.resolve(this.runQuery(ee,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(te,{hours:e},t))}catch(e){return Promise.reject(e)}}runQuery(e,t=undefined,n={}){try{const a=this,{chainId:s,env:i}=a.getContextWithOverride(n),o=a.getEnvConfigs(i)[s];return Promise.resolve(function(n,a){try{var s=Promise.resolve(r(o,e,t))}catch(e){return a(e)}return s&&s.then?s.then(void 0,a):s}(0,function(n){throw console.error(`[subgraph:${a.API_NAME}]`,n),new f(`Error running query: ${e}. Variables: ${JSON.stringify(t)}. API: ${o}. Inner Error: ${n}`)}))}catch(e){return Promise.reject(e)}}getContextWithOverride(e={}){return{...this.context,...e}}getEnvConfigs(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?re:ae}}const ie=()=>import("./utils-c6e2eeca.js");class oe{static signOrder(e,t,n){try{return Promise.resolve(ie()).then(function({signOrder:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,n){try{return Promise.resolve(ie()).then(function({signOrderCancellation:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,n){try{return Promise.resolve(ie()).then(function({signOrderCancellations:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(ie()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(ie()).then(function({getDomain:t}){return Promise.resolve(import("ethers/lib/utils")).then(function({_TypedDataEncoder:n}){return n.hashDomain(t(e))})})}catch(e){return Promise.reject(e)}}static getEIP712Types(){return{Order:[{name:"sellToken",type:"address"},{name:"buyToken",type:"address"},{name:"receiver",type:"address"},{name:"sellAmount",type:"uint256"},{name:"buyAmount",type:"uint256"},{name:"validTo",type:"uint32"},{name:"appData",type:"bytes32"},{name:"feeAmount",type:"uint256"},{name:"kind",type:"string"},{name:"partiallyFillable",type:"bool"},{name:"sellTokenBalance",type:"string"},{name:"buyTokenBalance",type:"string"}]}}}var de,ce;!function(e){e[e.PRIVATE=0]="PRIVATE",e[e.EMITTED=1]="EMITTED",e[e.SWARM=2]="SWARM",e[e.WAKU=3]="WAKU",e[e.RESERVED=4]="RESERVED",e[e.IPFS=5]="IPFS"}(de||(de={})),function(e){e.SUCCESS="SUCCESS",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.TRY_NEXT_BLOCK="TRY_NEXT_BLOCK",e.TRY_ON_BLOCK="TRY_ON_BLOCK",e.TRY_AT_EPOCH="TRY_AT_EPOCH",e.DONT_TRY_AGAIN="DONT_TRY_AGAIN"}(ce||(ce={}));const ue=[{inputs:[{internalType:"address",name:"_settlement",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InterfaceNotSupported",type:"error"},{inputs:[],name:"InvalidHandler",type:"error"},{inputs:[],name:"ProofNotAuthed",type:"error"},{inputs:[],name:"SingleOrderNotAuthed",type:"error"},{inputs:[],name:"SwapGuardRestricted",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],indexed:!1,internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"ConditionalOrderCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],indexed:!1,internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"MerkleRootSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"SwapGuardSet",type:"event"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"cabinet",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"create",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"createWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bytes",name:"offchainInput",type:"bytes"},{internalType:"bytes32[]",name:"proof",type:"bytes32[]"}],name:"getTradeableOrderWithSignature",outputs:[{components:[{internalType:"contract IERC20",name:"sellToken",type:"address"},{internalType:"contract IERC20",name:"buyToken",type:"address"},{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"buyAmount",type:"uint256"},{internalType:"uint32",name:"validTo",type:"uint32"},{internalType:"bytes32",name:"appData",type:"bytes32"},{internalType:"uint256",name:"feeAmount",type:"uint256"},{internalType:"bytes32",name:"kind",type:"bytes32"},{internalType:"bool",name:"partiallyFillable",type:"bool"},{internalType:"bytes32",name:"sellTokenBalance",type:"bytes32"},{internalType:"bytes32",name:"buyTokenBalance",type:"bytes32"}],internalType:"struct GPv2Order.Data",name:"order",type:"tuple"},{internalType:"bytes",name:"signature",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"hash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"safe",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes32",name:"_domainSeparator",type:"bytes32"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"encodeData",type:"bytes"},{internalType:"bytes",name:"payload",type:"bytes"}],name:"isValidSafeSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"singleOrderHash",type:"bytes32"}],name:"remove",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"roots",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"setRoot",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"setRootWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"setSwapGuard",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"singleOrders",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"swapGuards",outputs:[{internalType:"contract ISwapGuard",name:"",type:"address"}],stateMutability:"view",type:"function"}];class pe{static createInterface(){return new a.Interface(ue)}static connect(e,t){return new s(e,ue,t)}}pe.abi=ue;const le=[{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"verifier",type:"address"}],name:"AddedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"AddedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"method",type:"bytes32"}],name:"AddedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"oldVerifier",type:"address"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"ChangedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"oldMethod",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"ChangedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"}],name:"RemovedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"RemovedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"}],name:"RemovedSafeMethod",type:"event"},{stateMutability:"nonpayable",type:"fallback"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"domainVerifiers",outputs:[{internalType:"contract ISafeSignatureVerifier",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeInterfaces",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeMethods",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"setDomainVerifier",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"},{internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"setSafeMethod",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"},{internalType:"bool",name:"supported",type:"bool"}],name:"setSupportedInterface",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"_interfaceId",type:"bytes4"},{internalType:"bytes32[]",name:"handlerWithSelectors",type:"bytes32[]"}],name:"setSupportedInterfaceBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class ye{static createInterface(){return new a.Interface(le)}static connect(e,t){return new s(e,le,t)}}ye.abi=le;const me=function(e){try{return Promise.resolve(e.getBlock("latest")).then(function(e){return{blockNumber:e.number,blockTimestamp:e.timestamp}})}catch(e){return Promise.reject(e)}},fe=function(e,t,n,r){try{const a=ye.connect(S[n],r);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}},Te=["erc20","0x5a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc9"],be=["external","0xabee3b73373acd583a130924aad6dc38cfdc44ba0555ba94ce2ff63980ea0632"],he=["internal","0x4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce"],Ee=["sell","0xf3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee346775"],Ie=["buy","0x6ed88e868af0a1983e3886d5f3e95a2fafbd6c3450bc229e27342283dc429ccc"],Ae=["tuple(address handler, bytes32 salt, bytes staticInput)"],Oe=(e,t)=>`${t}@${e}`;function ve(e,t){return e===S[t]}function Ne(e,t){return e===P[t]}function Se(e,t){return ye.createInterface().encodeFunctionData("setDomainVerifier",[e,t])}function Pe(e){return a.defaultAbiCoder.encode(Ae,[e])}function _e(e){const{handler:t,salt:n,staticInput:r}=a.defaultAbiCoder.decode(Ae,e)[0];return{handler:t,salt:n,staticInput:r}}function ge(e,t){try{a.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}function De(e){return new Date(1e3*e).toISOString()}function Ce(e){if(Te.includes(e))return c.ERC20;if(be.includes(e))return c.EXTERNAL;if(he.includes(e))return c.INTERNAL;throw new Error(`Unknown balance type: ${e}`)}function Re(e){if(Ee.includes(e))return u.SELL;if(Ie.includes(e))return u.BUY;throw new Error(`Unknown kind: ${e}`)}function we(e){const{sellToken:t,sellAmount:n,buyToken:r,buyAmount:a,buyTokenBalance:s,sellTokenBalance:i,feeAmount:o,kind:d,receiver:c,validTo:u,partiallyFillable:p,appData:l}=e;return{sellToken:t,sellAmount:n,buyToken:r,buyAmount:a,feeAmount:o,receiver:c,partiallyFillable:p,appData:l,validTo:Number(u),kind:Re(d.toString()),sellTokenBalance:Ce(i.toString()),buyTokenBalance:Ce(s.toString())}}let xe,Ue;function Le(){return xe||(xe=pe.createInterface()),xe}function Me(e,t){return Ue||(Ue=pe.connect(P[e],t)),Ue}const Fe={};class ke{constructor(e){this.handler=void 0,this.salt=void 0,this.data=void 0,this.staticInput=void 0,this.hasOffChainInput=void 0;const{handler:t,salt:n=a.keccak256(a.randomBytes(32)),data:r,hasOffChainInput:s=!1}=e;if(!i.utils.isAddress(t))throw new Error(`Invalid handler: ${t}`);if(!i.utils.isHexString(n)||32!==i.utils.hexDataLength(n))throw new Error(`Invalid salt: ${n}`);this.handler=t,this.salt=n,this.data=r,this.staticInput=this.transformDataToStruct(r),this.hasOffChainInput=s}get context(){}assertIsValid(){const e=this.isValid();if(!e.isValid)throw new Error(`Invalid order: ${e.reason}`)}get createCalldata(){this.assertIsValid();const e=this.context,t=Le(),n={handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()};if(e){const r=e.factoryArgs?a.defaultAbiCoder.encode(e.factoryArgs.argsType,e.factoryArgs.args):"0x";return t.encodeFunctionData("createWithContext",[n,e.address,r,!0])}return t.encodeFunctionData("create",[n,!0])}get removeCalldata(){return this.assertIsValid(),Le().encodeFunctionData("remove",[this.id])}get id(){return a.keccak256(this.serialize())}get ctx(){return this.isSingleOrder?this.id:o.HashZero}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.keccak256(Pe(e))}get offChainInput(){return"0x"}encodeStaticInputHelper(e,t){return a.defaultAbiCoder.encode(e,[t])}poll(e){try{const t=this,{chainId:n,owner:r,provider:a,orderbookApiConfig:s}=e,i=Me(n,a);return Promise.resolve(function(a,o){try{var d=function(){const a=t.isValid();return a.isValid?Promise.resolve(t.pollValidate(e)).then(function(a){return a||Promise.resolve(t.isAuthorized(e)).then(function(a){return a?Promise.resolve(i.getTradeableOrderWithSignature(r,t.leaf,t.offChainInput,[])).then(function([a,i]){let o=Fe[n];return o||(o=new F({...s,chainId:n}),Fe[n]=o),Promise.resolve(function(e,t,n){try{return Promise.resolve(import("@cowprotocol/contracts")).then(function({computeOrderUid:r}){return Promise.resolve(oe.getDomain(e)).then(function(e){return r(e,n,t)})})}catch(e){return Promise.reject(e)}}(n,r,we(a))).then(function(n){return Promise.resolve(o.getOrder(n).then(()=>!0).catch(()=>!1)).then(function(r){let s;function o(e){return s?e:{result:ce.SUCCESS,order:a,signature:i}}const d=function(){if(r)return Promise.resolve(t.handlePollFailedAlreadyPresent(n,a,e)).then(function(e){return e?(s=1,e):(s=1,{result:ce.TRY_NEXT_BLOCK,reason:"Order already in orderbook"})})}();return d&&d.then?d.then(o):o(d)})})}):{result:ce.DONT_TRY_AGAIN,reason:`NotAuthorized: Order ${t.id} is not authorized for ${r} on chain ${n}`}})}):{result:ce.DONT_TRY_AGAIN,reason:`InvalidConditionalOrder. Reason: ${a.reason}`}}()}catch(e){return o(e)}return d&&d.then?d.then(void 0,o):d}(0,function(e){return{result:ce.UNEXPECTED_ERROR,error:e}}))}catch(e){return Promise.reject(e)}}isAuthorized(e){const{chainId:t,owner:n,provider:r}=e;return Me(t,r).callStatic.singleOrders(n,this.id)}cabinet(e){const{chainId:t,owner:n,provider:r}=e;return Me(t,r).callStatic.cabinet(n,this.ctx)}static deserializeHelper(e,t,n,r){try{const{handler:s,salt:i,staticInput:o}=_e(e);if(s!=t)throw new Error("HandlerMismatch");const[d]=a.defaultAbiCoder.decode(n,o);return r(d,i)}catch(e){throw"HandlerMismatch"===e.message?e:new Error("InvalidSerializedConditionalOrder")}}}const Ge=["address","bytes32","bytes"],Be=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];class Ve{constructor(e,t,n,r=de.PRIVATE){if(this.chain=void 0,this.location=void 0,this.orders={},this.tree=void 0,this.ctx=void 0,this.chain=e,this.location=r,t&&0===Object.keys(t).length)throw new Error("orders must have non-zero length");if(t&&!n||!t&&n)throw new Error("orders cannot have undefined root");for(const e in t)if(t.hasOwnProperty(e)){const n=t[e];if(!Ve.orderTypeRegistry.hasOwnProperty(n.orderType))throw new Error(`Unknown order type: ${n.orderType}`)}if(t&&(this.orders=t,this.getOrGenerateTree().root!==n))throw new Error("root mismatch")}static fromJSON(e){const{chain:t,orders:n,root:r,location:a}=JSON.parse(e,(e,t)=>{if("orders"===e&&"object"==typeof t&&null!==t){const e={};for(const n in t)if(t.hasOwnProperty(n)){const{orderType:r,...a}=t[n];if(!Ve.orderTypeRegistry.hasOwnProperty(r))throw new Error(`Unknown order type: ${r}`);e[n]=new(0,Ve.orderTypeRegistry[r])(a)}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?d.from(t):t}),s=new Ve(t,n,r);return s.location=a,s}toJSON(){const e=this.getOrGenerateTree().root;return JSON.stringify({...this,root:e},(e,t)=>{if("tree"!==e){if("object"==typeof t&&null!==t&&"orderType"in t){const e=t;return{...e,orderType:e.orderType}}return t}})}add(e){e.assertIsValid(),this.orders[e.id]=e,this.reset()}remove(e){delete this.orders[e],this.reset()}update(e,t){const n=t(this.orders[e],this.ctx);delete this.orders[e],this.orders[n.id]=n,this.reset()}getById(e){return this.orders[e]}getByIndex(e){return this.orders[this.orderIds[e]]}get orderIds(){return Object.keys(this.orders)}get root(){return this.getOrGenerateTree().root}getOrGenerateTree(){return this.tree||(this.tree=p.of(Object.values(this.orders).map(e=>[...Object.values(e.leaf)]),Ge)),this.tree}static decodeFromJSON(e){return JSON.parse(e)}prepareProofStruct(e,t,n){try{const r=this;void 0===e&&(e=r.location);const s=function(){try{switch(e){case de.PRIVATE:return Promise.resolve("0x");case de.EMITTED:return Promise.resolve(r.encodeToABI(t));case de.SWARM:case de.WAKU:case de.IPFS:if(!n)throw new Error("Must provide an uploader function");return Promise.resolve(function(e,a){try{var s=Promise.resolve(n(r.encodeToJSON(t)))}catch(e){return a(e)}return s&&s.then?s.then(void 0,a):s}(0,function(t){throw new Error(`Error uploading to decentralized storage ${e}: ${t}`)}));default:throw new Error("Unsupported location")}}catch(e){return Promise.reject(e)}};return Promise.resolve(s().then(t=>{try{return a.hexlify(a.arrayify(t)),r.location=e,{location:e,data:t}}catch(e){throw new Error("data returned by uploader is invalid")}}).catch(e=>{throw new Error(`Error preparing proof struct: ${e}`)}))}catch(e){return Promise.reject(e)}}static poll(e,t,n,r,a){try{function s(n){return Promise.resolve(i.getTradeableOrderWithSignature(e,t.params,n,t.proof))}const i=Me(n,r);return Promise.resolve(a?Promise.resolve(a(e,t.params)).then(s):s("0x"))}catch(o){return Promise.reject(o)}}dumpProofs(e){return this.encodeToJSON(e)}dumpProofsAndParams(e){return this.getProofs(e)}getProofs(e){return[...this.getOrGenerateTree().entries()].map(([t,n])=>e&&e(n)||void 0===e?{idx:t,value:n}:void 0).reduce((e,t)=>{if(t){const n={handler:t.value[0],salt:t.value[1],staticInput:t.value[2]};e.push({proof:this.getOrGenerateTree().getProof(t.idx),params:n})}return e},[])}encodeToABI(e){return a.defaultAbiCoder.encode(Be,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){Ve.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){Ve.orderTypeRegistry={}}}Ve.orderTypeRegistry={};class $e{constructor(e){this.knownOrderTypes=void 0,this.knownOrderTypes=e}fromParams(e){const{handler:t}=e,n=this.knownOrderTypes[t];if(n)return n(e)}}const He="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",We="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",je=d.from(2).pow(32).sub(1),Ye=d.from(31536e3),Ke=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"];var Ze,Xe;!function(e){e.AUTO="AUTO",e.LIMIT_DURATION="LIMIT_DURATION"}(Ze||(Ze={})),function(e){e.AT_MINING_TIME="AT_MINING_TIME",e.AT_EPOCH="AT_EPOCH"}(Xe||(Xe={}));const qe={startType:Xe.AT_MINING_TIME},ze={durationType:Ze.AUTO};class Je extends ke{constructor(e){const{handler:t,salt:n,data:r,hasOffChainInput:a}=e;if(t!==He)throw new Error(`InvalidHandler: Expected: ${He}, provided: ${t}`);super({handler:He,salt:n,data:r,hasOffChainInput:a}),this.isSingleOrder=!0}static fromData(e,t){return new Je({handler:He,data:e,salt:t})}static fromParams(e){return Je.deserialize(Pe(e))}get context(){return this.staticInput.t0.gt(0)?super.context:{address:We,factoryArgs:void 0}}get orderType(){return"twap"}isValid(){const e=(()=>{const{sellToken:e,sellAmount:t,buyToken:n,buyAmount:r,startTime:a=qe,numberOfParts:s,timeBetweenParts:i,durationOfPart:d=ze}=this.data;if(e==n)return"InvalidSameToken";if(e==o.AddressZero||n==o.AddressZero)return"InvalidToken";if(!t.gt(o.Zero))return"InvalidSellAmount";if(!r.gt(o.Zero))return"InvalidMinBuyAmount";if(a.startType===Xe.AT_EPOCH){const e=a.epoch;if(!e.gte(o.Zero)||!e.lt(je))return"InvalidStartTime"}return s.gt(o.One)&&s.lte(je)?i.gt(o.Zero)&&i.lte(Ye)?d.durationType!==Ze.LIMIT_DURATION||d.duration.lte(i)?ge(Ke,[this.staticInput])?void 0:"InvalidData":"InvalidSpan":"InvalidFrequency":"InvalidNumParts"})();return e?{isValid:!1,reason:e}:{isValid:!0}}startTimestamp(e){try{const t=this,{startTime:n}=t.data;return n?.startType===Xe.AT_EPOCH?Promise.resolve(n.epoch.toNumber()):Promise.resolve(t.cabinet(e)).then(function(e){const t=a.defaultAbiCoder.decode(["uint256"],e)[0];if(t.gt(je))throw new Error(`Cabinet epoch out of range: ${t.toString()}`);const n=t.toNumber();if(0===n)throw new Error("Cabinet is not set. Required for TWAP orders that start at mining time.");return n})}catch(e){return Promise.reject(e)}}endTimestamp(e){const{numberOfParts:t,timeBetweenParts:n,durationOfPart:r}=this.data;return r&&r.durationType===Ze.LIMIT_DURATION?e+t.sub(1).mul(n).add(r.duration).toNumber():e+t.mul(n).toNumber()}pollValidate(e){try{const t=this;return Promise.resolve(me(e.provider)).then(function(n){const{blockInfo:r=n}=e,{blockTimestamp:a}=r;return function(n,r){try{var s=Promise.resolve(t.startTimestamp(e)).then(function(e){if(e>a)return{result:ce.TRY_AT_EPOCH,epoch:e,reason:`TWAP hasn't started yet. Starts at ${e} (${De(e)})`};const n=t.endTimestamp(e);return a>=n?{result:ce.DONT_TRY_AGAIN,reason:`TWAP has expired. Expired at ${n} (${De(n)})`}:void 0})}catch(e){return r(e)}return s&&s.then?s.then(void 0,r):s}(0,function(e){return e?.message?.includes("Cabinet is not set")?{result:ce.DONT_TRY_AGAIN,reason:`${e?.message}. User likely removed the order.`}:e?.message?.includes("Cabinet epoch out of range")?{result:ce.DONT_TRY_AGAIN,reason:`${e?.message}`}:{result:ce.UNEXPECTED_ERROR,reason:`Unexpected error: ${e.message}`,error:e}})})}catch(e){return Promise.reject(e)}}handlePollFailedAlreadyPresent(e,t,n){try{const e=this;return Promise.resolve(me(n.provider)).then(function(t){const{blockInfo:r=t}=n,{blockTimestamp:a}=r,s=e.data.timeBetweenParts.toNumber(),{numberOfParts:i}=e.data;return Promise.resolve(e.startTimestamp(n)).then(function(e){if(a<e)return{result:ce.UNEXPECTED_ERROR,reason:`TWAP part hash't started. First TWAP part start at ${e} (${De(e)})`,error:void 0};const t=i.mul(s).add(e).toNumber();if(a>=t)return{result:ce.UNEXPECTED_ERROR,reason:`TWAP is expired. Expired at ${t} (${De(t)})`,error:void 0};const n=Math.floor((a-e)/s);if(n===i.toNumber()-1)return{result:ce.DONT_TRY_AGAIN,reason:`Current active TWAP part (${n+1}/${i}) is already in the Order Book. This was the last TWAP part, no more orders need to be placed`};const r=e+(n+1)*s;return{result:ce.TRY_AT_EPOCH,epoch:r,reason:`Current active TWAP part (${n+1}/${i}) is already in the Order Book. TWAP part ${n+2} doesn't start until ${r} (${De(r)})`}})})}catch(e){return Promise.reject(e)}}serialize(){return Pe(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(Ke,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,He,Ke,(e,t)=>new Je({handler:He,salt:t,data:et(e)}))}toString(){const{sellAmount:e,sellToken:t,buyAmount:n,buyToken:r,numberOfParts:a,startTime:s=qe,timeBetweenParts:i,durationOfPart:o=ze,receiver:d,appData:c}=this.data,u=s.startType===Xe.AT_MINING_TIME?"AT_MINING_TIME":s.epoch.toNumber(),p=o.durationType===Ze.AUTO?"AUTO":o.duration.toNumber(),l={sellAmount:e.toString(),sellToken:t,buyAmount:n.toString(),buyToken:r,numberOfParts:a.toString(),startTime:u,timeBetweenParts:i.toNumber(),durationOfPart:p,receiver:d,appData:c};return`${this.orderType} (${this.id}): ${JSON.stringify(l)}`}transformDataToStruct(e){return Qe(e)}transformStructToData(e){return et(e)}}function Qe(e){const{sellAmount:t,buyAmount:n,numberOfParts:r,startTime:a=qe,timeBetweenParts:s,durationOfPart:i=ze,...d}=e,{partSellAmount:c,minPartLimit:u}=r&&!r.isZero()?{partSellAmount:t.div(r),minPartLimit:n.div(r)}:{partSellAmount:o.Zero,minPartLimit:o.Zero};return{partSellAmount:c,minPartLimit:u,t0:a.startType===Xe.AT_MINING_TIME?o.Zero:a.epoch,n:r,t:s,span:i.durationType===Ze.AUTO?o.Zero:i.duration,...d}}function et(e){const{n:t,partSellAmount:n,minPartLimit:r,t:a,t0:s,span:i,...o}=e,d=i.isZero()?{durationType:Ze.AUTO}:{durationType:Ze.LIMIT_DURATION,duration:i},c=i.isZero()?{startType:Xe.AT_MINING_TIME}:{startType:Xe.AT_EPOCH,epoch:s};return{sellAmount:n.mul(t),buyAmount:r.mul(t),startTime:c,numberOfParts:t,timeBetweenParts:a,durationOfPart:d,...o}}const tt={[He]:e=>Je.fromParams(e)};export{v as ALL_SUPPORTED_CHAIN_IDS,I as BUY_ETH_ADDRESS,k as BuyTokenDestination,O as COMPOSABLE_COW,P as COMPOSABLE_COW_CONTRACT_ADDRESS,Ae as CONDITIONAL_ORDER_PARAMS_ABI,N as COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS,We as CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS,ke as ConditionalOrder,$e as ConditionalOrderFactory,f as CowError,R as DEFAULT_BACKOFF_OPTIONS,tt as DEFAULT_CONDITIONAL_ORDER_REGISTRY,m as DEFAULT_COW_API_CONTEXT,b as DEFAULT_IPFS_READ_URI,h as DEFAULT_IPFS_WRITE_URI,w as DEFAULT_LIMITER_OPTIONS,Oe as DEFAULT_TOKEN_FORMATTER,Ze as DurationType,y as ENVS_LIST,A as EXTENSIBLE_FALLBACK_HANDLER,S as EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS,G as EcdsaSigningScheme,Ye as MAX_FREQUENCY,je as MAX_UINT32,Ve as Multiplexer,U as ORDER_BOOK_PROD_CONFIG,L as ORDER_BOOK_STAGING_CONFIG,B as OnchainOrderData,F as OrderBookApi,D as OrderBookApiError,V as OrderCancellationError,$ as OrderClass,H as OrderKind,W as OrderPostError,j as OrderQuoteSideKindBuy,Y as OrderQuoteSideKindSell,oe as OrderSigningUtils,K as OrderStatus,ce as PollResultCode,Z as PriceEstimationError,X as PriceQuality,de as ProofLocation,q as ReplaceOrderError,re as SUBGRAPH_PROD_CONFIG,ae as SUBGRAPH_STAGING_CONFIG,z as SellTokenSource,J as SigningScheme,Xe as StartTimeValue,se as SubgraphApi,l as SupportedChainId,He as TWAP_ADDRESS,Je as Twap,Se as createSetDomainVerifierTx,_e as decodeParams,Pe as encodeParams,De as formatEpoch,we as fromStructToOrder,me as getBlockInfo,fe as getDomainVerifier,Ne as isComposableCow,ve as isExtensibleFallbackHandler,ge as isValidAbi,T as logPrefix,g as request,Qe as transformDataToStruct,et as transformStructToData}; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@cowprotocol/cow-sdk", | ||
"version": "4.0.0", | ||
"version": "4.0.3", | ||
"license": "(MIT OR Apache-2.0)", | ||
@@ -5,0 +5,0 @@ "files": [ |
{ | ||
"name": "@cowprotocol/cow-sdk", | ||
"version": "4.0.0", | ||
"version": "4.0.3", | ||
"license": "(MIT OR Apache-2.0)", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1101519
8288