rainbow-swap-sdk 1.5.11 → 1.5.13
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/README.md +68 -3
- package/package.json +75 -70
package/README.md
CHANGED
|
@@ -11,23 +11,40 @@ This SDK is designed for building applications on top of [Rainbow.ag](https://gi
|
|
|
11
11
|
[](https://badge.fury.io/js/rainbow-swap-sdk)
|
|
12
12
|

|
|
13
13
|
|
|
14
|
+
## Docs
|
|
15
|
+
|
|
16
|
+
- SDK guide: https://rainbow-ag.gitbook.io/docs/technical/sdk
|
|
17
|
+
- Full docs: https://rainbow-ag.gitbook.io/docs
|
|
18
|
+
|
|
19
|
+
## Quick links
|
|
20
|
+
|
|
21
|
+
- Support: https://t.me/rainbow_swap_manager
|
|
22
|
+
|
|
14
23
|
## Installation
|
|
15
24
|
|
|
16
25
|
You can install the Rainbow Swap SDK using either npm or Yarn:
|
|
17
26
|
|
|
18
27
|
**Using npm:**
|
|
28
|
+
|
|
19
29
|
```shell
|
|
20
30
|
npm install rainbow-swap-sdk
|
|
21
31
|
```
|
|
22
32
|
|
|
23
33
|
**Using Yarn:**
|
|
34
|
+
|
|
24
35
|
```shell
|
|
25
36
|
yarn add rainbow-swap-sdk
|
|
26
37
|
```
|
|
27
38
|
|
|
28
|
-
##
|
|
39
|
+
## What you get
|
|
40
|
+
|
|
41
|
+
- Typed API helpers for assets, routes, and swap history.
|
|
42
|
+
- Utilities for TON amount conversion (`toNano`, `fromNano`).
|
|
43
|
+
- Enum/type exports to keep your integration strongly typed.
|
|
29
44
|
|
|
30
|
-
|
|
45
|
+
## Integrate your dApp
|
|
46
|
+
|
|
47
|
+
### Example: swapping 1.35 TON to USDT
|
|
31
48
|
|
|
32
49
|
```typescript
|
|
33
50
|
import {getAssetsList, getBestRoute, toNano} from 'rainbow-swap-sdk';
|
|
@@ -39,7 +56,10 @@ const assetsList = await getAssetsList({
|
|
|
39
56
|
|
|
40
57
|
// Retrieve specific assets by their address
|
|
41
58
|
const inputAsset = assetsList.find(asset => asset.address === 'ton');
|
|
42
|
-
const outputAsset = assetsList.find(
|
|
59
|
+
const outputAsset = assetsList.find(
|
|
60
|
+
asset =>
|
|
61
|
+
asset.address === 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'
|
|
62
|
+
);
|
|
43
63
|
|
|
44
64
|
// 2. Load the best swap route and swap messages
|
|
45
65
|
const bestRouteResponse = await getBestRoute({
|
|
@@ -62,6 +82,45 @@ const result = await tonConnectUI.sendTransaction({
|
|
|
62
82
|
});
|
|
63
83
|
```
|
|
64
84
|
|
|
85
|
+
## API overview
|
|
86
|
+
|
|
87
|
+
### Assets
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import {getAssetsList} from 'rainbow-swap-sdk';
|
|
91
|
+
|
|
92
|
+
const assets = await getAssetsList({
|
|
93
|
+
userAssets: ['ton'], // optional: user-held assets
|
|
94
|
+
searchValue: 'USDT', // optional: filter by name/symbol/address
|
|
95
|
+
limit: 100 // optional: 10..200
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Best route
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import {getBestRoute, toNano} from 'rainbow-swap-sdk';
|
|
103
|
+
|
|
104
|
+
const route = await getBestRoute({
|
|
105
|
+
inputAssetAmount: toNano('1.35', 9).toString(),
|
|
106
|
+
inputAssetAddress: 'ton',
|
|
107
|
+
outputAssetAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
|
|
108
|
+
senderAddress: 'UQDGGjjuwhikx8ZPJsrLbKXGq7mx26D8pK_l8GqBejzB52Pa',
|
|
109
|
+
maxSlippage: 1.5,
|
|
110
|
+
partnerId: 'demo-partner'
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Swap history
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import {getSwapHistoryData} from 'rainbow-swap-sdk';
|
|
118
|
+
|
|
119
|
+
const history = await getSwapHistoryData({
|
|
120
|
+
bocHash: '64c1a1c5b7c2f8...'
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
65
124
|
## Application Status Check
|
|
66
125
|
|
|
67
126
|
You may want to check the status of your application to ensure everything is functioning correctly. For example, temporarily disable swaps if block production on TON is disrupted due to an external event like the DOGS listing.
|
|
@@ -75,6 +134,12 @@ const {
|
|
|
75
134
|
} = await getAppStatus();
|
|
76
135
|
```
|
|
77
136
|
|
|
137
|
+
## Notes
|
|
138
|
+
|
|
139
|
+
- `getAssetsRecord` is deprecated; use `getAssetsList` instead.
|
|
140
|
+
- `getBestRoute` returns `swapMessages` only when `senderAddress` is provided.
|
|
141
|
+
- Requests to `getAssetsList` and `getBestRoute` cancel any previous in-flight request.
|
|
142
|
+
|
|
78
143
|
## Live Example
|
|
79
144
|
|
|
80
145
|
For a live example of using the SDK, visit the [Rainbow Swap 🌈 Repository](https://github.com/0xblackbot/rainbow-swap).
|
package/package.json
CHANGED
|
@@ -1,72 +1,77 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
2
|
+
"name": "rainbow-swap-sdk",
|
|
3
|
+
"version": "1.5.13",
|
|
4
|
+
"description": "SDK for building applications on top of Rainbow.ag - Swap Aggregator on TON 💎.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/0xblackbot/rainbow-swap-sdk.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://rainbow-ag.gitbook.io/docs/technical/sdk",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://t.me/rainbow_swap_manager"
|
|
12
|
+
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"ts": "tsc --pretty",
|
|
21
|
+
"lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
|
|
22
|
+
"build": "tsc"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@rnw-community/shared": "^0.83.0",
|
|
26
|
+
"axios": "^1.10.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.14.10",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
31
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
32
|
+
"eslint": "^8.57.0",
|
|
33
|
+
"eslint-config-prettier": "^9.1.0",
|
|
34
|
+
"eslint-plugin-import": "^2.29.1",
|
|
35
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
36
|
+
"prettier": "^3.2.5",
|
|
37
|
+
"ts-node": "^10.9.2",
|
|
38
|
+
"typescript": "^5.5.3"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"registry": "https://registry.npmjs.org/"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"rainbow-swap",
|
|
46
|
+
"rainbow-swap-sdk",
|
|
47
|
+
"DEX",
|
|
48
|
+
"decentralized-exchange",
|
|
49
|
+
"TON",
|
|
50
|
+
"TON blockchain",
|
|
51
|
+
"decentralized finance",
|
|
52
|
+
"DeFi",
|
|
53
|
+
"swap",
|
|
54
|
+
"token swap",
|
|
55
|
+
"token exchange",
|
|
56
|
+
"crypto",
|
|
57
|
+
"cryptocurrency",
|
|
58
|
+
"blockchain",
|
|
59
|
+
"smart contract",
|
|
60
|
+
"wallet integration",
|
|
61
|
+
"asset exchange",
|
|
62
|
+
"SDK",
|
|
63
|
+
"TypeScript",
|
|
64
|
+
"JavaScript",
|
|
65
|
+
"TON SDK",
|
|
66
|
+
"TON DEX",
|
|
67
|
+
"commission sharing",
|
|
68
|
+
"DApp integration",
|
|
69
|
+
"liquidity",
|
|
70
|
+
"trading",
|
|
71
|
+
"TON tokens",
|
|
72
|
+
"DeFi aggregator",
|
|
73
|
+
"decentralized application",
|
|
74
|
+
"web3",
|
|
75
|
+
"blockchain development"
|
|
76
|
+
]
|
|
72
77
|
}
|