-
Notifications
You must be signed in to change notification settings - Fork 5
/
sdkDemo.js
118 lines (110 loc) · 3.37 KB
/
sdkDemo.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const transitSwap = require("./index")
async function chain() {
const chains = await transitSwap.swapV1.getSupportChain()
// const chains = await transitSwap.swapV1.getCrossRouter("BSC")
console.log(chains)
}
async function crossTokens() {
const res = await transitSwap.swapV1.quoteCrossTokens()
if (res.msg == transitSwap.SUCCESS) {
console.log("returun data:", res)
} else {
console.log("query failure:", res)
}
}
async function limit() {
const data = {
token0: "0xa71edc38d189767582c38a3145b5873052c3e47a",
token1: "0x55d398326f99059ff775485246999027b3197955",
fromChainID: 128,
toChainID: 56,
bridge: "METAPATH"
}
const res = await transitSwap.swapV1.quoteCrossTransferLimit(data)
if (res.msg == transitSwap.SUCCESS) {
console.log("returun data:", res)
} else {
console.log("query failure:", res)
}
}
async function swap() {
const data = {
chain: "BSC",
token0: "0x0000000000000000000000000000000000000000",
token1: "0x55d398326f99059ff775485246999027b3197955",
decimal0: 18,
decimal1: 18,
to: "0xFab745c5Ee6C59C09605a40464232930892bA48C",
amountIn: "1000000000000000000",
impact: "300",
amountOutMin: "0",
part: 10,
channel: "default",
issuer: "0xFab745c5Ee6C59C09605a40464232930892bA48C"
}
const res = await transitSwap.swapV1.quoteSwap(data)
if (res.msg == transitSwap.SUCCESS) {
console.log("returun data:", res)
} else {
console.log("query failure:", res)
}
}
async function details() {
const res = await transitSwap.swapV1.quoteDetails("0x0cec30133c4362c9053266e3bc67a5f2d25aac5d0a75a5a46e3cbc37a9a91573")
if (res.msg == transitSwap.SUCCESS) {
console.log("returun data:", res)
} else {
console.log("query failure:", res)
}
}
async function crossSwap() {
const data = {
bridge: "METAPATH",
token0: "0xdac17f958d2ee523a2206206994597c13d831ec7",
token1: "0x55d398326f99059ff775485246999027b3197955",
decimal0: 6,
decimal1: 18,
to: "0xFab745c5Ee6C59C09605a40464232930892bA48C",
amountIn: "11000000",
fromChainID: 1,
toChainID: 56,
channel: "default",
issuer: "0xFab745c5Ee6C59C09605a40464232930892bA48C"
}
const res = await transitSwap.swapV1.quoteCrossSwap(data)
if (res.msg == transitSwap.SUCCESS) {
console.log("returun data:", res)
} else {
console.log("query failure:", res)
}
}
async function swapCallback() {
const data = {
bridge: "METAPATH",
token0: "0xdac17f958d2ee523a2206206994597c13d831ec7",
token1: "0x55d398326f99059ff775485246999027b3197955",
decimal0: 6,
decimal1: 18,
to: "0xFab745c5Ee6C59C09605a40464232930892bA48C",
amountIn: "11000000",
fromChainID: 1,
toChainID: 56,
channel: "default",
issuer: "0xFab745c5Ee6C59C09605a40464232930892bA48C",
amountOutMin: "3980020",
hash: ""
}
const res = await transitSwap.swapV1.CallbackSwap(data)
if (res.msg == transitSwap.SUCCESS) {
console.log("returun data:", res)
} else {
console.log("query failure:", res)
}
}
// crossTokens()
// limit()
// swap()
// details()
// crossSwap()
// swapCallback()
// chain()