@velora-dex/sdk 9.3.2-dev.1 → 9.3.3-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velora-dex/sdk",
3
- "version": "9.3.2-dev.1",
3
+ "version": "9.3.3-dev.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/sdk.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -45,9 +45,9 @@ export const constructFetcher =
45
45
  const response = await fetch(url, {
46
46
  method,
47
47
  body,
48
+ keepalive: extra?.keepalive,
48
49
  ...requestParams,
49
50
  headers,
50
- keepalive: extra?.keepalive,
51
51
  });
52
52
 
53
53
  const data = await response.json();
@@ -29,6 +29,8 @@ export type DeltaPriceParams = {
29
29
  beneficiary?: string; // beneficiary==owner if no transferTo
30
30
  /** @description Partner string. */
31
31
  partner?: string;
32
+ /** @description Used together with `partner` if provided. Represented in basis points, 50bps=0.5% */
33
+ partnerFeeBps?: number;
32
34
  /** @description Destination Chain ID for Crosschain Orders */
33
35
  destChainId?: number;
34
36
  /** @description SELL or BUY, default is SELL */
@@ -29,17 +29,31 @@ export type SetDeltaOrderPreSignature<T> = (
29
29
  requestParams?: RequestParameters
30
30
  ) => Promise<T>;
31
31
 
32
+ export type DepositNativeAndPreSign<T> = (
33
+ orderHash: string,
34
+ overrides?: TxSendOverrides,
35
+ requestParams?: RequestParameters
36
+ ) => Promise<T>;
37
+
32
38
  export type PreSignDeltaOrder<T> = (
33
39
  signableOrderData: SignableDeltaOrderData,
34
40
  overrides?: TxSendOverrides,
35
41
  requestParams?: RequestParameters
36
42
  ) => Promise<T>;
37
43
 
44
+ export type DepositNativeAndPreSignDeltaOrder<T> = (
45
+ signableOrderData: SignableDeltaOrderData,
46
+ overrides?: TxSendOverrides,
47
+ requestParams?: RequestParameters
48
+ ) => Promise<T>;
49
+
38
50
  export type PreSignDeltaOrderFunctions<T> = {
39
51
  hashDeltaOrderTypedData: HashDeltaOrderTypedData;
40
52
  hashDeltaOrder: HashDeltaOrder;
41
53
  setDeltaOrderPreSignature: SetDeltaOrderPreSignature<T>;
42
54
  preSignDeltaOrder: PreSignDeltaOrder<T>;
55
+ depositNativeAndPreSign: DepositNativeAndPreSign<T>;
56
+ depositNativeAndPreSignDeltaOrder: DepositNativeAndPreSignDeltaOrder<T>;
43
57
  };
44
58
 
45
59
  const PreSignatureModuleAbi = [
@@ -61,6 +75,19 @@ const PreSignatureModuleAbi = [
61
75
  stateMutability: 'nonpayable',
62
76
  type: 'function',
63
77
  },
78
+ {
79
+ inputs: [
80
+ {
81
+ internalType: 'bytes32',
82
+ name: 'orderHash',
83
+ type: 'bytes32',
84
+ },
85
+ ],
86
+ name: 'depositNativeAndPreSign',
87
+ outputs: [],
88
+ stateMutability: 'payable',
89
+ type: 'function',
90
+ },
64
91
  ] as const;
65
92
 
66
93
  type AvailableMethods = ExtractAbiMethodNames<typeof PreSignatureModuleAbi>;
@@ -119,6 +146,27 @@ export const constructPreSignDeltaOrder = <T>(
119
146
  return res;
120
147
  };
121
148
 
149
+ const depositNativeAndPreSign: DepositNativeAndPreSign<T> = async (
150
+ orderHash,
151
+ overrides = {},
152
+ requestParams
153
+ ) => {
154
+ const ParaswapDelta = await getDeltaContract(requestParams);
155
+ if (!ParaswapDelta) {
156
+ throw new Error(`Delta is not available on chain ${options.chainId}`);
157
+ }
158
+
159
+ const res = await options.contractCaller.transactCall<AvailableMethods>({
160
+ address: ParaswapDelta,
161
+ abi: PreSignatureModuleAbi,
162
+ contractMethod: 'depositNativeAndPreSign',
163
+ args: [orderHash],
164
+ overrides,
165
+ });
166
+
167
+ return res;
168
+ };
169
+
122
170
  const preSignDeltaOrder: PreSignDeltaOrder<T> = async (
123
171
  signableOrderData,
124
172
  overrides = {},
@@ -133,11 +181,25 @@ export const constructPreSignDeltaOrder = <T>(
133
181
  return res;
134
182
  };
135
183
 
184
+ const depositNativeAndPreSignDeltaOrder: DepositNativeAndPreSignDeltaOrder<
185
+ T
186
+ > = async (signableOrderData, overrides = {}, requestParams) => {
187
+ const orderHash = hashDeltaOrderTypedData(signableOrderData);
188
+ const res = await depositNativeAndPreSign(
189
+ orderHash,
190
+ overrides,
191
+ requestParams
192
+ );
193
+ return res;
194
+ };
195
+
136
196
  return {
137
197
  hashDeltaOrderTypedData,
138
198
  hashDeltaOrder,
139
199
  setDeltaOrderPreSignature,
140
200
  preSignDeltaOrder,
201
+ depositNativeAndPreSign,
202
+ depositNativeAndPreSignDeltaOrder,
141
203
  };
142
204
  };
143
205
 
@@ -29,6 +29,8 @@ export type QuoteParams<M extends TradeMode = TradeMode> = {
29
29
  userAddress?: string;
30
30
  /** @description Partner string */
31
31
  partner?: string;
32
+ /** @description Used together with `partner` if provided. Represented in basis points, 50bps=0.5% */
33
+ partnerFeeBps?: number;
32
34
  /** @description Maximum price impact (in percentage) acceptable for the trade */
33
35
  maxImpact?: number;
34
36
  /** @description Maximum price impact (in USD) acceptable for the trade */
@@ -149,6 +149,8 @@ export type RateOptions = {
149
149
  excludeContractMethods?: ContractMethodByName[];
150
150
  includeContractMethods?: ContractMethodByName[];
151
151
  partner?: string;
152
+ /** @description Used together with `partner` if provided. Represented in basis points, 50bps=0.5% */
153
+ partnerFeeBps?: number;
152
154
  /** @description In %. It's a way to bypass the API price impact check (default = 15%) */
153
155
  maxImpact?: number;
154
156
  maxUSDImpact?: number;
package/src/sdk/simple.ts CHANGED
@@ -219,7 +219,11 @@ const constructFetcher = (options: FetcherOptions): FetcherFunction => {
219
219
  ...params.headers,
220
220
  ...params.requestParams?.headers,
221
221
  }
222
- : { ...options.headers, ...params.headers };
222
+ : {
223
+ ...options.headers,
224
+ ...params.headers,
225
+ ...params.requestParams?.headers,
226
+ };
223
227
 
224
228
  return options.fetcher({ ...params, headers });
225
229
  };