rainbow-swap-sdk 1.7.0 → 1.8.0
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/enums/dex-group-id.enum.d.ts +11 -0
- package/dist/enums/dex-group-id.enum.js +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/types/best-route-params.type.d.ts +6 -0
- package/dist/types/dex-group.type.d.ts +9 -0
- package/dist/types/dex-group.type.js +65 -0
- package/dist/utils/api.utils.d.ts +1 -1
- package/dist/utils/api.utils.js +6 -2
- package/dist/utils/dex-group.utils.d.ts +2 -0
- package/dist/utils/dex-group.utils.js +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DexGroupIdEnum = void 0;
|
|
4
|
+
var DexGroupIdEnum;
|
|
5
|
+
(function (DexGroupIdEnum) {
|
|
6
|
+
DexGroupIdEnum["Ston"] = "ston";
|
|
7
|
+
DexGroupIdEnum["StonV2"] = "ston_v2";
|
|
8
|
+
DexGroupIdEnum["DeDust"] = "dedust";
|
|
9
|
+
DexGroupIdEnum["DeDustV2"] = "dedust_v2";
|
|
10
|
+
DexGroupIdEnum["Tonco"] = "tonco";
|
|
11
|
+
DexGroupIdEnum["Bidask"] = "bidask";
|
|
12
|
+
DexGroupIdEnum["Torch"] = "torch";
|
|
13
|
+
DexGroupIdEnum["MoonCx"] = "mooncx";
|
|
14
|
+
DexGroupIdEnum["Coffee"] = "coffee";
|
|
15
|
+
})(DexGroupIdEnum || (exports.DexGroupIdEnum = DexGroupIdEnum = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { DexGroupIdEnum } from './enums/dex-group-id.enum';
|
|
1
2
|
export { DexTypeEnum } from './enums/dex-type.enum';
|
|
2
3
|
export { RouteDirectionEnum } from './enums/route-direction.enum';
|
|
3
4
|
export { SwapRouteType } from './enums/swap-route-type.enum';
|
|
@@ -11,6 +12,8 @@ export type { AssetsRecord } from './types/assets-record.type';
|
|
|
11
12
|
export type { BestRouteDisplayData, RouteDisplayData, RouteStepDisplayData } from './types/best-route-display-data.type';
|
|
12
13
|
export type { BestRouteParams } from './types/best-route-params.type';
|
|
13
14
|
export type { BestRouteResponse } from './types/best-route-response.type';
|
|
15
|
+
export type { DexGroup } from './types/dex-group.type';
|
|
16
|
+
export { DEX_GROUPS } from './types/dex-group.type';
|
|
14
17
|
export { getAssetsRecord, getAssetsList, getBestRoute, getAppStatus, getSwapHistoryData } from './utils/api.utils';
|
|
15
18
|
export { toNano, fromNano } from './utils/big-int.utils';
|
|
16
19
|
export { getQueryId } from './utils/transfer-params.utils';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getQueryId = exports.fromNano = exports.toNano = exports.getSwapHistoryData = exports.getAppStatus = exports.getBestRoute = exports.getAssetsList = exports.getAssetsRecord = exports.SwapStatusEnum = exports.SwapRouteType = exports.RouteDirectionEnum = exports.DexTypeEnum = void 0;
|
|
3
|
+
exports.getQueryId = exports.fromNano = exports.toNano = exports.getSwapHistoryData = exports.getAppStatus = exports.getBestRoute = exports.getAssetsList = exports.getAssetsRecord = exports.DEX_GROUPS = exports.SwapStatusEnum = exports.SwapRouteType = exports.RouteDirectionEnum = exports.DexTypeEnum = exports.DexGroupIdEnum = void 0;
|
|
4
|
+
var dex_group_id_enum_1 = require("./enums/dex-group-id.enum");
|
|
5
|
+
Object.defineProperty(exports, "DexGroupIdEnum", { enumerable: true, get: function () { return dex_group_id_enum_1.DexGroupIdEnum; } });
|
|
4
6
|
var dex_type_enum_1 = require("./enums/dex-type.enum");
|
|
5
7
|
Object.defineProperty(exports, "DexTypeEnum", { enumerable: true, get: function () { return dex_type_enum_1.DexTypeEnum; } });
|
|
6
8
|
var route_direction_enum_1 = require("./enums/route-direction.enum");
|
|
@@ -9,6 +11,8 @@ var swap_route_type_enum_1 = require("./enums/swap-route-type.enum");
|
|
|
9
11
|
Object.defineProperty(exports, "SwapRouteType", { enumerable: true, get: function () { return swap_route_type_enum_1.SwapRouteType; } });
|
|
10
12
|
var swap_status_enum_1 = require("./enums/swap-status.enum");
|
|
11
13
|
Object.defineProperty(exports, "SwapStatusEnum", { enumerable: true, get: function () { return swap_status_enum_1.SwapStatusEnum; } });
|
|
14
|
+
var dex_group_type_1 = require("./types/dex-group.type");
|
|
15
|
+
Object.defineProperty(exports, "DEX_GROUPS", { enumerable: true, get: function () { return dex_group_type_1.DEX_GROUPS; } });
|
|
12
16
|
var api_utils_1 = require("./utils/api.utils");
|
|
13
17
|
Object.defineProperty(exports, "getAssetsRecord", { enumerable: true, get: function () { return api_utils_1.getAssetsRecord; } });
|
|
14
18
|
Object.defineProperty(exports, "getAssetsList", { enumerable: true, get: function () { return api_utils_1.getAssetsList; } });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DexGroupIdEnum } from '../enums/dex-group-id.enum';
|
|
1
2
|
export type BestRouteParams = {
|
|
2
3
|
/**
|
|
3
4
|
* The amount of the input asset that the user wants to send, specified in nano units.
|
|
@@ -50,6 +51,11 @@ export type BestRouteParams = {
|
|
|
50
51
|
* **Default:** `5`
|
|
51
52
|
*/
|
|
52
53
|
maxSlippage?: number;
|
|
54
|
+
/**
|
|
55
|
+
* (Optional) DEX groups to exclude from route calculation.
|
|
56
|
+
* Missing or empty value means all DEX groups are enabled.
|
|
57
|
+
*/
|
|
58
|
+
disabledDexGroups?: DexGroupIdEnum[];
|
|
53
59
|
/**
|
|
54
60
|
* (Optional) The referral address of a user.
|
|
55
61
|
* Refer a new user and earn a share of their trading fees.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DexGroupIdEnum } from '../enums/dex-group-id.enum';
|
|
2
|
+
import { DexTypeEnum } from '../enums/dex-type.enum';
|
|
3
|
+
export type DexGroup = {
|
|
4
|
+
id: DexGroupIdEnum;
|
|
5
|
+
name: string;
|
|
6
|
+
image: string;
|
|
7
|
+
dexTypes: readonly DexTypeEnum[];
|
|
8
|
+
};
|
|
9
|
+
export declare const DEX_GROUPS: readonly DexGroup[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEX_GROUPS = void 0;
|
|
4
|
+
const dex_group_id_enum_1 = require("../enums/dex-group-id.enum");
|
|
5
|
+
const dex_type_enum_1 = require("../enums/dex-type.enum");
|
|
6
|
+
exports.DEX_GROUPS = [
|
|
7
|
+
{
|
|
8
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.Ston,
|
|
9
|
+
name: 'StonFi',
|
|
10
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/ston-v2.png',
|
|
11
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.Ston]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.StonV2,
|
|
15
|
+
name: 'StonFi v2',
|
|
16
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/ston-v2.png',
|
|
17
|
+
dexTypes: [
|
|
18
|
+
dex_type_enum_1.DexTypeEnum.Ston_v2,
|
|
19
|
+
dex_type_enum_1.DexTypeEnum.StonStable,
|
|
20
|
+
dex_type_enum_1.DexTypeEnum.StonWeightedStable
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.DeDust,
|
|
25
|
+
name: 'DeDust',
|
|
26
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/dedust.png',
|
|
27
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.DeDust, dex_type_enum_1.DexTypeEnum.DeDustStable]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.DeDustV2,
|
|
31
|
+
name: 'DeDust v2',
|
|
32
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/dedust.png',
|
|
33
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.DeDustCpmmV2]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.Tonco,
|
|
37
|
+
name: 'Tonco',
|
|
38
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/tonco.jpg',
|
|
39
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.Tonco]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.Bidask,
|
|
43
|
+
name: 'Bidask',
|
|
44
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/bidask.png',
|
|
45
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.BidaskDamm, dex_type_enum_1.DexTypeEnum.BidaskDlmm]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.Torch,
|
|
49
|
+
name: 'Torch Finance',
|
|
50
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/torch.png',
|
|
51
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.Torch]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.MoonCx,
|
|
55
|
+
name: 'Moon.cx',
|
|
56
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/mooncx.png',
|
|
57
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.MoonCxCpmm, dex_type_enum_1.DexTypeEnum.MoonCxClmm]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: dex_group_id_enum_1.DexGroupIdEnum.Coffee,
|
|
61
|
+
name: 'Coffee',
|
|
62
|
+
image: 'https://raw.githubusercontent.com/0xblackbot/rainbow-swap/refs/heads/main/public/external-assets/coffee.png',
|
|
63
|
+
dexTypes: [dex_type_enum_1.DexTypeEnum.Coffee, dex_type_enum_1.DexTypeEnum.CoffeeCurveFiV2]
|
|
64
|
+
}
|
|
65
|
+
];
|
|
@@ -13,5 +13,5 @@ export declare const getAppStatus: () => Promise<AppStatus>;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const getAssetsRecord: () => Promise<AssetsRecord>;
|
|
15
15
|
export declare const getAssetsList: (params: AssetsListParams) => Promise<Asset[]>;
|
|
16
|
-
export declare const getBestRoute: (params: BestRouteParams, authTokens?: string) => Promise<BestRouteResponse>;
|
|
16
|
+
export declare const getBestRoute: ({ disabledDexGroups, ...params }: BestRouteParams, authTokens?: string) => Promise<BestRouteResponse>;
|
|
17
17
|
export declare const getSwapHistoryData: (params: SwapHistoryDataParams) => Promise<SwapHistoryData>;
|
package/dist/utils/api.utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSwapHistoryData = exports.getBestRoute = exports.getAssetsList = exports.getAssetsRecord = exports.getAppStatus = void 0;
|
|
4
4
|
const globals_1 = require("../globals");
|
|
5
|
+
const dex_group_utils_1 = require("./dex-group.utils");
|
|
5
6
|
const getAppStatus = () => globals_1.API.get('/app-status').then(response => response.data);
|
|
6
7
|
exports.getAppStatus = getAppStatus;
|
|
7
8
|
/**
|
|
@@ -25,13 +26,16 @@ const getAssetsList = (params) => {
|
|
|
25
26
|
}).then(response => response.data);
|
|
26
27
|
};
|
|
27
28
|
exports.getAssetsList = getAssetsList;
|
|
28
|
-
const getBestRoute = (params, authTokens) => {
|
|
29
|
+
const getBestRoute = ({ disabledDexGroups, ...params }, authTokens) => {
|
|
29
30
|
if (abortControllers.bestRoute) {
|
|
30
31
|
abortControllers.bestRoute.abort();
|
|
31
32
|
}
|
|
32
33
|
abortControllers.bestRoute = new AbortController();
|
|
33
34
|
return globals_1.API.get('/best-route', {
|
|
34
|
-
params
|
|
35
|
+
params: {
|
|
36
|
+
...params,
|
|
37
|
+
disabledDexTypes: (0, dex_group_utils_1.getDisabledDexTypesParam)(disabledDexGroups)
|
|
38
|
+
},
|
|
35
39
|
signal: abortControllers.bestRoute.signal,
|
|
36
40
|
headers: {
|
|
37
41
|
Authorization: authTokens
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDisabledDexTypesParam = void 0;
|
|
4
|
+
const dex_group_type_1 = require("../types/dex-group.type");
|
|
5
|
+
const getDisabledDexTypesParam = (disabledDexGroups) => {
|
|
6
|
+
if (!disabledDexGroups?.length) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const disabledDexGroupIds = new Set(disabledDexGroups);
|
|
10
|
+
const disabledDexTypes = new Set(dex_group_type_1.DEX_GROUPS.flatMap(dexGroup => disabledDexGroupIds.has(dexGroup.id) ? dexGroup.dexTypes : []));
|
|
11
|
+
return Array.from(disabledDexTypes);
|
|
12
|
+
};
|
|
13
|
+
exports.getDisabledDexTypesParam = getDisabledDexTypesParam;
|