@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.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"
|
|
@@ -1997,9 +1997,10 @@ var getHistoryOrders = async ({
|
|
|
1997
1997
|
accessToken,
|
|
1998
1998
|
address,
|
|
1999
1999
|
...params
|
|
2000
|
-
}) => {
|
|
2000
|
+
}, envParams) => {
|
|
2001
|
+
const isProd = envParams?.isProd ?? true;
|
|
2001
2002
|
return http.get(
|
|
2002
|
-
`${
|
|
2003
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/closed`,
|
|
2003
2004
|
params,
|
|
2004
2005
|
{
|
|
2005
2006
|
headers: {
|
|
@@ -2026,9 +2027,10 @@ var getPositionHistory = async ({
|
|
|
2026
2027
|
accessToken,
|
|
2027
2028
|
address,
|
|
2028
2029
|
...params
|
|
2029
|
-
}) => {
|
|
2030
|
+
}, envParams) => {
|
|
2031
|
+
const isProd = envParams?.isProd ?? true;
|
|
2030
2032
|
return http.get(
|
|
2031
|
-
`${
|
|
2033
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/position/closed`,
|
|
2032
2034
|
params,
|
|
2033
2035
|
{
|
|
2034
2036
|
headers: {
|
|
@@ -2048,9 +2050,10 @@ var getTradeFlow = async ({
|
|
|
2048
2050
|
accessToken,
|
|
2049
2051
|
address,
|
|
2050
2052
|
...params
|
|
2051
|
-
}) => {
|
|
2053
|
+
}, envParams) => {
|
|
2054
|
+
const isProd = envParams?.isProd ?? true;
|
|
2052
2055
|
return http.get(
|
|
2053
|
-
`${
|
|
2056
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/trade/flow`,
|
|
2054
2057
|
params,
|
|
2055
2058
|
{
|
|
2056
2059
|
headers: {
|
|
@@ -2062,10 +2065,9 @@ var getTradeFlow = async ({
|
|
|
2062
2065
|
};
|
|
2063
2066
|
|
|
2064
2067
|
// src/api/seamless/index.ts
|
|
2065
|
-
var forwarderTxApi = async (params, chainId) => {
|
|
2066
|
-
console.log("forwarderTxApi params-->", params);
|
|
2068
|
+
var forwarderTxApi = async (params, chainId, isProd = true) => {
|
|
2067
2069
|
return http.post(
|
|
2068
|
-
`${
|
|
2070
|
+
`${getForwardUrlByEnv(isProd)}/forwarder/tx-v2`,
|
|
2069
2071
|
params,
|
|
2070
2072
|
{
|
|
2071
2073
|
headers: {
|
|
@@ -2081,56 +2083,72 @@ var ForwarderGetStatus = /* @__PURE__ */ ((ForwarderGetStatus2) => {
|
|
|
2081
2083
|
ForwarderGetStatus2[ForwarderGetStatus2["EXECUTED"] = 9] = "EXECUTED";
|
|
2082
2084
|
return ForwarderGetStatus2;
|
|
2083
2085
|
})(ForwarderGetStatus || {});
|
|
2084
|
-
var fetchForwarderGetApi = async (params) => {
|
|
2086
|
+
var fetchForwarderGetApi = async (params, isProd = true) => {
|
|
2085
2087
|
const rs = await http.get(
|
|
2086
|
-
`${
|
|
2088
|
+
`${getForwardUrlByEnv(isProd)}/forwarder/get${addQueryParams(params)}`
|
|
2087
2089
|
);
|
|
2088
2090
|
return rs;
|
|
2089
2091
|
};
|
|
2090
2092
|
|
|
2091
2093
|
// src/api/pool/index.ts
|
|
2092
|
-
var getPoolList = async (
|
|
2094
|
+
var getPoolList = async ({
|
|
2095
|
+
isProd = true
|
|
2096
|
+
}) => {
|
|
2093
2097
|
return http.get(
|
|
2094
|
-
`${
|
|
2098
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/list`
|
|
2095
2099
|
);
|
|
2096
2100
|
};
|
|
2097
|
-
var getPoolSymbolAll = async (
|
|
2101
|
+
var getPoolSymbolAll = async ({
|
|
2102
|
+
isProd = true
|
|
2103
|
+
}) => {
|
|
2098
2104
|
return http.get(
|
|
2099
|
-
`${
|
|
2105
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/pools`
|
|
2100
2106
|
);
|
|
2101
2107
|
};
|
|
2102
2108
|
|
|
2103
2109
|
// src/api/index.ts
|
|
2104
|
-
var
|
|
2105
|
-
|
|
2106
|
-
|
|
2110
|
+
var getBaseUrlByEnv = (isProd) => {
|
|
2111
|
+
return isProd ? "https://api.myx.finance" : "https://api-test.myx.cash";
|
|
2112
|
+
};
|
|
2113
|
+
var getForwardUrlByEnv = (isProd) => {
|
|
2114
|
+
return isProd ? "https://api.myx.finance/v2/agent" : "https://api-test.myx.cash/v2/agent";
|
|
2115
|
+
};
|
|
2116
|
+
var getOraclePrice = async (chainId, poolIds = [], isProd = true) => {
|
|
2107
2117
|
if (!!poolIds.length) {
|
|
2108
|
-
return http.get(
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2118
|
+
return http.get(
|
|
2119
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/price/oracles`,
|
|
2120
|
+
{
|
|
2121
|
+
chainId,
|
|
2122
|
+
poolIds: poolIds.join(",")
|
|
2123
|
+
}
|
|
2124
|
+
);
|
|
2112
2125
|
}
|
|
2113
2126
|
return Promise.reject(new Error("Invalid pool id"));
|
|
2114
2127
|
};
|
|
2115
2128
|
var getPoolLevelConfig = async ({
|
|
2116
2129
|
poolId,
|
|
2117
|
-
chainId
|
|
2130
|
+
chainId,
|
|
2131
|
+
isProd = true
|
|
2118
2132
|
}) => {
|
|
2119
2133
|
return http.get(
|
|
2120
|
-
`${
|
|
2134
|
+
`${getBaseUrlByEnv(
|
|
2135
|
+
isProd
|
|
2136
|
+
)}/openapi/gateway/risk/market_pool/level_config${addQueryParams({
|
|
2121
2137
|
poolId,
|
|
2122
2138
|
chainId
|
|
2123
2139
|
})}`
|
|
2124
2140
|
);
|
|
2125
2141
|
};
|
|
2126
|
-
var getPoolDetail = async (chainId, poolId) => {
|
|
2142
|
+
var getPoolDetail = async (chainId, poolId, isProd = true) => {
|
|
2127
2143
|
return await http.get(
|
|
2128
|
-
`${
|
|
2144
|
+
`${getBaseUrlByEnv(
|
|
2145
|
+
isProd
|
|
2146
|
+
)}/openapi/gateway/scan/market/info?chainId=${chainId}&poolId=${poolId}`
|
|
2129
2147
|
);
|
|
2130
2148
|
};
|
|
2131
|
-
var getPositions = async (accessToken, address) => {
|
|
2149
|
+
var getPositions = async (accessToken, address, isProd = true) => {
|
|
2132
2150
|
return await http.get(
|
|
2133
|
-
`${
|
|
2151
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/position/open`,
|
|
2134
2152
|
void 0,
|
|
2135
2153
|
// params
|
|
2136
2154
|
{
|
|
@@ -2141,29 +2159,36 @@ var getPositions = async (accessToken, address) => {
|
|
|
2141
2159
|
}
|
|
2142
2160
|
);
|
|
2143
2161
|
};
|
|
2144
|
-
var getOrders = async (accessToken, address) => {
|
|
2162
|
+
var getOrders = async (accessToken, address, isProd = true) => {
|
|
2145
2163
|
return await http.get(
|
|
2146
|
-
`${
|
|
2164
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/open`,
|
|
2147
2165
|
void 0,
|
|
2148
|
-
{
|
|
2166
|
+
{
|
|
2167
|
+
headers: {
|
|
2168
|
+
myx_openapi_access_token: accessToken,
|
|
2169
|
+
myx_openapi_account: address
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2149
2172
|
);
|
|
2150
2173
|
};
|
|
2151
|
-
var getPoolOpenOrders = async (accessToken, address, chainId) => {
|
|
2174
|
+
var getPoolOpenOrders = async (accessToken, address, chainId, isProd = true) => {
|
|
2152
2175
|
return await http.get(
|
|
2153
|
-
`${
|
|
2176
|
+
`${getBaseUrlByEnv(
|
|
2177
|
+
isProd
|
|
2178
|
+
)}/openapi/gateway/scan/market/pool-order/open?chainId=${chainId}`,
|
|
2154
2179
|
void 0,
|
|
2155
|
-
{
|
|
2180
|
+
{
|
|
2181
|
+
headers: {
|
|
2182
|
+
myx_openapi_access_token: accessToken,
|
|
2183
|
+
myx_openapi_account: address
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2156
2186
|
);
|
|
2157
2187
|
};
|
|
2158
|
-
var getKlineData = ({
|
|
2159
|
-
|
|
2160
|
-
poolId,
|
|
2161
|
-
endTime,
|
|
2162
|
-
limit,
|
|
2163
|
-
interval
|
|
2164
|
-
}) => {
|
|
2188
|
+
var getKlineData = ({ chainId, poolId, endTime, limit, interval }, envParams) => {
|
|
2189
|
+
const isProd = envParams?.isProd ?? true;
|
|
2165
2190
|
return http.get(
|
|
2166
|
-
`${
|
|
2191
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candles`,
|
|
2167
2192
|
{
|
|
2168
2193
|
chainId,
|
|
2169
2194
|
poolId,
|
|
@@ -2173,36 +2198,33 @@ var getKlineData = ({
|
|
|
2173
2198
|
}
|
|
2174
2199
|
);
|
|
2175
2200
|
};
|
|
2176
|
-
var getKlineLatestBar = async (params) => {
|
|
2201
|
+
var getKlineLatestBar = async (params, envParams) => {
|
|
2202
|
+
const isProd = envParams?.isProd ?? true;
|
|
2177
2203
|
return http.get(
|
|
2178
|
-
`${
|
|
2204
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/latest`,
|
|
2179
2205
|
params
|
|
2180
2206
|
);
|
|
2181
2207
|
};
|
|
2182
|
-
var getTickerData = async ({
|
|
2183
|
-
|
|
2184
|
-
poolIds
|
|
2185
|
-
}) => {
|
|
2208
|
+
var getTickerData = async ({ chainId, poolIds }, envParams) => {
|
|
2209
|
+
const isProd = envParams?.isProd ?? true;
|
|
2186
2210
|
return http.get(
|
|
2187
|
-
`${
|
|
2211
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/tickers`,
|
|
2188
2212
|
{
|
|
2189
2213
|
chainId,
|
|
2190
2214
|
poolIds: poolIds.join(",")
|
|
2191
2215
|
}
|
|
2192
2216
|
);
|
|
2193
2217
|
};
|
|
2194
|
-
var getAllTickers = async () => {
|
|
2218
|
+
var getAllTickers = async (envParams) => {
|
|
2219
|
+
const isProd = envParams?.isProd ?? true;
|
|
2195
2220
|
return http.get(
|
|
2196
|
-
`${
|
|
2221
|
+
`${getBaseUrlByEnv(isProd)}/v2/mx-gateway/quote/candle/all_tickers`
|
|
2197
2222
|
);
|
|
2198
2223
|
};
|
|
2199
|
-
var searchMarketAuth = async ({
|
|
2200
|
-
|
|
2201
|
-
address,
|
|
2202
|
-
...params
|
|
2203
|
-
}) => {
|
|
2224
|
+
var searchMarketAuth = async ({ accessToken, address, ...params }, envParams) => {
|
|
2225
|
+
const isProd = envParams?.isProd ?? true;
|
|
2204
2226
|
return http.get(
|
|
2205
|
-
`${
|
|
2227
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/ac-search`,
|
|
2206
2228
|
params,
|
|
2207
2229
|
{
|
|
2208
2230
|
headers: {
|
|
@@ -2212,19 +2234,17 @@ var searchMarketAuth = async ({
|
|
|
2212
2234
|
}
|
|
2213
2235
|
);
|
|
2214
2236
|
};
|
|
2215
|
-
var searchMarket = async ({ ...params }) => {
|
|
2237
|
+
var searchMarket = async ({ ...params }, envParams) => {
|
|
2238
|
+
const isProd = envParams?.isProd ?? true;
|
|
2216
2239
|
return http.get(
|
|
2217
|
-
`${
|
|
2240
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/search`,
|
|
2218
2241
|
params
|
|
2219
2242
|
);
|
|
2220
2243
|
};
|
|
2221
|
-
var addFavorite = async ({
|
|
2222
|
-
|
|
2223
|
-
address,
|
|
2224
|
-
...params
|
|
2225
|
-
}) => {
|
|
2244
|
+
var addFavorite = async ({ accessToken, address, ...params }, envParams) => {
|
|
2245
|
+
const isProd = envParams?.isProd ?? true;
|
|
2226
2246
|
return http.get(
|
|
2227
|
-
`${
|
|
2247
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/add-favorites`,
|
|
2228
2248
|
params,
|
|
2229
2249
|
{
|
|
2230
2250
|
headers: {
|
|
@@ -2238,9 +2258,10 @@ var removeFavorite = async ({
|
|
|
2238
2258
|
accessToken,
|
|
2239
2259
|
address,
|
|
2240
2260
|
...params
|
|
2241
|
-
}) => {
|
|
2261
|
+
}, envParams) => {
|
|
2262
|
+
const isProd = envParams?.isProd ?? true;
|
|
2242
2263
|
return http.get(
|
|
2243
|
-
`${
|
|
2264
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/cancel-favorites`,
|
|
2244
2265
|
params,
|
|
2245
2266
|
{
|
|
2246
2267
|
headers: {
|
|
@@ -2250,13 +2271,10 @@ var removeFavorite = async ({
|
|
|
2250
2271
|
}
|
|
2251
2272
|
);
|
|
2252
2273
|
};
|
|
2253
|
-
var getFavoritesList = async ({
|
|
2254
|
-
|
|
2255
|
-
address,
|
|
2256
|
-
...params
|
|
2257
|
-
}) => {
|
|
2274
|
+
var getFavoritesList = async ({ accessToken, address, ...params }, envParams) => {
|
|
2275
|
+
const isProd = envParams?.isProd ?? true;
|
|
2258
2276
|
return http.get(
|
|
2259
|
-
`${
|
|
2277
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/favorites`,
|
|
2260
2278
|
params,
|
|
2261
2279
|
{
|
|
2262
2280
|
headers: {
|
|
@@ -2266,20 +2284,25 @@ var getFavoritesList = async ({
|
|
|
2266
2284
|
}
|
|
2267
2285
|
);
|
|
2268
2286
|
};
|
|
2269
|
-
var getBaseDetail = async (params) => {
|
|
2287
|
+
var getBaseDetail = async ({ ...params }, envParams) => {
|
|
2288
|
+
const isProd = envParams?.isProd ?? true;
|
|
2270
2289
|
return http.get(
|
|
2271
|
-
`${
|
|
2290
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/base-details`,
|
|
2272
2291
|
params
|
|
2273
2292
|
);
|
|
2274
2293
|
};
|
|
2275
|
-
var getMarketDetail = async (params) => {
|
|
2294
|
+
var getMarketDetail = async ({ ...params }, envParams) => {
|
|
2295
|
+
const isProd = envParams?.isProd ?? true;
|
|
2276
2296
|
return http.get(
|
|
2277
|
-
`${
|
|
2297
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/detail`,
|
|
2278
2298
|
params
|
|
2279
2299
|
);
|
|
2280
2300
|
};
|
|
2281
|
-
var getMarketList = async () => {
|
|
2282
|
-
|
|
2301
|
+
var getMarketList = async (envParams) => {
|
|
2302
|
+
const isProd = envParams?.isProd ?? true;
|
|
2303
|
+
return http.get(
|
|
2304
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market`
|
|
2305
|
+
);
|
|
2283
2306
|
};
|
|
2284
2307
|
|
|
2285
2308
|
// src/web3/index.ts
|
|
@@ -5318,6 +5341,11 @@ var BasePool_default = [
|
|
|
5318
5341
|
|
|
5319
5342
|
// src/abi/Broker.json
|
|
5320
5343
|
var Broker_default = [
|
|
5344
|
+
{
|
|
5345
|
+
type: "constructor",
|
|
5346
|
+
payable: false,
|
|
5347
|
+
inputs: []
|
|
5348
|
+
},
|
|
5321
5349
|
{
|
|
5322
5350
|
type: "error",
|
|
5323
5351
|
name: "ECDSAInvalidSignature",
|
|
@@ -5667,7 +5695,16 @@ var Broker_default = [
|
|
|
5667
5695
|
constant: true,
|
|
5668
5696
|
stateMutability: "view",
|
|
5669
5697
|
payable: false,
|
|
5670
|
-
inputs: [
|
|
5698
|
+
inputs: [
|
|
5699
|
+
{
|
|
5700
|
+
type: "uint8",
|
|
5701
|
+
name: "assetClass"
|
|
5702
|
+
},
|
|
5703
|
+
{
|
|
5704
|
+
type: "uint8",
|
|
5705
|
+
name: "riskTier"
|
|
5706
|
+
}
|
|
5707
|
+
],
|
|
5671
5708
|
outputs: [
|
|
5672
5709
|
{
|
|
5673
5710
|
type: "uint256[]"
|
|
@@ -5680,7 +5717,16 @@ var Broker_default = [
|
|
|
5680
5717
|
constant: true,
|
|
5681
5718
|
stateMutability: "view",
|
|
5682
5719
|
payable: false,
|
|
5683
|
-
inputs: [
|
|
5720
|
+
inputs: [
|
|
5721
|
+
{
|
|
5722
|
+
type: "uint8",
|
|
5723
|
+
name: "assetClass"
|
|
5724
|
+
},
|
|
5725
|
+
{
|
|
5726
|
+
type: "uint8",
|
|
5727
|
+
name: "riskTier"
|
|
5728
|
+
}
|
|
5729
|
+
],
|
|
5684
5730
|
outputs: [
|
|
5685
5731
|
{
|
|
5686
5732
|
type: "uint256[]"
|
|
@@ -5731,6 +5777,82 @@ var Broker_default = [
|
|
|
5731
5777
|
],
|
|
5732
5778
|
outputs: []
|
|
5733
5779
|
},
|
|
5780
|
+
{
|
|
5781
|
+
type: "function",
|
|
5782
|
+
name: "batchSetSpecialFeeTiers",
|
|
5783
|
+
constant: false,
|
|
5784
|
+
payable: false,
|
|
5785
|
+
inputs: [
|
|
5786
|
+
{
|
|
5787
|
+
type: "tuple[]",
|
|
5788
|
+
name: "params",
|
|
5789
|
+
components: [
|
|
5790
|
+
{
|
|
5791
|
+
type: "uint8",
|
|
5792
|
+
name: "assetClass"
|
|
5793
|
+
},
|
|
5794
|
+
{
|
|
5795
|
+
type: "uint8",
|
|
5796
|
+
name: "riskTier"
|
|
5797
|
+
},
|
|
5798
|
+
{
|
|
5799
|
+
type: "uint8",
|
|
5800
|
+
name: "feeTier"
|
|
5801
|
+
},
|
|
5802
|
+
{
|
|
5803
|
+
type: "int32",
|
|
5804
|
+
name: "makerFeeRate"
|
|
5805
|
+
},
|
|
5806
|
+
{
|
|
5807
|
+
type: "uint32",
|
|
5808
|
+
name: "takerFeeRate"
|
|
5809
|
+
}
|
|
5810
|
+
]
|
|
5811
|
+
}
|
|
5812
|
+
],
|
|
5813
|
+
outputs: []
|
|
5814
|
+
},
|
|
5815
|
+
{
|
|
5816
|
+
type: "function",
|
|
5817
|
+
name: "batchUpdateFeeTiers",
|
|
5818
|
+
constant: false,
|
|
5819
|
+
payable: false,
|
|
5820
|
+
inputs: [
|
|
5821
|
+
{
|
|
5822
|
+
type: "tuple[]",
|
|
5823
|
+
name: "params",
|
|
5824
|
+
components: [
|
|
5825
|
+
{
|
|
5826
|
+
type: "uint8",
|
|
5827
|
+
name: "assetClass"
|
|
5828
|
+
},
|
|
5829
|
+
{
|
|
5830
|
+
type: "uint8",
|
|
5831
|
+
name: "riskTier"
|
|
5832
|
+
},
|
|
5833
|
+
{
|
|
5834
|
+
type: "uint8",
|
|
5835
|
+
name: "feeTier"
|
|
5836
|
+
},
|
|
5837
|
+
{
|
|
5838
|
+
type: "tuple",
|
|
5839
|
+
name: "addOnFeeRate",
|
|
5840
|
+
components: [
|
|
5841
|
+
{
|
|
5842
|
+
type: "uint32",
|
|
5843
|
+
name: "takerFeeRate"
|
|
5844
|
+
},
|
|
5845
|
+
{
|
|
5846
|
+
type: "uint32",
|
|
5847
|
+
name: "makerFeeRate"
|
|
5848
|
+
}
|
|
5849
|
+
]
|
|
5850
|
+
}
|
|
5851
|
+
]
|
|
5852
|
+
}
|
|
5853
|
+
],
|
|
5854
|
+
outputs: []
|
|
5855
|
+
},
|
|
5734
5856
|
{
|
|
5735
5857
|
type: "function",
|
|
5736
5858
|
name: "cancelOrder",
|
|
@@ -5830,7 +5952,15 @@ var Broker_default = [
|
|
|
5830
5952
|
inputs: [
|
|
5831
5953
|
{
|
|
5832
5954
|
type: "uint8",
|
|
5833
|
-
name: "
|
|
5955
|
+
name: "assetClass"
|
|
5956
|
+
},
|
|
5957
|
+
{
|
|
5958
|
+
type: "uint8",
|
|
5959
|
+
name: "riskTier"
|
|
5960
|
+
},
|
|
5961
|
+
{
|
|
5962
|
+
type: "uint8",
|
|
5963
|
+
name: "feeTier"
|
|
5834
5964
|
}
|
|
5835
5965
|
],
|
|
5836
5966
|
outputs: [
|
|
@@ -5880,6 +6010,14 @@ var Broker_default = [
|
|
|
5880
6010
|
stateMutability: "view",
|
|
5881
6011
|
payable: false,
|
|
5882
6012
|
inputs: [
|
|
6013
|
+
{
|
|
6014
|
+
type: "uint8",
|
|
6015
|
+
name: "assetClass"
|
|
6016
|
+
},
|
|
6017
|
+
{
|
|
6018
|
+
type: "uint8",
|
|
6019
|
+
name: "riskTier"
|
|
6020
|
+
},
|
|
5883
6021
|
{
|
|
5884
6022
|
type: "uint8",
|
|
5885
6023
|
name: "feeTier"
|
|
@@ -5910,6 +6048,10 @@ var Broker_default = [
|
|
|
5910
6048
|
{
|
|
5911
6049
|
type: "uint8",
|
|
5912
6050
|
name: "assetClass"
|
|
6051
|
+
},
|
|
6052
|
+
{
|
|
6053
|
+
type: "uint8",
|
|
6054
|
+
name: "riskTier"
|
|
5913
6055
|
}
|
|
5914
6056
|
],
|
|
5915
6057
|
outputs: [
|
|
@@ -6522,16 +6664,30 @@ var Broker_default = [
|
|
|
6522
6664
|
payable: false,
|
|
6523
6665
|
inputs: [
|
|
6524
6666
|
{
|
|
6525
|
-
type: "
|
|
6526
|
-
name: "
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6667
|
+
type: "tuple",
|
|
6668
|
+
name: "params",
|
|
6669
|
+
components: [
|
|
6670
|
+
{
|
|
6671
|
+
type: "uint8",
|
|
6672
|
+
name: "assetClass"
|
|
6673
|
+
},
|
|
6674
|
+
{
|
|
6675
|
+
type: "uint8",
|
|
6676
|
+
name: "riskTier"
|
|
6677
|
+
},
|
|
6678
|
+
{
|
|
6679
|
+
type: "uint8",
|
|
6680
|
+
name: "feeTier"
|
|
6681
|
+
},
|
|
6682
|
+
{
|
|
6683
|
+
type: "int32",
|
|
6684
|
+
name: "makerFeeRate"
|
|
6685
|
+
},
|
|
6686
|
+
{
|
|
6687
|
+
type: "uint32",
|
|
6688
|
+
name: "takerFeeRate"
|
|
6689
|
+
}
|
|
6690
|
+
]
|
|
6535
6691
|
}
|
|
6536
6692
|
],
|
|
6537
6693
|
outputs: []
|
|
@@ -6651,25 +6807,31 @@ var Broker_default = [
|
|
|
6651
6807
|
constant: false,
|
|
6652
6808
|
payable: false,
|
|
6653
6809
|
inputs: [
|
|
6654
|
-
{
|
|
6655
|
-
type: "uint8[]",
|
|
6656
|
-
name: "assetClasses"
|
|
6657
|
-
},
|
|
6658
|
-
{
|
|
6659
|
-
type: "bool[]",
|
|
6660
|
-
name: "isEnables"
|
|
6661
|
-
},
|
|
6662
6810
|
{
|
|
6663
6811
|
type: "tuple[]",
|
|
6664
|
-
name: "
|
|
6812
|
+
name: "params",
|
|
6665
6813
|
components: [
|
|
6666
6814
|
{
|
|
6667
|
-
type: "
|
|
6668
|
-
name: "
|
|
6815
|
+
type: "uint8",
|
|
6816
|
+
name: "assetClass"
|
|
6669
6817
|
},
|
|
6670
6818
|
{
|
|
6671
|
-
type: "
|
|
6672
|
-
name: "
|
|
6819
|
+
type: "bool",
|
|
6820
|
+
name: "isEnable"
|
|
6821
|
+
},
|
|
6822
|
+
{
|
|
6823
|
+
type: "tuple",
|
|
6824
|
+
name: "baseFeeRate",
|
|
6825
|
+
components: [
|
|
6826
|
+
{
|
|
6827
|
+
type: "uint32",
|
|
6828
|
+
name: "takerFeeRate"
|
|
6829
|
+
},
|
|
6830
|
+
{
|
|
6831
|
+
type: "uint32",
|
|
6832
|
+
name: "makerFeeRate"
|
|
6833
|
+
}
|
|
6834
|
+
]
|
|
6673
6835
|
}
|
|
6674
6836
|
]
|
|
6675
6837
|
}
|
|
@@ -6697,7 +6859,15 @@ var Broker_default = [
|
|
|
6697
6859
|
inputs: [
|
|
6698
6860
|
{
|
|
6699
6861
|
type: "uint8",
|
|
6700
|
-
name: "
|
|
6862
|
+
name: "assetClass"
|
|
6863
|
+
},
|
|
6864
|
+
{
|
|
6865
|
+
type: "uint8",
|
|
6866
|
+
name: "riskTier"
|
|
6867
|
+
},
|
|
6868
|
+
{
|
|
6869
|
+
type: "uint8",
|
|
6870
|
+
name: "feeTier"
|
|
6701
6871
|
},
|
|
6702
6872
|
{
|
|
6703
6873
|
type: "tuple",
|
|
@@ -6722,9 +6892,17 @@ var Broker_default = [
|
|
|
6722
6892
|
constant: false,
|
|
6723
6893
|
payable: false,
|
|
6724
6894
|
inputs: [
|
|
6895
|
+
{
|
|
6896
|
+
type: "uint8",
|
|
6897
|
+
name: "assetClass"
|
|
6898
|
+
},
|
|
6899
|
+
{
|
|
6900
|
+
type: "uint8",
|
|
6901
|
+
name: "riskTier"
|
|
6902
|
+
},
|
|
6725
6903
|
{
|
|
6726
6904
|
type: "uint8[]",
|
|
6727
|
-
name: "
|
|
6905
|
+
name: "feeTiers"
|
|
6728
6906
|
},
|
|
6729
6907
|
{
|
|
6730
6908
|
type: "tuple[]",
|
|
@@ -9620,6 +9798,14 @@ var DataProvider_default = [
|
|
|
9620
9798
|
type: "address",
|
|
9621
9799
|
name: "brokerAddress"
|
|
9622
9800
|
},
|
|
9801
|
+
{
|
|
9802
|
+
type: "uint8[]",
|
|
9803
|
+
name: "assetClasses"
|
|
9804
|
+
},
|
|
9805
|
+
{
|
|
9806
|
+
type: "uint8[][]",
|
|
9807
|
+
name: "assetRiskTiers"
|
|
9808
|
+
},
|
|
9623
9809
|
{
|
|
9624
9810
|
type: "bool",
|
|
9625
9811
|
name: "isMYXBroker"
|
|
@@ -9627,60 +9813,74 @@ var DataProvider_default = [
|
|
|
9627
9813
|
],
|
|
9628
9814
|
outputs: [
|
|
9629
9815
|
{
|
|
9630
|
-
type: "tuple",
|
|
9631
|
-
name: "
|
|
9816
|
+
type: "tuple[]",
|
|
9817
|
+
name: "brokerFees",
|
|
9632
9818
|
components: [
|
|
9633
9819
|
{
|
|
9634
|
-
type: "
|
|
9635
|
-
name: "
|
|
9636
|
-
components: [
|
|
9637
|
-
{
|
|
9638
|
-
type: "uint8",
|
|
9639
|
-
name: "tier"
|
|
9640
|
-
},
|
|
9641
|
-
{
|
|
9642
|
-
type: "uint32",
|
|
9643
|
-
name: "takerFeeRate"
|
|
9644
|
-
},
|
|
9645
|
-
{
|
|
9646
|
-
type: "int32",
|
|
9647
|
-
name: "makerFeeRate"
|
|
9648
|
-
}
|
|
9649
|
-
]
|
|
9820
|
+
type: "uint8",
|
|
9821
|
+
name: "asset"
|
|
9650
9822
|
},
|
|
9651
9823
|
{
|
|
9652
9824
|
type: "tuple[]",
|
|
9653
|
-
name: "
|
|
9825
|
+
name: "riskTieredBrokerFees",
|
|
9654
9826
|
components: [
|
|
9655
9827
|
{
|
|
9656
9828
|
type: "uint8",
|
|
9657
|
-
name: "
|
|
9829
|
+
name: "riskTier"
|
|
9658
9830
|
},
|
|
9659
9831
|
{
|
|
9660
|
-
type: "
|
|
9661
|
-
name: "
|
|
9832
|
+
type: "tuple[]",
|
|
9833
|
+
name: "addOnFeeTiers",
|
|
9834
|
+
components: [
|
|
9835
|
+
{
|
|
9836
|
+
type: "uint8",
|
|
9837
|
+
name: "tier"
|
|
9838
|
+
},
|
|
9839
|
+
{
|
|
9840
|
+
type: "uint32",
|
|
9841
|
+
name: "takerFeeRate"
|
|
9842
|
+
},
|
|
9843
|
+
{
|
|
9844
|
+
type: "int32",
|
|
9845
|
+
name: "makerFeeRate"
|
|
9846
|
+
}
|
|
9847
|
+
]
|
|
9662
9848
|
},
|
|
9663
9849
|
{
|
|
9664
|
-
type: "
|
|
9665
|
-
name: "
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9850
|
+
type: "tuple[]",
|
|
9851
|
+
name: "baseFeeRate",
|
|
9852
|
+
components: [
|
|
9853
|
+
{
|
|
9854
|
+
type: "uint8",
|
|
9855
|
+
name: "assetClass"
|
|
9856
|
+
},
|
|
9857
|
+
{
|
|
9858
|
+
type: "uint32",
|
|
9859
|
+
name: "makerFeeRate"
|
|
9860
|
+
},
|
|
9861
|
+
{
|
|
9862
|
+
type: "uint32",
|
|
9863
|
+
name: "takerFeeRate"
|
|
9864
|
+
}
|
|
9865
|
+
]
|
|
9676
9866
|
},
|
|
9677
9867
|
{
|
|
9678
|
-
type: "
|
|
9679
|
-
name: "
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9868
|
+
type: "tuple[]",
|
|
9869
|
+
name: "specialFeeTiers",
|
|
9870
|
+
components: [
|
|
9871
|
+
{
|
|
9872
|
+
type: "uint8",
|
|
9873
|
+
name: "tier"
|
|
9874
|
+
},
|
|
9875
|
+
{
|
|
9876
|
+
type: "uint32",
|
|
9877
|
+
name: "takerFeeRate"
|
|
9878
|
+
},
|
|
9879
|
+
{
|
|
9880
|
+
type: "int32",
|
|
9881
|
+
name: "makerFeeRate"
|
|
9882
|
+
}
|
|
9883
|
+
]
|
|
9684
9884
|
}
|
|
9685
9885
|
]
|
|
9686
9886
|
}
|
|
@@ -11874,9 +12074,9 @@ var getPricesData = async (chainId, poolIds) => {
|
|
|
11874
12074
|
const result = await parsePriceData(chainId, rs.data);
|
|
11875
12075
|
return result;
|
|
11876
12076
|
};
|
|
11877
|
-
var getPriceData = async (chainId, poolId) => {
|
|
12077
|
+
var getPriceData = async (chainId, poolId, isProd) => {
|
|
11878
12078
|
if (!poolId) return;
|
|
11879
|
-
const rs = await getOraclePrice(chainId, [poolId]);
|
|
12079
|
+
const rs = await getOraclePrice(chainId, [poolId], isProd);
|
|
11880
12080
|
const data = rs?.data?.[0];
|
|
11881
12081
|
if (!data) {
|
|
11882
12082
|
throw new Error(`Unable to get price for ${poolId} in the deposit`);
|
|
@@ -12133,7 +12333,7 @@ var deposit = async (params) => {
|
|
|
12133
12333
|
let value = 0n;
|
|
12134
12334
|
let amountOut;
|
|
12135
12335
|
if (isNeedPrice) {
|
|
12136
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12336
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12137
12337
|
if (!priceData) return;
|
|
12138
12338
|
const referencePrice = parseUnits7(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12139
12339
|
price.push({
|
|
@@ -12203,7 +12403,7 @@ var withdraw = async (params) => {
|
|
|
12203
12403
|
let value = 0n;
|
|
12204
12404
|
let amountOut;
|
|
12205
12405
|
if (isNeedPrice) {
|
|
12206
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12406
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12207
12407
|
if (!priceData) return;
|
|
12208
12408
|
const referencePrice = parseUnits8(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12209
12409
|
price.push({
|
|
@@ -12275,7 +12475,7 @@ var getLpPrice = async (chainId, poolId) => {
|
|
|
12275
12475
|
try {
|
|
12276
12476
|
const contract = await getBasePoolContract(chainId);
|
|
12277
12477
|
let price = 0n;
|
|
12278
|
-
const res = await getPriceData(chainId, poolId);
|
|
12478
|
+
const res = await getPriceData(chainId, poolId, true);
|
|
12279
12479
|
if (res?.price) {
|
|
12280
12480
|
price = parseUnits10(res.price, COMMON_PRICE_DECIMALS);
|
|
12281
12481
|
}
|
|
@@ -12367,7 +12567,7 @@ var deposit2 = async (params) => {
|
|
|
12367
12567
|
let value = 0n;
|
|
12368
12568
|
let amountOut;
|
|
12369
12569
|
if (isNeedPrice) {
|
|
12370
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12570
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12371
12571
|
if (!priceData) return;
|
|
12372
12572
|
const referencePrice = parseUnits11(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12373
12573
|
price.push({
|
|
@@ -12437,7 +12637,7 @@ var withdraw2 = async (params) => {
|
|
|
12437
12637
|
let value = 0n;
|
|
12438
12638
|
let amountOut;
|
|
12439
12639
|
if (isNeedPrice) {
|
|
12440
|
-
const priceData = await getPriceData(chainId, poolId);
|
|
12640
|
+
const priceData = await getPriceData(chainId, poolId, true);
|
|
12441
12641
|
if (!priceData) return;
|
|
12442
12642
|
const referencePrice = parseUnits12(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12443
12643
|
price.push({
|
|
@@ -12639,7 +12839,7 @@ var getLpPrice2 = async (chainId, poolId) => {
|
|
|
12639
12839
|
try {
|
|
12640
12840
|
const contract = await getQuotePoolContract(chainId);
|
|
12641
12841
|
let price = 0n;
|
|
12642
|
-
const res = await getPriceData(chainId, poolId);
|
|
12842
|
+
const res = await getPriceData(chainId, poolId, true);
|
|
12643
12843
|
if (res?.price) {
|
|
12644
12844
|
price = parseUnits16(res.price, COMMON_PRICE_DECIMALS);
|
|
12645
12845
|
}
|
|
@@ -13944,19 +14144,31 @@ var Markets = class {
|
|
|
13944
14144
|
interval,
|
|
13945
14145
|
...params
|
|
13946
14146
|
}) {
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
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;
|
|
13951
14157
|
}
|
|
13952
14158
|
async getKlineLatestBar({
|
|
13953
14159
|
interval,
|
|
13954
14160
|
...params
|
|
13955
14161
|
}) {
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
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;
|
|
13960
14172
|
}
|
|
13961
14173
|
/**
|
|
13962
14174
|
* kline end
|
|
@@ -13965,7 +14177,10 @@ var Markets = class {
|
|
|
13965
14177
|
* ticker start
|
|
13966
14178
|
*/
|
|
13967
14179
|
async getTickerList(params) {
|
|
13968
|
-
|
|
14180
|
+
const config = this.configManager.getConfig();
|
|
14181
|
+
return (await getTickerData(params, {
|
|
14182
|
+
isProd: !config?.isTestnet
|
|
14183
|
+
})).data;
|
|
13969
14184
|
}
|
|
13970
14185
|
/**
|
|
13971
14186
|
* ticker end
|
|
@@ -13976,6 +14191,7 @@ var Markets = class {
|
|
|
13976
14191
|
*
|
|
13977
14192
|
*/
|
|
13978
14193
|
async searchMarketAuth(params, address) {
|
|
14194
|
+
const config = this.configManager.getConfig();
|
|
13979
14195
|
const accessToken = await this.configManager.getAccessToken();
|
|
13980
14196
|
if (!accessToken) {
|
|
13981
14197
|
throw new MyxSDKError(
|
|
@@ -13983,23 +14199,32 @@ var Markets = class {
|
|
|
13983
14199
|
"Invalid access token"
|
|
13984
14200
|
);
|
|
13985
14201
|
}
|
|
13986
|
-
return (await searchMarketAuth(
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
|
|
14202
|
+
return (await searchMarketAuth(
|
|
14203
|
+
{
|
|
14204
|
+
address,
|
|
14205
|
+
...params,
|
|
14206
|
+
accessToken
|
|
14207
|
+
},
|
|
14208
|
+
{
|
|
14209
|
+
isProd: !config?.isTestnet
|
|
14210
|
+
}
|
|
14211
|
+
)).data;
|
|
13991
14212
|
}
|
|
13992
14213
|
/**
|
|
13993
14214
|
* search by unauthenticated users
|
|
13994
14215
|
*/
|
|
13995
14216
|
async searchMarket(params) {
|
|
13996
|
-
|
|
14217
|
+
const config = this.configManager.getConfig();
|
|
14218
|
+
return (await searchMarket(params, {
|
|
14219
|
+
isProd: !config?.isTestnet
|
|
14220
|
+
})).data;
|
|
13997
14221
|
}
|
|
13998
14222
|
/**
|
|
13999
14223
|
* get favorites list
|
|
14000
14224
|
* (only for authenticated users)
|
|
14001
14225
|
*/
|
|
14002
14226
|
async getFavoritesList(params, address) {
|
|
14227
|
+
const config = this.configManager.getConfig();
|
|
14003
14228
|
const accessToken = await this.configManager.getAccessToken();
|
|
14004
14229
|
if (!accessToken) {
|
|
14005
14230
|
throw new MyxSDKError(
|
|
@@ -14007,16 +14232,22 @@ var Markets = class {
|
|
|
14007
14232
|
"Invalid access token"
|
|
14008
14233
|
);
|
|
14009
14234
|
}
|
|
14010
|
-
return (await getFavoritesList(
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14235
|
+
return (await getFavoritesList(
|
|
14236
|
+
{
|
|
14237
|
+
...params,
|
|
14238
|
+
address,
|
|
14239
|
+
accessToken
|
|
14240
|
+
},
|
|
14241
|
+
{
|
|
14242
|
+
isProd: !config?.isTestnet
|
|
14243
|
+
}
|
|
14244
|
+
)).data;
|
|
14015
14245
|
}
|
|
14016
14246
|
/**
|
|
14017
14247
|
* favorite
|
|
14018
14248
|
*/
|
|
14019
14249
|
async addFavorite(params, address) {
|
|
14250
|
+
const config = this.configManager.getConfig();
|
|
14020
14251
|
const accessToken = await this.configManager.getAccessToken();
|
|
14021
14252
|
if (!accessToken) {
|
|
14022
14253
|
throw new MyxSDKError(
|
|
@@ -14024,13 +14255,19 @@ var Markets = class {
|
|
|
14024
14255
|
"Invalid access token"
|
|
14025
14256
|
);
|
|
14026
14257
|
}
|
|
14027
|
-
return (await addFavorite(
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14258
|
+
return (await addFavorite(
|
|
14259
|
+
{
|
|
14260
|
+
...params,
|
|
14261
|
+
address,
|
|
14262
|
+
accessToken
|
|
14263
|
+
},
|
|
14264
|
+
{
|
|
14265
|
+
isProd: !config?.isTestnet
|
|
14266
|
+
}
|
|
14267
|
+
)).data;
|
|
14032
14268
|
}
|
|
14033
14269
|
async removeFavorite(params, address) {
|
|
14270
|
+
const config = this.configManager.getConfig();
|
|
14034
14271
|
const accessToken = await this.configManager.getAccessToken();
|
|
14035
14272
|
if (!accessToken) {
|
|
14036
14273
|
throw new MyxSDKError(
|
|
@@ -14038,29 +14275,43 @@ var Markets = class {
|
|
|
14038
14275
|
"Invalid access token"
|
|
14039
14276
|
);
|
|
14040
14277
|
}
|
|
14041
|
-
return (await removeFavorite(
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14278
|
+
return (await removeFavorite(
|
|
14279
|
+
{
|
|
14280
|
+
...params,
|
|
14281
|
+
address,
|
|
14282
|
+
accessToken
|
|
14283
|
+
},
|
|
14284
|
+
{
|
|
14285
|
+
isProd: !config?.isTestnet
|
|
14286
|
+
}
|
|
14287
|
+
)).data;
|
|
14046
14288
|
}
|
|
14047
14289
|
/**
|
|
14048
14290
|
* base detail
|
|
14049
14291
|
*/
|
|
14050
14292
|
async getBaseDetail(params) {
|
|
14051
|
-
|
|
14293
|
+
const config = this.configManager.getConfig();
|
|
14294
|
+
return (await getBaseDetail(params, {
|
|
14295
|
+
isProd: !config?.isTestnet
|
|
14296
|
+
})).data;
|
|
14052
14297
|
}
|
|
14053
14298
|
/**
|
|
14054
14299
|
* get market detail
|
|
14055
14300
|
*/
|
|
14056
14301
|
async getMarketDetail(params) {
|
|
14057
|
-
|
|
14302
|
+
const config = this.configManager.getConfig();
|
|
14303
|
+
return (await getMarketDetail(params, {
|
|
14304
|
+
isProd: !config?.isTestnet
|
|
14305
|
+
})).data;
|
|
14058
14306
|
}
|
|
14059
14307
|
/**
|
|
14060
14308
|
* get pool symbol all
|
|
14061
14309
|
*/
|
|
14062
14310
|
async getPoolSymbolAll() {
|
|
14063
|
-
|
|
14311
|
+
const config = this.configManager.getConfig();
|
|
14312
|
+
return (await getPoolSymbolAll({
|
|
14313
|
+
isProd: !config?.isTestnet
|
|
14314
|
+
})).data;
|
|
14064
14315
|
}
|
|
14065
14316
|
};
|
|
14066
14317
|
|
|
@@ -14076,6 +14327,7 @@ var Position = class {
|
|
|
14076
14327
|
this.account = account;
|
|
14077
14328
|
}
|
|
14078
14329
|
async listPositions(address) {
|
|
14330
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
14079
14331
|
const accessToken = await this.configManager.getAccessToken();
|
|
14080
14332
|
if (!accessToken) {
|
|
14081
14333
|
return {
|
|
@@ -14084,7 +14336,7 @@ var Position = class {
|
|
|
14084
14336
|
};
|
|
14085
14337
|
}
|
|
14086
14338
|
try {
|
|
14087
|
-
const res = await getPositions(accessToken, address);
|
|
14339
|
+
const res = await getPositions(accessToken, address, isProd);
|
|
14088
14340
|
return {
|
|
14089
14341
|
code: 0,
|
|
14090
14342
|
data: res.data
|
|
@@ -14098,6 +14350,7 @@ var Position = class {
|
|
|
14098
14350
|
}
|
|
14099
14351
|
}
|
|
14100
14352
|
async getPositionHistory(params, address) {
|
|
14353
|
+
const config = this.configManager.getConfig();
|
|
14101
14354
|
const accessToken = await this.configManager.getAccessToken();
|
|
14102
14355
|
if (!accessToken) {
|
|
14103
14356
|
throw new MyxSDKError(
|
|
@@ -14105,7 +14358,12 @@ var Position = class {
|
|
|
14105
14358
|
"Invalid access token"
|
|
14106
14359
|
);
|
|
14107
14360
|
}
|
|
14108
|
-
const res = await getPositionHistory(
|
|
14361
|
+
const res = await getPositionHistory(
|
|
14362
|
+
{ accessToken, ...params, address },
|
|
14363
|
+
{
|
|
14364
|
+
isProd: !config?.isTestnet
|
|
14365
|
+
}
|
|
14366
|
+
);
|
|
14109
14367
|
return {
|
|
14110
14368
|
code: 0,
|
|
14111
14369
|
data: res.data
|
|
@@ -14128,7 +14386,7 @@ var Position = class {
|
|
|
14128
14386
|
quoteToken
|
|
14129
14387
|
});
|
|
14130
14388
|
try {
|
|
14131
|
-
const priceData = await this.utils.getOraclePrice(poolId);
|
|
14389
|
+
const priceData = await this.utils.getOraclePrice(poolId, chainId);
|
|
14132
14390
|
if (!priceData) {
|
|
14133
14391
|
throw new Error("Failed to get price data");
|
|
14134
14392
|
}
|
|
@@ -14151,7 +14409,11 @@ var Position = class {
|
|
|
14151
14409
|
const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
|
|
14152
14410
|
let depositAmount = BigInt(0);
|
|
14153
14411
|
const used = BigInt(adjustAmount) > 0 ? BigInt(adjustAmount) : 0n;
|
|
14154
|
-
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14412
|
+
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({
|
|
14413
|
+
poolId,
|
|
14414
|
+
chainId,
|
|
14415
|
+
address
|
|
14416
|
+
});
|
|
14155
14417
|
let diff = BigInt(0);
|
|
14156
14418
|
if (availableAccountMarginBalance < used) {
|
|
14157
14419
|
diff = used - availableAccountMarginBalance;
|
|
@@ -14173,21 +14435,24 @@ var Position = class {
|
|
|
14173
14435
|
throw new Error(approvalResult.message);
|
|
14174
14436
|
}
|
|
14175
14437
|
}
|
|
14176
|
-
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14438
|
+
const isEnoughGas = await this.utils.checkSeamlessGas(
|
|
14439
|
+
config.seamlessAccount?.masterAddress
|
|
14440
|
+
);
|
|
14177
14441
|
if (!isEnoughGas) {
|
|
14178
|
-
throw new MyxSDKError(
|
|
14442
|
+
throw new MyxSDKError(
|
|
14443
|
+
"INSUFFICIENT_BALANCE" /* InsufficientBalance */,
|
|
14444
|
+
"Insufficient relay fee"
|
|
14445
|
+
);
|
|
14179
14446
|
}
|
|
14180
14447
|
const forwarderContract = await getForwarderContract(chainId);
|
|
14181
14448
|
const brokerContract2 = await getSeamlessBrokerContract(
|
|
14182
14449
|
this.configManager.getConfig().brokerAddress,
|
|
14183
14450
|
seamlessWallet
|
|
14184
14451
|
);
|
|
14185
|
-
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14186
|
-
|
|
14187
|
-
depositData,
|
|
14188
|
-
|
|
14189
|
-
adjustAmount
|
|
14190
|
-
]);
|
|
14452
|
+
const functionHash = brokerContract2.interface.encodeFunctionData(
|
|
14453
|
+
"updatePriceAndAdjustCollateral",
|
|
14454
|
+
[[updateParams], depositData, positionId, adjustAmount]
|
|
14455
|
+
);
|
|
14191
14456
|
const nonce = await forwarderContract.nonces(seamlessWallet.address);
|
|
14192
14457
|
const forwardTxParams = {
|
|
14193
14458
|
from: seamlessWallet.address ?? "",
|
|
@@ -14198,8 +14463,15 @@ var Position = class {
|
|
|
14198
14463
|
data: functionHash,
|
|
14199
14464
|
nonce: nonce.toString()
|
|
14200
14465
|
};
|
|
14201
|
-
this.logger.info(
|
|
14202
|
-
|
|
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
|
+
);
|
|
14203
14475
|
console.log("rs-->", rs);
|
|
14204
14476
|
return {
|
|
14205
14477
|
code: 0,
|
|
@@ -15295,6 +15567,7 @@ var Order = class {
|
|
|
15295
15567
|
}
|
|
15296
15568
|
}
|
|
15297
15569
|
async getOrders(address) {
|
|
15570
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
15298
15571
|
const accessToken = await this.configManager.getAccessToken();
|
|
15299
15572
|
if (!accessToken) {
|
|
15300
15573
|
return {
|
|
@@ -15303,7 +15576,7 @@ var Order = class {
|
|
|
15303
15576
|
};
|
|
15304
15577
|
}
|
|
15305
15578
|
try {
|
|
15306
|
-
const res = await getOrders(accessToken, address);
|
|
15579
|
+
const res = await getOrders(accessToken, address, isProd);
|
|
15307
15580
|
return {
|
|
15308
15581
|
code: 0,
|
|
15309
15582
|
data: res.data
|
|
@@ -15317,6 +15590,7 @@ var Order = class {
|
|
|
15317
15590
|
}
|
|
15318
15591
|
}
|
|
15319
15592
|
async getOrderHistory(params, address) {
|
|
15593
|
+
const config = this.configManager.getConfig();
|
|
15320
15594
|
const accessToken = await this.configManager.getAccessToken();
|
|
15321
15595
|
if (!accessToken) {
|
|
15322
15596
|
throw new MyxSDKError(
|
|
@@ -15324,7 +15598,9 @@ var Order = class {
|
|
|
15324
15598
|
"Invalid access token"
|
|
15325
15599
|
);
|
|
15326
15600
|
}
|
|
15327
|
-
const res = await getHistoryOrders({ accessToken, ...params, address }
|
|
15601
|
+
const res = await getHistoryOrders({ accessToken, ...params, address }, {
|
|
15602
|
+
isProd: !config?.isTestnet
|
|
15603
|
+
});
|
|
15328
15604
|
return {
|
|
15329
15605
|
code: 0,
|
|
15330
15606
|
data: res.data
|
|
@@ -20094,7 +20370,7 @@ var Utils = class {
|
|
|
20094
20370
|
};
|
|
20095
20371
|
}
|
|
20096
20372
|
}
|
|
20097
|
-
async getUserTradingFeeRate(assetClass) {
|
|
20373
|
+
async getUserTradingFeeRate(assetClass, riskTier) {
|
|
20098
20374
|
const config = this.configManager.getConfig();
|
|
20099
20375
|
const brokerAddress = config.brokerAddress;
|
|
20100
20376
|
try {
|
|
@@ -20107,7 +20383,8 @@ var Utils = class {
|
|
|
20107
20383
|
const targetAddress = config.seamlessMode ? config.seamlessAccount?.masterAddress : config.signer?.getAddress();
|
|
20108
20384
|
const userFeeRate = await brokerContract.getUserFeeRate(
|
|
20109
20385
|
targetAddress,
|
|
20110
|
-
assetClass
|
|
20386
|
+
assetClass,
|
|
20387
|
+
riskTier
|
|
20111
20388
|
);
|
|
20112
20389
|
return {
|
|
20113
20390
|
code: 0,
|
|
@@ -20148,10 +20425,10 @@ var Utils = class {
|
|
|
20148
20425
|
return "0";
|
|
20149
20426
|
}
|
|
20150
20427
|
}
|
|
20151
|
-
async getOraclePrice(poolId) {
|
|
20428
|
+
async getOraclePrice(poolId, chainId) {
|
|
20152
20429
|
try {
|
|
20153
|
-
const
|
|
20154
|
-
const priceData = await getPriceData(
|
|
20430
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
20431
|
+
const priceData = await getPriceData(chainId, poolId, isProd);
|
|
20155
20432
|
if (!priceData) throw new Error("Failed to get price data");
|
|
20156
20433
|
return priceData;
|
|
20157
20434
|
} catch (error) {
|
|
@@ -21067,7 +21344,8 @@ var Account = class {
|
|
|
21067
21344
|
}
|
|
21068
21345
|
async getAvailableMarginBalance({ poolId, chainId, address }) {
|
|
21069
21346
|
try {
|
|
21070
|
-
const
|
|
21347
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
21348
|
+
const poolListRes = await getPoolList({ isProd });
|
|
21071
21349
|
if (poolListRes.code !== 9200) {
|
|
21072
21350
|
throw new MyxSDKError(
|
|
21073
21351
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -21097,20 +21375,15 @@ var Account = class {
|
|
|
21097
21375
|
"Failed to get account info"
|
|
21098
21376
|
);
|
|
21099
21377
|
}
|
|
21100
|
-
this.logger.info("getAvailableMarginBalance used-->", used);
|
|
21101
21378
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
21102
21379
|
const usedMargin = BigInt(used ?? "0");
|
|
21103
21380
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
21104
|
-
this.logger.info("getAvailableMarginBalance quoteProfit-->", quoteProfit.toString);
|
|
21105
21381
|
const freeAmount = BigInt(marginAccountBalance?.freeMargin ?? 0);
|
|
21106
|
-
this.logger.info("getAvailableMarginBalance freeAmount-->", freeAmount.toString());
|
|
21107
21382
|
const accountMargin = freeAmount + quoteProfit;
|
|
21108
|
-
this.logger.info("getAvailableMarginBalance accountMargin-->", accountMargin.toString());
|
|
21109
21383
|
if (accountMargin < usedMargin) {
|
|
21110
21384
|
return BigInt(0);
|
|
21111
21385
|
}
|
|
21112
21386
|
const availableAccountMarginBalance = accountMargin - usedMargin;
|
|
21113
|
-
this.logger.info("getAvailableMarginBalance availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
21114
21387
|
return availableAccountMarginBalance;
|
|
21115
21388
|
} catch (error) {
|
|
21116
21389
|
this.logger.info("getAvailableMarginBalance error-->", error);
|
|
@@ -21121,6 +21394,7 @@ var Account = class {
|
|
|
21121
21394
|
}
|
|
21122
21395
|
}
|
|
21123
21396
|
async getTradeFlow(params, address) {
|
|
21397
|
+
const config = this.configManager.getConfig();
|
|
21124
21398
|
const accessToken = await this.configManager.getAccessToken();
|
|
21125
21399
|
if (!accessToken) {
|
|
21126
21400
|
throw new MyxSDKError(
|
|
@@ -21128,7 +21402,9 @@ var Account = class {
|
|
|
21128
21402
|
"Invalid access token"
|
|
21129
21403
|
);
|
|
21130
21404
|
}
|
|
21131
|
-
const res = await getTradeFlow({ accessToken, ...params, address }
|
|
21405
|
+
const res = await getTradeFlow({ accessToken, ...params, address }, {
|
|
21406
|
+
isProd: !config?.isTestnet
|
|
21407
|
+
});
|
|
21132
21408
|
return {
|
|
21133
21409
|
code: 0,
|
|
21134
21410
|
data: res.data
|
|
@@ -21556,6 +21832,7 @@ var Seamless = class {
|
|
|
21556
21832
|
data,
|
|
21557
21833
|
nonce
|
|
21558
21834
|
}, chainId, provider) {
|
|
21835
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
21559
21836
|
const forwarderContract = await getForwarderContract(chainId);
|
|
21560
21837
|
const forwarderJsonRpcContractDomain = await forwarderContract.eip712Domain();
|
|
21561
21838
|
const domain = {
|
|
@@ -21574,7 +21851,7 @@ var Seamless = class {
|
|
|
21574
21851
|
deadline,
|
|
21575
21852
|
data
|
|
21576
21853
|
});
|
|
21577
|
-
const txRs = await forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature }, chainId);
|
|
21854
|
+
const txRs = await forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature }, chainId, isProd);
|
|
21578
21855
|
return txRs;
|
|
21579
21856
|
}
|
|
21580
21857
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
|
@@ -21587,7 +21864,7 @@ var Seamless = class {
|
|
|
21587
21864
|
if (approve2) {
|
|
21588
21865
|
const balanceRes = await this.account.getWalletQuoteTokenBalance(masterAddress);
|
|
21589
21866
|
const balance = balanceRes.data;
|
|
21590
|
-
const forwarderContract2 = await getForwarderContract(
|
|
21867
|
+
const forwarderContract2 = await getForwarderContract(chainId);
|
|
21591
21868
|
const pledgeFee = await forwarderContract2.getRelayFee();
|
|
21592
21869
|
const gasFee = BigInt(pledgeFee) * BigInt(FORWARD_PLEDGE_FEE_RADIO);
|
|
21593
21870
|
if (gasFee > 0 && gasFee > BigInt(balance)) {
|
|
@@ -21598,9 +21875,7 @@ var Seamless = class {
|
|
|
21598
21875
|
let permitParams = [];
|
|
21599
21876
|
if (approve2) {
|
|
21600
21877
|
try {
|
|
21601
|
-
console.log("getUSDPermitParams");
|
|
21602
21878
|
permitParams = await this.getUSDPermitParams(deadline, chainId);
|
|
21603
|
-
console.log("permitParams result-->", permitParams);
|
|
21604
21879
|
} catch (error) {
|
|
21605
21880
|
console.warn("Failed to get USD permit params, proceeding without permit:", error);
|
|
21606
21881
|
permitParams = [];
|
|
@@ -21869,19 +22144,19 @@ export {
|
|
|
21869
22144
|
addFavorite,
|
|
21870
22145
|
approve,
|
|
21871
22146
|
base_exports as base,
|
|
21872
|
-
baseUrl,
|
|
21873
22147
|
bigintAmountSlipperCalculator,
|
|
21874
22148
|
bigintTradingGasPriceWithRatio,
|
|
21875
22149
|
bigintTradingGasToRatioCalculator,
|
|
21876
22150
|
fetchForwarderGetApi,
|
|
21877
22151
|
formatUnits2 as formatUnits,
|
|
21878
|
-
forwardUrl,
|
|
21879
22152
|
forwarderTxApi,
|
|
21880
22153
|
getAllTickers,
|
|
21881
22154
|
getAllowanceApproved,
|
|
21882
22155
|
getBalanceOf,
|
|
21883
22156
|
getBaseDetail,
|
|
22157
|
+
getBaseUrlByEnv,
|
|
21884
22158
|
getFavoritesList,
|
|
22159
|
+
getForwardUrlByEnv,
|
|
21885
22160
|
getHistoryOrders,
|
|
21886
22161
|
getKlineData,
|
|
21887
22162
|
getKlineLatestBar,
|