@velora-dex/sdk 8.1.0 → 8.1.1-dev.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/helpers/providers/viem.d.ts +1 -1
- package/dist/helpers/providers/viem.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts +1 -1
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts.map +1 -1
- package/dist/methods/delta/buildDeltaOrder.d.ts +9 -6
- package/dist/methods/delta/buildDeltaOrder.d.ts.map +1 -1
- package/dist/methods/delta/cancelDeltaOrder.d.ts +21 -0
- package/dist/methods/delta/cancelDeltaOrder.d.ts.map +1 -0
- package/dist/methods/delta/getDeltaOrders.d.ts +11 -1
- package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +29 -10
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
- package/dist/methods/delta/helpers/buildCancelDeltaOrderData.d.ts +25 -0
- package/dist/methods/delta/helpers/buildCancelDeltaOrderData.d.ts.map +1 -0
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts +3 -3
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts.map +1 -1
- package/dist/methods/delta/helpers/misc.d.ts +1 -1
- package/dist/methods/delta/helpers/misc.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +34 -6
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/delta/index.d.ts +7 -5
- package/dist/methods/delta/index.d.ts.map +1 -1
- package/dist/methods/delta/postDeltaOrder.d.ts +9 -1
- package/dist/methods/delta/postDeltaOrder.d.ts.map +1 -1
- package/dist/methods/quote/getQuote.d.ts +4 -4
- package/dist/methods/quote/getQuote.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +354 -407
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +354 -408
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/providers/viem.ts +4 -1
- package/src/index.ts +6 -0
- package/src/methods/delta/buildCrosschainOrderBridge.ts +15 -6
- package/src/methods/delta/buildDeltaOrder.ts +33 -65
- package/src/methods/delta/cancelDeltaOrder.ts +109 -0
- package/src/methods/delta/getDeltaOrders.ts +38 -0
- package/src/methods/delta/getDeltaPrice.ts +60 -15
- package/src/methods/delta/helpers/across.ts +1 -1
- package/src/methods/delta/helpers/buildCancelDeltaOrderData.ts +48 -0
- package/src/methods/delta/helpers/buildDeltaOrderData.ts +36 -11
- package/src/methods/delta/helpers/misc.ts +6 -2
- package/src/methods/delta/helpers/types.ts +55 -7
- package/src/methods/delta/index.ts +19 -4
- package/src/methods/delta/postDeltaOrder.ts +11 -1
- package/src/methods/quote/getQuote.ts +7 -10
- package/dist/methods/delta/helpers/composePermit.d.ts +0 -5
- package/dist/methods/delta/helpers/composePermit.d.ts.map +0 -1
- package/src/methods/delta/helpers/composePermit.ts +0 -76
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MarkOptional } from 'ts-essentials';
|
|
2
2
|
import { Domain, ZERO_ADDRESS } from '../../common/orders/buildOrderData';
|
|
3
3
|
import { Bridge, DeltaAuctionOrder } from './types';
|
|
4
|
-
import { composeDeltaOrderPermit } from './composePermit';
|
|
5
4
|
|
|
6
5
|
// Order(address owner,address beneficiary,address srcToken,address destToken,uint256 srcAmount,uint256 destAmount,uint256 deadline,uint256 nonce,bytes permit, bridge Bridge)";
|
|
7
6
|
const SWAP_ORDER_EIP_712_TYPES = {
|
|
@@ -12,18 +11,36 @@ const SWAP_ORDER_EIP_712_TYPES = {
|
|
|
12
11
|
{ name: 'destToken', type: 'address' },
|
|
13
12
|
{ name: 'srcAmount', type: 'uint256' },
|
|
14
13
|
{ name: 'destAmount', type: 'uint256' },
|
|
15
|
-
{ name: '
|
|
14
|
+
{ name: 'expectedAmount', type: 'uint256' },
|
|
16
15
|
{ name: 'deadline', type: 'uint256' },
|
|
16
|
+
{ name: 'kind', type: 'uint8' },
|
|
17
17
|
{ name: 'nonce', type: 'uint256' },
|
|
18
18
|
{ name: 'partnerAndFee', type: 'uint256' },
|
|
19
19
|
{ name: 'permit', type: 'bytes' },
|
|
20
|
+
{ name: 'metadata', type: 'bytes' },
|
|
20
21
|
{ name: 'bridge', type: 'Bridge' },
|
|
21
22
|
],
|
|
22
23
|
Bridge: [
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
{
|
|
25
|
+
name: 'protocolSelector',
|
|
26
|
+
type: 'bytes4',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'destinationChainId',
|
|
30
|
+
type: 'uint256',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'outputToken',
|
|
34
|
+
type: 'address',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'scalingFactor',
|
|
38
|
+
type: 'int8',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'protocolData',
|
|
42
|
+
type: 'bytes',
|
|
43
|
+
},
|
|
27
44
|
],
|
|
28
45
|
};
|
|
29
46
|
|
|
@@ -69,7 +86,10 @@ export type DeltaOrderDataInput = MarkOptional<
|
|
|
69
86
|
'beneficiary' | 'deadline' | 'nonce' | 'permit'
|
|
70
87
|
>;
|
|
71
88
|
|
|
72
|
-
export type BuildDeltaOrderDataInput =
|
|
89
|
+
export type BuildDeltaOrderDataInput = MarkOptional<
|
|
90
|
+
DeltaOrderDataInput,
|
|
91
|
+
'metadata'
|
|
92
|
+
> & {
|
|
73
93
|
partnerAddress: string;
|
|
74
94
|
paraswapDeltaAddress: string;
|
|
75
95
|
partnerFeeBps: number;
|
|
@@ -78,7 +98,7 @@ export type BuildDeltaOrderDataInput = DeltaOrderDataInput & {
|
|
|
78
98
|
bridge: Bridge;
|
|
79
99
|
};
|
|
80
100
|
|
|
81
|
-
// default deadline = 1 hour
|
|
101
|
+
// default deadline = 1 hour for now (may be changed later)
|
|
82
102
|
export const DELTA_DEFAULT_EXPIRY = 60 * 60; // seconds
|
|
83
103
|
|
|
84
104
|
export function buildDeltaSignableOrderData({
|
|
@@ -89,13 +109,16 @@ export function buildDeltaSignableOrderData({
|
|
|
89
109
|
destToken,
|
|
90
110
|
srcAmount,
|
|
91
111
|
destAmount,
|
|
92
|
-
|
|
112
|
+
expectedAmount,
|
|
93
113
|
|
|
94
114
|
deadline = Math.floor(Date.now() / 1000 + DELTA_DEFAULT_EXPIRY),
|
|
95
115
|
nonce = Date.now().toString(10), // random enough to not cause collisions
|
|
96
116
|
|
|
97
117
|
permit = '0x',
|
|
98
118
|
|
|
119
|
+
kind,
|
|
120
|
+
metadata = '0x',
|
|
121
|
+
|
|
99
122
|
partnerAddress,
|
|
100
123
|
partnerFeeBps,
|
|
101
124
|
partnerTakesSurplus = false,
|
|
@@ -111,16 +134,18 @@ export function buildDeltaSignableOrderData({
|
|
|
111
134
|
destToken,
|
|
112
135
|
srcAmount,
|
|
113
136
|
destAmount,
|
|
114
|
-
|
|
137
|
+
expectedAmount,
|
|
115
138
|
deadline,
|
|
116
139
|
nonce,
|
|
117
|
-
permit
|
|
140
|
+
permit,
|
|
118
141
|
partnerAndFee: producePartnerAndFee({
|
|
119
142
|
partnerFeeBps,
|
|
120
143
|
partnerAddress,
|
|
121
144
|
partnerTakesSurplus,
|
|
122
145
|
}),
|
|
123
146
|
bridge,
|
|
147
|
+
kind,
|
|
148
|
+
metadata,
|
|
124
149
|
};
|
|
125
150
|
|
|
126
151
|
return produceDeltaOrderTypedData({
|
|
@@ -7,12 +7,14 @@ export function sanitizeDeltaOrderData({
|
|
|
7
7
|
destToken,
|
|
8
8
|
srcAmount,
|
|
9
9
|
destAmount,
|
|
10
|
-
|
|
10
|
+
expectedAmount,
|
|
11
11
|
deadline,
|
|
12
12
|
nonce,
|
|
13
13
|
permit,
|
|
14
14
|
partnerAndFee,
|
|
15
15
|
bridge,
|
|
16
|
+
kind,
|
|
17
|
+
metadata,
|
|
16
18
|
}: SignableDeltaOrderData['data'] &
|
|
17
19
|
Record<string, any>): SignableDeltaOrderData['data'] {
|
|
18
20
|
return {
|
|
@@ -22,11 +24,13 @@ export function sanitizeDeltaOrderData({
|
|
|
22
24
|
destToken,
|
|
23
25
|
srcAmount,
|
|
24
26
|
destAmount,
|
|
25
|
-
|
|
27
|
+
expectedAmount,
|
|
26
28
|
deadline,
|
|
27
29
|
nonce,
|
|
28
30
|
permit,
|
|
29
31
|
partnerAndFee,
|
|
30
32
|
bridge,
|
|
33
|
+
kind,
|
|
34
|
+
metadata,
|
|
31
35
|
};
|
|
32
36
|
}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import { SwapSide } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
enum OrderKind {
|
|
4
|
+
Sell = 0,
|
|
5
|
+
Buy = 1,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const SwapSideToOrderKind = {
|
|
9
|
+
[SwapSide.SELL]: OrderKind.Sell,
|
|
10
|
+
[SwapSide.BUY]: OrderKind.Buy,
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
1
13
|
export type DeltaAuctionOrder = {
|
|
2
14
|
/** @description The address of the order owner */
|
|
3
15
|
owner: string;
|
|
@@ -11,8 +23,12 @@ export type DeltaAuctionOrder = {
|
|
|
11
23
|
srcAmount: string; // wei
|
|
12
24
|
/** @description The minimum amount of dest token to receive */
|
|
13
25
|
destAmount: string; // wei
|
|
14
|
-
/** @description The expected amount of
|
|
15
|
-
|
|
26
|
+
/** @description The expected amount of token to receive */
|
|
27
|
+
expectedAmount: string; // wei
|
|
28
|
+
/** @description The kind of the order */
|
|
29
|
+
kind: OrderKind;
|
|
30
|
+
/** @description Metadata for the order, hex string */
|
|
31
|
+
metadata: string;
|
|
16
32
|
/** @description The deadline for the order */
|
|
17
33
|
deadline: number; // seconds
|
|
18
34
|
/** @description The nonce of the order */
|
|
@@ -26,22 +42,28 @@ export type DeltaAuctionOrder = {
|
|
|
26
42
|
};
|
|
27
43
|
|
|
28
44
|
export type Bridge = {
|
|
29
|
-
|
|
45
|
+
protocolSelector: string; // Hex string
|
|
30
46
|
destinationChainId: number;
|
|
31
47
|
/** @description The address of the output token. Same as Order.destToken but on destination chain, so can still be a different address */
|
|
32
48
|
outputToken: string;
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
scalingFactor: number;
|
|
50
|
+
|
|
51
|
+
/** @description Data specific to the protocol */
|
|
52
|
+
protocolData: string; // Hex string
|
|
35
53
|
};
|
|
36
54
|
|
|
37
55
|
type DeltaAuctionStatus =
|
|
38
56
|
| 'NOT_STARTED'
|
|
39
|
-
| 'POSTED'
|
|
40
57
|
| 'RUNNING'
|
|
41
58
|
| 'EXECUTING'
|
|
42
59
|
| 'EXECUTED'
|
|
43
60
|
| 'FAILED'
|
|
44
|
-
| 'EXPIRED'
|
|
61
|
+
| 'EXPIRED'
|
|
62
|
+
| 'CANCELLED'; // @TODO check if added
|
|
63
|
+
// these are not exposed, but are coerced into FAILED
|
|
64
|
+
// | 'INSUFFICIENT_BALANCE'
|
|
65
|
+
// | 'INSUFFICIENT_ALLOWANCE'
|
|
66
|
+
// | 'INVALIDATED';
|
|
45
67
|
|
|
46
68
|
type DeltaAuctionTransaction = {
|
|
47
69
|
id: string;
|
|
@@ -91,6 +113,12 @@ export type DeltaAuction = {
|
|
|
91
113
|
|
|
92
114
|
bridgeMetadata: BridgeMetadata | null;
|
|
93
115
|
bridgeStatus: BridgeStatus | null;
|
|
116
|
+
|
|
117
|
+
// @TODO only returned after POST Order so far
|
|
118
|
+
// orderVersion: string; // "2.0.0"
|
|
119
|
+
// deltaGasOverhead: number;
|
|
120
|
+
|
|
121
|
+
type: 'MARKET' | 'LIMIT'; // @TODO when available in API for individual /order/:hash|:id
|
|
94
122
|
};
|
|
95
123
|
|
|
96
124
|
export type BridgeMetadata = {
|
|
@@ -108,3 +136,23 @@ export type BridgeMetadata = {
|
|
|
108
136
|
|
|
109
137
|
// refunded is basically failed
|
|
110
138
|
export type BridgeStatus = 'pending' | 'filled' | 'expired' | 'refunded';
|
|
139
|
+
|
|
140
|
+
//// available on BridgePrice ////
|
|
141
|
+
|
|
142
|
+
// so far
|
|
143
|
+
type ProtocolName = 'Across' | 'StargateBus' | 'StargateTaxi';
|
|
144
|
+
|
|
145
|
+
type BridgeQuoteFee = {
|
|
146
|
+
feeToken: string;
|
|
147
|
+
amount: string;
|
|
148
|
+
amountInSrcToken: string;
|
|
149
|
+
amountInUSD: string;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export type BridgePriceInfo = {
|
|
153
|
+
protocolName: ProtocolName;
|
|
154
|
+
destAmountAfterBridge: string;
|
|
155
|
+
destUSDAfterBridge: string;
|
|
156
|
+
fees: BridgeQuoteFee[];
|
|
157
|
+
estimatedTimeMs: number;
|
|
158
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ConstructProviderFetchInput } from '../../types';
|
|
2
|
-
import type { DeltaAuction } from './helpers/types';
|
|
3
2
|
import {
|
|
4
3
|
BuildDeltaOrderDataParams,
|
|
5
4
|
BuildDeltaOrderFunctions,
|
|
@@ -7,6 +6,8 @@ import {
|
|
|
7
6
|
} from './buildDeltaOrder';
|
|
8
7
|
import {
|
|
9
8
|
constructPostDeltaOrder,
|
|
9
|
+
DeltaOrderApiResponse,
|
|
10
|
+
DeltaOrderToPost,
|
|
10
11
|
PostDeltaOrderFunctions,
|
|
11
12
|
} from './postDeltaOrder';
|
|
12
13
|
import {
|
|
@@ -49,15 +50,21 @@ import {
|
|
|
49
50
|
BuildCrosschainOrderBridgeFunctions,
|
|
50
51
|
constructBuildCrosschainOrderBridge,
|
|
51
52
|
} from './buildCrosschainOrderBridge';
|
|
53
|
+
import {
|
|
54
|
+
CancelDeltaOrderFunctions,
|
|
55
|
+
constructCancelDeltaOrder,
|
|
56
|
+
} from './cancelDeltaOrder';
|
|
52
57
|
|
|
53
58
|
export type SubmitDeltaOrderParams = BuildDeltaOrderDataParams & {
|
|
54
59
|
/** @description designates the Order as being able to be partially filled, as opposed to fill-or-kill */
|
|
55
60
|
partiallyFillable?: boolean;
|
|
56
|
-
|
|
61
|
+
/** @description Referrer address */
|
|
62
|
+
referrerAddress?: string;
|
|
63
|
+
} & Pick<DeltaOrderToPost, 'type' | 'includeAgents' | 'excludeAgents'>;
|
|
57
64
|
|
|
58
65
|
type SubmitDeltaOrder = (
|
|
59
66
|
orderParams: SubmitDeltaOrderParams
|
|
60
|
-
) => Promise<
|
|
67
|
+
) => Promise<DeltaOrderApiResponse>;
|
|
61
68
|
|
|
62
69
|
export type SubmitDeltaOrderFuncs = {
|
|
63
70
|
submitDeltaOrder: SubmitDeltaOrder;
|
|
@@ -79,6 +86,10 @@ export const constructSubmitDeltaOrder = (
|
|
|
79
86
|
partner: orderParams.partner,
|
|
80
87
|
order: orderData.data,
|
|
81
88
|
partiallyFillable: orderParams.partiallyFillable,
|
|
89
|
+
referrerAddress: orderParams.referrerAddress,
|
|
90
|
+
type: orderParams.type,
|
|
91
|
+
includeAgents: orderParams.includeAgents,
|
|
92
|
+
excludeAgents: orderParams.excludeAgents,
|
|
82
93
|
});
|
|
83
94
|
|
|
84
95
|
return response;
|
|
@@ -99,7 +110,8 @@ export type DeltaOrderHandlers<T> = SubmitDeltaOrderFuncs &
|
|
|
99
110
|
GetBridgeInfoFunctions &
|
|
100
111
|
IsTokenSupportedInDeltaFunctions &
|
|
101
112
|
PostDeltaOrderFunctions &
|
|
102
|
-
SignDeltaOrderFunctions
|
|
113
|
+
SignDeltaOrderFunctions &
|
|
114
|
+
CancelDeltaOrderFunctions;
|
|
103
115
|
|
|
104
116
|
/** @description construct SDK with every Delta Order-related method, fetching from API and Order signing */
|
|
105
117
|
export const constructAllDeltaOrdersHandlers = <TxResponse>(
|
|
@@ -128,6 +140,8 @@ export const constructAllDeltaOrdersHandlers = <TxResponse>(
|
|
|
128
140
|
const deltaOrdersSign = constructSignDeltaOrder(options);
|
|
129
141
|
const deltaOrdersPost = constructPostDeltaOrder(options);
|
|
130
142
|
|
|
143
|
+
const deltaOrdersCancel = constructCancelDeltaOrder(options);
|
|
144
|
+
|
|
131
145
|
return {
|
|
132
146
|
...deltaOrdersGetters,
|
|
133
147
|
...deltaOrdersContractGetter,
|
|
@@ -141,6 +155,7 @@ export const constructAllDeltaOrdersHandlers = <TxResponse>(
|
|
|
141
155
|
...deltaOrdersBuild,
|
|
142
156
|
...deltaOrdersSign,
|
|
143
157
|
...deltaOrdersPost,
|
|
158
|
+
...deltaOrdersCancel,
|
|
144
159
|
...buildCrosschainOrderBridge,
|
|
145
160
|
};
|
|
146
161
|
};
|
|
@@ -13,11 +13,21 @@ export type DeltaOrderToPost = {
|
|
|
13
13
|
chainId: number;
|
|
14
14
|
/** @description designates the Order as being able to partially filled, as opposed to fill-or-kill */
|
|
15
15
|
partiallyFillable?: boolean;
|
|
16
|
+
|
|
17
|
+
/** @description Type of the order. MARKET or LIMIT. Default is MARKET */
|
|
18
|
+
type?: 'MARKET' | 'LIMIT';
|
|
19
|
+
|
|
20
|
+
includeAgents?: string[];
|
|
21
|
+
excludeAgents?: string[];
|
|
16
22
|
};
|
|
17
23
|
|
|
18
24
|
export type PostDeltaOrderParams = Omit<DeltaOrderToPost, 'chainId'>;
|
|
19
25
|
|
|
20
|
-
type DeltaOrderApiResponse = DeltaAuction
|
|
26
|
+
export type DeltaOrderApiResponse = Omit<DeltaAuction, 'transactions'> & {
|
|
27
|
+
orderVersion: string; // "2.0.0"
|
|
28
|
+
deltaGasOverhead: number; // @TODO may be removed
|
|
29
|
+
type: 'MARKET' | 'LIMIT';
|
|
30
|
+
};
|
|
21
31
|
|
|
22
32
|
type PostDeltaOrder = (
|
|
23
33
|
postData: PostDeltaOrderParams,
|
|
@@ -23,8 +23,8 @@ export type QuoteParams<M extends TradeMode = TradeMode> = {
|
|
|
23
23
|
srcDecimals: number;
|
|
24
24
|
/** @description Destination Token Decimals */
|
|
25
25
|
destDecimals: number;
|
|
26
|
-
/** @description SELL or BUY */
|
|
27
|
-
side
|
|
26
|
+
/** @description SELL or BUY, default is SELL */
|
|
27
|
+
side?: SwapSideUnion;
|
|
28
28
|
/** @description User's Wallet Address */
|
|
29
29
|
userAddress?: string;
|
|
30
30
|
/** @description Partner string */
|
|
@@ -69,7 +69,8 @@ export type QuoteResponse =
|
|
|
69
69
|
| QuoteWithDeltaPrice
|
|
70
70
|
| QuoteWithMarketPrice
|
|
71
71
|
| QuoteWithBridgePrice
|
|
72
|
-
| QuoteWithMarketPriceAsFallback
|
|
72
|
+
| QuoteWithMarketPriceAsFallback
|
|
73
|
+
| QuoteWithDeltaPriceAndBridgePrice;
|
|
73
74
|
|
|
74
75
|
interface GetQuoteFunc {
|
|
75
76
|
(
|
|
@@ -97,9 +98,7 @@ interface GetQuoteFunc {
|
|
|
97
98
|
(
|
|
98
99
|
options: QuoteParams<'all'> & { destChainId: number },
|
|
99
100
|
requestParams?: RequestParameters
|
|
100
|
-
): Promise<
|
|
101
|
-
QuoteWithBridgePrice | QuoteWithMarketPriceAsFallback // "all" mode tries for deltaPrice and falls back to market priceRoute
|
|
102
|
-
>;
|
|
101
|
+
): Promise<QuoteWithBridgePrice>;
|
|
103
102
|
(options: QuoteParams<'all'>, requestParams?: RequestParameters): Promise<
|
|
104
103
|
QuoteWithDeltaPriceAndBridgePrice | QuoteWithMarketPriceAsFallback // "all" mode tries for deltaPrice and falls back to market priceRoute
|
|
105
104
|
>;
|
|
@@ -145,9 +144,7 @@ export const constructGetQuote = ({
|
|
|
145
144
|
function getQuote(
|
|
146
145
|
options: QuoteParams<'all'> & { destChainId: number },
|
|
147
146
|
requestParams?: RequestParameters
|
|
148
|
-
): Promise<
|
|
149
|
-
QuoteWithBridgePrice | QuoteWithMarketPriceAsFallback // "all" mode tries for deltaPrice and falls back to market priceRoute
|
|
150
|
-
>;
|
|
147
|
+
): Promise<QuoteWithBridgePrice>;
|
|
151
148
|
function getQuote(
|
|
152
149
|
options: QuoteParams<'all'>,
|
|
153
150
|
requestParams?: RequestParameters
|
|
@@ -165,7 +162,7 @@ export const constructGetQuote = ({
|
|
|
165
162
|
const search = constructSearchString<QuoteQueryOptions>({
|
|
166
163
|
...options,
|
|
167
164
|
chainId,
|
|
168
|
-
|
|
165
|
+
side: options.side ?? SwapSide.SELL,
|
|
169
166
|
});
|
|
170
167
|
|
|
171
168
|
const fetchURL = `${pricesUrl}/${search}` as const;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DeltaAuctionOrder } from './types';
|
|
2
|
-
type DeltaOrderPermitInput = Pick<DeltaAuctionOrder, 'permit' | 'nonce'>;
|
|
3
|
-
export declare function composeDeltaOrderPermit({ permit, nonce, }: DeltaOrderPermitInput): string;
|
|
4
|
-
export {};
|
|
5
|
-
//# sourceMappingURL=composePermit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composePermit.d.ts","sourceRoot":"","sources":["../../../../src/methods/delta/helpers/composePermit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC;AAEzE,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,KAAK,GACN,EAAE,qBAAqB,GAAG,MAAM,CAiBhC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { DeltaAuctionOrder } from './types';
|
|
2
|
-
|
|
3
|
-
type DeltaOrderPermitInput = Pick<DeltaAuctionOrder, 'permit' | 'nonce'>;
|
|
4
|
-
|
|
5
|
-
export function composeDeltaOrderPermit({
|
|
6
|
-
permit,
|
|
7
|
-
nonce,
|
|
8
|
-
}: DeltaOrderPermitInput): string {
|
|
9
|
-
// Can be empty Permit if allowance is available for srcToken
|
|
10
|
-
if (permit === '0x' || permit === '0x01') {
|
|
11
|
-
// 0x01 is a special permit value that signifies existing Permit2 allowance.
|
|
12
|
-
return permit;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// In the Contract, specifically for Permit2 transferFrom, we have signature consisting of
|
|
16
|
-
// bytes32(permit2nonce) + bytes64(compacted signature) = bytes96 Permit2 Transfer format
|
|
17
|
-
|
|
18
|
-
if (permit.length >= 194) {
|
|
19
|
-
// "0x".length + 96bytes*2 = 194, means permit already concatenated with nonce
|
|
20
|
-
// or it's a different type of Permit all together
|
|
21
|
-
return permit;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return encodePermit2Transfer(BigInt(nonce), permit);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function uintTo32ByteArrayBuffer(nonce: number | bigint) {
|
|
28
|
-
// Create a 32-byte ArrayBuffer
|
|
29
|
-
const buffer = new Uint8Array(32);
|
|
30
|
-
|
|
31
|
-
// Convert nonce to hex string and pad it to 64 hex characters (32 bytes)
|
|
32
|
-
let nonceHex = nonce.toString(16).padStart(64, '0');
|
|
33
|
-
|
|
34
|
-
// Convert the hex string to bytes and fill the ArrayBuffer
|
|
35
|
-
for (let i = 0; i < 32; i++) {
|
|
36
|
-
buffer[i] = parseInt(nonceHex.slice(i * 2, i * 2 + 2), 16);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return buffer;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function hexToByteArray(hexString: string) {
|
|
43
|
-
// Remove "0x" prefix if present
|
|
44
|
-
hexString = hexString.replace(/^0x/, '');
|
|
45
|
-
|
|
46
|
-
// Convert hex string to Uint8Array
|
|
47
|
-
const byteArray = new Uint8Array(hexString.length / 2);
|
|
48
|
-
for (let i = 0; i < hexString.length; i += 2) {
|
|
49
|
-
byteArray[i / 2] = parseInt(hexString.slice(i, i + 2), 16);
|
|
50
|
-
}
|
|
51
|
-
return byteArray;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function encodePermit2Transfer(nonce: number | bigint, signature: string) {
|
|
55
|
-
// Get 32-byte ArrayBuffer for nonce
|
|
56
|
-
const nonceBuffer = uintTo32ByteArrayBuffer(nonce);
|
|
57
|
-
|
|
58
|
-
// Convert signature hex string to Uint8Array (64 bytes)
|
|
59
|
-
const signatureBuffer = hexToByteArray(signature);
|
|
60
|
-
if (signatureBuffer.length !== 64) {
|
|
61
|
-
throw new Error('Signature must be exactly 64 bytes');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Concatenate nonceBuffer and signatureBuffer
|
|
65
|
-
const packedBuffer = new Uint8Array(32 + 64);
|
|
66
|
-
packedBuffer.set(nonceBuffer, 0); // Copy nonceBuffer at the start
|
|
67
|
-
packedBuffer.set(signatureBuffer, 32); // Copy signatureBuffer after nonce
|
|
68
|
-
|
|
69
|
-
// Convert to hex string for output
|
|
70
|
-
return (
|
|
71
|
-
'0x' +
|
|
72
|
-
Array.from(packedBuffer)
|
|
73
|
-
.map((b) => b.toString(16).padStart(2, '0'))
|
|
74
|
-
.join('')
|
|
75
|
-
);
|
|
76
|
-
}
|