-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
218 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -917,7 +917,7 @@ time | timestamp | Time of the swap (milliseconds) | |
|
||
## Pool Positions | ||
```shell | ||
curl https://wax.alcor.exchange/api/v2/swap/pools/0/positions | ||
curl https://alcor.exchange/api/v2/swap/pools/0/positions | ||
``` | ||
|
||
> The above command returns JSON structured like this: | ||
|
@@ -945,7 +945,7 @@ curl https://wax.alcor.exchange/api/v2/swap/pools/0/positions | |
API for getting all positions of pool | ||
|
||
### HTTP Request | ||
`GET https://wax.alcor.exchange/api/v2/swap/pools/<:pool_id>/positions` | ||
`GET https://alcor.exchange/api/v2/swap/pools/<:pool_id>/positions` | ||
|
||
|
||
**Query params:** | ||
|
@@ -972,9 +972,132 @@ pool | number | pool ID | |
amountA | asset | Positoin token A amount | ||
amountB | asset | Positoin token B amount | ||
|
||
## Output & Route calculation | ||
```shell | ||
curl "https://alcor.exchange/api/v2/swapRouter/getRoute?trade_type=EXACT_INPUT&input=wax-eosio.token&output=tlm-alien.worlds&amount=1.00000000&slippage=0.30&receiver=alcordexfund&maxHops=2" | ||
``` | ||
|
||
> The above command returns JSON structured like this: | ||
```json | ||
{ | ||
"executionPrice": { | ||
"denominator": "100000000", | ||
"numerator": "39285" | ||
}, | ||
"input": "1.00000000", | ||
"maxSent": "1.00000000", | ||
"memo": "swapexactin#0#alcordexfund#3.9167 [email protected]#0", | ||
"minReceived": "3.9167", | ||
"output": "3.9285", | ||
"priceImpact": "0.3", | ||
"route": [ | ||
0 | ||
] | ||
} | ||
``` | ||
|
||
Finding the best route for given input/output | ||
|
||
To calculate output amount based on input amount use trade_type <b>EXACT_INPUT</b> | ||
To calculate input amount based on output amount use trade_type <b>EXACT_OUTPUT</b> | ||
|
||
<aside class="notice"> | ||
EXACT_OUTPUT Will charge + 0.3% more imput amount for slippage, and will refund it within swap transaction. | ||
</aside> | ||
|
||
|
||
### HTTP Request | ||
|
||
`GET https://alcor.exchange/api/v2/swapRouter/getRoute` | ||
|
||
**Query params:** | ||
|
||
Name | Type | Description | required | ||
--- | --- | --- | --- | ||
trade_type | string | EXACT_OUTPUT or EXACT_INPUT | true | ||
input | string | Input token ID | true | ||
output | string | Output token ID | true | ||
amount | number | Amount of input/output(depends on trade_type) | true | ||
slippage | number | permissible slippage | false | ||
receiver | string | Account to receive output | false | ||
maxHops | number | Maximum number of intermediate pools for exchange route | false | ||
|
||
### Responce | ||
Name | Type | Description | ||
--- | --- | --- | --- | ||
executionPrice | object | Execution price in format for Price object from Swap-SDK. | ||
input | number | Input Amount | ||
output | number | Output Amount | ||
maxSent | number | Amount(with slippage included) to get exact output | ||
memo | string | Memo for the transfer action | ||
minReceived | number | Amount to receive with max slippage | ||
priceImpact | number | Swap price impact percent | ||
route | array[number] | Sequence of the pools id's that swap will use | ||
|
||
|
||
# Account | ||
Account data api | ||
|
||
## Account Spot Deals | ||
```shell | ||
curl https://alcor.exchange/api/v2/account/<account>/deals | ||
``` | ||
|
||
> The above command returns JSON structured like this: | ||
```json | ||
[ | ||
{ | ||
"_id": "6675d517cbc8490fd50823ab", | ||
"market": 763, | ||
"type": "buymatch", | ||
"trx_id": "14169e8d274786b984917c79f14cefa4e13d2dc823604d47f88a11c116d9e901", | ||
"unit_price": 0.0410099, | ||
"ask": 2.75797508, | ||
"asker": "foreverstone", | ||
"bid": 0.1131, | ||
"bidder": "alcordexfund", | ||
"time": "2024-06-21T19:31:33.000Z" | ||
}, | ||
... | ||
] | ||
``` | ||
|
||
API for getting the spot deals history of a specific account. | ||
|
||
### HTTP Request | ||
`GET https://alcor.exchange/api/v2/account/<account>/deals` | ||
|
||
**Query params:** | ||
|
||
| Name | Type | Description | Required | | ||
|---------|--------|------------------------------|----------| | ||
| account | string | Account ID | true | | ||
| from | number | Start time in seconds | false | | ||
| to | number | End time in seconds | false | | ||
| limit | number | Limit of records to return | false | | ||
| skip | number | Number of records to skip | false | | ||
| market | number | Market ID | false | | ||
|
||
### Response | ||
| Name | Type | Description | | ||
|-------------------|--------|-----------------------------------------| | ||
| _id | string | Deal ID | | ||
| market | number | Market ID | | ||
| type | string | Type of the deal | | ||
| trx_id | string | Transaction ID | | ||
| unit_price | number | Unit price | | ||
| ask | number | Ask amount | | ||
| asker | string | Asker account | | ||
| bid | number | Bid amount | | ||
| bidder | string | Bidder account | | ||
| time | string | Time of the deal | | ||
|
||
|
||
## Account Positions | ||
```shell | ||
curl https://wax.alcor.exchange/api/v2/account/<account>/positions | ||
curl https://alcor.exchange/api/v2/account/<account>/positions | ||
``` | ||
|
||
> The above command returns JSON structured like this: | ||
|
@@ -1012,7 +1135,7 @@ curl https://wax.alcor.exchange/api/v2/account/<account>/positions | |
API for getting all positions belong to specific account | ||
|
||
### HTTP Request | ||
`GET https://wax.alcor.exchange/api/v2/swap/pools/<:pool_id>/positions` | ||
`GET https://alcor.exchange/api/v2/swap/pools/<:pool_id>/positions` | ||
|
||
|
||
**Query params:** | ||
|
@@ -1046,68 +1169,114 @@ inRange | Boolean | is position in range | |
totalValue | number | Total position value in USD | ||
pNl | number | Profit & Loss (totalValue - depositedUSDTotal) | ||
|
||
## Output & Route calculation | ||
|
||
## Account Positions History | ||
```shell | ||
curl "https://alcor.exchange/api/v2/swapRouter/getRoute?trade_type=EXACT_INPUT&input=wax-eosio.token&output=tlm-alien.worlds&amount=1.00000000&slippage=0.30&receiver=alcordexfund&maxHops=2" | ||
curl https://alcor.exchange/api/v2/account/<account>/positions-history | ||
``` | ||
|
||
> The above command returns JSON structured like this: | ||
```json | ||
{ | ||
"executionPrice": { | ||
"denominator": "100000000", | ||
"numerator": "39285" | ||
}, | ||
"input": "1.00000000", | ||
"maxSent": "1.00000000", | ||
"memo": "swapexactin#0#alcordexfund#3.9167 [email protected]#0", | ||
"minReceived": "3.9167", | ||
"output": "3.9285", | ||
"priceImpact": "0.3", | ||
"route": [ | ||
0 | ||
] | ||
} | ||
[ | ||
{ | ||
"_id": "666fe1a9248953a275e29568", | ||
"tokenAUSDPrice": 0.04254746, | ||
"tokenBUSDPrice": 0.622996928304, | ||
"owner": "alcordexfund", | ||
"type": "collect", | ||
"id": 43827, | ||
"pool": 1259, | ||
"tokenA": 740.63011288, | ||
"tokenB": 39.0449, | ||
"totalUSDValue": 55.8368, | ||
"trx_id": "cee97277979cee5ffcfa7df078050ecce9026e87b7b3eced7e517e6b10c9348c", | ||
"time": "2024-06-17T07:11:35.000Z" | ||
}, | ||
... | ||
] | ||
``` | ||
|
||
Finding the best route for given input/output | ||
API for getting the position history of a specific account. | ||
|
||
To calculate output amount based on input amount use trade_type <b>EXACT_INPUT</b> | ||
To calculate input amount based on output amount use trade_type <b>EXACT_OUTPUT</b> | ||
### HTTP Request | ||
`GET https://alcor.exchange/api/v2/account/<account>/positions-history` | ||
|
||
<aside class="notice"> | ||
EXACT_OUTPUT Will charge + 0.3% more imput amount for slippage, and will refund it within swap transaction. | ||
</aside> | ||
**Query params:** | ||
|
||
| Name | Type | Description | Required | | ||
|---------|--------|------------------------------|----------| | ||
| account | string | Account ID | true | | ||
| limit | number | Limit of records to return | false | | ||
| skip | number | Number of records to skip | false | | ||
|
||
### HTTP Request | ||
### Response | ||
| Name | Type | Description | | ||
|-------------------|--------|-----------------------------------------| | ||
| _id | string | Position history ID | | ||
| tokenAUSDPrice | number | Token A USD price | | ||
| tokenBUSDPrice | number | Token B USD price | | ||
| owner | string | Position owner account | | ||
| type | string | Type of the position history | | ||
| id | number | Position history ID | | ||
| pool | number | Pool ID | | ||
| tokenA | number | Token A amount | | ||
| tokenB | number | Token B amount | | ||
| totalUSDValue | number | Total USD value | | ||
| trx_id | string | Transaction ID | | ||
| time | string | Time of the position history | | ||
|
||
|
||
## Account Swap History | ||
```shell | ||
curl https://alcor.exchange/api/v2/account/<account>/swap-history | ||
``` | ||
|
||
`GET https://alcor.exchange/api/v2/swapRouter/getRoute` | ||
> The above command returns JSON structured like this: | ||
```json | ||
[ | ||
{ | ||
"_id": "6670108cebb327bcc470ffc3", | ||
"pool": 1166, | ||
"trx_id": "e9815f8ca7af5d56d08a0163ec98f1142db097ee0d356b49cb3fb2182d596006", | ||
"sender": "alcordexfund", | ||
"sqrtPriceX64": "335692961505657228690", | ||
"totalUSDVolume": 20.3636278111581, | ||
"tokenA": 14027.5692, | ||
"tokenB": -480.37435682, | ||
"time": "2024-06-17T10:31:37.500Z" | ||
}, | ||
... | ||
] | ||
``` | ||
|
||
API for getting the swap history of a specific account. | ||
|
||
### HTTP Request | ||
`GET https://alcor.exchange/api/v2/account/<account>/swap-history` | ||
|
||
**Query params:** | ||
|
||
Name | Type | Description | required | ||
--- | --- | --- | --- | ||
trade_type | string | EXACT_OUTPUT or EXACT_INPUT | true | ||
input | string | Input token ID | true | ||
output | string | Output token ID | true | ||
amount | number | Amount of input/output(depends on trade_type) | true | ||
slippage | number | permissible slippage | false | ||
receiver | string | Account to receive output | false | ||
maxHops | number | Maximum number of intermediate pools for exchange route | false | ||
| Name | Type | Description | Required | | ||
|---------|--------|------------------------------|----------| | ||
| account | string | Account ID | true | | ||
| limit | number | Limit of records to return | false | | ||
| skip | number | Number of records to skip | false | | ||
|
||
### Response | ||
| Name | Type | Description | | ||
|-------------------|--------|-----------------------------------------| | ||
| _id | string | Swap history ID | | ||
| pool | number | Pool ID | | ||
| trx_id | string | Transaction ID | | ||
| sender | string | Swap sender account | | ||
| sqrtPriceX64 | string | Square root price X64 | | ||
| totalUSDVolume | number | Total USD volume | | ||
| tokenA | number | Token A amount | | ||
| tokenB | number | Token B amount | | ||
| time | string | Time of the swap history | | ||
|
||
### Responce | ||
Name | Type | Description | ||
--- | --- | --- | --- | ||
executionPrice | object | Execution price in format for Price object from Swap-SDK. | ||
input | number | Input Amount | ||
output | number | Output Amount | ||
maxSent | number | Amount(with slippage included) to get exact output | ||
memo | string | Memo for the transfer action | ||
minReceived | number | Amount to receive with max slippage | ||
priceImpact | number | Swap price impact percent | ||
route | array[number] | Sequence of the pools id's that swap will use | ||
|
||
# OnChain Data | ||
To fetch data (orders/markets) directly from blockchain you have to use NodeAPI | ||
|