@myx-trade/sdk 0.1.190 → 0.1.191
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.mts +96 -175
- package/dist/index.d.ts +96 -175
- package/dist/index.js +186 -119
- package/dist/index.mjs +186 -119
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1824,7 +1824,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
|
|
|
1824
1824
|
// package.json
|
|
1825
1825
|
var package_default = {
|
|
1826
1826
|
name: "@myx-trade/sdk",
|
|
1827
|
-
version: "0.1.
|
|
1827
|
+
version: "0.1.191",
|
|
1828
1828
|
private: false,
|
|
1829
1829
|
publishConfig: {
|
|
1830
1830
|
access: "public"
|
|
@@ -2089,9 +2089,9 @@ var ExecTypeEnum = /* @__PURE__ */ ((ExecTypeEnum2) => {
|
|
|
2089
2089
|
var getHistoryOrders = async ({
|
|
2090
2090
|
accessToken,
|
|
2091
2091
|
address,
|
|
2092
|
-
isProd = true,
|
|
2093
2092
|
...params
|
|
2094
|
-
}) => {
|
|
2093
|
+
}, envParams) => {
|
|
2094
|
+
const isProd = envParams?.isProd ?? true;
|
|
2095
2095
|
return http.get(
|
|
2096
2096
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/closed`,
|
|
2097
2097
|
params,
|
|
@@ -2119,9 +2119,9 @@ var CloseTypeEnum = /* @__PURE__ */ ((CloseTypeEnum2) => {
|
|
|
2119
2119
|
var getPositionHistory = async ({
|
|
2120
2120
|
accessToken,
|
|
2121
2121
|
address,
|
|
2122
|
-
isProd = true,
|
|
2123
2122
|
...params
|
|
2124
|
-
}) => {
|
|
2123
|
+
}, envParams) => {
|
|
2124
|
+
const isProd = envParams?.isProd ?? true;
|
|
2125
2125
|
return http.get(
|
|
2126
2126
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/position/closed`,
|
|
2127
2127
|
params,
|
|
@@ -2142,9 +2142,9 @@ var TradeFlowAccountTypeEnum = /* @__PURE__ */ ((TradeFlowAccountTypeEnum2) => {
|
|
|
2142
2142
|
var getTradeFlow = async ({
|
|
2143
2143
|
accessToken,
|
|
2144
2144
|
address,
|
|
2145
|
-
isProd = true,
|
|
2146
2145
|
...params
|
|
2147
|
-
}) => {
|
|
2146
|
+
}, envParams) => {
|
|
2147
|
+
const isProd = envParams?.isProd ?? true;
|
|
2148
2148
|
return http.get(
|
|
2149
2149
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/trade/flow`,
|
|
2150
2150
|
params,
|
|
@@ -2208,10 +2208,13 @@ var getForwardUrlByEnv = (isProd) => {
|
|
|
2208
2208
|
};
|
|
2209
2209
|
var getOraclePrice = async (chainId, poolIds = [], isProd = true) => {
|
|
2210
2210
|
if (!!poolIds.length) {
|
|
2211
|
-
return http.get(
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2211
|
+
return http.get(
|
|
2212
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/price/oracles`,
|
|
2213
|
+
{
|
|
2214
|
+
chainId,
|
|
2215
|
+
poolIds: poolIds.join(",")
|
|
2216
|
+
}
|
|
2217
|
+
);
|
|
2215
2218
|
}
|
|
2216
2219
|
return Promise.reject(new Error("Invalid pool id"));
|
|
2217
2220
|
};
|
|
@@ -2221,7 +2224,9 @@ var getPoolLevelConfig = async ({
|
|
|
2221
2224
|
isProd = true
|
|
2222
2225
|
}) => {
|
|
2223
2226
|
return http.get(
|
|
2224
|
-
`${getBaseUrlByEnv(
|
|
2227
|
+
`${getBaseUrlByEnv(
|
|
2228
|
+
isProd
|
|
2229
|
+
)}/openapi/gateway/risk/market_pool/level_config${addQueryParams({
|
|
2225
2230
|
poolId,
|
|
2226
2231
|
chainId
|
|
2227
2232
|
})}`
|
|
@@ -2229,7 +2234,9 @@ var getPoolLevelConfig = async ({
|
|
|
2229
2234
|
};
|
|
2230
2235
|
var getPoolDetail = async (chainId, poolId, isProd = true) => {
|
|
2231
2236
|
return await http.get(
|
|
2232
|
-
`${getBaseUrlByEnv(
|
|
2237
|
+
`${getBaseUrlByEnv(
|
|
2238
|
+
isProd
|
|
2239
|
+
)}/openapi/gateway/scan/market/info?chainId=${chainId}&poolId=${poolId}`
|
|
2233
2240
|
);
|
|
2234
2241
|
};
|
|
2235
2242
|
var getPositions = async (accessToken, address, isProd = true) => {
|
|
@@ -2249,24 +2256,30 @@ var getOrders = async (accessToken, address, isProd = true) => {
|
|
|
2249
2256
|
return await http.get(
|
|
2250
2257
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/open`,
|
|
2251
2258
|
void 0,
|
|
2252
|
-
{
|
|
2259
|
+
{
|
|
2260
|
+
headers: {
|
|
2261
|
+
myx_openapi_access_token: accessToken,
|
|
2262
|
+
myx_openapi_account: address
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2253
2265
|
);
|
|
2254
2266
|
};
|
|
2255
2267
|
var getPoolOpenOrders = async (accessToken, address, chainId, isProd = true) => {
|
|
2256
2268
|
return await http.get(
|
|
2257
|
-
`${getBaseUrlByEnv(
|
|
2269
|
+
`${getBaseUrlByEnv(
|
|
2270
|
+
isProd
|
|
2271
|
+
)}/openapi/gateway/scan/market/pool-order/open?chainId=${chainId}`,
|
|
2258
2272
|
void 0,
|
|
2259
|
-
{
|
|
2273
|
+
{
|
|
2274
|
+
headers: {
|
|
2275
|
+
myx_openapi_access_token: accessToken,
|
|
2276
|
+
myx_openapi_account: address
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2260
2279
|
);
|
|
2261
2280
|
};
|
|
2262
|
-
var getKlineData = ({
|
|
2263
|
-
|
|
2264
|
-
poolId,
|
|
2265
|
-
endTime,
|
|
2266
|
-
limit,
|
|
2267
|
-
interval,
|
|
2268
|
-
isProd = true
|
|
2269
|
-
}) => {
|
|
2281
|
+
var getKlineData = ({ chainId, poolId, endTime, limit, interval }, envParams) => {
|
|
2282
|
+
const isProd = envParams?.isProd ?? true;
|
|
2270
2283
|
return http.get(
|
|
2271
2284
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candles`,
|
|
2272
2285
|
{
|
|
@@ -2278,17 +2291,15 @@ var getKlineData = ({
|
|
|
2278
2291
|
}
|
|
2279
2292
|
);
|
|
2280
2293
|
};
|
|
2281
|
-
var getKlineLatestBar = async (params,
|
|
2294
|
+
var getKlineLatestBar = async (params, envParams) => {
|
|
2295
|
+
const isProd = envParams?.isProd ?? true;
|
|
2282
2296
|
return http.get(
|
|
2283
2297
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/latest`,
|
|
2284
2298
|
params
|
|
2285
2299
|
);
|
|
2286
2300
|
};
|
|
2287
|
-
var getTickerData = async ({
|
|
2288
|
-
|
|
2289
|
-
poolIds,
|
|
2290
|
-
isProd = true
|
|
2291
|
-
}) => {
|
|
2301
|
+
var getTickerData = async ({ chainId, poolIds }, envParams) => {
|
|
2302
|
+
const isProd = envParams?.isProd ?? true;
|
|
2292
2303
|
return http.get(
|
|
2293
2304
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/tickers`,
|
|
2294
2305
|
{
|
|
@@ -2297,19 +2308,14 @@ var getTickerData = async ({
|
|
|
2297
2308
|
}
|
|
2298
2309
|
);
|
|
2299
2310
|
};
|
|
2300
|
-
var getAllTickers = async ({
|
|
2301
|
-
isProd = true
|
|
2302
|
-
}) => {
|
|
2311
|
+
var getAllTickers = async (envParams) => {
|
|
2312
|
+
const isProd = envParams?.isProd ?? true;
|
|
2303
2313
|
return http.get(
|
|
2304
2314
|
`${getBaseUrlByEnv(isProd)}/v2/mx-gateway/quote/candle/all_tickers`
|
|
2305
2315
|
);
|
|
2306
2316
|
};
|
|
2307
|
-
var searchMarketAuth = async ({
|
|
2308
|
-
|
|
2309
|
-
address,
|
|
2310
|
-
isProd = true,
|
|
2311
|
-
...params
|
|
2312
|
-
}) => {
|
|
2317
|
+
var searchMarketAuth = async ({ accessToken, address, ...params }, envParams) => {
|
|
2318
|
+
const isProd = envParams?.isProd ?? true;
|
|
2313
2319
|
return http.get(
|
|
2314
2320
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/ac-search`,
|
|
2315
2321
|
params,
|
|
@@ -2321,21 +2327,15 @@ var searchMarketAuth = async ({
|
|
|
2321
2327
|
}
|
|
2322
2328
|
);
|
|
2323
2329
|
};
|
|
2324
|
-
var searchMarket = async ({
|
|
2325
|
-
isProd = true
|
|
2326
|
-
...params
|
|
2327
|
-
}) => {
|
|
2330
|
+
var searchMarket = async ({ ...params }, envParams) => {
|
|
2331
|
+
const isProd = envParams?.isProd ?? true;
|
|
2328
2332
|
return http.get(
|
|
2329
2333
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/search`,
|
|
2330
2334
|
params
|
|
2331
2335
|
);
|
|
2332
2336
|
};
|
|
2333
|
-
var addFavorite = async ({
|
|
2334
|
-
|
|
2335
|
-
address,
|
|
2336
|
-
isProd = true,
|
|
2337
|
-
...params
|
|
2338
|
-
}) => {
|
|
2337
|
+
var addFavorite = async ({ accessToken, address, ...params }, envParams) => {
|
|
2338
|
+
const isProd = envParams?.isProd ?? true;
|
|
2339
2339
|
return http.get(
|
|
2340
2340
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/add-favorites`,
|
|
2341
2341
|
params,
|
|
@@ -2350,9 +2350,9 @@ var addFavorite = async ({
|
|
|
2350
2350
|
var removeFavorite = async ({
|
|
2351
2351
|
accessToken,
|
|
2352
2352
|
address,
|
|
2353
|
-
isProd = true,
|
|
2354
2353
|
...params
|
|
2355
|
-
}) => {
|
|
2354
|
+
}, envParams) => {
|
|
2355
|
+
const isProd = envParams?.isProd ?? true;
|
|
2356
2356
|
return http.get(
|
|
2357
2357
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/cancel-favorites`,
|
|
2358
2358
|
params,
|
|
@@ -2364,12 +2364,8 @@ var removeFavorite = async ({
|
|
|
2364
2364
|
}
|
|
2365
2365
|
);
|
|
2366
2366
|
};
|
|
2367
|
-
var getFavoritesList = async ({
|
|
2368
|
-
|
|
2369
|
-
address,
|
|
2370
|
-
isProd = true,
|
|
2371
|
-
...params
|
|
2372
|
-
}) => {
|
|
2367
|
+
var getFavoritesList = async ({ accessToken, address, ...params }, envParams) => {
|
|
2368
|
+
const isProd = envParams?.isProd ?? true;
|
|
2373
2369
|
return http.get(
|
|
2374
2370
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/favorites`,
|
|
2375
2371
|
params,
|
|
@@ -2381,28 +2377,25 @@ var getFavoritesList = async ({
|
|
|
2381
2377
|
}
|
|
2382
2378
|
);
|
|
2383
2379
|
};
|
|
2384
|
-
var getBaseDetail = async ({
|
|
2385
|
-
isProd = true
|
|
2386
|
-
...params
|
|
2387
|
-
}) => {
|
|
2380
|
+
var getBaseDetail = async ({ ...params }, envParams) => {
|
|
2381
|
+
const isProd = envParams?.isProd ?? true;
|
|
2388
2382
|
return http.get(
|
|
2389
2383
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/base-details`,
|
|
2390
2384
|
params
|
|
2391
2385
|
);
|
|
2392
2386
|
};
|
|
2393
|
-
var getMarketDetail = async ({
|
|
2394
|
-
isProd = true
|
|
2395
|
-
...params
|
|
2396
|
-
}) => {
|
|
2387
|
+
var getMarketDetail = async ({ ...params }, envParams) => {
|
|
2388
|
+
const isProd = envParams?.isProd ?? true;
|
|
2397
2389
|
return http.get(
|
|
2398
2390
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/detail`,
|
|
2399
2391
|
params
|
|
2400
2392
|
);
|
|
2401
2393
|
};
|
|
2402
|
-
var getMarketList = async ({
|
|
2403
|
-
isProd = true
|
|
2404
|
-
|
|
2405
|
-
|
|
2394
|
+
var getMarketList = async (envParams) => {
|
|
2395
|
+
const isProd = envParams?.isProd ?? true;
|
|
2396
|
+
return http.get(
|
|
2397
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market`
|
|
2398
|
+
);
|
|
2406
2399
|
};
|
|
2407
2400
|
|
|
2408
2401
|
// src/web3/index.ts
|
|
@@ -14244,19 +14237,31 @@ var Markets = class {
|
|
|
14244
14237
|
interval,
|
|
14245
14238
|
...params
|
|
14246
14239
|
}) {
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14240
|
+
const config = this.configManager.getConfig();
|
|
14241
|
+
return (await getKlineData(
|
|
14242
|
+
{
|
|
14243
|
+
...params,
|
|
14244
|
+
interval: this.utils.transferKlineResolutionToInterval(interval)
|
|
14245
|
+
},
|
|
14246
|
+
{
|
|
14247
|
+
isProd: !config?.isTestnet
|
|
14248
|
+
}
|
|
14249
|
+
)).data;
|
|
14251
14250
|
}
|
|
14252
14251
|
async getKlineLatestBar({
|
|
14253
14252
|
interval,
|
|
14254
14253
|
...params
|
|
14255
14254
|
}) {
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14255
|
+
const config = this.configManager.getConfig();
|
|
14256
|
+
return (await getKlineLatestBar(
|
|
14257
|
+
{
|
|
14258
|
+
...params,
|
|
14259
|
+
interval: this.utils.transferKlineResolutionToInterval(interval)
|
|
14260
|
+
},
|
|
14261
|
+
{
|
|
14262
|
+
isProd: !config?.isTestnet
|
|
14263
|
+
}
|
|
14264
|
+
)).data;
|
|
14260
14265
|
}
|
|
14261
14266
|
/**
|
|
14262
14267
|
* kline end
|
|
@@ -14265,7 +14270,10 @@ var Markets = class {
|
|
|
14265
14270
|
* ticker start
|
|
14266
14271
|
*/
|
|
14267
14272
|
async getTickerList(params) {
|
|
14268
|
-
|
|
14273
|
+
const config = this.configManager.getConfig();
|
|
14274
|
+
return (await getTickerData(params, {
|
|
14275
|
+
isProd: !config?.isTestnet
|
|
14276
|
+
})).data;
|
|
14269
14277
|
}
|
|
14270
14278
|
/**
|
|
14271
14279
|
* ticker end
|
|
@@ -14276,6 +14284,7 @@ var Markets = class {
|
|
|
14276
14284
|
*
|
|
14277
14285
|
*/
|
|
14278
14286
|
async searchMarketAuth(params, address) {
|
|
14287
|
+
const config = this.configManager.getConfig();
|
|
14279
14288
|
const accessToken = await this.configManager.getAccessToken();
|
|
14280
14289
|
if (!accessToken) {
|
|
14281
14290
|
throw new MyxSDKError(
|
|
@@ -14283,23 +14292,32 @@ var Markets = class {
|
|
|
14283
14292
|
"Invalid access token"
|
|
14284
14293
|
);
|
|
14285
14294
|
}
|
|
14286
|
-
return (await searchMarketAuth(
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14295
|
+
return (await searchMarketAuth(
|
|
14296
|
+
{
|
|
14297
|
+
address,
|
|
14298
|
+
...params,
|
|
14299
|
+
accessToken
|
|
14300
|
+
},
|
|
14301
|
+
{
|
|
14302
|
+
isProd: !config?.isTestnet
|
|
14303
|
+
}
|
|
14304
|
+
)).data;
|
|
14291
14305
|
}
|
|
14292
14306
|
/**
|
|
14293
14307
|
* search by unauthenticated users
|
|
14294
14308
|
*/
|
|
14295
14309
|
async searchMarket(params) {
|
|
14296
|
-
|
|
14310
|
+
const config = this.configManager.getConfig();
|
|
14311
|
+
return (await searchMarket(params, {
|
|
14312
|
+
isProd: !config?.isTestnet
|
|
14313
|
+
})).data;
|
|
14297
14314
|
}
|
|
14298
14315
|
/**
|
|
14299
14316
|
* get favorites list
|
|
14300
14317
|
* (only for authenticated users)
|
|
14301
14318
|
*/
|
|
14302
14319
|
async getFavoritesList(params, address) {
|
|
14320
|
+
const config = this.configManager.getConfig();
|
|
14303
14321
|
const accessToken = await this.configManager.getAccessToken();
|
|
14304
14322
|
if (!accessToken) {
|
|
14305
14323
|
throw new MyxSDKError(
|
|
@@ -14307,16 +14325,22 @@ var Markets = class {
|
|
|
14307
14325
|
"Invalid access token"
|
|
14308
14326
|
);
|
|
14309
14327
|
}
|
|
14310
|
-
return (await getFavoritesList(
|
|
14311
|
-
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14328
|
+
return (await getFavoritesList(
|
|
14329
|
+
{
|
|
14330
|
+
...params,
|
|
14331
|
+
address,
|
|
14332
|
+
accessToken
|
|
14333
|
+
},
|
|
14334
|
+
{
|
|
14335
|
+
isProd: !config?.isTestnet
|
|
14336
|
+
}
|
|
14337
|
+
)).data;
|
|
14315
14338
|
}
|
|
14316
14339
|
/**
|
|
14317
14340
|
* favorite
|
|
14318
14341
|
*/
|
|
14319
14342
|
async addFavorite(params, address) {
|
|
14343
|
+
const config = this.configManager.getConfig();
|
|
14320
14344
|
const accessToken = await this.configManager.getAccessToken();
|
|
14321
14345
|
if (!accessToken) {
|
|
14322
14346
|
throw new MyxSDKError(
|
|
@@ -14324,13 +14348,19 @@ var Markets = class {
|
|
|
14324
14348
|
"Invalid access token"
|
|
14325
14349
|
);
|
|
14326
14350
|
}
|
|
14327
|
-
return (await addFavorite(
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14351
|
+
return (await addFavorite(
|
|
14352
|
+
{
|
|
14353
|
+
...params,
|
|
14354
|
+
address,
|
|
14355
|
+
accessToken
|
|
14356
|
+
},
|
|
14357
|
+
{
|
|
14358
|
+
isProd: !config?.isTestnet
|
|
14359
|
+
}
|
|
14360
|
+
)).data;
|
|
14332
14361
|
}
|
|
14333
14362
|
async removeFavorite(params, address) {
|
|
14363
|
+
const config = this.configManager.getConfig();
|
|
14334
14364
|
const accessToken = await this.configManager.getAccessToken();
|
|
14335
14365
|
if (!accessToken) {
|
|
14336
14366
|
throw new MyxSDKError(
|
|
@@ -14338,29 +14368,43 @@ var Markets = class {
|
|
|
14338
14368
|
"Invalid access token"
|
|
14339
14369
|
);
|
|
14340
14370
|
}
|
|
14341
|
-
return (await removeFavorite(
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
14371
|
+
return (await removeFavorite(
|
|
14372
|
+
{
|
|
14373
|
+
...params,
|
|
14374
|
+
address,
|
|
14375
|
+
accessToken
|
|
14376
|
+
},
|
|
14377
|
+
{
|
|
14378
|
+
isProd: !config?.isTestnet
|
|
14379
|
+
}
|
|
14380
|
+
)).data;
|
|
14346
14381
|
}
|
|
14347
14382
|
/**
|
|
14348
14383
|
* base detail
|
|
14349
14384
|
*/
|
|
14350
14385
|
async getBaseDetail(params) {
|
|
14351
|
-
|
|
14386
|
+
const config = this.configManager.getConfig();
|
|
14387
|
+
return (await getBaseDetail(params, {
|
|
14388
|
+
isProd: !config?.isTestnet
|
|
14389
|
+
})).data;
|
|
14352
14390
|
}
|
|
14353
14391
|
/**
|
|
14354
14392
|
* get market detail
|
|
14355
14393
|
*/
|
|
14356
14394
|
async getMarketDetail(params) {
|
|
14357
|
-
|
|
14395
|
+
const config = this.configManager.getConfig();
|
|
14396
|
+
return (await getMarketDetail(params, {
|
|
14397
|
+
isProd: !config?.isTestnet
|
|
14398
|
+
})).data;
|
|
14358
14399
|
}
|
|
14359
14400
|
/**
|
|
14360
14401
|
* get pool symbol all
|
|
14361
14402
|
*/
|
|
14362
14403
|
async getPoolSymbolAll() {
|
|
14363
|
-
|
|
14404
|
+
const config = this.configManager.getConfig();
|
|
14405
|
+
return (await getPoolSymbolAll({
|
|
14406
|
+
isProd: !config?.isTestnet
|
|
14407
|
+
})).data;
|
|
14364
14408
|
}
|
|
14365
14409
|
};
|
|
14366
14410
|
|
|
@@ -14399,7 +14443,7 @@ var Position = class {
|
|
|
14399
14443
|
}
|
|
14400
14444
|
}
|
|
14401
14445
|
async getPositionHistory(params, address) {
|
|
14402
|
-
const
|
|
14446
|
+
const config = this.configManager.getConfig();
|
|
14403
14447
|
const accessToken = await this.configManager.getAccessToken();
|
|
14404
14448
|
if (!accessToken) {
|
|
14405
14449
|
throw new MyxSDKError(
|
|
@@ -14407,7 +14451,12 @@ var Position = class {
|
|
|
14407
14451
|
"Invalid access token"
|
|
14408
14452
|
);
|
|
14409
14453
|
}
|
|
14410
|
-
const res = await getPositionHistory(
|
|
14454
|
+
const res = await getPositionHistory(
|
|
14455
|
+
{ accessToken, ...params, address },
|
|
14456
|
+
{
|
|
14457
|
+
isProd: !config?.isTestnet
|
|
14458
|
+
}
|
|
14459
|
+
);
|
|
14411
14460
|
return {
|
|
14412
14461
|
code: 0,
|
|
14413
14462
|
data: res.data
|
|
@@ -14453,7 +14502,11 @@ var Position = class {
|
|
|
14453
14502
|
const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
|
|
14454
14503
|
let depositAmount = BigInt(0);
|
|
14455
14504
|
const used = BigInt(adjustAmount) > 0 ? BigInt(adjustAmount) : 0n;
|
|
14456
|
-
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14505
|
+
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14506
|
+
poolId,
|
|
14507
|
+
chainId,
|
|
14508
|
+
address
|
|
14509
|
+
});
|
|
14457
14510
|
let diff = BigInt(0);
|
|
14458
14511
|
if (availableAccountMarginBalance < used) {
|
|
14459
14512
|
diff = used - availableAccountMarginBalance;
|
|
@@ -14475,21 +14528,24 @@ var Position = class {
|
|
|
14475
14528
|
throw new Error(approvalResult.message);
|
|
14476
14529
|
}
|
|
14477
14530
|
}
|
|
14478
|
-
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14531
|
+
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14532
|
+
config.seamlessAccount?.masterAddress
|
|
14533
|
+
);
|
|
14479
14534
|
if (!isEnoughGas) {
|
|
14480
|
-
throw new MyxSDKError(
|
|
14535
|
+
throw new MyxSDKError(
|
|
14536
|
+
"INSUFFICIENT_BALANCE" /* InsufficientBalance */,
|
|
14537
|
+
"Insufficient relay fee"
|
|
14538
|
+
);
|
|
14481
14539
|
}
|
|
14482
14540
|
const forwarderContract = await getForwarderContract(chainId);
|
|
14483
14541
|
const brokerContract2 = await getSeamlessBrokerContract(
|
|
14484
14542
|
this.configManager.getConfig().brokerAddress,
|
|
14485
14543
|
seamlessWallet
|
|
14486
14544
|
);
|
|
14487
|
-
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14488
|
-
|
|
14489
|
-
depositData,
|
|
14490
|
-
|
|
14491
|
-
adjustAmount
|
|
14492
|
-
]);
|
|
14545
|
+
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14546
|
+
"updatePriceAndAdjustCollateral",
|
|
14547
|
+
[[updateParams], depositData, positionId, adjustAmount]
|
|
14548
|
+
);
|
|
14493
14549
|
const nonce = await forwarderContract.nonces(seamlessWallet.address);
|
|
14494
14550
|
const forwardTxParams = {
|
|
14495
14551
|
from: seamlessWallet.address ?? "",
|
|
@@ -14500,8 +14556,15 @@ var Position = class {
|
|
|
14500
14556
|
data: functionHash,
|
|
14501
14557
|
nonce: nonce.toString()
|
|
14502
14558
|
};
|
|
14503
|
-
this.logger.info(
|
|
14504
|
-
|
|
14559
|
+
this.logger.info(
|
|
14560
|
+
"adjust collateral forward tx params --->",
|
|
14561
|
+
forwardTxParams
|
|
14562
|
+
);
|
|
14563
|
+
const rs = await this.seamless.forwarderTx(
|
|
14564
|
+
forwardTxParams,
|
|
14565
|
+
chainId,
|
|
14566
|
+
seamlessWallet
|
|
14567
|
+
);
|
|
14505
14568
|
console.log("rs-->", rs);
|
|
14506
14569
|
return {
|
|
14507
14570
|
code: 0,
|
|
@@ -15620,15 +15683,17 @@ var Order = class {
|
|
|
15620
15683
|
}
|
|
15621
15684
|
}
|
|
15622
15685
|
async getOrderHistory(params, address) {
|
|
15686
|
+
const config = this.configManager.getConfig();
|
|
15623
15687
|
const accessToken = await this.configManager.getAccessToken();
|
|
15624
|
-
const isProd = !this.configManager.getConfig().isTestnet;
|
|
15625
15688
|
if (!accessToken) {
|
|
15626
15689
|
throw new MyxSDKError(
|
|
15627
15690
|
"INVALID_ACCESS_TOKEN" /* InvalidAccessToken */,
|
|
15628
15691
|
"Invalid access token"
|
|
15629
15692
|
);
|
|
15630
15693
|
}
|
|
15631
|
-
const res = await getHistoryOrders({ accessToken, ...params, address,
|
|
15694
|
+
const res = await getHistoryOrders({ accessToken, ...params, address }, {
|
|
15695
|
+
isProd: !config?.isTestnet
|
|
15696
|
+
});
|
|
15632
15697
|
return {
|
|
15633
15698
|
code: 0,
|
|
15634
15699
|
data: res.data
|
|
@@ -21422,7 +21487,7 @@ var Account = class {
|
|
|
21422
21487
|
}
|
|
21423
21488
|
}
|
|
21424
21489
|
async getTradeFlow(params, address) {
|
|
21425
|
-
const
|
|
21490
|
+
const config = this.configManager.getConfig();
|
|
21426
21491
|
const accessToken = await this.configManager.getAccessToken();
|
|
21427
21492
|
if (!accessToken) {
|
|
21428
21493
|
throw new MyxSDKError(
|
|
@@ -21430,7 +21495,9 @@ var Account = class {
|
|
|
21430
21495
|
"Invalid access token"
|
|
21431
21496
|
);
|
|
21432
21497
|
}
|
|
21433
|
-
const res = await getTradeFlow({ accessToken, ...params, address,
|
|
21498
|
+
const res = await getTradeFlow({ accessToken, ...params, address }, {
|
|
21499
|
+
isProd: !config?.isTestnet
|
|
21500
|
+
});
|
|
21434
21501
|
return {
|
|
21435
21502
|
code: 0,
|
|
21436
21503
|
data: res.data
|