@flashnet/sdk 0.3.12-rc.4 → 0.3.12-rc.5
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/cjs/src/api/typed-endpoints.d.ts +23 -2
- package/dist/cjs/src/api/typed-endpoints.d.ts.map +1 -1
- package/dist/cjs/src/api/typed-endpoints.js +33 -3
- package/dist/cjs/src/api/typed-endpoints.js.map +1 -1
- package/dist/cjs/src/client/FlashnetClient.d.ts +76 -5
- package/dist/cjs/src/client/FlashnetClient.d.ts.map +1 -1
- package/dist/cjs/src/client/FlashnetClient.js +214 -19
- package/dist/cjs/src/client/FlashnetClient.js.map +1 -1
- package/dist/cjs/src/types/index.d.ts +225 -14
- package/dist/cjs/src/types/index.d.ts.map +1 -1
- package/dist/cjs/src/types/index.js +38 -0
- package/dist/cjs/src/types/index.js.map +1 -1
- package/dist/cjs/src/utils/intents.d.ts +40 -5
- package/dist/cjs/src/utils/intents.d.ts.map +1 -1
- package/dist/cjs/src/utils/intents.js +60 -11
- package/dist/cjs/src/utils/intents.js.map +1 -1
- package/dist/esm/src/api/typed-endpoints.d.ts +23 -2
- package/dist/esm/src/api/typed-endpoints.d.ts.map +1 -1
- package/dist/esm/src/api/typed-endpoints.js +33 -3
- package/dist/esm/src/api/typed-endpoints.js.map +1 -1
- package/dist/esm/src/client/FlashnetClient.d.ts +76 -5
- package/dist/esm/src/client/FlashnetClient.d.ts.map +1 -1
- package/dist/esm/src/client/FlashnetClient.js +215 -20
- package/dist/esm/src/client/FlashnetClient.js.map +1 -1
- package/dist/esm/src/types/index.d.ts +225 -14
- package/dist/esm/src/types/index.d.ts.map +1 -1
- package/dist/esm/src/types/index.js +39 -1
- package/dist/esm/src/types/index.js.map +1 -1
- package/dist/esm/src/utils/intents.d.ts +40 -5
- package/dist/esm/src/utils/intents.d.ts.map +1 -1
- package/dist/esm/src/utils/intents.js +58 -12
- package/dist/esm/src/utils/intents.js.map +1 -1
- package/package.json +1 -1
|
@@ -150,8 +150,6 @@ export declare class TypedAmmApi {
|
|
|
150
150
|
* @requires Bearer token
|
|
151
151
|
*/
|
|
152
152
|
getIntegratorFees(): Promise<Types.GetIntegratorFeesResponse>;
|
|
153
|
-
/**
|
|
154
|
-
* Get pool integrator fees
|
|
155
153
|
/**
|
|
156
154
|
* Get pool integrator fees
|
|
157
155
|
* @GET /v1/integrators/pool-fees/{poolId}
|
|
@@ -164,6 +162,29 @@ export declare class TypedAmmApi {
|
|
|
164
162
|
* @requires Bearer token
|
|
165
163
|
*/
|
|
166
164
|
withdrawIntegratorFees(request: Types.WithdrawIntegratorFeesRequest): Promise<Types.WithdrawIntegratorFeesResponse>;
|
|
165
|
+
/**
|
|
166
|
+
* Create a new escrow contract
|
|
167
|
+
* @POST /v1/escrows/create
|
|
168
|
+
* @requires Bearer token
|
|
169
|
+
*/
|
|
170
|
+
createEscrow(request: Types.CreateEscrowRequest): Promise<Types.CreateEscrowResponse>;
|
|
171
|
+
/**
|
|
172
|
+
* Fund an existing escrow contract
|
|
173
|
+
* @POST /v1/escrows/fund
|
|
174
|
+
* @requires Bearer token
|
|
175
|
+
*/
|
|
176
|
+
fundEscrow(request: Types.FundEscrowRequest): Promise<Types.FundEscrowResponse>;
|
|
177
|
+
/**
|
|
178
|
+
* Claim funds from an escrow contract
|
|
179
|
+
* @POST /v1/escrows/claim
|
|
180
|
+
* @requires Bearer token
|
|
181
|
+
*/
|
|
182
|
+
claimEscrow(request: Types.ClaimEscrowRequest): Promise<Types.ClaimEscrowResponse>;
|
|
183
|
+
/**
|
|
184
|
+
* Get the state of an escrow contract
|
|
185
|
+
* @GET /v1/escrows/{escrowId}
|
|
186
|
+
*/
|
|
187
|
+
getEscrow(escrowId: string): Promise<Types.EscrowState>;
|
|
167
188
|
/**
|
|
168
189
|
* Ping settlement service
|
|
169
190
|
* @GET /v1/ping
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-endpoints.d.ts","sourceRoot":"","sources":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;IACG,iBAAiB,IAAI,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC;IAMnE;;;;OAIG;IACG,qBAAqB,CACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC;IAM/C;;;;OAIG;IACG,sBAAsB,CAC1B,OAAO,EAAE,KAAK,CAAC,6BAA6B,GAC3C,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC;IAShD;;;;OAIG;IACG,YAAY,CAChB,OAAO,EAAE,KAAK,CAAC,mBAAmB,GACjC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAOtC;;;;OAIG;IACG,UAAU,CACd,OAAO,EAAE,KAAK,CAAC,iBAAiB,GAC/B,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC;IAOpC;;;;OAIG;IACG,WAAW,CACf,OAAO,EAAE,KAAK,CAAC,kBAAkB,GAChC,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC;IAOrC;;;OAGG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC;IAM7D;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC;CAGpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,KAAK,CAAC,qBAAqB,CAStC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,gBAAgB,CAO1E"}
|
|
@@ -215,15 +215,13 @@ class TypedAmmApi {
|
|
|
215
215
|
async getIntegratorFees() {
|
|
216
216
|
return this.client.ammGet("/v1/hosts/integrator-fees");
|
|
217
217
|
}
|
|
218
|
-
/**
|
|
219
|
-
* Get pool integrator fees
|
|
220
218
|
/**
|
|
221
219
|
* Get pool integrator fees
|
|
222
220
|
* @GET /v1/integrators/pool-fees/{poolId}
|
|
223
221
|
* @requires Bearer token
|
|
224
222
|
*/
|
|
225
223
|
async getPoolIntegratorFees(poolId) {
|
|
226
|
-
return this.client.ammGet(`/v1/
|
|
224
|
+
return this.client.ammGet(`/v1/hosts/pool-integrator-fees/${poolId}`);
|
|
227
225
|
}
|
|
228
226
|
/**
|
|
229
227
|
* Withdraw integrator fees
|
|
@@ -233,6 +231,38 @@ class TypedAmmApi {
|
|
|
233
231
|
async withdrawIntegratorFees(request) {
|
|
234
232
|
return this.client.ammPost("/v1/integrators/withdraw-fees", request);
|
|
235
233
|
}
|
|
234
|
+
// ===== Escrow Endpoints =====
|
|
235
|
+
/**
|
|
236
|
+
* Create a new escrow contract
|
|
237
|
+
* @POST /v1/escrows/create
|
|
238
|
+
* @requires Bearer token
|
|
239
|
+
*/
|
|
240
|
+
async createEscrow(request) {
|
|
241
|
+
return this.client.ammPost("/v1/escrows/create", request);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Fund an existing escrow contract
|
|
245
|
+
* @POST /v1/escrows/fund
|
|
246
|
+
* @requires Bearer token
|
|
247
|
+
*/
|
|
248
|
+
async fundEscrow(request) {
|
|
249
|
+
return this.client.ammPost("/v1/escrows/fund", request);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Claim funds from an escrow contract
|
|
253
|
+
* @POST /v1/escrows/claim
|
|
254
|
+
* @requires Bearer token
|
|
255
|
+
*/
|
|
256
|
+
async claimEscrow(request) {
|
|
257
|
+
return this.client.ammPost("/v1/escrows/claim", request);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Get the state of an escrow contract
|
|
261
|
+
* @GET /v1/escrows/{escrowId}
|
|
262
|
+
*/
|
|
263
|
+
async getEscrow(escrowId) {
|
|
264
|
+
return this.client.ammGet(`/v1/escrows/${escrowId}`);
|
|
265
|
+
}
|
|
236
266
|
// ===== Status Endpoints =====
|
|
237
267
|
/**
|
|
238
268
|
* Ping settlement service
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-endpoints.js","sources":["../../../../../../src/api/typed-endpoints.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;AAEG;MACU,WAAW,CAAA;AACF,IAAA,MAAA;AAApB,IAAA,WAAA,CAAoB,MAAiB,EAAA;QAAjB,IAAA,CAAA,MAAM,GAAN,MAAM;IAAc;;AAIxC;;;AAGG;IACH,MAAM,YAAY,CAChB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,oBAAoB,EACpB,OAAO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,MAAM,CAAC,OAA4B,EAAA;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,iBAAiB,EACjB,OAAO,CACR;IACH;;AAIA;;;;AAIG;IACH,MAAM,YAAY,CAChB,OAAkC,EAAA;QAElC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,oBAAoB,EACpB,OAAO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,OAAO,CAAC,SAAiB,EAAA;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAwB,CAAA,UAAA,EAAa,SAAS,CAAA,CAAE,CAAC;IAC5E;AAEA;;;;AAIG;IACH,MAAM,gBAAgB,CACpB,OAAsC,EAAA;QAEtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,yBAAyB,EACzB,OAAO,CACR;IACH;AAEA;;;;AAIG;IACH,MAAM,eAAe,CACnB,OAAqC,EAAA;QAErC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,qBAAqB,EACrB,OAAO,CACR;IACH;AAEA;;;;AAIG;IACH,MAAM,WAAW,CACf,OAAiC,EAAA;QAEjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,qBAAqB,EACrB,OAAO,CACR;IACH;;AAIA;;;;AAIG;IACH,MAAM,yBAAyB,CAC7B,OAA+C,EAAA;QAE/C,OAAO,IAAI,CAAC,MAAM,C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AO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,iBAAiB,CACrB,OAAuC,EAAA;QAEvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,yBAAyB,EACzB,OAAO,CACR;IACH;;AAIA;;;;AAIG;AACH,IAAA,MAAM,iBAAiB,GAAA;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CACvB,2BAA2B,CAC5B;IACH;AAEA
|
|
1
|
+
{"version":3,"file":"typed-endpoints.js","sources":["../../../../../../src/api/typed-endpoints.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;AAEG;MACU,WAAW,CAAA;AACF,IAAA,MAAA;AAApB,IAAA,WAAA,CAAoB,MAAiB,EAAA;QAAjB,IAAA,CAAA,MAAM,GAAN,MAAM;IAAc;;AAIxC;;;AAGG;IACH,MAAM,YAAY,CAChB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,oBAAoB,EACpB,OAAO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,MAAM,CAAC,OAA4B,EAAA;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,iBAAiB,EACjB,OAAO,CACR;IACH;;AAIA;;;;AAIG;IACH,MAAM,YAAY,CAChB,OAAkC,EAAA;QAElC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,oBAAoB,EACpB,OAAO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,OAAO,CAAC,SAAiB,EAAA;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAwB,CAAA,UAAA,EAAa,SAAS,CAAA,CAAE,CAAC;IAC5E;AAEA;;;;AAIG;IACH,MAAM,gBAAgB,CACpB,OAAsC,EAAA;QAEtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,yBAAyB,EACzB,OAAO,CACR;IACH;AAEA;;;;AAIG;IACH,MAAM,eAAe,CACnB,OAAqC,EAAA;QAErC,OAAO,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;;AAGG;IACH,MAAM,SAAS,CAAC,QAAgB,EAAA;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAoB,CAAA,YAAA,EAAe,QAAQ,CAAA,CAAE,CAAC;IACzE;;AAIA;;;AAGG;AACH,IAAA,MAAM,IAAI,GAAA;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAA+B,UAAU,CAAC;IACrE;AACD;AAED;;AAEG;AACG,SAAU,eAAe,CAC7B,KAAc,EAAA;AAEd,IAAA,QACE,OAAO,KAAK,KAAK,QAAQ;AACzB,QAAA,KAAK,KAAK,IAAI;AACd,QAAA,MAAM,IAAI,KAAK;AACf,QAAA,KAAK,IAAI,KAAK;AACd,QAAA,OAAQ,KAAa,CAAC,IAAI,KAAK,QAAQ;AACvC,QAAA,OAAQ,KAAa,CAAC,GAAG,KAAK,QAAQ;AAE1C;AAEM,SAAU,UAAU,CAAC,KAAc,EAAA;AACvC,IAAA,QACE,OAAO,KAAK,KAAK,QAAQ;AACzB,QAAA,KAAK,KAAK,IAAI;AACd,QAAA,OAAO,IAAI,KAAK;AAChB,QAAA,OAAQ,KAAa,CAAC,KAAK,KAAK,QAAQ;AAE5C;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IssuerSparkWallet } from "@buildonspark/issuer-sdk";
|
|
2
2
|
import type { SparkWallet } from "@buildonspark/spark-sdk";
|
|
3
|
-
import { type AddLiquidityResponse, type AllLpPositionsResponse, type ClientEnvironment, type ConfirmDepositResponse, type CreatePoolResponse, type ExecuteRouteSwapResponse, type FlashnetClientConfig, type FlashnetClientCustomConfig, type FlashnetClientEnvironmentConfig, type FlashnetClientLegacyConfig, type GetHostFeesResponse, type GetHostResponse, type GetIntegratorFeesResponse, type GetPoolHostFeesResponse, type ListGlobalSwapsQuery, type ListGlobalSwapsResponse, type ListPoolSwapsQuery, type ListPoolSwapsResponse, type ListPoolsQuery, type ListPoolsResponse, type ListUserSwapsQuery, type ListUserSwapsResponse, type LpPositionDetailsResponse, type NetworkType, type PoolDetailsResponse, type RegisterHostResponse, type RemoveLiquidityResponse, type SettlementPingResponse, type SimulateAddLiquidityRequest, type SimulateAddLiquidityResponse, type SimulateRemoveLiquidityRequest, type SimulateRemoveLiquidityResponse, type SimulateRouteSwapRequest, type SimulateRouteSwapResponse, type SimulateSwapRequest, type SimulateSwapResponse, type SparkNetworkType, type SwapResponse, type TransferAssetRecipient, type WithdrawHostFeesResponse, type WithdrawIntegratorFeesResponse } from "../types";
|
|
3
|
+
import { type AddLiquidityResponse, type AllLpPositionsResponse, type ClaimEscrowResponse, type ClientEnvironment, type Condition, type ConfirmDepositResponse, type CreateEscrowResponse, type CreatePoolResponse, type EscrowState, type ExecuteRouteSwapResponse, type FlashnetClientConfig, type FlashnetClientCustomConfig, type FlashnetClientEnvironmentConfig, type FlashnetClientLegacyConfig, type FundEscrowResponse, type GetHostFeesResponse, type GetHostResponse, type GetIntegratorFeesResponse, type GetPoolHostFeesResponse, type ListGlobalSwapsQuery, type ListGlobalSwapsResponse, type ListPoolSwapsQuery, type ListPoolSwapsResponse, type ListPoolsQuery, type ListPoolsResponse, type ListUserSwapsQuery, type ListUserSwapsResponse, type LpPositionDetailsResponse, type NetworkType, type PoolDetailsResponse, type RegisterHostResponse, type RemoveLiquidityResponse, type SettlementPingResponse, type SimulateAddLiquidityRequest, type SimulateAddLiquidityResponse, type SimulateRemoveLiquidityRequest, type SimulateRemoveLiquidityResponse, type SimulateRouteSwapRequest, type SimulateRouteSwapResponse, type SimulateSwapRequest, type SimulateSwapResponse, type SparkNetworkType, type SwapResponse, type TransferAssetRecipient, type WithdrawHostFeesResponse, type WithdrawIntegratorFeesResponse } from "../types";
|
|
4
4
|
import { type SparkHumanReadableTokenIdentifier } from "../utils/tokenAddress";
|
|
5
5
|
export interface TokenBalance {
|
|
6
6
|
balance: bigint;
|
|
@@ -165,8 +165,32 @@ export declare class FlashnetClient {
|
|
|
165
165
|
initialLiquidity?: {
|
|
166
166
|
assetAAmount: bigint;
|
|
167
167
|
assetBAmount: bigint;
|
|
168
|
+
assetAMinAmountIn: bigint;
|
|
169
|
+
assetBMinAmountIn: bigint;
|
|
168
170
|
};
|
|
169
171
|
}): Promise<CreatePoolResponse>;
|
|
172
|
+
/**
|
|
173
|
+
* Calculates virtual reserves for a bonding curve AMM.
|
|
174
|
+
*
|
|
175
|
+
* This helper function calculates the initial virtual reserves (`v_A^0`, `v_B^0`)
|
|
176
|
+
* based on the bonding curve parameters. These virtual reserves ensure smooth
|
|
177
|
+
* pricing and price continuity during graduation to the double-sided phase.
|
|
178
|
+
*
|
|
179
|
+
* @param params - The parameters for the calculation.
|
|
180
|
+
* @param params.initialTokenSupply - The initial supply of Asset A (tokens to be sold).
|
|
181
|
+
* @param params.graduationThresholdPct - The percentage of tokens that need to be sold for graduation (20-95%).
|
|
182
|
+
* @param params.targetRaise - The target amount of Asset B to raise at graduation.
|
|
183
|
+
* @returns An object containing `virtualReserveA`, `virtualReserveB`, and `threshold`.
|
|
184
|
+
*/
|
|
185
|
+
static calculateVirtualReserves(params: {
|
|
186
|
+
initialTokenSupply: number | string;
|
|
187
|
+
graduationThresholdPct: number;
|
|
188
|
+
targetRaise: number | string;
|
|
189
|
+
}): {
|
|
190
|
+
virtualReserveA: number;
|
|
191
|
+
virtualReserveB: number;
|
|
192
|
+
threshold: number;
|
|
193
|
+
};
|
|
170
194
|
/**
|
|
171
195
|
* Create a single-sided pool with automatic initial deposit
|
|
172
196
|
*
|
|
@@ -177,8 +201,9 @@ export declare class FlashnetClient {
|
|
|
177
201
|
assetAAddress: string;
|
|
178
202
|
assetBAddress: string;
|
|
179
203
|
assetAInitialReserve: string;
|
|
180
|
-
|
|
181
|
-
|
|
204
|
+
virtualReserveA: string;
|
|
205
|
+
virtualReserveB: string;
|
|
206
|
+
threshold: string;
|
|
182
207
|
lpFeeRateBps: number;
|
|
183
208
|
totalHostFeeRateBps: number;
|
|
184
209
|
hostNamespace?: string;
|
|
@@ -251,6 +276,8 @@ export declare class FlashnetClient {
|
|
|
251
276
|
poolId: string;
|
|
252
277
|
assetAAmount: string;
|
|
253
278
|
assetBAmount: string;
|
|
279
|
+
assetAMinAmountIn: string;
|
|
280
|
+
assetBMinAmountIn: string;
|
|
254
281
|
}): Promise<AddLiquidityResponse>;
|
|
255
282
|
/**
|
|
256
283
|
* Simulate removing liquidity
|
|
@@ -284,7 +311,6 @@ export declare class FlashnetClient {
|
|
|
284
311
|
*/
|
|
285
312
|
withdrawHostFees(params: {
|
|
286
313
|
lpIdentityPublicKey: string;
|
|
287
|
-
assetAAmount?: string;
|
|
288
314
|
assetBAmount?: string;
|
|
289
315
|
}): Promise<WithdrawHostFeesResponse>;
|
|
290
316
|
/**
|
|
@@ -296,13 +322,58 @@ export declare class FlashnetClient {
|
|
|
296
322
|
*/
|
|
297
323
|
withdrawIntegratorFees(params: {
|
|
298
324
|
lpIdentityPublicKey: string;
|
|
299
|
-
assetAAmount?: string;
|
|
300
325
|
assetBAmount?: string;
|
|
301
326
|
}): Promise<WithdrawIntegratorFeesResponse>;
|
|
302
327
|
/**
|
|
303
328
|
* Get integrator fees across all pools
|
|
304
329
|
*/
|
|
305
330
|
getIntegratorFees(): Promise<GetIntegratorFeesResponse>;
|
|
331
|
+
/**
|
|
332
|
+
* Creates a new escrow contract.
|
|
333
|
+
* This is the first step in a two-step process: create, then fund.
|
|
334
|
+
* @param params Parameters to create the escrow.
|
|
335
|
+
* @returns The escrow creation response, including the ID and deposit address.
|
|
336
|
+
*/
|
|
337
|
+
createEscrow(params: {
|
|
338
|
+
assetId: string;
|
|
339
|
+
assetAmount: string;
|
|
340
|
+
recipients: {
|
|
341
|
+
id: string;
|
|
342
|
+
amount: string;
|
|
343
|
+
}[];
|
|
344
|
+
claimConditions: Condition[];
|
|
345
|
+
abandonHost?: string;
|
|
346
|
+
abandonConditions?: Condition[];
|
|
347
|
+
autoFund?: boolean;
|
|
348
|
+
}): Promise<CreateEscrowResponse | FundEscrowResponse>;
|
|
349
|
+
/**
|
|
350
|
+
* Funds an escrow contract to activate it.
|
|
351
|
+
* This handles the asset transfer and confirmation in one step.
|
|
352
|
+
* @param params Parameters to fund the escrow, including asset details and deposit address.
|
|
353
|
+
* @returns The funding confirmation response.
|
|
354
|
+
*/
|
|
355
|
+
fundEscrow(params: {
|
|
356
|
+
escrowId: string;
|
|
357
|
+
depositAddress: string;
|
|
358
|
+
assetId: string;
|
|
359
|
+
assetAmount: string;
|
|
360
|
+
}): Promise<FundEscrowResponse>;
|
|
361
|
+
/**
|
|
362
|
+
* Claims funds from an active escrow contract.
|
|
363
|
+
* The caller must be a valid recipient and all claim conditions must be met.
|
|
364
|
+
* @param params Parameters for the claim.
|
|
365
|
+
* @returns The claim processing response.
|
|
366
|
+
*/
|
|
367
|
+
claimEscrow(params: {
|
|
368
|
+
escrowId: string;
|
|
369
|
+
}): Promise<ClaimEscrowResponse>;
|
|
370
|
+
/**
|
|
371
|
+
* Retrieves the current state of an escrow contract.
|
|
372
|
+
* This is a read-only operation and does not require authentication.
|
|
373
|
+
* @param escrowId The unique identifier of the escrow.
|
|
374
|
+
* @returns The full state of the escrow.
|
|
375
|
+
*/
|
|
376
|
+
getEscrow(escrowId: string): Promise<EscrowState>;
|
|
306
377
|
/**
|
|
307
378
|
* Get swaps for a specific pool
|
|
308
379
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlashnetClient.d.ts","sourceRoot":"","sources":["../../../../src/client/FlashnetClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAS3D,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"FlashnetClient.d.ts","sourceRoot":"","sources":["../../../../src/client/FlashnetClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB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-368,10 +368,62 @@ class FlashnetClient {
|
|
|
368
368
|
const response = await this.typedApi.createConstantProductPool(request);
|
|
369
369
|
// Add initial liquidity if specified
|
|
370
370
|
if (params.initialLiquidity && response.poolId) {
|
|
371
|
-
await this.addInitialLiquidity(response.poolId, params.assetAAddress, params.assetBAddress, params.initialLiquidity.assetAAmount.toString(), params.initialLiquidity.assetBAmount.toString());
|
|
371
|
+
await this.addInitialLiquidity(response.poolId, params.assetAAddress, params.assetBAddress, params.initialLiquidity.assetAAmount.toString(), params.initialLiquidity.assetBAmount.toString(), params.initialLiquidity.assetAMinAmountIn.toString(), params.initialLiquidity.assetBMinAmountIn.toString());
|
|
372
372
|
}
|
|
373
373
|
return response;
|
|
374
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Calculates virtual reserves for a bonding curve AMM.
|
|
377
|
+
*
|
|
378
|
+
* This helper function calculates the initial virtual reserves (`v_A^0`, `v_B^0`)
|
|
379
|
+
* based on the bonding curve parameters. These virtual reserves ensure smooth
|
|
380
|
+
* pricing and price continuity during graduation to the double-sided phase.
|
|
381
|
+
*
|
|
382
|
+
* @param params - The parameters for the calculation.
|
|
383
|
+
* @param params.initialTokenSupply - The initial supply of Asset A (tokens to be sold).
|
|
384
|
+
* @param params.graduationThresholdPct - The percentage of tokens that need to be sold for graduation (20-95%).
|
|
385
|
+
* @param params.targetRaise - The target amount of Asset B to raise at graduation.
|
|
386
|
+
* @returns An object containing `virtualReserveA`, `virtualReserveB`, and `threshold`.
|
|
387
|
+
*/
|
|
388
|
+
static calculateVirtualReserves(params) {
|
|
389
|
+
const supply = Number(params.initialTokenSupply);
|
|
390
|
+
const targetB = Number(params.targetRaise);
|
|
391
|
+
const lpFrac = 1.0;
|
|
392
|
+
// Validate inputs
|
|
393
|
+
if (supply <= 0) {
|
|
394
|
+
throw new Error("Initial token supply must be positive");
|
|
395
|
+
}
|
|
396
|
+
if (targetB <= 0) {
|
|
397
|
+
throw new Error("Target raise must be positive");
|
|
398
|
+
}
|
|
399
|
+
const MIN_GRADUATION_THRESHOLD_PCT = 20;
|
|
400
|
+
const MAX_GRADUATION_THRESHOLD_PCT = 95;
|
|
401
|
+
// Validate graduation threshold is a positive whole number
|
|
402
|
+
if (!Number.isInteger(params.graduationThresholdPct) ||
|
|
403
|
+
params.graduationThresholdPct <= 0) {
|
|
404
|
+
throw new Error("Graduation threshold percentage must be a positive whole number");
|
|
405
|
+
}
|
|
406
|
+
if (params.graduationThresholdPct < MIN_GRADUATION_THRESHOLD_PCT ||
|
|
407
|
+
params.graduationThresholdPct > MAX_GRADUATION_THRESHOLD_PCT) {
|
|
408
|
+
throw new Error(`Graduation threshold percentage must be between ${MIN_GRADUATION_THRESHOLD_PCT} and ${MAX_GRADUATION_THRESHOLD_PCT}`);
|
|
409
|
+
}
|
|
410
|
+
// Calculate graduation parameters
|
|
411
|
+
const f = params.graduationThresholdPct / 100;
|
|
412
|
+
const g = lpFrac;
|
|
413
|
+
// Check feasibility: f - g*(1-f) > 0
|
|
414
|
+
const denom = f - g * (1 - f);
|
|
415
|
+
if (denom <= 0) {
|
|
416
|
+
throw new Error(`Invalid configuration: graduation threshold ${f * 100}% with LP fraction ${g} is infeasible. Need f > g/(1+g)`);
|
|
417
|
+
}
|
|
418
|
+
// Calculate virtual reserves and round down to integers
|
|
419
|
+
const virtualA = Math.floor((supply * f * f) / denom);
|
|
420
|
+
const virtualB = Math.floor((targetB * g * (1 - f)) / denom);
|
|
421
|
+
return {
|
|
422
|
+
virtualReserveA: virtualA,
|
|
423
|
+
virtualReserveB: virtualB,
|
|
424
|
+
threshold: params.graduationThresholdPct,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
375
427
|
/**
|
|
376
428
|
* Create a single-sided pool with automatic initial deposit
|
|
377
429
|
*
|
|
@@ -380,19 +432,18 @@ class FlashnetClient {
|
|
|
380
432
|
*/
|
|
381
433
|
async createSingleSidedPool(params) {
|
|
382
434
|
await this.ensureInitialized();
|
|
383
|
-
// check that assetAPctSoldAtGraduation is between 0 and 100 - no decimals
|
|
384
|
-
if (params.assetAPctSoldAtGraduation < 0 ||
|
|
385
|
-
params.assetAPctSoldAtGraduation > 100) {
|
|
386
|
-
throw new Error(`assetAPctSoldAtGraduation must be between 0 and 100`);
|
|
387
|
-
}
|
|
388
435
|
if (!params.hostNamespace && params.totalHostFeeRateBps < 10) {
|
|
389
436
|
throw new Error(`Host fee must be greater than 10 bps when no host namespace is provided`);
|
|
390
437
|
}
|
|
438
|
+
// Clip decimals off reserves before any operations
|
|
439
|
+
const clippedAssetAInitialReserve = Math.floor(Number(params.assetAInitialReserve)).toString();
|
|
440
|
+
const clippedVirtualReserveA = Math.floor(Number(params.virtualReserveA)).toString();
|
|
441
|
+
const clippedVirtualReserveB = Math.floor(Number(params.virtualReserveB)).toString();
|
|
391
442
|
await this.checkBalance({
|
|
392
443
|
balancesToCheck: [
|
|
393
444
|
{
|
|
394
445
|
assetAddress: params.assetAInitialReserve,
|
|
395
|
-
amount:
|
|
446
|
+
amount: clippedAssetAInitialReserve,
|
|
396
447
|
},
|
|
397
448
|
],
|
|
398
449
|
errorPrefix: "Insufficient balance for pool creation: ",
|
|
@@ -403,9 +454,10 @@ class FlashnetClient {
|
|
|
403
454
|
poolOwnerPublicKey: this.publicKey,
|
|
404
455
|
assetAAddress: this.toHexTokenIdentifier(params.assetAAddress),
|
|
405
456
|
assetBAddress: this.toHexTokenIdentifier(params.assetBAddress),
|
|
406
|
-
assetAInitialReserve:
|
|
407
|
-
|
|
408
|
-
|
|
457
|
+
assetAInitialReserve: clippedAssetAInitialReserve,
|
|
458
|
+
virtualReserveA: clippedVirtualReserveA,
|
|
459
|
+
virtualReserveB: clippedVirtualReserveB,
|
|
460
|
+
threshold: params.threshold,
|
|
409
461
|
lpFeeRateBps: params.lpFeeRateBps.toString(),
|
|
410
462
|
totalHostFeeRateBps: params.totalHostFeeRateBps.toString(),
|
|
411
463
|
nonce,
|
|
@@ -417,9 +469,10 @@ class FlashnetClient {
|
|
|
417
469
|
poolOwnerPublicKey: this.publicKey,
|
|
418
470
|
assetAAddress: this.toHexTokenIdentifier(params.assetAAddress),
|
|
419
471
|
assetBAddress: this.toHexTokenIdentifier(params.assetBAddress),
|
|
420
|
-
assetAInitialReserve:
|
|
421
|
-
|
|
422
|
-
|
|
472
|
+
assetAInitialReserve: clippedAssetAInitialReserve,
|
|
473
|
+
virtualReserveA: clippedVirtualReserveA,
|
|
474
|
+
virtualReserveB: clippedVirtualReserveB,
|
|
475
|
+
threshold: params.threshold,
|
|
423
476
|
lpFeeRateBps: params.lpFeeRateBps.toString(),
|
|
424
477
|
totalHostFeeRateBps: params.totalHostFeeRateBps.toString(),
|
|
425
478
|
hostNamespace: params.hostNamespace,
|
|
@@ -439,7 +492,7 @@ class FlashnetClient {
|
|
|
439
492
|
const assetATransferId = await this.transferAsset({
|
|
440
493
|
receiverSparkAddress: lpSparkAddress,
|
|
441
494
|
assetAddress: params.assetAAddress,
|
|
442
|
-
amount:
|
|
495
|
+
amount: clippedAssetAInitialReserve,
|
|
443
496
|
});
|
|
444
497
|
const confirmResponse = await this.confirmInitialDeposit(createResponse.poolId, assetATransferId);
|
|
445
498
|
if (!confirmResponse.confirmed) {
|
|
@@ -685,6 +738,8 @@ class FlashnetClient {
|
|
|
685
738
|
assetBSparkTransferId: assetBTransferId,
|
|
686
739
|
assetAAmount: params.assetAAmount.toString(),
|
|
687
740
|
assetBAmount: params.assetBAmount.toString(),
|
|
741
|
+
assetAMinAmountIn: params.assetAMinAmountIn.toString(),
|
|
742
|
+
assetBMinAmountIn: params.assetBMinAmountIn.toString(),
|
|
688
743
|
nonce,
|
|
689
744
|
});
|
|
690
745
|
// Sign intent
|
|
@@ -697,6 +752,8 @@ class FlashnetClient {
|
|
|
697
752
|
assetBSparkTransferId: assetBTransferId,
|
|
698
753
|
assetAAmountToAdd: params.assetAAmount.toString(),
|
|
699
754
|
assetBAmountToAdd: params.assetBAmount.toString(),
|
|
755
|
+
assetAMinAmountIn: params.assetAMinAmountIn.toString(),
|
|
756
|
+
assetBMinAmountIn: params.assetBMinAmountIn.toString(),
|
|
700
757
|
nonce,
|
|
701
758
|
signature: Buffer.from(signature).toString("hex"),
|
|
702
759
|
};
|
|
@@ -806,7 +863,6 @@ class FlashnetClient {
|
|
|
806
863
|
const intentMessage = intents.generateWithdrawHostFeesIntentMessage({
|
|
807
864
|
hostPublicKey: this.publicKey,
|
|
808
865
|
lpIdentityPublicKey: params.lpIdentityPublicKey,
|
|
809
|
-
assetAAmount: params.assetAAmount,
|
|
810
866
|
assetBAmount: params.assetBAmount,
|
|
811
867
|
nonce,
|
|
812
868
|
});
|
|
@@ -815,7 +871,6 @@ class FlashnetClient {
|
|
|
815
871
|
const signature = await this._wallet.config.signer.signMessageWithIdentityKey(messageHash, true);
|
|
816
872
|
const request = {
|
|
817
873
|
lpIdentityPublicKey: params.lpIdentityPublicKey,
|
|
818
|
-
assetAAmount: params.assetAAmount,
|
|
819
874
|
assetBAmount: params.assetBAmount,
|
|
820
875
|
nonce,
|
|
821
876
|
signature: Buffer.from(signature).toString("hex"),
|
|
@@ -847,7 +902,6 @@ class FlashnetClient {
|
|
|
847
902
|
const intentMessage = intents.generateWithdrawIntegratorFeesIntentMessage({
|
|
848
903
|
integratorPublicKey: this.publicKey,
|
|
849
904
|
lpIdentityPublicKey: params.lpIdentityPublicKey,
|
|
850
|
-
assetAAmount: params.assetAAmount,
|
|
851
905
|
assetBAmount: params.assetBAmount,
|
|
852
906
|
nonce,
|
|
853
907
|
});
|
|
@@ -857,7 +911,6 @@ class FlashnetClient {
|
|
|
857
911
|
const request = {
|
|
858
912
|
integratorPublicKey: this.publicKey,
|
|
859
913
|
lpIdentityPublicKey: params.lpIdentityPublicKey,
|
|
860
|
-
assetAAmount: params.assetAAmount,
|
|
861
914
|
assetBAmount: params.assetBAmount,
|
|
862
915
|
nonce,
|
|
863
916
|
signature: Buffer.from(signature).toString("hex"),
|
|
@@ -877,6 +930,144 @@ class FlashnetClient {
|
|
|
877
930
|
await this.ensureInitialized();
|
|
878
931
|
return this.typedApi.getIntegratorFees();
|
|
879
932
|
}
|
|
933
|
+
// ===== Escrow Operations =====
|
|
934
|
+
/**
|
|
935
|
+
* Creates a new escrow contract.
|
|
936
|
+
* This is the first step in a two-step process: create, then fund.
|
|
937
|
+
* @param params Parameters to create the escrow.
|
|
938
|
+
* @returns The escrow creation response, including the ID and deposit address.
|
|
939
|
+
*/
|
|
940
|
+
async createEscrow(params) {
|
|
941
|
+
await this.ensureInitialized();
|
|
942
|
+
const nonce = index$2.generateNonce();
|
|
943
|
+
// The intent message requires a different structure for recipients and conditions
|
|
944
|
+
const intentRecipients = params.recipients.map((r) => ({
|
|
945
|
+
recipientId: r.id,
|
|
946
|
+
amount: r.amount,
|
|
947
|
+
hasClaimed: false, // Default value for creation
|
|
948
|
+
}));
|
|
949
|
+
const intentMessage = intents.generateCreateEscrowIntentMessage({
|
|
950
|
+
creatorPublicKey: this.publicKey,
|
|
951
|
+
assetId: params.assetId,
|
|
952
|
+
assetAmount: params.assetAmount,
|
|
953
|
+
recipients: intentRecipients,
|
|
954
|
+
claimConditions: params.claimConditions, // Assuming API `Condition` is compatible
|
|
955
|
+
abandonHost: params.abandonHost,
|
|
956
|
+
abandonConditions: params.abandonConditions || undefined,
|
|
957
|
+
nonce,
|
|
958
|
+
});
|
|
959
|
+
const messageHash = new Uint8Array(await crypto.subtle.digest("SHA-256", intentMessage));
|
|
960
|
+
const signature = await this._wallet.config.signer.signMessageWithIdentityKey(messageHash, true);
|
|
961
|
+
const request = {
|
|
962
|
+
creatorPublicKey: this.publicKey,
|
|
963
|
+
assetId: params.assetId,
|
|
964
|
+
assetAmount: params.assetAmount,
|
|
965
|
+
recipients: params.recipients,
|
|
966
|
+
claimConditions: params.claimConditions,
|
|
967
|
+
abandonHost: params.abandonHost,
|
|
968
|
+
abandonConditions: params.abandonConditions,
|
|
969
|
+
nonce,
|
|
970
|
+
signature: Buffer.from(signature).toString("hex"),
|
|
971
|
+
};
|
|
972
|
+
const createResponse = await this.typedApi.createEscrow(request);
|
|
973
|
+
const autoFund = params.autoFund !== false;
|
|
974
|
+
if (!autoFund) {
|
|
975
|
+
return createResponse;
|
|
976
|
+
}
|
|
977
|
+
// Auto-fund the escrow
|
|
978
|
+
return this.fundEscrow({
|
|
979
|
+
escrowId: createResponse.escrowId,
|
|
980
|
+
depositAddress: createResponse.depositAddress,
|
|
981
|
+
assetId: params.assetId,
|
|
982
|
+
assetAmount: params.assetAmount,
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Funds an escrow contract to activate it.
|
|
987
|
+
* This handles the asset transfer and confirmation in one step.
|
|
988
|
+
* @param params Parameters to fund the escrow, including asset details and deposit address.
|
|
989
|
+
* @returns The funding confirmation response.
|
|
990
|
+
*/
|
|
991
|
+
async fundEscrow(params) {
|
|
992
|
+
await this.ensureInitialized();
|
|
993
|
+
// 1. Balance check
|
|
994
|
+
await this.checkBalance({
|
|
995
|
+
balancesToCheck: [
|
|
996
|
+
{ assetAddress: params.assetId, amount: params.assetAmount },
|
|
997
|
+
],
|
|
998
|
+
errorPrefix: "Insufficient balance to fund escrow: ",
|
|
999
|
+
});
|
|
1000
|
+
// 2. Perform transfer
|
|
1001
|
+
const escrowSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
1002
|
+
identityPublicKey: params.depositAddress,
|
|
1003
|
+
network: this.sparkNetwork,
|
|
1004
|
+
});
|
|
1005
|
+
let sparkTransferId;
|
|
1006
|
+
if (params.assetId === index$1.BTC_ASSET_PUBKEY) {
|
|
1007
|
+
const transfer = await this._wallet.transfer({
|
|
1008
|
+
amountSats: Number(params.assetAmount),
|
|
1009
|
+
receiverSparkAddress: escrowSparkAddress,
|
|
1010
|
+
});
|
|
1011
|
+
sparkTransferId = transfer.id;
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
sparkTransferId = await this._wallet.transferTokens({
|
|
1015
|
+
tokenIdentifier: this.toHumanReadableTokenIdentifier(params.assetId),
|
|
1016
|
+
tokenAmount: BigInt(params.assetAmount),
|
|
1017
|
+
receiverSparkAddress: escrowSparkAddress,
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
// 3. Generate intent, sign, and call API
|
|
1021
|
+
const nonce = index$2.generateNonce();
|
|
1022
|
+
const intentMessage = intents.generateFundEscrowIntentMessage({
|
|
1023
|
+
escrowId: params.escrowId,
|
|
1024
|
+
creatorPublicKey: this.publicKey,
|
|
1025
|
+
sparkTransferId,
|
|
1026
|
+
nonce,
|
|
1027
|
+
});
|
|
1028
|
+
const messageHash = new Uint8Array(await crypto.subtle.digest("SHA-256", intentMessage));
|
|
1029
|
+
const signature = await this._wallet.config.signer.signMessageWithIdentityKey(messageHash, true);
|
|
1030
|
+
const request = {
|
|
1031
|
+
escrowId: params.escrowId,
|
|
1032
|
+
sparkTransferId,
|
|
1033
|
+
nonce,
|
|
1034
|
+
signature: Buffer.from(signature).toString("hex"),
|
|
1035
|
+
};
|
|
1036
|
+
return this.typedApi.fundEscrow(request);
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Claims funds from an active escrow contract.
|
|
1040
|
+
* The caller must be a valid recipient and all claim conditions must be met.
|
|
1041
|
+
* @param params Parameters for the claim.
|
|
1042
|
+
* @returns The claim processing response.
|
|
1043
|
+
*/
|
|
1044
|
+
async claimEscrow(params) {
|
|
1045
|
+
await this.ensureInitialized();
|
|
1046
|
+
const nonce = index$2.generateNonce();
|
|
1047
|
+
const intentMessage = intents.generateClaimEscrowIntentMessage({
|
|
1048
|
+
escrowId: params.escrowId,
|
|
1049
|
+
recipientPublicKey: this.publicKey,
|
|
1050
|
+
nonce,
|
|
1051
|
+
});
|
|
1052
|
+
const messageHash = new Uint8Array(await crypto.subtle.digest("SHA-256", intentMessage));
|
|
1053
|
+
const signature = await this._wallet.config.signer.signMessageWithIdentityKey(messageHash, true);
|
|
1054
|
+
const request = {
|
|
1055
|
+
escrowId: params.escrowId,
|
|
1056
|
+
nonce,
|
|
1057
|
+
signature: Buffer.from(signature).toString("hex"),
|
|
1058
|
+
};
|
|
1059
|
+
return this.typedApi.claimEscrow(request);
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Retrieves the current state of an escrow contract.
|
|
1063
|
+
* This is a read-only operation and does not require authentication.
|
|
1064
|
+
* @param escrowId The unique identifier of the escrow.
|
|
1065
|
+
* @returns The full state of the escrow.
|
|
1066
|
+
*/
|
|
1067
|
+
async getEscrow(escrowId) {
|
|
1068
|
+
await this.ensureInitialized();
|
|
1069
|
+
return this.typedApi.getEscrow(escrowId);
|
|
1070
|
+
}
|
|
880
1071
|
// ===== Swap History =====
|
|
881
1072
|
/**
|
|
882
1073
|
* Get swaps for a specific pool
|
|
@@ -985,7 +1176,7 @@ class FlashnetClient {
|
|
|
985
1176
|
/**
|
|
986
1177
|
* Helper method to add initial liquidity after pool creation
|
|
987
1178
|
*/
|
|
988
|
-
async addInitialLiquidity(poolId, assetAAddress, assetBAddress, assetAAmount, assetBAmount) {
|
|
1179
|
+
async addInitialLiquidity(poolId, assetAAddress, assetBAddress, assetAAmount, assetBAmount, assetAMinAmountIn, assetBMinAmountIn) {
|
|
989
1180
|
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
990
1181
|
identityPublicKey: poolId,
|
|
991
1182
|
network: this.sparkNetwork,
|
|
@@ -1011,6 +1202,8 @@ class FlashnetClient {
|
|
|
1011
1202
|
assetBSparkTransferId: assetBTransferId,
|
|
1012
1203
|
assetAAmount: assetAAmount.toString(),
|
|
1013
1204
|
assetBAmount: assetBAmount.toString(),
|
|
1205
|
+
assetAMinAmountIn: assetAMinAmountIn.toString(),
|
|
1206
|
+
assetBMinAmountIn: assetBMinAmountIn.toString(),
|
|
1014
1207
|
nonce,
|
|
1015
1208
|
});
|
|
1016
1209
|
const messageHash = new Uint8Array(await crypto.subtle.digest("SHA-256", intentMessage));
|
|
@@ -1022,6 +1215,8 @@ class FlashnetClient {
|
|
|
1022
1215
|
assetBSparkTransferId: assetBTransferId,
|
|
1023
1216
|
assetAAmountToAdd: assetAAmount.toString(),
|
|
1024
1217
|
assetBAmountToAdd: assetBAmount.toString(),
|
|
1218
|
+
assetAMinAmountIn: assetAMinAmountIn.toString(),
|
|
1219
|
+
assetBMinAmountIn: assetBMinAmountIn.toString(),
|
|
1025
1220
|
nonce,
|
|
1026
1221
|
signature: Buffer.from(signature).toString("hex"),
|
|
1027
1222
|
};
|