@myx-trade/sdk 0.1.189 → 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 +115 -176
- package/dist/index.d.ts +115 -176
- package/dist/index.js +500 -225
- package/dist/index.mjs +498 -223
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61,19 +61,19 @@ __export(index_exports, {
|
|
|
61
61
|
addFavorite: () => addFavorite,
|
|
62
62
|
approve: () => approve,
|
|
63
63
|
base: () => base_exports,
|
|
64
|
-
baseUrl: () => baseUrl,
|
|
65
64
|
bigintAmountSlipperCalculator: () => bigintAmountSlipperCalculator,
|
|
66
65
|
bigintTradingGasPriceWithRatio: () => bigintTradingGasPriceWithRatio,
|
|
67
66
|
bigintTradingGasToRatioCalculator: () => bigintTradingGasToRatioCalculator,
|
|
68
67
|
fetchForwarderGetApi: () => fetchForwarderGetApi,
|
|
69
68
|
formatUnits: () => import_ethers22.formatUnits,
|
|
70
|
-
forwardUrl: () => forwardUrl,
|
|
71
69
|
forwarderTxApi: () => forwarderTxApi,
|
|
72
70
|
getAllTickers: () => getAllTickers,
|
|
73
71
|
getAllowanceApproved: () => getAllowanceApproved,
|
|
74
72
|
getBalanceOf: () => getBalanceOf,
|
|
75
73
|
getBaseDetail: () => getBaseDetail,
|
|
74
|
+
getBaseUrlByEnv: () => getBaseUrlByEnv,
|
|
76
75
|
getFavoritesList: () => getFavoritesList,
|
|
76
|
+
getForwardUrlByEnv: () => getForwardUrlByEnv,
|
|
77
77
|
getHistoryOrders: () => getHistoryOrders,
|
|
78
78
|
getKlineData: () => getKlineData,
|
|
79
79
|
getKlineLatestBar: () => getKlineLatestBar,
|
|
@@ -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"
|
|
@@ -2090,9 +2090,10 @@ var getHistoryOrders = async ({
|
|
|
2090
2090
|
accessToken,
|
|
2091
2091
|
address,
|
|
2092
2092
|
...params
|
|
2093
|
-
}) => {
|
|
2093
|
+
}, envParams) => {
|
|
2094
|
+
const isProd = envParams?.isProd ?? true;
|
|
2094
2095
|
return http.get(
|
|
2095
|
-
`${
|
|
2096
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/closed`,
|
|
2096
2097
|
params,
|
|
2097
2098
|
{
|
|
2098
2099
|
headers: {
|
|
@@ -2119,9 +2120,10 @@ var getPositionHistory = async ({
|
|
|
2119
2120
|
accessToken,
|
|
2120
2121
|
address,
|
|
2121
2122
|
...params
|
|
2122
|
-
}) => {
|
|
2123
|
+
}, envParams) => {
|
|
2124
|
+
const isProd = envParams?.isProd ?? true;
|
|
2123
2125
|
return http.get(
|
|
2124
|
-
`${
|
|
2126
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/position/closed`,
|
|
2125
2127
|
params,
|
|
2126
2128
|
{
|
|
2127
2129
|
headers: {
|
|
@@ -2141,9 +2143,10 @@ var getTradeFlow = async ({
|
|
|
2141
2143
|
accessToken,
|
|
2142
2144
|
address,
|
|
2143
2145
|
...params
|
|
2144
|
-
}) => {
|
|
2146
|
+
}, envParams) => {
|
|
2147
|
+
const isProd = envParams?.isProd ?? true;
|
|
2145
2148
|
return http.get(
|
|
2146
|
-
`${
|
|
2149
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/trade/flow`,
|
|
2147
2150
|
params,
|
|
2148
2151
|
{
|
|
2149
2152
|
headers: {
|
|
@@ -2155,10 +2158,9 @@ var getTradeFlow = async ({
|
|
|
2155
2158
|
};
|
|
2156
2159
|
|
|
2157
2160
|
// src/api/seamless/index.ts
|
|
2158
|
-
var forwarderTxApi = async (params, chainId) => {
|
|
2159
|
-
console.log("forwarderTxApi params-->", params);
|
|
2161
|
+
var forwarderTxApi = async (params, chainId, isProd = true) => {
|
|
2160
2162
|
return http.post(
|
|
2161
|
-
`${
|
|
2163
|
+
`${getForwardUrlByEnv(isProd)}/forwarder/tx-v2`,
|
|
2162
2164
|
params,
|
|
2163
2165
|
{
|
|
2164
2166
|
headers: {
|
|
@@ -2174,56 +2176,72 @@ var ForwarderGetStatus = /* @__PURE__ */ ((ForwarderGetStatus2) => {
|
|
|
2174
2176
|
ForwarderGetStatus2[ForwarderGetStatus2["EXECUTED"] = 9] = "EXECUTED";
|
|
2175
2177
|
return ForwarderGetStatus2;
|
|
2176
2178
|
})(ForwarderGetStatus || {});
|
|
2177
|
-
var fetchForwarderGetApi = async (params) => {
|
|
2179
|
+
var fetchForwarderGetApi = async (params, isProd = true) => {
|
|
2178
2180
|
const rs = await http.get(
|
|
2179
|
-
`${
|
|
2181
|
+
`${getForwardUrlByEnv(isProd)}/forwarder/get${addQueryParams(params)}`
|
|
2180
2182
|
);
|
|
2181
2183
|
return rs;
|
|
2182
2184
|
};
|
|
2183
2185
|
|
|
2184
2186
|
// src/api/pool/index.ts
|
|
2185
|
-
var getPoolList = async (
|
|
2187
|
+
var getPoolList = async ({
|
|
2188
|
+
isProd = true
|
|
2189
|
+
}) => {
|
|
2186
2190
|
return http.get(
|
|
2187
|
-
`${
|
|
2191
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/list`
|
|
2188
2192
|
);
|
|
2189
2193
|
};
|
|
2190
|
-
var getPoolSymbolAll = async (
|
|
2194
|
+
var getPoolSymbolAll = async ({
|
|
2195
|
+
isProd = true
|
|
2196
|
+
}) => {
|
|
2191
2197
|
return http.get(
|
|
2192
|
-
`${
|
|
2198
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/pools`
|
|
2193
2199
|
);
|
|
2194
2200
|
};
|
|
2195
2201
|
|
|
2196
2202
|
// src/api/index.ts
|
|
2197
|
-
var
|
|
2198
|
-
|
|
2199
|
-
|
|
2203
|
+
var getBaseUrlByEnv = (isProd) => {
|
|
2204
|
+
return isProd ? "https://api.myx.finance" : "https://api-test.myx.cash";
|
|
2205
|
+
};
|
|
2206
|
+
var getForwardUrlByEnv = (isProd) => {
|
|
2207
|
+
return isProd ? "https://api.myx.finance/v2/agent" : "https://api-test.myx.cash/v2/agent";
|
|
2208
|
+
};
|
|
2209
|
+
var getOraclePrice = async (chainId, poolIds = [], isProd = true) => {
|
|
2200
2210
|
if (!!poolIds.length) {
|
|
2201
|
-
return http.get(
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2211
|
+
return http.get(
|
|
2212
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/price/oracles`,
|
|
2213
|
+
{
|
|
2214
|
+
chainId,
|
|
2215
|
+
poolIds: poolIds.join(",")
|
|
2216
|
+
}
|
|
2217
|
+
);
|
|
2205
2218
|
}
|
|
2206
2219
|
return Promise.reject(new Error("Invalid pool id"));
|
|
2207
2220
|
};
|
|
2208
2221
|
var getPoolLevelConfig = async ({
|
|
2209
2222
|
poolId,
|
|
2210
|
-
chainId
|
|
2223
|
+
chainId,
|
|
2224
|
+
isProd = true
|
|
2211
2225
|
}) => {
|
|
2212
2226
|
return http.get(
|
|
2213
|
-
`${
|
|
2227
|
+
`${getBaseUrlByEnv(
|
|
2228
|
+
isProd
|
|
2229
|
+
)}/openapi/gateway/risk/market_pool/level_config${addQueryParams({
|
|
2214
2230
|
poolId,
|
|
2215
2231
|
chainId
|
|
2216
2232
|
})}`
|
|
2217
2233
|
);
|
|
2218
2234
|
};
|
|
2219
|
-
var getPoolDetail = async (chainId, poolId) => {
|
|
2235
|
+
var getPoolDetail = async (chainId, poolId, isProd = true) => {
|
|
2220
2236
|
return await http.get(
|
|
2221
|
-
`${
|
|
2237
|
+
`${getBaseUrlByEnv(
|
|
2238
|
+
isProd
|
|
2239
|
+
)}/openapi/gateway/scan/market/info?chainId=${chainId}&poolId=${poolId}`
|
|
2222
2240
|
);
|
|
2223
2241
|
};
|
|
2224
|
-
var getPositions = async (accessToken, address) => {
|
|
2242
|
+
var getPositions = async (accessToken, address, isProd = true) => {
|
|
2225
2243
|
return await http.get(
|
|
2226
|
-
`${
|
|
2244
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/position/open`,
|
|
2227
2245
|
void 0,
|
|
2228
2246
|
// params
|
|
2229
2247
|
{
|
|
@@ -2234,29 +2252,36 @@ var getPositions = async (accessToken, address) => {
|
|
|
2234
2252
|
}
|
|
2235
2253
|
);
|
|
2236
2254
|
};
|
|
2237
|
-
var getOrders = async (accessToken, address) => {
|
|
2255
|
+
var getOrders = async (accessToken, address, isProd = true) => {
|
|
2238
2256
|
return await http.get(
|
|
2239
|
-
`${
|
|
2257
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/open`,
|
|
2240
2258
|
void 0,
|
|
2241
|
-
{
|
|
2259
|
+
{
|
|
2260
|
+
headers: {
|
|
2261
|
+
myx_openapi_access_token: accessToken,
|
|
2262
|
+
myx_openapi_account: address
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2242
2265
|
);
|
|
2243
2266
|
};
|
|
2244
|
-
var getPoolOpenOrders = async (accessToken, address, chainId) => {
|
|
2267
|
+
var getPoolOpenOrders = async (accessToken, address, chainId, isProd = true) => {
|
|
2245
2268
|
return await http.get(
|
|
2246
|
-
`${
|
|
2269
|
+
`${getBaseUrlByEnv(
|
|
2270
|
+
isProd
|
|
2271
|
+
)}/openapi/gateway/scan/market/pool-order/open?chainId=${chainId}`,
|
|
2247
2272
|
void 0,
|
|
2248
|
-
{
|
|
2273
|
+
{
|
|
2274
|
+
headers: {
|
|
2275
|
+
myx_openapi_access_token: accessToken,
|
|
2276
|
+
myx_openapi_account: address
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2249
2279
|
);
|
|
2250
2280
|
};
|
|
2251
|
-
var getKlineData = ({
|
|
2252
|
-
|
|
2253
|
-
poolId,
|
|
2254
|
-
endTime,
|
|
2255
|
-
limit,
|
|
2256
|
-
interval
|
|
2257
|
-
}) => {
|
|
2281
|
+
var getKlineData = ({ chainId, poolId, endTime, limit, interval }, envParams) => {
|
|
2282
|
+
const isProd = envParams?.isProd ?? true;
|
|
2258
2283
|
return http.get(
|
|
2259
|
-
`${
|
|
2284
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candles`,
|
|
2260
2285
|
{
|
|
2261
2286
|
chainId,
|
|
2262
2287
|
poolId,
|
|
@@ -2266,36 +2291,33 @@ var getKlineData = ({
|
|
|
2266
2291
|
}
|
|
2267
2292
|
);
|
|
2268
2293
|
};
|
|
2269
|
-
var getKlineLatestBar = async (params) => {
|
|
2294
|
+
var getKlineLatestBar = async (params, envParams) => {
|
|
2295
|
+
const isProd = envParams?.isProd ?? true;
|
|
2270
2296
|
return http.get(
|
|
2271
|
-
`${
|
|
2297
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/latest`,
|
|
2272
2298
|
params
|
|
2273
2299
|
);
|
|
2274
2300
|
};
|
|
2275
|
-
var getTickerData = async ({
|
|
2276
|
-
|
|
2277
|
-
poolIds
|
|
2278
|
-
}) => {
|
|
2301
|
+
var getTickerData = async ({ chainId, poolIds }, envParams) => {
|
|
2302
|
+
const isProd = envParams?.isProd ?? true;
|
|
2279
2303
|
return http.get(
|
|
2280
|
-
`${
|
|
2304
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/tickers`,
|
|
2281
2305
|
{
|
|
2282
2306
|
chainId,
|
|
2283
2307
|
poolIds: poolIds.join(",")
|
|
2284
2308
|
}
|
|
2285
2309
|
);
|
|
2286
2310
|
};
|
|
2287
|
-
var getAllTickers = async () => {
|
|
2311
|
+
var getAllTickers = async (envParams) => {
|
|
2312
|
+
const isProd = envParams?.isProd ?? true;
|
|
2288
2313
|
return http.get(
|
|
2289
|
-
`${
|
|
2314
|
+
`${getBaseUrlByEnv(isProd)}/v2/mx-gateway/quote/candle/all_tickers`
|
|
2290
2315
|
);
|
|
2291
2316
|
};
|
|
2292
|
-
var searchMarketAuth = async ({
|
|
2293
|
-
|
|
2294
|
-
address,
|
|
2295
|
-
...params
|
|
2296
|
-
}) => {
|
|
2317
|
+
var searchMarketAuth = async ({ accessToken, address, ...params }, envParams) => {
|
|
2318
|
+
const isProd = envParams?.isProd ?? true;
|
|
2297
2319
|
return http.get(
|
|
2298
|
-
`${
|
|
2320
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/ac-search`,
|
|
2299
2321
|
params,
|
|
2300
2322
|
{
|
|
2301
2323
|
headers: {
|
|
@@ -2305,19 +2327,17 @@ var searchMarketAuth = async ({
|
|
|
2305
2327
|
}
|
|
2306
2328
|
);
|
|
2307
2329
|
};
|
|
2308
|
-
var searchMarket = async ({ ...params }) => {
|
|
2330
|
+
var searchMarket = async ({ ...params }, envParams) => {
|
|
2331
|
+
const isProd = envParams?.isProd ?? true;
|
|
2309
2332
|
return http.get(
|
|
2310
|
-
`${
|
|
2333
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/search`,
|
|
2311
2334
|
params
|
|
2312
2335
|
);
|
|
2313
2336
|
};
|
|
2314
|
-
var addFavorite = async ({
|
|
2315
|
-
|
|
2316
|
-
address,
|
|
2317
|
-
...params
|
|
2318
|
-
}) => {
|
|
2337
|
+
var addFavorite = async ({ accessToken, address, ...params }, envParams) => {
|
|
2338
|
+
const isProd = envParams?.isProd ?? true;
|
|
2319
2339
|
return http.get(
|
|
2320
|
-
`${
|
|
2340
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/add-favorites`,
|
|
2321
2341
|
params,
|
|
2322
2342
|
{
|
|
2323
2343
|
headers: {
|
|
@@ -2331,9 +2351,10 @@ var removeFavorite = async ({
|
|
|
2331
2351
|
accessToken,
|
|
2332
2352
|
address,
|
|
2333
2353
|
...params
|
|
2334
|
-
}) => {
|
|
2354
|
+
}, envParams) => {
|
|
2355
|
+
const isProd = envParams?.isProd ?? true;
|
|
2335
2356
|
return http.get(
|
|
2336
|
-
`${
|
|
2357
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/cancel-favorites`,
|
|
2337
2358
|
params,
|
|
2338
2359
|
{
|
|
2339
2360
|
headers: {
|
|
@@ -2343,13 +2364,10 @@ var removeFavorite = async ({
|
|
|
2343
2364
|
}
|
|
2344
2365
|
);
|
|
2345
2366
|
};
|
|
2346
|
-
var getFavoritesList = async ({
|
|
2347
|
-
|
|
2348
|
-
address,
|
|
2349
|
-
...params
|
|
2350
|
-
}) => {
|
|
2367
|
+
var getFavoritesList = async ({ accessToken, address, ...params }, envParams) => {
|
|
2368
|
+
const isProd = envParams?.isProd ?? true;
|
|
2351
2369
|
return http.get(
|
|
2352
|
-
`${
|
|
2370
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/favorites`,
|
|
2353
2371
|
params,
|
|
2354
2372
|
{
|
|
2355
2373
|
headers: {
|
|
@@ -2359,20 +2377,25 @@ var getFavoritesList = async ({
|
|
|
2359
2377
|
}
|
|
2360
2378
|
);
|
|
2361
2379
|
};
|
|
2362
|
-
var getBaseDetail = async (params) => {
|
|
2380
|
+
var getBaseDetail = async ({ ...params }, envParams) => {
|
|
2381
|
+
const isProd = envParams?.isProd ?? true;
|
|
2363
2382
|
return http.get(
|
|
2364
|
-
`${
|
|
2383
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/base-details`,
|
|
2365
2384
|
params
|
|
2366
2385
|
);
|
|
2367
2386
|
};
|
|
2368
|
-
var getMarketDetail = async (params) => {
|
|
2387
|
+
var getMarketDetail = async ({ ...params }, envParams) => {
|
|
2388
|
+
const isProd = envParams?.isProd ?? true;
|
|
2369
2389
|
return http.get(
|
|
2370
|
-
`${
|
|
2390
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/detail`,
|
|
2371
2391
|
params
|
|
2372
2392
|
);
|
|
2373
2393
|
};
|
|
2374
|
-
var getMarketList = async () => {
|
|
2375
|
-
|
|
2394
|
+
var getMarketList = async (envParams) => {
|
|
2395
|
+
const isProd = envParams?.isProd ?? true;
|
|
2396
|
+
return http.get(
|
|
2397
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market`
|
|
2398
|
+
);
|
|
2376
2399
|
};
|
|
2377
2400
|
|
|
2378
2401
|
// src/web3/index.ts
|
|
@@ -5411,6 +5434,11 @@ var BasePool_default = [
|
|
|
5411
5434
|
|
|
5412
5435
|
// src/abi/Broker.json
|
|
5413
5436
|
var Broker_default = [
|
|
5437
|
+
{
|
|
5438
|
+
type: "constructor",
|
|
5439
|
+
payable: false,
|
|
5440
|
+
inputs: []
|
|
5441
|
+
},
|
|
5414
5442
|
{
|
|
5415
5443
|
type: "error",
|
|
5416
5444
|
name: "ECDSAInvalidSignature",
|
|
@@ -5760,7 +5788,16 @@ var Broker_default = [
|
|
|
5760
5788
|
constant: true,
|
|
5761
5789
|
stateMutability: "view",
|
|
5762
5790
|
payable: false,
|
|
5763
|
-
inputs: [
|
|
5791
|
+
inputs: [
|
|
5792
|
+
{
|
|
5793
|
+
type: "uint8",
|
|
5794
|
+
name: "assetClass"
|
|
5795
|
+
},
|
|
5796
|
+
{
|
|
5797
|
+
type: "uint8",
|
|
5798
|
+
name: "riskTier"
|
|
5799
|
+
}
|
|
5800
|
+
],
|
|
5764
5801
|
outputs: [
|
|
5765
5802
|
{
|
|
5766
5803
|
type: "uint256[]"
|
|
@@ -5773,7 +5810,16 @@ var Broker_default = [
|
|
|
5773
5810
|
constant: true,
|
|
5774
5811
|
stateMutability: "view",
|
|
5775
5812
|
payable: false,
|
|
5776
|
-
inputs: [
|
|
5813
|
+
inputs: [
|
|
5814
|
+
{
|
|
5815
|
+
type: "uint8",
|
|
5816
|
+
name: "assetClass"
|
|
5817
|
+
},
|
|
5818
|
+
{
|
|
5819
|
+
type: "uint8",
|
|
5820
|
+
name: "riskTier"
|
|
5821
|
+
}
|
|
5822
|
+
],
|
|
5777
5823
|
outputs: [
|
|
5778
5824
|
{
|
|
5779
5825
|
type: "uint256[]"
|
|
@@ -5824,6 +5870,82 @@ var Broker_default = [
|
|
|
5824
5870
|
],
|
|
5825
5871
|
outputs: []
|
|
5826
5872
|
},
|
|
5873
|
+
{
|
|
5874
|
+
type: "function",
|
|
5875
|
+
name: "batchSetSpecialFeeTiers",
|
|
5876
|
+
constant: false,
|
|
5877
|
+
payable: false,
|
|
5878
|
+
inputs: [
|
|
5879
|
+
{
|
|
5880
|
+
type: "tuple[]",
|
|
5881
|
+
name: "params",
|
|
5882
|
+
components: [
|
|
5883
|
+
{
|
|
5884
|
+
type: "uint8",
|
|
5885
|
+
name: "assetClass"
|
|
5886
|
+
},
|
|
5887
|
+
{
|
|
5888
|
+
type: "uint8",
|
|
5889
|
+
name: "riskTier"
|
|
5890
|
+
},
|
|
5891
|
+
{
|
|
5892
|
+
type: "uint8",
|
|
5893
|
+
name: "feeTier"
|
|
5894
|
+
},
|
|
5895
|
+
{
|
|
5896
|
+
type: "int32",
|
|
5897
|
+
name: "makerFeeRate"
|
|
5898
|
+
},
|
|
5899
|
+
{
|
|
5900
|
+
type: "uint32",
|
|
5901
|
+
name: "takerFeeRate"
|
|
5902
|
+
}
|
|
5903
|
+
]
|
|
5904
|
+
}
|
|
5905
|
+
],
|
|
5906
|
+
outputs: []
|
|
5907
|
+
},
|
|
5908
|
+
{
|
|
5909
|
+
type: "function",
|
|
5910
|
+
name: "batchUpdateFeeTiers",
|
|
5911
|
+
constant: false,
|
|
5912
|
+
payable: false,
|
|
5913
|
+
inputs: [
|
|
5914
|
+
{
|
|
5915
|
+
type: "tuple[]",
|
|
5916
|
+
name: "params",
|
|
5917
|
+
components: [
|
|
5918
|
+
{
|
|
5919
|
+
type: "uint8",
|
|
5920
|
+
name: "assetClass"
|
|
5921
|
+
},
|
|
5922
|
+
{
|
|
5923
|
+
type: "uint8",
|
|
5924
|
+
name: "riskTier"
|
|
5925
|
+
},
|
|
5926
|
+
{
|
|
5927
|
+
type: "uint8",
|
|
5928
|
+
name: "feeTier"
|
|
5929
|
+
},
|
|
5930
|
+
{
|
|
5931
|
+
type: "tuple",
|
|
5932
|
+
name: "addOnFeeRate",
|
|
5933
|
+
components: [
|
|
5934
|
+
{
|
|
5935
|
+
type: "uint32",
|
|
5936
|
+
name: "takerFeeRate"
|
|
5937
|
+
},
|
|
5938
|
+
{
|
|
5939
|
+
type: "uint32",
|
|
5940
|
+
name: "makerFeeRate"
|
|
5941
|
+
}
|
|
5942
|
+
]
|
|
5943
|
+
}
|
|
5944
|
+
]
|
|
5945
|
+
}
|
|
5946
|
+
],
|
|
5947
|
+
outputs: []
|
|
5948
|
+
},
|
|
5827
5949
|
{
|
|
5828
5950
|
type: "function",
|
|
5829
5951
|
name: "cancelOrder",
|
|
@@ -5923,7 +6045,15 @@ var Broker_default = [
|
|
|
5923
6045
|
inputs: [
|
|
5924
6046
|
{
|
|
5925
6047
|
type: "uint8",
|
|
5926
|
-
name: "
|
|
6048
|
+
name: "assetClass"
|
|
6049
|
+
},
|
|
6050
|
+
{
|
|
6051
|
+
type: "uint8",
|
|
6052
|
+
name: "riskTier"
|
|
6053
|
+
},
|
|
6054
|
+
{
|
|
6055
|
+
type: "uint8",
|
|
6056
|
+
name: "feeTier"
|
|
5927
6057
|
}
|
|
5928
6058
|
],
|
|
5929
6059
|
outputs: [
|
|
@@ -5973,6 +6103,14 @@ var Broker_default = [
|
|
|
5973
6103
|
stateMutability: "view",
|
|
5974
6104
|
payable: false,
|
|
5975
6105
|
inputs: [
|
|
6106
|
+
{
|
|
6107
|
+
type: "uint8",
|
|
6108
|
+
name: "assetClass"
|
|
6109
|
+
},
|
|
6110
|
+
{
|
|
6111
|
+
type: "uint8",
|
|
6112
|
+
name: "riskTier"
|
|
6113
|
+
},
|
|
5976
6114
|
{
|
|
5977
6115
|
type: "uint8",
|
|
5978
6116
|
name: "feeTier"
|
|
@@ -6003,6 +6141,10 @@ var Broker_default = [
|
|
|
6003
6141
|
{
|
|
6004
6142
|
type: "uint8",
|
|
6005
6143
|
name: "assetClass"
|
|
6144
|
+
},
|
|
6145
|
+
{
|
|
6146
|
+
type: "uint8",
|
|
6147
|
+
name: "riskTier"
|
|
6006
6148
|
}
|
|
6007
6149
|
],
|
|
6008
6150
|
outputs: [
|
|
@@ -6615,16 +6757,30 @@ var Broker_default = [
|
|
|
6615
6757
|
payable: false,
|
|
6616
6758
|
inputs: [
|
|
6617
6759
|
{
|
|
6618
|
-
type: "
|
|
6619
|
-
name: "
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6760
|
+
type: "tuple",
|
|
6761
|
+
name: "params",
|
|
6762
|
+
components: [
|
|
6763
|
+
{
|
|
6764
|
+
type: "uint8",
|
|
6765
|
+
name: "assetClass"
|
|
6766
|
+
},
|
|
6767
|
+
{
|
|
6768
|
+
type: "uint8",
|
|
6769
|
+
name: "riskTier"
|
|
6770
|
+
},
|
|
6771
|
+
{
|
|
6772
|
+
type: "uint8",
|
|
6773
|
+
name: "feeTier"
|
|
6774
|
+
},
|
|
6775
|
+
{
|
|
6776
|
+
type: "int32",
|
|
6777
|
+
name: "makerFeeRate"
|
|
6778
|
+
},
|
|
6779
|
+
{
|
|
6780
|
+
type: "uint32",
|
|
6781
|
+
name: "takerFeeRate"
|
|
6782
|
+
}
|
|
6783
|
+
]
|
|
6628
6784
|
}
|
|
6629
6785
|
],
|
|
6630
6786
|
outputs: []
|
|
@@ -6744,25 +6900,31 @@ var Broker_default = [
|
|
|
6744
6900
|
constant: false,
|
|
6745
6901
|
payable: false,
|
|
6746
6902
|
inputs: [
|
|
6747
|
-
{
|
|
6748
|
-
type: "uint8[]",
|
|
6749
|
-
name: "assetClasses"
|
|
6750
|
-
},
|
|
6751
|
-
{
|
|
6752
|
-
type: "bool[]",
|
|
6753
|
-
name: "isEnables"
|
|
6754
|
-
},
|
|
6755
6903
|
{
|
|
6756
6904
|
type: "tuple[]",
|
|
6757
|
-
name: "
|
|
6905
|
+
name: "params",
|
|
6758
6906
|
components: [
|
|
6759
6907
|
{
|
|
6760
|
-
type: "
|
|
6761
|
-
name: "
|
|
6908
|
+
type: "uint8",
|
|
6909
|
+
name: "assetClass"
|
|
6762
6910
|
},
|
|
6763
6911
|
{
|
|
6764
|
-
type: "
|
|
6765
|
-
name: "
|
|
6912
|
+
type: "bool",
|
|
6913
|
+
name: "isEnable"
|
|
6914
|
+
},
|
|
6915
|
+
{
|
|
6916
|
+
type: "tuple",
|
|
6917
|
+
name: "baseFeeRate",
|
|
6918
|
+
components: [
|
|
6919
|
+
{
|
|
6920
|
+
type: "uint32",
|
|
6921
|
+
name: "takerFeeRate"
|
|
6922
|
+
},
|
|
6923
|
+
{
|
|
6924
|
+
type: "uint32",
|
|
6925
|
+
name: "makerFeeRate"
|
|
6926
|
+
}
|
|
6927
|
+
]
|
|
6766
6928
|
}
|
|
6767
6929
|
]
|
|
6768
6930
|
}
|
|
@@ -6790,7 +6952,15 @@ var Broker_default = [
|
|
|
6790
6952
|
inputs: [
|
|
6791
6953
|
{
|
|
6792
6954
|
type: "uint8",
|
|
6793
|
-
name: "
|
|
6955
|
+
name: "assetClass"
|
|
6956
|
+
},
|
|
6957
|
+
{
|
|
6958
|
+
type: "uint8",
|
|
6959
|
+
name: "riskTier"
|
|
6960
|
+
},
|
|
6961
|
+
{
|
|
6962
|
+
type: "uint8",
|
|
6963
|
+
name: "feeTier"
|
|
6794
6964
|
},
|
|
6795
6965
|
{
|
|
6796
6966
|
type: "tuple",
|
|
@@ -6815,9 +6985,17 @@ var Broker_default = [
|
|
|
6815
6985
|
constant: false,
|
|
6816
6986
|
payable: false,
|
|
6817
6987
|
inputs: [
|
|
6988
|
+
{
|
|
6989
|
+
type: "uint8",
|
|
6990
|
+
name: "assetClass"
|
|
6991
|
+
},
|
|
6992
|
+
{
|
|
6993
|
+
type: "uint8",
|
|
6994
|
+
name: "riskTier"
|
|
6995
|
+
},
|
|
6818
6996
|
{
|
|
6819
6997
|
type: "uint8[]",
|
|
6820
|
-
name: "
|
|
6998
|
+
name: "feeTiers"
|
|
6821
6999
|
},
|
|
6822
7000
|
{
|
|
6823
7001
|
type: "tuple[]",
|
|
@@ -9713,6 +9891,14 @@ var DataProvider_default = [
|
|
|
9713
9891
|
type: "address",
|
|
9714
9892
|
name: "brokerAddress"
|
|
9715
9893
|
},
|
|
9894
|
+
{
|
|
9895
|
+
type: "uint8[]",
|
|
9896
|
+
name: "assetClasses"
|
|
9897
|
+
},
|
|
9898
|
+
{
|
|
9899
|
+
type: "uint8[][]",
|
|
9900
|
+
name: "assetRiskTiers"
|
|
9901
|
+
},
|
|
9716
9902
|
{
|
|
9717
9903
|
type: "bool",
|
|
9718
9904
|
name: "isMYXBroker"
|
|
@@ -9720,60 +9906,74 @@ var DataProvider_default = [
|
|
|
9720
9906
|
],
|
|
9721
9907
|
outputs: [
|
|
9722
9908
|
{
|
|
9723
|
-
type: "tuple",
|
|
9724
|
-
name: "
|
|
9909
|
+
type: "tuple[]",
|
|
9910
|
+
name: "brokerFees",
|
|
9725
9911
|
components: [
|
|
9726
9912
|
{
|
|
9727
|
-
type: "
|
|
9728
|
-
name: "
|
|
9729
|
-
components: [
|
|
9730
|
-
{
|
|
9731
|
-
type: "uint8",
|
|
9732
|
-
name: "tier"
|
|
9733
|
-
},
|
|
9734
|
-
{
|
|
9735
|
-
type: "uint32",
|
|
9736
|
-
name: "takerFeeRate"
|
|
9737
|
-
},
|
|
9738
|
-
{
|
|
9739
|
-
type: "int32",
|
|
9740
|
-
name: "makerFeeRate"
|
|
9741
|
-
}
|
|
9742
|
-
]
|
|
9913
|
+
type: "uint8",
|
|
9914
|
+
name: "asset"
|
|
9743
9915
|
},
|
|
9744
9916
|
{
|
|
9745
9917
|
type: "tuple[]",
|
|
9746
|
-
name: "
|
|
9918
|
+
name: "riskTieredBrokerFees",
|
|
9747
9919
|
components: [
|
|
9748
9920
|
{
|
|
9749
9921
|
type: "uint8",
|
|
9750
|
-
name: "
|
|
9922
|
+
name: "riskTier"
|
|
9751
9923
|
},
|
|
9752
9924
|
{
|
|
9753
|
-
type: "
|
|
9754
|
-
name: "
|
|
9925
|
+
type: "tuple[]",
|
|
9926
|
+
name: "addOnFeeTiers",
|
|
9927
|
+
components: [
|
|
9928
|
+
{
|
|
9929
|
+
type: "uint8",
|
|
9930
|
+
name: "tier"
|
|
9931
|
+
},
|
|
9932
|
+
{
|
|
9933
|
+
type: "uint32",
|
|
9934
|
+
name: "takerFeeRate"
|
|
9935
|
+
},
|
|
9936
|
+
{
|
|
9937
|
+
type: "int32",
|
|
9938
|
+
name: "makerFeeRate"
|
|
9939
|
+
}
|
|
9940
|
+
]
|
|
9755
9941
|
},
|
|
9756
9942
|
{
|
|
9757
|
-
type: "
|
|
9758
|
-
name: "
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9943
|
+
type: "tuple[]",
|
|
9944
|
+
name: "baseFeeRate",
|
|
9945
|
+
components: [
|
|
9946
|
+
{
|
|
9947
|
+
type: "uint8",
|
|
9948
|
+
name: "assetClass"
|
|
9949
|
+
},
|
|
9950
|
+
{
|
|
9951
|
+
type: "uint32",
|
|
9952
|
+
name: "makerFeeRate"
|
|
9953
|
+
},
|
|
9954
|
+
{
|
|
9955
|
+
type: "uint32",
|
|
9956
|
+
name: "takerFeeRate"
|
|
9957
|
+
}
|
|
9958
|
+
]
|
|
9769
9959
|
},
|
|
9770
9960
|
{
|
|
9771
|
-
type: "
|
|
9772
|
-
name: "
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9961
|
+
type: "tuple[]",
|
|
9962
|
+
name: "specialFeeTiers",
|
|
9963
|
+
components: [
|
|
9964
|
+
{
|
|
9965
|
+
type: "uint8",
|
|
9966
|
+
name: "tier"
|
|
9967
|
+
},
|
|
9968
|
+
{
|
|
9969
|
+
type: "uint32",
|
|
9970
|
+
name: "takerFeeRate"
|
|
9971
|
+
},
|
|
9972
|
+
{
|
|
9973
|
+
type: "int32",
|
|
9974
|
+
name: "makerFeeRate"
|
|
9975
|
+
}
|
|
9976
|
+
]
|
|
9777
9977
|
}
|
|
9778
9978
|
]
|
|
9779
9979
|
}
|
|
@@ -11967,9 +12167,9 @@ var getPricesData = async (chainId, poolIds) => {
|
|
|
11967
12167
|
const result = await parsePriceData(chainId, rs.data);
|
|
11968
12168
|
return result;
|
|
11969
12169
|
};
|
|
11970
|
-
var getPriceData = async (chainId, poolId) => {
|
|
12170
|
+
var getPriceData = async (chainId, poolId, isProd) => {
|
|
11971
12171
|
if (!poolId) return;
|
|
11972
|
-
const rs = await getOraclePrice(chainId, [poolId]);
|
|
12172
|
+
const rs = await getOraclePrice(chainId, [poolId], isProd);
|
|
11973
12173
|
const data = rs?.data?.[0];
|
|
11974
12174
|
if (!data) {
|
|
11975
12175
|
throw new Error(`Unable to get price for ${poolId} in the deposit`);
|
|
@@ -12226,7 +12426,7 @@ var deposit = async (params) => {
|
|
|
12226
12426
|
let value = 0n;
|
|
12227
12427
|
let amountOut;
|
|
12228
12428
|
if (isNeedPrice) {
|
|
12229
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12429
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12230
12430
|
if (!priceData) return;
|
|
12231
12431
|
const referencePrice = (0, import_ethers10.parseUnits)(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12232
12432
|
price.push({
|
|
@@ -12296,7 +12496,7 @@ var withdraw = async (params) => {
|
|
|
12296
12496
|
let value = 0n;
|
|
12297
12497
|
let amountOut;
|
|
12298
12498
|
if (isNeedPrice) {
|
|
12299
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12499
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12300
12500
|
if (!priceData) return;
|
|
12301
12501
|
const referencePrice = (0, import_ethers11.parseUnits)(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12302
12502
|
price.push({
|
|
@@ -12368,7 +12568,7 @@ var getLpPrice = async (chainId, poolId) => {
|
|
|
12368
12568
|
try {
|
|
12369
12569
|
const contract = await getBasePoolContract(chainId);
|
|
12370
12570
|
let price = 0n;
|
|
12371
|
-
const res = await getPriceData(chainId, poolId);
|
|
12571
|
+
const res = await getPriceData(chainId, poolId, true);
|
|
12372
12572
|
if (res?.price) {
|
|
12373
12573
|
price = (0, import_ethers13.parseUnits)(res.price, COMMON_PRICE_DECIMALS);
|
|
12374
12574
|
}
|
|
@@ -12460,7 +12660,7 @@ var deposit2 = async (params) => {
|
|
|
12460
12660
|
let value = 0n;
|
|
12461
12661
|
let amountOut;
|
|
12462
12662
|
if (isNeedPrice) {
|
|
12463
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12663
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12464
12664
|
if (!priceData) return;
|
|
12465
12665
|
const referencePrice = (0, import_ethers14.parseUnits)(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12466
12666
|
price.push({
|
|
@@ -12530,7 +12730,7 @@ var withdraw2 = async (params) => {
|
|
|
12530
12730
|
let value = 0n;
|
|
12531
12731
|
let amountOut;
|
|
12532
12732
|
if (isNeedPrice) {
|
|
12533
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12733
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12534
12734
|
if (!priceData) return;
|
|
12535
12735
|
const referencePrice = (0, import_ethers15.parseUnits)(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12536
12736
|
price.push({
|
|
@@ -12732,7 +12932,7 @@ var getLpPrice2 = async (chainId, poolId) => {
|
|
|
12732
12932
|
try {
|
|
12733
12933
|
const contract = await getQuotePoolContract(chainId);
|
|
12734
12934
|
let price = 0n;
|
|
12735
|
-
const res = await getPriceData(chainId, poolId);
|
|
12935
|
+
const res = await getPriceData(chainId, poolId, true);
|
|
12736
12936
|
if (res?.price) {
|
|
12737
12937
|
price = (0, import_ethers19.parseUnits)(res.price, COMMON_PRICE_DECIMALS);
|
|
12738
12938
|
}
|
|
@@ -14037,19 +14237,31 @@ var Markets = class {
|
|
|
14037
14237
|
interval,
|
|
14038
14238
|
...params
|
|
14039
14239
|
}) {
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
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;
|
|
14044
14250
|
}
|
|
14045
14251
|
async getKlineLatestBar({
|
|
14046
14252
|
interval,
|
|
14047
14253
|
...params
|
|
14048
14254
|
}) {
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
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;
|
|
14053
14265
|
}
|
|
14054
14266
|
/**
|
|
14055
14267
|
* kline end
|
|
@@ -14058,7 +14270,10 @@ var Markets = class {
|
|
|
14058
14270
|
* ticker start
|
|
14059
14271
|
*/
|
|
14060
14272
|
async getTickerList(params) {
|
|
14061
|
-
|
|
14273
|
+
const config = this.configManager.getConfig();
|
|
14274
|
+
return (await getTickerData(params, {
|
|
14275
|
+
isProd: !config?.isTestnet
|
|
14276
|
+
})).data;
|
|
14062
14277
|
}
|
|
14063
14278
|
/**
|
|
14064
14279
|
* ticker end
|
|
@@ -14069,6 +14284,7 @@ var Markets = class {
|
|
|
14069
14284
|
*
|
|
14070
14285
|
*/
|
|
14071
14286
|
async searchMarketAuth(params, address) {
|
|
14287
|
+
const config = this.configManager.getConfig();
|
|
14072
14288
|
const accessToken = await this.configManager.getAccessToken();
|
|
14073
14289
|
if (!accessToken) {
|
|
14074
14290
|
throw new MyxSDKError(
|
|
@@ -14076,23 +14292,32 @@ var Markets = class {
|
|
|
14076
14292
|
"Invalid access token"
|
|
14077
14293
|
);
|
|
14078
14294
|
}
|
|
14079
|
-
return (await searchMarketAuth(
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14295
|
+
return (await searchMarketAuth(
|
|
14296
|
+
{
|
|
14297
|
+
address,
|
|
14298
|
+
...params,
|
|
14299
|
+
accessToken
|
|
14300
|
+
},
|
|
14301
|
+
{
|
|
14302
|
+
isProd: !config?.isTestnet
|
|
14303
|
+
}
|
|
14304
|
+
)).data;
|
|
14084
14305
|
}
|
|
14085
14306
|
/**
|
|
14086
14307
|
* search by unauthenticated users
|
|
14087
14308
|
*/
|
|
14088
14309
|
async searchMarket(params) {
|
|
14089
|
-
|
|
14310
|
+
const config = this.configManager.getConfig();
|
|
14311
|
+
return (await searchMarket(params, {
|
|
14312
|
+
isProd: !config?.isTestnet
|
|
14313
|
+
})).data;
|
|
14090
14314
|
}
|
|
14091
14315
|
/**
|
|
14092
14316
|
* get favorites list
|
|
14093
14317
|
* (only for authenticated users)
|
|
14094
14318
|
*/
|
|
14095
14319
|
async getFavoritesList(params, address) {
|
|
14320
|
+
const config = this.configManager.getConfig();
|
|
14096
14321
|
const accessToken = await this.configManager.getAccessToken();
|
|
14097
14322
|
if (!accessToken) {
|
|
14098
14323
|
throw new MyxSDKError(
|
|
@@ -14100,16 +14325,22 @@ var Markets = class {
|
|
|
14100
14325
|
"Invalid access token"
|
|
14101
14326
|
);
|
|
14102
14327
|
}
|
|
14103
|
-
return (await getFavoritesList(
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14328
|
+
return (await getFavoritesList(
|
|
14329
|
+
{
|
|
14330
|
+
...params,
|
|
14331
|
+
address,
|
|
14332
|
+
accessToken
|
|
14333
|
+
},
|
|
14334
|
+
{
|
|
14335
|
+
isProd: !config?.isTestnet
|
|
14336
|
+
}
|
|
14337
|
+
)).data;
|
|
14108
14338
|
}
|
|
14109
14339
|
/**
|
|
14110
14340
|
* favorite
|
|
14111
14341
|
*/
|
|
14112
14342
|
async addFavorite(params, address) {
|
|
14343
|
+
const config = this.configManager.getConfig();
|
|
14113
14344
|
const accessToken = await this.configManager.getAccessToken();
|
|
14114
14345
|
if (!accessToken) {
|
|
14115
14346
|
throw new MyxSDKError(
|
|
@@ -14117,13 +14348,19 @@ var Markets = class {
|
|
|
14117
14348
|
"Invalid access token"
|
|
14118
14349
|
);
|
|
14119
14350
|
}
|
|
14120
|
-
return (await addFavorite(
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14351
|
+
return (await addFavorite(
|
|
14352
|
+
{
|
|
14353
|
+
...params,
|
|
14354
|
+
address,
|
|
14355
|
+
accessToken
|
|
14356
|
+
},
|
|
14357
|
+
{
|
|
14358
|
+
isProd: !config?.isTestnet
|
|
14359
|
+
}
|
|
14360
|
+
)).data;
|
|
14125
14361
|
}
|
|
14126
14362
|
async removeFavorite(params, address) {
|
|
14363
|
+
const config = this.configManager.getConfig();
|
|
14127
14364
|
const accessToken = await this.configManager.getAccessToken();
|
|
14128
14365
|
if (!accessToken) {
|
|
14129
14366
|
throw new MyxSDKError(
|
|
@@ -14131,29 +14368,43 @@ var Markets = class {
|
|
|
14131
14368
|
"Invalid access token"
|
|
14132
14369
|
);
|
|
14133
14370
|
}
|
|
14134
|
-
return (await removeFavorite(
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14371
|
+
return (await removeFavorite(
|
|
14372
|
+
{
|
|
14373
|
+
...params,
|
|
14374
|
+
address,
|
|
14375
|
+
accessToken
|
|
14376
|
+
},
|
|
14377
|
+
{
|
|
14378
|
+
isProd: !config?.isTestnet
|
|
14379
|
+
}
|
|
14380
|
+
)).data;
|
|
14139
14381
|
}
|
|
14140
14382
|
/**
|
|
14141
14383
|
* base detail
|
|
14142
14384
|
*/
|
|
14143
14385
|
async getBaseDetail(params) {
|
|
14144
|
-
|
|
14386
|
+
const config = this.configManager.getConfig();
|
|
14387
|
+
return (await getBaseDetail(params, {
|
|
14388
|
+
isProd: !config?.isTestnet
|
|
14389
|
+
})).data;
|
|
14145
14390
|
}
|
|
14146
14391
|
/**
|
|
14147
14392
|
* get market detail
|
|
14148
14393
|
*/
|
|
14149
14394
|
async getMarketDetail(params) {
|
|
14150
|
-
|
|
14395
|
+
const config = this.configManager.getConfig();
|
|
14396
|
+
return (await getMarketDetail(params, {
|
|
14397
|
+
isProd: !config?.isTestnet
|
|
14398
|
+
})).data;
|
|
14151
14399
|
}
|
|
14152
14400
|
/**
|
|
14153
14401
|
* get pool symbol all
|
|
14154
14402
|
*/
|
|
14155
14403
|
async getPoolSymbolAll() {
|
|
14156
|
-
|
|
14404
|
+
const config = this.configManager.getConfig();
|
|
14405
|
+
return (await getPoolSymbolAll({
|
|
14406
|
+
isProd: !config?.isTestnet
|
|
14407
|
+
})).data;
|
|
14157
14408
|
}
|
|
14158
14409
|
};
|
|
14159
14410
|
|
|
@@ -14169,6 +14420,7 @@ var Position = class {
|
|
|
14169
14420
|
this.account = account;
|
|
14170
14421
|
}
|
|
14171
14422
|
async listPositions(address) {
|
|
14423
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
14172
14424
|
const accessToken = await this.configManager.getAccessToken();
|
|
14173
14425
|
if (!accessToken) {
|
|
14174
14426
|
return {
|
|
@@ -14177,7 +14429,7 @@ var Position = class {
|
|
|
14177
14429
|
};
|
|
14178
14430
|
}
|
|
14179
14431
|
try {
|
|
14180
|
-
const res = await getPositions(accessToken, address);
|
|
14432
|
+
const res = await getPositions(accessToken, address, isProd);
|
|
14181
14433
|
return {
|
|
14182
14434
|
code: 0,
|
|
14183
14435
|
data: res.data
|
|
@@ -14191,6 +14443,7 @@ var Position = class {
|
|
|
14191
14443
|
}
|
|
14192
14444
|
}
|
|
14193
14445
|
async getPositionHistory(params, address) {
|
|
14446
|
+
const config = this.configManager.getConfig();
|
|
14194
14447
|
const accessToken = await this.configManager.getAccessToken();
|
|
14195
14448
|
if (!accessToken) {
|
|
14196
14449
|
throw new MyxSDKError(
|
|
@@ -14198,7 +14451,12 @@ var Position = class {
|
|
|
14198
14451
|
"Invalid access token"
|
|
14199
14452
|
);
|
|
14200
14453
|
}
|
|
14201
|
-
const res = await getPositionHistory(
|
|
14454
|
+
const res = await getPositionHistory(
|
|
14455
|
+
{ accessToken, ...params, address },
|
|
14456
|
+
{
|
|
14457
|
+
isProd: !config?.isTestnet
|
|
14458
|
+
}
|
|
14459
|
+
);
|
|
14202
14460
|
return {
|
|
14203
14461
|
code: 0,
|
|
14204
14462
|
data: res.data
|
|
@@ -14221,7 +14479,7 @@ var Position = class {
|
|
|
14221
14479
|
quoteToken
|
|
14222
14480
|
});
|
|
14223
14481
|
try {
|
|
14224
|
-
const priceData = await this.utils.getOraclePrice(poolId);
|
|
14482
|
+
const priceData = await this.utils.getOraclePrice(poolId, chainId);
|
|
14225
14483
|
if (!priceData) {
|
|
14226
14484
|
throw new Error("Failed to get price data");
|
|
14227
14485
|
}
|
|
@@ -14244,7 +14502,11 @@ var Position = class {
|
|
|
14244
14502
|
const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
|
|
14245
14503
|
let depositAmount = BigInt(0);
|
|
14246
14504
|
const used = BigInt(adjustAmount) > 0 ? BigInt(adjustAmount) : 0n;
|
|
14247
|
-
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14505
|
+
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14506
|
+
poolId,
|
|
14507
|
+
chainId,
|
|
14508
|
+
address
|
|
14509
|
+
});
|
|
14248
14510
|
let diff = BigInt(0);
|
|
14249
14511
|
if (availableAccountMarginBalance < used) {
|
|
14250
14512
|
diff = used - availableAccountMarginBalance;
|
|
@@ -14266,21 +14528,24 @@ var Position = class {
|
|
|
14266
14528
|
throw new Error(approvalResult.message);
|
|
14267
14529
|
}
|
|
14268
14530
|
}
|
|
14269
|
-
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14531
|
+
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14532
|
+
config.seamlessAccount?.masterAddress
|
|
14533
|
+
);
|
|
14270
14534
|
if (!isEnoughGas) {
|
|
14271
|
-
throw new MyxSDKError(
|
|
14535
|
+
throw new MyxSDKError(
|
|
14536
|
+
"INSUFFICIENT_BALANCE" /* InsufficientBalance */,
|
|
14537
|
+
"Insufficient relay fee"
|
|
14538
|
+
);
|
|
14272
14539
|
}
|
|
14273
14540
|
const forwarderContract = await getForwarderContract(chainId);
|
|
14274
14541
|
const brokerContract2 = await getSeamlessBrokerContract(
|
|
14275
14542
|
this.configManager.getConfig().brokerAddress,
|
|
14276
14543
|
seamlessWallet
|
|
14277
14544
|
);
|
|
14278
|
-
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14279
|
-
|
|
14280
|
-
depositData,
|
|
14281
|
-
|
|
14282
|
-
adjustAmount
|
|
14283
|
-
]);
|
|
14545
|
+
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14546
|
+
"updatePriceAndAdjustCollateral",
|
|
14547
|
+
[[updateParams], depositData, positionId, adjustAmount]
|
|
14548
|
+
);
|
|
14284
14549
|
const nonce = await forwarderContract.nonces(seamlessWallet.address);
|
|
14285
14550
|
const forwardTxParams = {
|
|
14286
14551
|
from: seamlessWallet.address ?? "",
|
|
@@ -14291,8 +14556,15 @@ var Position = class {
|
|
|
14291
14556
|
data: functionHash,
|
|
14292
14557
|
nonce: nonce.toString()
|
|
14293
14558
|
};
|
|
14294
|
-
this.logger.info(
|
|
14295
|
-
|
|
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
|
+
);
|
|
14296
14568
|
console.log("rs-->", rs);
|
|
14297
14569
|
return {
|
|
14298
14570
|
code: 0,
|
|
@@ -15388,6 +15660,7 @@ var Order = class {
|
|
|
15388
15660
|
}
|
|
15389
15661
|
}
|
|
15390
15662
|
async getOrders(address) {
|
|
15663
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
15391
15664
|
const accessToken = await this.configManager.getAccessToken();
|
|
15392
15665
|
if (!accessToken) {
|
|
15393
15666
|
return {
|
|
@@ -15396,7 +15669,7 @@ var Order = class {
|
|
|
15396
15669
|
};
|
|
15397
15670
|
}
|
|
15398
15671
|
try {
|
|
15399
|
-
const res = await getOrders(accessToken, address);
|
|
15672
|
+
const res = await getOrders(accessToken, address, isProd);
|
|
15400
15673
|
return {
|
|
15401
15674
|
code: 0,
|
|
15402
15675
|
data: res.data
|
|
@@ -15410,6 +15683,7 @@ var Order = class {
|
|
|
15410
15683
|
}
|
|
15411
15684
|
}
|
|
15412
15685
|
async getOrderHistory(params, address) {
|
|
15686
|
+
const config = this.configManager.getConfig();
|
|
15413
15687
|
const accessToken = await this.configManager.getAccessToken();
|
|
15414
15688
|
if (!accessToken) {
|
|
15415
15689
|
throw new MyxSDKError(
|
|
@@ -15417,7 +15691,9 @@ var Order = class {
|
|
|
15417
15691
|
"Invalid access token"
|
|
15418
15692
|
);
|
|
15419
15693
|
}
|
|
15420
|
-
const res = await getHistoryOrders({ accessToken, ...params, address }
|
|
15694
|
+
const res = await getHistoryOrders({ accessToken, ...params, address }, {
|
|
15695
|
+
isProd: !config?.isTestnet
|
|
15696
|
+
});
|
|
15421
15697
|
return {
|
|
15422
15698
|
code: 0,
|
|
15423
15699
|
data: res.data
|
|
@@ -20187,7 +20463,7 @@ var Utils = class {
|
|
|
20187
20463
|
};
|
|
20188
20464
|
}
|
|
20189
20465
|
}
|
|
20190
|
-
async getUserTradingFeeRate(assetClass) {
|
|
20466
|
+
async getUserTradingFeeRate(assetClass, riskTier) {
|
|
20191
20467
|
const config = this.configManager.getConfig();
|
|
20192
20468
|
const brokerAddress = config.brokerAddress;
|
|
20193
20469
|
try {
|
|
@@ -20200,7 +20476,8 @@ var Utils = class {
|
|
|
20200
20476
|
const targetAddress = config.seamlessMode ? config.seamlessAccount?.masterAddress : config.signer?.getAddress();
|
|
20201
20477
|
const userFeeRate = await brokerContract.getUserFeeRate(
|
|
20202
20478
|
targetAddress,
|
|
20203
|
-
assetClass
|
|
20479
|
+
assetClass,
|
|
20480
|
+
riskTier
|
|
20204
20481
|
);
|
|
20205
20482
|
return {
|
|
20206
20483
|
code: 0,
|
|
@@ -20241,10 +20518,10 @@ var Utils = class {
|
|
|
20241
20518
|
return "0";
|
|
20242
20519
|
}
|
|
20243
20520
|
}
|
|
20244
|
-
async getOraclePrice(poolId) {
|
|
20521
|
+
async getOraclePrice(poolId, chainId) {
|
|
20245
20522
|
try {
|
|
20246
|
-
const
|
|
20247
|
-
const priceData = await getPriceData(
|
|
20523
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
20524
|
+
const priceData = await getPriceData(chainId, poolId, isProd);
|
|
20248
20525
|
if (!priceData) throw new Error("Failed to get price data");
|
|
20249
20526
|
return priceData;
|
|
20250
20527
|
} catch (error) {
|
|
@@ -21160,7 +21437,8 @@ var Account = class {
|
|
|
21160
21437
|
}
|
|
21161
21438
|
async getAvailableMarginBalance({ poolId, chainId, address }) {
|
|
21162
21439
|
try {
|
|
21163
|
-
const
|
|
21440
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
21441
|
+
const poolListRes = await getPoolList({ isProd });
|
|
21164
21442
|
if (poolListRes.code !== 9200) {
|
|
21165
21443
|
throw new MyxSDKError(
|
|
21166
21444
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -21190,20 +21468,15 @@ var Account = class {
|
|
|
21190
21468
|
"Failed to get account info"
|
|
21191
21469
|
);
|
|
21192
21470
|
}
|
|
21193
|
-
this.logger.info("getAvailableMarginBalance used-->", used);
|
|
21194
21471
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
21195
21472
|
const usedMargin = BigInt(used ?? "0");
|
|
21196
21473
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
21197
|
-
this.logger.info("getAvailableMarginBalance quoteProfit-->", quoteProfit.toString);
|
|
21198
21474
|
const freeAmount = BigInt(marginAccountBalance?.freeMargin ?? 0);
|
|
21199
|
-
this.logger.info("getAvailableMarginBalance freeAmount-->", freeAmount.toString());
|
|
21200
21475
|
const accountMargin = freeAmount + quoteProfit;
|
|
21201
|
-
this.logger.info("getAvailableMarginBalance accountMargin-->", accountMargin.toString());
|
|
21202
21476
|
if (accountMargin < usedMargin) {
|
|
21203
21477
|
return BigInt(0);
|
|
21204
21478
|
}
|
|
21205
21479
|
const availableAccountMarginBalance = accountMargin - usedMargin;
|
|
21206
|
-
this.logger.info("getAvailableMarginBalance availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
21207
21480
|
return availableAccountMarginBalance;
|
|
21208
21481
|
} catch (error) {
|
|
21209
21482
|
this.logger.info("getAvailableMarginBalance error-->", error);
|
|
@@ -21214,6 +21487,7 @@ var Account = class {
|
|
|
21214
21487
|
}
|
|
21215
21488
|
}
|
|
21216
21489
|
async getTradeFlow(params, address) {
|
|
21490
|
+
const config = this.configManager.getConfig();
|
|
21217
21491
|
const accessToken = await this.configManager.getAccessToken();
|
|
21218
21492
|
if (!accessToken) {
|
|
21219
21493
|
throw new MyxSDKError(
|
|
@@ -21221,7 +21495,9 @@ var Account = class {
|
|
|
21221
21495
|
"Invalid access token"
|
|
21222
21496
|
);
|
|
21223
21497
|
}
|
|
21224
|
-
const res = await getTradeFlow({ accessToken, ...params, address }
|
|
21498
|
+
const res = await getTradeFlow({ accessToken, ...params, address }, {
|
|
21499
|
+
isProd: !config?.isTestnet
|
|
21500
|
+
});
|
|
21225
21501
|
return {
|
|
21226
21502
|
code: 0,
|
|
21227
21503
|
data: res.data
|
|
@@ -21649,6 +21925,7 @@ var Seamless = class {
|
|
|
21649
21925
|
data,
|
|
21650
21926
|
nonce
|
|
21651
21927
|
}, chainId, provider) {
|
|
21928
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
21652
21929
|
const forwarderContract = await getForwarderContract(chainId);
|
|
21653
21930
|
const forwarderJsonRpcContractDomain = await forwarderContract.eip712Domain();
|
|
21654
21931
|
const domain = {
|
|
@@ -21667,7 +21944,7 @@ var Seamless = class {
|
|
|
21667
21944
|
deadline,
|
|
21668
21945
|
data
|
|
21669
21946
|
});
|
|
21670
|
-
const txRs = await forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature }, chainId);
|
|
21947
|
+
const txRs = await forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature }, chainId, isProd);
|
|
21671
21948
|
return txRs;
|
|
21672
21949
|
}
|
|
21673
21950
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
|
@@ -21680,7 +21957,7 @@ var Seamless = class {
|
|
|
21680
21957
|
if (approve2) {
|
|
21681
21958
|
const balanceRes = await this.account.getWalletQuoteTokenBalance(masterAddress);
|
|
21682
21959
|
const balance = balanceRes.data;
|
|
21683
|
-
const forwarderContract2 = await getForwarderContract(
|
|
21960
|
+
const forwarderContract2 = await getForwarderContract(chainId);
|
|
21684
21961
|
const pledgeFee = await forwarderContract2.getRelayFee();
|
|
21685
21962
|
const gasFee = BigInt(pledgeFee) * BigInt(FORWARD_PLEDGE_FEE_RADIO);
|
|
21686
21963
|
if (gasFee > 0 && gasFee > BigInt(balance)) {
|
|
@@ -21691,9 +21968,7 @@ var Seamless = class {
|
|
|
21691
21968
|
let permitParams = [];
|
|
21692
21969
|
if (approve2) {
|
|
21693
21970
|
try {
|
|
21694
|
-
console.log("getUSDPermitParams");
|
|
21695
21971
|
permitParams = await this.getUSDPermitParams(deadline, chainId);
|
|
21696
|
-
console.log("permitParams result-->", permitParams);
|
|
21697
21972
|
} catch (error) {
|
|
21698
21973
|
console.warn("Failed to get USD permit params, proceeding without permit:", error);
|
|
21699
21974
|
permitParams = [];
|
|
@@ -21963,19 +22238,19 @@ var MyxClient = class {
|
|
|
21963
22238
|
addFavorite,
|
|
21964
22239
|
approve,
|
|
21965
22240
|
base,
|
|
21966
|
-
baseUrl,
|
|
21967
22241
|
bigintAmountSlipperCalculator,
|
|
21968
22242
|
bigintTradingGasPriceWithRatio,
|
|
21969
22243
|
bigintTradingGasToRatioCalculator,
|
|
21970
22244
|
fetchForwarderGetApi,
|
|
21971
22245
|
formatUnits,
|
|
21972
|
-
forwardUrl,
|
|
21973
22246
|
forwarderTxApi,
|
|
21974
22247
|
getAllTickers,
|
|
21975
22248
|
getAllowanceApproved,
|
|
21976
22249
|
getBalanceOf,
|
|
21977
22250
|
getBaseDetail,
|
|
22251
|
+
getBaseUrlByEnv,
|
|
21978
22252
|
getFavoritesList,
|
|
22253
|
+
getForwardUrlByEnv,
|
|
21979
22254
|
getHistoryOrders,
|
|
21980
22255
|
getKlineData,
|
|
21981
22256
|
getKlineLatestBar,
|