@velora-dex/sdk 9.3.0-dev.0 → 9.3.0-dev.2
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.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/delta/getBridgeInfo.d.ts +14 -1
- package/dist/methods/delta/getBridgeInfo.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaOrders.d.ts +1 -1
- package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +4 -8
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +4 -3
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/delta/postDeltaOrder.d.ts +0 -1
- package/dist/methods/delta/postDeltaOrder.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +46 -9
- 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 +46 -9
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/methods/delta/getBridgeInfo.ts +58 -4
- package/src/methods/delta/getDeltaOrders.ts +1 -1
- package/src/methods/delta/getDeltaPrice.ts +11 -9
- package/src/methods/delta/helpers/types.ts +4 -16
- package/src/methods/delta/postDeltaOrder.ts +0 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -174,6 +174,7 @@ import {
|
|
|
174
174
|
GetDeltaPriceFunctions,
|
|
175
175
|
DeltaPrice,
|
|
176
176
|
BridgePrice,
|
|
177
|
+
AvailableBridge,
|
|
177
178
|
DeltaPriceParams,
|
|
178
179
|
} from './methods/delta/getDeltaPrice';
|
|
179
180
|
import {
|
|
@@ -194,6 +195,7 @@ import {
|
|
|
194
195
|
constructGetBridgeInfo,
|
|
195
196
|
GetBridgeInfoFunctions,
|
|
196
197
|
BridgeInfo,
|
|
198
|
+
BridgeProtocolResponse,
|
|
197
199
|
} from './methods/delta/getBridgeInfo';
|
|
198
200
|
import {
|
|
199
201
|
constructIsTokenSupportedInDelta,
|
|
@@ -378,6 +380,8 @@ export type {
|
|
|
378
380
|
BridgeStatus,
|
|
379
381
|
Bridge,
|
|
380
382
|
BridgeInfo,
|
|
383
|
+
AvailableBridge,
|
|
384
|
+
BridgeProtocolResponse,
|
|
381
385
|
BuildDeltaOrderDataParams,
|
|
382
386
|
BuildDeltaOrderFunctions,
|
|
383
387
|
SignableDeltaOrderData,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { API_URL } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
2
3
|
import type {
|
|
3
4
|
Address,
|
|
4
5
|
ConstructFetchInput,
|
|
@@ -10,21 +11,61 @@ import type {
|
|
|
10
11
|
export type BridgeInfo = Record<number, Record<number, Address[]>>;
|
|
11
12
|
type BridgeInfoResponse = { supportedTokens: BridgeInfo };
|
|
12
13
|
|
|
13
|
-
type
|
|
14
|
+
type GetBridgeInfoParams = {
|
|
15
|
+
/** @description Include tokens that can be swapped on destChain after bridge. Default is true. */
|
|
16
|
+
allowBridgeAndSwap?: boolean;
|
|
17
|
+
/** @description Include only the specified bridges. Default is all bridges. */
|
|
18
|
+
bridges?: string[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type BridgeInfoQuery = {
|
|
22
|
+
allowBridgeAndSwap?: boolean;
|
|
23
|
+
bridges?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type GetBridgeInfo = (
|
|
27
|
+
params?: GetBridgeInfoParams,
|
|
28
|
+
requestParams?: RequestParameters
|
|
29
|
+
) => Promise<BridgeInfo>;
|
|
30
|
+
|
|
31
|
+
export type BridgeProtocolResponse = {
|
|
32
|
+
protocol: string;
|
|
33
|
+
displayName: string;
|
|
34
|
+
icon: string; // CDN URL
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type BridgeProtocolsResponse = {
|
|
38
|
+
bridgeProtocols: BridgeProtocolResponse[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type GetBridgeProtocols = (
|
|
42
|
+
requestParams?: RequestParameters
|
|
43
|
+
) => Promise<BridgeProtocolResponse[]>;
|
|
14
44
|
|
|
15
45
|
export type GetBridgeInfoFunctions = {
|
|
16
46
|
getBridgeInfo: GetBridgeInfo;
|
|
47
|
+
getBridgeProtocols: GetBridgeProtocols;
|
|
17
48
|
};
|
|
18
49
|
|
|
19
50
|
export const constructGetBridgeInfo = ({
|
|
20
51
|
apiURL = API_URL,
|
|
21
52
|
fetcher,
|
|
22
53
|
}: ConstructFetchInput): GetBridgeInfoFunctions => {
|
|
23
|
-
const
|
|
54
|
+
const deltaBridgeUrl = `${apiURL}/delta/prices` as const;
|
|
55
|
+
|
|
56
|
+
const getBridgeInfo: GetBridgeInfo = async (params = {}, requestParams) => {
|
|
57
|
+
const { allowBridgeAndSwap, bridges } = params;
|
|
58
|
+
const bridgesString = bridges ? bridges.join(',') : undefined;
|
|
59
|
+
|
|
60
|
+
const search = constructSearchString<BridgeInfoQuery>({
|
|
61
|
+
allowBridgeAndSwap: !!allowBridgeAndSwap,
|
|
62
|
+
bridges: bridgesString,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const fetchURL = `${deltaBridgeUrl}/bridge-info${search}` as const;
|
|
24
66
|
|
|
25
|
-
const getBridgeInfo: GetBridgeInfo = async (requestParams) => {
|
|
26
67
|
const data = await fetcher<BridgeInfoResponse>({
|
|
27
|
-
url:
|
|
68
|
+
url: fetchURL,
|
|
28
69
|
method: 'GET',
|
|
29
70
|
requestParams,
|
|
30
71
|
});
|
|
@@ -32,7 +73,20 @@ export const constructGetBridgeInfo = ({
|
|
|
32
73
|
return data.supportedTokens;
|
|
33
74
|
};
|
|
34
75
|
|
|
76
|
+
const getBridgeProtocols: GetBridgeProtocols = async (requestParams) => {
|
|
77
|
+
const fetchURL = `${deltaBridgeUrl}/bridge-protocols` as const;
|
|
78
|
+
|
|
79
|
+
const data = await fetcher<BridgeProtocolsResponse>({
|
|
80
|
+
url: fetchURL,
|
|
81
|
+
method: 'GET',
|
|
82
|
+
requestParams,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return data.bridgeProtocols;
|
|
86
|
+
};
|
|
87
|
+
|
|
35
88
|
return {
|
|
36
89
|
getBridgeInfo,
|
|
90
|
+
getBridgeProtocols,
|
|
37
91
|
};
|
|
38
92
|
};
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
} from '../../types';
|
|
8
8
|
import type { DeltaAuction, DeltaAuctionStatus } from './helpers/types';
|
|
9
9
|
|
|
10
|
-
export type DeltaOrderFromAPI = Omit<DeltaAuction, 'signature'
|
|
10
|
+
export type DeltaOrderFromAPI = Omit<DeltaAuction, 'signature'>;
|
|
11
11
|
|
|
12
12
|
export type DeltaOrderFilterByStatus =
|
|
13
13
|
| DeltaAuctionStatus
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Prettify } from 'viem';
|
|
1
2
|
import { Bridge } from '../..';
|
|
2
3
|
import { API_URL, SwapSide } from '../../constants';
|
|
3
4
|
import { constructSearchString } from '../../helpers/misc';
|
|
@@ -39,7 +40,7 @@ export type DeltaPriceParams = {
|
|
|
39
40
|
excludeBridges?: string[];
|
|
40
41
|
|
|
41
42
|
/** @description Allow swap on destChain after bridge. Default is true. */
|
|
42
|
-
|
|
43
|
+
allowBridgeAndSwap?: boolean;
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
type DeltaPriceQueryOptions = Omit<
|
|
@@ -98,21 +99,22 @@ type AvailableBridgePrice = Pick<
|
|
|
98
99
|
DeltaPrice,
|
|
99
100
|
| 'destToken'
|
|
100
101
|
| 'destAmount'
|
|
101
|
-
| 'destAmountBeforeFee'
|
|
102
|
+
| 'destAmountBeforeFee' // Available for SELL side
|
|
102
103
|
| 'destUSD'
|
|
103
|
-
| 'destUSDBeforeFee'
|
|
104
|
+
| 'destUSDBeforeFee' // Available for SELL side
|
|
104
105
|
| 'gasCostUSD'
|
|
105
106
|
| 'gasCost'
|
|
106
107
|
| 'gasCostUSDBeforeFee'
|
|
107
108
|
| 'gasCostBeforeFee'
|
|
109
|
+
| 'receivedDestAmount'
|
|
110
|
+
| 'receivedDestAmountBeforeFee'
|
|
111
|
+
| 'receivedDestUSD'
|
|
112
|
+
| 'receivedDestUSDBeforeFee'
|
|
108
113
|
>;
|
|
109
114
|
|
|
110
|
-
type AvailableBridge =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
bridgeInfo: BridgePriceInfo;
|
|
114
|
-
}[];
|
|
115
|
-
};
|
|
115
|
+
export type AvailableBridge = Prettify<
|
|
116
|
+
AvailableBridgePrice & Pick<BridgePrice, 'bridge' | 'bridgeInfo'>
|
|
117
|
+
>;
|
|
116
118
|
|
|
117
119
|
export type BridgePrice = Omit<DeltaPrice, 'bridge'> & {
|
|
118
120
|
// destAmountAfterBridge: string; // became bridgeInfo.destAmountAfterBridge
|
|
@@ -95,7 +95,6 @@ export type DeltaAuction = {
|
|
|
95
95
|
deltaVersion: string; // 1.0 or 2.0 currently
|
|
96
96
|
user: string;
|
|
97
97
|
signature: string;
|
|
98
|
-
cosignature: string; // added for Crosschain Orders after bridge
|
|
99
98
|
status: DeltaAuctionStatus;
|
|
100
99
|
order: DeltaAuctionOrder;
|
|
101
100
|
orderHash: string | null; // not available on old Orders only
|
|
@@ -139,20 +138,6 @@ export type BridgeStatus = 'pending' | 'filled' | 'expired' | 'refunded';
|
|
|
139
138
|
|
|
140
139
|
//// available on BridgePrice ////
|
|
141
140
|
|
|
142
|
-
// so far
|
|
143
|
-
type ProtocolName =
|
|
144
|
-
| 'Across'
|
|
145
|
-
| 'StargateBus'
|
|
146
|
-
| 'StargateTaxi'
|
|
147
|
-
| 'StargateOftV2'
|
|
148
|
-
| 'Relay'
|
|
149
|
-
| 'CCTPFast'
|
|
150
|
-
| 'CCTPStandard'
|
|
151
|
-
| 'Celer'
|
|
152
|
-
| 'Canonical'
|
|
153
|
-
| 'Polygon'
|
|
154
|
-
| 'Arbitrum';
|
|
155
|
-
|
|
156
141
|
type BridgeQuoteFee = {
|
|
157
142
|
feeToken: string;
|
|
158
143
|
amount: string;
|
|
@@ -161,9 +146,12 @@ type BridgeQuoteFee = {
|
|
|
161
146
|
};
|
|
162
147
|
|
|
163
148
|
export type BridgePriceInfo = {
|
|
164
|
-
protocolName:
|
|
149
|
+
protocolName: string;
|
|
165
150
|
destAmountAfterBridge: string;
|
|
166
151
|
destUSDAfterBridge: string;
|
|
167
152
|
fees: BridgeQuoteFee[];
|
|
168
153
|
estimatedTimeMs: number;
|
|
154
|
+
fastest: boolean;
|
|
155
|
+
bestReturn: boolean;
|
|
156
|
+
recommended: boolean;
|
|
169
157
|
};
|