mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-05-01 03:02:45 +08:00
feat: update README.md
This commit is contained in:
41
README.md
41
README.md
@@ -26,21 +26,26 @@ export enum Currency {
|
||||
|
||||
The AlexSDK class includes the following functions:
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
export declare class AlexSDK {
|
||||
getFeeRate(from: Currency, to: Currency): Promise<bigint>;
|
||||
getRouter(from: Currency, to: Currency): Promise<Currency[]>;
|
||||
getAmountTo(from: Currency, fromAmount: bigint, to: Currency): Promise<bigint>;
|
||||
runSwap(stxAddress: string, currencyX: Currency, currencyY: Currency, fromAmount: bigint, minDy: bigint, router: Currency[]): TxToBroadCast;
|
||||
getCurrencyFrom(address: string): Currency | undefined;
|
||||
}
|
||||
getLatestPrices(): Promise<
|
||||
Partial<{
|
||||
[currency in Currency]: number;
|
||||
}>
|
||||
>
|
||||
}
|
||||
```
|
||||
|
||||
### getFee
|
||||
Rate
|
||||
Get the swap fee (liquidity provider fee) between two currencies.
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
async function getFeeRate(from: Currency, to: Currency): Promise<bigint>;
|
||||
```
|
||||
|
||||
@@ -48,7 +53,7 @@ async function getFeeRate(from: Currency, to: Currency): Promise<bigint>;
|
||||
|
||||
Get the router path for swapping between two currencies.
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
async function getRouter(from: Currency, to: Currency): Promise<Currency[]>;
|
||||
```
|
||||
|
||||
@@ -56,7 +61,7 @@ async function getRouter(from: Currency, to: Currency): Promise<Currency[]>;
|
||||
|
||||
Get the amount of destination currency that will be received when swapping from one currency to another.
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
async function getAmountTo(from: Currency, fromAmount: bigint, to: Currency): Promise<bigint>;
|
||||
```
|
||||
|
||||
@@ -64,7 +69,7 @@ async function getAmountTo(from: Currency, fromAmount: bigint, to: Currency): Pr
|
||||
|
||||
Perform a swap between two currencies using the specified route and amount.
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
function runSwap(stxAddress: string, currencyX: Currency, currencyY: Currency, fromAmount: bigint, minDy: bigint, router: Currency[]): TxToBroadCast;
|
||||
```
|
||||
|
||||
@@ -72,7 +77,7 @@ function runSwap(stxAddress: string, currencyX: Currency, currencyY: Currency, f
|
||||
|
||||
Get the corresponding currency for a given address.
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
function getCurrencyFrom(address: string): Currency | undefined;
|
||||
```
|
||||
|
||||
@@ -80,28 +85,40 @@ function getCurrencyFrom(address: string): Currency | undefined;
|
||||
|
||||
Get the corresponding currency for a given address.
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
function getAddressFrom(currency: Exclude<Currency, Currency.STX>): string;
|
||||
```
|
||||
|
||||
### isAlexSwapTransaction
|
||||
|
||||
### getLatestPrices
|
||||
|
||||
Get a list of token prices from Alex's price endpoint
|
||||
```typescript
|
||||
getLatestPrices(): Promise<
|
||||
Partial<{
|
||||
[currency in Currency]: number;
|
||||
}>
|
||||
>
|
||||
```
|
||||
It will do it's best to find the price, and where it can't, it will return undefined.
|
||||
|
||||
Check if a transaction is a swap transaction from Alex
|
||||
```javascript
|
||||
```typescript
|
||||
function isAlexSwapTransaction(deployer: string, contractName: string, functionName: string): boolean;
|
||||
```
|
||||
|
||||
### broadcastSponsoredTx
|
||||
|
||||
Broadcast a sponsored transaction to Alex's sponsored tx services
|
||||
```javascript
|
||||
```typescript
|
||||
function broadcastSponsoredTx(txRaw: string): Promise<string>;
|
||||
````
|
||||
|
||||
### isSponsoredSwapEnabled
|
||||
|
||||
Check if alex's swap sponsor service is activated
|
||||
```javascript
|
||||
```typescript
|
||||
function isSponsoredSwapEnabled(): Promise<boolean>;
|
||||
````
|
||||
|
||||
@@ -117,7 +134,7 @@ npm install alex-sdk
|
||||
|
||||
To use the AlexSDK, you can import it into your project and instantiate a new object:
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
import { AlexSDK, Currency } from 'alex-sdk';
|
||||
|
||||
const alex = new AlexSDK();
|
||||
|
||||
Reference in New Issue
Block a user