@shogun-sdk/intents-sdk 1.2.6-test.12 → 1.2.6-test.13
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.cjs +37 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -12
- package/dist/index.d.ts +23 -12
- package/dist/index.js +37 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/auth/siwe.ts +6 -2
- package/src/constants.ts +2 -0
- package/src/core/evm/intent-helpers.ts +11 -6
- package/src/core/orders/api/fetch.ts +2 -2
- package/src/core/orders/common.ts +2 -0
- package/src/core/orders/cross-chain.ts +12 -8
- package/src/core/orders/single-chain.ts +10 -6
- package/src/core/sdk.ts +2 -2
- package/src/core/solana/intent-helpers.ts +5 -3
- package/src/core/sui/intent-helpers.ts +8 -5
- package/src/utils/quote/aggregator.ts +10 -24
package/dist/index.cjs
CHANGED
|
@@ -144,7 +144,7 @@ function isNativeEvmToken(tokenAddress) {
|
|
|
144
144
|
const normalizedAddress = tokenAddress.toLowerCase();
|
|
145
145
|
return NATIVE_EVM_ETH_ADDRESSES.some((addr) => addr.toLowerCase() === normalizedAddress);
|
|
146
146
|
}
|
|
147
|
-
var import_kit, useProdConfig, IntentsOrderType, PERMIT2_ADDRESS, PROD_CROSS_CHAIN_GUARD_ADDRESSES, TEST_CROSS_CHAIN_GUARD_ADDRESSES, PROD_SINGLE_CHAIN_GUARD_ADDRESSES, TEST_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_DCA_CROSS_CHAIN_GUARD_ADDRESSES, TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, CROSS_CHAIN_GUARD_ADDRESSES, SINGLE_CHAIN_GUARD_ADDRESSES, DCA_SINGLE_CHAIN_GUARD_ADDRESSES, NATIVE_SOLANA_TOKEN_ADDRESS, WRAPPED_SOL_MINT_ADDRESS, SOLANA_USDC_MINT, SOLANA_MINT_TOKEN, PROD_SUI_PACKAGE_ID, TEST_SUI_PACKAGE_ID, SUI_PACKAGE_ID, SUI_GUARD_COLLATERAL_TYPE, SUI_GUARD_STABLECOIN_TYPE, AUCTIONEER_URL, MAX_UINT_32, MAX_UINT_64, MAX_UINT_128, MAX_UINT_256, NATIVE_EVM_ETH_ADDRESSES, WRAPPED_ETH_ADDRESSES, NATIVE_SUI_TOKEN_ADDRESS, TOKEN_SEARCH_API_BASE_URL;
|
|
147
|
+
var import_kit, useProdConfig, IntentsOrderType, PERMIT2_ADDRESS, PROD_CROSS_CHAIN_GUARD_ADDRESSES, TEST_CROSS_CHAIN_GUARD_ADDRESSES, PROD_SINGLE_CHAIN_GUARD_ADDRESSES, TEST_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_DCA_CROSS_CHAIN_GUARD_ADDRESSES, TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, CROSS_CHAIN_GUARD_ADDRESSES, SINGLE_CHAIN_GUARD_ADDRESSES, DCA_SINGLE_CHAIN_GUARD_ADDRESSES, NATIVE_SOLANA_TOKEN_ADDRESS, WRAPPED_SOL_MINT_ADDRESS, SOLANA_USDC_MINT, SOLANA_MINT_TOKEN, PROD_SUI_PACKAGE_ID, TEST_SUI_PACKAGE_ID, SUI_PACKAGE_ID, SUI_GUARD_COLLATERAL_TYPE, SUI_GUARD_STABLECOIN_TYPE, AUCTIONEER_URL, MAX_UINT_32, MAX_UINT_64, MAX_UINT_128, MAX_UINT_256, NATIVE_EVM_ETH_ADDRESSES, WRAPPED_ETH_ADDRESSES, NATIVE_SUI_TOKEN_ADDRESS, TOKEN_SEARCH_API_BASE_URL, DEV_ACCESS_KEY;
|
|
148
148
|
var init_constants = __esm({
|
|
149
149
|
"src/constants.ts"() {
|
|
150
150
|
"use strict";
|
|
@@ -260,6 +260,7 @@ var init_constants = __esm({
|
|
|
260
260
|
};
|
|
261
261
|
NATIVE_SUI_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
262
262
|
TOKEN_SEARCH_API_BASE_URL = "https://shogun-token-search-api-825534211396.europe-west4.run.app";
|
|
263
|
+
DEV_ACCESS_KEY = process.env.DEV_ACCESS_KEY || process.env.NEXT_PUBLIC_DEV_ACCESS_KEY;
|
|
263
264
|
}
|
|
264
265
|
});
|
|
265
266
|
|
|
@@ -375,6 +376,7 @@ __export(index_exports, {
|
|
|
375
376
|
ChainType: () => ChainType,
|
|
376
377
|
CrossChainOrder: () => CrossChainOrder,
|
|
377
378
|
DCA_SINGLE_CHAIN_GUARD_ADDRESSES: () => DCA_SINGLE_CHAIN_GUARD_ADDRESSES,
|
|
379
|
+
DEV_ACCESS_KEY: () => DEV_ACCESS_KEY,
|
|
378
380
|
DcaSingleChainOrder: () => DcaSingleChainOrder,
|
|
379
381
|
EVMSDK: () => EVMSDK,
|
|
380
382
|
IntentsOrderType: () => IntentsOrderType,
|
|
@@ -6370,8 +6372,9 @@ var CrossChainOrder = class _CrossChainOrder {
|
|
|
6370
6372
|
__publicField(this, "deadline");
|
|
6371
6373
|
/** Extra transfers to be made */
|
|
6372
6374
|
__publicField(this, "extraTransfers");
|
|
6373
|
-
/** Stop loss
|
|
6374
|
-
__publicField(this, "
|
|
6375
|
+
/** Stop loss */
|
|
6376
|
+
__publicField(this, "stopLossType");
|
|
6377
|
+
__publicField(this, "stopLossTriggerPrice");
|
|
6375
6378
|
/** Take profit min out */
|
|
6376
6379
|
__publicField(this, "takeProfitMinOut");
|
|
6377
6380
|
this.user = params.user;
|
|
@@ -6385,7 +6388,8 @@ var CrossChainOrder = class _CrossChainOrder {
|
|
|
6385
6388
|
this.minStablecoinAmount = params.minStablecoinAmount ?? 1n;
|
|
6386
6389
|
this.deadline = params.deadline;
|
|
6387
6390
|
this.extraTransfers = params.extraTransfers;
|
|
6388
|
-
this.
|
|
6391
|
+
this.stopLossType = params.stopLossType;
|
|
6392
|
+
this.stopLossTriggerPrice = params.stopLossTriggerPrice;
|
|
6389
6393
|
this.takeProfitMinOut = params.takeProfitMinOut;
|
|
6390
6394
|
}
|
|
6391
6395
|
/**
|
|
@@ -6437,8 +6441,8 @@ var CrossChainOrder = class _CrossChainOrder {
|
|
|
6437
6441
|
}
|
|
6438
6442
|
}
|
|
6439
6443
|
static async calculateAmountOutMin(input) {
|
|
6440
|
-
const { destinationTokenMinAmount,
|
|
6441
|
-
if (
|
|
6444
|
+
const { destinationTokenMinAmount, stopLossType, stopLossTriggerPrice, minStablecoinAmount } = input;
|
|
6445
|
+
if (stopLossType !== void 0 && stopLossTriggerPrice !== void 0) {
|
|
6442
6446
|
return {
|
|
6443
6447
|
destinationTokenMinAmount: 1n,
|
|
6444
6448
|
minStablecoinAmount: 1n
|
|
@@ -6591,7 +6595,8 @@ var SingleChainOrder = class _SingleChainOrder {
|
|
|
6591
6595
|
__publicField(this, "destinationAddress");
|
|
6592
6596
|
__publicField(this, "extraTransfers");
|
|
6593
6597
|
__publicField(this, "deadline");
|
|
6594
|
-
__publicField(this, "
|
|
6598
|
+
__publicField(this, "stopLossType");
|
|
6599
|
+
__publicField(this, "stopLossTriggerPrice");
|
|
6595
6600
|
__publicField(this, "takeProfitMinOut");
|
|
6596
6601
|
this.user = params.user;
|
|
6597
6602
|
this.chainId = params.chainId;
|
|
@@ -6602,7 +6607,8 @@ var SingleChainOrder = class _SingleChainOrder {
|
|
|
6602
6607
|
this.destinationAddress = params.destinationAddress;
|
|
6603
6608
|
this.extraTransfers = params.extraTransfers;
|
|
6604
6609
|
this.deadline = params.deadline;
|
|
6605
|
-
this.
|
|
6610
|
+
this.stopLossType = params.stopLossType;
|
|
6611
|
+
this.stopLossTriggerPrice = params.stopLossTriggerPrice;
|
|
6606
6612
|
this.takeProfitMinOut = params.takeProfitMinOut;
|
|
6607
6613
|
}
|
|
6608
6614
|
static async create(input) {
|
|
@@ -6645,10 +6651,10 @@ var SingleChainOrder = class _SingleChainOrder {
|
|
|
6645
6651
|
}
|
|
6646
6652
|
}
|
|
6647
6653
|
static async calculateAmountOutMin(input) {
|
|
6648
|
-
const { amountOutMin,
|
|
6654
|
+
const { amountOutMin, stopLossType, stopLossTriggerPrice } = input;
|
|
6649
6655
|
const scenario = this.getSingleChainOrderScenario({
|
|
6650
6656
|
hasAmountOutMin: !!amountOutMin,
|
|
6651
|
-
hasStopLoss: !!
|
|
6657
|
+
hasStopLoss: !!stopLossType && !!stopLossTriggerPrice
|
|
6652
6658
|
});
|
|
6653
6659
|
switch (scenario) {
|
|
6654
6660
|
case "QUOTE_REQUIRED": {
|
|
@@ -6718,7 +6724,7 @@ var BaseSDK = class _BaseSDK {
|
|
|
6718
6724
|
static async makeRequest(url, body) {
|
|
6719
6725
|
const response = await fetch(url, {
|
|
6720
6726
|
method: "POST",
|
|
6721
|
-
headers: { "Content-Type": "application/json" },
|
|
6727
|
+
headers: { "Content-Type": "application/json", "x-dev-access": DEV_ACCESS_KEY },
|
|
6722
6728
|
body
|
|
6723
6729
|
});
|
|
6724
6730
|
console.debug(`url`, url, `body`, body);
|
|
@@ -6992,7 +6998,11 @@ init_constants();
|
|
|
6992
6998
|
init_constants();
|
|
6993
6999
|
async function fetchSiweMessage(params) {
|
|
6994
7000
|
const url = `${AUCTIONEER_URL}/siwe?wallet=${params.wallet}&chainId=${params.chainId}`;
|
|
6995
|
-
const response = await fetch(url
|
|
7001
|
+
const response = await fetch(url, {
|
|
7002
|
+
headers: {
|
|
7003
|
+
"x-dev-access": DEV_ACCESS_KEY
|
|
7004
|
+
}
|
|
7005
|
+
});
|
|
6996
7006
|
if (!response.ok) {
|
|
6997
7007
|
throw new Error(`Failed to fetch SIWE message: ${response.status} ${response.statusText}`);
|
|
6998
7008
|
}
|
|
@@ -7772,7 +7782,7 @@ async function fetchUserOrders(evmAddress, solAddress, suiAddress) {
|
|
|
7772
7782
|
const url = `${AUCTIONEER_URL}/user_intent?${params.toString()}`;
|
|
7773
7783
|
const response = await fetch(url, {
|
|
7774
7784
|
method: "GET",
|
|
7775
|
-
headers: { "Content-Type": "application/json" }
|
|
7785
|
+
headers: { "Content-Type": "application/json", "x-dev-access": DEV_ACCESS_KEY }
|
|
7776
7786
|
});
|
|
7777
7787
|
if (!response.ok) {
|
|
7778
7788
|
throw new Error(`Failed to fetch user orders: ${response.status} ${response.statusText}`);
|
|
@@ -8279,7 +8289,6 @@ function createSuiSingleChainLimitOrderIntentRequest(params) {
|
|
|
8279
8289
|
destinationAddress: params.destinationAddress,
|
|
8280
8290
|
extraTransfers: params.extraTransfers,
|
|
8281
8291
|
deadline: params.deadline,
|
|
8282
|
-
stopLossMaxOut: params.stopLossMaxOut,
|
|
8283
8292
|
takeProfitMinOut: params.takeProfitMinOut
|
|
8284
8293
|
};
|
|
8285
8294
|
return {
|
|
@@ -8324,8 +8333,9 @@ function createSuiCrossChainOrderIntentRequest(params) {
|
|
|
8324
8333
|
tokenOut: params.tokenOut,
|
|
8325
8334
|
amountOutMin: params.amountOutMin.toString(),
|
|
8326
8335
|
destinationAddress: params.destinationAddress,
|
|
8327
|
-
stopLossMaxOut: params.stopLossMaxOut?.toString(),
|
|
8328
8336
|
takeProfitMinOut: params.takeProfitMinOut?.toString(),
|
|
8337
|
+
stopLossType: params.stopLossType,
|
|
8338
|
+
stopLossTriggerPrice: params.stopLossTriggerPrice,
|
|
8329
8339
|
extraTransfers: params.extraTransfers
|
|
8330
8340
|
};
|
|
8331
8341
|
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
@@ -8569,8 +8579,9 @@ function createEvmSingleChainLimitOrderIntentRequest(params) {
|
|
|
8569
8579
|
destinationAddress: params.destinationAddress,
|
|
8570
8580
|
extraTransfers: params.extraTransfers,
|
|
8571
8581
|
deadline: params.deadline,
|
|
8572
|
-
|
|
8573
|
-
|
|
8582
|
+
takeProfitMinOut: params.takeProfitMinOut,
|
|
8583
|
+
stopLossType: params.stopLossType,
|
|
8584
|
+
stopLossTriggerPrice: params.stopLossTriggerPrice
|
|
8574
8585
|
};
|
|
8575
8586
|
return {
|
|
8576
8587
|
genericData: order,
|
|
@@ -8614,8 +8625,9 @@ function createEvmCrossChainOrderIntentRequest(params) {
|
|
|
8614
8625
|
amountOutMin: params.destinationTokenMinAmount?.toString() || "1",
|
|
8615
8626
|
destinationAddress: params.destinationAddress,
|
|
8616
8627
|
extraTransfers: params.extraTransfers,
|
|
8617
|
-
|
|
8618
|
-
|
|
8628
|
+
takeProfitMinOut: params.takeProfitMinOut?.toString(),
|
|
8629
|
+
stopLossType: params.stopLossType,
|
|
8630
|
+
stopLossTriggerPrice: params.stopLossTriggerPrice
|
|
8619
8631
|
};
|
|
8620
8632
|
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
8621
8633
|
const executionDetailsHash = generateExecutionDetailsHash(executionDetails);
|
|
@@ -8628,8 +8640,9 @@ function createEvmCrossChainOrderIntentRequest(params) {
|
|
|
8628
8640
|
deadline: params.deadline,
|
|
8629
8641
|
executionDetailsHash,
|
|
8630
8642
|
extraTransfers: params.extraTransfers,
|
|
8631
|
-
|
|
8632
|
-
|
|
8643
|
+
takeProfitMinOut: params.takeProfitMinOut,
|
|
8644
|
+
stopLossType: params.stopLossType,
|
|
8645
|
+
stopLossTriggerPrice: params.stopLossTriggerPrice
|
|
8633
8646
|
};
|
|
8634
8647
|
return {
|
|
8635
8648
|
genericData,
|
|
@@ -8668,8 +8681,9 @@ function createSolanaSingleChainLimitOrderIntentRequest(params) {
|
|
|
8668
8681
|
destinationAddress: params.destinationAddress,
|
|
8669
8682
|
extraTransfers: params.extraTransfers,
|
|
8670
8683
|
deadline: params.deadline,
|
|
8671
|
-
|
|
8672
|
-
|
|
8684
|
+
takeProfitMinOut: params.takeProfitMinOut,
|
|
8685
|
+
stopLossType: params.stopLossType,
|
|
8686
|
+
stopLossTriggerPrice: params.stopLossTriggerPrice
|
|
8673
8687
|
};
|
|
8674
8688
|
return {
|
|
8675
8689
|
genericData: order,
|