@cowprotocol/cow-sdk 6.0.0-RC.9 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/README.md +3 -1
- package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +87 -63
- package/dist/bridging/BridgingSdk/findBridgeProviderFromHook.d.ts +2 -0
- package/dist/bridging/BridgingSdk/getBridgeSignedHook.d.ts +8 -0
- package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +16 -0
- package/dist/bridging/BridgingSdk/getQuoteWithBridge.d.ts +3 -0
- package/dist/bridging/BridgingSdk/getQuoteWithoutBridge.d.ts +7 -7
- package/dist/bridging/BridgingSdk/mock/bridgeRequestMocks.d.ts +20 -0
- package/dist/bridging/BridgingSdk/types.d.ts +43 -0
- package/dist/bridging/const.d.ts +4 -2
- package/dist/bridging/errors.d.ts +22 -0
- package/dist/bridging/index.d.ts +8 -5
- package/dist/bridging/providers/across/AcrossApi.d.ts +30 -195
- package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +44 -41
- package/dist/bridging/providers/across/abi.d.ts +154 -154
- package/dist/bridging/providers/across/const/contracts.d.ts +3 -3
- package/dist/bridging/providers/across/const/interfaces.d.ts +3 -0
- package/dist/bridging/providers/across/const/misc.d.ts +2 -0
- package/dist/bridging/providers/across/const/tokens.d.ts +11 -11
- package/dist/bridging/providers/across/createAcrossDepositCall.d.ts +9 -9
- package/dist/bridging/providers/across/getDepositParams.d.ts +4 -0
- package/dist/bridging/providers/across/types.d.ts +242 -0
- package/dist/bridging/providers/across/util.d.ts +43 -39
- package/dist/bridging/providers/bungee/BungeeApi.d.ts +67 -0
- package/dist/bridging/providers/bungee/BungeeBridgeProvider.d.ts +44 -0
- package/dist/bridging/providers/bungee/abi.d.ts +203 -0
- package/dist/bridging/providers/bungee/const/contracts.d.ts +4 -0
- package/dist/bridging/providers/bungee/const/misc.d.ts +8 -0
- package/dist/bridging/providers/bungee/createBungeeDepositCall.d.ts +7 -0
- package/dist/bridging/providers/bungee/getBridgingStatusFromEvents.d.ts +3 -0
- package/dist/bridging/providers/bungee/types.d.ts +267 -0
- package/dist/bridging/providers/bungee/util.d.ts +62 -0
- package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +26 -20
- package/dist/bridging/providers/utils/getGasLimitEstimationForHook.d.ts +4 -0
- package/dist/bridging/types.d.ts +323 -251
- package/dist/bridging/utils.d.ts +9 -6
- package/dist/chains/const/index.d.ts +25 -25
- package/dist/chains/const/path.d.ts +1 -1
- package/dist/chains/details/arbitrum.d.ts +7 -7
- package/dist/chains/details/avalanche.d.ts +2 -0
- package/dist/chains/details/base.d.ts +7 -7
- package/dist/chains/details/gnosis.d.ts +7 -7
- package/dist/chains/details/index.d.ts +8 -0
- package/dist/chains/details/mainnet.d.ts +7 -7
- package/dist/chains/details/optimism.d.ts +2 -2
- package/dist/chains/details/polygon.d.ts +2 -2
- package/dist/chains/details/sepolia.d.ts +7 -7
- package/dist/chains/index.d.ts +4 -3
- package/dist/chains/types.d.ts +127 -122
- package/dist/chains/utils.d.ts +18 -18
- package/dist/common/consts/config.d.ts +9 -9
- package/dist/common/consts/contracts.d.ts +43 -34
- package/dist/common/consts/ipfs.d.ts +2 -2
- package/dist/common/consts/order.d.ts +1 -0
- package/dist/common/consts/path.d.ts +1 -1
- package/dist/common/consts/tokens.d.ts +9 -9
- package/dist/common/generated/CoWShed.d.ts +219 -219
- package/dist/common/generated/CoWShedFactory.d.ts +191 -191
- package/dist/common/generated/ComposableCoW.d.ts +340 -340
- package/dist/common/generated/EthFlow.d.ts +117 -117
- package/dist/common/generated/ExtensibleFallbackHandler.d.ts +282 -282
- package/dist/common/generated/GPv2Settlement.d.ts +107 -107
- package/dist/common/generated/TWAP.d.ts +141 -141
- package/dist/common/generated/common.d.ts +21 -21
- package/dist/common/generated/factories/CoWShedFactory__factory.d.ts +250 -250
- package/dist/common/generated/factories/CoWShed__factory.d.ts +254 -254
- package/dist/common/generated/factories/ComposableCoW__factory.d.ts +475 -475
- package/dist/common/generated/factories/EthFlow__factory.d.ts +124 -124
- package/dist/common/generated/factories/ExtensibleFallbackHandler__factory.d.ts +389 -389
- package/dist/common/generated/factories/GPv2Settlement__factory.d.ts +81 -81
- package/dist/common/generated/factories/TWAP__factory.d.ts +260 -260
- package/dist/common/generated/factories/index.d.ts +7 -7
- package/dist/common/generated/index.d.ts +15 -15
- package/dist/common/index.d.ts +12 -10
- package/dist/common/types/config.d.ts +70 -70
- package/dist/common/types/cow-error.d.ts +4 -4
- package/dist/common/types/ethereum.d.ts +5 -5
- package/dist/common/types/tokens.d.ts +12 -12
- package/dist/common/types/wallets.d.ts +5 -5
- package/dist/common/utils/common.d.ts +1 -0
- package/dist/common/utils/config.d.ts +4 -4
- package/dist/common/utils/log.d.ts +2 -0
- package/dist/common/utils/math.d.ts +19 -0
- package/dist/common/utils/order.d.ts +4 -0
- package/dist/common/utils/serialize.d.ts +1 -1
- package/dist/common/utils/wallet.d.ts +3 -3
- package/dist/composable/ConditionalOrder.d.ts +206 -206
- package/dist/composable/ConditionalOrderFactory.d.ts +19 -19
- package/dist/composable/Multiplexer.d.ts +174 -174
- package/dist/composable/contracts.d.ts +6 -6
- package/dist/composable/generated/ComposableCoW.d.ts +340 -340
- package/dist/composable/generated/ExtensibleFallbackHandler.d.ts +282 -282
- package/dist/composable/generated/TWAP.d.ts +141 -141
- package/dist/composable/generated/common.d.ts +21 -21
- package/dist/composable/generated/factories/ComposableCoW__factory.d.ts +475 -475
- package/dist/composable/generated/factories/ExtensibleFallbackHandler__factory.d.ts +389 -389
- package/dist/composable/generated/factories/TWAP__factory.d.ts +260 -260
- package/dist/composable/generated/factories/index.d.ts +3 -3
- package/dist/composable/generated/index.d.ts +7 -7
- package/dist/composable/index.d.ts +6 -6
- package/dist/composable/orderTypes/Twap.d.ts +242 -242
- package/dist/composable/orderTypes/index.d.ts +3 -3
- package/dist/composable/orderTypes/test/TestConditionalOrder.d.ts +25 -25
- package/dist/composable/types.d.ts +133 -133
- package/dist/composable/utils.d.ts +37 -37
- package/dist/cow-shed/CowShedSdk.d.ts +74 -69
- package/dist/cow-shed/contracts/CoWShedHooks.d.ts +47 -45
- package/dist/cow-shed/contracts/utils.d.ts +4 -4
- package/dist/cow-shed/index.d.ts +3 -2
- package/dist/cow-shed/types.d.ts +17 -17
- package/dist/hooks/utils.d.ts +3 -2
- package/dist/index-847d9333.js +29 -0
- package/dist/index-847d9333.js.map +1 -0
- package/dist/index.d.ts +11 -10
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.module.js +4 -4
- package/dist/index.module.js.map +1 -1
- package/dist/order-book/api.d.ts +235 -235
- package/dist/order-book/generated/index.d.ts +55 -55
- package/dist/order-book/generated/models/Address.d.ts +4 -4
- package/dist/order-book/generated/models/AppData.d.ts +7 -7
- package/dist/order-book/generated/models/AppDataHash.d.ts +6 -6
- package/dist/order-book/generated/models/AppDataObject.d.ts +7 -7
- package/dist/order-book/generated/models/Auction.d.ts +30 -30
- package/dist/order-book/generated/models/AuctionOrder.d.ts +92 -92
- package/dist/order-book/generated/models/AuctionPrices.d.ts +6 -6
- package/dist/order-book/generated/models/BigUint.d.ts +4 -4
- package/dist/order-book/generated/models/BuyTokenDestination.d.ts +7 -7
- package/dist/order-book/generated/models/CallData.d.ts +4 -4
- package/dist/order-book/generated/models/CompetitionAuction.d.ts +14 -14
- package/dist/order-book/generated/models/CompetitionOrderStatus.d.ts +29 -29
- package/dist/order-book/generated/models/EcdsaSignature.d.ts +4 -4
- package/dist/order-book/generated/models/EcdsaSigningScheme.d.ts +7 -7
- package/dist/order-book/generated/models/EthflowData.d.ts +20 -20
- package/dist/order-book/generated/models/ExecutedAmounts.d.ts +5 -5
- package/dist/order-book/generated/models/ExecutedProtocolFee.d.ts +8 -8
- package/dist/order-book/generated/models/FeePolicy.d.ts +7 -7
- package/dist/order-book/generated/models/InteractionData.d.ts +11 -11
- package/dist/order-book/generated/models/NativePriceResponse.d.ts +10 -10
- package/dist/order-book/generated/models/OnchainOrderData.d.ts +24 -24
- package/dist/order-book/generated/models/Order.d.ts +3 -3
- package/dist/order-book/generated/models/OrderCancellation.d.ts +14 -14
- package/dist/order-book/generated/models/OrderCancellationError.d.ts +15 -15
- package/dist/order-book/generated/models/OrderCancellations.d.ts +18 -18
- package/dist/order-book/generated/models/OrderClass.d.ts +8 -8
- package/dist/order-book/generated/models/OrderCreation.d.ts +80 -80
- package/dist/order-book/generated/models/OrderKind.d.ts +7 -7
- package/dist/order-book/generated/models/OrderMetaData.d.ts +100 -100
- package/dist/order-book/generated/models/OrderParameters.d.ts +53 -53
- package/dist/order-book/generated/models/OrderPostError.d.ts +35 -35
- package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +58 -58
- package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +27 -27
- package/dist/order-book/generated/models/OrderQuoteSide.d.ts +26 -26
- package/dist/order-book/generated/models/OrderQuoteSideKindBuy.d.ts +3 -3
- package/dist/order-book/generated/models/OrderQuoteSideKindSell.d.ts +3 -3
- package/dist/order-book/generated/models/OrderQuoteValidity.d.ts +14 -14
- package/dist/order-book/generated/models/OrderStatus.d.ts +10 -10
- package/dist/order-book/generated/models/PreSignature.d.ts +4 -4
- package/dist/order-book/generated/models/PriceEstimationError.d.ts +12 -12
- package/dist/order-book/generated/models/PriceImprovement.d.ts +12 -12
- package/dist/order-book/generated/models/PriceQuality.d.ts +16 -16
- package/dist/order-book/generated/models/Quote.d.ts +19 -19
- package/dist/order-book/generated/models/SellTokenSource.d.ts +8 -8
- package/dist/order-book/generated/models/Signature.d.ts +6 -6
- package/dist/order-book/generated/models/SigningScheme.d.ts +9 -9
- package/dist/order-book/generated/models/SolverCompetitionResponse.d.ts +30 -30
- package/dist/order-book/generated/models/SolverSettlement.d.ts +47 -47
- package/dist/order-book/generated/models/Surplus.d.ts +7 -7
- package/dist/order-book/generated/models/TokenAmount.d.ts +4 -4
- package/dist/order-book/generated/models/TotalSurplus.d.ts +10 -10
- package/dist/order-book/generated/models/Trade.d.ts +57 -57
- package/dist/order-book/generated/models/TransactionHash.d.ts +4 -4
- package/dist/order-book/generated/models/UID.d.ts +8 -8
- package/dist/order-book/generated/models/Volume.d.ts +6 -6
- package/dist/order-book/index.d.ts +5 -5
- package/dist/order-book/mock.d.ts +63 -63
- package/dist/order-book/quoteAmountsAndCostsUtils.d.ts +35 -22
- package/dist/order-book/request.d.ts +49 -49
- package/dist/order-book/transformOrder.d.ts +10 -10
- package/dist/order-book/types.d.ts +74 -74
- package/dist/order-signing/index.d.ts +2 -2
- package/dist/order-signing/orderSigningUtils.d.ts +97 -97
- package/dist/order-signing/types.d.ts +55 -55
- package/dist/order-signing/utils.d.ts +49 -49
- package/dist/package.json +31 -32
- package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +151 -12
- package/dist/schemas/trading/LimitTradeParameters.ts +136 -15
- package/dist/schemas/trading/QuoteResultsSerialized.ts +292 -27
- package/dist/schemas/trading/QuoterParameters.ts +10 -0
- package/dist/schemas/trading/SwapAdvancedSettings.ts +331 -12
- package/dist/schemas/trading/TradeParameters.ts +136 -15
- package/dist/src/trading/README.md +99 -7
- package/dist/subgraph/api.d.ts +77 -77
- package/dist/subgraph/graphql.d.ts +3203 -3203
- package/dist/subgraph/index.d.ts +1 -1
- package/dist/subgraph/queries.d.ts +14 -14
- package/dist/test/utils.d.ts +1 -0
- package/dist/trading/appDataUtils.d.ts +5 -4
- package/dist/trading/calculateUniqueOrderId.d.ts +5 -5
- package/dist/trading/consts.d.ts +6 -14
- package/dist/trading/getEthFlowTransaction.d.ts +12 -7
- package/dist/trading/getOrderToSign.d.ts +11 -8
- package/dist/trading/getOrderTypedData.d.ts +4 -4
- package/dist/trading/getPreSignTransaction.d.ts +4 -4
- package/dist/trading/getQuote.d.ts +26 -14
- package/dist/trading/index.d.ts +21 -19
- package/dist/trading/postCoWProtocolTrade.d.ts +4 -4
- package/dist/trading/postLimitOrder.d.ts +3 -3
- package/dist/trading/postSellNativeCurrencyOrder.d.ts +4 -7
- package/dist/trading/postSwapOrder.d.ts +5 -5
- package/dist/trading/suggestSlippageBps.d.ts +13 -0
- package/dist/trading/suggestSlippageFromFee.d.ts +19 -0
- package/dist/trading/suggestSlippageFromVolume.d.ts +10 -0
- package/dist/trading/tradingSdk.d.ts +26 -26
- package/dist/trading/types.d.ts +221 -190
- package/dist/trading/utils/getPartnerFeeBps.d.ts +2 -0
- package/dist/trading/{utils.d.ts → utils/misc.d.ts} +27 -27
- package/dist/trading/utils/slippage.d.ts +16 -0
- package/dist/utils-09dadb80.js +2 -0
- package/dist/utils-09dadb80.js.map +1 -0
- package/dist/utils-0ff3f95e.js +2 -0
- package/dist/utils-0ff3f95e.js.map +1 -0
- package/dist/utils-ddcfac77.js +2 -0
- package/dist/utils-ddcfac77.js.map +1 -0
- package/dist/utils.d.ts +3 -3
- package/dist/weiroll/index.d.ts +23 -23
- package/package.json +31 -32
- package/dist/bridging/BridgingSdk/getErc20Decimals.d.ts +0 -4
- package/dist/bridging/BridgingSdk/getQuoteWithBridging.d.ts +0 -9
- package/dist/index-317c25f1.js +0 -29
- package/dist/index-317c25f1.js.map +0 -1
- package/dist/utils-204a9cbe.js +0 -2
- package/dist/utils-204a9cbe.js.map +0 -1
- package/dist/utils-762ee9c3.js +0 -2
- package/dist/utils-762ee9c3.js.map +0 -1
- package/dist/utils-de2eb543.js +0 -2
- package/dist/utils-de2eb543.js.map +0 -1
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
import { providers } from 'ethers';
|
|
2
|
-
import { SupportedChainId } from '../chains';
|
|
3
|
-
import { ComposableCoW, GPv2Order } from '../common/generated/ComposableCoW';
|
|
4
|
-
import { ProofLocation, ProofWithParams, ConditionalOrderParams } from './types';
|
|
5
|
-
import { ConditionalOrder } from './ConditionalOrder';
|
|
6
|
-
export type Orders = Record<string, ConditionalOrder<unknown, unknown>>;
|
|
7
|
-
/**
|
|
8
|
-
* Multiplexer for conditional orders - using `ComposableCoW`!
|
|
9
|
-
*
|
|
10
|
-
* This class provides functionality to:
|
|
11
|
-
* - Generate a merkle tree of conditional orders
|
|
12
|
-
* - Generate proofs for all orders in the merkle tree
|
|
13
|
-
* - Save proofs, with the ability to omit / skip specific conditional orders
|
|
14
|
-
* - Support for passing an optional upload function to upload the proofs to a decentralized storage network
|
|
15
|
-
*/
|
|
16
|
-
export declare class Multiplexer {
|
|
17
|
-
static orderTypeRegistry: Record<string, new (...args: unknown[]) => ConditionalOrder<unknown, unknown>>;
|
|
18
|
-
chain: SupportedChainId;
|
|
19
|
-
location: ProofLocation;
|
|
20
|
-
private orders;
|
|
21
|
-
private tree?;
|
|
22
|
-
private ctx?;
|
|
23
|
-
/**
|
|
24
|
-
* @param chain The `chainId` for where we're using `ComposableCoW`.
|
|
25
|
-
* @param orders An optional array of conditional orders to initialize the merkle tree with.
|
|
26
|
-
* @param root An optional root to verify against.
|
|
27
|
-
* @param location The location of the proofs for the conditional orders.
|
|
28
|
-
*/
|
|
29
|
-
constructor(chain: SupportedChainId, orders?: Orders, root?: string, location?: ProofLocation);
|
|
30
|
-
/**
|
|
31
|
-
* Given a serialized multiplexer, create the multiplexer and rehydrate all conditional orders.
|
|
32
|
-
* Integrity of the multiplexer will be verified by generating the merkle tree and verifying
|
|
33
|
-
* the root.
|
|
34
|
-
*
|
|
35
|
-
* **NOTE**: Before using this method, you must register all conditional order types using `Multiplexer.registerOrderType`.
|
|
36
|
-
* @param s The serialized multiplexer.
|
|
37
|
-
* @returns The multiplexer with all conditional orders rehydrated.
|
|
38
|
-
* @throws If the multiplexer cannot be deserialized.
|
|
39
|
-
* @throws If the merkle tree cannot be generated.
|
|
40
|
-
* @throws If the merkle tree cannot be verified against the root.
|
|
41
|
-
*/
|
|
42
|
-
static fromJSON(s: string): Multiplexer;
|
|
43
|
-
/**
|
|
44
|
-
* Serialize the multiplexer to JSON.
|
|
45
|
-
*
|
|
46
|
-
* This will include all state necessary to reconstruct the multiplexer, including the root.
|
|
47
|
-
* @remarks This will **NOT** include the merkle tree.
|
|
48
|
-
* @returns The JSON representation of the multiplexer, including the root but excluding the merkle tree.
|
|
49
|
-
*/
|
|
50
|
-
toJSON(): string;
|
|
51
|
-
/**
|
|
52
|
-
* Add a conditional order to the merkle tree.
|
|
53
|
-
* @param order The order to add to the merkle tree.
|
|
54
|
-
*/
|
|
55
|
-
add<T, P>(order: ConditionalOrder<T, P>): void;
|
|
56
|
-
/**
|
|
57
|
-
* Remove a conditional order from the merkle tree.
|
|
58
|
-
* @param id The id of the `ConditionalOrder` to remove from the merkle tree.
|
|
59
|
-
*/
|
|
60
|
-
remove(id: string): void;
|
|
61
|
-
/**
|
|
62
|
-
* Update a given conditional order in the merkle tree.
|
|
63
|
-
* @param id The id of the `ConditionalOrder` to update.
|
|
64
|
-
* @param updater A function that takes the existing `ConditionalOrder` and context, returning an updated `ConditionalOrder`.
|
|
65
|
-
*/
|
|
66
|
-
update(id: string, updater: (order: ConditionalOrder<unknown, unknown>, ctx?: string) => ConditionalOrder<unknown, unknown>): void;
|
|
67
|
-
/**
|
|
68
|
-
* Accessor for a given conditional order in the multiplexer.
|
|
69
|
-
* @param id The `id` of the `ConditionalOrder` to retrieve.
|
|
70
|
-
* @returns A `ConditionalOrder` with the given `id`.
|
|
71
|
-
*/
|
|
72
|
-
getById(id: string): ConditionalOrder<unknown, unknown>;
|
|
73
|
-
/**
|
|
74
|
-
* Accessor for a given conditional order in the multiplexer.
|
|
75
|
-
* @param i The index of the `ConditionalOrder` to retrieve.
|
|
76
|
-
* @returns A `ConditionalOrder` at the given index.
|
|
77
|
-
*/
|
|
78
|
-
getByIndex(i: number): ConditionalOrder<unknown, unknown>;
|
|
79
|
-
/**
|
|
80
|
-
* Get all the conditional order ids in the multiplexer.
|
|
81
|
-
*/
|
|
82
|
-
get orderIds(): string[];
|
|
83
|
-
get root(): string;
|
|
84
|
-
/**
|
|
85
|
-
* Retrieve the merkle tree of orders, or generate it if it doesn't exist.
|
|
86
|
-
*
|
|
87
|
-
* **CAUTION**: Developers of the SDK should prefer to use this method instead of generating the
|
|
88
|
-
* merkle tree themselves. This method makes use of caching to avoid generating the
|
|
89
|
-
* merkle tree needlessly.
|
|
90
|
-
* @throws If the merkle tree cannot be generated.
|
|
91
|
-
* @returns The merkle tree for the current set of conditional orders.
|
|
92
|
-
*/
|
|
93
|
-
private getOrGenerateTree;
|
|
94
|
-
/**
|
|
95
|
-
* The primary method for watch towers to use when deserializing the proofs and parameters for the conditional orders.
|
|
96
|
-
* @param s The serialized proofs with parameters for consumption by watchtowers / indexers.
|
|
97
|
-
* @returns The `ProofWithParams` array.
|
|
98
|
-
* @throws If the `ProofWithParams` array cannot be deserialized.
|
|
99
|
-
*/
|
|
100
|
-
static decodeFromJSON(s: string): ProofWithParams[];
|
|
101
|
-
/**
|
|
102
|
-
* The primary entry point for dapps integrating with `ComposableCoW` to generate the proofs and
|
|
103
|
-
* parameters for the conditional orders.
|
|
104
|
-
*
|
|
105
|
-
* After populating the multiplexer with conditional orders, this method can be used to generate
|
|
106
|
-
* the proofs and parameters for the conditional orders. The returned `ProofStruct` can then be
|
|
107
|
-
* used with `setRoot` or `setRootWithContext` on a `ComposableCoW`-enabled Safe.
|
|
108
|
-
*
|
|
109
|
-
* @param filter {@link getProofs}
|
|
110
|
-
* @parma locFn A function that takes the off-chain encoded input, and returns the `location`
|
|
111
|
-
* for the `ProofStruct`, and the `data` for the `ProofStruct`.
|
|
112
|
-
* @returns The ABI-encoded `ProofStruct` for `setRoot` and `setRootWithContext`.
|
|
113
|
-
*/
|
|
114
|
-
prepareProofStruct(location?: ProofLocation, filter?: (v: string[]) => boolean, uploader?: (offChainEncoded: string) => Promise<string>): Promise<ComposableCoW.ProofStruct>;
|
|
115
|
-
/**
|
|
116
|
-
* Poll a conditional order to see if it is tradeable.
|
|
117
|
-
* @param owner The owner of the conditional order.
|
|
118
|
-
* @param p The proof and parameters.
|
|
119
|
-
* @param chain Which chain to use for the ComposableCoW contract.
|
|
120
|
-
* @param provider An RPC provider for the chain.
|
|
121
|
-
* @param offChainInputFn A function, if provided, that will return the off-chain input for the conditional order.
|
|
122
|
-
* @throws If the conditional order is not tradeable.
|
|
123
|
-
* @returns The tradeable `GPv2Order.Data` struct and the `signature` for the conditional order.
|
|
124
|
-
*/
|
|
125
|
-
static poll(owner: string, p: ProofWithParams, chain: SupportedChainId, provider: providers.Provider, offChainInputFn?: (owner: string, params: ConditionalOrderParams) => Promise<string>): Promise<[GPv2Order.DataStruct, string]>;
|
|
126
|
-
/**
|
|
127
|
-
* The primary entry point for dumping the proofs and parameters for the conditional orders.
|
|
128
|
-
*
|
|
129
|
-
* This is to be used by watchtowers / indexers to store the proofs and parameters for the
|
|
130
|
-
* conditional orders off-chain. The encoding returned by this method may **NOT** contain all
|
|
131
|
-
* proofs and parameters, depending on the `filter` provided, and therefore should not be used
|
|
132
|
-
* to rehydrate the multiplexer from a user's perspective.
|
|
133
|
-
* @param filter {@link getProofs}
|
|
134
|
-
* @returns A JSON-encoded string of the proofs and parameters for the conditional orders.
|
|
135
|
-
*/
|
|
136
|
-
dumpProofs(filter?: (v: string[]) => boolean): string;
|
|
137
|
-
dumpProofsAndParams(filter?: (v: string[]) => boolean): ProofWithParams[];
|
|
138
|
-
/**
|
|
139
|
-
* Get the proofs with parameters for the conditional orders in the merkle tree.
|
|
140
|
-
* @param filter A function that takes a conditional order and returns a boolean indicating
|
|
141
|
-
* whether the order should be included in the proof.
|
|
142
|
-
* @returns An array of proofs and their order's parameters for the conditional orders in the
|
|
143
|
-
* merkle tree.
|
|
144
|
-
*/
|
|
145
|
-
private getProofs;
|
|
146
|
-
/**
|
|
147
|
-
* ABI-encode the proofs and parameters for the conditional orders in the merkle tree.
|
|
148
|
-
* @param filter {@link getProofs}
|
|
149
|
-
* @returns ABI-encoded `data` for the `ProofStruct`.
|
|
150
|
-
*/
|
|
151
|
-
private encodeToABI;
|
|
152
|
-
/**
|
|
153
|
-
* JSON-encode the proofs and parameters for the conditional orders in the merkle tree.
|
|
154
|
-
* @param filter {@link getProofs}
|
|
155
|
-
* @returns The JSON-encoded data for storage off-chain.
|
|
156
|
-
*/
|
|
157
|
-
private encodeToJSON;
|
|
158
|
-
/**
|
|
159
|
-
* A helper to reset the merkle tree.
|
|
160
|
-
*/
|
|
161
|
-
private reset;
|
|
162
|
-
/**
|
|
163
|
-
* Register a conditional order type with the multiplexer.
|
|
164
|
-
*
|
|
165
|
-
* **CAUTION**: This is required for using `Multiplexer.fromJSON` and `Multiplexer.toJSON`.
|
|
166
|
-
* @param orderType The order type to register.
|
|
167
|
-
* @param conditionalOrderClass The class to use for the given order type.
|
|
168
|
-
*/
|
|
169
|
-
static registerOrderType(orderType: string, conditionalOrderClass: new (...args: any[]) => ConditionalOrder<unknown, unknown>): void;
|
|
170
|
-
/**
|
|
171
|
-
* Reset the order type registry.
|
|
172
|
-
*/
|
|
173
|
-
static resetOrderTypeRegistry(): void;
|
|
174
|
-
}
|
|
1
|
+
import { providers } from 'ethers';
|
|
2
|
+
import { SupportedChainId } from '../chains';
|
|
3
|
+
import { ComposableCoW, GPv2Order } from '../common/generated/ComposableCoW';
|
|
4
|
+
import { ProofLocation, ProofWithParams, ConditionalOrderParams } from './types';
|
|
5
|
+
import { ConditionalOrder } from './ConditionalOrder';
|
|
6
|
+
export type Orders = Record<string, ConditionalOrder<unknown, unknown>>;
|
|
7
|
+
/**
|
|
8
|
+
* Multiplexer for conditional orders - using `ComposableCoW`!
|
|
9
|
+
*
|
|
10
|
+
* This class provides functionality to:
|
|
11
|
+
* - Generate a merkle tree of conditional orders
|
|
12
|
+
* - Generate proofs for all orders in the merkle tree
|
|
13
|
+
* - Save proofs, with the ability to omit / skip specific conditional orders
|
|
14
|
+
* - Support for passing an optional upload function to upload the proofs to a decentralized storage network
|
|
15
|
+
*/
|
|
16
|
+
export declare class Multiplexer {
|
|
17
|
+
static orderTypeRegistry: Record<string, new (...args: unknown[]) => ConditionalOrder<unknown, unknown>>;
|
|
18
|
+
chain: SupportedChainId;
|
|
19
|
+
location: ProofLocation;
|
|
20
|
+
private orders;
|
|
21
|
+
private tree?;
|
|
22
|
+
private ctx?;
|
|
23
|
+
/**
|
|
24
|
+
* @param chain The `chainId` for where we're using `ComposableCoW`.
|
|
25
|
+
* @param orders An optional array of conditional orders to initialize the merkle tree with.
|
|
26
|
+
* @param root An optional root to verify against.
|
|
27
|
+
* @param location The location of the proofs for the conditional orders.
|
|
28
|
+
*/
|
|
29
|
+
constructor(chain: SupportedChainId, orders?: Orders, root?: string, location?: ProofLocation);
|
|
30
|
+
/**
|
|
31
|
+
* Given a serialized multiplexer, create the multiplexer and rehydrate all conditional orders.
|
|
32
|
+
* Integrity of the multiplexer will be verified by generating the merkle tree and verifying
|
|
33
|
+
* the root.
|
|
34
|
+
*
|
|
35
|
+
* **NOTE**: Before using this method, you must register all conditional order types using `Multiplexer.registerOrderType`.
|
|
36
|
+
* @param s The serialized multiplexer.
|
|
37
|
+
* @returns The multiplexer with all conditional orders rehydrated.
|
|
38
|
+
* @throws If the multiplexer cannot be deserialized.
|
|
39
|
+
* @throws If the merkle tree cannot be generated.
|
|
40
|
+
* @throws If the merkle tree cannot be verified against the root.
|
|
41
|
+
*/
|
|
42
|
+
static fromJSON(s: string): Multiplexer;
|
|
43
|
+
/**
|
|
44
|
+
* Serialize the multiplexer to JSON.
|
|
45
|
+
*
|
|
46
|
+
* This will include all state necessary to reconstruct the multiplexer, including the root.
|
|
47
|
+
* @remarks This will **NOT** include the merkle tree.
|
|
48
|
+
* @returns The JSON representation of the multiplexer, including the root but excluding the merkle tree.
|
|
49
|
+
*/
|
|
50
|
+
toJSON(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Add a conditional order to the merkle tree.
|
|
53
|
+
* @param order The order to add to the merkle tree.
|
|
54
|
+
*/
|
|
55
|
+
add<T, P>(order: ConditionalOrder<T, P>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Remove a conditional order from the merkle tree.
|
|
58
|
+
* @param id The id of the `ConditionalOrder` to remove from the merkle tree.
|
|
59
|
+
*/
|
|
60
|
+
remove(id: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Update a given conditional order in the merkle tree.
|
|
63
|
+
* @param id The id of the `ConditionalOrder` to update.
|
|
64
|
+
* @param updater A function that takes the existing `ConditionalOrder` and context, returning an updated `ConditionalOrder`.
|
|
65
|
+
*/
|
|
66
|
+
update(id: string, updater: (order: ConditionalOrder<unknown, unknown>, ctx?: string) => ConditionalOrder<unknown, unknown>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Accessor for a given conditional order in the multiplexer.
|
|
69
|
+
* @param id The `id` of the `ConditionalOrder` to retrieve.
|
|
70
|
+
* @returns A `ConditionalOrder` with the given `id`.
|
|
71
|
+
*/
|
|
72
|
+
getById(id: string): ConditionalOrder<unknown, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Accessor for a given conditional order in the multiplexer.
|
|
75
|
+
* @param i The index of the `ConditionalOrder` to retrieve.
|
|
76
|
+
* @returns A `ConditionalOrder` at the given index.
|
|
77
|
+
*/
|
|
78
|
+
getByIndex(i: number): ConditionalOrder<unknown, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Get all the conditional order ids in the multiplexer.
|
|
81
|
+
*/
|
|
82
|
+
get orderIds(): string[];
|
|
83
|
+
get root(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieve the merkle tree of orders, or generate it if it doesn't exist.
|
|
86
|
+
*
|
|
87
|
+
* **CAUTION**: Developers of the SDK should prefer to use this method instead of generating the
|
|
88
|
+
* merkle tree themselves. This method makes use of caching to avoid generating the
|
|
89
|
+
* merkle tree needlessly.
|
|
90
|
+
* @throws If the merkle tree cannot be generated.
|
|
91
|
+
* @returns The merkle tree for the current set of conditional orders.
|
|
92
|
+
*/
|
|
93
|
+
private getOrGenerateTree;
|
|
94
|
+
/**
|
|
95
|
+
* The primary method for watch towers to use when deserializing the proofs and parameters for the conditional orders.
|
|
96
|
+
* @param s The serialized proofs with parameters for consumption by watchtowers / indexers.
|
|
97
|
+
* @returns The `ProofWithParams` array.
|
|
98
|
+
* @throws If the `ProofWithParams` array cannot be deserialized.
|
|
99
|
+
*/
|
|
100
|
+
static decodeFromJSON(s: string): ProofWithParams[];
|
|
101
|
+
/**
|
|
102
|
+
* The primary entry point for dapps integrating with `ComposableCoW` to generate the proofs and
|
|
103
|
+
* parameters for the conditional orders.
|
|
104
|
+
*
|
|
105
|
+
* After populating the multiplexer with conditional orders, this method can be used to generate
|
|
106
|
+
* the proofs and parameters for the conditional orders. The returned `ProofStruct` can then be
|
|
107
|
+
* used with `setRoot` or `setRootWithContext` on a `ComposableCoW`-enabled Safe.
|
|
108
|
+
*
|
|
109
|
+
* @param filter {@link getProofs}
|
|
110
|
+
* @parma locFn A function that takes the off-chain encoded input, and returns the `location`
|
|
111
|
+
* for the `ProofStruct`, and the `data` for the `ProofStruct`.
|
|
112
|
+
* @returns The ABI-encoded `ProofStruct` for `setRoot` and `setRootWithContext`.
|
|
113
|
+
*/
|
|
114
|
+
prepareProofStruct(location?: ProofLocation, filter?: (v: string[]) => boolean, uploader?: (offChainEncoded: string) => Promise<string>): Promise<ComposableCoW.ProofStruct>;
|
|
115
|
+
/**
|
|
116
|
+
* Poll a conditional order to see if it is tradeable.
|
|
117
|
+
* @param owner The owner of the conditional order.
|
|
118
|
+
* @param p The proof and parameters.
|
|
119
|
+
* @param chain Which chain to use for the ComposableCoW contract.
|
|
120
|
+
* @param provider An RPC provider for the chain.
|
|
121
|
+
* @param offChainInputFn A function, if provided, that will return the off-chain input for the conditional order.
|
|
122
|
+
* @throws If the conditional order is not tradeable.
|
|
123
|
+
* @returns The tradeable `GPv2Order.Data` struct and the `signature` for the conditional order.
|
|
124
|
+
*/
|
|
125
|
+
static poll(owner: string, p: ProofWithParams, chain: SupportedChainId, provider: providers.Provider, offChainInputFn?: (owner: string, params: ConditionalOrderParams) => Promise<string>): Promise<[GPv2Order.DataStruct, string]>;
|
|
126
|
+
/**
|
|
127
|
+
* The primary entry point for dumping the proofs and parameters for the conditional orders.
|
|
128
|
+
*
|
|
129
|
+
* This is to be used by watchtowers / indexers to store the proofs and parameters for the
|
|
130
|
+
* conditional orders off-chain. The encoding returned by this method may **NOT** contain all
|
|
131
|
+
* proofs and parameters, depending on the `filter` provided, and therefore should not be used
|
|
132
|
+
* to rehydrate the multiplexer from a user's perspective.
|
|
133
|
+
* @param filter {@link getProofs}
|
|
134
|
+
* @returns A JSON-encoded string of the proofs and parameters for the conditional orders.
|
|
135
|
+
*/
|
|
136
|
+
dumpProofs(filter?: (v: string[]) => boolean): string;
|
|
137
|
+
dumpProofsAndParams(filter?: (v: string[]) => boolean): ProofWithParams[];
|
|
138
|
+
/**
|
|
139
|
+
* Get the proofs with parameters for the conditional orders in the merkle tree.
|
|
140
|
+
* @param filter A function that takes a conditional order and returns a boolean indicating
|
|
141
|
+
* whether the order should be included in the proof.
|
|
142
|
+
* @returns An array of proofs and their order's parameters for the conditional orders in the
|
|
143
|
+
* merkle tree.
|
|
144
|
+
*/
|
|
145
|
+
private getProofs;
|
|
146
|
+
/**
|
|
147
|
+
* ABI-encode the proofs and parameters for the conditional orders in the merkle tree.
|
|
148
|
+
* @param filter {@link getProofs}
|
|
149
|
+
* @returns ABI-encoded `data` for the `ProofStruct`.
|
|
150
|
+
*/
|
|
151
|
+
private encodeToABI;
|
|
152
|
+
/**
|
|
153
|
+
* JSON-encode the proofs and parameters for the conditional orders in the merkle tree.
|
|
154
|
+
* @param filter {@link getProofs}
|
|
155
|
+
* @returns The JSON-encoded data for storage off-chain.
|
|
156
|
+
*/
|
|
157
|
+
private encodeToJSON;
|
|
158
|
+
/**
|
|
159
|
+
* A helper to reset the merkle tree.
|
|
160
|
+
*/
|
|
161
|
+
private reset;
|
|
162
|
+
/**
|
|
163
|
+
* Register a conditional order type with the multiplexer.
|
|
164
|
+
*
|
|
165
|
+
* **CAUTION**: This is required for using `Multiplexer.fromJSON` and `Multiplexer.toJSON`.
|
|
166
|
+
* @param orderType The order type to register.
|
|
167
|
+
* @param conditionalOrderClass The class to use for the given order type.
|
|
168
|
+
*/
|
|
169
|
+
static registerOrderType(orderType: string, conditionalOrderClass: new (...args: any[]) => ConditionalOrder<unknown, unknown>): void;
|
|
170
|
+
/**
|
|
171
|
+
* Reset the order type registry.
|
|
172
|
+
*/
|
|
173
|
+
static resetOrderTypeRegistry(): void;
|
|
174
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { providers } from 'ethers';
|
|
2
|
-
import { SupportedChainId } from '../chains';
|
|
3
|
-
import { ComposableCoW } from '../common/generated';
|
|
4
|
-
import { ComposableCoWInterface } from '../common/generated/ComposableCoW';
|
|
5
|
-
export declare function getComposableCowInterface(): ComposableCoWInterface;
|
|
6
|
-
export declare function getComposableCow(chain: SupportedChainId, provider: providers.Provider): ComposableCoW;
|
|
1
|
+
import { providers } from 'ethers';
|
|
2
|
+
import { SupportedChainId } from '../chains';
|
|
3
|
+
import { ComposableCoW } from '../common/generated';
|
|
4
|
+
import { ComposableCoWInterface } from '../common/generated/ComposableCoW';
|
|
5
|
+
export declare function getComposableCowInterface(): ComposableCoWInterface;
|
|
6
|
+
export declare function getComposableCow(chain: SupportedChainId, provider: providers.Provider): ComposableCoW;
|