rubic-sdk 6.0.0-alpha.ton.4 → 6.0.0-alpha.ton.41
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/LICENSE +674 -674
- package/README.md +361 -361
- package/dist/rubic-sdk.min.js +6 -0
- package/lib/core/blockchain/services/ton/tonapi-service.d.ts +3 -2
- package/lib/core/blockchain/services/ton/tonapi-service.js +13 -10
- package/lib/core/blockchain/services/ton/tonapi-service.js.map +1 -1
- package/lib/core/blockchain/utils/blockchains-info/blockchains-info.d.ts +2 -1
- package/lib/core/blockchain/utils/blockchains-info/blockchains-info.js +3 -0
- package/lib/core/blockchain/utils/blockchains-info/blockchains-info.js.map +1 -1
- package/lib/core/blockchain/web3-private-service/web3-private/ton-web3-private/ton-web3-private.js +8 -9
- package/lib/core/blockchain/web3-private-service/web3-private/ton-web3-private/ton-web3-private.js.map +1 -1
- package/lib/core/blockchain/web3-public-service/web3-public/ton-web3-public/ton-web3-public.d.ts +4 -1
- package/lib/core/blockchain/web3-public-service/web3-public/ton-web3-public/ton-web3-public.js +34 -15
- package/lib/core/blockchain/web3-public-service/web3-public/ton-web3-public/ton-web3-public.js.map +1 -1
- package/lib/core/blockchain/web3-pure/typed-web3-pure/ton-web3-pure/ton-web3-pure.d.ts +11 -0
- package/lib/core/blockchain/web3-pure/typed-web3-pure/ton-web3-pure/ton-web3-pure.js +31 -3
- package/lib/core/blockchain/web3-pure/typed-web3-pure/ton-web3-pure/ton-web3-pure.js.map +1 -1
- package/lib/features/common/providers/rango/models/rango-api-trade-types.d.ts +2 -2
- package/lib/features/common/providers/symbiosis/services/symbiosis-api-service.js +5 -6
- package/lib/features/common/providers/symbiosis/services/symbiosis-api-service.js.map +1 -1
- package/lib/features/cross-chain/calculation-manager/constants/cross-chain-providers.d.ts +1 -2
- package/lib/features/cross-chain/calculation-manager/constants/cross-chain-providers.js +3 -3
- package/lib/features/cross-chain/calculation-manager/constants/cross-chain-providers.js.map +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/changenow-provider/changenow-cross-chain-trade.d.ts +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/changenow-provider/changenow-cross-chain-trade.js +13 -4
- package/lib/features/cross-chain/calculation-manager/providers/changenow-provider/changenow-cross-chain-trade.js.map +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/eddy-bridge/utils/get-eddy-bridge-dst-status.js +2 -2
- package/lib/features/cross-chain/calculation-manager/providers/orbiter-bridge/models/orbiter-api-status-types.d.ts +7 -0
- package/lib/features/cross-chain/calculation-manager/providers/orbiter-bridge/orbiter-bridge-provider.js +6 -2
- package/lib/features/cross-chain/calculation-manager/providers/orbiter-bridge/orbiter-bridge-provider.js.map +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/orbiter-bridge/services/orbiter-api-service.d.ts +4 -3
- package/lib/features/cross-chain/calculation-manager/providers/orbiter-bridge/services/orbiter-api-service.js +14 -4
- package/lib/features/cross-chain/calculation-manager/providers/orbiter-bridge/services/orbiter-api-service.js.map +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/models/symbiosis-cross-chain-supported-blockchains.d.ts +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/models/symbiosis-cross-chain-supported-blockchains.js +1 -0
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/models/symbiosis-cross-chain-supported-blockchains.js.map +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/{symbiosis-cross-chain-trade.d.ts → symbiosis-ccr-evm-trade.d.ts} +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/{symbiosis-cross-chain-trade.js → symbiosis-ccr-evm-trade.js} +11 -8
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/symbiosis-ccr-evm-trade.js.map +1 -0
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/symbiosis-cross-chain-provider.d.ts +3 -2
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/symbiosis-cross-chain-provider.js +37 -50
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/symbiosis-cross-chain-provider.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/models/on-chain-manager-aggregators-types.d.ts +4 -4
- package/lib/features/on-chain/calculation-manager/models/on-chain-manager-aggregators-types.js +6 -4
- package/lib/features/on-chain/calculation-manager/models/on-chain-manager-aggregators-types.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/on-chain-manager.js +23 -14
- package/lib/features/on-chain/calculation-manager/on-chain-manager.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/1inch/one-inch-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/native-router-abstract/native-router-abstract-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/{tonkeeper → common/tonkeeper}/models/tonkeeper-api-types.d.ts +5 -4
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/models/tonkeeper-api-types.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/models/tonkeeper-trade-struct.d.ts +15 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/models/tonkeeper-trade-struct.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/services/tonkeeper-api-service.d.ts +9 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/services/tonkeeper-api-service.js +46 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/services/tonkeeper-api-service.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/tonkeeper-on-chain-provider.d.ts +16 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/{tonkeeper → common/tonkeeper}/tonkeeper-on-chain-provider.js +29 -19
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/tonkeeper-on-chain-provider.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/tonkeeper-on-chain-trade.d.ts +16 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/tonkeeper-on-chain-trade.js +46 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/common/tonkeeper/tonkeeper-on-chain-trade.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/dedust/dedust-on-chain-provider.d.ts +6 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/dedust/dedust-on-chain-provider.js +14 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/dedust/dedust-on-chain-provider.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/dln/chains/dln-evm-on-chain-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/dln/chains/dln-solana-on-chain-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/lifi/lifi-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/odos/odos-on-chain-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/okuswap/okuswap-on-chain-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/open-ocean/open-ocean-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/piteas/piteas-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/rango-on-chain-provider.js +4 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/rango-on-chain-provider.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/rango-on-chain-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/rango-on-chain-trade.js +1 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/rango-on-chain-trade.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/services/rango-on-chain-api-service.d.ts +1 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/services/rango-on-chain-api-service.js +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/rango/services/rango-on-chain-api-service.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/stonfi/stonfi-on-chain-provider.d.ts +6 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/stonfi/stonfi-on-chain-provider.js +14 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/stonfi/stonfi-on-chain-provider.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/aggregators/symbiosis/symbiosis-on-chain-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/xy-dex/xy-dex-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/aggregators/zrx/zrx-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/common/evm-wrap-trade/evm-wrap-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/common/models/on-chain-trade-type.d.ts +2 -1
- package/lib/features/on-chain/calculation-manager/providers/common/models/on-chain-trade-type.js +2 -1
- package/lib/features/on-chain/calculation-manager/providers/common/models/on-chain-trade-type.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-aggregator/aggregator-solana-on-chain-trade-abstract.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-aggregator/models/aggregator-on-chain-types.d.ts +1 -1
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/evm-on-chain-trade/evm-on-chain-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/on-chain-trade.js +1 -1
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/on-chain-trade.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/ton-on-chain-trade/models/ton-on-chian-trade-types.d.ts +9 -0
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/ton-on-chain-trade/models/ton-on-chian-trade-types.js +3 -0
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/ton-on-chain-trade/models/ton-on-chian-trade-types.js.map +1 -0
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/ton-on-chain-trade/ton-on-chain-trade.d.ts +6 -2
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/ton-on-chain-trade/ton-on-chain-trade.js +11 -0
- package/lib/features/on-chain/calculation-manager/providers/common/on-chain-trade/ton-on-chain-trade/ton-on-chain-trade.js.map +1 -1
- package/lib/features/on-chain/calculation-manager/providers/dexes/common/curve-provider/curve-abstract-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/common/izumi-abstract/izumi-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/common/pancake-router/pancake-router-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/common/sync-swap-abstract/sync-swap-abstract-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/common/uniswap-v2-abstract/uniswap-v2-abstract-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/common/uniswap-v3-algebra-abstract/uniswap-v3-algebra-abstract-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/common/vooi-abstract/vooi-abstract-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/mode/eddy-finance-mode/eddy-finance-mode-trade.d.ts +2 -2
- package/lib/features/on-chain/calculation-manager/providers/dexes/zetachain/eddy-finance/eddy-finance-trade.d.ts +2 -2
- package/lib/index.d.ts +9 -7
- package/lib/index.js +9 -7
- package/lib/index.js.map +1 -1
- package/package.json +158 -158
- package/lib/core/blockchain/services/ton/ton-utils.d.ts +0 -13
- package/lib/core/blockchain/services/ton/ton-utils.js +0 -36
- package/lib/core/blockchain/services/ton/ton-utils.js.map +0 -1
- package/lib/features/cross-chain/calculation-manager/providers/symbiosis-provider/symbiosis-cross-chain-trade.js.map +0 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/models/tonkeeper-api-types.js.map +0 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/models/tonkeeper-trade-struct.d.ts +0 -6
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/models/tonkeeper-trade-struct.js.map +0 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/services/tonkeeper-api-service.d.ts +0 -10
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/services/tonkeeper-api-service.js +0 -56
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/services/tonkeeper-api-service.js.map +0 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/tonkeeper-on-chain-provider.d.ts +0 -14
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/tonkeeper-on-chain-provider.js.map +0 -1
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/tonkeeper-on-chain-trade.d.ts +0 -10
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/tonkeeper-on-chain-trade.js +0 -23
- package/lib/features/on-chain/calculation-manager/providers/aggregators/tonkeeper/tonkeeper-on-chain-trade.js.map +0 -1
- /package/lib/features/on-chain/calculation-manager/providers/aggregators/{tonkeeper → common/tonkeeper}/models/tonkeeper-api-types.js +0 -0
- /package/lib/features/on-chain/calculation-manager/providers/aggregators/{tonkeeper → common/tonkeeper}/models/tonkeeper-trade-struct.js +0 -0
package/README.md
CHANGED
@@ -1,361 +1,361 @@
|
|
1
|
-
# Rubic SDK
|
2
|
-
|
3
|
-
## API Documentation
|
4
|
-
|
5
|
-
[Latest API Documentation](https://cryptorubic.github.io/rubic-sdk)
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
### Installation with cdn
|
9
|
-
```html
|
10
|
-
<script src="https://unpkg.com/rubic-sdk@latest/dist/rubic-sdk.min.js"></script>
|
11
|
-
```
|
12
|
-
|
13
|
-
### Installation with npm and webpack (React, ...)
|
14
|
-
1. `npm install rubic-sdk`
|
15
|
-
|
16
|
-
|
17
|
-
ℹ️️ Skip the rest of the steps if your have already installed [web3](https://github.com/ChainSafe/web3.js) in your project.
|
18
|
-
|
19
|
-
|
20
|
-
2. `npm install --save-dev http-browserify https-browserify stream-browserify crypto-browserify`
|
21
|
-
3. modify webpack.config.js. If you use create-react-app, run `npm run eject` to extract config
|
22
|
-
1. add to `plugins`
|
23
|
-
```javascript
|
24
|
-
new webpack.ProvidePlugin({
|
25
|
-
Buffer: ['buffer', 'Buffer'],
|
26
|
-
process: 'process/browser'
|
27
|
-
})
|
28
|
-
```
|
29
|
-
2. add `resolve.fallback`
|
30
|
-
```json
|
31
|
-
"fallback": {
|
32
|
-
"fs": false,
|
33
|
-
"constants": false,
|
34
|
-
"querystring": false,
|
35
|
-
"url": false,
|
36
|
-
"path": false,
|
37
|
-
"os": false,
|
38
|
-
"http": require.resolve("http-browserify"),
|
39
|
-
"https": require.resolve("https-browserify"),
|
40
|
-
"zlib": false,
|
41
|
-
"stream": require.resolve("stream-browserify"),
|
42
|
-
"crypto": require.resolve("crypto-browserify"),
|
43
|
-
"zlib": require.resolve('browserify-zlib')
|
44
|
-
}
|
45
|
-
```
|
46
|
-
|
47
|
-
### Installation with npm for Angular
|
48
|
-
1. `npm install rubic-sdk`
|
49
|
-
|
50
|
-
|
51
|
-
ℹ️️ Skip the rest of the steps if your have already installed [web3](https://github.com/ChainSafe/web3.js) in your project.
|
52
|
-
|
53
|
-
|
54
|
-
2. `npm install --save-dev stream-browserify assert https-browserify os-browserify stream-http crypto-browserify process buffer`
|
55
|
-
3. Modify tsconfig.json
|
56
|
-
```json
|
57
|
-
{
|
58
|
-
"compilerOptions": {
|
59
|
-
...
|
60
|
-
"paths" : {
|
61
|
-
...
|
62
|
-
"stream": ["./node_modules/stream-browserify"],
|
63
|
-
"assert": ["./node_modules/assert"],
|
64
|
-
"https": ["./node_modules/https-browserify"],
|
65
|
-
"os": ["./node_modules/os-browserify"],
|
66
|
-
"http": ["./node_modules/stream-http"],
|
67
|
-
"crypto": ["./node_modules/crypto-browserify"]
|
68
|
-
}
|
69
|
-
}
|
70
|
-
```
|
71
|
-
4. Modify polyfills.ts
|
72
|
-
```typescript
|
73
|
-
import Process = NodeJS.Process;
|
74
|
-
|
75
|
-
export interface AppWindow extends Window {
|
76
|
-
process: Process;
|
77
|
-
Buffer: Buffer;
|
78
|
-
global?: unknown;
|
79
|
-
}
|
80
|
-
|
81
|
-
(window as AppWindow).global = window;
|
82
|
-
(window as AppWindow).process = window.process || require('process');
|
83
|
-
(window as AppWindow).Buffer = (window as any).Buffer || require('buffer').Buffer;
|
84
|
-
```
|
85
|
-
|
86
|
-
## Trades usage
|
87
|
-
|
88
|
-
### Get started after cdn installation
|
89
|
-
```html
|
90
|
-
<script>
|
91
|
-
// you have to declare rpc links only for networks you will use
|
92
|
-
const configuration = {
|
93
|
-
rpcProviders: {
|
94
|
-
ETH: {
|
95
|
-
rpcList: ['<your ethereum rpc>']
|
96
|
-
},
|
97
|
-
BSC: {
|
98
|
-
rpcList: ['<your bsc rpc>']
|
99
|
-
},
|
100
|
-
...
|
101
|
-
TRON: {
|
102
|
-
rpcList: [
|
103
|
-
{
|
104
|
-
fullHost: '<tron-api>',
|
105
|
-
headers: { "TRON-PRO-API-KEY": 'your api key' }
|
106
|
-
}
|
107
|
-
]
|
108
|
-
}
|
109
|
-
},
|
110
|
-
// if you are whitelisted integrator, provide your wallet address here
|
111
|
-
providerAddress: {
|
112
|
-
[CHAIN_TYPE.EVM]: {
|
113
|
-
crossChain: '0x0000000000000000000000000000000000000000', // Address for cross chain fee
|
114
|
-
onChain: '0x0000000000000000000000000000000000000000' // Address for on chain fee
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
async function main() {
|
120
|
-
// create SDK instance
|
121
|
-
const sdk = await RubicSDK.SDK.createSDK(configuration);
|
122
|
-
|
123
|
-
// define example trade parameters
|
124
|
-
const blockchain = 'ETH';
|
125
|
-
const fromTokenAddress = '0x0000000000000000000000000000000000000000';
|
126
|
-
const fromAmount = 1;
|
127
|
-
const toTokenAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7';
|
128
|
-
|
129
|
-
// calculate trades
|
130
|
-
const trades = await sdk.onChainManager
|
131
|
-
.calculateTrade({blockchain, address: fromTokenAddress}, fromAmount, toTokenAddress);
|
132
|
-
|
133
|
-
console.log(trades);
|
134
|
-
}
|
135
|
-
main();
|
136
|
-
</script>
|
137
|
-
```
|
138
|
-
|
139
|
-
|
140
|
-
### Get started after npm installation
|
141
|
-
1. Create configuration
|
142
|
-
```typescript
|
143
|
-
import { Configuration, BLOCKCHAIN_NAME } from 'rubic-sdk';
|
144
|
-
|
145
|
-
// you have to declare rpc links only for networks you will use
|
146
|
-
export const configuration: Configuration = {
|
147
|
-
rpcProviders: {
|
148
|
-
[BLOCKCHAIN_NAME.ETHEREUM]: {
|
149
|
-
rpcList: ['<your ethereum rpc #1>', '<your ethereum rpc #2>', ...]
|
150
|
-
},
|
151
|
-
[BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]: {
|
152
|
-
rpcList: ['<your bsc rpc>']
|
153
|
-
},
|
154
|
-
...
|
155
|
-
[BLOCKCHAIN_NAME.TRON]: {
|
156
|
-
rpcList: [
|
157
|
-
{
|
158
|
-
fullHost: '<tron api>',
|
159
|
-
headers: { "TRON-PRO-API-KEY": 'your api key' }
|
160
|
-
}
|
161
|
-
]
|
162
|
-
}
|
163
|
-
},
|
164
|
-
// if you are whitelisted integrator, provide your wallet address here
|
165
|
-
providerAddress: {
|
166
|
-
[CHAIN_TYPE.EVM]: {
|
167
|
-
crossChain: '0x0000000000000000000000000000000000000000', // Address for cross chain fee
|
168
|
-
onChain: '0x0000000000000000000000000000000000000000' // Address for on chain fee
|
169
|
-
}
|
170
|
-
}
|
171
|
-
}
|
172
|
-
```
|
173
|
-
2. Create sdk instance
|
174
|
-
```typescript
|
175
|
-
import { SDK } from 'rubic-sdk';
|
176
|
-
|
177
|
-
const sdk = await SDK.createSDK(configuration);
|
178
|
-
```
|
179
|
-
|
180
|
-
3. Use sdk instance for trade calculation
|
181
|
-
```typescript
|
182
|
-
import { BLOCKCHAIN_NAME, TradeType, OnChainTrade, EvmOnChainTrade } from 'rubic-sdk';
|
183
|
-
|
184
|
-
const blockchain = BLOCKCHAIN_NAME.ETHEREUM;
|
185
|
-
const fromTokenAddress = '0x0000000000000000000000000000000000000000'; // ETH
|
186
|
-
const fromAmount = 1;
|
187
|
-
const toTokenAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7'; // USDT
|
188
|
-
|
189
|
-
const trades = await sdk.onChainManager.calculateTrade(
|
190
|
-
{ blockchain, address: fromTokenAddress },
|
191
|
-
fromAmount,
|
192
|
-
toTokenAddress
|
193
|
-
);
|
194
|
-
const bestTrade = trades[0];
|
195
|
-
|
196
|
-
trades.forEach(trade => {
|
197
|
-
const tradeType: TradeType = trade.type;
|
198
|
-
console.log(`trade type: ${tradeType}`);
|
199
|
-
|
200
|
-
if (trade instanceof OnChainTrade) {
|
201
|
-
console.log(`to amount: ${trade.to.tokenAmount.toFormat(3)}`);
|
202
|
-
} else {
|
203
|
-
console.log(`error: ${trade.error}`);
|
204
|
-
}
|
205
|
-
|
206
|
-
// explore trades info
|
207
|
-
if (trade instanceof EvmOnChainTrade) {
|
208
|
-
console.log(`Gas fee: ${bestTrade.gasFeeInfo}`);
|
209
|
-
}
|
210
|
-
...
|
211
|
-
});
|
212
|
-
```
|
213
|
-
|
214
|
-
4. When user connects wallet (e.g. MetaMask) you should change configuration to use trade `swap` method.<br />
|
215
|
-
**⚠️ Recalculate trades after this**.
|
216
|
-
```typescript
|
217
|
-
import { WalletProvider, CHAIN_TYPE, Configuration } from 'rubic-sdk';
|
218
|
-
|
219
|
-
const walletProvider: WalletProvider = {
|
220
|
-
[CHAIN_TYPE.EVM]: {
|
221
|
-
address: '0x123...', // user wallet address
|
222
|
-
core: window.ethereum
|
223
|
-
},
|
224
|
-
[CHAIN_TYPE.TRON]: {
|
225
|
-
address: 'T123...', // user wallet address
|
226
|
-
core: window.tronLink.tronWeb // or window.tronWeb
|
227
|
-
}
|
228
|
-
};
|
229
|
-
|
230
|
-
// initial configuration example
|
231
|
-
const configuration: Configuration = {
|
232
|
-
...
|
233
|
-
walletProvider
|
234
|
-
}
|
235
|
-
const sdk = await SDK.createSDK(configuration);
|
236
|
-
|
237
|
-
// after user's wallet address changed
|
238
|
-
// Example #1:
|
239
|
-
sdk.updateWalletProvider(walletProvider);
|
240
|
-
|
241
|
-
// Example #2:
|
242
|
-
sdk.updateWalletAddress(CHAIN_TYPE.EVM, address);
|
243
|
-
|
244
|
-
```
|
245
|
-
|
246
|
-
5. Now you can use `swap` method of trade instance. Approve transaction will be sent automatically if needed.
|
247
|
-
```typescript
|
248
|
-
const onConfirm = (hash: string) => console.log(hash);
|
249
|
-
|
250
|
-
// check that trade is defined
|
251
|
-
сonst bestTrade = trades[0];
|
252
|
-
const receipt = await bestTrade.swap({ onConfirm });
|
253
|
-
```
|
254
|
-
|
255
|
-
### Get started with cross-chain swaps
|
256
|
-
Steps 1. and 2. are the same. You can use single sdk instance for on-chain trades and cross-chain swaps calculations.
|
257
|
-
|
258
|
-
3. Use sdk instance for trade calculation
|
259
|
-
```typescript
|
260
|
-
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
261
|
-
|
262
|
-
const fromBlockchain = BLOCKCHAIN_NAME.ETHEREUM;
|
263
|
-
const fromTokenAddress = '0x0000000000000000000000000000000000000000'; // ETH
|
264
|
-
const fromAmount = 1;
|
265
|
-
const toBlockchain = BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN;
|
266
|
-
const toTokenAddress = '0xe9e7cea3dedca5984780bafc599bd69add087d56'; // BUSD
|
267
|
-
|
268
|
-
const wrappedTrades = await sdk.crossChainManager.calculateTrade(
|
269
|
-
{ blockchain: fromBlockchain, address: fromTokenAddress },
|
270
|
-
fromAmount,
|
271
|
-
{ blockchain: toBlockchain, address: toTokenAddress }
|
272
|
-
);
|
273
|
-
|
274
|
-
wrappedTrades.forEach(wrappedTrade => {
|
275
|
-
const tradeType: TradeType = wrappedTrade.type;
|
276
|
-
console.log(`trade type: ${tradeType}`);
|
277
|
-
|
278
|
-
if (wrappedTrade.error) {
|
279
|
-
console.log(`error: ${wrappedTrade.error}`);
|
280
|
-
} else {
|
281
|
-
const trade = wrappedTrade.trade!;
|
282
|
-
console.log(`to amount: ${trade.to.tokenAmount.toFormat(3)}`);
|
283
|
-
|
284
|
-
// explore trades info
|
285
|
-
if (trade instanceof EvmCrossChainTrade) {
|
286
|
-
console.log(trade.gasData)
|
287
|
-
}
|
288
|
-
...
|
289
|
-
}
|
290
|
-
})
|
291
|
-
```
|
292
|
-
|
293
|
-
4. Same as in on-chain.
|
294
|
-
|
295
|
-
5. Now you can use `swap` method of trade instance. Approve transaction will be sent automatically if needed.
|
296
|
-
```typescript
|
297
|
-
const onConfirm = (hash: string) => console.log(hash);
|
298
|
-
|
299
|
-
// check, that trade is defined
|
300
|
-
const bestTrade = wrappedTrades[0].trade;
|
301
|
-
const receipt = await bestTrade.swap({ onConfirm });
|
302
|
-
```
|
303
|
-
|
304
|
-
## Token classes
|
305
|
-
|
306
|
-
You can use specific sdk `Token` classes to work with tokens.
|
307
|
-
|
308
|
-
### Token
|
309
|
-
|
310
|
-
```typescript
|
311
|
-
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
312
|
-
|
313
|
-
const token: Token = await Token.createToken({
|
314
|
-
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
315
|
-
address: '0xdac17f958d2ee523a2206206994597c13d831ec7'
|
316
|
-
});
|
317
|
-
|
318
|
-
console.log(token.symbol); // USDT
|
319
|
-
console.log(token.name); // Tether USD
|
320
|
-
console.log(token.decimals); // 6
|
321
|
-
```
|
322
|
-
|
323
|
-
You can also use constructor directly.
|
324
|
-
```typescript
|
325
|
-
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
326
|
-
|
327
|
-
const token = new Token({
|
328
|
-
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
329
|
-
address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
330
|
-
name: 'USD Coin',
|
331
|
-
symbol: 'USDC',
|
332
|
-
decimals: 6
|
333
|
-
})
|
334
|
-
```
|
335
|
-
|
336
|
-
### PriceToken
|
337
|
-
|
338
|
-
```typescript
|
339
|
-
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
340
|
-
|
341
|
-
const token: PriceToken = await PriceToken.createToken({
|
342
|
-
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
343
|
-
address: '0xdac17f958d2ee523a2206206994597c13d831ec7'
|
344
|
-
});
|
345
|
-
|
346
|
-
console.log(token.price);
|
347
|
-
```
|
348
|
-
|
349
|
-
### PriceTokenAmount
|
350
|
-
|
351
|
-
```typescript
|
352
|
-
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
353
|
-
|
354
|
-
const token: PriceTokenAmount = await PriceTokenAmount.createToken({
|
355
|
-
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
356
|
-
address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
357
|
-
tokenAmount: new BigNumber(1)
|
358
|
-
});
|
359
|
-
|
360
|
-
console.log(token.weiAmount);
|
361
|
-
```
|
1
|
+
# Rubic SDK
|
2
|
+
|
3
|
+
## API Documentation
|
4
|
+
|
5
|
+
[Latest API Documentation](https://cryptorubic.github.io/rubic-sdk)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
### Installation with cdn
|
9
|
+
```html
|
10
|
+
<script src="https://unpkg.com/rubic-sdk@latest/dist/rubic-sdk.min.js"></script>
|
11
|
+
```
|
12
|
+
|
13
|
+
### Installation with npm and webpack (React, ...)
|
14
|
+
1. `npm install rubic-sdk`
|
15
|
+
|
16
|
+
|
17
|
+
ℹ️️ Skip the rest of the steps if your have already installed [web3](https://github.com/ChainSafe/web3.js) in your project.
|
18
|
+
|
19
|
+
|
20
|
+
2. `npm install --save-dev http-browserify https-browserify stream-browserify crypto-browserify`
|
21
|
+
3. modify webpack.config.js. If you use create-react-app, run `npm run eject` to extract config
|
22
|
+
1. add to `plugins`
|
23
|
+
```javascript
|
24
|
+
new webpack.ProvidePlugin({
|
25
|
+
Buffer: ['buffer', 'Buffer'],
|
26
|
+
process: 'process/browser'
|
27
|
+
})
|
28
|
+
```
|
29
|
+
2. add `resolve.fallback`
|
30
|
+
```json
|
31
|
+
"fallback": {
|
32
|
+
"fs": false,
|
33
|
+
"constants": false,
|
34
|
+
"querystring": false,
|
35
|
+
"url": false,
|
36
|
+
"path": false,
|
37
|
+
"os": false,
|
38
|
+
"http": require.resolve("http-browserify"),
|
39
|
+
"https": require.resolve("https-browserify"),
|
40
|
+
"zlib": false,
|
41
|
+
"stream": require.resolve("stream-browserify"),
|
42
|
+
"crypto": require.resolve("crypto-browserify"),
|
43
|
+
"zlib": require.resolve('browserify-zlib')
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
### Installation with npm for Angular
|
48
|
+
1. `npm install rubic-sdk`
|
49
|
+
|
50
|
+
|
51
|
+
ℹ️️ Skip the rest of the steps if your have already installed [web3](https://github.com/ChainSafe/web3.js) in your project.
|
52
|
+
|
53
|
+
|
54
|
+
2. `npm install --save-dev stream-browserify assert https-browserify os-browserify stream-http crypto-browserify process buffer`
|
55
|
+
3. Modify tsconfig.json
|
56
|
+
```json
|
57
|
+
{
|
58
|
+
"compilerOptions": {
|
59
|
+
...
|
60
|
+
"paths" : {
|
61
|
+
...
|
62
|
+
"stream": ["./node_modules/stream-browserify"],
|
63
|
+
"assert": ["./node_modules/assert"],
|
64
|
+
"https": ["./node_modules/https-browserify"],
|
65
|
+
"os": ["./node_modules/os-browserify"],
|
66
|
+
"http": ["./node_modules/stream-http"],
|
67
|
+
"crypto": ["./node_modules/crypto-browserify"]
|
68
|
+
}
|
69
|
+
}
|
70
|
+
```
|
71
|
+
4. Modify polyfills.ts
|
72
|
+
```typescript
|
73
|
+
import Process = NodeJS.Process;
|
74
|
+
|
75
|
+
export interface AppWindow extends Window {
|
76
|
+
process: Process;
|
77
|
+
Buffer: Buffer;
|
78
|
+
global?: unknown;
|
79
|
+
}
|
80
|
+
|
81
|
+
(window as AppWindow).global = window;
|
82
|
+
(window as AppWindow).process = window.process || require('process');
|
83
|
+
(window as AppWindow).Buffer = (window as any).Buffer || require('buffer').Buffer;
|
84
|
+
```
|
85
|
+
|
86
|
+
## Trades usage
|
87
|
+
|
88
|
+
### Get started after cdn installation
|
89
|
+
```html
|
90
|
+
<script>
|
91
|
+
// you have to declare rpc links only for networks you will use
|
92
|
+
const configuration = {
|
93
|
+
rpcProviders: {
|
94
|
+
ETH: {
|
95
|
+
rpcList: ['<your ethereum rpc>']
|
96
|
+
},
|
97
|
+
BSC: {
|
98
|
+
rpcList: ['<your bsc rpc>']
|
99
|
+
},
|
100
|
+
...
|
101
|
+
TRON: {
|
102
|
+
rpcList: [
|
103
|
+
{
|
104
|
+
fullHost: '<tron-api>',
|
105
|
+
headers: { "TRON-PRO-API-KEY": 'your api key' }
|
106
|
+
}
|
107
|
+
]
|
108
|
+
}
|
109
|
+
},
|
110
|
+
// if you are whitelisted integrator, provide your wallet address here
|
111
|
+
providerAddress: {
|
112
|
+
[CHAIN_TYPE.EVM]: {
|
113
|
+
crossChain: '0x0000000000000000000000000000000000000000', // Address for cross chain fee
|
114
|
+
onChain: '0x0000000000000000000000000000000000000000' // Address for on chain fee
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
async function main() {
|
120
|
+
// create SDK instance
|
121
|
+
const sdk = await RubicSDK.SDK.createSDK(configuration);
|
122
|
+
|
123
|
+
// define example trade parameters
|
124
|
+
const blockchain = 'ETH';
|
125
|
+
const fromTokenAddress = '0x0000000000000000000000000000000000000000';
|
126
|
+
const fromAmount = 1;
|
127
|
+
const toTokenAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7';
|
128
|
+
|
129
|
+
// calculate trades
|
130
|
+
const trades = await sdk.onChainManager
|
131
|
+
.calculateTrade({blockchain, address: fromTokenAddress}, fromAmount, toTokenAddress);
|
132
|
+
|
133
|
+
console.log(trades);
|
134
|
+
}
|
135
|
+
main();
|
136
|
+
</script>
|
137
|
+
```
|
138
|
+
|
139
|
+
|
140
|
+
### Get started after npm installation
|
141
|
+
1. Create configuration
|
142
|
+
```typescript
|
143
|
+
import { Configuration, BLOCKCHAIN_NAME } from 'rubic-sdk';
|
144
|
+
|
145
|
+
// you have to declare rpc links only for networks you will use
|
146
|
+
export const configuration: Configuration = {
|
147
|
+
rpcProviders: {
|
148
|
+
[BLOCKCHAIN_NAME.ETHEREUM]: {
|
149
|
+
rpcList: ['<your ethereum rpc #1>', '<your ethereum rpc #2>', ...]
|
150
|
+
},
|
151
|
+
[BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]: {
|
152
|
+
rpcList: ['<your bsc rpc>']
|
153
|
+
},
|
154
|
+
...
|
155
|
+
[BLOCKCHAIN_NAME.TRON]: {
|
156
|
+
rpcList: [
|
157
|
+
{
|
158
|
+
fullHost: '<tron api>',
|
159
|
+
headers: { "TRON-PRO-API-KEY": 'your api key' }
|
160
|
+
}
|
161
|
+
]
|
162
|
+
}
|
163
|
+
},
|
164
|
+
// if you are whitelisted integrator, provide your wallet address here
|
165
|
+
providerAddress: {
|
166
|
+
[CHAIN_TYPE.EVM]: {
|
167
|
+
crossChain: '0x0000000000000000000000000000000000000000', // Address for cross chain fee
|
168
|
+
onChain: '0x0000000000000000000000000000000000000000' // Address for on chain fee
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
```
|
173
|
+
2. Create sdk instance
|
174
|
+
```typescript
|
175
|
+
import { SDK } from 'rubic-sdk';
|
176
|
+
|
177
|
+
const sdk = await SDK.createSDK(configuration);
|
178
|
+
```
|
179
|
+
|
180
|
+
3. Use sdk instance for trade calculation
|
181
|
+
```typescript
|
182
|
+
import { BLOCKCHAIN_NAME, TradeType, OnChainTrade, EvmOnChainTrade } from 'rubic-sdk';
|
183
|
+
|
184
|
+
const blockchain = BLOCKCHAIN_NAME.ETHEREUM;
|
185
|
+
const fromTokenAddress = '0x0000000000000000000000000000000000000000'; // ETH
|
186
|
+
const fromAmount = 1;
|
187
|
+
const toTokenAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7'; // USDT
|
188
|
+
|
189
|
+
const trades = await sdk.onChainManager.calculateTrade(
|
190
|
+
{ blockchain, address: fromTokenAddress },
|
191
|
+
fromAmount,
|
192
|
+
toTokenAddress
|
193
|
+
);
|
194
|
+
const bestTrade = trades[0];
|
195
|
+
|
196
|
+
trades.forEach(trade => {
|
197
|
+
const tradeType: TradeType = trade.type;
|
198
|
+
console.log(`trade type: ${tradeType}`);
|
199
|
+
|
200
|
+
if (trade instanceof OnChainTrade) {
|
201
|
+
console.log(`to amount: ${trade.to.tokenAmount.toFormat(3)}`);
|
202
|
+
} else {
|
203
|
+
console.log(`error: ${trade.error}`);
|
204
|
+
}
|
205
|
+
|
206
|
+
// explore trades info
|
207
|
+
if (trade instanceof EvmOnChainTrade) {
|
208
|
+
console.log(`Gas fee: ${bestTrade.gasFeeInfo}`);
|
209
|
+
}
|
210
|
+
...
|
211
|
+
});
|
212
|
+
```
|
213
|
+
|
214
|
+
4. When user connects wallet (e.g. MetaMask) you should change configuration to use trade `swap` method.<br />
|
215
|
+
**⚠️ Recalculate trades after this**.
|
216
|
+
```typescript
|
217
|
+
import { WalletProvider, CHAIN_TYPE, Configuration } from 'rubic-sdk';
|
218
|
+
|
219
|
+
const walletProvider: WalletProvider = {
|
220
|
+
[CHAIN_TYPE.EVM]: {
|
221
|
+
address: '0x123...', // user wallet address
|
222
|
+
core: window.ethereum
|
223
|
+
},
|
224
|
+
[CHAIN_TYPE.TRON]: {
|
225
|
+
address: 'T123...', // user wallet address
|
226
|
+
core: window.tronLink.tronWeb // or window.tronWeb
|
227
|
+
}
|
228
|
+
};
|
229
|
+
|
230
|
+
// initial configuration example
|
231
|
+
const configuration: Configuration = {
|
232
|
+
...
|
233
|
+
walletProvider
|
234
|
+
}
|
235
|
+
const sdk = await SDK.createSDK(configuration);
|
236
|
+
|
237
|
+
// after user's wallet address changed
|
238
|
+
// Example #1:
|
239
|
+
sdk.updateWalletProvider(walletProvider);
|
240
|
+
|
241
|
+
// Example #2:
|
242
|
+
sdk.updateWalletAddress(CHAIN_TYPE.EVM, address);
|
243
|
+
|
244
|
+
```
|
245
|
+
|
246
|
+
5. Now you can use `swap` method of trade instance. Approve transaction will be sent automatically if needed.
|
247
|
+
```typescript
|
248
|
+
const onConfirm = (hash: string) => console.log(hash);
|
249
|
+
|
250
|
+
// check that trade is defined
|
251
|
+
сonst bestTrade = trades[0];
|
252
|
+
const receipt = await bestTrade.swap({ onConfirm });
|
253
|
+
```
|
254
|
+
|
255
|
+
### Get started with cross-chain swaps
|
256
|
+
Steps 1. and 2. are the same. You can use single sdk instance for on-chain trades and cross-chain swaps calculations.
|
257
|
+
|
258
|
+
3. Use sdk instance for trade calculation
|
259
|
+
```typescript
|
260
|
+
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
261
|
+
|
262
|
+
const fromBlockchain = BLOCKCHAIN_NAME.ETHEREUM;
|
263
|
+
const fromTokenAddress = '0x0000000000000000000000000000000000000000'; // ETH
|
264
|
+
const fromAmount = 1;
|
265
|
+
const toBlockchain = BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN;
|
266
|
+
const toTokenAddress = '0xe9e7cea3dedca5984780bafc599bd69add087d56'; // BUSD
|
267
|
+
|
268
|
+
const wrappedTrades = await sdk.crossChainManager.calculateTrade(
|
269
|
+
{ blockchain: fromBlockchain, address: fromTokenAddress },
|
270
|
+
fromAmount,
|
271
|
+
{ blockchain: toBlockchain, address: toTokenAddress }
|
272
|
+
);
|
273
|
+
|
274
|
+
wrappedTrades.forEach(wrappedTrade => {
|
275
|
+
const tradeType: TradeType = wrappedTrade.type;
|
276
|
+
console.log(`trade type: ${tradeType}`);
|
277
|
+
|
278
|
+
if (wrappedTrade.error) {
|
279
|
+
console.log(`error: ${wrappedTrade.error}`);
|
280
|
+
} else {
|
281
|
+
const trade = wrappedTrade.trade!;
|
282
|
+
console.log(`to amount: ${trade.to.tokenAmount.toFormat(3)}`);
|
283
|
+
|
284
|
+
// explore trades info
|
285
|
+
if (trade instanceof EvmCrossChainTrade) {
|
286
|
+
console.log(trade.gasData)
|
287
|
+
}
|
288
|
+
...
|
289
|
+
}
|
290
|
+
})
|
291
|
+
```
|
292
|
+
|
293
|
+
4. Same as in on-chain.
|
294
|
+
|
295
|
+
5. Now you can use `swap` method of trade instance. Approve transaction will be sent automatically if needed.
|
296
|
+
```typescript
|
297
|
+
const onConfirm = (hash: string) => console.log(hash);
|
298
|
+
|
299
|
+
// check, that trade is defined
|
300
|
+
const bestTrade = wrappedTrades[0].trade;
|
301
|
+
const receipt = await bestTrade.swap({ onConfirm });
|
302
|
+
```
|
303
|
+
|
304
|
+
## Token classes
|
305
|
+
|
306
|
+
You can use specific sdk `Token` classes to work with tokens.
|
307
|
+
|
308
|
+
### Token
|
309
|
+
|
310
|
+
```typescript
|
311
|
+
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
312
|
+
|
313
|
+
const token: Token = await Token.createToken({
|
314
|
+
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
315
|
+
address: '0xdac17f958d2ee523a2206206994597c13d831ec7'
|
316
|
+
});
|
317
|
+
|
318
|
+
console.log(token.symbol); // USDT
|
319
|
+
console.log(token.name); // Tether USD
|
320
|
+
console.log(token.decimals); // 6
|
321
|
+
```
|
322
|
+
|
323
|
+
You can also use constructor directly.
|
324
|
+
```typescript
|
325
|
+
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
326
|
+
|
327
|
+
const token = new Token({
|
328
|
+
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
329
|
+
address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
330
|
+
name: 'USD Coin',
|
331
|
+
symbol: 'USDC',
|
332
|
+
decimals: 6
|
333
|
+
})
|
334
|
+
```
|
335
|
+
|
336
|
+
### PriceToken
|
337
|
+
|
338
|
+
```typescript
|
339
|
+
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
340
|
+
|
341
|
+
const token: PriceToken = await PriceToken.createToken({
|
342
|
+
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
343
|
+
address: '0xdac17f958d2ee523a2206206994597c13d831ec7'
|
344
|
+
});
|
345
|
+
|
346
|
+
console.log(token.price);
|
347
|
+
```
|
348
|
+
|
349
|
+
### PriceTokenAmount
|
350
|
+
|
351
|
+
```typescript
|
352
|
+
import { BLOCKCHAIN_NAME } from 'rubic-sdk';
|
353
|
+
|
354
|
+
const token: PriceTokenAmount = await PriceTokenAmount.createToken({
|
355
|
+
blockchain: BLOCKCHAIN_NAME.ETHEREUM,
|
356
|
+
address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
357
|
+
tokenAmount: new BigNumber(1)
|
358
|
+
});
|
359
|
+
|
360
|
+
console.log(token.weiAmount);
|
361
|
+
```
|