mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-01-12 22:12:16 +08:00
added exceptions
This commit is contained in:
38
README.md
38
README.md
@@ -46,6 +46,13 @@ Get the swap fee (liquidity provider fee) between two currencies.
|
||||
```javascript
|
||||
async function getFeeRate(from: Currency, to: Currency): Promise<bigint>;
|
||||
```
|
||||
Exceptions:
|
||||
```javascript
|
||||
- "Failed to fetch token mappings"
|
||||
- "No AMM pools in route"
|
||||
- "Too many AMM pools in route"
|
||||
- "Error calling read-only function"
|
||||
```
|
||||
|
||||
### getRouter
|
||||
|
||||
@@ -54,6 +61,11 @@ Get the router path for swapping between two currencies.
|
||||
```javascript
|
||||
async function getRouter(from: Currency, to: Currency): Promise<Currency[]>;
|
||||
```
|
||||
Exceptions:
|
||||
```javascript
|
||||
- "Failed to fetch token mappings"
|
||||
- "Can't find route"
|
||||
```
|
||||
|
||||
### getAmountTo
|
||||
|
||||
@@ -62,6 +74,13 @@ Get the amount of destination currency that will be received when swapping from
|
||||
```javascript
|
||||
async function getAmountTo(from: Currency, fromAmount: bigint, to: Currency): Promise<bigint>;
|
||||
```
|
||||
Exceptions:
|
||||
```javascript
|
||||
- "Failed to fetch token mappings"
|
||||
- "No AMM pool found for the given route"
|
||||
- "Too many AMM pools in route"
|
||||
- "Error calling read-only function"
|
||||
```
|
||||
|
||||
### runSwap
|
||||
|
||||
@@ -71,6 +90,13 @@ Perform a swap between two currencies using the specified route and amount.
|
||||
function runSwap(stxAddress: string, currencyX: Currency, currencyY: Currency,
|
||||
fromAmount: bigint, minDy: bigint, router: Currency[]): TxToBroadCast;
|
||||
```
|
||||
Exceptions:
|
||||
```javascript
|
||||
- "Failed to fetch token mappings"
|
||||
- "Can't find AMM route"
|
||||
- "Token mapping not found"
|
||||
- "Too many AMM pools in route"
|
||||
```
|
||||
|
||||
**getLatestPrices**
|
||||
|
||||
@@ -79,6 +105,10 @@ This function fetches the current price data for all supported tokens. It return
|
||||
```javascript
|
||||
async function getLatestPrices(): Promise<Partial<{ [currency in Currency]: number }>>;
|
||||
```
|
||||
Exceptions:
|
||||
```javascript
|
||||
- "Failed to fetch token mappings"
|
||||
```
|
||||
|
||||
**getBalances**
|
||||
|
||||
@@ -87,6 +117,10 @@ This function fetches the current balances of all supported tokens for a specifi
|
||||
```javascript
|
||||
async function getBalances(stxAddress: string): Promise<Partial<{ [currency in Currency]: bigint }>>;
|
||||
```
|
||||
Exceptions:
|
||||
```javascript
|
||||
- "Failed to fetch token mappings"
|
||||
```
|
||||
|
||||
**fetchSwappableCurrency**
|
||||
|
||||
@@ -95,6 +129,10 @@ This function returns an array of `TokenInfo` objects, each containing detailed
|
||||
```javascript
|
||||
function fetchSwappableCurrency(): Promise<TokenInfo[]>;
|
||||
```
|
||||
Exceptions:
|
||||
```javascript
|
||||
- "Failed to fetch token mappings"
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user