forked from paraswap/paraswap-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
apiary.apib
133 lines (113 loc) · 6.45 KB
/
apiary.apib
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
FORMAT: 1A
HOST: https://paraswap.io/api/v1
# ParaSwap.io API
ParaSwap API allows any developer to retrieve Token prices as well as making swaps or payments using ETH and ERC-20 tokens.
We tried, as much as possible, to make it very simple to integrate. All you need is 2 API calls (get price & build tx) for making a swap or a payment.
Developers can also use our JS/TS SDK for web and Node.js integrations https://www.npmjs.com/package/paraswap
## Tokens Collection [/tokens/{networkID}]
### List All Tokens [GET]
+ Response 200 (application/json)
{
"tokens": [
{
"decimals": 18,
"symbol": "DAI",
"address": " 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
}
]
}
## Get Rate for a Token Pair [/prices/{networkID}/{srcToken}/{destToken}/{srcAmount}]
### Get Rate for a Token Pair [GET]
+ Response 200 (application/json)
{
"priceRoute":{
"amount":"182037836304840811050",
"bestRoute":[
{
"exchange":"ETH2DAI",
"percent":"76",
"srcAmount":"760000000000000000",
"destAmount":"182020000000000000000"
},
{
"exchange":"BANCOR",
"percent":"24",
"srcAmount":"240000000000000000",
"destAmount":"181845805751241582628"
},
{
"exchange":"UNISWAP",
"percent":"0",
"srcAmount":"0",
"destAmount":"181869789397925163230"
},
{
"exchange":"KYBER",
"percent":"0",
"srcAmount":"0",
"destAmount":"181897167924745125888"
}
],
"others":[
{
"exchange":"UNISWAP",
"rate":"181869789397925163230",
"unit":"181869789397925163230"
},
{
"exchange":"BANCOR",
"rate":"181845805751241582628",
"unit":"181845805751241582628"
},
{
"exchange":"KYBER",
"rate":"181897167924745125888",
"unit":"181897167924745125888"
},
{
"exchange":"ETH2DAI",
"rate":"182020000000000000000",
"unit":"182020000000000000000"
}
]
}
}
## Transaction builder [/transactions/{networkID}]
### Swap or Pay [POST]
PayTo field is the one that determines if the swap is a payment
+ Request (application/json)
{
"priceRoute": {
"bestRoute": [
{
"exchange":"ETH2DAI",
"percent":"76",
"srcAmount":"760000000000000000",
"destAmount":"182020000000000000000"
},
{
"exchange":"BANCOR",
"percent":"24",
"srcAmount":"240000000000000000",
"destAmount":"181845805751241582628"
}
]
},
"srcToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"destToken": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359",
"srcAmount": "1000000000000000000",
"destAmount": "182037836304840811050",
"userAddress": "0xfceA770875E7e6f25E33CEa5188d12Ef234606b4",
"payTo": "0x8B4e846c90a2521F0D2733EaCb56760209EAd51A",
"referrer": "my-company-or-user-name"
}
+ Response 200 (application/json)
{
"from": "0xfceA770875E7e6f25E33CEa5188d12Ef234606b4",
"to": "0x6b158039b9678b7452f311deb12dd08c579dad26",
"value": "1000000000000000000",
"data": "0x0ae417bc0000000000000000000000008b4e846c90a2521f0d2733eacb56760209ead51a000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a232603590000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000009de484fa436be622a000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000793ebbe21607e4f04788f89c7a9b97320773ec59000000000000000000000000eee90e509a639e95e3bb502b17a0eed6e014bfc000000000000000000000000000000000000000000000000000000000000001a8e50278a600000000000000000000000039755357759ce0d7f32dc8dc45414cca409ae24e000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a232603590000000000000000000000000000000000000000000000077ff984351f5d7dcef3898a9700000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000354a6ba7a1800000000000000000000000000000000000000000000000000025e4ecb6f1760e45c0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000c0829421c1d260bd3cb3e0f06cfe2d52db2ce3150000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c0000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c000000000000000000000000ee01b3ab5f6728adc137be101d99c678938e6e7200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a2326035900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008400000000000000000000000000000000000000000000000000000000000001a800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000a8c0ff92d4c00000000000000000000000000000000000000000000000000000354a6ba7a180000",
"chainId": 1,
"gasPrice":"1200000000",
"gas": 680051
}