@gmx-io/sdk 1.0.3 → 1.0.4
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/build/cjs/src/modules/markets/query-builders.js +5 -0
- package/build/cjs/src/modules/orders/orders.js +3 -4
- package/build/esm/src/modules/markets/query-builders.js +5 -0
- package/build/esm/src/modules/orders/orders.js +3 -4
- package/build/types/src/modules/orders/orders.d.ts +1 -2
- package/package.json +1 -1
|
@@ -49,6 +49,11 @@ async function buildMarketsValuesRequest(chainId, { marketsAddresses, marketsDat
|
|
|
49
49
|
const request = {};
|
|
50
50
|
for (const marketAddress of marketsAddresses || []) {
|
|
51
51
|
const market = (0, objects_1.getByKey)(marketsData, marketAddress);
|
|
52
|
+
if (!market) {
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.warn(`No market data found for ${marketAddress}, skipping market values request`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
52
57
|
const marketPrices = (0, markets_1.getContractMarketPrices)(tokensData, market);
|
|
53
58
|
if (!marketPrices) {
|
|
54
59
|
// eslint-disable-next-line no-console
|
|
@@ -198,7 +198,7 @@ class Orders extends base_1.Module {
|
|
|
198
198
|
})),
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
async createDecreaseOrder({ marketsInfoData, tokensData, marketInfo, decreaseAmounts, collateralToken, allowedSlippage, isLong, referralCode,
|
|
201
|
+
async createDecreaseOrder({ marketsInfoData, tokensData, marketInfo, decreaseAmounts, collateralToken, allowedSlippage, isLong, referralCode, }) {
|
|
202
202
|
const account = this.account;
|
|
203
203
|
if (!account) {
|
|
204
204
|
throw new Error("Account is not defined");
|
|
@@ -209,8 +209,7 @@ class Orders extends base_1.Module {
|
|
|
209
209
|
if (!executionFee) {
|
|
210
210
|
throw new Error("Execution fee is not available");
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
if (orderType === undefined) {
|
|
212
|
+
if (decreaseAmounts?.triggerOrderType === undefined) {
|
|
214
213
|
throw new Error("Trigger order type is not defined");
|
|
215
214
|
}
|
|
216
215
|
const { ordersInfoData } = await this.sdk.orders.getOrders({
|
|
@@ -241,7 +240,7 @@ class Orders extends base_1.Module {
|
|
|
241
240
|
minOutputUsd: BigInt(0),
|
|
242
241
|
isLong,
|
|
243
242
|
decreasePositionSwapType: decreaseAmounts.decreaseSwapType,
|
|
244
|
-
orderType:
|
|
243
|
+
orderType: decreaseAmounts?.triggerOrderType,
|
|
245
244
|
executionFee: executionFee.feeTokenAmount,
|
|
246
245
|
allowedSlippage,
|
|
247
246
|
referralCode,
|
|
@@ -45,6 +45,11 @@ export async function buildMarketsValuesRequest(chainId, { marketsAddresses, mar
|
|
|
45
45
|
const request = {};
|
|
46
46
|
for (const marketAddress of marketsAddresses || []) {
|
|
47
47
|
const market = getByKey(marketsData, marketAddress);
|
|
48
|
+
if (!market) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.warn(`No market data found for ${marketAddress}, skipping market values request`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
48
53
|
const marketPrices = getContractMarketPrices(tokensData, market);
|
|
49
54
|
if (!marketPrices) {
|
|
50
55
|
// eslint-disable-next-line no-console
|
|
@@ -195,7 +195,7 @@ export class Orders extends Module {
|
|
|
195
195
|
})),
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
|
-
async createDecreaseOrder({ marketsInfoData, tokensData, marketInfo, decreaseAmounts, collateralToken, allowedSlippage, isLong, referralCode,
|
|
198
|
+
async createDecreaseOrder({ marketsInfoData, tokensData, marketInfo, decreaseAmounts, collateralToken, allowedSlippage, isLong, referralCode, }) {
|
|
199
199
|
const account = this.account;
|
|
200
200
|
if (!account) {
|
|
201
201
|
throw new Error("Account is not defined");
|
|
@@ -206,8 +206,7 @@ export class Orders extends Module {
|
|
|
206
206
|
if (!executionFee) {
|
|
207
207
|
throw new Error("Execution fee is not available");
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
if (orderType === undefined) {
|
|
209
|
+
if (decreaseAmounts?.triggerOrderType === undefined) {
|
|
211
210
|
throw new Error("Trigger order type is not defined");
|
|
212
211
|
}
|
|
213
212
|
const { ordersInfoData } = await this.sdk.orders.getOrders({
|
|
@@ -238,7 +237,7 @@ export class Orders extends Module {
|
|
|
238
237
|
minOutputUsd: BigInt(0),
|
|
239
238
|
isLong,
|
|
240
239
|
decreasePositionSwapType: decreaseAmounts.decreaseSwapType,
|
|
241
|
-
orderType:
|
|
240
|
+
orderType: decreaseAmounts?.triggerOrderType,
|
|
242
241
|
executionFee: executionFee.feeTokenAmount,
|
|
243
242
|
allowedSlippage,
|
|
244
243
|
referralCode,
|
|
@@ -39,7 +39,7 @@ export declare class Orders extends Module {
|
|
|
39
39
|
increaseAmounts: IncreasePositionAmounts;
|
|
40
40
|
skipSimulation?: boolean;
|
|
41
41
|
}): Promise<void>;
|
|
42
|
-
createDecreaseOrder({ marketsInfoData, tokensData, marketInfo, decreaseAmounts, collateralToken, allowedSlippage, isLong, referralCode,
|
|
42
|
+
createDecreaseOrder({ marketsInfoData, tokensData, marketInfo, decreaseAmounts, collateralToken, allowedSlippage, isLong, referralCode, }: {
|
|
43
43
|
marketInfo: MarketInfo;
|
|
44
44
|
marketsInfoData: MarketsInfoData;
|
|
45
45
|
tokensData: TokensData;
|
|
@@ -48,7 +48,6 @@ export declare class Orders extends Module {
|
|
|
48
48
|
decreaseAmounts: DecreasePositionAmounts;
|
|
49
49
|
collateralToken: TokenData;
|
|
50
50
|
referralCode?: string;
|
|
51
|
-
isTrigger?: boolean;
|
|
52
51
|
}): Promise<void>;
|
|
53
52
|
createSwapOrder({ isLimit, swapAmounts, allowedSlippage, fromToken, toToken, referralCodeForTxn, tokensData, triggerPrice, }: {
|
|
54
53
|
isLimit: boolean;
|