@velora-dex/sdk 9.2.0 → 9.3.0-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/methods/delta/getBridgeInfo.d.ts +13 -1
- package/dist/methods/delta/getBridgeInfo.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +4 -0
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +1 -2
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +58 -16
- 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 +58 -16
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/methods/delta/getBridgeInfo.ts +58 -4
- package/src/methods/delta/getDeltaPrice.ts +25 -4
- package/src/methods/delta/helpers/types.ts +1 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velora-dex/sdk",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0-dev.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/sdk.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -49,19 +49,19 @@
|
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@size-limit/preset-small-lib": "^
|
|
52
|
+
"@size-limit/preset-small-lib": "^12.0.0",
|
|
53
53
|
"@tsconfig/recommended": "^1.0.8",
|
|
54
|
-
"axios": "^1.
|
|
54
|
+
"axios": "^1.13.2",
|
|
55
55
|
"bignumber.js": "^9.1.2",
|
|
56
56
|
"dotenv": "^16.4.5",
|
|
57
57
|
"dts-cli": "^2.0.5",
|
|
58
58
|
"ethers": "^6.13.4",
|
|
59
59
|
"ethersV5": "npm:ethers@5",
|
|
60
|
-
"hardhat": "^2.
|
|
61
|
-
"hardhat-switch-network": "^1.
|
|
60
|
+
"hardhat": "^2.28.0",
|
|
61
|
+
"hardhat-switch-network": "^1.2.1",
|
|
62
62
|
"husky": "^9.1.6",
|
|
63
63
|
"isomorphic-unfetch": "^4.0.2",
|
|
64
|
-
"size-limit": "^
|
|
64
|
+
"size-limit": "^12.0.0",
|
|
65
65
|
"tslib": "^2.8.1",
|
|
66
66
|
"typedoc": "^0.26.11",
|
|
67
67
|
"typedoc-plugin-markdown": "^4.2.10",
|
|
@@ -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?: string;
|
|
23
|
+
bridges?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type GetBridgeInfo = (
|
|
27
|
+
params?: GetBridgeInfoParams,
|
|
28
|
+
requestParams?: RequestParameters
|
|
29
|
+
) => Promise<BridgeInfo>;
|
|
30
|
+
|
|
31
|
+
type BridgeProtocolResponse = {
|
|
32
|
+
protocol: string;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type BridgeProtocolsResponse = {
|
|
37
|
+
bridgeProtocols: BridgeProtocolResponse[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type GetBridgeProtocols = (
|
|
41
|
+
requestParams?: RequestParameters
|
|
42
|
+
) => Promise<BridgeProtocolResponse[]>;
|
|
14
43
|
|
|
15
44
|
export type GetBridgeInfoFunctions = {
|
|
16
45
|
getBridgeInfo: GetBridgeInfo;
|
|
46
|
+
getBridgeProtocols: GetBridgeProtocols;
|
|
17
47
|
};
|
|
18
48
|
|
|
19
49
|
export const constructGetBridgeInfo = ({
|
|
20
50
|
apiURL = API_URL,
|
|
21
51
|
fetcher,
|
|
22
52
|
}: ConstructFetchInput): GetBridgeInfoFunctions => {
|
|
23
|
-
const
|
|
53
|
+
const deltaBridgeUrl = `${apiURL}/delta/prices` as const;
|
|
54
|
+
|
|
55
|
+
const getBridgeInfo: GetBridgeInfo = async (params = {}, requestParams) => {
|
|
56
|
+
const { allowBridgeAndSwap, bridges } = params;
|
|
57
|
+
const allowBridgeAndSwapString = allowBridgeAndSwap ? 'true' : 'false';
|
|
58
|
+
const bridgesString = bridges ? bridges.join(',') : undefined;
|
|
59
|
+
|
|
60
|
+
const search = constructSearchString<BridgeInfoQuery>({
|
|
61
|
+
allowBridgeAndSwap: allowBridgeAndSwapString,
|
|
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
|
};
|
|
@@ -35,15 +35,22 @@ export type DeltaPriceParams = {
|
|
|
35
35
|
|
|
36
36
|
includeAgents?: string[];
|
|
37
37
|
excludeAgents?: string[];
|
|
38
|
+
includeBridges?: string[];
|
|
39
|
+
excludeBridges?: string[];
|
|
40
|
+
|
|
41
|
+
/** @description Allow swap on destChain after bridge. Default is true. */
|
|
42
|
+
allowBridgeAndSwap?: boolean;
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
type DeltaPriceQueryOptions = Omit<
|
|
41
46
|
DeltaPriceParams,
|
|
42
|
-
'includeAgents' | 'excludeAgents'
|
|
47
|
+
'includeAgents' | 'excludeAgents' | 'includeBridges' | 'excludeBridges'
|
|
43
48
|
> & {
|
|
44
49
|
chainId: number; // will return error from API on unsupported chains
|
|
45
50
|
includeAgents?: string;
|
|
46
51
|
excludeAgents?: string;
|
|
52
|
+
includeBridges?: string;
|
|
53
|
+
excludeBridges?: string;
|
|
47
54
|
};
|
|
48
55
|
|
|
49
56
|
// for same-chain Orders, all 0 params
|
|
@@ -91,9 +98,9 @@ type AvailableBridgePrice = Pick<
|
|
|
91
98
|
DeltaPrice,
|
|
92
99
|
| 'destToken'
|
|
93
100
|
| 'destAmount'
|
|
94
|
-
| 'destAmountBeforeFee'
|
|
101
|
+
| 'destAmountBeforeFee' // Available for SELL side
|
|
95
102
|
| 'destUSD'
|
|
96
|
-
| 'destUSDBeforeFee'
|
|
103
|
+
| 'destUSDBeforeFee' // Available for SELL side
|
|
97
104
|
| 'gasCostUSD'
|
|
98
105
|
| 'gasCost'
|
|
99
106
|
| 'gasCostUSDBeforeFee'
|
|
@@ -164,13 +171,25 @@ export const constructGetDeltaPrice = ({
|
|
|
164
171
|
options: DeltaPriceParams,
|
|
165
172
|
requestParams?: RequestParameters
|
|
166
173
|
): Promise<DeltaPrice | BridgePrice> {
|
|
167
|
-
const {
|
|
174
|
+
const {
|
|
175
|
+
includeAgents,
|
|
176
|
+
excludeAgents,
|
|
177
|
+
includeBridges,
|
|
178
|
+
excludeBridges,
|
|
179
|
+
...rest
|
|
180
|
+
} = options;
|
|
168
181
|
const includeAgentsString = includeAgents
|
|
169
182
|
? includeAgents.join(',')
|
|
170
183
|
: undefined;
|
|
171
184
|
const excludeAgentsString = excludeAgents
|
|
172
185
|
? excludeAgents.join(',')
|
|
173
186
|
: undefined;
|
|
187
|
+
const includeBridgesString = includeBridges
|
|
188
|
+
? includeBridges.join(',')
|
|
189
|
+
: undefined;
|
|
190
|
+
const excludeBridgesString = excludeBridges
|
|
191
|
+
? excludeBridges.join(',')
|
|
192
|
+
: undefined;
|
|
174
193
|
|
|
175
194
|
const search = constructSearchString<DeltaPriceQueryOptions>({
|
|
176
195
|
...rest,
|
|
@@ -178,6 +197,8 @@ export const constructGetDeltaPrice = ({
|
|
|
178
197
|
side: options.side ?? SwapSide.SELL,
|
|
179
198
|
includeAgents: includeAgentsString,
|
|
180
199
|
excludeAgents: excludeAgentsString,
|
|
200
|
+
includeBridges: includeBridgesString,
|
|
201
|
+
excludeBridges: excludeBridgesString,
|
|
181
202
|
});
|
|
182
203
|
|
|
183
204
|
const fetchURL = `${pricesUrl}/${search}` as const;
|
|
@@ -138,20 +138,6 @@ export type BridgeStatus = 'pending' | 'filled' | 'expired' | 'refunded';
|
|
|
138
138
|
|
|
139
139
|
//// available on BridgePrice ////
|
|
140
140
|
|
|
141
|
-
// so far
|
|
142
|
-
type ProtocolName =
|
|
143
|
-
| 'Across'
|
|
144
|
-
| 'StargateBus'
|
|
145
|
-
| 'StargateTaxi'
|
|
146
|
-
| 'StargateOftV2'
|
|
147
|
-
| 'Relay'
|
|
148
|
-
| 'CCTPFast'
|
|
149
|
-
| 'CCTPStandard'
|
|
150
|
-
| 'Celer'
|
|
151
|
-
| 'Canonical'
|
|
152
|
-
| 'Polygon'
|
|
153
|
-
| 'Arbitrum';
|
|
154
|
-
|
|
155
141
|
type BridgeQuoteFee = {
|
|
156
142
|
feeToken: string;
|
|
157
143
|
amount: string;
|
|
@@ -160,7 +146,7 @@ type BridgeQuoteFee = {
|
|
|
160
146
|
};
|
|
161
147
|
|
|
162
148
|
export type BridgePriceInfo = {
|
|
163
|
-
protocolName:
|
|
149
|
+
protocolName: string;
|
|
164
150
|
destAmountAfterBridge: string;
|
|
165
151
|
destUSDAfterBridge: string;
|
|
166
152
|
fees: BridgeQuoteFee[];
|