@velora-dex/sdk 9.3.0-dev.2 → 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 +0 -1
- package/dist/methods/delta/getBridgeInfo.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +7 -3
- package/dist/methods/delta/getDeltaPrice.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/methods/delta/helpers/types.d.ts +0 -3
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +15 -6
- 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 +15 -6
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +0 -2
- package/src/methods/delta/buildDeltaOrder.ts +5 -0
- package/src/methods/delta/getBridgeInfo.ts +1 -2
- package/src/methods/delta/getDeltaPrice.ts +6 -8
- package/src/methods/delta/helpers/buildDeltaOrderData.ts +17 -8
- package/src/methods/delta/helpers/types.ts +0 -3
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
|
@@ -174,7 +174,6 @@ import {
|
|
|
174
174
|
GetDeltaPriceFunctions,
|
|
175
175
|
DeltaPrice,
|
|
176
176
|
BridgePrice,
|
|
177
|
-
AvailableBridge,
|
|
178
177
|
DeltaPriceParams,
|
|
179
178
|
} from './methods/delta/getDeltaPrice';
|
|
180
179
|
import {
|
|
@@ -380,7 +379,6 @@ export type {
|
|
|
380
379
|
BridgeStatus,
|
|
381
380
|
Bridge,
|
|
382
381
|
BridgeInfo,
|
|
383
|
-
AvailableBridge,
|
|
384
382
|
BridgeProtocolResponse,
|
|
385
383
|
BuildDeltaOrderDataParams,
|
|
386
384
|
BuildDeltaOrderFunctions,
|
|
@@ -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
|
|
|
@@ -31,7 +31,6 @@ type GetBridgeInfo = (
|
|
|
31
31
|
export type BridgeProtocolResponse = {
|
|
32
32
|
protocol: string;
|
|
33
33
|
displayName: string;
|
|
34
|
-
icon: string; // CDN URL
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
type BridgeProtocolsResponse = {
|
|
@@ -58,7 +57,7 @@ export const constructGetBridgeInfo = ({
|
|
|
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
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Prettify } from 'viem';
|
|
2
1
|
import { Bridge } from '../..';
|
|
3
2
|
import { API_URL, SwapSide } from '../../constants';
|
|
4
3
|
import { constructSearchString } from '../../helpers/misc';
|
|
@@ -106,15 +105,14 @@ type AvailableBridgePrice = Pick<
|
|
|
106
105
|
| 'gasCost'
|
|
107
106
|
| 'gasCostUSDBeforeFee'
|
|
108
107
|
| 'gasCostBeforeFee'
|
|
109
|
-
| 'receivedDestAmount'
|
|
110
|
-
| 'receivedDestAmountBeforeFee'
|
|
111
|
-
| 'receivedDestUSD'
|
|
112
|
-
| 'receivedDestUSDBeforeFee'
|
|
113
108
|
>;
|
|
114
109
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
type AvailableBridge = AvailableBridgePrice & {
|
|
111
|
+
bridgeParams: {
|
|
112
|
+
bridge: Bridge;
|
|
113
|
+
bridgeInfo: BridgePriceInfo;
|
|
114
|
+
}[];
|
|
115
|
+
};
|
|
118
116
|
|
|
119
117
|
export type BridgePrice = Omit<DeltaPrice, 'bridge'> & {
|
|
120
118
|
// destAmountAfterBridge: string; // became bridgeInfo.destAmountAfterBridge
|
|
@@ -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
|
}
|