@velora-dex/sdk 9.5.3 → 9.5.4-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/examples/deltaV2.d.ts +2 -0
- package/dist/examples/deltaV2.d.ts.map +1 -0
- package/dist/examples/helpers/deltaV2.d.ts +5 -0
- package/dist/examples/helpers/deltaV2.d.ts.map +1 -0
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/delta/cancelDeltaOrder.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaOrders.d.ts +4 -4
- package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
- package/dist/methods/delta/helpers/orders.d.ts +16 -1
- package/dist/methods/delta/helpers/orders.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +49 -5
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/delta/postDeltaOrder.d.ts +3 -3
- package/dist/methods/delta/postDeltaOrder.d.ts.map +1 -1
- package/dist/methods/deltaV2/buildDeltaOrderV2.d.ts +44 -0
- package/dist/methods/deltaV2/buildDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/buildExternalDeltaOrderV2.d.ts +48 -0
- package/dist/methods/deltaV2/buildExternalDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/buildTWAPDeltaOrderV2.d.ts +59 -0
- package/dist/methods/deltaV2/buildTWAPDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts +21 -0
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/getAgentsListV2.d.ts +10 -0
- package/dist/methods/deltaV2/getAgentsListV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts +20 -0
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts.map +1 -0
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts +33 -0
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/getDeltaPriceV2.d.ts +46 -0
- package/dist/methods/deltaV2/getDeltaPriceV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/index.d.ts +59 -0
- package/dist/methods/deltaV2/index.d.ts.map +1 -0
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts +8 -0
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/postDeltaOrderV2.d.ts +28 -0
- package/dist/methods/deltaV2/postDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts +11 -0
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts +16 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/types.d.ts +163 -0
- package/dist/methods/deltaV2/types.d.ts.map +1 -0
- package/dist/sdk/full.d.ts +2 -0
- package/dist/sdk/full.d.ts.map +1 -1
- package/dist/sdk/simple.d.ts +10 -0
- package/dist/sdk/simple.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +1091 -242
- 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 +1075 -243
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/examples/deltaV2.ts +200 -0
- package/src/examples/helpers/deltaV2.ts +29 -0
- package/src/index.js +18 -0
- package/src/index.ts +153 -0
- package/src/methods/delta/cancelDeltaOrder.ts +4 -1
- package/src/methods/delta/getDeltaOrders.ts +6 -5
- package/src/methods/delta/getDeltaPrice.ts +1 -1
- package/src/methods/delta/helpers/orders.ts +26 -0
- package/src/methods/delta/helpers/types.ts +62 -13
- package/src/methods/delta/postDeltaOrder.ts +4 -4
- package/src/methods/delta/postTWAPDeltaOrder.ts +1 -1
- package/src/methods/deltaV2/buildDeltaOrderV2.ts +86 -0
- package/src/methods/deltaV2/buildExternalDeltaOrderV2.ts +95 -0
- package/src/methods/deltaV2/buildTWAPDeltaOrderV2.ts +131 -0
- package/src/methods/deltaV2/cancelDeltaOrderV2.ts +103 -0
- package/src/methods/deltaV2/getAgentsListV2.ts +34 -0
- package/src/methods/deltaV2/getBridgeRoutes.ts +82 -0
- package/src/methods/deltaV2/getDeltaOrdersV2.ts +119 -0
- package/src/methods/deltaV2/getDeltaPriceV2.ts +108 -0
- package/src/methods/deltaV2/index.ts +303 -0
- package/src/methods/deltaV2/isTokenSupportedInDeltaV2.ts +52 -0
- package/src/methods/deltaV2/postDeltaOrderV2.ts +65 -0
- package/src/methods/deltaV2/postExternalDeltaOrderV2.ts +45 -0
- package/src/methods/deltaV2/postTWAPDeltaOrderV2.ts +63 -0
- package/src/methods/deltaV2/types.ts +189 -0
- package/src/sdk/full.ts +8 -0
- package/src/sdk/simple.ts +56 -0
- package/src/types.ts +9 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
4
|
+
import type {
|
|
5
|
+
DeltaAuction,
|
|
6
|
+
DeltaOrderType,
|
|
7
|
+
OnChainOrderMap,
|
|
8
|
+
} from '../delta/helpers/types';
|
|
9
|
+
|
|
10
|
+
export type DeltaOrderToPostV2<T extends keyof OnChainOrderMap = 'Order'> = {
|
|
11
|
+
/** @description Partner string */
|
|
12
|
+
partner?: string;
|
|
13
|
+
/** @description Referrer address */
|
|
14
|
+
referrerAddress?: string;
|
|
15
|
+
order: OnChainOrderMap[T];
|
|
16
|
+
/** @description Signature of the order from order.owner address. EOA signatures must be submitted in ERC-2098 Compact Representation. */
|
|
17
|
+
signature: string;
|
|
18
|
+
chainId: number;
|
|
19
|
+
/** @description Designates the Order as being able to be partially filled, as opposed to fill-or-kill */
|
|
20
|
+
partiallyFillable?: boolean;
|
|
21
|
+
/** @description Type of the order. MARKET or LIMIT. Default is MARKET */
|
|
22
|
+
type?: DeltaOrderType;
|
|
23
|
+
includeAgents?: string[];
|
|
24
|
+
excludeAgents?: string[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type PostDeltaOrderV2Params = Omit<DeltaOrderToPostV2, 'chainId'> & {
|
|
28
|
+
degenMode?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type PostDeltaOrderV2 = (
|
|
32
|
+
postData: PostDeltaOrderV2Params,
|
|
33
|
+
requestParams?: RequestParameters
|
|
34
|
+
) => Promise<DeltaAuction<'Order'>>;
|
|
35
|
+
|
|
36
|
+
export type PostDeltaOrderV2Functions = {
|
|
37
|
+
postDeltaOrderV2: PostDeltaOrderV2;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const constructPostDeltaOrderV2 = ({
|
|
41
|
+
apiURL = API_URL,
|
|
42
|
+
chainId,
|
|
43
|
+
fetcher,
|
|
44
|
+
}: ConstructFetchInput): PostDeltaOrderV2Functions => {
|
|
45
|
+
const postOrderUrl = `${apiURL}/delta/v2/orders` as const;
|
|
46
|
+
|
|
47
|
+
const postDeltaOrderV2: PostDeltaOrderV2 = (_postData, requestParams) => {
|
|
48
|
+
const { degenMode, ...postData } = _postData;
|
|
49
|
+
const deltaOrderToPost: DeltaOrderToPostV2 = { ...postData, chainId };
|
|
50
|
+
|
|
51
|
+
const search = constructSearchString<{ degenMode?: boolean }>({
|
|
52
|
+
degenMode,
|
|
53
|
+
});
|
|
54
|
+
const fetchURL = `${postOrderUrl}${search}` as const;
|
|
55
|
+
|
|
56
|
+
return fetcher<DeltaAuction<'Order'>>({
|
|
57
|
+
url: fetchURL,
|
|
58
|
+
method: 'POST',
|
|
59
|
+
data: deltaOrderToPost,
|
|
60
|
+
requestParams,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return { postDeltaOrderV2 };
|
|
65
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
+
import type { DeltaAuction } from '../delta/helpers/types';
|
|
4
|
+
import type { DeltaOrderToPostV2 } from './postDeltaOrderV2';
|
|
5
|
+
|
|
6
|
+
export type PostExternalDeltaOrderV2Params = Omit<
|
|
7
|
+
DeltaOrderToPostV2<'ExternalOrder'>,
|
|
8
|
+
'chainId'
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
type PostExternalDeltaOrderV2 = (
|
|
12
|
+
postData: PostExternalDeltaOrderV2Params,
|
|
13
|
+
requestParams?: RequestParameters
|
|
14
|
+
) => Promise<DeltaAuction<'ExternalOrder'>>;
|
|
15
|
+
|
|
16
|
+
export type PostExternalDeltaOrderV2Functions = {
|
|
17
|
+
postExternalDeltaOrderV2: PostExternalDeltaOrderV2;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const constructPostExternalDeltaOrderV2 = ({
|
|
21
|
+
apiURL = API_URL,
|
|
22
|
+
chainId,
|
|
23
|
+
fetcher,
|
|
24
|
+
}: ConstructFetchInput): PostExternalDeltaOrderV2Functions => {
|
|
25
|
+
const postOrderUrl = `${apiURL}/delta/v2/orders` as const;
|
|
26
|
+
|
|
27
|
+
const postExternalDeltaOrderV2: PostExternalDeltaOrderV2 = (
|
|
28
|
+
postData,
|
|
29
|
+
requestParams
|
|
30
|
+
) => {
|
|
31
|
+
const deltaOrderToPost: DeltaOrderToPostV2<'ExternalOrder'> = {
|
|
32
|
+
...postData,
|
|
33
|
+
chainId,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return fetcher<DeltaAuction<'ExternalOrder'>>({
|
|
37
|
+
url: postOrderUrl,
|
|
38
|
+
method: 'POST',
|
|
39
|
+
data: deltaOrderToPost,
|
|
40
|
+
requestParams,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return { postExternalDeltaOrderV2 };
|
|
45
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Prettify } from 'ts-essentials';
|
|
2
|
+
import { API_URL } from '../../constants';
|
|
3
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
4
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
5
|
+
import type {
|
|
6
|
+
DeltaAuction,
|
|
7
|
+
TWAPOnChainOrderType,
|
|
8
|
+
} from '../delta/helpers/types';
|
|
9
|
+
import type { DeltaOrderToPostV2 } from './postDeltaOrderV2';
|
|
10
|
+
|
|
11
|
+
export type PostTWAPDeltaOrderV2Params = Prettify<
|
|
12
|
+
Omit<
|
|
13
|
+
DeltaOrderToPostV2<'TWAPOrder'> | DeltaOrderToPostV2<'TWAPBuyOrder'>,
|
|
14
|
+
'chainId'
|
|
15
|
+
> & {
|
|
16
|
+
/** @description Must be "TWAPOrder" or "TWAPBuyOrder" */
|
|
17
|
+
onChainOrderType: TWAPOnChainOrderType;
|
|
18
|
+
degenMode?: boolean;
|
|
19
|
+
}
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
type PostTWAPDeltaOrderV2 = (
|
|
23
|
+
postData: PostTWAPDeltaOrderV2Params,
|
|
24
|
+
requestParams?: RequestParameters
|
|
25
|
+
) => Promise<DeltaAuction<'TWAPOrder'> | DeltaAuction<'TWAPBuyOrder'>>;
|
|
26
|
+
|
|
27
|
+
export type PostTWAPDeltaOrderV2Functions = {
|
|
28
|
+
postTWAPDeltaOrderV2: PostTWAPDeltaOrderV2;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const constructPostTWAPDeltaOrderV2 = ({
|
|
32
|
+
apiURL = API_URL,
|
|
33
|
+
chainId,
|
|
34
|
+
fetcher,
|
|
35
|
+
}: ConstructFetchInput): PostTWAPDeltaOrderV2Functions => {
|
|
36
|
+
const postOrderUrl = `${apiURL}/delta/v2/orders` as const;
|
|
37
|
+
|
|
38
|
+
const postTWAPDeltaOrderV2: PostTWAPDeltaOrderV2 = (
|
|
39
|
+
_postData,
|
|
40
|
+
requestParams
|
|
41
|
+
) => {
|
|
42
|
+
const { degenMode, ...postData } = _postData;
|
|
43
|
+
const deltaOrderToPost: DeltaOrderToPostV2<'TWAPOrder' | 'TWAPBuyOrder'> = {
|
|
44
|
+
...postData,
|
|
45
|
+
chainId,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const search = constructSearchString<{ degenMode?: boolean }>({
|
|
49
|
+
degenMode,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const fetchURL = `${postOrderUrl}${search}` as const;
|
|
53
|
+
|
|
54
|
+
return fetcher<DeltaAuction<'TWAPOrder'> | DeltaAuction<'TWAPBuyOrder'>>({
|
|
55
|
+
url: fetchURL,
|
|
56
|
+
method: 'POST',
|
|
57
|
+
data: deltaOrderToPost,
|
|
58
|
+
requestParams,
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return { postTWAPDeltaOrderV2 };
|
|
63
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { Address } from '../../types';
|
|
2
|
+
import type { TypedDataField } from '../common/orders/buildOrderData';
|
|
3
|
+
import type {
|
|
4
|
+
Bridge,
|
|
5
|
+
DeltaOrderType,
|
|
6
|
+
DeltaOrderUnion,
|
|
7
|
+
OnChainOrderType,
|
|
8
|
+
} from '../delta/helpers/types';
|
|
9
|
+
|
|
10
|
+
/** @description Response from POST /delta/v2/orders/build — EIP-712 typed data ready to sign. */
|
|
11
|
+
export type BuiltDeltaOrderV2 = {
|
|
12
|
+
toSign: {
|
|
13
|
+
domain: {
|
|
14
|
+
name: string;
|
|
15
|
+
version: string;
|
|
16
|
+
chainId: number;
|
|
17
|
+
verifyingContract: string;
|
|
18
|
+
};
|
|
19
|
+
/** EIP-712 type definitions keyed by type name. */
|
|
20
|
+
types: Record<string, TypedDataField[]>;
|
|
21
|
+
/** The on-chain order struct value to sign. */
|
|
22
|
+
value: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
/** EIP-712 order hash. */
|
|
25
|
+
orderHash: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** @description Token identity used across v2 endpoints. */
|
|
29
|
+
export type DeltaPriceToken = {
|
|
30
|
+
chainId: number;
|
|
31
|
+
address: Address;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @description A token amount with its USD value, used uniformly for inputs, outputs, and fees. */
|
|
35
|
+
export type DeltaTokenAmount = {
|
|
36
|
+
token: DeltaPriceToken;
|
|
37
|
+
/** @description Amount in wei. */
|
|
38
|
+
amount: string;
|
|
39
|
+
/** @description USD value of the amount. */
|
|
40
|
+
amountUSD: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** @description Bridge tag used to mark routes as recommended / fastest / best-return. */
|
|
44
|
+
export type BridgeTag = 'recommended' | 'fastest' | 'best-return';
|
|
45
|
+
|
|
46
|
+
/** @description Subset of the on-chain Bridge struct returned in v2 price responses.
|
|
47
|
+
* (the full `route` object is passed to the server when building an order). */
|
|
48
|
+
export type DeltaRouteBridgeContractParams = Omit<Bridge, 'destinationChainId'>;
|
|
49
|
+
|
|
50
|
+
/** @description Bridge details on a route. Same-chain routes carry `null` for `route.bridge`. */
|
|
51
|
+
export type DeltaRouteBridge = {
|
|
52
|
+
/** @description Bridge protocol identifier (e.g. "Across", "Relay", "Mayan"). */
|
|
53
|
+
protocol: string;
|
|
54
|
+
/** @description Estimated bridging time in milliseconds. */
|
|
55
|
+
estimatedTimeMs: number;
|
|
56
|
+
/** @description Tags for this route ("recommended", "fastest", "best-return"). May be empty. */
|
|
57
|
+
tags: BridgeTag[];
|
|
58
|
+
/** @description Bridge contract parameters as returned by the server. */
|
|
59
|
+
contractParams: DeltaRouteBridgeContractParams;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** @description A single step of a route (origin chain or destination chain). */
|
|
63
|
+
export type DeltaRouteStep = {
|
|
64
|
+
/** @description The token amount entering this step (before any per-step swap). */
|
|
65
|
+
input: DeltaTokenAmount;
|
|
66
|
+
/** @description The token amount exiting this step (after any per-step swap). */
|
|
67
|
+
output: DeltaTokenAmount;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** @description A route describes how the swap flows from origin chain to destination chain. */
|
|
71
|
+
export type DeltaRoute = {
|
|
72
|
+
/** @description Source-chain step. The on-chain Delta order's amounts come from `origin.input` and `origin.output`. */
|
|
73
|
+
origin: DeltaRouteStep;
|
|
74
|
+
/** @description Destination-chain step. For same-chain routes this mirrors `origin`. */
|
|
75
|
+
destination: DeltaRouteStep;
|
|
76
|
+
/** @description Bridge details. `null` for same-chain routes. */
|
|
77
|
+
bridge: DeltaRouteBridge | null;
|
|
78
|
+
/** @description Fee breakdown for this route. */
|
|
79
|
+
fees: {
|
|
80
|
+
/** @description Gas fee (single DeltaTokenAmount on the source chain). */
|
|
81
|
+
gas: DeltaTokenAmount;
|
|
82
|
+
/** @description Bridge fees (empty array for same-chain). */
|
|
83
|
+
bridge: DeltaTokenAmount[];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** @description v2 price response: route-based, cross-chain first. */
|
|
88
|
+
export type DeltaPriceV2 = {
|
|
89
|
+
/** @description Unique request ID for tracing. */
|
|
90
|
+
id: string;
|
|
91
|
+
/** @description Order side. */
|
|
92
|
+
side: 'SELL' | 'BUY';
|
|
93
|
+
/** @description Token the user trades (identity only — amounts live in route.origin.input). */
|
|
94
|
+
inputToken: DeltaPriceToken;
|
|
95
|
+
/** @description Token the user receives (identity only — amounts live in route.destination.output). */
|
|
96
|
+
outputToken: DeltaPriceToken;
|
|
97
|
+
/** @description Recommended route with full amounts and bridge details. */
|
|
98
|
+
route: DeltaRoute;
|
|
99
|
+
/** @description Partner info attached to this price. */
|
|
100
|
+
partner: {
|
|
101
|
+
name: string;
|
|
102
|
+
/** @description Partner fee in percent (e.g. 0.12 = 0.12%). */
|
|
103
|
+
feePercent: number;
|
|
104
|
+
};
|
|
105
|
+
/** @description Address to approve for spending the input token. */
|
|
106
|
+
spender: Address;
|
|
107
|
+
/** @description Alternative routes (other bridges). Each is a full DeltaRoute. */
|
|
108
|
+
alternatives: DeltaRoute[];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** @description A flat bridge-routes entry returned by GET /delta/v2/prices/bridge-routes. */
|
|
112
|
+
export type BridgeRoute = {
|
|
113
|
+
srcChainId: number;
|
|
114
|
+
destChainId: number;
|
|
115
|
+
/** @description Output tokens supported on the dest chain for this src→dest pair. */
|
|
116
|
+
tokens: Address[];
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/* ------------------------------------------------------------------ */
|
|
120
|
+
/* Orders v2 response shape (different from v1's DeltaAuction) */
|
|
121
|
+
/* ------------------------------------------------------------------ */
|
|
122
|
+
|
|
123
|
+
/** @description Integrator-facing order status returned by v2 order endpoints. */
|
|
124
|
+
const DeltaOrderStatusV2Map = {
|
|
125
|
+
Pending: 'PENDING',
|
|
126
|
+
AwaitingSignature: 'AWAITING_SIGNATURE',
|
|
127
|
+
Active: 'ACTIVE',
|
|
128
|
+
Suspended: 'SUSPENDED',
|
|
129
|
+
Cancelling: 'CANCELLING',
|
|
130
|
+
Bridging: 'BRIDGING',
|
|
131
|
+
Completed: 'COMPLETED',
|
|
132
|
+
Failed: 'FAILED',
|
|
133
|
+
Expired: 'EXPIRED',
|
|
134
|
+
Cancelled: 'CANCELLED',
|
|
135
|
+
Refunded: 'REFUNDED',
|
|
136
|
+
} as const;
|
|
137
|
+
|
|
138
|
+
export type DeltaOrderStatusV2 =
|
|
139
|
+
(typeof DeltaOrderStatusV2Map)[keyof typeof DeltaOrderStatusV2Map];
|
|
140
|
+
|
|
141
|
+
/** @description `OnChainOrderType` plus the synthetic `FillableOrder` label, used when a Standard `Order` is `partiallyFillable`. */
|
|
142
|
+
export type DeltaOnChainOrderTypeReported = OnChainOrderType | 'FillableOrder';
|
|
143
|
+
|
|
144
|
+
/** @description Token side on an order. SELL provides an explicit `amount`; BUY provides expected/executed amounts. */
|
|
145
|
+
export type DeltaTokenSide =
|
|
146
|
+
| {
|
|
147
|
+
chainId: number;
|
|
148
|
+
token: Address;
|
|
149
|
+
amount: string;
|
|
150
|
+
}
|
|
151
|
+
| {
|
|
152
|
+
chainId: number;
|
|
153
|
+
token: Address;
|
|
154
|
+
expectedAmount: string | null;
|
|
155
|
+
executedAmount: string | null;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/** @description A single transaction entry on a v2 order. */
|
|
159
|
+
export type DeltaTransactionV2 = {
|
|
160
|
+
originTx: string;
|
|
161
|
+
destinationTx: string | null;
|
|
162
|
+
/** @description Filled percent of the slice (0–100). */
|
|
163
|
+
filledPercent: number;
|
|
164
|
+
spentAmount: string | null;
|
|
165
|
+
receivedAmount: string | null;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/** @description Order shape returned by GET /v2/orders, /v2/orders/:id, /v2/orders/hash/:hash. */
|
|
169
|
+
export type DeltaOrderV2Response = {
|
|
170
|
+
id: string;
|
|
171
|
+
status: DeltaOrderStatusV2;
|
|
172
|
+
side: 'SELL' | 'BUY';
|
|
173
|
+
type: DeltaOrderType;
|
|
174
|
+
onChainOrderType: DeltaOnChainOrderTypeReported | null;
|
|
175
|
+
input: DeltaTokenSide;
|
|
176
|
+
output: DeltaTokenSide;
|
|
177
|
+
owner: Address;
|
|
178
|
+
beneficiary: Address;
|
|
179
|
+
orderHash: string | null;
|
|
180
|
+
partner: string;
|
|
181
|
+
order: DeltaOrderUnion;
|
|
182
|
+
transactions: DeltaTransactionV2[];
|
|
183
|
+
/** @description ISO datetime string. */
|
|
184
|
+
createdAt: string | null;
|
|
185
|
+
/** @description ISO datetime string. */
|
|
186
|
+
updatedAt: string | null;
|
|
187
|
+
/** @description ISO datetime string. */
|
|
188
|
+
expiresAt: string | null;
|
|
189
|
+
};
|
package/src/sdk/full.ts
CHANGED
|
@@ -12,6 +12,10 @@ import {
|
|
|
12
12
|
constructAllDeltaOrdersHandlers,
|
|
13
13
|
DeltaOrderHandlers,
|
|
14
14
|
} from '../methods/delta';
|
|
15
|
+
import {
|
|
16
|
+
constructAllDeltaV2OrdersHandlers,
|
|
17
|
+
DeltaV2OrderHandlers,
|
|
18
|
+
} from '../methods/deltaV2';
|
|
15
19
|
import {
|
|
16
20
|
constructGetQuote,
|
|
17
21
|
GetQuoteFunctions,
|
|
@@ -26,6 +30,7 @@ export type AllSDKMethods<TxResponse> = {
|
|
|
26
30
|
/** @deprecated NFT Orders are deprecated and will be removed in a future version. */
|
|
27
31
|
nftOrders: NFTOrderHandlers<TxResponse>;
|
|
28
32
|
delta: DeltaOrderHandlers<TxResponse>;
|
|
33
|
+
deltaV2: DeltaV2OrderHandlers<TxResponse>;
|
|
29
34
|
quote: GetQuoteFunctions;
|
|
30
35
|
} & Required<ConstructBaseInput>;
|
|
31
36
|
|
|
@@ -41,6 +46,8 @@ export const constructFullSDK = <TxResponse = any>(
|
|
|
41
46
|
constructAllNFTOrdersHandlers(config);
|
|
42
47
|
const delta: DeltaOrderHandlers<TxResponse> =
|
|
43
48
|
constructAllDeltaOrdersHandlers(config);
|
|
49
|
+
const deltaV2: DeltaV2OrderHandlers<TxResponse> =
|
|
50
|
+
constructAllDeltaV2OrdersHandlers(config);
|
|
44
51
|
const quote = constructGetQuote(config);
|
|
45
52
|
|
|
46
53
|
return {
|
|
@@ -48,6 +55,7 @@ export const constructFullSDK = <TxResponse = any>(
|
|
|
48
55
|
limitOrders,
|
|
49
56
|
nftOrders,
|
|
50
57
|
delta,
|
|
58
|
+
deltaV2,
|
|
51
59
|
quote,
|
|
52
60
|
apiURL: config.apiURL ?? API_URL,
|
|
53
61
|
chainId: config.chainId,
|
package/src/sdk/simple.ts
CHANGED
|
@@ -136,6 +136,34 @@ import {
|
|
|
136
136
|
constructIsTokenSupportedInDelta,
|
|
137
137
|
IsTokenSupportedInDeltaFunctions,
|
|
138
138
|
} from '../methods/delta/isTokenSupportedInDelta';
|
|
139
|
+
import {
|
|
140
|
+
constructAllDeltaV2OrdersHandlers,
|
|
141
|
+
DeltaV2OrderHandlers,
|
|
142
|
+
} from '../methods/deltaV2';
|
|
143
|
+
import {
|
|
144
|
+
BuildDeltaOrderV2Functions,
|
|
145
|
+
constructBuildDeltaOrderV2,
|
|
146
|
+
} from '../methods/deltaV2/buildDeltaOrderV2';
|
|
147
|
+
import {
|
|
148
|
+
constructPostDeltaOrderV2,
|
|
149
|
+
PostDeltaOrderV2Functions,
|
|
150
|
+
} from '../methods/deltaV2/postDeltaOrderV2';
|
|
151
|
+
import {
|
|
152
|
+
constructGetDeltaOrdersV2,
|
|
153
|
+
GetDeltaOrdersV2Functions,
|
|
154
|
+
} from '../methods/deltaV2/getDeltaOrdersV2';
|
|
155
|
+
import {
|
|
156
|
+
constructGetDeltaPriceV2,
|
|
157
|
+
GetDeltaPriceV2Functions,
|
|
158
|
+
} from '../methods/deltaV2/getDeltaPriceV2';
|
|
159
|
+
import {
|
|
160
|
+
constructGetBridgeRoutes,
|
|
161
|
+
GetBridgeRoutesFunctions,
|
|
162
|
+
} from '../methods/deltaV2/getBridgeRoutes';
|
|
163
|
+
import {
|
|
164
|
+
constructIsTokenSupportedInDeltaV2,
|
|
165
|
+
IsTokenSupportedInDeltaV2Functions,
|
|
166
|
+
} from '../methods/deltaV2/isTokenSupportedInDeltaV2';
|
|
139
167
|
|
|
140
168
|
export type SwapFetchMethods = GetBalancesFunctions &
|
|
141
169
|
GetTokensFunctions &
|
|
@@ -168,6 +196,15 @@ export type DeltaFetchMethods = BuildDeltaOrderFunctions &
|
|
|
168
196
|
IsTokenSupportedInDeltaFunctions &
|
|
169
197
|
PostDeltaOrderFunctions;
|
|
170
198
|
|
|
199
|
+
export type DeltaV2FetchMethods = BuildDeltaOrderV2Functions &
|
|
200
|
+
GetDeltaOrdersV2Functions &
|
|
201
|
+
GetDeltaPriceV2Functions &
|
|
202
|
+
GetDeltaContractFunctions &
|
|
203
|
+
GetPartnerFeeFunctions &
|
|
204
|
+
GetBridgeRoutesFunctions &
|
|
205
|
+
IsTokenSupportedInDeltaV2Functions &
|
|
206
|
+
PostDeltaOrderV2Functions;
|
|
207
|
+
|
|
171
208
|
export type SimpleFetchSDK = {
|
|
172
209
|
swap: SwapFetchMethods;
|
|
173
210
|
/** @deprecated Limit Orders are deprecated and will be removed in a future version. */
|
|
@@ -175,6 +212,7 @@ export type SimpleFetchSDK = {
|
|
|
175
212
|
/** @deprecated NFT Orders are deprecated and will be removed in a future version. */
|
|
176
213
|
nftOrders: NFTOrdersFetchMethods;
|
|
177
214
|
delta: DeltaFetchMethods;
|
|
215
|
+
deltaV2: DeltaV2FetchMethods;
|
|
178
216
|
quote: QuoteFetchMethods;
|
|
179
217
|
} & Required<ConstructBaseInput>;
|
|
180
218
|
|
|
@@ -187,6 +225,7 @@ export type SimpleSDK = {
|
|
|
187
225
|
/** @deprecated NFT Orders are deprecated and will be removed in a future version. */
|
|
188
226
|
nftOrders: NFTOrderHandlers<TxHash>;
|
|
189
227
|
delta: DeltaOrderHandlers<TxHash>;
|
|
228
|
+
deltaV2: DeltaV2OrderHandlers<TxHash>;
|
|
190
229
|
quote: QuoteFetchMethods;
|
|
191
230
|
} & Required<ConstructBaseInput>;
|
|
192
231
|
|
|
@@ -298,6 +337,18 @@ export function constructSimpleSDK(
|
|
|
298
337
|
constructIsTokenSupportedInDelta
|
|
299
338
|
);
|
|
300
339
|
|
|
340
|
+
const deltaV2 = constructPartialSDK(
|
|
341
|
+
config,
|
|
342
|
+
constructBuildDeltaOrderV2,
|
|
343
|
+
constructPostDeltaOrderV2,
|
|
344
|
+
constructGetDeltaOrdersV2,
|
|
345
|
+
constructGetDeltaPriceV2,
|
|
346
|
+
constructGetDeltaContract,
|
|
347
|
+
constructGetPartnerFee,
|
|
348
|
+
constructGetBridgeRoutes,
|
|
349
|
+
constructIsTokenSupportedInDeltaV2
|
|
350
|
+
);
|
|
351
|
+
|
|
301
352
|
const quote = constructPartialSDK(config, constructGetQuote);
|
|
302
353
|
|
|
303
354
|
return {
|
|
@@ -305,6 +356,7 @@ export function constructSimpleSDK(
|
|
|
305
356
|
limitOrders,
|
|
306
357
|
nftOrders,
|
|
307
358
|
delta,
|
|
359
|
+
deltaV2,
|
|
308
360
|
quote,
|
|
309
361
|
apiURL: options.apiURL ?? API_URL,
|
|
310
362
|
chainId: options.chainId,
|
|
@@ -333,6 +385,9 @@ export function constructSimpleSDK(
|
|
|
333
385
|
const delta: DeltaOrderHandlers<TxHash> =
|
|
334
386
|
constructAllDeltaOrdersHandlers<TxHash>(config);
|
|
335
387
|
|
|
388
|
+
const deltaV2: DeltaV2OrderHandlers<TxHash> =
|
|
389
|
+
constructAllDeltaV2OrdersHandlers<TxHash>(config);
|
|
390
|
+
|
|
336
391
|
const quote = constructGetQuote(config);
|
|
337
392
|
|
|
338
393
|
return {
|
|
@@ -340,6 +395,7 @@ export function constructSimpleSDK(
|
|
|
340
395
|
limitOrders,
|
|
341
396
|
nftOrders,
|
|
342
397
|
delta,
|
|
398
|
+
deltaV2,
|
|
343
399
|
quote,
|
|
344
400
|
apiURL: options.apiURL ?? API_URL,
|
|
345
401
|
chainId: options.chainId,
|
package/src/types.ts
CHANGED
|
@@ -241,3 +241,12 @@ export interface JsonFragment {
|
|
|
241
241
|
*/
|
|
242
242
|
readonly gas?: string;
|
|
243
243
|
}
|
|
244
|
+
|
|
245
|
+
/** @description Standard pagination envelope returned by paginated API endpoints. */
|
|
246
|
+
export type PaginatedResponse<T> = {
|
|
247
|
+
data: T[];
|
|
248
|
+
total: number;
|
|
249
|
+
page: number;
|
|
250
|
+
limit: number;
|
|
251
|
+
hasMore: boolean;
|
|
252
|
+
};
|