@velora-dex/sdk 9.3.0-dev.1 → 9.3.0
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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/delta/buildDeltaOrder.d.ts +2 -0
- package/dist/methods/delta/buildDeltaOrder.d.ts.map +1 -1
- package/dist/methods/delta/getBridgeInfo.d.ts +1 -1
- package/dist/methods/delta/getBridgeInfo.d.ts.map +1 -1
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts +2 -1
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +19 -11
- 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 +19 -11
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/methods/delta/buildDeltaOrder.ts +5 -0
- package/src/methods/delta/getBridgeInfo.ts +3 -4
- package/src/methods/delta/helpers/buildDeltaOrderData.ts +17 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velora-dex/sdk",
|
|
3
|
-
"version": "9.3.0
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/sdk.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@paraswap/core": "2.4.
|
|
96
|
+
"@paraswap/core": "2.4.1",
|
|
97
97
|
"ts-essentials": "^10.0.3",
|
|
98
98
|
"viem": "^2.21.0"
|
|
99
99
|
},
|
package/src/index.ts
CHANGED
|
@@ -194,6 +194,7 @@ import {
|
|
|
194
194
|
constructGetBridgeInfo,
|
|
195
195
|
GetBridgeInfoFunctions,
|
|
196
196
|
BridgeInfo,
|
|
197
|
+
BridgeProtocolResponse,
|
|
197
198
|
} from './methods/delta/getBridgeInfo';
|
|
198
199
|
import {
|
|
199
200
|
constructIsTokenSupportedInDelta,
|
|
@@ -378,6 +379,7 @@ export type {
|
|
|
378
379
|
BridgeStatus,
|
|
379
380
|
Bridge,
|
|
380
381
|
BridgeInfo,
|
|
382
|
+
BridgeProtocolResponse,
|
|
381
383
|
BuildDeltaOrderDataParams,
|
|
382
384
|
BuildDeltaOrderFunctions,
|
|
383
385
|
SignableDeltaOrderData,
|
|
@@ -65,6 +65,9 @@ export type BuildDeltaOrderDataParams = {
|
|
|
65
65
|
/** @description take surplus */
|
|
66
66
|
partnerTakesSurplus?: boolean;
|
|
67
67
|
|
|
68
|
+
/** @description A boolean indicating whether the surplus should be capped. True by default */
|
|
69
|
+
capSurplus?: boolean;
|
|
70
|
+
|
|
68
71
|
/** @description The side of the order. Default is SELL */
|
|
69
72
|
side?: SwapSideUnion;
|
|
70
73
|
/** @description Metadata for the order, hex string */
|
|
@@ -164,6 +167,8 @@ export const constructBuildDeltaOrder = (
|
|
|
164
167
|
partnerTakesSurplus,
|
|
165
168
|
partnerFeeBps,
|
|
166
169
|
|
|
170
|
+
capSurplus: options.capSurplus,
|
|
171
|
+
|
|
167
172
|
bridge: options.deltaPrice.bridge, // ZERO_BRIDGE for same-chain Orders
|
|
168
173
|
};
|
|
169
174
|
|
|
@@ -19,7 +19,7 @@ type GetBridgeInfoParams = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
type BridgeInfoQuery = {
|
|
22
|
-
allowBridgeAndSwap?:
|
|
22
|
+
allowBridgeAndSwap?: boolean;
|
|
23
23
|
bridges?: string;
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -28,7 +28,7 @@ type GetBridgeInfo = (
|
|
|
28
28
|
requestParams?: RequestParameters
|
|
29
29
|
) => Promise<BridgeInfo>;
|
|
30
30
|
|
|
31
|
-
type BridgeProtocolResponse = {
|
|
31
|
+
export type BridgeProtocolResponse = {
|
|
32
32
|
protocol: string;
|
|
33
33
|
displayName: string;
|
|
34
34
|
};
|
|
@@ -54,11 +54,10 @@ export const constructGetBridgeInfo = ({
|
|
|
54
54
|
|
|
55
55
|
const getBridgeInfo: GetBridgeInfo = async (params = {}, requestParams) => {
|
|
56
56
|
const { allowBridgeAndSwap, bridges } = params;
|
|
57
|
-
const allowBridgeAndSwapString = allowBridgeAndSwap ? 'true' : 'false';
|
|
58
57
|
const bridgesString = bridges ? bridges.join(',') : undefined;
|
|
59
58
|
|
|
60
59
|
const search = constructSearchString<BridgeInfoQuery>({
|
|
61
|
-
allowBridgeAndSwap
|
|
60
|
+
allowBridgeAndSwap,
|
|
62
61
|
bridges: bridgesString,
|
|
63
62
|
});
|
|
64
63
|
|
|
@@ -94,6 +94,7 @@ export type BuildDeltaOrderDataInput = MarkOptional<
|
|
|
94
94
|
paraswapDeltaAddress: string;
|
|
95
95
|
partnerFeeBps: number;
|
|
96
96
|
partnerTakesSurplus?: boolean;
|
|
97
|
+
capSurplus?: boolean;
|
|
97
98
|
chainId: number;
|
|
98
99
|
bridge: Bridge;
|
|
99
100
|
};
|
|
@@ -122,6 +123,7 @@ export function buildDeltaSignableOrderData({
|
|
|
122
123
|
partnerAddress,
|
|
123
124
|
partnerFeeBps,
|
|
124
125
|
partnerTakesSurplus = false,
|
|
126
|
+
capSurplus = true,
|
|
125
127
|
|
|
126
128
|
chainId,
|
|
127
129
|
paraswapDeltaAddress,
|
|
@@ -142,6 +144,7 @@ export function buildDeltaSignableOrderData({
|
|
|
142
144
|
partnerFeeBps,
|
|
143
145
|
partnerAddress,
|
|
144
146
|
partnerTakesSurplus,
|
|
147
|
+
capSurplus,
|
|
145
148
|
}),
|
|
146
149
|
bridge,
|
|
147
150
|
kind,
|
|
@@ -159,6 +162,7 @@ type ProducePartnerAndFeeInput = {
|
|
|
159
162
|
partnerFeeBps: number;
|
|
160
163
|
partnerAddress: string;
|
|
161
164
|
partnerTakesSurplus: boolean;
|
|
165
|
+
capSurplus: boolean;
|
|
162
166
|
};
|
|
163
167
|
|
|
164
168
|
// fee and address are encoded together
|
|
@@ -166,13 +170,18 @@ function producePartnerAndFee({
|
|
|
166
170
|
partnerFeeBps,
|
|
167
171
|
partnerAddress,
|
|
168
172
|
partnerTakesSurplus,
|
|
173
|
+
capSurplus,
|
|
169
174
|
}: ProducePartnerAndFeeInput): string {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
const capSurplusShifted = BigInt(capSurplus) << BigInt(9);
|
|
176
|
+
if (partnerAddress === ZERO_ADDRESS) {
|
|
177
|
+
return capSurplusShifted.toString(10);
|
|
178
|
+
} else {
|
|
179
|
+
const partnerAndFee =
|
|
180
|
+
(BigInt(partnerAddress) << BigInt(96)) |
|
|
181
|
+
BigInt(partnerFeeBps.toFixed(0)) |
|
|
182
|
+
(BigInt(partnerTakesSurplus) << BigInt(8)) |
|
|
183
|
+
capSurplusShifted;
|
|
184
|
+
|
|
185
|
+
return partnerAndFee.toString(10);
|
|
186
|
+
}
|
|
178
187
|
}
|