@myx-trade/sdk 0.1.192 → 0.1.194
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 +197 -136
- package/dist/index.d.ts +197 -136
- package/dist/index.js +354 -466
- package/dist/index.mjs +353 -448
- 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.194",
|
|
1735
1735
|
private: false,
|
|
1736
1736
|
publishConfig: {
|
|
1737
1737
|
access: "public"
|
|
@@ -1847,28 +1847,6 @@ var http = {
|
|
|
1847
1847
|
}
|
|
1848
1848
|
};
|
|
1849
1849
|
|
|
1850
|
-
// src/api/utils.ts
|
|
1851
|
-
function encodeQueryParam(key, value) {
|
|
1852
|
-
const encodedKey = encodeURIComponent(key);
|
|
1853
|
-
return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
|
|
1854
|
-
}
|
|
1855
|
-
function addQueryParam(query, key) {
|
|
1856
|
-
return encodeQueryParam(key, query[key]);
|
|
1857
|
-
}
|
|
1858
|
-
function addArrayQueryParam(query, key) {
|
|
1859
|
-
const value = query[key];
|
|
1860
|
-
return value.map((v) => encodeQueryParam(key, v)).join("&");
|
|
1861
|
-
}
|
|
1862
|
-
function toQueryString(rawQuery) {
|
|
1863
|
-
const query = rawQuery || {};
|
|
1864
|
-
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
|
|
1865
|
-
return keys.map((key) => Array.isArray(query[key]) ? addArrayQueryParam(query, key) : addQueryParam(query, key)).join("&");
|
|
1866
|
-
}
|
|
1867
|
-
function addQueryParams(rawQuery) {
|
|
1868
|
-
const queryString = toQueryString(rawQuery);
|
|
1869
|
-
return queryString ? `?${queryString}` : "";
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
1850
|
// src/api/type.ts
|
|
1873
1851
|
var ErrorCode = /* @__PURE__ */ ((ErrorCode3) => {
|
|
1874
1852
|
ErrorCode3[ErrorCode3["SUCCESS"] = 9200] = "SUCCESS";
|
|
@@ -1891,10 +1869,10 @@ var MarketPoolState = /* @__PURE__ */ ((MarketPoolState3) => {
|
|
|
1891
1869
|
MarketPoolState3[MarketPoolState3["Bench"] = 4] = "Bench";
|
|
1892
1870
|
return MarketPoolState3;
|
|
1893
1871
|
})(MarketPoolState || {});
|
|
1894
|
-
var OracleType = /* @__PURE__ */ ((
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
return
|
|
1872
|
+
var OracleType = /* @__PURE__ */ ((OracleType6) => {
|
|
1873
|
+
OracleType6[OracleType6["Chainlink"] = 1] = "Chainlink";
|
|
1874
|
+
OracleType6[OracleType6["Pyth"] = 2] = "Pyth";
|
|
1875
|
+
return OracleType6;
|
|
1898
1876
|
})(OracleType || {});
|
|
1899
1877
|
var HttpKlineIntervalEnum = /* @__PURE__ */ ((HttpKlineIntervalEnum2) => {
|
|
1900
1878
|
HttpKlineIntervalEnum2[HttpKlineIntervalEnum2["Minute1"] = 1] = "Minute1";
|
|
@@ -1993,23 +1971,6 @@ var ExecTypeEnum = /* @__PURE__ */ ((ExecTypeEnum2) => {
|
|
|
1993
1971
|
ExecTypeEnum2[ExecTypeEnum2["MarketClose"] = 9] = "MarketClose";
|
|
1994
1972
|
return ExecTypeEnum2;
|
|
1995
1973
|
})(ExecTypeEnum || {});
|
|
1996
|
-
var getHistoryOrders = async ({
|
|
1997
|
-
accessToken,
|
|
1998
|
-
address,
|
|
1999
|
-
...params
|
|
2000
|
-
}, envParams) => {
|
|
2001
|
-
const isProd = envParams?.isProd ?? true;
|
|
2002
|
-
return http.get(
|
|
2003
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/order/closed`,
|
|
2004
|
-
params,
|
|
2005
|
-
{
|
|
2006
|
-
headers: {
|
|
2007
|
-
myx_openapi_account: address,
|
|
2008
|
-
myx_openapi_access_token: accessToken
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
);
|
|
2012
|
-
};
|
|
2013
1974
|
var CloseTypeEnum = /* @__PURE__ */ ((CloseTypeEnum2) => {
|
|
2014
1975
|
CloseTypeEnum2[CloseTypeEnum2["Open"] = 0] = "Open";
|
|
2015
1976
|
CloseTypeEnum2[CloseTypeEnum2["PartialClose"] = 1] = "PartialClose";
|
|
@@ -2023,59 +1984,14 @@ var CloseTypeEnum = /* @__PURE__ */ ((CloseTypeEnum2) => {
|
|
|
2023
1984
|
CloseTypeEnum2[CloseTypeEnum2["Increase"] = 9] = "Increase";
|
|
2024
1985
|
return CloseTypeEnum2;
|
|
2025
1986
|
})(CloseTypeEnum || {});
|
|
2026
|
-
var getPositionHistory = async ({
|
|
2027
|
-
accessToken,
|
|
2028
|
-
address,
|
|
2029
|
-
...params
|
|
2030
|
-
}, envParams) => {
|
|
2031
|
-
const isProd = envParams?.isProd ?? true;
|
|
2032
|
-
return http.get(
|
|
2033
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/position/closed`,
|
|
2034
|
-
params,
|
|
2035
|
-
{
|
|
2036
|
-
headers: {
|
|
2037
|
-
myx_openapi_account: address,
|
|
2038
|
-
myx_openapi_access_token: accessToken
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
);
|
|
2042
|
-
};
|
|
2043
1987
|
var TradeFlowAccountTypeEnum = /* @__PURE__ */ ((TradeFlowAccountTypeEnum2) => {
|
|
2044
1988
|
TradeFlowAccountTypeEnum2[TradeFlowAccountTypeEnum2["MarginAccount"] = 1] = "MarginAccount";
|
|
2045
1989
|
TradeFlowAccountTypeEnum2[TradeFlowAccountTypeEnum2["WalletAccount"] = 2] = "WalletAccount";
|
|
2046
1990
|
TradeFlowAccountTypeEnum2[TradeFlowAccountTypeEnum2["ReferralReward"] = 3] = "ReferralReward";
|
|
2047
1991
|
return TradeFlowAccountTypeEnum2;
|
|
2048
1992
|
})(TradeFlowAccountTypeEnum || {});
|
|
2049
|
-
var getTradeFlow = async ({
|
|
2050
|
-
accessToken,
|
|
2051
|
-
address,
|
|
2052
|
-
...params
|
|
2053
|
-
}, envParams) => {
|
|
2054
|
-
const isProd = envParams?.isProd ?? true;
|
|
2055
|
-
return http.get(
|
|
2056
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/trade/flow`,
|
|
2057
|
-
params,
|
|
2058
|
-
{
|
|
2059
|
-
headers: {
|
|
2060
|
-
myx_openapi_access_token: accessToken,
|
|
2061
|
-
myx_openapi_account: address
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
);
|
|
2065
|
-
};
|
|
2066
1993
|
|
|
2067
1994
|
// src/api/seamless/index.ts
|
|
2068
|
-
var forwarderTxApi = async (params, chainId, isProd = true) => {
|
|
2069
|
-
return http.post(
|
|
2070
|
-
`${getForwardUrlByEnv(isProd)}/forwarder/tx-v2`,
|
|
2071
|
-
params,
|
|
2072
|
-
{
|
|
2073
|
-
headers: {
|
|
2074
|
-
"myx-chain-id": chainId.toString()
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
);
|
|
2078
|
-
};
|
|
2079
1995
|
var ForwarderGetStatus = /* @__PURE__ */ ((ForwarderGetStatus2) => {
|
|
2080
1996
|
ForwarderGetStatus2[ForwarderGetStatus2["EXECUTING"] = 1] = "EXECUTING";
|
|
2081
1997
|
ForwarderGetStatus2[ForwarderGetStatus2["BROADCAST_FAILED"] = 2] = "BROADCAST_FAILED";
|
|
@@ -2083,40 +1999,26 @@ var ForwarderGetStatus = /* @__PURE__ */ ((ForwarderGetStatus2) => {
|
|
|
2083
1999
|
ForwarderGetStatus2[ForwarderGetStatus2["EXECUTED"] = 9] = "EXECUTED";
|
|
2084
2000
|
return ForwarderGetStatus2;
|
|
2085
2001
|
})(ForwarderGetStatus || {});
|
|
2086
|
-
var fetchForwarderGetApi = async (params, isProd = true) => {
|
|
2087
|
-
const rs = await http.get(
|
|
2088
|
-
`${getForwardUrlByEnv(isProd)}/forwarder/get${addQueryParams(params)}`
|
|
2089
|
-
);
|
|
2090
|
-
return rs;
|
|
2091
|
-
};
|
|
2092
2002
|
|
|
2093
2003
|
// src/api/pool/index.ts
|
|
2094
|
-
var getPoolList = async ({
|
|
2095
|
-
isProd = true
|
|
2096
|
-
}) => {
|
|
2004
|
+
var getPoolList = async () => {
|
|
2097
2005
|
return http.get(
|
|
2098
|
-
`${getBaseUrlByEnv(
|
|
2099
|
-
);
|
|
2100
|
-
};
|
|
2101
|
-
var getPoolSymbolAll = async ({
|
|
2102
|
-
isProd = true
|
|
2103
|
-
}) => {
|
|
2104
|
-
return http.get(
|
|
2105
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/pools`
|
|
2006
|
+
`${getBaseUrlByEnv()}/openapi/gateway/scan/market/list`
|
|
2106
2007
|
);
|
|
2107
2008
|
};
|
|
2108
2009
|
|
|
2109
2010
|
// src/api/index.ts
|
|
2110
2011
|
var getBaseUrlByEnv = (isProd) => {
|
|
2111
|
-
|
|
2012
|
+
const _isProd = !!isProd || !web3_default.getConfigManager()?.getConfig()?.isTestnet;
|
|
2013
|
+
return _isProd ? "https://api.myx.finance" : "https://api-test.myx.cash";
|
|
2112
2014
|
};
|
|
2113
2015
|
var getForwardUrlByEnv = (isProd) => {
|
|
2114
|
-
return isProd
|
|
2016
|
+
return `${getBaseUrlByEnv(isProd)}/v2/agent`;
|
|
2115
2017
|
};
|
|
2116
|
-
var getOraclePrice = async (chainId, poolIds = []
|
|
2018
|
+
var getOraclePrice = async (chainId, poolIds = []) => {
|
|
2117
2019
|
if (!!poolIds.length) {
|
|
2118
2020
|
return http.get(
|
|
2119
|
-
`${getBaseUrlByEnv(
|
|
2021
|
+
`${getBaseUrlByEnv()}/openapi/gateway/quote/price/oracles`,
|
|
2120
2022
|
{
|
|
2121
2023
|
chainId,
|
|
2122
2024
|
poolIds: poolIds.join(",")
|
|
@@ -2125,43 +2027,14 @@ var getOraclePrice = async (chainId, poolIds = [], isProd = true) => {
|
|
|
2125
2027
|
}
|
|
2126
2028
|
return Promise.reject(new Error("Invalid pool id"));
|
|
2127
2029
|
};
|
|
2128
|
-
var
|
|
2129
|
-
poolId,
|
|
2130
|
-
chainId,
|
|
2131
|
-
isProd = true
|
|
2132
|
-
}) => {
|
|
2133
|
-
return http.get(
|
|
2134
|
-
`${getBaseUrlByEnv(
|
|
2135
|
-
isProd
|
|
2136
|
-
)}/openapi/gateway/risk/market_pool/level_config${addQueryParams({
|
|
2137
|
-
poolId,
|
|
2138
|
-
chainId
|
|
2139
|
-
})}`
|
|
2140
|
-
);
|
|
2141
|
-
};
|
|
2142
|
-
var getPoolDetail = async (chainId, poolId, isProd = true) => {
|
|
2143
|
-
return await http.get(
|
|
2144
|
-
`${getBaseUrlByEnv(
|
|
2145
|
-
isProd
|
|
2146
|
-
)}/openapi/gateway/scan/market/info?chainId=${chainId}&poolId=${poolId}`
|
|
2147
|
-
);
|
|
2148
|
-
};
|
|
2149
|
-
var getPositions = async (accessToken, address, isProd = true) => {
|
|
2030
|
+
var getPoolDetail = async (chainId, poolId, isProd) => {
|
|
2150
2031
|
return await http.get(
|
|
2151
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/
|
|
2152
|
-
void 0,
|
|
2153
|
-
// params
|
|
2154
|
-
{
|
|
2155
|
-
headers: {
|
|
2156
|
-
myx_openapi_access_token: accessToken,
|
|
2157
|
-
myx_openapi_account: address
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2032
|
+
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/info?chainId=${chainId}&poolId=${poolId}`
|
|
2160
2033
|
);
|
|
2161
2034
|
};
|
|
2162
|
-
var
|
|
2035
|
+
var getPoolOpenOrders = async (accessToken, address, chainId) => {
|
|
2163
2036
|
return await http.get(
|
|
2164
|
-
`${getBaseUrlByEnv(
|
|
2037
|
+
`${getBaseUrlByEnv()}/openapi/gateway/scan/market/pool-order/open?chainId=${chainId}`,
|
|
2165
2038
|
void 0,
|
|
2166
2039
|
{
|
|
2167
2040
|
headers: {
|
|
@@ -2171,40 +2044,6 @@ var getOrders = async (accessToken, address, isProd = true) => {
|
|
|
2171
2044
|
}
|
|
2172
2045
|
);
|
|
2173
2046
|
};
|
|
2174
|
-
var getPoolOpenOrders = async (accessToken, address, chainId, isProd = true) => {
|
|
2175
|
-
return await http.get(
|
|
2176
|
-
`${getBaseUrlByEnv(
|
|
2177
|
-
isProd
|
|
2178
|
-
)}/openapi/gateway/scan/market/pool-order/open?chainId=${chainId}`,
|
|
2179
|
-
void 0,
|
|
2180
|
-
{
|
|
2181
|
-
headers: {
|
|
2182
|
-
myx_openapi_access_token: accessToken,
|
|
2183
|
-
myx_openapi_account: address
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
);
|
|
2187
|
-
};
|
|
2188
|
-
var getKlineData = ({ chainId, poolId, endTime, limit, interval }, envParams) => {
|
|
2189
|
-
const isProd = envParams?.isProd ?? true;
|
|
2190
|
-
return http.get(
|
|
2191
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candles`,
|
|
2192
|
-
{
|
|
2193
|
-
chainId,
|
|
2194
|
-
poolId,
|
|
2195
|
-
endTime,
|
|
2196
|
-
limit,
|
|
2197
|
-
interval
|
|
2198
|
-
}
|
|
2199
|
-
);
|
|
2200
|
-
};
|
|
2201
|
-
var getKlineLatestBar = async (params, envParams) => {
|
|
2202
|
-
const isProd = envParams?.isProd ?? true;
|
|
2203
|
-
return http.get(
|
|
2204
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/quote/candle/latest`,
|
|
2205
|
-
params
|
|
2206
|
-
);
|
|
2207
|
-
};
|
|
2208
2047
|
var getTickerData = async ({ chainId, poolIds }, envParams) => {
|
|
2209
2048
|
const isProd = envParams?.isProd ?? true;
|
|
2210
2049
|
return http.get(
|
|
@@ -2215,93 +2054,21 @@ var getTickerData = async ({ chainId, poolIds }, envParams) => {
|
|
|
2215
2054
|
}
|
|
2216
2055
|
);
|
|
2217
2056
|
};
|
|
2218
|
-
var
|
|
2219
|
-
const isProd = envParams?.isProd ?? true;
|
|
2220
|
-
return http.get(
|
|
2221
|
-
`${getBaseUrlByEnv(isProd)}/v2/mx-gateway/quote/candle/all_tickers`
|
|
2222
|
-
);
|
|
2223
|
-
};
|
|
2224
|
-
var searchMarketAuth = async ({ accessToken, address, ...params }, envParams) => {
|
|
2225
|
-
const isProd = envParams?.isProd ?? true;
|
|
2226
|
-
return http.get(
|
|
2227
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/ac-search`,
|
|
2228
|
-
params,
|
|
2229
|
-
{
|
|
2230
|
-
headers: {
|
|
2231
|
-
myx_openapi_access_token: accessToken,
|
|
2232
|
-
myx_openapi_account: address
|
|
2233
|
-
}
|
|
2234
|
-
}
|
|
2235
|
-
);
|
|
2236
|
-
};
|
|
2237
|
-
var searchMarket = async ({ ...params }, envParams) => {
|
|
2238
|
-
const isProd = envParams?.isProd ?? true;
|
|
2239
|
-
return http.get(
|
|
2240
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/search`,
|
|
2241
|
-
params
|
|
2242
|
-
);
|
|
2243
|
-
};
|
|
2244
|
-
var addFavorite = async ({ accessToken, address, ...params }, envParams) => {
|
|
2245
|
-
const isProd = envParams?.isProd ?? true;
|
|
2246
|
-
return http.get(
|
|
2247
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/add-favorites`,
|
|
2248
|
-
params,
|
|
2249
|
-
{
|
|
2250
|
-
headers: {
|
|
2251
|
-
myx_openapi_access_token: accessToken,
|
|
2252
|
-
myx_openapi_account: address
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
);
|
|
2256
|
-
};
|
|
2257
|
-
var removeFavorite = async ({
|
|
2258
|
-
accessToken,
|
|
2259
|
-
address,
|
|
2260
|
-
...params
|
|
2261
|
-
}, envParams) => {
|
|
2262
|
-
const isProd = envParams?.isProd ?? true;
|
|
2263
|
-
return http.get(
|
|
2264
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/cancel-favorites`,
|
|
2265
|
-
params,
|
|
2266
|
-
{
|
|
2267
|
-
headers: {
|
|
2268
|
-
myx_openapi_access_token: accessToken,
|
|
2269
|
-
myx_openapi_account: address
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
);
|
|
2273
|
-
};
|
|
2274
|
-
var getFavoritesList = async ({ accessToken, address, ...params }, envParams) => {
|
|
2275
|
-
const isProd = envParams?.isProd ?? true;
|
|
2057
|
+
var getBaseDetail = async ({ ...params }) => {
|
|
2276
2058
|
return http.get(
|
|
2277
|
-
`${getBaseUrlByEnv(
|
|
2278
|
-
params,
|
|
2279
|
-
{
|
|
2280
|
-
headers: {
|
|
2281
|
-
myx_openapi_access_token: accessToken,
|
|
2282
|
-
myx_openapi_account: address
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
);
|
|
2286
|
-
};
|
|
2287
|
-
var getBaseDetail = async ({ ...params }, envParams) => {
|
|
2288
|
-
const isProd = envParams?.isProd ?? true;
|
|
2289
|
-
return http.get(
|
|
2290
|
-
`${getBaseUrlByEnv(isProd)}/openapi/gateway/scan/market/base-details`,
|
|
2059
|
+
`${getBaseUrlByEnv()}/openapi/gateway/scan/market/base-details`,
|
|
2291
2060
|
params
|
|
2292
2061
|
);
|
|
2293
2062
|
};
|
|
2294
|
-
var getMarketDetail = async ({ ...params }
|
|
2295
|
-
const isProd = envParams?.isProd ?? true;
|
|
2063
|
+
var getMarketDetail = async ({ ...params }) => {
|
|
2296
2064
|
return http.get(
|
|
2297
|
-
`${getBaseUrlByEnv(
|
|
2065
|
+
`${getBaseUrlByEnv()}/openapi/gateway/scan/market/detail`,
|
|
2298
2066
|
params
|
|
2299
2067
|
);
|
|
2300
2068
|
};
|
|
2301
|
-
var getMarketList = async (
|
|
2302
|
-
const isProd = envParams?.isProd ?? true;
|
|
2069
|
+
var getMarketList = async () => {
|
|
2303
2070
|
return http.get(
|
|
2304
|
-
`${getBaseUrlByEnv(
|
|
2071
|
+
`${getBaseUrlByEnv()}/openapi/gateway/scan/market`
|
|
2305
2072
|
);
|
|
2306
2073
|
};
|
|
2307
2074
|
|
|
@@ -2358,9 +2125,7 @@ var MxSDK = class _MxSDK {
|
|
|
2358
2125
|
}
|
|
2359
2126
|
async getMarkets() {
|
|
2360
2127
|
try {
|
|
2361
|
-
const result = await getMarketList(
|
|
2362
|
-
isProd: !this.configManager?.getConfig()?.isTestnet
|
|
2363
|
-
});
|
|
2128
|
+
const result = await getMarketList();
|
|
2364
2129
|
this.Markets = result?.data || [];
|
|
2365
2130
|
} catch (error) {
|
|
2366
2131
|
throw error;
|
|
@@ -2373,6 +2138,7 @@ if (typeof window !== "undefined") {
|
|
|
2373
2138
|
} else if (typeof globalThis !== "undefined") {
|
|
2374
2139
|
globalThis.MxSDK = sdk;
|
|
2375
2140
|
}
|
|
2141
|
+
var web3_default = sdk;
|
|
2376
2142
|
var getWalletProvider = async (chainId) => {
|
|
2377
2143
|
try {
|
|
2378
2144
|
const walletClient = sdk.getConfigManager()?.getConfig()?.walletClient;
|
|
@@ -12076,9 +11842,9 @@ var getPricesData = async (chainId, poolIds) => {
|
|
|
12076
11842
|
const result = await parsePriceData(chainId, rs.data);
|
|
12077
11843
|
return result;
|
|
12078
11844
|
};
|
|
12079
|
-
var getPriceData = async (chainId, poolId
|
|
11845
|
+
var getPriceData = async (chainId, poolId) => {
|
|
12080
11846
|
if (!poolId) return;
|
|
12081
|
-
const rs = await getOraclePrice(chainId, [poolId]
|
|
11847
|
+
const rs = await getOraclePrice(chainId, [poolId]);
|
|
12082
11848
|
const data = rs?.data?.[0];
|
|
12083
11849
|
if (!data) {
|
|
12084
11850
|
throw new Error(`Unable to get price for ${poolId} in the deposit`);
|
|
@@ -12335,7 +12101,7 @@ var deposit = async (params) => {
|
|
|
12335
12101
|
let value = 0n;
|
|
12336
12102
|
let amountOut;
|
|
12337
12103
|
if (isNeedPrice) {
|
|
12338
|
-
const priceData = await getPriceData(chainId, poolId
|
|
12104
|
+
const priceData = await getPriceData(chainId, poolId);
|
|
12339
12105
|
if (!priceData) return;
|
|
12340
12106
|
const referencePrice = parseUnits7(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12341
12107
|
price.push({
|
|
@@ -12405,7 +12171,7 @@ var withdraw = async (params) => {
|
|
|
12405
12171
|
let value = 0n;
|
|
12406
12172
|
let amountOut;
|
|
12407
12173
|
if (isNeedPrice) {
|
|
12408
|
-
const priceData = await getPriceData(chainId, poolId
|
|
12174
|
+
const priceData = await getPriceData(chainId, poolId);
|
|
12409
12175
|
if (!priceData) return;
|
|
12410
12176
|
const referencePrice = parseUnits8(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12411
12177
|
price.push({
|
|
@@ -12477,7 +12243,7 @@ var getLpPrice = async (chainId, poolId) => {
|
|
|
12477
12243
|
try {
|
|
12478
12244
|
const contract = await getBasePoolContract(chainId);
|
|
12479
12245
|
let price = 0n;
|
|
12480
|
-
const res = await getPriceData(chainId, poolId
|
|
12246
|
+
const res = await getPriceData(chainId, poolId);
|
|
12481
12247
|
if (res?.price) {
|
|
12482
12248
|
price = parseUnits10(res.price, COMMON_PRICE_DECIMALS);
|
|
12483
12249
|
}
|
|
@@ -12569,7 +12335,7 @@ var deposit2 = async (params) => {
|
|
|
12569
12335
|
let value = 0n;
|
|
12570
12336
|
let amountOut;
|
|
12571
12337
|
if (isNeedPrice) {
|
|
12572
|
-
const priceData = await getPriceData(chainId, poolId
|
|
12338
|
+
const priceData = await getPriceData(chainId, poolId);
|
|
12573
12339
|
if (!priceData) return;
|
|
12574
12340
|
const referencePrice = parseUnits11(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12575
12341
|
price.push({
|
|
@@ -12639,7 +12405,7 @@ var withdraw2 = async (params) => {
|
|
|
12639
12405
|
let value = 0n;
|
|
12640
12406
|
let amountOut;
|
|
12641
12407
|
if (isNeedPrice) {
|
|
12642
|
-
const priceData = await getPriceData(chainId, poolId
|
|
12408
|
+
const priceData = await getPriceData(chainId, poolId);
|
|
12643
12409
|
if (!priceData) return;
|
|
12644
12410
|
const referencePrice = parseUnits12(priceData.price, COMMON_PRICE_DECIMALS);
|
|
12645
12411
|
price.push({
|
|
@@ -12841,7 +12607,7 @@ var getLpPrice2 = async (chainId, poolId) => {
|
|
|
12841
12607
|
try {
|
|
12842
12608
|
const contract = await getQuotePoolContract(chainId);
|
|
12843
12609
|
let price = 0n;
|
|
12844
|
-
const res = await getPriceData(chainId, poolId
|
|
12610
|
+
const res = await getPriceData(chainId, poolId);
|
|
12845
12611
|
if (res?.price) {
|
|
12846
12612
|
price = parseUnits16(res.price, COMMON_PRICE_DECIMALS);
|
|
12847
12613
|
}
|
|
@@ -14125,18 +13891,19 @@ var ConfigManager = class {
|
|
|
14125
13891
|
|
|
14126
13892
|
// src/manager/markets/index.ts
|
|
14127
13893
|
var Markets = class {
|
|
14128
|
-
constructor(configManager, utils) {
|
|
13894
|
+
constructor(configManager, utils, api) {
|
|
14129
13895
|
this.configManager = configManager;
|
|
14130
13896
|
this.utils = utils;
|
|
13897
|
+
this.api = api;
|
|
14131
13898
|
}
|
|
14132
13899
|
getMarkets() {
|
|
14133
13900
|
return Promise.resolve([]);
|
|
14134
13901
|
}
|
|
14135
|
-
async getPoolLevelConfig(poolId) {
|
|
13902
|
+
async getPoolLevelConfig(poolId, chainId) {
|
|
14136
13903
|
const config = this.configManager.getConfig();
|
|
14137
|
-
return (await getPoolLevelConfig({
|
|
13904
|
+
return (await this.api.getPoolLevelConfig({
|
|
14138
13905
|
poolId,
|
|
14139
|
-
chainId
|
|
13906
|
+
chainId
|
|
14140
13907
|
})).data;
|
|
14141
13908
|
}
|
|
14142
13909
|
/**
|
|
@@ -14147,13 +13914,10 @@ var Markets = class {
|
|
|
14147
13914
|
...params
|
|
14148
13915
|
}) {
|
|
14149
13916
|
const config = this.configManager.getConfig();
|
|
14150
|
-
return (await getKlineData(
|
|
13917
|
+
return (await this.api.getKlineData(
|
|
14151
13918
|
{
|
|
14152
13919
|
...params,
|
|
14153
13920
|
interval: this.utils.transferKlineResolutionToInterval(interval)
|
|
14154
|
-
},
|
|
14155
|
-
{
|
|
14156
|
-
isProd: !config?.isTestnet
|
|
14157
13921
|
}
|
|
14158
13922
|
)).data;
|
|
14159
13923
|
}
|
|
@@ -14162,13 +13926,10 @@ var Markets = class {
|
|
|
14162
13926
|
...params
|
|
14163
13927
|
}) {
|
|
14164
13928
|
const config = this.configManager.getConfig();
|
|
14165
|
-
return (await getKlineLatestBar(
|
|
13929
|
+
return (await this.api.getKlineLatestBar(
|
|
14166
13930
|
{
|
|
14167
13931
|
...params,
|
|
14168
13932
|
interval: this.utils.transferKlineResolutionToInterval(interval)
|
|
14169
|
-
},
|
|
14170
|
-
{
|
|
14171
|
-
isProd: !config?.isTestnet
|
|
14172
13933
|
}
|
|
14173
13934
|
)).data;
|
|
14174
13935
|
}
|
|
@@ -14179,10 +13940,7 @@ var Markets = class {
|
|
|
14179
13940
|
* ticker start
|
|
14180
13941
|
*/
|
|
14181
13942
|
async getTickerList(params) {
|
|
14182
|
-
|
|
14183
|
-
return (await getTickerData(params, {
|
|
14184
|
-
isProd: !config?.isTestnet
|
|
14185
|
-
})).data;
|
|
13943
|
+
return (await this.api.getTickerData(params)).data;
|
|
14186
13944
|
}
|
|
14187
13945
|
/**
|
|
14188
13946
|
* ticker end
|
|
@@ -14193,7 +13951,6 @@ var Markets = class {
|
|
|
14193
13951
|
*
|
|
14194
13952
|
*/
|
|
14195
13953
|
async searchMarketAuth(params, address) {
|
|
14196
|
-
const config = this.configManager.getConfig();
|
|
14197
13954
|
const accessToken = await this.configManager.getAccessToken();
|
|
14198
13955
|
if (!accessToken) {
|
|
14199
13956
|
throw new MyxSDKError(
|
|
@@ -14201,14 +13958,11 @@ var Markets = class {
|
|
|
14201
13958
|
"Invalid access token"
|
|
14202
13959
|
);
|
|
14203
13960
|
}
|
|
14204
|
-
return (await searchMarketAuth(
|
|
13961
|
+
return (await this.api.searchMarketAuth(
|
|
14205
13962
|
{
|
|
14206
13963
|
address,
|
|
14207
13964
|
...params,
|
|
14208
13965
|
accessToken
|
|
14209
|
-
},
|
|
14210
|
-
{
|
|
14211
|
-
isProd: !config?.isTestnet
|
|
14212
13966
|
}
|
|
14213
13967
|
)).data;
|
|
14214
13968
|
}
|
|
@@ -14216,10 +13970,7 @@ var Markets = class {
|
|
|
14216
13970
|
* search by unauthenticated users
|
|
14217
13971
|
*/
|
|
14218
13972
|
async searchMarket(params) {
|
|
14219
|
-
|
|
14220
|
-
return (await searchMarket(params, {
|
|
14221
|
-
isProd: !config?.isTestnet
|
|
14222
|
-
})).data;
|
|
13973
|
+
return (await this.api.searchMarket(params)).data;
|
|
14223
13974
|
}
|
|
14224
13975
|
/**
|
|
14225
13976
|
* get favorites list
|
|
@@ -14234,14 +13985,11 @@ var Markets = class {
|
|
|
14234
13985
|
"Invalid access token"
|
|
14235
13986
|
);
|
|
14236
13987
|
}
|
|
14237
|
-
return (await getFavoritesList(
|
|
13988
|
+
return (await this.api.getFavoritesList(
|
|
14238
13989
|
{
|
|
14239
13990
|
...params,
|
|
14240
13991
|
address,
|
|
14241
13992
|
accessToken
|
|
14242
|
-
},
|
|
14243
|
-
{
|
|
14244
|
-
isProd: !config?.isTestnet
|
|
14245
13993
|
}
|
|
14246
13994
|
)).data;
|
|
14247
13995
|
}
|
|
@@ -14257,19 +14005,15 @@ var Markets = class {
|
|
|
14257
14005
|
"Invalid access token"
|
|
14258
14006
|
);
|
|
14259
14007
|
}
|
|
14260
|
-
return (await addFavorite(
|
|
14008
|
+
return (await this.api.addFavorite(
|
|
14261
14009
|
{
|
|
14262
14010
|
...params,
|
|
14263
14011
|
address,
|
|
14264
14012
|
accessToken
|
|
14265
|
-
},
|
|
14266
|
-
{
|
|
14267
|
-
isProd: !config?.isTestnet
|
|
14268
14013
|
}
|
|
14269
14014
|
)).data;
|
|
14270
14015
|
}
|
|
14271
14016
|
async removeFavorite(params, address) {
|
|
14272
|
-
const config = this.configManager.getConfig();
|
|
14273
14017
|
const accessToken = await this.configManager.getAccessToken();
|
|
14274
14018
|
if (!accessToken) {
|
|
14275
14019
|
throw new MyxSDKError(
|
|
@@ -14277,14 +14021,11 @@ var Markets = class {
|
|
|
14277
14021
|
"Invalid access token"
|
|
14278
14022
|
);
|
|
14279
14023
|
}
|
|
14280
|
-
return (await removeFavorite(
|
|
14024
|
+
return (await this.api.removeFavorite(
|
|
14281
14025
|
{
|
|
14282
14026
|
...params,
|
|
14283
14027
|
address,
|
|
14284
14028
|
accessToken
|
|
14285
|
-
},
|
|
14286
|
-
{
|
|
14287
|
-
isProd: !config?.isTestnet
|
|
14288
14029
|
}
|
|
14289
14030
|
)).data;
|
|
14290
14031
|
}
|
|
@@ -14292,28 +14033,19 @@ var Markets = class {
|
|
|
14292
14033
|
* base detail
|
|
14293
14034
|
*/
|
|
14294
14035
|
async getBaseDetail(params) {
|
|
14295
|
-
|
|
14296
|
-
return (await getBaseDetail(params, {
|
|
14297
|
-
isProd: !config?.isTestnet
|
|
14298
|
-
})).data;
|
|
14036
|
+
return (await this.api.getBaseDetail(params)).data;
|
|
14299
14037
|
}
|
|
14300
14038
|
/**
|
|
14301
14039
|
* get market detail
|
|
14302
14040
|
*/
|
|
14303
14041
|
async getMarketDetail(params) {
|
|
14304
|
-
|
|
14305
|
-
return (await getMarketDetail(params, {
|
|
14306
|
-
isProd: !config?.isTestnet
|
|
14307
|
-
})).data;
|
|
14042
|
+
return (await this.api.getMarketDetail(params)).data;
|
|
14308
14043
|
}
|
|
14309
14044
|
/**
|
|
14310
14045
|
* get pool symbol all
|
|
14311
14046
|
*/
|
|
14312
14047
|
async getPoolSymbolAll() {
|
|
14313
|
-
|
|
14314
|
-
return (await getPoolSymbolAll({
|
|
14315
|
-
isProd: !config?.isTestnet
|
|
14316
|
-
})).data;
|
|
14048
|
+
return (await this.api.getPoolSymbolAll()).data;
|
|
14317
14049
|
}
|
|
14318
14050
|
};
|
|
14319
14051
|
|
|
@@ -14321,15 +14053,15 @@ var Markets = class {
|
|
|
14321
14053
|
import { ethers as ethers5 } from "ethers";
|
|
14322
14054
|
import dayjs from "dayjs";
|
|
14323
14055
|
var Position = class {
|
|
14324
|
-
constructor(configManager, logger, utils, seamless, account) {
|
|
14056
|
+
constructor(configManager, logger, utils, seamless, account, api) {
|
|
14325
14057
|
this.configManager = configManager;
|
|
14326
14058
|
this.logger = logger;
|
|
14327
14059
|
this.utils = utils;
|
|
14328
14060
|
this.seamless = seamless;
|
|
14329
14061
|
this.account = account;
|
|
14062
|
+
this.api = api;
|
|
14330
14063
|
}
|
|
14331
14064
|
async listPositions(address) {
|
|
14332
|
-
const isProd = !this.configManager.getConfig().isTestnet;
|
|
14333
14065
|
const accessToken = await this.configManager.getAccessToken();
|
|
14334
14066
|
if (!accessToken) {
|
|
14335
14067
|
return {
|
|
@@ -14338,7 +14070,7 @@ var Position = class {
|
|
|
14338
14070
|
};
|
|
14339
14071
|
}
|
|
14340
14072
|
try {
|
|
14341
|
-
const res = await getPositions(accessToken, address
|
|
14073
|
+
const res = await this.api.getPositions(accessToken, address);
|
|
14342
14074
|
return {
|
|
14343
14075
|
code: 0,
|
|
14344
14076
|
data: res.data
|
|
@@ -14352,7 +14084,6 @@ var Position = class {
|
|
|
14352
14084
|
}
|
|
14353
14085
|
}
|
|
14354
14086
|
async getPositionHistory(params, address) {
|
|
14355
|
-
const config = this.configManager.getConfig();
|
|
14356
14087
|
const accessToken = await this.configManager.getAccessToken();
|
|
14357
14088
|
if (!accessToken) {
|
|
14358
14089
|
throw new MyxSDKError(
|
|
@@ -14360,11 +14091,8 @@ var Position = class {
|
|
|
14360
14091
|
"Invalid access token"
|
|
14361
14092
|
);
|
|
14362
14093
|
}
|
|
14363
|
-
const res = await getPositionHistory(
|
|
14364
|
-
{ accessToken, ...params, address }
|
|
14365
|
-
{
|
|
14366
|
-
isProd: !config?.isTestnet
|
|
14367
|
-
}
|
|
14094
|
+
const res = await this.api.getPositionHistory(
|
|
14095
|
+
{ accessToken, ...params, address }
|
|
14368
14096
|
);
|
|
14369
14097
|
return {
|
|
14370
14098
|
code: 0,
|
|
@@ -14587,12 +14315,13 @@ var OrderStatus = {
|
|
|
14587
14315
|
import { ethers as ethers6 } from "ethers";
|
|
14588
14316
|
import dayjs2 from "dayjs";
|
|
14589
14317
|
var Order = class {
|
|
14590
|
-
constructor(configManager, logger, utils, seamless, account) {
|
|
14318
|
+
constructor(configManager, logger, utils, seamless, account, api) {
|
|
14591
14319
|
this.configManager = configManager;
|
|
14592
14320
|
this.logger = logger;
|
|
14593
14321
|
this.utils = utils;
|
|
14594
14322
|
this.seamless = seamless;
|
|
14595
14323
|
this.account = account;
|
|
14324
|
+
this.api = api;
|
|
14596
14325
|
}
|
|
14597
14326
|
async createIncreaseOrder(params, tradingFee) {
|
|
14598
14327
|
try {
|
|
@@ -14752,10 +14481,9 @@ var Order = class {
|
|
|
14752
14481
|
);
|
|
14753
14482
|
}
|
|
14754
14483
|
const receipt = await transaction.wait();
|
|
14755
|
-
const orderId = this.utils.getOrderIdFromTransaction(receipt);
|
|
14756
14484
|
const result = {
|
|
14757
14485
|
success: true,
|
|
14758
|
-
orderId,
|
|
14486
|
+
// orderId,
|
|
14759
14487
|
transactionHash: transaction.hash,
|
|
14760
14488
|
blockNumber: receipt?.blockNumber,
|
|
14761
14489
|
gasUsed: receipt?.gasUsed?.toString(),
|
|
@@ -14764,10 +14492,6 @@ var Order = class {
|
|
|
14764
14492
|
timestamp: Date.now(),
|
|
14765
14493
|
receipt
|
|
14766
14494
|
};
|
|
14767
|
-
if (!orderId) {
|
|
14768
|
-
this.logger.warn("Warning: OrderId not found in transaction logs");
|
|
14769
|
-
result.success = false;
|
|
14770
|
-
}
|
|
14771
14495
|
return {
|
|
14772
14496
|
code: 0,
|
|
14773
14497
|
message: "create increase order success",
|
|
@@ -14892,16 +14616,11 @@ var Order = class {
|
|
|
14892
14616
|
const transaction = await brokerContract.placeOrdersWithPosition(depositData, positionIds, dataMap, {
|
|
14893
14617
|
gasLimit: gasLimit * 120n / 100n
|
|
14894
14618
|
});
|
|
14895
|
-
this.logger.info("Transaction sent:", transaction.hash);
|
|
14896
|
-
this.logger.info("Waiting for confirmation...");
|
|
14897
14619
|
const receipt = await transaction.wait();
|
|
14898
|
-
this.logger.info("Transaction confirmed in block:", receipt?.blockNumber);
|
|
14899
|
-
this.logger.info("closeAllPositions receipt--->", receipt);
|
|
14900
|
-
const orderId = this.utils.getOrderIdFromTransaction(receipt);
|
|
14901
14620
|
return {
|
|
14902
14621
|
code: 0,
|
|
14903
14622
|
message: "close all positions success",
|
|
14904
|
-
data: orderId,
|
|
14623
|
+
// data: orderId,
|
|
14905
14624
|
transactionHash: transaction.hash,
|
|
14906
14625
|
blockNumber: receipt?.blockNumber,
|
|
14907
14626
|
gasUsed: receipt?.gasUsed?.toString(),
|
|
@@ -15046,10 +14765,9 @@ var Order = class {
|
|
|
15046
14765
|
);
|
|
15047
14766
|
}
|
|
15048
14767
|
const receipt = await transaction.wait();
|
|
15049
|
-
const orderId = this.utils.getOrderIdFromTransaction(receipt);
|
|
15050
14768
|
const result = {
|
|
15051
14769
|
success: true,
|
|
15052
|
-
orderId,
|
|
14770
|
+
// orderId,
|
|
15053
14771
|
transactionHash: transaction.hash,
|
|
15054
14772
|
blockNumber: receipt?.blockNumber,
|
|
15055
14773
|
gasUsed: receipt?.gasUsed?.toString(),
|
|
@@ -15058,10 +14776,6 @@ var Order = class {
|
|
|
15058
14776
|
timestamp: Date.now(),
|
|
15059
14777
|
receipt
|
|
15060
14778
|
};
|
|
15061
|
-
if (!orderId) {
|
|
15062
|
-
this.logger.warn("Warning: OrderId not found in transaction logs");
|
|
15063
|
-
result.success = false;
|
|
15064
|
-
}
|
|
15065
14779
|
return {
|
|
15066
14780
|
code: 0,
|
|
15067
14781
|
message: "create decrease order success",
|
|
@@ -15217,18 +14931,10 @@ var Order = class {
|
|
|
15217
14931
|
gasLimit: gasLimit * 120n / 100n
|
|
15218
14932
|
});
|
|
15219
14933
|
}
|
|
15220
|
-
this.logger.info("Transaction sent:", transaction2.hash);
|
|
15221
|
-
this.logger.info("Waiting for confirmation...");
|
|
15222
14934
|
const receipt2 = await transaction2.wait();
|
|
15223
|
-
this.logger.info(
|
|
15224
|
-
"Transaction confirmed in block:",
|
|
15225
|
-
receipt2?.blockNumber
|
|
15226
|
-
);
|
|
15227
|
-
this.logger.info("createDecreaseOrder receipt--->", receipt2);
|
|
15228
|
-
const orderId2 = this.utils.getOrderIdFromTransaction(receipt2);
|
|
15229
14935
|
const result2 = {
|
|
15230
14936
|
success: true,
|
|
15231
|
-
orderId
|
|
14937
|
+
// orderId,
|
|
15232
14938
|
transactionHash: transaction2.hash,
|
|
15233
14939
|
blockNumber: receipt2?.blockNumber,
|
|
15234
14940
|
gasUsed: receipt2?.gasUsed?.toString(),
|
|
@@ -15237,10 +14943,6 @@ var Order = class {
|
|
|
15237
14943
|
timestamp: Date.now(),
|
|
15238
14944
|
receipt: receipt2
|
|
15239
14945
|
};
|
|
15240
|
-
if (!orderId2) {
|
|
15241
|
-
this.logger.warn("Warning: OrderId not found in transaction logs");
|
|
15242
|
-
result2.success = false;
|
|
15243
|
-
}
|
|
15244
14946
|
return {
|
|
15245
14947
|
code: 0,
|
|
15246
14948
|
message: "create decrease order success",
|
|
@@ -15356,18 +15058,10 @@ var Order = class {
|
|
|
15356
15058
|
gasLimit: gasLimit * 120n / 100n
|
|
15357
15059
|
});
|
|
15358
15060
|
}
|
|
15359
|
-
this.logger.info("Transaction sent:", transaction.hash);
|
|
15360
|
-
this.logger.info("Waiting for confirmation...");
|
|
15361
15061
|
const receipt = await transaction.wait();
|
|
15362
|
-
this.logger.info(
|
|
15363
|
-
"Transaction confirmed in block:",
|
|
15364
|
-
receipt?.blockNumber
|
|
15365
|
-
);
|
|
15366
|
-
this.logger.info("createDecreaseOrder receipt--->", receipt);
|
|
15367
|
-
const orderId = this.utils.getOrderIdFromTransaction(receipt);
|
|
15368
15062
|
const result = {
|
|
15369
15063
|
success: true,
|
|
15370
|
-
orderId,
|
|
15064
|
+
// orderId,
|
|
15371
15065
|
transactionHash: transaction.hash,
|
|
15372
15066
|
blockNumber: receipt?.blockNumber,
|
|
15373
15067
|
gasUsed: receipt?.gasUsed?.toString(),
|
|
@@ -15376,10 +15070,6 @@ var Order = class {
|
|
|
15376
15070
|
timestamp: Date.now(),
|
|
15377
15071
|
receipt
|
|
15378
15072
|
};
|
|
15379
|
-
if (!orderId) {
|
|
15380
|
-
this.logger.warn("Warning: OrderId not found in transaction logs");
|
|
15381
|
-
result.success = false;
|
|
15382
|
-
}
|
|
15383
15073
|
return {
|
|
15384
15074
|
code: 0,
|
|
15385
15075
|
message: "create decrease order success",
|
|
@@ -15569,7 +15259,6 @@ var Order = class {
|
|
|
15569
15259
|
}
|
|
15570
15260
|
}
|
|
15571
15261
|
async getOrders(address) {
|
|
15572
|
-
const isProd = !this.configManager.getConfig().isTestnet;
|
|
15573
15262
|
const accessToken = await this.configManager.getAccessToken();
|
|
15574
15263
|
if (!accessToken) {
|
|
15575
15264
|
return {
|
|
@@ -15578,7 +15267,7 @@ var Order = class {
|
|
|
15578
15267
|
};
|
|
15579
15268
|
}
|
|
15580
15269
|
try {
|
|
15581
|
-
const res = await getOrders(accessToken, address
|
|
15270
|
+
const res = await this.api.getOrders(accessToken, address);
|
|
15582
15271
|
return {
|
|
15583
15272
|
code: 0,
|
|
15584
15273
|
data: res.data
|
|
@@ -15600,9 +15289,7 @@ var Order = class {
|
|
|
15600
15289
|
"Invalid access token"
|
|
15601
15290
|
);
|
|
15602
15291
|
}
|
|
15603
|
-
const res = await getHistoryOrders({ accessToken, ...params, address }
|
|
15604
|
-
isProd: !config?.isTestnet
|
|
15605
|
-
});
|
|
15292
|
+
const res = await this.api.getHistoryOrders({ accessToken, ...params, address });
|
|
15606
15293
|
return {
|
|
15607
15294
|
code: 0,
|
|
15608
15295
|
data: res.data
|
|
@@ -20258,7 +19945,6 @@ var Utils = class {
|
|
|
20258
19945
|
const eventTopic = ethers7.id(
|
|
20259
19946
|
"OrderPlaced(address,address,bytes32,uint256,uint256,uint8,uint8,uint8,uint8,uint256,uint256,uint256,uint8,bool,uint16,address,uint256,uint16)"
|
|
20260
19947
|
);
|
|
20261
|
-
this.logger.info("Looking for OrderPlaced events with topic:", eventTopic);
|
|
20262
19948
|
for (let i = 0; i < receipt.logs.length; i++) {
|
|
20263
19949
|
const log = receipt.logs[i];
|
|
20264
19950
|
this.logger.info(`Log ${i}:`, {
|
|
@@ -20267,18 +19953,15 @@ var Utils = class {
|
|
|
20267
19953
|
data: log.data
|
|
20268
19954
|
});
|
|
20269
19955
|
if (log.topics && log.topics.length > 0 && log.topics[0] === eventTopic) {
|
|
20270
|
-
this.logger.info(`Found OrderPlaced event in log ${i}`);
|
|
20271
19956
|
try {
|
|
20272
19957
|
const parsedLog = emiterInterface.parseLog({
|
|
20273
19958
|
topics: log.topics,
|
|
20274
19959
|
data: log.data
|
|
20275
19960
|
});
|
|
20276
19961
|
if (parsedLog && parsedLog.name === "OrderPlaced") {
|
|
20277
|
-
this.logger.info("Parsed OrderPlaced event:", parsedLog.args);
|
|
20278
19962
|
const orderId = parsedLog.args[4];
|
|
20279
19963
|
if (orderId !== void 0 && orderId !== null) {
|
|
20280
19964
|
const orderIdString = orderId.toString();
|
|
20281
|
-
this.logger.info(`Found orderId: ${orderIdString}`);
|
|
20282
19965
|
return orderIdString;
|
|
20283
19966
|
}
|
|
20284
19967
|
}
|
|
@@ -20288,7 +19971,6 @@ var Utils = class {
|
|
|
20288
19971
|
}
|
|
20289
19972
|
}
|
|
20290
19973
|
}
|
|
20291
|
-
this.logger.warn("OrderPlaced event not found in transaction logs");
|
|
20292
19974
|
return null;
|
|
20293
19975
|
}
|
|
20294
19976
|
async getApproveQuoteAmount(chainId, quoteAddress, spenderAddress) {
|
|
@@ -20420,7 +20102,6 @@ var Utils = class {
|
|
|
20420
20102
|
const networkFee = await orderManagerContract.getExecutionFee(
|
|
20421
20103
|
quoteAddress
|
|
20422
20104
|
);
|
|
20423
|
-
console.log("networkFee-->", networkFee.toString());
|
|
20424
20105
|
return networkFee.toString();
|
|
20425
20106
|
} catch (error) {
|
|
20426
20107
|
this.logger.error("Error getting network fee:", error);
|
|
@@ -20429,8 +20110,7 @@ var Utils = class {
|
|
|
20429
20110
|
}
|
|
20430
20111
|
async getOraclePrice(poolId, chainId) {
|
|
20431
20112
|
try {
|
|
20432
|
-
const
|
|
20433
|
-
const priceData = await getPriceData(chainId, poolId, isProd);
|
|
20113
|
+
const priceData = await getPriceData(chainId, poolId);
|
|
20434
20114
|
if (!priceData) throw new Error("Failed to get price data");
|
|
20435
20115
|
return priceData;
|
|
20436
20116
|
} catch (error) {
|
|
@@ -21316,38 +20996,10 @@ var Account = class {
|
|
|
21316
20996
|
data: balance
|
|
21317
20997
|
};
|
|
21318
20998
|
}
|
|
21319
|
-
/**
|
|
21320
|
-
* get tradable amount
|
|
21321
|
-
*/
|
|
21322
|
-
async getTradableAmount({ poolId, chainId, address }) {
|
|
21323
|
-
const contractAddress = getContractAddressByChainId(chainId);
|
|
21324
|
-
const provider = await getJSONProvider(chainId);
|
|
21325
|
-
const accountContract = new ethers8.Contract(
|
|
21326
|
-
contractAddress.Account,
|
|
21327
|
-
Account_default,
|
|
21328
|
-
provider
|
|
21329
|
-
);
|
|
21330
|
-
try {
|
|
21331
|
-
const assets = await accountContract.getTradableAmount(address, poolId);
|
|
21332
|
-
const data = {
|
|
21333
|
-
profitIsReleased: assets[0],
|
|
21334
|
-
freeAmount: assets[1],
|
|
21335
|
-
tradeableProfit: assets[2]
|
|
21336
|
-
};
|
|
21337
|
-
return {
|
|
21338
|
-
code: 0,
|
|
21339
|
-
data
|
|
21340
|
-
};
|
|
21341
|
-
} catch (error) {
|
|
21342
|
-
return {
|
|
21343
|
-
code: -1
|
|
21344
|
-
};
|
|
21345
|
-
}
|
|
21346
|
-
}
|
|
21347
20999
|
async getAvailableMarginBalance({ poolId, chainId, address }) {
|
|
21348
21000
|
try {
|
|
21349
21001
|
const isProd = !this.configManager.getConfig().isTestnet;
|
|
21350
|
-
const poolListRes = await getPoolList(
|
|
21002
|
+
const poolListRes = await this.client.api.getPoolList();
|
|
21351
21003
|
if (poolListRes.code !== 9200) {
|
|
21352
21004
|
throw new MyxSDKError(
|
|
21353
21005
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -21388,7 +21040,6 @@ var Account = class {
|
|
|
21388
21040
|
const availableAccountMarginBalance = accountMargin - usedMargin;
|
|
21389
21041
|
return availableAccountMarginBalance;
|
|
21390
21042
|
} catch (error) {
|
|
21391
|
-
this.logger.info("getAvailableMarginBalance error-->", error);
|
|
21392
21043
|
throw new MyxSDKError(
|
|
21393
21044
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
21394
21045
|
"Failed to get getAvailableMarginBalance"
|
|
@@ -21396,7 +21047,6 @@ var Account = class {
|
|
|
21396
21047
|
}
|
|
21397
21048
|
}
|
|
21398
21049
|
async getTradeFlow(params, address) {
|
|
21399
|
-
const config = this.configManager.getConfig();
|
|
21400
21050
|
const accessToken = await this.configManager.getAccessToken();
|
|
21401
21051
|
if (!accessToken) {
|
|
21402
21052
|
throw new MyxSDKError(
|
|
@@ -21404,9 +21054,7 @@ var Account = class {
|
|
|
21404
21054
|
"Invalid access token"
|
|
21405
21055
|
);
|
|
21406
21056
|
}
|
|
21407
|
-
const res = await getTradeFlow({ accessToken, ...params, address }
|
|
21408
|
-
isProd: !config?.isTestnet
|
|
21409
|
-
});
|
|
21057
|
+
const res = await this.client.api.getTradeFlow({ accessToken, ...params, address });
|
|
21410
21058
|
return {
|
|
21411
21059
|
code: 0,
|
|
21412
21060
|
data: res.data
|
|
@@ -21440,9 +21088,7 @@ var Account = class {
|
|
|
21440
21088
|
data: functionHash,
|
|
21441
21089
|
nonce: nonce.toString()
|
|
21442
21090
|
};
|
|
21443
|
-
this.logger.info("withdraw forward tx params --->", forwardTxParams);
|
|
21444
21091
|
const rs2 = await this.client.seamless.forwarderTx(forwardTxParams, chainId, seamlessWallet);
|
|
21445
|
-
console.log("rs-->", rs2);
|
|
21446
21092
|
return {
|
|
21447
21093
|
code: 0,
|
|
21448
21094
|
message: "withdraw success",
|
|
@@ -21516,7 +21162,6 @@ var Account = class {
|
|
|
21516
21162
|
};
|
|
21517
21163
|
this.logger.info("deposit forward tx params --->", forwardTxParams);
|
|
21518
21164
|
const rs2 = await this.client.seamless.forwarderTx(forwardTxParams, chainId, seamlessWallet);
|
|
21519
|
-
console.log("rs-->", rs2);
|
|
21520
21165
|
return {
|
|
21521
21166
|
code: 0,
|
|
21522
21167
|
message: "deposit success",
|
|
@@ -21575,6 +21220,282 @@ var Account = class {
|
|
|
21575
21220
|
}
|
|
21576
21221
|
};
|
|
21577
21222
|
|
|
21223
|
+
// src/api/utils.ts
|
|
21224
|
+
function encodeQueryParam(key, value) {
|
|
21225
|
+
const encodedKey = encodeURIComponent(key);
|
|
21226
|
+
return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
|
|
21227
|
+
}
|
|
21228
|
+
function addQueryParam(query, key) {
|
|
21229
|
+
return encodeQueryParam(key, query[key]);
|
|
21230
|
+
}
|
|
21231
|
+
function addArrayQueryParam(query, key) {
|
|
21232
|
+
const value = query[key];
|
|
21233
|
+
return value.map((v) => encodeQueryParam(key, v)).join("&");
|
|
21234
|
+
}
|
|
21235
|
+
function toQueryString(rawQuery) {
|
|
21236
|
+
const query = rawQuery || {};
|
|
21237
|
+
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
|
|
21238
|
+
return keys.map((key) => Array.isArray(query[key]) ? addArrayQueryParam(query, key) : addQueryParam(query, key)).join("&");
|
|
21239
|
+
}
|
|
21240
|
+
function addQueryParams(rawQuery) {
|
|
21241
|
+
const queryString = toQueryString(rawQuery);
|
|
21242
|
+
return queryString ? `?${queryString}` : "";
|
|
21243
|
+
}
|
|
21244
|
+
|
|
21245
|
+
// src/manager/api/index.ts
|
|
21246
|
+
var Api = class {
|
|
21247
|
+
constructor(configManager, logger) {
|
|
21248
|
+
this.configManager = configManager;
|
|
21249
|
+
this.logger = logger;
|
|
21250
|
+
}
|
|
21251
|
+
getHost() {
|
|
21252
|
+
const isProd = !this.configManager.getConfig().isTestnet;
|
|
21253
|
+
return isProd ? "https://api.myx.finance" : "https://api-test.myx.cash";
|
|
21254
|
+
}
|
|
21255
|
+
async getTradeFlow({
|
|
21256
|
+
accessToken,
|
|
21257
|
+
address,
|
|
21258
|
+
...params
|
|
21259
|
+
}) {
|
|
21260
|
+
return http.get(
|
|
21261
|
+
`${this.getHost()}/openapi/gateway/scan/trade/flow`,
|
|
21262
|
+
params,
|
|
21263
|
+
{
|
|
21264
|
+
headers: {
|
|
21265
|
+
myx_openapi_access_token: accessToken,
|
|
21266
|
+
myx_openapi_account: address
|
|
21267
|
+
}
|
|
21268
|
+
}
|
|
21269
|
+
);
|
|
21270
|
+
}
|
|
21271
|
+
async getPoolSymbolAll() {
|
|
21272
|
+
return http.get(
|
|
21273
|
+
`${this.getHost()}/openapi/gateway/scan/pools`
|
|
21274
|
+
);
|
|
21275
|
+
}
|
|
21276
|
+
async fetchForwarderGetApi(params) {
|
|
21277
|
+
const rs = await http.get(
|
|
21278
|
+
`${this.getHost()}/v2/agent/forwarder/get${addQueryParams(params)}`
|
|
21279
|
+
);
|
|
21280
|
+
return rs;
|
|
21281
|
+
}
|
|
21282
|
+
async getPoolList() {
|
|
21283
|
+
return http.get(
|
|
21284
|
+
`${this.getHost()}/openapi/gateway/scan/market/list`
|
|
21285
|
+
);
|
|
21286
|
+
}
|
|
21287
|
+
async forwarderTxApi(params, chainId) {
|
|
21288
|
+
return http.post(
|
|
21289
|
+
`${this.getHost()}/v2/agent/forwarder/tx-v2`,
|
|
21290
|
+
params,
|
|
21291
|
+
{
|
|
21292
|
+
headers: {
|
|
21293
|
+
"myx-chain-id": chainId.toString()
|
|
21294
|
+
}
|
|
21295
|
+
}
|
|
21296
|
+
);
|
|
21297
|
+
}
|
|
21298
|
+
async getOraclePrice(chainId, poolIds = []) {
|
|
21299
|
+
if (!!poolIds.length) {
|
|
21300
|
+
return http.get(
|
|
21301
|
+
`${this.getHost()}/openapi/gateway/quote/price/oracles`,
|
|
21302
|
+
{
|
|
21303
|
+
chainId,
|
|
21304
|
+
poolIds: poolIds.join(",")
|
|
21305
|
+
}
|
|
21306
|
+
);
|
|
21307
|
+
}
|
|
21308
|
+
throw new Error("Invalid pool id");
|
|
21309
|
+
}
|
|
21310
|
+
async getPoolDetail(chainId, poolId) {
|
|
21311
|
+
return await http.get(
|
|
21312
|
+
`${this.getHost()}/openapi/gateway/scan/market/info?chainId=${chainId}&poolId=${poolId}`
|
|
21313
|
+
);
|
|
21314
|
+
}
|
|
21315
|
+
async getPoolLevelConfig({
|
|
21316
|
+
poolId,
|
|
21317
|
+
chainId
|
|
21318
|
+
}) {
|
|
21319
|
+
return http.get(
|
|
21320
|
+
`${this.getHost()}/openapi/gateway/risk/market_pool/level_config${addQueryParams({
|
|
21321
|
+
poolId,
|
|
21322
|
+
chainId
|
|
21323
|
+
})}`
|
|
21324
|
+
);
|
|
21325
|
+
}
|
|
21326
|
+
async getPositions(accessToken, address) {
|
|
21327
|
+
return await http.get(
|
|
21328
|
+
`${this.getHost()}/openapi/gateway/scan/position/open`,
|
|
21329
|
+
void 0,
|
|
21330
|
+
{
|
|
21331
|
+
headers: {
|
|
21332
|
+
myx_openapi_access_token: accessToken,
|
|
21333
|
+
myx_openapi_account: address
|
|
21334
|
+
}
|
|
21335
|
+
}
|
|
21336
|
+
);
|
|
21337
|
+
}
|
|
21338
|
+
async getOrders(accessToken, address) {
|
|
21339
|
+
return await http.get(
|
|
21340
|
+
`${this.getHost()}/openapi/gateway/scan/order/open`,
|
|
21341
|
+
void 0,
|
|
21342
|
+
{
|
|
21343
|
+
headers: {
|
|
21344
|
+
myx_openapi_access_token: accessToken,
|
|
21345
|
+
myx_openapi_account: address
|
|
21346
|
+
}
|
|
21347
|
+
}
|
|
21348
|
+
);
|
|
21349
|
+
}
|
|
21350
|
+
async getPoolOpenOrders(accessToken, address, chainId) {
|
|
21351
|
+
return await http.get(
|
|
21352
|
+
`${this.getHost()}/openapi/gateway/scan/market/pool-order/open?chainId=${chainId}`,
|
|
21353
|
+
void 0,
|
|
21354
|
+
{
|
|
21355
|
+
headers: {
|
|
21356
|
+
myx_openapi_access_token: accessToken,
|
|
21357
|
+
myx_openapi_account: address
|
|
21358
|
+
}
|
|
21359
|
+
}
|
|
21360
|
+
);
|
|
21361
|
+
}
|
|
21362
|
+
async getKlineData({ chainId, poolId, endTime, limit, interval }) {
|
|
21363
|
+
return http.get(
|
|
21364
|
+
`${this.getHost()}/openapi/gateway/quote/candles`,
|
|
21365
|
+
{
|
|
21366
|
+
chainId,
|
|
21367
|
+
poolId,
|
|
21368
|
+
endTime,
|
|
21369
|
+
limit,
|
|
21370
|
+
interval
|
|
21371
|
+
}
|
|
21372
|
+
);
|
|
21373
|
+
}
|
|
21374
|
+
async getKlineLatestBar(params) {
|
|
21375
|
+
return http.get(
|
|
21376
|
+
`${this.getHost()}/openapi/gateway/quote/candle/latest`,
|
|
21377
|
+
params
|
|
21378
|
+
);
|
|
21379
|
+
}
|
|
21380
|
+
async getTickerData({ chainId, poolIds }) {
|
|
21381
|
+
return http.get(
|
|
21382
|
+
`${this.getHost()}/openapi/gateway/quote/candle/tickers`,
|
|
21383
|
+
{
|
|
21384
|
+
chainId,
|
|
21385
|
+
poolIds: poolIds.join(",")
|
|
21386
|
+
}
|
|
21387
|
+
);
|
|
21388
|
+
}
|
|
21389
|
+
async getAllTickers() {
|
|
21390
|
+
return http.get(
|
|
21391
|
+
`${this.getHost()}/v2/mx-gateway/quote/candle/all_tickers`
|
|
21392
|
+
);
|
|
21393
|
+
}
|
|
21394
|
+
async searchMarketAuth({ accessToken, address, ...params }) {
|
|
21395
|
+
return http.get(
|
|
21396
|
+
`${this.getHost()}/openapi/gateway/scan/market/ac-search`,
|
|
21397
|
+
params,
|
|
21398
|
+
{
|
|
21399
|
+
headers: {
|
|
21400
|
+
myx_openapi_access_token: accessToken,
|
|
21401
|
+
myx_openapi_account: address
|
|
21402
|
+
}
|
|
21403
|
+
}
|
|
21404
|
+
);
|
|
21405
|
+
}
|
|
21406
|
+
async searchMarket({ ...params }) {
|
|
21407
|
+
return http.get(
|
|
21408
|
+
`${this.getHost()}/openapi/gateway/scan/market/search`,
|
|
21409
|
+
params
|
|
21410
|
+
);
|
|
21411
|
+
}
|
|
21412
|
+
async addFavorite({ accessToken, address, ...params }) {
|
|
21413
|
+
return http.get(
|
|
21414
|
+
`${this.getHost()}/openapi/gateway/scan/market/add-favorites`,
|
|
21415
|
+
params,
|
|
21416
|
+
{
|
|
21417
|
+
headers: {
|
|
21418
|
+
myx_openapi_access_token: accessToken,
|
|
21419
|
+
myx_openapi_account: address
|
|
21420
|
+
}
|
|
21421
|
+
}
|
|
21422
|
+
);
|
|
21423
|
+
}
|
|
21424
|
+
async removeFavorite({ accessToken, address, ...params }) {
|
|
21425
|
+
return http.get(
|
|
21426
|
+
`${this.getHost()}/openapi/gateway/scan/market/cancel-favorites`,
|
|
21427
|
+
params,
|
|
21428
|
+
{
|
|
21429
|
+
headers: {
|
|
21430
|
+
myx_openapi_access_token: accessToken,
|
|
21431
|
+
myx_openapi_account: address
|
|
21432
|
+
}
|
|
21433
|
+
}
|
|
21434
|
+
);
|
|
21435
|
+
}
|
|
21436
|
+
async getFavoritesList({ accessToken, address, ...params }) {
|
|
21437
|
+
return http.get(
|
|
21438
|
+
`${this.getHost()}/openapi/gateway/scan/market/favorites`,
|
|
21439
|
+
params,
|
|
21440
|
+
{
|
|
21441
|
+
headers: {
|
|
21442
|
+
myx_openapi_access_token: accessToken,
|
|
21443
|
+
myx_openapi_account: address
|
|
21444
|
+
}
|
|
21445
|
+
}
|
|
21446
|
+
);
|
|
21447
|
+
}
|
|
21448
|
+
async getBaseDetail({ ...params }) {
|
|
21449
|
+
return http.get(
|
|
21450
|
+
`${this.getHost()}/openapi/gateway/scan/market/base-details`,
|
|
21451
|
+
params
|
|
21452
|
+
);
|
|
21453
|
+
}
|
|
21454
|
+
async getMarketDetail({ ...params }) {
|
|
21455
|
+
return http.get(
|
|
21456
|
+
`${this.getHost()}/openapi/gateway/scan/market/detail`,
|
|
21457
|
+
params
|
|
21458
|
+
);
|
|
21459
|
+
}
|
|
21460
|
+
async getHistoryOrders({
|
|
21461
|
+
accessToken,
|
|
21462
|
+
address,
|
|
21463
|
+
...params
|
|
21464
|
+
}) {
|
|
21465
|
+
return http.get(
|
|
21466
|
+
`${this.getHost()}/openapi/gateway/scan/order/closed`,
|
|
21467
|
+
params,
|
|
21468
|
+
{
|
|
21469
|
+
headers: {
|
|
21470
|
+
myx_openapi_account: address,
|
|
21471
|
+
myx_openapi_access_token: accessToken
|
|
21472
|
+
}
|
|
21473
|
+
}
|
|
21474
|
+
);
|
|
21475
|
+
}
|
|
21476
|
+
async getPositionHistory({
|
|
21477
|
+
accessToken,
|
|
21478
|
+
address,
|
|
21479
|
+
...params
|
|
21480
|
+
}) {
|
|
21481
|
+
return http.get(
|
|
21482
|
+
`${this.getHost()}/openapi/gateway/scan/position/closed`,
|
|
21483
|
+
params,
|
|
21484
|
+
{
|
|
21485
|
+
headers: {
|
|
21486
|
+
myx_openapi_account: address,
|
|
21487
|
+
myx_openapi_access_token: accessToken
|
|
21488
|
+
}
|
|
21489
|
+
}
|
|
21490
|
+
);
|
|
21491
|
+
}
|
|
21492
|
+
async getMarketList() {
|
|
21493
|
+
return http.get(
|
|
21494
|
+
`${this.getHost()}/openapi/gateway/scan/market`
|
|
21495
|
+
);
|
|
21496
|
+
}
|
|
21497
|
+
};
|
|
21498
|
+
|
|
21578
21499
|
// src/manager/seamless/index.ts
|
|
21579
21500
|
import CryptoJS from "crypto-js";
|
|
21580
21501
|
import { toUtf8Bytes, keccak256, hexlify, ethers as ethers9, isHexString, getBytes, ZeroAddress as ZeroAddress2 } from "ethers";
|
|
@@ -21750,11 +21671,12 @@ async function signPermit(provider, contract, owner, spender, value, nonce, dead
|
|
|
21750
21671
|
return { v, r, s };
|
|
21751
21672
|
}
|
|
21752
21673
|
var Seamless = class {
|
|
21753
|
-
constructor(configManager, logger, utils, account) {
|
|
21674
|
+
constructor(configManager, logger, utils, account, api) {
|
|
21754
21675
|
this.configManager = configManager;
|
|
21755
21676
|
this.logger = logger;
|
|
21756
21677
|
this.utils = utils;
|
|
21757
21678
|
this.account = account;
|
|
21679
|
+
this.api = api;
|
|
21758
21680
|
}
|
|
21759
21681
|
async onCheckRelayer(account, relayer, chainId) {
|
|
21760
21682
|
const forwarderContract = await getForwarderContract(chainId);
|
|
@@ -21834,7 +21756,6 @@ var Seamless = class {
|
|
|
21834
21756
|
data,
|
|
21835
21757
|
nonce
|
|
21836
21758
|
}, chainId, provider) {
|
|
21837
|
-
const isProd = !this.configManager.getConfig().isTestnet;
|
|
21838
21759
|
const forwarderContract = await getForwarderContract(chainId);
|
|
21839
21760
|
const forwarderJsonRpcContractDomain = await forwarderContract.eip712Domain();
|
|
21840
21761
|
const domain = {
|
|
@@ -21853,7 +21774,7 @@ var Seamless = class {
|
|
|
21853
21774
|
deadline,
|
|
21854
21775
|
data
|
|
21855
21776
|
});
|
|
21856
|
-
const txRs = await forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature }, chainId
|
|
21777
|
+
const txRs = await this.api.forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature }, chainId);
|
|
21857
21778
|
return txRs;
|
|
21858
21779
|
}
|
|
21859
21780
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
|
@@ -21903,7 +21824,7 @@ var Seamless = class {
|
|
|
21903
21824
|
if (!txRs.data?.txHash) {
|
|
21904
21825
|
const retryOptions = { n: 10, minWait: 250, maxWait: 1e3 };
|
|
21905
21826
|
const { promise } = retry(async () => {
|
|
21906
|
-
const getRs = await fetchForwarderGetApi({
|
|
21827
|
+
const getRs = await this.api.fetchForwarderGetApi({
|
|
21907
21828
|
requestId: txRs.data?.requestId
|
|
21908
21829
|
});
|
|
21909
21830
|
if (getRs.data?.status === 9 /* EXECUTED */) {
|
|
@@ -22081,15 +22002,16 @@ var MyxClient = class {
|
|
|
22081
22002
|
this.logger = new Logger({
|
|
22082
22003
|
logLevel: options.logLevel
|
|
22083
22004
|
});
|
|
22005
|
+
const lp = MxSDK.getInstance();
|
|
22006
|
+
lp.setConfigManager(this.configManager);
|
|
22084
22007
|
this.utils = new Utils(this.configManager, this.logger);
|
|
22008
|
+
this.api = new Api(this.configManager, this.logger);
|
|
22085
22009
|
this.account = new Account(this.configManager, this.logger, this.utils, this);
|
|
22086
|
-
this.seamless = new Seamless(this.configManager, this.logger, this.utils, this.account);
|
|
22087
|
-
this.markets = new Markets(this.configManager, this.utils);
|
|
22088
|
-
this.position = new Position(this.configManager, this.logger, this.utils, this.seamless, this.account);
|
|
22089
|
-
this.order = new Order(this.configManager, this.logger, this.utils, this.seamless, this.account);
|
|
22010
|
+
this.seamless = new Seamless(this.configManager, this.logger, this.utils, this.account, this.api);
|
|
22011
|
+
this.markets = new Markets(this.configManager, this.utils, this.api);
|
|
22012
|
+
this.position = new Position(this.configManager, this.logger, this.utils, this.seamless, this.account, this.api);
|
|
22013
|
+
this.order = new Order(this.configManager, this.logger, this.utils, this.seamless, this.account, this.api);
|
|
22090
22014
|
this.subscription = new SubScription(this.configManager, this.logger);
|
|
22091
|
-
const lp = MxSDK.getInstance();
|
|
22092
|
-
lp.setConfigManager(this.configManager);
|
|
22093
22015
|
}
|
|
22094
22016
|
/**
|
|
22095
22017
|
* auth the client
|
|
@@ -22143,48 +22065,31 @@ export {
|
|
|
22143
22065
|
TradeFlowTypeEnum,
|
|
22144
22066
|
TriggerType2 as TriggerType,
|
|
22145
22067
|
TriggerTypeEnum,
|
|
22146
|
-
addFavorite,
|
|
22147
22068
|
approve,
|
|
22148
22069
|
base_exports as base,
|
|
22149
22070
|
bigintAmountSlipperCalculator,
|
|
22150
22071
|
bigintTradingGasPriceWithRatio,
|
|
22151
22072
|
bigintTradingGasToRatioCalculator,
|
|
22152
|
-
fetchForwarderGetApi,
|
|
22153
22073
|
formatUnits2 as formatUnits,
|
|
22154
|
-
forwarderTxApi,
|
|
22155
|
-
getAllTickers,
|
|
22156
22074
|
getAllowanceApproved,
|
|
22157
22075
|
getBalanceOf,
|
|
22158
22076
|
getBaseDetail,
|
|
22159
22077
|
getBaseUrlByEnv,
|
|
22160
|
-
getFavoritesList,
|
|
22161
22078
|
getForwardUrlByEnv,
|
|
22162
|
-
getHistoryOrders,
|
|
22163
|
-
getKlineData,
|
|
22164
|
-
getKlineLatestBar,
|
|
22165
22079
|
getMarketDetail,
|
|
22166
22080
|
getMarketList,
|
|
22167
22081
|
getOraclePrice,
|
|
22168
|
-
getOrders,
|
|
22169
22082
|
getPoolDetail,
|
|
22170
|
-
getPoolLevelConfig,
|
|
22171
22083
|
getPoolList,
|
|
22172
22084
|
getPoolOpenOrders,
|
|
22173
|
-
getPoolSymbolAll,
|
|
22174
|
-
getPositionHistory,
|
|
22175
|
-
getPositions,
|
|
22176
22085
|
getPriceData,
|
|
22177
22086
|
getPricesData,
|
|
22178
22087
|
getTickerData,
|
|
22179
22088
|
getTokenInfo,
|
|
22180
|
-
getTradeFlow,
|
|
22181
22089
|
market_exports as market,
|
|
22182
22090
|
parseUnits17 as parseUnits,
|
|
22183
22091
|
pool_exports as pool,
|
|
22184
|
-
quote_exports as quote
|
|
22185
|
-
removeFavorite,
|
|
22186
|
-
searchMarket,
|
|
22187
|
-
searchMarketAuth
|
|
22092
|
+
quote_exports as quote
|
|
22188
22093
|
};
|
|
22189
22094
|
/**
|
|
22190
22095
|
* MyxLogger
|