rainbow-swap-sdk
Advanced tools
Comparing version 1.4.5 to 1.4.6
@@ -10,2 +10,3 @@ export { mapSwapRouteToRoute } from './dexes/shared/calculated-swap-route.utils'; | ||
export type { Asset } from './types/asset.type'; | ||
export type { AssetsListParams } from './types/assets-list-patams.type'; | ||
export type { AssetsRecord } from './types/assets-record.type'; | ||
@@ -15,4 +16,4 @@ export type { BestRouteParams } from './types/best-route-params.type'; | ||
export type { CalculatedSwapRoute } from './types/calculated-swap-route.type'; | ||
export { getAssetsRecord, getBestRoute, getAppStatus } from './utils/api.utils'; | ||
export { getAssetsRecord, getAssetsList, getBestRoute, getAppStatus } from './utils/api.utils'; | ||
export { toNano, fromNano } from './utils/big-int.utils'; | ||
export { getQueryId } from './utils/transfer-params.utils'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getQueryId = exports.fromNano = exports.toNano = exports.getAppStatus = exports.getBestRoute = exports.getAssetsRecord = exports.SwapRouteType = exports.RouteDirectionEnum = exports.DexTypeEnum = exports.mapSwapRouteToRoute = void 0; | ||
exports.getQueryId = exports.fromNano = exports.toNano = exports.getAppStatus = exports.getBestRoute = exports.getAssetsList = exports.getAssetsRecord = exports.SwapRouteType = exports.RouteDirectionEnum = exports.DexTypeEnum = exports.mapSwapRouteToRoute = void 0; | ||
var calculated_swap_route_utils_1 = require("./dexes/shared/calculated-swap-route.utils"); | ||
@@ -14,2 +14,3 @@ Object.defineProperty(exports, "mapSwapRouteToRoute", { enumerable: true, get: function () { return calculated_swap_route_utils_1.mapSwapRouteToRoute; } }); | ||
Object.defineProperty(exports, "getAssetsRecord", { enumerable: true, get: function () { return api_utils_1.getAssetsRecord; } }); | ||
Object.defineProperty(exports, "getAssetsList", { enumerable: true, get: function () { return api_utils_1.getAssetsList; } }); | ||
Object.defineProperty(exports, "getBestRoute", { enumerable: true, get: function () { return api_utils_1.getBestRoute; } }); | ||
@@ -16,0 +17,0 @@ Object.defineProperty(exports, "getAppStatus", { enumerable: true, get: function () { return api_utils_1.getAppStatus; } }); |
import { AppStatus } from '../types/app-status.type'; | ||
import { Asset } from '../types/asset.type'; | ||
import { AssetsListParams } from '../types/assets-list-patams.type'; | ||
import { AssetsRecord } from '../types/assets-record.type'; | ||
@@ -6,3 +8,4 @@ import { BestRouteParams } from '../types/best-route-params.type'; | ||
export declare const getAssetsRecord: () => Promise<AssetsRecord>; | ||
export declare const getAssetsList: (params: AssetsListParams) => Promise<Asset[]>; | ||
export declare const getBestRoute: (params: BestRouteParams) => Promise<BestRouteResponse>; | ||
export declare const getAppStatus: () => Promise<AppStatus>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAppStatus = exports.getBestRoute = exports.getAssetsRecord = void 0; | ||
exports.getAppStatus = exports.getBestRoute = exports.getAssetsList = exports.getAssetsRecord = void 0; | ||
const globals_1 = require("../globals"); | ||
const getAssetsRecord = () => globals_1.API.get('/assets-record').then(response => response.data); | ||
exports.getAssetsRecord = getAssetsRecord; | ||
const getAssetsList = (params) => globals_1.API.post('/assets-list', params).then(response => response.data); | ||
exports.getAssetsList = getAssetsList; | ||
const getBestRoute = (params) => globals_1.API.get('/best-route', { params }).then(response => response.data); | ||
@@ -8,0 +10,0 @@ exports.getBestRoute = getBestRoute; |
{ | ||
"name": "rainbow-swap-sdk", | ||
"version": "1.4.5", | ||
"version": "1.4.6", | ||
"description": "SDK for building applications on top of Rainbow.ag - Swap Aggregator on TON 💎.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/0xblackbot/rainbow-swap-sdk.git", |
@@ -33,9 +33,12 @@ # Rainbow Swap 🌈 SDK | ||
```typescript | ||
import {getAssetsRecord, getBestRoute, toNano} from 'rainbow-swap-sdk'; | ||
import {getAssetsList, getBestRoute, toNano} from 'rainbow-swap-sdk'; | ||
// 1. Load the list of available tokens | ||
const assetsRecord = await getAssetsRecord(); | ||
const assetsList = await getAssetsList({ | ||
userAssets: [] // Array of asset addresses the user holds; see AssetsListParams for more details. | ||
}); | ||
const inputAsset = assetsRecord['ton']; // TON asset | ||
const outputAsset = assetsRecord['EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs']; // USDT asset | ||
// Retrieve specific assets by their address | ||
const inputAsset = assetsList.find(asset => asset.address === 'ton'); | ||
const outputAsset = assetsList.find(asset => asset.address === 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'); | ||
@@ -42,0 +45,0 @@ // 2. Load the best swap route and swap messages |
38885
73
490
89