@cowprotocol/sdk-order-book 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +557 -68
- package/dist/index.d.ts +557 -68
- package/dist/index.js +33 -5
- package/dist/index.mjs +31 -5
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ import { RateLimiterOpts, RateLimiter } from 'limiter';
|
|
|
7
7
|
*/
|
|
8
8
|
type Address = string;
|
|
9
9
|
|
|
10
|
+
type AccessListItem = {
|
|
11
|
+
address: Address;
|
|
12
|
+
storage_keys: Array<string>;
|
|
13
|
+
};
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* The string encoding of a JSON object representing some `appData`. The
|
|
12
17
|
* format of the JSON expected in the `appData` field is defined
|
|
@@ -43,7 +48,7 @@ declare enum BuyTokenDestination {
|
|
|
43
48
|
type TokenAmount = string;
|
|
44
49
|
|
|
45
50
|
/**
|
|
46
|
-
* A calculated order quote.
|
|
51
|
+
* A calculated order quote used in solver auctions.
|
|
47
52
|
*
|
|
48
53
|
*/
|
|
49
54
|
type Quote = {
|
|
@@ -90,21 +95,40 @@ type Volume = {
|
|
|
90
95
|
|
|
91
96
|
/**
|
|
92
97
|
* Defines the ways to calculate the protocol fee.
|
|
98
|
+
*
|
|
93
99
|
*/
|
|
94
|
-
type FeePolicy = (
|
|
100
|
+
type FeePolicy = ({
|
|
101
|
+
surplus: Surplus;
|
|
102
|
+
} | {
|
|
103
|
+
volume: Volume;
|
|
104
|
+
} | {
|
|
105
|
+
priceImprovement: PriceImprovement;
|
|
106
|
+
});
|
|
95
107
|
|
|
96
108
|
/**
|
|
97
109
|
* Some `calldata` sent to a contract in a transaction encoded as a hex with `0x` prefix.
|
|
98
110
|
*/
|
|
99
111
|
type CallData = string;
|
|
100
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Represents a smart contract interaction that can be executed as part of an order's pre or post hooks.
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
101
117
|
type InteractionData = {
|
|
102
|
-
target?: Address;
|
|
103
|
-
value?: TokenAmount;
|
|
104
118
|
/**
|
|
105
|
-
* The
|
|
119
|
+
* The address of the contract to call.
|
|
120
|
+
*/
|
|
121
|
+
target: Address;
|
|
122
|
+
/**
|
|
123
|
+
* The amount of native token (ETH, xDAI, etc.) in Wei to send with the interaction call.
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
value: TokenAmount;
|
|
127
|
+
/**
|
|
128
|
+
* The calldata to be sent to the target contract. Encoded as a hex string with `0x` prefix.
|
|
129
|
+
*
|
|
106
130
|
*/
|
|
107
|
-
|
|
131
|
+
callData: CallData;
|
|
108
132
|
};
|
|
109
133
|
|
|
110
134
|
/**
|
|
@@ -324,79 +348,116 @@ declare namespace CompetitionOrderStatus {
|
|
|
324
348
|
}
|
|
325
349
|
}
|
|
326
350
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
EIP712 = "eip712",
|
|
332
|
-
ETHSIGN = "ethsign"
|
|
333
|
-
}
|
|
351
|
+
type DebugProtocolFee = {
|
|
352
|
+
token: Address;
|
|
353
|
+
amount: TokenAmount;
|
|
354
|
+
};
|
|
334
355
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
356
|
+
type DebugExecution = {
|
|
357
|
+
executedFee: TokenAmount;
|
|
358
|
+
executedFeeToken: Address;
|
|
359
|
+
blockNumber: number;
|
|
360
|
+
protocolFees: Array<DebugProtocolFee>;
|
|
361
|
+
};
|
|
339
362
|
|
|
340
363
|
/**
|
|
341
|
-
*
|
|
364
|
+
* Fee policy applied to this order in this auction.
|
|
342
365
|
*/
|
|
343
|
-
type
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Describes the `validTo` of an order ethflow order.
|
|
352
|
-
*
|
|
353
|
-
* **NOTE**: For ethflow orders, the `validTo` encoded in the smart
|
|
354
|
-
* contract is `type(uint256).max`.
|
|
355
|
-
*
|
|
356
|
-
*/
|
|
357
|
-
userValidTo: number;
|
|
366
|
+
type DebugFeePolicy = {
|
|
367
|
+
kind: DebugFeePolicy.kind;
|
|
368
|
+
surplusFactor?: number;
|
|
369
|
+
surplusMaxVolumeFactor?: number;
|
|
370
|
+
volumeFactor?: number;
|
|
371
|
+
priceImprovementFactor?: number;
|
|
372
|
+
priceImprovementMaxVolumeFactor?: number;
|
|
358
373
|
};
|
|
374
|
+
declare namespace DebugFeePolicy {
|
|
375
|
+
enum kind {
|
|
376
|
+
SURPLUS = "surplus",
|
|
377
|
+
VOLUME = "volume",
|
|
378
|
+
PRICE_IMPROVEMENT = "priceImprovement"
|
|
379
|
+
}
|
|
380
|
+
}
|
|
359
381
|
|
|
360
|
-
type
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
382
|
+
type DebugProposedSolution = {
|
|
383
|
+
solutionUid: number;
|
|
384
|
+
ranking: number;
|
|
385
|
+
solver: Address;
|
|
386
|
+
isWinner: boolean;
|
|
387
|
+
filteredOut: boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Decimal-encoded score.
|
|
390
|
+
*/
|
|
391
|
+
score: string;
|
|
392
|
+
executedSell: TokenAmount;
|
|
393
|
+
executedBuy: TokenAmount;
|
|
364
394
|
};
|
|
365
395
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
396
|
+
type DebugSettlementAttempt = {
|
|
397
|
+
solver: Address;
|
|
398
|
+
solutionUid: number;
|
|
399
|
+
startTimestamp: string;
|
|
400
|
+
endTimestamp?: string;
|
|
401
|
+
startBlock: number;
|
|
402
|
+
endBlock?: number;
|
|
403
|
+
deadlineBlock: number;
|
|
371
404
|
/**
|
|
372
|
-
*
|
|
405
|
+
* Settlement outcome (e.g. "success", "revert").
|
|
373
406
|
*/
|
|
374
|
-
|
|
407
|
+
outcome?: string;
|
|
375
408
|
};
|
|
376
409
|
|
|
377
|
-
type
|
|
410
|
+
type DebugAuction = {
|
|
378
411
|
/**
|
|
379
|
-
*
|
|
380
|
-
*
|
|
412
|
+
* Auction ID.
|
|
381
413
|
*/
|
|
382
|
-
|
|
414
|
+
id: number;
|
|
383
415
|
/**
|
|
384
|
-
*
|
|
416
|
+
* Block number of the auction.
|
|
417
|
+
*/
|
|
418
|
+
block: number;
|
|
419
|
+
/**
|
|
420
|
+
* Deadline block for the auction.
|
|
421
|
+
*/
|
|
422
|
+
deadline: number;
|
|
423
|
+
/**
|
|
424
|
+
* Native prices for the order's sell and buy tokens in this auction. Keys are hex-encoded token addresses, values are decimal price strings.
|
|
385
425
|
*
|
|
386
426
|
*/
|
|
387
|
-
|
|
427
|
+
nativePrices: Record<string, string>;
|
|
428
|
+
proposedSolutions: Array<DebugProposedSolution>;
|
|
429
|
+
executions: Array<DebugExecution>;
|
|
430
|
+
settlementAttempts: Array<DebugSettlementAttempt>;
|
|
431
|
+
feePolicies: Array<DebugFeePolicy>;
|
|
388
432
|
};
|
|
389
|
-
|
|
433
|
+
|
|
434
|
+
type DebugEvent = {
|
|
390
435
|
/**
|
|
391
|
-
*
|
|
436
|
+
* Event type (e.g. created, ready, filtered, traded).
|
|
437
|
+
*/
|
|
438
|
+
label: string;
|
|
439
|
+
timestamp: string;
|
|
440
|
+
/**
|
|
441
|
+
* Why the order was filtered or marked invalid. Only present for "filtered" and "invalid" events.
|
|
392
442
|
*
|
|
393
443
|
*/
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
444
|
+
reason?: string | null;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* 32 byte digest encoded as a hex with `0x` prefix.
|
|
449
|
+
*/
|
|
450
|
+
type TransactionHash = string;
|
|
451
|
+
|
|
452
|
+
type DebugTrade = {
|
|
453
|
+
blockNumber: number;
|
|
454
|
+
logIndex: number;
|
|
455
|
+
buyAmount: TokenAmount;
|
|
456
|
+
sellAmount: TokenAmount;
|
|
457
|
+
sellAmountBeforeFees: TokenAmount;
|
|
458
|
+
txHash?: TransactionHash;
|
|
459
|
+
auctionId?: number;
|
|
460
|
+
};
|
|
400
461
|
|
|
401
462
|
/**
|
|
402
463
|
* How was the order signed?
|
|
@@ -478,7 +539,56 @@ type OrderCreation = {
|
|
|
478
539
|
*
|
|
479
540
|
*/
|
|
480
541
|
appDataHash?: AppDataHash | null;
|
|
542
|
+
/**
|
|
543
|
+
* If set to true, full sell amount will be checked during allowance and balance checking. This will ensure the account has correct allowance and available balance for the order to be created.
|
|
544
|
+
*
|
|
545
|
+
*/
|
|
546
|
+
fullBalanceCheck?: boolean;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Provides the additional data for ethflow orders.
|
|
551
|
+
*/
|
|
552
|
+
type EthflowData = {
|
|
553
|
+
/**
|
|
554
|
+
* Specifies in which transaction the order was refunded. If
|
|
555
|
+
* this field is null the order was not yet refunded.
|
|
556
|
+
*
|
|
557
|
+
*/
|
|
558
|
+
refundTxHash: TransactionHash | null;
|
|
559
|
+
/**
|
|
560
|
+
* Describes the `validTo` of an order ethflow order.
|
|
561
|
+
*
|
|
562
|
+
* **NOTE**: For ethflow orders, the `validTo` encoded in the smart
|
|
563
|
+
* contract is `type(uint256).max`.
|
|
564
|
+
*
|
|
565
|
+
*/
|
|
566
|
+
userValidTo: number;
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
type OnchainOrderData = {
|
|
570
|
+
/**
|
|
571
|
+
* If orders are placed as on-chain orders, the owner of the order might be a smart contract, but not the user placing the order. The actual user will be provided in this field.
|
|
572
|
+
*
|
|
573
|
+
*/
|
|
574
|
+
sender: Address;
|
|
575
|
+
/**
|
|
576
|
+
* Describes the error, if the order placement was not successful. This could happen, for example, if the `validTo` is too high, or no valid quote was found or generated.
|
|
577
|
+
*
|
|
578
|
+
*/
|
|
579
|
+
placementError?: OnchainOrderData.placementError;
|
|
481
580
|
};
|
|
581
|
+
declare namespace OnchainOrderData {
|
|
582
|
+
/**
|
|
583
|
+
* Describes the error, if the order placement was not successful. This could happen, for example, if the `validTo` is too high, or no valid quote was found or generated.
|
|
584
|
+
*
|
|
585
|
+
*/
|
|
586
|
+
enum placementError {
|
|
587
|
+
QUOTE_NOT_FOUND = "QuoteNotFound",
|
|
588
|
+
VALID_TO_TOO_FAR_IN_FUTURE = "ValidToTooFarInFuture",
|
|
589
|
+
PRE_VALIDATION_ERROR = "PreValidationError"
|
|
590
|
+
}
|
|
591
|
+
}
|
|
482
592
|
|
|
483
593
|
/**
|
|
484
594
|
* The current order status.
|
|
@@ -491,6 +601,83 @@ declare enum OrderStatus {
|
|
|
491
601
|
EXPIRED = "expired"
|
|
492
602
|
}
|
|
493
603
|
|
|
604
|
+
/**
|
|
605
|
+
* Quote data stored with an order. This represents the original quote used to
|
|
606
|
+
* create the order, containing gas estimation and pricing information captured
|
|
607
|
+
* at the time of quoting.
|
|
608
|
+
*
|
|
609
|
+
* Note: This is different from `OrderQuoteResponse` which is returned by the
|
|
610
|
+
* `POST /api/v1/quote` endpoint and contains order parameters to sign.
|
|
611
|
+
*
|
|
612
|
+
*/
|
|
613
|
+
type StoredOrderQuote = {
|
|
614
|
+
/**
|
|
615
|
+
* The estimated gas units required to execute the quoted trade.
|
|
616
|
+
* Measured in gas units (not Wei). Used together with `gasPrice` and
|
|
617
|
+
* `sellTokenPrice` to calculate the network fee in sell token atoms.
|
|
618
|
+
*
|
|
619
|
+
*/
|
|
620
|
+
gasAmount: string;
|
|
621
|
+
/**
|
|
622
|
+
* The estimated gas price at the time of quoting, measured in Wei per gas unit.
|
|
623
|
+
* The network fee in Wei can be calculated as: `feeInWei = gasAmount * gasPrice`.
|
|
624
|
+
*
|
|
625
|
+
*/
|
|
626
|
+
gasPrice: string;
|
|
627
|
+
/**
|
|
628
|
+
* The price of the sell token expressed in native token atoms per sell token atom.
|
|
629
|
+
*
|
|
630
|
+
* Units: `native token atoms / sell token atoms`
|
|
631
|
+
*
|
|
632
|
+
* **Example calculation (Mainnet, selling USDC):**
|
|
633
|
+
* - Sell token: USDC (6 decimals)
|
|
634
|
+
* - Native token: ETH (18 decimals)
|
|
635
|
+
* - Market price: 1 ETH = 1000 USDC
|
|
636
|
+
*
|
|
637
|
+
* `sellTokenPrice = 1 × 10^18 wei / (1000 × 10^6 USDC atoms) = 10^9`
|
|
638
|
+
*
|
|
639
|
+
* This value is used to convert network fees (in native token) to sell token amounts.
|
|
640
|
+
*
|
|
641
|
+
*/
|
|
642
|
+
sellTokenPrice: string;
|
|
643
|
+
/**
|
|
644
|
+
* The quoted sell amount in atoms of the sell token.
|
|
645
|
+
*/
|
|
646
|
+
sellAmount: TokenAmount;
|
|
647
|
+
/**
|
|
648
|
+
* The quoted buy amount in atoms of the buy token.
|
|
649
|
+
*/
|
|
650
|
+
buyAmount: TokenAmount;
|
|
651
|
+
/**
|
|
652
|
+
* The fee amount in atoms of the sell token, calculated from the gas parameters
|
|
653
|
+
* at the time of quoting.
|
|
654
|
+
*
|
|
655
|
+
* Computed as: `ceil((gasAmount * gasPrice) / sellTokenPrice)`.
|
|
656
|
+
*
|
|
657
|
+
* This represents the network fee that was estimated when the quote was created.
|
|
658
|
+
*
|
|
659
|
+
*/
|
|
660
|
+
feeAmount: TokenAmount;
|
|
661
|
+
/**
|
|
662
|
+
* The address of the solver that provided this quote.
|
|
663
|
+
*/
|
|
664
|
+
solver: Address;
|
|
665
|
+
/**
|
|
666
|
+
* Whether the quote was verified through simulation. A verified quote
|
|
667
|
+
* provides higher confidence that the trade will execute successfully.
|
|
668
|
+
*
|
|
669
|
+
*/
|
|
670
|
+
verified: boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Additional metadata about the quote execution plan (e.g., the route taken).
|
|
673
|
+
* This field is only populated for orders that are no longer fillable
|
|
674
|
+
* (filled, cancelled, or expired) to prevent solvers from copying
|
|
675
|
+
* execution strategies for active orders.
|
|
676
|
+
*
|
|
677
|
+
*/
|
|
678
|
+
metadata?: Record<string, any>;
|
|
679
|
+
};
|
|
680
|
+
|
|
494
681
|
/**
|
|
495
682
|
* Extra order data that is returned to users when querying orders but not provided by users when creating orders.
|
|
496
683
|
*
|
|
@@ -500,8 +687,20 @@ type OrderMetaData = {
|
|
|
500
687
|
* Creation time of the order. Encoded as ISO 8601 UTC.
|
|
501
688
|
*/
|
|
502
689
|
creationDate: string;
|
|
690
|
+
/**
|
|
691
|
+
* The class of the order (market, limit, or liquidity). Determines how fees are handled.
|
|
692
|
+
*
|
|
693
|
+
*/
|
|
503
694
|
class: OrderClass;
|
|
695
|
+
/**
|
|
696
|
+
* The address that signed the order and owns it. For regular orders, this is the trader. For EIP 1271 orders, it's the respective contract (see `onchainUser` for the actual trader).
|
|
697
|
+
*
|
|
698
|
+
*/
|
|
504
699
|
owner: Address;
|
|
700
|
+
/**
|
|
701
|
+
* Unique identifier of the order. Computed as the EIP-712 hash of the order data combined with the owner address and valid_to timestamp.
|
|
702
|
+
*
|
|
703
|
+
*/
|
|
505
704
|
uid: UID;
|
|
506
705
|
/**
|
|
507
706
|
* Unused field that is currently always set to `null` and will be removed in the future.
|
|
@@ -549,6 +748,10 @@ type OrderMetaData = {
|
|
|
549
748
|
* traded otherwise and should not expect to get surplus.
|
|
550
749
|
*/
|
|
551
750
|
isLiquidityOrder?: boolean;
|
|
751
|
+
/**
|
|
752
|
+
* Additional data specific to ethflow orders. Only present for orders placed through the EthFlow contract, which allows trading native ETH directly without wrapping to WETH first.
|
|
753
|
+
*
|
|
754
|
+
*/
|
|
552
755
|
ethflowData?: EthflowData;
|
|
553
756
|
/**
|
|
554
757
|
* This represents the actual trader of an on-chain order.
|
|
@@ -576,9 +779,80 @@ type OrderMetaData = {
|
|
|
576
779
|
*
|
|
577
780
|
*/
|
|
578
781
|
fullAppData?: string | null;
|
|
782
|
+
/**
|
|
783
|
+
* The address of the CoW Protocol settlement contract that this order is valid for. Orders are only valid on the settlement contract they were signed for.
|
|
784
|
+
*
|
|
785
|
+
*/
|
|
786
|
+
settlementContract: Address;
|
|
787
|
+
/**
|
|
788
|
+
* If the order was created with a quote, this field contains the original quote data for reference. Includes gas estimation and pricing information captured at the time of quoting, which can be used to analyze order execution and calculate fees.
|
|
789
|
+
*
|
|
790
|
+
*/
|
|
791
|
+
quote?: StoredOrderQuote | null;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* An order as returned by the API. Combines the order creation data, order metadata, and any associated interactions.
|
|
796
|
+
*
|
|
797
|
+
*/
|
|
798
|
+
type Order = (OrderCreation & OrderMetaData & {
|
|
799
|
+
/**
|
|
800
|
+
* Optional pre and post interactions associated with the order. Pre-interactions are executed before the order's trade, and post-interactions are executed after.
|
|
801
|
+
*
|
|
802
|
+
*/
|
|
803
|
+
interactions?: {
|
|
804
|
+
/**
|
|
805
|
+
* Interactions to be executed before the order's trade. These can be used for setup operations like token approvals.
|
|
806
|
+
*
|
|
807
|
+
*/
|
|
808
|
+
pre?: Array<InteractionData>;
|
|
809
|
+
/**
|
|
810
|
+
* Interactions to be executed after the order's trade. These can be used for cleanup or follow-up operations.
|
|
811
|
+
*
|
|
812
|
+
*/
|
|
813
|
+
post?: Array<InteractionData>;
|
|
814
|
+
};
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
type DebugOrderResponse = {
|
|
818
|
+
/**
|
|
819
|
+
* The UID of the order being debugged.
|
|
820
|
+
*/
|
|
821
|
+
orderUid: UID;
|
|
822
|
+
order: Order;
|
|
823
|
+
events: Array<DebugEvent>;
|
|
824
|
+
/**
|
|
825
|
+
* Auctions this order participated in, sorted by ID. Each auction groups all related data: native prices, proposed solutions, executions, settlement attempts, and fee policies.
|
|
826
|
+
*
|
|
827
|
+
*/
|
|
828
|
+
auctions: Array<DebugAuction>;
|
|
829
|
+
trades: Array<DebugTrade>;
|
|
579
830
|
};
|
|
580
831
|
|
|
581
|
-
|
|
832
|
+
/**
|
|
833
|
+
* How was the order signed?
|
|
834
|
+
*/
|
|
835
|
+
declare enum EcdsaSigningScheme {
|
|
836
|
+
EIP712 = "eip712",
|
|
837
|
+
ETHSIGN = "ethsign"
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
type ExecutedProtocolFee = {
|
|
841
|
+
policy?: FeePolicy;
|
|
842
|
+
amount?: TokenAmount;
|
|
843
|
+
token?: Address;
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* The estimated native price for the token
|
|
848
|
+
*
|
|
849
|
+
*/
|
|
850
|
+
type NativePriceResponse = {
|
|
851
|
+
/**
|
|
852
|
+
* Estimated price of the token.
|
|
853
|
+
*/
|
|
854
|
+
price?: number;
|
|
855
|
+
};
|
|
582
856
|
|
|
583
857
|
/**
|
|
584
858
|
* [EIP-712](https://eips.ethereum.org/EIPS/eip-712) signature of struct
|
|
@@ -615,7 +889,7 @@ declare namespace OrderCancellationError {
|
|
|
615
889
|
*/
|
|
616
890
|
type OrderCancellations = {
|
|
617
891
|
/**
|
|
618
|
-
* UIDs of orders to cancel.
|
|
892
|
+
* Up to 128 UIDs of orders to cancel.
|
|
619
893
|
*/
|
|
620
894
|
orderUids?: Array<UID>;
|
|
621
895
|
/**
|
|
@@ -654,11 +928,42 @@ type OrderParameters = {
|
|
|
654
928
|
* Unix timestamp (`uint32`) until which the order is valid.
|
|
655
929
|
*/
|
|
656
930
|
validTo: number;
|
|
657
|
-
appData: AppDataHash;
|
|
658
931
|
/**
|
|
659
|
-
*
|
|
932
|
+
* The app data associated with the order. In quote responses, this can be either the full app data JSON string or the app data hash, depending on what was provided in the quote request.
|
|
933
|
+
*
|
|
934
|
+
*/
|
|
935
|
+
appData: (AppData | AppDataHash);
|
|
936
|
+
/**
|
|
937
|
+
* The hash of the app data. Only present when the full app data is also provided in the `appData` field.
|
|
938
|
+
*
|
|
939
|
+
*/
|
|
940
|
+
appDataHash?: AppDataHash;
|
|
941
|
+
/**
|
|
942
|
+
* The fee amount in sell token atoms. For quote responses, this represents
|
|
943
|
+
* the estimated network fee, calculated as:
|
|
944
|
+
* `feeAmount = ceil((gasAmount * gasPrice) / sellTokenPrice)`.
|
|
945
|
+
*
|
|
946
|
+
* When creating an order, this should be set to zero as fees are now
|
|
947
|
+
* computed dynamically by solvers.
|
|
948
|
+
*
|
|
660
949
|
*/
|
|
661
950
|
feeAmount: TokenAmount;
|
|
951
|
+
/**
|
|
952
|
+
* The estimated gas units required to execute the quoted trade.
|
|
953
|
+
*
|
|
954
|
+
*/
|
|
955
|
+
gasAmount: string;
|
|
956
|
+
/**
|
|
957
|
+
* The estimated gas price at the time of quoting, measured in Wei per gas unit.
|
|
958
|
+
*
|
|
959
|
+
*/
|
|
960
|
+
gasPrice: string;
|
|
961
|
+
/**
|
|
962
|
+
* Represents how much one atomic unit of the sell token is worth
|
|
963
|
+
* in the network's native token (in Wei or the equivalent atom).
|
|
964
|
+
*
|
|
965
|
+
*/
|
|
966
|
+
sellTokenPrice: string;
|
|
662
967
|
/**
|
|
663
968
|
* The kind is either a buy or sell order.
|
|
664
969
|
*/
|
|
@@ -667,8 +972,20 @@ type OrderParameters = {
|
|
|
667
972
|
* Is the order fill-or-kill or partially fillable?
|
|
668
973
|
*/
|
|
669
974
|
partiallyFillable: boolean;
|
|
975
|
+
/**
|
|
976
|
+
* Where the sell token should be drawn from. Defaults to `erc20` for standard ERC-20 token transfers.
|
|
977
|
+
*
|
|
978
|
+
*/
|
|
670
979
|
sellTokenBalance?: SellTokenSource;
|
|
980
|
+
/**
|
|
981
|
+
* Where the buy token should be transferred to. Defaults to `erc20` for standard ERC-20 token transfers.
|
|
982
|
+
*
|
|
983
|
+
*/
|
|
671
984
|
buyTokenBalance?: BuyTokenDestination;
|
|
985
|
+
/**
|
|
986
|
+
* The signing scheme to use for the order. Defaults to `eip712` for standard typed data signing.
|
|
987
|
+
*
|
|
988
|
+
*/
|
|
672
989
|
signingScheme?: SigningScheme;
|
|
673
990
|
};
|
|
674
991
|
|
|
@@ -704,7 +1021,9 @@ declare namespace OrderPostError {
|
|
|
704
1021
|
UNSUPPORTED_TOKEN = "UnsupportedToken",
|
|
705
1022
|
INVALID_APP_DATA = "InvalidAppData",
|
|
706
1023
|
APP_DATA_HASH_MISMATCH = "AppDataHashMismatch",
|
|
1024
|
+
APP_DATA_MISMATCH = "AppDataMismatch",
|
|
707
1025
|
APPDATA_FROM_MISMATCH = "AppdataFromMismatch",
|
|
1026
|
+
METADATA_SERIALIZATION_FAILED = "MetadataSerializationFailed",
|
|
708
1027
|
OLD_ORDER_ACTIVELY_BID_ON = "OldOrderActivelyBidOn"
|
|
709
1028
|
}
|
|
710
1029
|
}
|
|
@@ -822,7 +1141,7 @@ type OrderQuoteRequest = (OrderQuoteSide & OrderQuoteValidity & {
|
|
|
822
1141
|
*/
|
|
823
1142
|
onchainOrder?: any;
|
|
824
1143
|
/**
|
|
825
|
-
* User provided timeout in milliseconds.
|
|
1144
|
+
* User provided timeout in milliseconds. If no value is provided the systems default quote timeout will be used. Values get capped at a generous maximum timeout. Note that reducing the timeout can result in worse quotes because it might be too short for some price estimators.
|
|
826
1145
|
*
|
|
827
1146
|
*/
|
|
828
1147
|
timeout?: number;
|
|
@@ -834,7 +1153,15 @@ type OrderQuoteRequest = (OrderQuoteSide & OrderQuoteValidity & {
|
|
|
834
1153
|
*
|
|
835
1154
|
*/
|
|
836
1155
|
type OrderQuoteResponse = {
|
|
1156
|
+
/**
|
|
1157
|
+
* The quoted order parameters. These values can be used directly to create and sign an order.
|
|
1158
|
+
*
|
|
1159
|
+
*/
|
|
837
1160
|
quote: OrderParameters;
|
|
1161
|
+
/**
|
|
1162
|
+
* The address of the trader for whom the quote was requested.
|
|
1163
|
+
*
|
|
1164
|
+
*/
|
|
838
1165
|
from?: Address;
|
|
839
1166
|
/**
|
|
840
1167
|
* Expiration date of the offered fee. Order service might not accept
|
|
@@ -853,15 +1180,107 @@ type OrderQuoteResponse = {
|
|
|
853
1180
|
*/
|
|
854
1181
|
verified: boolean;
|
|
855
1182
|
/**
|
|
856
|
-
* Protocol fee in basis points (e.g., "2" for 0.02%). This represents the volume-based fee policy. Only present when configured.
|
|
1183
|
+
* Protocol fee in basis points (e.g., "2" for 0.02%). This represents the volume-based fee policy. Only present when a volume fee is configured.
|
|
857
1184
|
*
|
|
858
1185
|
*/
|
|
859
1186
|
protocolFeeBps?: string;
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* The kind of Tenderly simulation to run.
|
|
1191
|
+
*/
|
|
1192
|
+
declare enum SimulationType {
|
|
1193
|
+
FULL = "full",
|
|
1194
|
+
QUICK = "quick"
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* State overrides for a given account before simulation.
|
|
1199
|
+
*/
|
|
1200
|
+
type StateObject = {
|
|
1201
|
+
/**
|
|
1202
|
+
* Fake balance to set for the account (decimal-encoded uint256).
|
|
1203
|
+
*/
|
|
1204
|
+
balance?: string;
|
|
1205
|
+
/**
|
|
1206
|
+
* Fake EVM bytecode to inject into the account (hex with `0x` prefix).
|
|
1207
|
+
*/
|
|
1208
|
+
code?: string;
|
|
1209
|
+
/**
|
|
1210
|
+
* Fake key-value mapping to override individual storage slots. Keys and values are 32-byte hex strings with `0x` prefix.
|
|
1211
|
+
*
|
|
1212
|
+
*/
|
|
1213
|
+
storage?: Record<string, string>;
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* A Tenderly transaction simulation request.
|
|
1218
|
+
*/
|
|
1219
|
+
type TenderlyRequest = {
|
|
1220
|
+
/**
|
|
1221
|
+
* The network identifier (e.g. "1" for mainnet).
|
|
1222
|
+
*/
|
|
1223
|
+
network_id: string;
|
|
1224
|
+
/**
|
|
1225
|
+
* Block number to simulate the transaction at.
|
|
1226
|
+
*/
|
|
1227
|
+
block_number?: number;
|
|
1228
|
+
/**
|
|
1229
|
+
* Transaction index within the block.
|
|
1230
|
+
*/
|
|
1231
|
+
transaction_index?: number;
|
|
1232
|
+
from: Address;
|
|
1233
|
+
to: Address;
|
|
1234
|
+
/**
|
|
1235
|
+
* Transaction calldata encoded as hex with `0x` prefix.
|
|
1236
|
+
*/
|
|
1237
|
+
input: CallData;
|
|
1238
|
+
/**
|
|
1239
|
+
* Gas limit for the transaction.
|
|
1240
|
+
*/
|
|
1241
|
+
gas?: number;
|
|
860
1242
|
/**
|
|
861
|
-
*
|
|
1243
|
+
* Gas price in Wei.
|
|
1244
|
+
*/
|
|
1245
|
+
gas_price?: number;
|
|
1246
|
+
/**
|
|
1247
|
+
* ETH value to send with the transaction (decimal-encoded uint256).
|
|
1248
|
+
*/
|
|
1249
|
+
value?: string;
|
|
1250
|
+
simulation_type?: SimulationType;
|
|
1251
|
+
/**
|
|
1252
|
+
* Whether to save the simulation on Tenderly.
|
|
1253
|
+
*/
|
|
1254
|
+
save?: boolean;
|
|
1255
|
+
/**
|
|
1256
|
+
* Whether to save the simulation only if it fails.
|
|
1257
|
+
*/
|
|
1258
|
+
save_if_fails?: boolean;
|
|
1259
|
+
/**
|
|
1260
|
+
* Whether to generate an access list for the transaction.
|
|
1261
|
+
*/
|
|
1262
|
+
generate_access_list?: boolean;
|
|
1263
|
+
/**
|
|
1264
|
+
* State overrides applied before simulation. Keys are account addresses (hex with `0x` prefix).
|
|
862
1265
|
*
|
|
863
1266
|
*/
|
|
864
|
-
|
|
1267
|
+
state_objects?: Record<string, StateObject>;
|
|
1268
|
+
/**
|
|
1269
|
+
* EIP-2930 access list for the transaction.
|
|
1270
|
+
*/
|
|
1271
|
+
access_list?: Array<AccessListItem>;
|
|
1272
|
+
};
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* The Tenderly simulation request for an order, along with any simulation error.
|
|
1276
|
+
*
|
|
1277
|
+
*/
|
|
1278
|
+
type OrderSimulation = {
|
|
1279
|
+
tenderly_request: TenderlyRequest;
|
|
1280
|
+
/**
|
|
1281
|
+
* Simulation error message, if the simulation failed.
|
|
1282
|
+
*/
|
|
1283
|
+
error?: string | null;
|
|
865
1284
|
};
|
|
866
1285
|
|
|
867
1286
|
type PriceEstimationError = {
|
|
@@ -872,11 +1291,77 @@ declare namespace PriceEstimationError {
|
|
|
872
1291
|
enum errorType {
|
|
873
1292
|
QUOTE_NOT_VERIFIED = "QuoteNotVerified",
|
|
874
1293
|
UNSUPPORTED_TOKEN = "UnsupportedToken",
|
|
875
|
-
|
|
1294
|
+
NO_LIQUIDITY = "NoLiquidity",
|
|
876
1295
|
UNSUPPORTED_ORDER_TYPE = "UnsupportedOrderType"
|
|
877
1296
|
}
|
|
878
1297
|
}
|
|
879
1298
|
|
|
1299
|
+
/**
|
|
1300
|
+
* Request body for simulating an arbitrary order without it being stored in the orderbook.
|
|
1301
|
+
*
|
|
1302
|
+
*/
|
|
1303
|
+
type SimulationRequest = {
|
|
1304
|
+
/**
|
|
1305
|
+
* The token being sold.
|
|
1306
|
+
*/
|
|
1307
|
+
sellToken: Address;
|
|
1308
|
+
/**
|
|
1309
|
+
* The token being bought.
|
|
1310
|
+
*/
|
|
1311
|
+
buyToken: Address;
|
|
1312
|
+
/**
|
|
1313
|
+
* Amount of sell token (hex- or decimal-encoded uint256). Must be greater than zero.
|
|
1314
|
+
*
|
|
1315
|
+
*/
|
|
1316
|
+
sellAmount: TokenAmount;
|
|
1317
|
+
/**
|
|
1318
|
+
* Amount of buy token (hex- or decimal-encoded uint256).
|
|
1319
|
+
*/
|
|
1320
|
+
buyAmount: TokenAmount;
|
|
1321
|
+
/**
|
|
1322
|
+
* Whether this is a sell or buy order.
|
|
1323
|
+
*/
|
|
1324
|
+
kind: OrderKind;
|
|
1325
|
+
/**
|
|
1326
|
+
* The address of the order owner.
|
|
1327
|
+
*/
|
|
1328
|
+
owner: Address;
|
|
1329
|
+
/**
|
|
1330
|
+
* The address that will receive the buy tokens. Defaults to the owner if omitted.
|
|
1331
|
+
*
|
|
1332
|
+
*/
|
|
1333
|
+
receiver?: Address;
|
|
1334
|
+
/**
|
|
1335
|
+
* Where the sell token should be drawn from.
|
|
1336
|
+
*/
|
|
1337
|
+
sellTokenBalance?: SellTokenSource;
|
|
1338
|
+
/**
|
|
1339
|
+
* Where the buy token should be transferred to.
|
|
1340
|
+
*/
|
|
1341
|
+
buyTokenBalance?: BuyTokenDestination;
|
|
1342
|
+
/**
|
|
1343
|
+
* Full app data JSON string.
|
|
1344
|
+
*
|
|
1345
|
+
*/
|
|
1346
|
+
appData: string;
|
|
1347
|
+
blockNumber?: number | null;
|
|
1348
|
+
signingScheme: SigningScheme;
|
|
1349
|
+
signature: Signature;
|
|
1350
|
+
/**
|
|
1351
|
+
* The fee amount in sell token atoms. Expected to be 0; only present because it must be part of the signed order data.
|
|
1352
|
+
*
|
|
1353
|
+
*/
|
|
1354
|
+
feeAmount: TokenAmount;
|
|
1355
|
+
/**
|
|
1356
|
+
* Unix timestamp (`uint32`) until which the order is valid.
|
|
1357
|
+
*/
|
|
1358
|
+
validTo: number;
|
|
1359
|
+
/**
|
|
1360
|
+
* Whether the order can be partially filled or must be filled all at once.
|
|
1361
|
+
*/
|
|
1362
|
+
partiallyFillable: boolean;
|
|
1363
|
+
};
|
|
1364
|
+
|
|
880
1365
|
type SolverSettlement = {
|
|
881
1366
|
/**
|
|
882
1367
|
* Which position the solution achieved in the total ranking of the competition.
|
|
@@ -942,6 +1427,10 @@ type SolverCompetitionResponse = {
|
|
|
942
1427
|
* Block that the auction started on.
|
|
943
1428
|
*/
|
|
944
1429
|
auctionStartBlock?: number;
|
|
1430
|
+
/**
|
|
1431
|
+
* Block deadline by which the auction must be settled.
|
|
1432
|
+
*/
|
|
1433
|
+
auctionDeadlineBlock?: number;
|
|
945
1434
|
/**
|
|
946
1435
|
* The hashes of the transactions for the winning solutions of this competition.
|
|
947
1436
|
*
|
|
@@ -1546,4 +2035,4 @@ interface ProtocolFeeAmountParams {
|
|
|
1546
2035
|
*/
|
|
1547
2036
|
declare function getProtocolFeeAmount(params: ProtocolFeeAmountParams): bigint;
|
|
1548
2037
|
|
|
1549
|
-
export { type Address, type Amounts, type AppData, type AppDataHash, type AppDataObject, type Auction, type AuctionOrder, type AuctionPrices, type BigUint, BuyTokenDestination, type CallData, type CompetitionAuction, CompetitionOrderStatus, type Costs, DEFAULT_BACKOFF_OPTIONS, DEFAULT_LIMITER_OPTIONS, type EcdsaSignature, EcdsaSigningScheme, type EnrichedOrder, type EthflowData, type ExecutedAmounts, type ExecutedProtocolFee, type FeePolicy, type FetchParams, type GetOrdersRequest, type GetTradesRequest, type InteractionData, type NativePriceResponse, ORDER_BOOK_PARTNER_PROD_CONFIG, ORDER_BOOK_PARTNER_STAGING_CONFIG, ORDER_BOOK_PROD_CONFIG, ORDER_BOOK_STAGING_CONFIG, OnchainOrderData, type Order, type OrderAmountsBig, OrderBookApi, OrderBookApiError, type OrderCancellation, OrderCancellationError, type OrderCancellations, OrderClass, type OrderCreation, OrderKind, type OrderMetaData, type OrderParameters, OrderPostError, type OrderQuoteRequest, type OrderQuoteResponse, type OrderQuoteSide, OrderQuoteSideKindBuy, OrderQuoteSideKindSell, type OrderQuoteValidity, OrderStatus, type PreSignature, PriceEstimationError, type PriceImprovement, PriceQuality, type ProtocolFeeAmountParams, type Quote, type QuoteAmountsAfterSlippage, type QuoteAmountsAfterSlippageParams, type QuoteAmountsAndCosts, type QuoteAmountsAndCostsParams, type QuoteAmountsWithNetworkCosts, type QuoteParameters, type QuotePriceParams, SellTokenSource, type Signature, SigningScheme, type SolverCompetitionResponse, type SolverSettlement, type Surplus, type TokenAmount, type TotalSurplus, type Trade, type TransactionHash, type UID, type Volume, getProtocolFeeAmount, getQuoteAmountsAfterPartnerFee, getQuoteAmountsAfterSlippage, getQuoteAmountsAndCosts, request };
|
|
2038
|
+
export { type AccessListItem, type Address, type Amounts, type AppData, type AppDataHash, type AppDataObject, type Auction, type AuctionOrder, type AuctionPrices, type BigUint, BuyTokenDestination, type CallData, type CompetitionAuction, CompetitionOrderStatus, type Costs, DEFAULT_BACKOFF_OPTIONS, DEFAULT_LIMITER_OPTIONS, type DebugAuction, type DebugEvent, type DebugExecution, DebugFeePolicy, type DebugOrderResponse, type DebugProposedSolution, type DebugProtocolFee, type DebugSettlementAttempt, type DebugTrade, type EcdsaSignature, EcdsaSigningScheme, type EnrichedOrder, type EthflowData, type ExecutedAmounts, type ExecutedProtocolFee, type FeePolicy, type FetchParams, type GetOrdersRequest, type GetTradesRequest, type InteractionData, type NativePriceResponse, ORDER_BOOK_PARTNER_PROD_CONFIG, ORDER_BOOK_PARTNER_STAGING_CONFIG, ORDER_BOOK_PROD_CONFIG, ORDER_BOOK_STAGING_CONFIG, OnchainOrderData, type Order, type OrderAmountsBig, OrderBookApi, OrderBookApiError, type OrderCancellation, OrderCancellationError, type OrderCancellations, OrderClass, type OrderCreation, OrderKind, type OrderMetaData, type OrderParameters, OrderPostError, type OrderQuoteRequest, type OrderQuoteResponse, type OrderQuoteSide, OrderQuoteSideKindBuy, OrderQuoteSideKindSell, type OrderQuoteValidity, type OrderSimulation, OrderStatus, type PreSignature, PriceEstimationError, type PriceImprovement, PriceQuality, type ProtocolFeeAmountParams, type Quote, type QuoteAmountsAfterSlippage, type QuoteAmountsAfterSlippageParams, type QuoteAmountsAndCosts, type QuoteAmountsAndCostsParams, type QuoteAmountsWithNetworkCosts, type QuoteParameters, type QuotePriceParams, SellTokenSource, type Signature, SigningScheme, type SimulationRequest, SimulationType, type SolverCompetitionResponse, type SolverSettlement, type StateObject, type StoredOrderQuote, type Surplus, type TenderlyRequest, type TokenAmount, type TotalSurplus, type Trade, type TransactionHash, type UID, type Volume, getProtocolFeeAmount, getQuoteAmountsAfterPartnerFee, getQuoteAmountsAfterSlippage, getQuoteAmountsAndCosts, request };
|