@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.mjs
CHANGED
|
@@ -1731,7 +1731,7 @@ var RotationProvider = class extends BaseProvider {
|
|
|
1731
1731
|
// package.json
|
|
1732
1732
|
var package_default = {
|
|
1733
1733
|
name: "@myx-trade/sdk",
|
|
1734
|
-
version: "0.1.
|
|
1734
|
+
version: "0.1.191",
|
|
1735
1735
|
private: false,
|
|
1736
1736
|
publishConfig: {
|
|
1737
1737
|
access: "public"
|
|
@@ -1996,9 +1996,9 @@ var ExecTypeEnum = /* @__PURE__ */ ((ExecTypeEnum2) => {
|
|
|
1996
1996
|
var getHistoryOrders = async ({
|
|
1997
1997
|
accessToken,
|
|
1998
1998
|
address,
|
|
1999
|
-
isProd = true,
|
|
2000
1999
|
...params
|
|
2001
|
-
}) => {
|
|
2000
|
+
}, envParams) => {
|
|
2001
|
+
const isProd = envParams?.isProd ?? true;
|
|
2002
2002
|
return http.get(
|
|
2003
2003
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/closed`,
|
|
2004
2004
|
params,
|
|
@@ -2026,9 +2026,9 @@ var CloseTypeEnum = /* @__PURE__ */ ((CloseTypeEnum2) => {
|
|
|
2026
2026
|
var getPositionHistory = async ({
|
|
2027
2027
|
accessToken,
|
|
2028
2028
|
address,
|
|
2029
|
-
isProd = true,
|
|
2030
2029
|
...params
|
|
2031
|
-
}) => {
|
|
2030
|
+
}, envParams) => {
|
|
2031
|
+
const isProd = envParams?.isProd ?? true;
|
|
2032
2032
|
return http.get(
|
|
2033
2033
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/position/closed`,
|
|
2034
2034
|
params,
|
|
@@ -2049,9 +2049,9 @@ var TradeFlowAccountTypeEnum = /* @__PURE__ */ ((TradeFlowAccountTypeEnum2) => {
|
|
|
2049
2049
|
var getTradeFlow = async ({
|
|
2050
2050
|
accessToken,
|
|
2051
2051
|
address,
|
|
2052
|
-
isProd = true,
|
|
2053
2052
|
...params
|
|
2054
|
-
}) => {
|
|
2053
|
+
}, envParams) => {
|
|
2054
|
+
const isProd = envParams?.isProd ?? true;
|
|
2055
2055
|
return http.get(
|
|
2056
2056
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/trade/flow`,
|
|
2057
2057
|
params,
|
|
@@ -2115,10 +2115,13 @@ var getForwardUrlByEnv = (isProd) => {
|
|
|
2115
2115
|
};
|
|
2116
2116
|
var getOraclePrice = async (chainId, poolIds = [], isProd = true) => {
|
|
2117
2117
|
if (!!poolIds.length) {
|
|
2118
|
-
return http.get(
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2118
|
+
return http.get(
|
|
2119
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/price/oracles`,
|
|
2120
|
+
{
|
|
2121
|
+
chainId,
|
|
2122
|
+
poolIds: poolIds.join(",")
|
|
2123
|
+
}
|
|
2124
|
+
);
|
|
2122
2125
|
}
|
|
2123
2126
|
return Promise.reject(new Error("Invalid pool id"));
|
|
2124
2127
|
};
|
|
@@ -2128,7 +2131,9 @@ var getPoolLevelConfig = async ({
|
|
|
2128
2131
|
isProd = true
|
|
2129
2132
|
}) => {
|
|
2130
2133
|
return http.get(
|
|
2131
|
-
`${getBaseUrlByEnv(
|
|
2134
|
+
`${getBaseUrlByEnv(
|
|
2135
|
+
isProd
|
|
2136
|
+
)}/openapi/gateway/risk/market_pool/level_config${addQueryParams({
|
|
2132
2137
|
poolId,
|
|
2133
2138
|
chainId
|
|
2134
2139
|
})}`
|
|
@@ -2136,7 +2141,9 @@ var getPoolLevelConfig = async ({
|
|
|
2136
2141
|
};
|
|
2137
2142
|
var getPoolDetail = async (chainId, poolId, isProd = true) => {
|
|
2138
2143
|
return await http.get(
|
|
2139
|
-
`${getBaseUrlByEnv(
|
|
2144
|
+
`${getBaseUrlByEnv(
|
|
2145
|
+
isProd
|
|
2146
|
+
)}/openapi/gateway/scan/market/info?chainId=${chainId}&poolId=${poolId}`
|
|
2140
2147
|
);
|
|
2141
2148
|
};
|
|
2142
2149
|
var getPositions = async (accessToken, address, isProd = true) => {
|
|
@@ -2156,24 +2163,30 @@ var getOrders = async (accessToken, address, isProd = true) => {
|
|
|
2156
2163
|
return await http.get(
|
|
2157
2164
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/open`,
|
|
2158
2165
|
void 0,
|
|
2159
|
-
{
|
|
2166
|
+
{
|
|
2167
|
+
headers: {
|
|
2168
|
+
myx_openapi_access_token: accessToken,
|
|
2169
|
+
myx_openapi_account: address
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2160
2172
|
);
|
|
2161
2173
|
};
|
|
2162
2174
|
var getPoolOpenOrders = async (accessToken, address, chainId, isProd = true) => {
|
|
2163
2175
|
return await http.get(
|
|
2164
|
-
`${getBaseUrlByEnv(
|
|
2176
|
+
`${getBaseUrlByEnv(
|
|
2177
|
+
isProd
|
|
2178
|
+
)}/openapi/gateway/scan/market/pool-order/open?chainId=${chainId}`,
|
|
2165
2179
|
void 0,
|
|
2166
|
-
{
|
|
2180
|
+
{
|
|
2181
|
+
headers: {
|
|
2182
|
+
myx_openapi_access_token: accessToken,
|
|
2183
|
+
myx_openapi_account: address
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2167
2186
|
);
|
|
2168
2187
|
};
|
|
2169
|
-
var getKlineData = ({
|
|
2170
|
-
|
|
2171
|
-
poolId,
|
|
2172
|
-
endTime,
|
|
2173
|
-
limit,
|
|
2174
|
-
interval,
|
|
2175
|
-
isProd = true
|
|
2176
|
-
}) => {
|
|
2188
|
+
var getKlineData = ({ chainId, poolId, endTime, limit, interval }, envParams) => {
|
|
2189
|
+
const isProd = envParams?.isProd ?? true;
|
|
2177
2190
|
return http.get(
|
|
2178
2191
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candles`,
|
|
2179
2192
|
{
|
|
@@ -2185,17 +2198,15 @@ var getKlineData = ({
|
|
|
2185
2198
|
}
|
|
2186
2199
|
);
|
|
2187
2200
|
};
|
|
2188
|
-
var getKlineLatestBar = async (params,
|
|
2201
|
+
var getKlineLatestBar = async (params, envParams) => {
|
|
2202
|
+
const isProd = envParams?.isProd ?? true;
|
|
2189
2203
|
return http.get(
|
|
2190
2204
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/latest`,
|
|
2191
2205
|
params
|
|
2192
2206
|
);
|
|
2193
2207
|
};
|
|
2194
|
-
var getTickerData = async ({
|
|
2195
|
-
|
|
2196
|
-
poolIds,
|
|
2197
|
-
isProd = true
|
|
2198
|
-
}) => {
|
|
2208
|
+
var getTickerData = async ({ chainId, poolIds }, envParams) => {
|
|
2209
|
+
const isProd = envParams?.isProd ?? true;
|
|
2199
2210
|
return http.get(
|
|
2200
2211
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/tickers`,
|
|
2201
2212
|
{
|
|
@@ -2204,19 +2215,14 @@ var getTickerData = async ({
|
|
|
2204
2215
|
}
|
|
2205
2216
|
);
|
|
2206
2217
|
};
|
|
2207
|
-
var getAllTickers = async ({
|
|
2208
|
-
isProd = true
|
|
2209
|
-
}) => {
|
|
2218
|
+
var getAllTickers = async (envParams) => {
|
|
2219
|
+
const isProd = envParams?.isProd ?? true;
|
|
2210
2220
|
return http.get(
|
|
2211
2221
|
`${getBaseUrlByEnv(isProd)}/v2/mx-gateway/quote/candle/all_tickers`
|
|
2212
2222
|
);
|
|
2213
2223
|
};
|
|
2214
|
-
var searchMarketAuth = async ({
|
|
2215
|
-
|
|
2216
|
-
address,
|
|
2217
|
-
isProd = true,
|
|
2218
|
-
...params
|
|
2219
|
-
}) => {
|
|
2224
|
+
var searchMarketAuth = async ({ accessToken, address, ...params }, envParams) => {
|
|
2225
|
+
const isProd = envParams?.isProd ?? true;
|
|
2220
2226
|
return http.get(
|
|
2221
2227
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/ac-search`,
|
|
2222
2228
|
params,
|
|
@@ -2228,21 +2234,15 @@ var searchMarketAuth = async ({
|
|
|
2228
2234
|
}
|
|
2229
2235
|
);
|
|
2230
2236
|
};
|
|
2231
|
-
var searchMarket = async ({
|
|
2232
|
-
isProd = true
|
|
2233
|
-
...params
|
|
2234
|
-
}) => {
|
|
2237
|
+
var searchMarket = async ({ ...params }, envParams) => {
|
|
2238
|
+
const isProd = envParams?.isProd ?? true;
|
|
2235
2239
|
return http.get(
|
|
2236
2240
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/search`,
|
|
2237
2241
|
params
|
|
2238
2242
|
);
|
|
2239
2243
|
};
|
|
2240
|
-
var addFavorite = async ({
|
|
2241
|
-
|
|
2242
|
-
address,
|
|
2243
|
-
isProd = true,
|
|
2244
|
-
...params
|
|
2245
|
-
}) => {
|
|
2244
|
+
var addFavorite = async ({ accessToken, address, ...params }, envParams) => {
|
|
2245
|
+
const isProd = envParams?.isProd ?? true;
|
|
2246
2246
|
return http.get(
|
|
2247
2247
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/add-favorites`,
|
|
2248
2248
|
params,
|
|
@@ -2257,9 +2257,9 @@ var addFavorite = async ({
|
|
|
2257
2257
|
var removeFavorite = async ({
|
|
2258
2258
|
accessToken,
|
|
2259
2259
|
address,
|
|
2260
|
-
isProd = true,
|
|
2261
2260
|
...params
|
|
2262
|
-
}) => {
|
|
2261
|
+
}, envParams) => {
|
|
2262
|
+
const isProd = envParams?.isProd ?? true;
|
|
2263
2263
|
return http.get(
|
|
2264
2264
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/cancel-favorites`,
|
|
2265
2265
|
params,
|
|
@@ -2271,12 +2271,8 @@ var removeFavorite = async ({
|
|
|
2271
2271
|
}
|
|
2272
2272
|
);
|
|
2273
2273
|
};
|
|
2274
|
-
var getFavoritesList = async ({
|
|
2275
|
-
|
|
2276
|
-
address,
|
|
2277
|
-
isProd = true,
|
|
2278
|
-
...params
|
|
2279
|
-
}) => {
|
|
2274
|
+
var getFavoritesList = async ({ accessToken, address, ...params }, envParams) => {
|
|
2275
|
+
const isProd = envParams?.isProd ?? true;
|
|
2280
2276
|
return http.get(
|
|
2281
2277
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/favorites`,
|
|
2282
2278
|
params,
|
|
@@ -2288,28 +2284,25 @@ var getFavoritesList = async ({
|
|
|
2288
2284
|
}
|
|
2289
2285
|
);
|
|
2290
2286
|
};
|
|
2291
|
-
var getBaseDetail = async ({
|
|
2292
|
-
isProd = true
|
|
2293
|
-
...params
|
|
2294
|
-
}) => {
|
|
2287
|
+
var getBaseDetail = async ({ ...params }, envParams) => {
|
|
2288
|
+
const isProd = envParams?.isProd ?? true;
|
|
2295
2289
|
return http.get(
|
|
2296
2290
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/base-details`,
|
|
2297
2291
|
params
|
|
2298
2292
|
);
|
|
2299
2293
|
};
|
|
2300
|
-
var getMarketDetail = async ({
|
|
2301
|
-
isProd = true
|
|
2302
|
-
...params
|
|
2303
|
-
}) => {
|
|
2294
|
+
var getMarketDetail = async ({ ...params }, envParams) => {
|
|
2295
|
+
const isProd = envParams?.isProd ?? true;
|
|
2304
2296
|
return http.get(
|
|
2305
2297
|
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/detail`,
|
|
2306
2298
|
params
|
|
2307
2299
|
);
|
|
2308
2300
|
};
|
|
2309
|
-
var getMarketList = async ({
|
|
2310
|
-
isProd = true
|
|
2311
|
-
|
|
2312
|
-
|
|
2301
|
+
var getMarketList = async (envParams) => {
|
|
2302
|
+
const isProd = envParams?.isProd ?? true;
|
|
2303
|
+
return http.get(
|
|
2304
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market`
|
|
2305
|
+
);
|
|
2313
2306
|
};
|
|
2314
2307
|
|
|
2315
2308
|
// src/web3/index.ts
|
|
@@ -14151,19 +14144,31 @@ var Markets = class {
|
|
|
14151
14144
|
interval,
|
|
14152
14145
|
...params
|
|
14153
14146
|
}) {
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14147
|
+
const config = this.configManager.getConfig();
|
|
14148
|
+
return (await getKlineData(
|
|
14149
|
+
{
|
|
14150
|
+
...params,
|
|
14151
|
+
interval: this.utils.transferKlineResolutionToInterval(interval)
|
|
14152
|
+
},
|
|
14153
|
+
{
|
|
14154
|
+
isProd: !config?.isTestnet
|
|
14155
|
+
}
|
|
14156
|
+
)).data;
|
|
14158
14157
|
}
|
|
14159
14158
|
async getKlineLatestBar({
|
|
14160
14159
|
interval,
|
|
14161
14160
|
...params
|
|
14162
14161
|
}) {
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14162
|
+
const config = this.configManager.getConfig();
|
|
14163
|
+
return (await getKlineLatestBar(
|
|
14164
|
+
{
|
|
14165
|
+
...params,
|
|
14166
|
+
interval: this.utils.transferKlineResolutionToInterval(interval)
|
|
14167
|
+
},
|
|
14168
|
+
{
|
|
14169
|
+
isProd: !config?.isTestnet
|
|
14170
|
+
}
|
|
14171
|
+
)).data;
|
|
14167
14172
|
}
|
|
14168
14173
|
/**
|
|
14169
14174
|
* kline end
|
|
@@ -14172,7 +14177,10 @@ var Markets = class {
|
|
|
14172
14177
|
* ticker start
|
|
14173
14178
|
*/
|
|
14174
14179
|
async getTickerList(params) {
|
|
14175
|
-
|
|
14180
|
+
const config = this.configManager.getConfig();
|
|
14181
|
+
return (await getTickerData(params, {
|
|
14182
|
+
isProd: !config?.isTestnet
|
|
14183
|
+
})).data;
|
|
14176
14184
|
}
|
|
14177
14185
|
/**
|
|
14178
14186
|
* ticker end
|
|
@@ -14183,6 +14191,7 @@ var Markets = class {
|
|
|
14183
14191
|
*
|
|
14184
14192
|
*/
|
|
14185
14193
|
async searchMarketAuth(params, address) {
|
|
14194
|
+
const config = this.configManager.getConfig();
|
|
14186
14195
|
const accessToken = await this.configManager.getAccessToken();
|
|
14187
14196
|
if (!accessToken) {
|
|
14188
14197
|
throw new MyxSDKError(
|
|
@@ -14190,23 +14199,32 @@ var Markets = class {
|
|
|
14190
14199
|
"Invalid access token"
|
|
14191
14200
|
);
|
|
14192
14201
|
}
|
|
14193
|
-
return (await searchMarketAuth(
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14202
|
+
return (await searchMarketAuth(
|
|
14203
|
+
{
|
|
14204
|
+
address,
|
|
14205
|
+
...params,
|
|
14206
|
+
accessToken
|
|
14207
|
+
},
|
|
14208
|
+
{
|
|
14209
|
+
isProd: !config?.isTestnet
|
|
14210
|
+
}
|
|
14211
|
+
)).data;
|
|
14198
14212
|
}
|
|
14199
14213
|
/**
|
|
14200
14214
|
* search by unauthenticated users
|
|
14201
14215
|
*/
|
|
14202
14216
|
async searchMarket(params) {
|
|
14203
|
-
|
|
14217
|
+
const config = this.configManager.getConfig();
|
|
14218
|
+
return (await searchMarket(params, {
|
|
14219
|
+
isProd: !config?.isTestnet
|
|
14220
|
+
})).data;
|
|
14204
14221
|
}
|
|
14205
14222
|
/**
|
|
14206
14223
|
* get favorites list
|
|
14207
14224
|
* (only for authenticated users)
|
|
14208
14225
|
*/
|
|
14209
14226
|
async getFavoritesList(params, address) {
|
|
14227
|
+
const config = this.configManager.getConfig();
|
|
14210
14228
|
const accessToken = await this.configManager.getAccessToken();
|
|
14211
14229
|
if (!accessToken) {
|
|
14212
14230
|
throw new MyxSDKError(
|
|
@@ -14214,16 +14232,22 @@ var Markets = class {
|
|
|
14214
14232
|
"Invalid access token"
|
|
14215
14233
|
);
|
|
14216
14234
|
}
|
|
14217
|
-
return (await getFavoritesList(
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14235
|
+
return (await getFavoritesList(
|
|
14236
|
+
{
|
|
14237
|
+
...params,
|
|
14238
|
+
address,
|
|
14239
|
+
accessToken
|
|
14240
|
+
},
|
|
14241
|
+
{
|
|
14242
|
+
isProd: !config?.isTestnet
|
|
14243
|
+
}
|
|
14244
|
+
)).data;
|
|
14222
14245
|
}
|
|
14223
14246
|
/**
|
|
14224
14247
|
* favorite
|
|
14225
14248
|
*/
|
|
14226
14249
|
async addFavorite(params, address) {
|
|
14250
|
+
const config = this.configManager.getConfig();
|
|
14227
14251
|
const accessToken = await this.configManager.getAccessToken();
|
|
14228
14252
|
if (!accessToken) {
|
|
14229
14253
|
throw new MyxSDKError(
|
|
@@ -14231,13 +14255,19 @@ var Markets = class {
|
|
|
14231
14255
|
"Invalid access token"
|
|
14232
14256
|
);
|
|
14233
14257
|
}
|
|
14234
|
-
return (await addFavorite(
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14258
|
+
return (await addFavorite(
|
|
14259
|
+
{
|
|
14260
|
+
...params,
|
|
14261
|
+
address,
|
|
14262
|
+
accessToken
|
|
14263
|
+
},
|
|
14264
|
+
{
|
|
14265
|
+
isProd: !config?.isTestnet
|
|
14266
|
+
}
|
|
14267
|
+
)).data;
|
|
14239
14268
|
}
|
|
14240
14269
|
async removeFavorite(params, address) {
|
|
14270
|
+
const config = this.configManager.getConfig();
|
|
14241
14271
|
const accessToken = await this.configManager.getAccessToken();
|
|
14242
14272
|
if (!accessToken) {
|
|
14243
14273
|
throw new MyxSDKError(
|
|
@@ -14245,29 +14275,43 @@ var Markets = class {
|
|
|
14245
14275
|
"Invalid access token"
|
|
14246
14276
|
);
|
|
14247
14277
|
}
|
|
14248
|
-
return (await removeFavorite(
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14278
|
+
return (await removeFavorite(
|
|
14279
|
+
{
|
|
14280
|
+
...params,
|
|
14281
|
+
address,
|
|
14282
|
+
accessToken
|
|
14283
|
+
},
|
|
14284
|
+
{
|
|
14285
|
+
isProd: !config?.isTestnet
|
|
14286
|
+
}
|
|
14287
|
+
)).data;
|
|
14253
14288
|
}
|
|
14254
14289
|
/**
|
|
14255
14290
|
* base detail
|
|
14256
14291
|
*/
|
|
14257
14292
|
async getBaseDetail(params) {
|
|
14258
|
-
|
|
14293
|
+
const config = this.configManager.getConfig();
|
|
14294
|
+
return (await getBaseDetail(params, {
|
|
14295
|
+
isProd: !config?.isTestnet
|
|
14296
|
+
})).data;
|
|
14259
14297
|
}
|
|
14260
14298
|
/**
|
|
14261
14299
|
* get market detail
|
|
14262
14300
|
*/
|
|
14263
14301
|
async getMarketDetail(params) {
|
|
14264
|
-
|
|
14302
|
+
const config = this.configManager.getConfig();
|
|
14303
|
+
return (await getMarketDetail(params, {
|
|
14304
|
+
isProd: !config?.isTestnet
|
|
14305
|
+
})).data;
|
|
14265
14306
|
}
|
|
14266
14307
|
/**
|
|
14267
14308
|
* get pool symbol all
|
|
14268
14309
|
*/
|
|
14269
14310
|
async getPoolSymbolAll() {
|
|
14270
|
-
|
|
14311
|
+
const config = this.configManager.getConfig();
|
|
14312
|
+
return (await getPoolSymbolAll({
|
|
14313
|
+
isProd: !config?.isTestnet
|
|
14314
|
+
})).data;
|
|
14271
14315
|
}
|
|
14272
14316
|
};
|
|
14273
14317
|
|
|
@@ -14306,7 +14350,7 @@ var Position = class {
|
|
|
14306
14350
|
}
|
|
14307
14351
|
}
|
|
14308
14352
|
async getPositionHistory(params, address) {
|
|
14309
|
-
const
|
|
14353
|
+
const config = this.configManager.getConfig();
|
|
14310
14354
|
const accessToken = await this.configManager.getAccessToken();
|
|
14311
14355
|
if (!accessToken) {
|
|
14312
14356
|
throw new MyxSDKError(
|
|
@@ -14314,7 +14358,12 @@ var Position = class {
|
|
|
14314
14358
|
"Invalid access token"
|
|
14315
14359
|
);
|
|
14316
14360
|
}
|
|
14317
|
-
const res = await getPositionHistory(
|
|
14361
|
+
const res = await getPositionHistory(
|
|
14362
|
+
{ accessToken, ...params, address },
|
|
14363
|
+
{
|
|
14364
|
+
isProd: !config?.isTestnet
|
|
14365
|
+
}
|
|
14366
|
+
);
|
|
14318
14367
|
return {
|
|
14319
14368
|
code: 0,
|
|
14320
14369
|
data: res.data
|
|
@@ -14360,7 +14409,11 @@ var Position = class {
|
|
|
14360
14409
|
const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
|
|
14361
14410
|
let depositAmount = BigInt(0);
|
|
14362
14411
|
const used = BigInt(adjustAmount) > 0 ? BigInt(adjustAmount) : 0n;
|
|
14363
|
-
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14412
|
+
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14413
|
+
poolId,
|
|
14414
|
+
chainId,
|
|
14415
|
+
address
|
|
14416
|
+
});
|
|
14364
14417
|
let diff = BigInt(0);
|
|
14365
14418
|
if (availableAccountMarginBalance < used) {
|
|
14366
14419
|
diff = used - availableAccountMarginBalance;
|
|
@@ -14382,21 +14435,24 @@ var Position = class {
|
|
|
14382
14435
|
throw new Error(approvalResult.message);
|
|
14383
14436
|
}
|
|
14384
14437
|
}
|
|
14385
|
-
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14438
|
+
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14439
|
+
config.seamlessAccount?.masterAddress
|
|
14440
|
+
);
|
|
14386
14441
|
if (!isEnoughGas) {
|
|
14387
|
-
throw new MyxSDKError(
|
|
14442
|
+
throw new MyxSDKError(
|
|
14443
|
+
"INSUFFICIENT_BALANCE" /* InsufficientBalance */,
|
|
14444
|
+
"Insufficient relay fee"
|
|
14445
|
+
);
|
|
14388
14446
|
}
|
|
14389
14447
|
const forwarderContract = await getForwarderContract(chainId);
|
|
14390
14448
|
const brokerContract2 = await getSeamlessBrokerContract(
|
|
14391
14449
|
this.configManager.getConfig().brokerAddress,
|
|
14392
14450
|
seamlessWallet
|
|
14393
14451
|
);
|
|
14394
|
-
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14395
|
-
|
|
14396
|
-
depositData,
|
|
14397
|
-
|
|
14398
|
-
adjustAmount
|
|
14399
|
-
]);
|
|
14452
|
+
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14453
|
+
"updatePriceAndAdjustCollateral",
|
|
14454
|
+
[[updateParams], depositData, positionId, adjustAmount]
|
|
14455
|
+
);
|
|
14400
14456
|
const nonce = await forwarderContract.nonces(seamlessWallet.address);
|
|
14401
14457
|
const forwardTxParams = {
|
|
14402
14458
|
from: seamlessWallet.address ?? "",
|
|
@@ -14407,8 +14463,15 @@ var Position = class {
|
|
|
14407
14463
|
data: functionHash,
|
|
14408
14464
|
nonce: nonce.toString()
|
|
14409
14465
|
};
|
|
14410
|
-
this.logger.info(
|
|
14411
|
-
|
|
14466
|
+
this.logger.info(
|
|
14467
|
+
"adjust collateral forward tx params --->",
|
|
14468
|
+
forwardTxParams
|
|
14469
|
+
);
|
|
14470
|
+
const rs = await this.seamless.forwarderTx(
|
|
14471
|
+
forwardTxParams,
|
|
14472
|
+
chainId,
|
|
14473
|
+
seamlessWallet
|
|
14474
|
+
);
|
|
14412
14475
|
console.log("rs-->", rs);
|
|
14413
14476
|
return {
|
|
14414
14477
|
code: 0,
|
|
@@ -15527,15 +15590,17 @@ var Order = class {
|
|
|
15527
15590
|
}
|
|
15528
15591
|
}
|
|
15529
15592
|
async getOrderHistory(params, address) {
|
|
15593
|
+
const config = this.configManager.getConfig();
|
|
15530
15594
|
const accessToken = await this.configManager.getAccessToken();
|
|
15531
|
-
const isProd = !this.configManager.getConfig().isTestnet;
|
|
15532
15595
|
if (!accessToken) {
|
|
15533
15596
|
throw new MyxSDKError(
|
|
15534
15597
|
"INVALID_ACCESS_TOKEN" /* InvalidAccessToken */,
|
|
15535
15598
|
"Invalid access token"
|
|
15536
15599
|
);
|
|
15537
15600
|
}
|
|
15538
|
-
const res = await getHistoryOrders({ accessToken, ...params, address,
|
|
15601
|
+
const res = await getHistoryOrders({ accessToken, ...params, address }, {
|
|
15602
|
+
isProd: !config?.isTestnet
|
|
15603
|
+
});
|
|
15539
15604
|
return {
|
|
15540
15605
|
code: 0,
|
|
15541
15606
|
data: res.data
|
|
@@ -21329,7 +21394,7 @@ var Account = class {
|
|
|
21329
21394
|
}
|
|
21330
21395
|
}
|
|
21331
21396
|
async getTradeFlow(params, address) {
|
|
21332
|
-
const
|
|
21397
|
+
const config = this.configManager.getConfig();
|
|
21333
21398
|
const accessToken = await this.configManager.getAccessToken();
|
|
21334
21399
|
if (!accessToken) {
|
|
21335
21400
|
throw new MyxSDKError(
|
|
@@ -21337,7 +21402,9 @@ var Account = class {
|
|
|
21337
21402
|
"Invalid access token"
|
|
21338
21403
|
);
|
|
21339
21404
|
}
|
|
21340
|
-
const res = await getTradeFlow({ accessToken, ...params, address,
|
|
21405
|
+
const res = await getTradeFlow({ accessToken, ...params, address }, {
|
|
21406
|
+
isProd: !config?.isTestnet
|
|
21407
|
+
});
|
|
21341
21408
|
return {
|
|
21342
21409
|
code: 0,
|
|
21343
21410
|
data: res.data
|