Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cowprotocol/cow-sdk

Package Overview
Dependencies
Maintainers
8
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cowprotocol/cow-sdk - npm Package Compare versions

Comparing version 3.0.0-rc.0 to 3.0.0-rc.3

dist/composable/ConditionalOrder.d.ts

8

dist/composable/index.d.ts

@@ -1,4 +0,6 @@

export * from './extensible';
export * from './multiplexer';
export * from './conditionalorder';
export * from './types';
export * from './utils';
export * from './ConditionalOrder';
export * from './Multiplexer';
export * from './ConditionalOrderFactory';
export * from './orderTypes';

@@ -1,2 +0,2 @@

require("cross-fetch/polyfill");var e,t=require("limiter"),r=require("exponential-backoff"),n=require("graphql-request"),a=require("ethers"),s=require("@openzeppelin/merkle-tree"),o=require("ethers/lib/utils");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 c extends Error{constructor(e,t){super(e),this.error_code=void 0,this.error_code=t}}const{GPv2Settlement:u}=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}'),y="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",l="0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",m="0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",f=[exports.SupportedChainId.MAINNET,exports.SupportedChainId.GOERLI,exports.SupportedChainId.GNOSIS_CHAIN],h=f.reduce((e,t)=>({...e,[t]:u[t].address}),{}),b=f.reduce((e,t)=>({...e,[t]:l}),{}),T=f.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=y;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:s},o,i){try{const d={Accept:"application/json","Content-Type":"application/json"},p=`${e}${t}${n?"?"+n:""}`,c={method:a,body:(()=>{if(s)return"string"==typeof s?s:JSON.stringify(s)})(),headers:d};return Promise.resolve(r.backOff(function(){try{return Promise.resolve(o.removeTokens(1)).then(function(){return Promise.resolve(fetch(p,c)).then(function(e){return Promise.resolve(v(e)).then(function(t){return e.status>=200&&e.status<300?t:Promise.reject(new S(e,t))})})})}catch(e){return Promise.reject(e)}},i))}catch(e){return Promise.reject(e)}};class S 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 O=[408,425,429,500,502,503,504],A={numOfAttempts:10,maxDelay:Infinity,jitter:"none",retry:e=>!(e instanceof S)||O.includes(e.response.status)},x={tokensPerInterval:5,interval:"second"},v=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)}},C={[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"},P={[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 D(e){return Object.keys(e).reduce((t,r)=>{const n=e[r];return void 0!==n&&(t[r]=n),t},{})}var g,N,_,R,w,L,U,F,M,B,G,k,V,H,W;exports.BuyTokenDestination=void 0,(g=exports.BuyTokenDestination||(exports.BuyTokenDestination={})).ERC20="erc20",g.INTERNAL="internal",exports.EcdsaSigningScheme=void 0,(N=exports.EcdsaSigningScheme||(exports.EcdsaSigningScheme={})).EIP712="eip712",N.ETHSIGN="ethsign",exports.FeeAndQuoteError=void 0,(R=(_=exports.FeeAndQuoteError||(exports.FeeAndQuoteError={})).errorType||(_.errorType={})).NO_LIQUIDITY="NoLiquidity",R.UNSUPPORTED_TOKEN="UnsupportedToken",R.AMOUNT_IS_ZERO="AmountIsZero",R.SELL_AMOUNT_DOES_NOT_COVER_FEE="SellAmountDoesNotCoverFee",exports.OnchainOrderData=void 0,(L=(w=exports.OnchainOrderData||(exports.OnchainOrderData={})).placementError||(w.placementError={})).QUOTE_NOT_FOUND="QuoteNotFound",L.VALID_TO_TOO_FAR_IN_FUTURE="ValidToTooFarInFuture",L.PRE_VALIDATION_ERROR="PreValidationError",exports.OrderCancellationError=void 0,function(e){e.INVALID_SIGNATURE="InvalidSignature",e.WRONG_OWNER="WrongOwner",e.ORDER_NOT_FOUND="OrderNotFound",e.ALREADY_CANCELLED="AlreadyCancelled",e.ORDER_FULLY_EXECUTED="OrderFullyExecuted",e.ORDER_EXPIRED="OrderExpired",e.ON_CHAIN_ORDER="OnChainOrder"}((U=exports.OrderCancellationError||(exports.OrderCancellationError={})).errorType||(U.errorType={})),exports.OrderClass=void 0,(F=exports.OrderClass||(exports.OrderClass={})).MARKET="market",F.LIMIT="limit",F.LIQUIDITY="liquidity",exports.OrderKind=void 0,(M=exports.OrderKind||(exports.OrderKind={})).BUY="buy",M.SELL="sell",exports.OrderPostError=void 0,function(e){e.DUPLICATE_ORDER="DuplicateOrder",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.INVALID_EIP1271SIGNATURE="InvalidEip1271Signature",e.MISSING_FROM="MissingFrom",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",e.TOO_MANY_LIMIT_ORDERS="TooManyLimitOrders",e.INVALID_APP_DATA="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,(G=exports.OrderStatus||(exports.OrderStatus={})).PRESIGNATURE_PENDING="presignaturePending",G.OPEN="open",G.FULFILLED="fulfilled",G.CANCELLED="cancelled",G.EXPIRED="expired",exports.PriceQuality=void 0,(k=exports.PriceQuality||(exports.PriceQuality={})).FAST="fast",k.OPTIMAL="optimal",k.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.DUPLICATE_ORDER="DuplicateOrder",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"}((V=exports.ReplaceOrderError||(exports.ReplaceOrderError={})).errorType||(V.errorType={})),exports.SellTokenSource=void 0,(H=exports.SellTokenSource||(exports.SellTokenSource={})).ERC20="erc20",H.INTERNAL="internal",H.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`
require("cross-fetch/polyfill");var e,t=require("limiter"),r=require("exponential-backoff"),n=require("graphql-request"),a=require("ethers"),s=require("@openzeppelin/merkle-tree");function o(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 i=["prod","staging"],d={env:"prod",chainId:exports.SupportedChainId.MAINNET};class p extends Error{constructor(e,t){super(e),this.error_code=void 0,this.error_code=t}}const{GPv2Settlement:u}=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}'),c="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",l="0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",y="0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",m=[exports.SupportedChainId.MAINNET,exports.SupportedChainId.GOERLI,exports.SupportedChainId.GNOSIS_CHAIN],T=m.reduce((e,t)=>({...e,[t]:u[t].address}),{}),f=m.reduce((e,t)=>({...e,[t]:l}),{}),h=m.reduce((e,t)=>({...e,[t]:y}),{});function b(e){return function(e){const{ethflowData:t}=e;if(!t)return e;const{userValidTo:r}=t,n=e.onchainUser||e.owner,a=c;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 E=function(e,{path:t,query:n,method:a,body:s},o,i){try{const d={Accept:"application/json","Content-Type":"application/json"},p=`${e}${t}${n?"?"+n:""}`,u={method:a,body:(()=>{if(s)return"string"==typeof s?s:JSON.stringify(s)})(),headers:d};return Promise.resolve(r.backOff(function(){try{return Promise.resolve(o.removeTokens(1)).then(function(){return Promise.resolve(fetch(p,u)).then(function(e){return Promise.resolve(x(e)).then(function(t){return e.status>=200&&e.status<300?t:Promise.reject(new I(e,t))})})})}catch(e){return Promise.reject(e)}},i))}catch(e){return Promise.reject(e)}};class I 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 O=[408,425,429,500,502,503,504],S={numOfAttempts:10,maxDelay:Infinity,jitter:"none",retry:e=>!(e instanceof I)||O.includes(e.response.status)},A={tokensPerInterval:5,interval:"second"},x=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"},C={[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 P(e){return Object.keys(e).reduce((t,r)=>{const n=e[r];return void 0!==n&&(t[r]=n),t},{})}var v,N,D,R,g,L,w,U,M,F,B,G,V,k,H;exports.BuyTokenDestination=void 0,(v=exports.BuyTokenDestination||(exports.BuyTokenDestination={})).ERC20="erc20",v.INTERNAL="internal",exports.EcdsaSigningScheme=void 0,(N=exports.EcdsaSigningScheme||(exports.EcdsaSigningScheme={})).EIP712="eip712",N.ETHSIGN="ethsign",exports.FeeAndQuoteError=void 0,(R=(D=exports.FeeAndQuoteError||(exports.FeeAndQuoteError={})).errorType||(D.errorType={})).NO_LIQUIDITY="NoLiquidity",R.UNSUPPORTED_TOKEN="UnsupportedToken",R.AMOUNT_IS_ZERO="AmountIsZero",R.SELL_AMOUNT_DOES_NOT_COVER_FEE="SellAmountDoesNotCoverFee",exports.OnchainOrderData=void 0,(L=(g=exports.OnchainOrderData||(exports.OnchainOrderData={})).placementError||(g.placementError={})).QUOTE_NOT_FOUND="QuoteNotFound",L.VALID_TO_TOO_FAR_IN_FUTURE="ValidToTooFarInFuture",L.PRE_VALIDATION_ERROR="PreValidationError",exports.OrderCancellationError=void 0,function(e){e.INVALID_SIGNATURE="InvalidSignature",e.WRONG_OWNER="WrongOwner",e.ORDER_NOT_FOUND="OrderNotFound",e.ALREADY_CANCELLED="AlreadyCancelled",e.ORDER_FULLY_EXECUTED="OrderFullyExecuted",e.ORDER_EXPIRED="OrderExpired",e.ON_CHAIN_ORDER="OnChainOrder"}((w=exports.OrderCancellationError||(exports.OrderCancellationError={})).errorType||(w.errorType={})),exports.OrderClass=void 0,(U=exports.OrderClass||(exports.OrderClass={})).MARKET="market",U.LIMIT="limit",U.LIQUIDITY="liquidity",exports.OrderKind=void 0,(M=exports.OrderKind||(exports.OrderKind={})).BUY="buy",M.SELL="sell",exports.OrderPostError=void 0,function(e){e.DUPLICATE_ORDER="DuplicateOrder",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.INVALID_EIP1271SIGNATURE="InvalidEip1271Signature",e.MISSING_FROM="MissingFrom",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",e.TOO_MANY_LIMIT_ORDERS="TooManyLimitOrders",e.INVALID_APP_DATA="InvalidAppData",e.APP_DATA_HASH_MISMATCH="AppDataHashMismatch"}((F=exports.OrderPostError||(exports.OrderPostError={})).errorType||(F.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,(B=exports.OrderStatus||(exports.OrderStatus={})).PRESIGNATURE_PENDING="presignaturePending",B.OPEN="open",B.FULFILLED="fulfilled",B.CANCELLED="cancelled",B.EXPIRED="expired",exports.PriceQuality=void 0,(G=exports.PriceQuality||(exports.PriceQuality={})).FAST="fast",G.OPTIMAL="optimal",G.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.DUPLICATE_ORDER="DuplicateOrder",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"}((V=exports.ReplaceOrderError||(exports.ReplaceOrderError={})).errorType||(V.errorType={})),exports.SellTokenSource=void 0,(k=exports.SellTokenSource||(exports.SellTokenSource={})).ERC20="erc20",k.INTERNAL="internal",k.EXTERNAL="external",exports.SigningScheme=void 0,(H=exports.SigningScheme||(exports.SigningScheme={})).EIP712="eip712",H.ETHSIGN="ethsign",H.PRESIGN="presign",H.EIP1271="eip1271";const $=n.gql`
query Totals {

@@ -14,3 +14,3 @@ totals {

}
`,$=n.gql`
`,W=n.gql`
query LastDaysVolume($days: Int!) {

@@ -22,3 +22,3 @@ dailyTotals(orderBy: timestamp, orderDirection: desc, first: $days) {

}
`,q=n.gql`
`,j=n.gql`
query LastHoursVolume($hours: Int!) {

@@ -30,3 +30,3 @@ hourlyTotals(orderBy: timestamp, orderDirection: desc, first: $hours) {

}
`,K="https://api.thegraph.com/subgraphs/name/cowprotocol",Q={[exports.SupportedChainId.MAINNET]:K+"/cow",[exports.SupportedChainId.GNOSIS_CHAIN]:K+"/cow-gc",[exports.SupportedChainId.GOERLI]:K+"/cow-goerli"},Y={[exports.SupportedChainId.MAINNET]:K+"/cow-staging",[exports.SupportedChainId.GNOSIS_CHAIN]:K+"/cow-gc-staging",[exports.SupportedChainId.GOERLI]:""},J=()=>Promise.resolve().then(function(){return require("./utils-6743154b.js")}),X=[{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 z{static createInterface(){return new a.utils.Interface(X)}static connect(e,t){return new a.Contract(e,X,t)}}z.abi=X;const Z=[{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 ee{static createInterface(){return new a.utils.Interface(Z)}static connect(e,t){return new a.Contract(e,Z,t)}}ee.abi=Z;const te=["address","bytes32","bytes"],re=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];var ne;exports.ProofLocation=void 0,(ne=exports.ProofLocation||(exports.ProofLocation={}))[ne.PRIVATE=0]="PRIVATE",ne[ne.EMITTED=1]="EMITTED",ne[ne.SWARM=2]="SWARM",ne[ne.WAKU=3]="WAKU",ne[ne.RESERVED=4]="RESERVED",ne[ne.IPFS=5]="IPFS";class ae{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(!ae.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:s}=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(!ae.orderTypeRegistry.hasOwnProperty(n))throw new Error(`Unknown order type: ${n}`);{const t=ae.orderTypeRegistry[n],s=Object.values(a);e[r]=new t(...s)}}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?a.BigNumber.from(t):t}),o=new ae(t,r,n);return o.location=s,o}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){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)]),te)),this.tree}static decodeFromJSON(e){return JSON.parse(e)}prepareProofStruct(e,t,r){try{const n=this;void 0===e&&(e=n.location);const s=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 s=Promise.resolve(r(n.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.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 s(r){return Promise.resolve(o.getTradeableOrderWithSignature(e,t.params,r,t.proof))}const o=z.connect(T[r],n);return Promise.resolve(a?Promise.resolve(a(e,t.params)).then(s):s("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(re,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){ae.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){ae.orderTypeRegistry={}}}ae.orderTypeRegistry={};const se=["tuple(address handler, bytes32 salt, bytes staticInput)"];class oe{constructor(e,t=o.keccak256(a.ethers.utils.randomBytes(32)),r,n=!1){if(this.handler=void 0,this.salt=void 0,this.staticInput=void 0,this.hasOffChainInput=void 0,!a.ethers.utils.isAddress(e))throw new Error(`Invalid handler: ${e}`);if(!a.ethers.utils.isHexString(t)||32!==a.ethers.utils.hexDataLength(t))throw new Error(`Invalid salt: ${t}`);this.handler=e,this.salt=t,this.staticInput=this.transformParamsToData(r),this.hasOffChainInput=n}get context(){}get createCalldata(){const e=this.context,t=z.createInterface(),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 z.createInterface().encodeFunctionData("remove",[this.id])}get id(){return a.utils.keccak256(this.serialize())}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.utils.keccak256(oe.encodeParams(e))}get offChainInput(){return"0x"}static isValidAbi(e,t){try{a.ethers.utils.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}encodeStaticInputHelper(e,t){try{return a.utils.defaultAbiCoder.encode(e,[t])}catch(e){throw new Error("SerializationFailed")}}transformParamsToData(e){return e}static encodeParams(e){try{return a.utils.defaultAbiCoder.encode(se,[e])}catch(e){throw new Error("SerializationFailed")}}static decodeParams(e){try{return a.utils.defaultAbiCoder.decode(se,e)[0]}catch(e){throw new Error("DeserializationFailed")}}static deserializeHelper(e,t,r,n){try{const{handler:s,salt:o,staticInput:i}=oe.decodeParams(e);if(s!=t)throw new Error("HandlerMismatch");const[d]=a.utils.defaultAbiCoder.decode(r,i);return n(d,o)}catch(e){throw"HandlerMismatch"===e.message?e:new Error("InvalidSerializedConditionalOrder")}}}const ie="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",de="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",pe=a.BigNumber.from(2).pow(32).sub(1),ce=a.BigNumber.from(31536e3),ue=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"];class ye extends oe{constructor(e,t=a.utils.keccak256(a.ethers.utils.randomBytes(32)),r,n=!1){if(e!==ie)throw new Error("InvalidHandler");if(ye.isValid(r),super(ie,t,r,n),!ye.isValidAbi(ue,[this.staticInput]))throw new Error("InvalidData")}static default(e){return new ye(ie,void 0,e)}get context(){return this.staticInput.t0.gt(0)?super.context:{address:de,factoryArgs:void 0}}get orderType(){return"TWAP"}static isValid(e){if(e.sellToken==e.buyToken)throw new Error("InvalidSameToken");if(e.sellToken==a.constants.AddressZero||e.buyToken==a.constants.AddressZero)throw new Error("InvalidToken");if(!e.sellAmount.gt(a.constants.Zero))throw new Error("InvalidSellAmount");if(!e.buyAmount.gt(a.constants.Zero))throw new Error("InvalidMinBuyAmount");if(!e.t0.gte(a.constants.Zero)||!e.t0.lt(pe))throw new Error("InvalidStartTime");if(!e.n.gt(a.constants.One)||!e.n.lte(pe))throw new Error("InvalidNumParts");if(!e.t.gt(a.constants.Zero)||!e.t.lte(ce))throw new Error("InvalidFrequency");if(!e.span.lte(e.t))throw new Error("InvalidSpan");return!0}serialize(){return oe.encodeParams(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(ue,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,ie,ue,(e,t)=>new ye(ie,t,{...e,...ye.partsToTotal(e)}))}toString(e){e=e||((e,t)=>`${e}@${t}`);const{sellAmount:t,buyAmount:r}=ye.partsToTotal(this.staticInput);return`${this.orderType}: Sell total ${e(this.staticInput.sellToken,t)} for a minimum of ${e(this.staticInput.buyToken,r)} over ${this.staticInput.n} parts with a spacing of ${this.staticInput.t}s beginning at ${this.staticInput.t0.eq(0)?"time of mining":new Date(1e3*Number(this.staticInput.t0))}`}transformParamsToData(e){return{...e,...ye.totalToPart(e)}}static partsToTotal(e){return{sellAmount:e.partSellAmount.mul(e.n),buyAmount:e.minPartLimit.mul(e.n)}}static totalToPart(e){return{partSellAmount:e.sellAmount.div(e.n),minPartLimit:e.buyAmount.div(e.n)}}}exports.ALL_SUPPORTED_CHAIN_IDS=f,exports.BUY_ETH_ADDRESS=y,exports.BaseConditionalOrder=oe,exports.COMPOSABLE_COW=m,exports.COMPOSABLE_COW_CONTRACT_ADDRESS=T,exports.CONDITIONAL_ORDER_PARAMS_ABI=se,exports.COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS=h,exports.CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS=de,exports.CowError=c,exports.DEFAULT_BACKOFF_OPTIONS=A,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.ENVS_LIST=d,exports.EXTENSIBLE_FALLBACK_HANDLER=l,exports.EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS=b,exports.MAX_FREQUENCY=ce,exports.MAX_UINT32=pe,exports.Multiplexer=ae,exports.ORDER_BOOK_PROD_CONFIG=C,exports.ORDER_BOOK_STAGING_CONFIG=P,exports.OrderBookApi=class{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 c("Cannot specify both owner and orderId"));if(!e.owner&&!e.orderUid)return Promise.reject(new c("Must specify either owner or orderId"));const r=new URLSearchParams(D(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(D({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 s=r=>{const o=n[a];return r instanceof S&&404===r.response.status&&o?(a++,this.getOrder(e,{...t,env:o}).catch(s)):Promise.reject(r)};return this.getOrder(e,{...t,env:r}).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,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?C:P}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||A)}},exports.OrderBookApiError=S,exports.OrderSigningUtils=class{static signOrder(e,t,r){try{return Promise.resolve(J()).then(function({signOrder:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,r){try{return Promise.resolve(J()).then(function({signOrderCancellation:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,r){try{return Promise.resolve(J()).then(function({signOrderCancellations:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(J()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(J()).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"}]}}},exports.SUBGRAPH_PROD_CONFIG=Q,exports.SUBGRAPH_STAGING_CONFIG=Y,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($,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(q,{hours:e},t))}catch(e){return Promise.reject(e)}}runQuery(e,t=undefined,r={}){try{const a=this,{chainId:s,env:o}=a.getContextWithOverride(r),i=a.getEnvConfigs(o)[s];return Promise.resolve(function(r,a){try{var s=Promise.resolve(n.request(i,e,t))}catch(e){return a(e)}return s&&s.then?s.then(void 0,a):s}(0,function(r){throw console.error(`[subgraph:${a.API_NAME}]`,r),new c(`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?Q:Y}},exports.TWAP=ye,exports.TWAP_ADDRESS=ie,exports.createSetDomainVerifierTx=function(e,t){return ee.createInterface().encodeFunctionData("setDomainVerifier",[e,t])},exports.getDomainVerifier=function(e,t,r,n){try{const a=ee.connect(b[r],n);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}},exports.isComposableCow=function(e,t){return e===T[t]},exports.isExtensibleFallbackHandler=function(e,t){return e===b[t]},exports.logPrefix="cow-sdk:",exports.request=I;
`,K="https://api.thegraph.com/subgraphs/name/cowprotocol",Y={[exports.SupportedChainId.MAINNET]:K+"/cow",[exports.SupportedChainId.GNOSIS_CHAIN]:K+"/cow-gc",[exports.SupportedChainId.GOERLI]:K+"/cow-goerli"},q={[exports.SupportedChainId.MAINNET]:K+"/cow-staging",[exports.SupportedChainId.GNOSIS_CHAIN]:K+"/cow-gc-staging",[exports.SupportedChainId.GOERLI]:""},Q=()=>Promise.resolve().then(function(){return require("./utils-4e0f831b.js")});var Z,X;exports.ProofLocation=void 0,(Z=exports.ProofLocation||(exports.ProofLocation={}))[Z.PRIVATE=0]="PRIVATE",Z[Z.EMITTED=1]="EMITTED",Z[Z.SWARM=2]="SWARM",Z[Z.WAKU=3]="WAKU",Z[Z.RESERVED=4]="RESERVED",Z[Z.IPFS=5]="IPFS",exports.PollResultCode=void 0,(X=exports.PollResultCode||(exports.PollResultCode={})).SUCCESS="SUCCESS",X.UNEXPECTED_ERROR="UNEXPECTED_ERROR",X.TRY_NEXT_BLOCK="TRY_NEXT_BLOCK",X.TRY_ON_BLOCK="TRY_ON_BLOCK",X.TRY_AT_EPOCH="TRY_AT_DATE",X.DONT_TRY_AGAIN="DONT_TRY_AGAIN";const J=[{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 z{static createInterface(){return new a.utils.Interface(J)}static connect(e,t){return new a.Contract(e,J,t)}}z.abi=J;const ee=[{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 te{static createInterface(){return new a.utils.Interface(ee)}static connect(e,t){return new a.Contract(e,ee,t)}}te.abi=ee;const re=["tuple(address handler, bytes32 salt, bytes staticInput)"];function ne(e){return a.utils.defaultAbiCoder.encode(re,[e])}function ae(e){const{handler:t,salt:r,staticInput:n}=a.utils.defaultAbiCoder.decode(re,e)[0];return{handler:t,salt:r,staticInput:n}}function se(e,t){try{a.utils.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}let oe,ie;function de(){return oe||(oe=z.createInterface()),oe}function pe(e,t){return ie||(ie=z.connect(h[e],t)),ie}class ue{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:s=!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=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=de(),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(),de().encodeFunctionData("remove",[this.id])}get id(){return a.utils.keccak256(this.serialize())}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.utils.keccak256(ne(e))}get offChainInput(){return"0x"}encodeStaticInputHelper(e,t){return a.utils.defaultAbiCoder.encode(e,[t])}poll(e,t,r){try{const n=this,a=pe(t,r);return Promise.resolve(function(s,o){try{var i=function(){const s=n.isValid();return s.isValid?Promise.resolve(n.pollValidate(e,t,r)).then(function(s){return s||Promise.resolve(n.isAuthorized(e,t,r)).then(function(r){return r?Promise.resolve(a.getTradeableOrderWithSignature(e,n.leaf,n.offChainInput,[])).then(function([e,t]){return{result:exports.PollResultCode.SUCCESS,order:e,signature:t}}):{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`NotAuthorised: Order ${n.id} is not authorised for ${e} on chain ${t}`}})}):{result:exports.PollResultCode.DONT_TRY_AGAIN,reason:`InvalidConditionalOrder. Reason: ${s.reason}`}}()}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){return{result:exports.PollResultCode.UNEXPECTED_ERROR,error:e}}))}catch(e){return Promise.reject(e)}}isAuthorized(e,t,r){return pe(t,r).callStatic.singleOrders(e,this.id)}static deserializeHelper(e,t,r,n){try{const{handler:s,salt:o,staticInput:i}=ae(e);if(s!=t)throw new Error("HandlerMismatch");const[d]=a.utils.defaultAbiCoder.decode(r,i);return n(d,o)}catch(e){throw"HandlerMismatch"===e.message?e:new Error("InvalidSerializedConditionalOrder")}}}const ce=["address","bytes32","bytes"],le=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];class ye{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(!ye.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:s}=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(!ye.orderTypeRegistry.hasOwnProperty(n))throw new Error(`Unknown order type: ${n}`);e[r]=new(0,ye.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}),o=new ye(t,r,n);return o.location=s,o}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)]),ce)),this.tree}static decodeFromJSON(e){return JSON.parse(e)}prepareProofStruct(e,t,r){try{const n=this;void 0===e&&(e=n.location);const s=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 s=Promise.resolve(r(n.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.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 s(r){return Promise.resolve(o.getTradeableOrderWithSignature(e,t.params,r,t.proof))}const o=pe(r,n);return Promise.resolve(a?Promise.resolve(a(e,t.params)).then(s):s("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(le,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){ye.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){ye.orderTypeRegistry={}}}ye.orderTypeRegistry={};const me="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",Te="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",fe=a.BigNumber.from(2).pow(32).sub(1),he=a.BigNumber.from(31536e3),be=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"],Ee=(e,t)=>`${e}@${t}`;var Ie,Oe;exports.DurationType=void 0,(Ie=exports.DurationType||(exports.DurationType={})).AUTO="AUTO",Ie.LIMIT_DURATION="LIMIT_DURATION",exports.StartTimeValue=void 0,(Oe=exports.StartTimeValue||(exports.StartTimeValue={})).AT_MINING_TIME="AT_MINING_TIME",Oe.AT_EPOC="AT_EPOC";const Se={startType:exports.StartTimeValue.AT_MINING_TIME},Ae={durationType:exports.DurationType.AUTO};class xe extends ue{constructor(e){const{handler:t,salt:r,data:n,hasOffChainInput:a}=e;if(t!==me)throw new Error(`InvalidHandler: Expected: ${me}, provided: ${t}`);super({handler:me,salt:r,data:n,hasOffChainInput:a})}static fromData(e){return new xe({handler:me,data:e})}static fromParams(e){return xe.deserialize(ne(e))}get context(){return this.staticInput.t0.gt(0)?super.context:{address:Te,factoryArgs:void 0}}get orderType(){return"twap"}isValid(){const e=(()=>{const{sellToken:e,sellAmount:t,buyToken:r,buyAmount:n,startTime:s=Se,numberOfParts:o,timeBetweenParts:i,durationOfPart:d=Ae}=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(s.startType===exports.StartTimeValue.AT_EPOC){const e=s.epoch;if(!e.gte(a.constants.Zero)||!e.lt(fe))return"InvalidStartTime"}return o.gt(a.constants.One)&&o.lte(fe)?i.gt(a.constants.Zero)&&i.lte(he)?d.durationType!==exports.DurationType.LIMIT_DURATION||d.duration.lte(i)?se(be,[this.staticInput])?void 0:"InvalidData":"InvalidSpan":"InvalidFrequency":"InvalidNumParts"})();return e?{isValid:!1,reason:e}:{isValid:!0}}pollValidate(e,t,r){return Promise.resolve(void 0)}serialize(){return ne(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(be,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,me,be,(e,t)=>new xe({handler:me,salt:t,data:Ce(e)}))}toString(e=Ee){const{sellToken:t,buyToken:r,numberOfParts:n,timeBetweenParts:a=Ae,startTime:s=Se,sellAmount:o,buyAmount:i}=this.data,d=e(t,o),p=e(r,i),u=s.startType===exports.StartTimeValue.AT_MINING_TIME?"time of mining":"epoch "+s.epoch.toString();return`${this.orderType}: Sell total ${d} for a minimum of ${p} over ${n} parts with a spacing of ${a}s beginning at ${u}`}transformDataToStruct(e){return _e(e)}transformStructToData(e){return Ce(e)}}function _e(e){const{sellAmount:t,buyAmount:r,numberOfParts:n,startTime:s=Se,timeBetweenParts:o,durationOfPart:i=Ae,...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:s.startType===exports.StartTimeValue.AT_MINING_TIME?a.constants.Zero:s.epoch,n:n,t:o,span:c,...d}}function Ce(e){const{n:t,partSellAmount:r,minPartLimit:n,t:a,t0:s,span:o,...i}=e,d=o.isZero()?{durationType:exports.DurationType.AUTO}:{durationType:exports.DurationType.LIMIT_DURATION,duration:o},p=o.isZero()?{startType:exports.StartTimeValue.AT_MINING_TIME}:{startType:exports.StartTimeValue.AT_EPOC,epoch:s};return{sellAmount:r.mul(t),buyAmount:n.mul(t),startTime:p,numberOfParts:t,timeBetweenParts:a,durationOfPart:d,...i}}const Pe={[me]:e=>xe.fromParams(e)};exports.ALL_SUPPORTED_CHAIN_IDS=m,exports.BUY_ETH_ADDRESS=c,exports.COMPOSABLE_COW=y,exports.COMPOSABLE_COW_CONTRACT_ADDRESS=h,exports.CONDITIONAL_ORDER_PARAMS_ABI=re,exports.COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS=T,exports.CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS=Te,exports.ConditionalOrder=ue,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=p,exports.DEFAULT_BACKOFF_OPTIONS=S,exports.DEFAULT_CONDITIONAL_ORDER_REGSTRY=Pe,exports.DEFAULT_COW_API_CONTEXT=d,exports.DEFAULT_IPFS_READ_URI="https://gnosis.mypinata.cloud/ipfs",exports.DEFAULT_IPFS_WRITE_URI="https://api.pinata.cloud",exports.DEFAULT_LIMITER_OPTIONS=A,exports.ENVS_LIST=i,exports.EXTENSIBLE_FALLBACK_HANDLER=l,exports.EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS=f,exports.MAX_FREQUENCY=he,exports.MAX_UINT32=fe,exports.Multiplexer=ye,exports.ORDER_BOOK_PROD_CONFIG=_,exports.ORDER_BOOK_STAGING_CONFIG=C,exports.OrderBookApi=class{constructor(e={}){this.context=void 0,this.rateLimiter=void 0,this.context={...d,...e},this.rateLimiter=new t.RateLimiter(e.limiterOpts||A)}getVersion(e={}){return this.fetch({path:"/api/v1/version",method:"GET"},e)}getTrades(e,t={}){if(e.owner&&e.orderUid)return Promise.reject(new p("Cannot specify both owner and orderId"));if(!e.owner&&!e.orderUid)return Promise.reject(new p("Must specify either owner or orderId"));const r=new URLSearchParams(P(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(P({offset:t.toString(),limit:r.toString()}));return this.fetch({path:`/api/v1/account/${e}/orders`,method:"GET",query:a},n).then(e=>e.map(b))}getTxOrders(e,t={}){return this.fetch({path:`/api/v1/transactions/${e}/orders`,method:"GET"},t).then(e=>e.map(b))}getOrder(e,t={}){return this.fetch({path:`/api/v1/orders/${e}`,method:"GET"},t).then(e=>b(e))}getOrderMultiEnv(e,t={}){const{env:r}=this.getContextWithOverride(t),n=i.filter(e=>e!==r);let a=0;const s=r=>{const o=n[a];return r instanceof I&&404===r.response.status&&o?(a++,this.getOrder(e,{...t,env:o}).catch(s)):Promise.reject(r)};return this.getOrder(e,{...t,env:r}).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,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?_:C}fetch(e,t={}){const{chainId:r,env:n}=this.getContextWithOverride(t),a=this.getApiBaseUrls(n)[r];return E(a,e,this.rateLimiter,this.context.backoffOpts||S)}},exports.OrderBookApiError=I,exports.OrderSigningUtils=class{static signOrder(e,t,r){try{return Promise.resolve(Q()).then(function({signOrder:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,r){try{return Promise.resolve(Q()).then(function({signOrderCancellation:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,r){try{return Promise.resolve(Q()).then(function({signOrderCancellations:n}){return n(e,t,r)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(Q()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(Q()).then(function({getDomain:t}){return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return o(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"}]}}},exports.SUBGRAPH_PROD_CONFIG=Y,exports.SUBGRAPH_STAGING_CONFIG=q,exports.SubgraphApi=class{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context={...d,...e}}getTotals(e={}){try{return Promise.resolve(this.runQuery($,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(W,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(j,{hours:e},t))}catch(e){return Promise.reject(e)}}runQuery(e,t=undefined,r={}){try{const a=this,{chainId:s,env:o}=a.getContextWithOverride(r),i=a.getEnvConfigs(o)[s];return Promise.resolve(function(r,a){try{var s=Promise.resolve(n.request(i,e,t))}catch(e){return a(e)}return s&&s.then?s.then(void 0,a):s}(0,function(r){throw console.error(`[subgraph:${a.API_NAME}]`,r),new p(`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?Y:q}},exports.TWAP_ADDRESS=me,exports.Twap=xe,exports.createSetDomainVerifierTx=function(e,t){return te.createInterface().encodeFunctionData("setDomainVerifier",[e,t])},exports.decodeParams=ae,exports.encodeParams=ne,exports.getDomainVerifier=function(e,t,r,n){try{const a=te.connect(f[r],n);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}},exports.isComposableCow=function(e,t){return e===h[t]},exports.isExtensibleFallbackHandler=function(e,t){return e===f[t]},exports.isValidAbi=se,exports.logPrefix="cow-sdk:",exports.request=E,exports.transformDataToStruct=_e,exports.transformStructToData=Ce;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

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,BigNumber as i,ethers as o,constants as d}from"ethers";import{StandardMerkleTree as p}from"@openzeppelin/merkle-tree";import{keccak256 as c}from"ethers/lib/utils";var y;!function(e){e[e.MAINNET=1]="MAINNET",e[e.GOERLI=5]="GOERLI",e[e.GNOSIS_CHAIN=100]="GNOSIS_CHAIN"}(y||(y={}));const u=["prod","staging"],l={env:"prod",chainId:y.MAINNET};class m extends Error{constructor(e,t){super(e),this.error_code=void 0,this.error_code=t}}const f="cow-sdk:",b="https://gnosis.mypinata.cloud/ipfs",h="https://api.pinata.cloud",{GPv2Settlement:T}=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}'),E="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",I="0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",A="0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",O=[y.MAINNET,y.GOERLI,y.GNOSIS_CHAIN],S=O.reduce((e,t)=>({...e,[t]:T[t].address}),{}),v=O.reduce((e,t)=>({...e,[t]:I}),{}),g=O.reduce((e,t)=>({...e,[t]:A}),{});function N(e){return function(e){const{ethflowData:t}=e;if(!t)return e;const{userValidTo:n}=t,r=e.onchainUser||e.owner,a=E;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 D=function(e,{path:n,query:r,method:a,body:s},i,o){try{const d={Accept:"application/json","Content-Type":"application/json"},p=`${e}${n}${r?"?"+r:""}`,c={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(p,c)).then(function(e){return Promise.resolve(_(e)).then(function(t){return e.status>=200&&e.status<300?t:Promise.reject(new P(e,t))})})})}catch(e){return Promise.reject(e)}},o))}catch(e){return Promise.reject(e)}};class P 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 w=[408,425,429,500,502,503,504],C={numOfAttempts:10,maxDelay:Infinity,jitter:"none",retry:e=>!(e instanceof P)||w.includes(e.response.status)},x={tokensPerInterval:5,interval:"second"},_=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)}},R={[y.MAINNET]:"https://api.cow.fi/mainnet",[y.GNOSIS_CHAIN]:"https://api.cow.fi/xdai",[y.GOERLI]:"https://api.cow.fi/goerli"},U={[y.MAINNET]:"https://barn.api.cow.fi/mainnet",[y.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai",[y.GOERLI]:"https://barn.api.cow.fi/goerli"};function L(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={...l,...t},this.rateLimiter=new e(t.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 m("Cannot specify both owner and orderId"));if(!e.owner&&!e.orderUid)return Promise.reject(new m("Must specify either owner or orderId"));const n=new URLSearchParams(L(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(L({offset:t.toString(),limit:n.toString()}));return this.fetch({path:`/api/v1/account/${e}/orders`,method:"GET",query:a},r).then(e=>e.map(N))}getTxOrders(e,t={}){return this.fetch({path:`/api/v1/transactions/${e}/orders`,method:"GET"},t).then(e=>e.map(N))}getOrder(e,t={}){return this.fetch({path:`/api/v1/orders/${e}`,method:"GET"},t).then(e=>N(e))}getOrderMultiEnv(e,t={}){const{env:n}=this.getContextWithOverride(t),r=u.filter(e=>e!==n);let a=0;const s=n=>{const i=r[a];return n instanceof P&&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?R:U}fetch(e,t={}){const{chainId:n,env:r}=this.getContextWithOverride(t),a=this.getApiBaseUrls(r)[n];return D(a,e,this.rateLimiter,this.context.backoffOpts||C)}}var M,G,V,k,B,H,$,j,W,q,Y,J,K,z,Z;!function(e){e.ERC20="erc20",e.INTERNAL="internal"}(M||(M={})),function(e){e.EIP712="eip712",e.ETHSIGN="ethsign"}(G||(G={})),function(e){var t;(t=e.errorType||(e.errorType={})).NO_LIQUIDITY="NoLiquidity",t.UNSUPPORTED_TOKEN="UnsupportedToken",t.AMOUNT_IS_ZERO="AmountIsZero",t.SELL_AMOUNT_DOES_NOT_COVER_FEE="SellAmountDoesNotCoverFee"}(V||(V={})),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"}(k||(k={})),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"}(B||(B={})),function(e){e.MARKET="market",e.LIMIT="limit",e.LIQUIDITY="liquidity"}(H||(H={})),function(e){e.BUY="buy",e.SELL="sell"}($||($={})),function(e){var t;(t=e.errorType||(e.errorType={})).DUPLICATE_ORDER="DuplicateOrder",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.INVALID_EIP1271SIGNATURE="InvalidEip1271Signature",t.MISSING_FROM="MissingFrom",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",t.TOO_MANY_LIMIT_ORDERS="TooManyLimitOrders",t.INVALID_APP_DATA="InvalidAppData",t.APP_DATA_HASH_MISMATCH="AppDataHashMismatch"}(j||(j={})),function(e){e.BUY="buy"}(W||(W={})),function(e){e.SELL="sell"}(q||(q={})),function(e){e.PRESIGNATURE_PENDING="presignaturePending",e.OPEN="open",e.FULFILLED="fulfilled",e.CANCELLED="cancelled",e.EXPIRED="expired"}(Y||(Y={})),function(e){e.FAST="fast",e.OPTIMAL="optimal",e.VERIFIED="verified"}(J||(J={})),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.DUPLICATE_ORDER="DuplicateOrder",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"}(K||(K={})),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"}(Z||(Z={}));const Q=n`
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,BigNumber as o,constants as d}from"ethers";import{StandardMerkleTree as p}from"@openzeppelin/merkle-tree";var c;!function(e){e[e.MAINNET=1]="MAINNET",e[e.GOERLI=5]="GOERLI",e[e.GNOSIS_CHAIN=100]="GNOSIS_CHAIN"}(c||(c={}));const u=["prod","staging"],y={env:"prod",chainId:c.MAINNET};class l extends Error{constructor(e,t){super(e),this.error_code=void 0,this.error_code=t}}const m="cow-sdk:",f="https://gnosis.mypinata.cloud/ipfs",T="https://api.pinata.cloud",{GPv2Settlement:h}=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}'),b="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",E="0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",I="0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",A=[c.MAINNET,c.GOERLI,c.GNOSIS_CHAIN],O=A.reduce((e,t)=>({...e,[t]:h[t].address}),{}),S=A.reduce((e,t)=>({...e,[t]:E}),{}),v=A.reduce((e,t)=>({...e,[t]:I}),{});function N(e){return function(e){const{ethflowData:t}=e;if(!t)return e;const{userValidTo:n}=t,r=e.onchainUser||e.owner,a=b;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 P=function(e,{path:n,query:r,method:a,body:s},i,o){try{const d={Accept:"application/json","Content-Type":"application/json"},p=`${e}${n}${r?"?"+r:""}`,c={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(p,c)).then(function(e){return Promise.resolve(R(e)).then(function(t){return e.status>=200&&e.status<300?t:Promise.reject(new _(e,t))})})})}catch(e){return Promise.reject(e)}},o))}catch(e){return Promise.reject(e)}};class _ 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 g=[408,425,429,500,502,503,504],D={numOfAttempts:10,maxDelay:Infinity,jitter:"none",retry:e=>!(e instanceof _)||g.includes(e.response.status)},C={tokensPerInterval:5,interval:"second"},R=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)}},x={[c.MAINNET]:"https://api.cow.fi/mainnet",[c.GNOSIS_CHAIN]:"https://api.cow.fi/xdai",[c.GOERLI]:"https://api.cow.fi/goerli"},w={[c.MAINNET]:"https://barn.api.cow.fi/mainnet",[c.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai",[c.GOERLI]:"https://barn.api.cow.fi/goerli"};function U(e){return Object.keys(e).reduce((t,n)=>{const r=e[n];return void 0!==r&&(t[n]=r),t},{})}class L{constructor(t={}){this.context=void 0,this.rateLimiter=void 0,this.context={...y,...t},this.rateLimiter=new e(t.limiterOpts||C)}getVersion(e={}){return this.fetch({path:"/api/v1/version",method:"GET"},e)}getTrades(e,t={}){if(e.owner&&e.orderUid)return Promise.reject(new l("Cannot specify both owner and orderId"));if(!e.owner&&!e.orderUid)return Promise.reject(new l("Must specify either owner or orderId"));const n=new URLSearchParams(U(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(U({offset:t.toString(),limit:n.toString()}));return this.fetch({path:`/api/v1/account/${e}/orders`,method:"GET",query:a},r).then(e=>e.map(N))}getTxOrders(e,t={}){return this.fetch({path:`/api/v1/transactions/${e}/orders`,method:"GET"},t).then(e=>e.map(N))}getOrder(e,t={}){return this.fetch({path:`/api/v1/orders/${e}`,method:"GET"},t).then(e=>N(e))}getOrderMultiEnv(e,t={}){const{env:n}=this.getContextWithOverride(t),r=u.filter(e=>e!==n);let a=0;const s=n=>{const i=r[a];return n instanceof _&&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?x:w}fetch(e,t={}){const{chainId:n,env:r}=this.getContextWithOverride(t),a=this.getApiBaseUrls(r)[n];return P(a,e,this.rateLimiter,this.context.backoffOpts||D)}}var M,F,G,V,B,k,H,$,j,W,Y,Z,K,q,J;!function(e){e.ERC20="erc20",e.INTERNAL="internal"}(M||(M={})),function(e){e.EIP712="eip712",e.ETHSIGN="ethsign"}(F||(F={})),function(e){var t;(t=e.errorType||(e.errorType={})).NO_LIQUIDITY="NoLiquidity",t.UNSUPPORTED_TOKEN="UnsupportedToken",t.AMOUNT_IS_ZERO="AmountIsZero",t.SELL_AMOUNT_DOES_NOT_COVER_FEE="SellAmountDoesNotCoverFee"}(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"}(V||(V={})),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"}(B||(B={})),function(e){e.MARKET="market",e.LIMIT="limit",e.LIQUIDITY="liquidity"}(k||(k={})),function(e){e.BUY="buy",e.SELL="sell"}(H||(H={})),function(e){var t;(t=e.errorType||(e.errorType={})).DUPLICATE_ORDER="DuplicateOrder",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.INVALID_EIP1271SIGNATURE="InvalidEip1271Signature",t.MISSING_FROM="MissingFrom",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",t.TOO_MANY_LIMIT_ORDERS="TooManyLimitOrders",t.INVALID_APP_DATA="InvalidAppData",t.APP_DATA_HASH_MISMATCH="AppDataHashMismatch"}($||($={})),function(e){e.BUY="buy"}(j||(j={})),function(e){e.SELL="sell"}(W||(W={})),function(e){e.PRESIGNATURE_PENDING="presignaturePending",e.OPEN="open",e.FULFILLED="fulfilled",e.CANCELLED="cancelled",e.EXPIRED="expired"}(Y||(Y={})),function(e){e.FAST="fast",e.OPTIMAL="optimal",e.VERIFIED="verified"}(Z||(Z={})),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.DUPLICATE_ORDER="DuplicateOrder",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"}(K||(K={})),function(e){e.ERC20="erc20",e.INTERNAL="internal",e.EXTERNAL="external"}(q||(q={})),function(e){e.EIP712="eip712",e.ETHSIGN="ethsign",e.PRESIGN="presign",e.EIP1271="eip1271"}(J||(J={}));const X=n`
query Totals {

@@ -14,3 +14,3 @@ totals {

}
`,X=n`
`,z=n`
query LastDaysVolume($days: Int!) {

@@ -22,3 +22,3 @@ dailyTotals(orderBy: timestamp, orderDirection: desc, first: $days) {

}
`,ee=n`
`,Q=n`
query LastHoursVolume($hours: Int!) {

@@ -30,3 +30,3 @@ hourlyTotals(orderBy: timestamp, orderDirection: desc, first: $hours) {

}
`,te="https://api.thegraph.com/subgraphs/name/cowprotocol",ne={[y.MAINNET]:te+"/cow",[y.GNOSIS_CHAIN]:te+"/cow-gc",[y.GOERLI]:te+"/cow-goerli"},re={[y.MAINNET]:te+"/cow-staging",[y.GNOSIS_CHAIN]:te+"/cow-gc-staging",[y.GOERLI]:""};class ae{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context={...l,...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(X,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(ee,{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 m(`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?ne:re}}const se=()=>import("./utils-3ea4a36c.js");class ie{static signOrder(e,t,n){try{return Promise.resolve(se()).then(function({signOrder:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,n){try{return Promise.resolve(se()).then(function({signOrderCancellation:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,n){try{return Promise.resolve(se()).then(function({signOrderCancellations:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(se()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(se()).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"}]}}}const oe=[{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 de{static createInterface(){return new a.Interface(oe)}static connect(e,t){return new s(e,oe,t)}}de.abi=oe;const pe=[{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 ce{static createInterface(){return new a.Interface(pe)}static connect(e,t){return new s(e,pe,t)}}ce.abi=pe;const ye=function(e,t,n,r){try{const a=ce.connect(v[n],r);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}};function ue(e,t){return e===v[t]}function le(e,t){return e===g[t]}function me(e,t){return ce.createInterface().encodeFunctionData("setDomainVerifier",[e,t])}const fe=["address","bytes32","bytes"],be=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];var he;!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"}(he||(he={}));class Te{constructor(e,t,n,r=he.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(!Te.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(!Te.orderTypeRegistry.hasOwnProperty(r))throw new Error(`Unknown order type: ${r}`);{const t=Te.orderTypeRegistry[r],s=Object.values(a);e[n]=new t(...s)}}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?i.from(t):t}),s=new Te(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){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)]),fe)),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 he.PRIVATE:return Promise.resolve("0x");case he.EMITTED:return Promise.resolve(r.encodeToABI(t));case he.SWARM:case he.WAKU:case he.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=de.connect(g[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){Te.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){Te.orderTypeRegistry={}}}Te.orderTypeRegistry={};const Ee=["tuple(address handler, bytes32 salt, bytes staticInput)"];class Ie{constructor(e,t=c(o.utils.randomBytes(32)),n,r=!1){if(this.handler=void 0,this.salt=void 0,this.staticInput=void 0,this.hasOffChainInput=void 0,!o.utils.isAddress(e))throw new Error(`Invalid handler: ${e}`);if(!o.utils.isHexString(t)||32!==o.utils.hexDataLength(t))throw new Error(`Invalid salt: ${t}`);this.handler=e,this.salt=t,this.staticInput=this.transformParamsToData(n),this.hasOffChainInput=r}get context(){}get createCalldata(){const e=this.context,t=de.createInterface(),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 de.createInterface().encodeFunctionData("remove",[this.id])}get id(){return a.keccak256(this.serialize())}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.keccak256(Ie.encodeParams(e))}get offChainInput(){return"0x"}static isValidAbi(e,t){try{o.utils.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}encodeStaticInputHelper(e,t){try{return a.defaultAbiCoder.encode(e,[t])}catch(e){throw new Error("SerializationFailed")}}transformParamsToData(e){return e}static encodeParams(e){try{return a.defaultAbiCoder.encode(Ee,[e])}catch(e){throw new Error("SerializationFailed")}}static decodeParams(e){try{return a.defaultAbiCoder.decode(Ee,e)[0]}catch(e){throw new Error("DeserializationFailed")}}static deserializeHelper(e,t,n,r){try{const{handler:s,salt:i,staticInput:o}=Ie.decodeParams(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 Ae="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",Oe="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",Se=i.from(2).pow(32).sub(1),ve=i.from(31536e3),ge=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"];class Ne extends Ie{constructor(e,t=a.keccak256(o.utils.randomBytes(32)),n,r=!1){if(e!==Ae)throw new Error("InvalidHandler");if(Ne.isValid(n),super(Ae,t,n,r),!Ne.isValidAbi(ge,[this.staticInput]))throw new Error("InvalidData")}static default(e){return new Ne(Ae,void 0,e)}get context(){return this.staticInput.t0.gt(0)?super.context:{address:Oe,factoryArgs:void 0}}get orderType(){return"TWAP"}static isValid(e){if(e.sellToken==e.buyToken)throw new Error("InvalidSameToken");if(e.sellToken==d.AddressZero||e.buyToken==d.AddressZero)throw new Error("InvalidToken");if(!e.sellAmount.gt(d.Zero))throw new Error("InvalidSellAmount");if(!e.buyAmount.gt(d.Zero))throw new Error("InvalidMinBuyAmount");if(!e.t0.gte(d.Zero)||!e.t0.lt(Se))throw new Error("InvalidStartTime");if(!e.n.gt(d.One)||!e.n.lte(Se))throw new Error("InvalidNumParts");if(!e.t.gt(d.Zero)||!e.t.lte(ve))throw new Error("InvalidFrequency");if(!e.span.lte(e.t))throw new Error("InvalidSpan");return!0}serialize(){return Ie.encodeParams(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(ge,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,Ae,ge,(e,t)=>new Ne(Ae,t,{...e,...Ne.partsToTotal(e)}))}toString(e){e=e||((e,t)=>`${e}@${t}`);const{sellAmount:t,buyAmount:n}=Ne.partsToTotal(this.staticInput);return`${this.orderType}: Sell total ${e(this.staticInput.sellToken,t)} for a minimum of ${e(this.staticInput.buyToken,n)} over ${this.staticInput.n} parts with a spacing of ${this.staticInput.t}s beginning at ${this.staticInput.t0.eq(0)?"time of mining":new Date(1e3*Number(this.staticInput.t0))}`}transformParamsToData(e){return{...e,...Ne.totalToPart(e)}}static partsToTotal(e){return{sellAmount:e.partSellAmount.mul(e.n),buyAmount:e.minPartLimit.mul(e.n)}}static totalToPart(e){return{partSellAmount:e.sellAmount.div(e.n),minPartLimit:e.buyAmount.div(e.n)}}}export{O as ALL_SUPPORTED_CHAIN_IDS,E as BUY_ETH_ADDRESS,Ie as BaseConditionalOrder,M as BuyTokenDestination,A as COMPOSABLE_COW,g as COMPOSABLE_COW_CONTRACT_ADDRESS,Ee as CONDITIONAL_ORDER_PARAMS_ABI,S as COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS,Oe as CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS,m as CowError,C as DEFAULT_BACKOFF_OPTIONS,l as DEFAULT_COW_API_CONTEXT,b as DEFAULT_IPFS_READ_URI,h as DEFAULT_IPFS_WRITE_URI,x as DEFAULT_LIMITER_OPTIONS,u as ENVS_LIST,I as EXTENSIBLE_FALLBACK_HANDLER,v as EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS,G as EcdsaSigningScheme,V as FeeAndQuoteError,ve as MAX_FREQUENCY,Se as MAX_UINT32,Te as Multiplexer,R as ORDER_BOOK_PROD_CONFIG,U as ORDER_BOOK_STAGING_CONFIG,k as OnchainOrderData,F as OrderBookApi,P as OrderBookApiError,B as OrderCancellationError,H as OrderClass,$ as OrderKind,j as OrderPostError,W as OrderQuoteSideKindBuy,q as OrderQuoteSideKindSell,ie as OrderSigningUtils,Y as OrderStatus,J as PriceQuality,he as ProofLocation,K as ReplaceOrderError,ne as SUBGRAPH_PROD_CONFIG,re as SUBGRAPH_STAGING_CONFIG,z as SellTokenSource,Z as SigningScheme,ae as SubgraphApi,y as SupportedChainId,Ne as TWAP,Ae as TWAP_ADDRESS,me as createSetDomainVerifierTx,ye as getDomainVerifier,le as isComposableCow,ue as isExtensibleFallbackHandler,f as logPrefix,D as request};
`,ee="https://api.thegraph.com/subgraphs/name/cowprotocol",te={[c.MAINNET]:ee+"/cow",[c.GNOSIS_CHAIN]:ee+"/cow-gc",[c.GOERLI]:ee+"/cow-goerli"},ne={[c.MAINNET]:ee+"/cow-staging",[c.GNOSIS_CHAIN]:ee+"/cow-gc-staging",[c.GOERLI]:""};class re{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context={...y,...e}}getTotals(e={}){try{return Promise.resolve(this.runQuery(X,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(z,{days:e},t))}catch(e){return Promise.reject(e)}}getLastHoursVolume(e,t={}){try{return Promise.resolve(this.runQuery(Q,{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 l(`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?te:ne}}const ae=()=>import("./utils-c362412e.js");class se{static signOrder(e,t,n){try{return Promise.resolve(ae()).then(function({signOrder:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellation(e,t,n){try{return Promise.resolve(ae()).then(function({signOrderCancellation:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static signOrderCancellations(e,t,n){try{return Promise.resolve(ae()).then(function({signOrderCancellations:r}){return r(e,t,n)})}catch(e){return Promise.reject(e)}}static getDomain(e){try{return Promise.resolve(ae()).then(function({getDomain:t}){return t(e)})}catch(e){return Promise.reject(e)}}static getDomainSeparator(e){try{return Promise.resolve(ae()).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 ie,oe;!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"}(ie||(ie={})),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_DATE",e.DONT_TRY_AGAIN="DONT_TRY_AGAIN"}(oe||(oe={}));const de=[{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(de)}static connect(e,t){return new s(e,de,t)}}pe.abi=de;const ce=[{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 ue{static createInterface(){return new a.Interface(ce)}static connect(e,t){return new s(e,ce,t)}}ue.abi=ce;const ye=function(e,t,n,r){try{const a=ue.connect(S[n],r);return Promise.resolve(a.callStatic.domainVerifiers(e,t))}catch(e){return Promise.reject(e)}},le=["tuple(address handler, bytes32 salt, bytes staticInput)"];function me(e,t){return e===S[t]}function fe(e,t){return e===v[t]}function Te(e,t){return ue.createInterface().encodeFunctionData("setDomainVerifier",[e,t])}function he(e){return a.defaultAbiCoder.encode(le,[e])}function be(e){const{handler:t,salt:n,staticInput:r}=a.defaultAbiCoder.decode(le,e)[0];return{handler:t,salt:n,staticInput:r}}function Ee(e,t){try{a.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}let Ie,Ae;function Oe(){return Ie||(Ie=pe.createInterface()),Ie}function Se(e,t){return Ae||(Ae=pe.connect(v[e],t)),Ae}class ve{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=Oe(),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(),Oe().encodeFunctionData("remove",[this.id])}get id(){return a.keccak256(this.serialize())}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return a.keccak256(he(e))}get offChainInput(){return"0x"}encodeStaticInputHelper(e,t){return a.defaultAbiCoder.encode(e,[t])}poll(e,t,n){try{const r=this,a=Se(t,n);return Promise.resolve(function(s,i){try{var o=function(){const s=r.isValid();return s.isValid?Promise.resolve(r.pollValidate(e,t,n)).then(function(s){return s||Promise.resolve(r.isAuthorized(e,t,n)).then(function(n){return n?Promise.resolve(a.getTradeableOrderWithSignature(e,r.leaf,r.offChainInput,[])).then(function([e,t]){return{result:oe.SUCCESS,order:e,signature:t}}):{result:oe.DONT_TRY_AGAIN,reason:`NotAuthorised: Order ${r.id} is not authorised for ${e} on chain ${t}`}})}):{result:oe.DONT_TRY_AGAIN,reason:`InvalidConditionalOrder. Reason: ${s.reason}`}}()}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(e){return{result:oe.UNEXPECTED_ERROR,error:e}}))}catch(e){return Promise.reject(e)}}isAuthorized(e,t,n){return Se(t,n).callStatic.singleOrders(e,this.id)}static deserializeHelper(e,t,n,r){try{const{handler:s,salt:i,staticInput:o}=be(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 Ne=["address","bytes32","bytes"],Pe=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];class _e{constructor(e,t,n,r=ie.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(!_e.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(!_e.orderTypeRegistry.hasOwnProperty(r))throw new Error(`Unknown order type: ${r}`);e[n]=new(0,_e.orderTypeRegistry[r])(a)}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?o.from(t):t}),s=new _e(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)]),Ne)),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 ie.PRIVATE:return Promise.resolve("0x");case ie.EMITTED:return Promise.resolve(r.encodeToABI(t));case ie.SWARM:case ie.WAKU:case ie.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=Se(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(Pe,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){_e.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){_e.orderTypeRegistry={}}}_e.orderTypeRegistry={};class ge{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 De="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",Ce="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",Re=o.from(2).pow(32).sub(1),xe=o.from(31536e3),we=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"],Ue=(e,t)=>`${e}@${t}`;var Le,Me;!function(e){e.AUTO="AUTO",e.LIMIT_DURATION="LIMIT_DURATION"}(Le||(Le={})),function(e){e.AT_MINING_TIME="AT_MINING_TIME",e.AT_EPOC="AT_EPOC"}(Me||(Me={}));const Fe={startType:Me.AT_MINING_TIME},Ge={durationType:Le.AUTO};class Ve extends ve{constructor(e){const{handler:t,salt:n,data:r,hasOffChainInput:a}=e;if(t!==De)throw new Error(`InvalidHandler: Expected: ${De}, provided: ${t}`);super({handler:De,salt:n,data:r,hasOffChainInput:a})}static fromData(e){return new Ve({handler:De,data:e})}static fromParams(e){return Ve.deserialize(he(e))}get context(){return this.staticInput.t0.gt(0)?super.context:{address:Ce,factoryArgs:void 0}}get orderType(){return"twap"}isValid(){const e=(()=>{const{sellToken:e,sellAmount:t,buyToken:n,buyAmount:r,startTime:a=Fe,numberOfParts:s,timeBetweenParts:i,durationOfPart:o=Ge}=this.data;if(e==n)return"InvalidSameToken";if(e==d.AddressZero||n==d.AddressZero)return"InvalidToken";if(!t.gt(d.Zero))return"InvalidSellAmount";if(!r.gt(d.Zero))return"InvalidMinBuyAmount";if(a.startType===Me.AT_EPOC){const e=a.epoch;if(!e.gte(d.Zero)||!e.lt(Re))return"InvalidStartTime"}return s.gt(d.One)&&s.lte(Re)?i.gt(d.Zero)&&i.lte(xe)?o.durationType!==Le.LIMIT_DURATION||o.duration.lte(i)?Ee(we,[this.staticInput])?void 0:"InvalidData":"InvalidSpan":"InvalidFrequency":"InvalidNumParts"})();return e?{isValid:!1,reason:e}:{isValid:!0}}pollValidate(e,t,n){return Promise.resolve(void 0)}serialize(){return he(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(we,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,De,we,(e,t)=>new Ve({handler:De,salt:t,data:ke(e)}))}toString(e=Ue){const{sellToken:t,buyToken:n,numberOfParts:r,timeBetweenParts:a=Ge,startTime:s=Fe,sellAmount:i,buyAmount:o}=this.data,d=e(t,i),p=e(n,o),c=s.startType===Me.AT_MINING_TIME?"time of mining":"epoch "+s.epoch.toString();return`${this.orderType}: Sell total ${d} for a minimum of ${p} over ${r} parts with a spacing of ${a}s beginning at ${c}`}transformDataToStruct(e){return Be(e)}transformStructToData(e){return ke(e)}}function Be(e){const{sellAmount:t,buyAmount:n,numberOfParts:r,startTime:a=Fe,timeBetweenParts:s,durationOfPart:i=Ge,...o}=e,{partSellAmount:p,minPartLimit:c}=r&&!r.isZero()?{partSellAmount:t.div(r),minPartLimit:n.div(r)}:{partSellAmount:d.Zero,minPartLimit:d.Zero};return{partSellAmount:p,minPartLimit:c,t0:a.startType===Me.AT_MINING_TIME?d.Zero:a.epoch,n:r,t:s,span:i.durationType===Le.AUTO?d.Zero:i.duration,...o}}function ke(e){const{n:t,partSellAmount:n,minPartLimit:r,t:a,t0:s,span:i,...o}=e,d=i.isZero()?{durationType:Le.AUTO}:{durationType:Le.LIMIT_DURATION,duration:i},p=i.isZero()?{startType:Me.AT_MINING_TIME}:{startType:Me.AT_EPOC,epoch:s};return{sellAmount:n.mul(t),buyAmount:r.mul(t),startTime:p,numberOfParts:t,timeBetweenParts:a,durationOfPart:d,...o}}const He={[De]:e=>Ve.fromParams(e)};export{A as ALL_SUPPORTED_CHAIN_IDS,b as BUY_ETH_ADDRESS,M as BuyTokenDestination,I as COMPOSABLE_COW,v as COMPOSABLE_COW_CONTRACT_ADDRESS,le as CONDITIONAL_ORDER_PARAMS_ABI,O as COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS,Ce as CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS,ve as ConditionalOrder,ge as ConditionalOrderFactory,l as CowError,D as DEFAULT_BACKOFF_OPTIONS,He as DEFAULT_CONDITIONAL_ORDER_REGSTRY,y as DEFAULT_COW_API_CONTEXT,f as DEFAULT_IPFS_READ_URI,T as DEFAULT_IPFS_WRITE_URI,C as DEFAULT_LIMITER_OPTIONS,Le as DurationType,u as ENVS_LIST,E as EXTENSIBLE_FALLBACK_HANDLER,S as EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS,F as EcdsaSigningScheme,G as FeeAndQuoteError,xe as MAX_FREQUENCY,Re as MAX_UINT32,_e as Multiplexer,x as ORDER_BOOK_PROD_CONFIG,w as ORDER_BOOK_STAGING_CONFIG,V as OnchainOrderData,L as OrderBookApi,_ as OrderBookApiError,B as OrderCancellationError,k as OrderClass,H as OrderKind,$ as OrderPostError,j as OrderQuoteSideKindBuy,W as OrderQuoteSideKindSell,se as OrderSigningUtils,Y as OrderStatus,oe as PollResultCode,Z as PriceQuality,ie as ProofLocation,K as ReplaceOrderError,te as SUBGRAPH_PROD_CONFIG,ne as SUBGRAPH_STAGING_CONFIG,q as SellTokenSource,J as SigningScheme,Me as StartTimeValue,re as SubgraphApi,c as SupportedChainId,De as TWAP_ADDRESS,Ve as Twap,Te as createSetDomainVerifierTx,be as decodeParams,he as encodeParams,ye as getDomainVerifier,fe as isComposableCow,me as isExtensibleFallbackHandler,Ee as isValidAbi,m as logPrefix,P as request,Be as transformDataToStruct,ke as transformStructToData};
//# sourceMappingURL=index.module.js.map
{
"name": "@cowprotocol/cow-sdk",
"version": "3.0.0-rc.0",
"version": "3.0.0-rc.3",
"license": "(MIT OR Apache-2.0)",

@@ -5,0 +5,0 @@ "files": [

{
"name": "@cowprotocol/cow-sdk",
"version": "3.0.0-rc.0",
"version": "3.0.0-rc.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc