mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-01-12 06:14:21 +08:00
Base PR to include ts-doc in sdk library sources (#15)
* add typedoc comments * documentation.md was removed because typedoc is now used * running typedoc * removed docs * added docs into gitignore * irrelevant subtitle removed
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
dist
|
||||
docs
|
||||
23
README.md
23
README.md
@@ -10,28 +10,11 @@ You can install Alex-SDK using npm:
|
||||
npm install alex-sdk
|
||||
```
|
||||
|
||||
## Functions
|
||||
## Documentation
|
||||
|
||||
The AlexSDK class includes the following functions:
|
||||
For detailed API documentation, including a full list of available methods and their usage, please refer to:
|
||||
|
||||
```typescript
|
||||
export declare class AlexSDK {
|
||||
fetchSwappableCurrency(): Promise<TokenInfo[]>;
|
||||
getAllPossibleRoutes(from: Currency, to: Currency): Promise<AMMRoute[]>;
|
||||
getAmountTo(from: Currency, fromAmount: bigint, to: Currency): Promise<bigint>;
|
||||
getBalances(stxAddress: string): Promise<Partial<{ [currency in Currency]: bigint }>>;
|
||||
getFeeRate(from: Currency, to: Currency): Promise<bigint>;
|
||||
getLatestPrices(): Promise<Partial<{ [currency in Currency]: number }>>;
|
||||
getRoute(from: Currency, to: Currency): Promise<AMMRoute>;
|
||||
getRouter(from: Currency, to: Currency): Promise<Currency[]>; // deprecated
|
||||
getWayPoints(route: AMMRoute): Promise<TokenInfo[]>;
|
||||
runSwap(stxAddress: string, currencyX: Currency,
|
||||
currencyY: Currency, fromAmount: bigint,
|
||||
minDy: bigint, customRoute: AMMRoute): Promise<TxToBroadCast>;
|
||||
}
|
||||
```
|
||||
|
||||
(detailed list [here](./documentation.md)).
|
||||
[SDK API Documentation](/alex-sdk/).
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
131
documentation.md
131
documentation.md
@@ -1,131 +0,0 @@
|
||||
# API documentation
|
||||
|
||||
## Functions
|
||||
|
||||
The AlexSDK class includes the following functions:
|
||||
|
||||
```typescript
|
||||
export declare class AlexSDK {
|
||||
fetchSwappableCurrency(): Promise<TokenInfo[]>;
|
||||
getAllPossibleRoutes(from: Currency, to: Currency): Promise<AMMRoute[]>;
|
||||
getAmountTo(from: Currency, fromAmount: bigint, to: Currency): Promise<bigint>;
|
||||
getBalances(stxAddress: string): Promise<Partial<{ [currency in Currency]: bigint }>>;
|
||||
getFeeRate(from: Currency, to: Currency): Promise<bigint>;
|
||||
getLatestPrices(): Promise<Partial<{ [currency in Currency]: number }>>;
|
||||
getRoute(from: Currency, to: Currency): Promise<AMMRoute>;
|
||||
getRouter(from: Currency, to: Currency): Promise<Currency[]>; // deprecated
|
||||
getWayPoints(route: AMMRoute): Promise<TokenInfo[]>;
|
||||
runSwap(stxAddress: string, currencyX: Currency,
|
||||
currencyY: Currency, fromAmount: bigint,
|
||||
minDy: bigint, customRoute: AMMRoute): Promise<TxToBroadCast>;
|
||||
}
|
||||
```
|
||||
|
||||
### fetchSwappableCurrency
|
||||
|
||||
This function returns an array of `TokenInfo` objects, each containing detailed information about a supported swappable currency.
|
||||
|
||||
```typescript
|
||||
function fetchSwappableCurrency(): Promise<TokenInfo[]>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`.
|
||||
|
||||
### getAllPossibleRoutes
|
||||
|
||||
This function returns all possible routes for swapping between two specified currencies. It returns an array of AMMRoute, representing possible swap routes.
|
||||
|
||||
```typescript
|
||||
async function getAllPossibleRoutes(from: Currency, to: Currency): Promise<AMMRoute[]>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`, `Can't find route`.
|
||||
|
||||
### getAmountTo
|
||||
|
||||
Get the amount of destination currency that will be received when swapping from one currency to another.
|
||||
|
||||
```typescript
|
||||
async function getAmountTo(from: Currency, fromAmount: bigint, to: Currency): Promise<bigint>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`, `No AMM pool found for the given route`, `Too many AMM pools in route`, `Error calling read-only function`.
|
||||
|
||||
### getBalances
|
||||
|
||||
This function fetches the current balances of all supported tokens for a specified STX address. It returns an object where the keys are the currency identifiers (as defined in the `Currency` enum) and the values are the corresponding balances as `bigint` values.
|
||||
|
||||
```typescript
|
||||
async function getBalances(stxAddress: string): Promise<Partial<{ [currency in Currency]: bigint }>>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`.
|
||||
|
||||
### getFeeRate
|
||||
|
||||
Get the swap fee (liquidity provider fee) between two currencies.
|
||||
|
||||
```typescript
|
||||
async function getFeeRate(from: Currency, to: Currency): Promise<bigint>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`, `No AMM pools in route`, `Too many AMM pools in route`, `Error calling read-only function`.
|
||||
|
||||
|
||||
### getLatestPrices
|
||||
|
||||
This function fetches the current price data for all supported tokens. It returns an object where the keys are the currency identifiers (as defined in the `Currency` enum) and the values are the corresponding prices in USD.
|
||||
|
||||
```typescript
|
||||
async function getLatestPrices(): Promise<Partial<{ [currency in Currency]: number }>>;
|
||||
```
|
||||
Possible exceptions: `Failed to fetch token mappings`.
|
||||
|
||||
### getRoute
|
||||
|
||||
Get the router path for swapping between two currencies.
|
||||
|
||||
```typescript
|
||||
async function getRoute(from: Currency, to: Currency): Promise<Currency[]>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`, `Can't find route`.
|
||||
|
||||
### getWayPoints
|
||||
|
||||
This function takes an AMMRoute and returns an array of TokenInfo objects representing the tokens involved in each step of the route, including the origin token.
|
||||
|
||||
```typescript
|
||||
async function getWayPoints(route: AMMRoute): Promise<TokenInfo[]>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`.
|
||||
|
||||
### runSwap
|
||||
|
||||
Perform a swap between two currencies using the specified route and amount.
|
||||
|
||||
```typescript
|
||||
async function runSwap(stxAddress: string, currencyX: Currency, currencyY: Currency,
|
||||
fromAmount: bigint, minDy: bigint, customRoute: Currency[]): Promise<TxToBroadCast>;
|
||||
```
|
||||
|
||||
Possible exceptions: `Failed to fetch token mappings`, `Can't find AMM route`, `Token mapping not found`, `Too many AMM pools in route`.
|
||||
|
||||
## Types
|
||||
```typescript
|
||||
export type TokenInfo = { // TokenInfo represents the details of a token that can be used in the AlexSDK.
|
||||
id: Currency; // The unique identifier of the currency.
|
||||
name: string; // The display name of the token that ALEX maintains, usually the token symbol.
|
||||
icon: string; // The URL to the icon image of the token, maintained by ALEX.
|
||||
wrapToken: string; // The full asset id of the alex wrapped token in the format of "{deployer}.{contract}::{asset}".
|
||||
wrapTokenDecimals: number; // The number of decimal places for the wrapped token.
|
||||
underlyingToken: string; // The full asset id of the underlying token in the format of "{deployer}.{contract}::{asset}".
|
||||
underlyingTokenDecimals: number; // The number of decimal places for the underlying token.
|
||||
isRebaseToken: boolean; // A boolean flag indicating whether the token is a rebase token.
|
||||
/**
|
||||
* In a rebase token, getBalance is different from ft-balance
|
||||
* Also postcondition would need to be adjusted since amount is different from ft-events
|
||||
*/
|
||||
};
|
||||
```
|
||||
@@ -21,6 +21,8 @@
|
||||
"lint-fix": "dts lint --fix",
|
||||
"size": "size-limit",
|
||||
"gen:contract": "rm -rf src/generated/smartContract/* && tsx ./scripts/gen-contract.ts && prettier --write 'src/generated/smartContract'",
|
||||
"docs": "typedoc src/index.ts",
|
||||
"docs:watch": "typedoc src/index.ts --watch",
|
||||
"analyze": "size-limit --why",
|
||||
"ci": "pnpm run lint && pnpm run test && pnpm run size"
|
||||
},
|
||||
@@ -72,6 +74,7 @@
|
||||
"ts-json-schema-generator": "^2.3.0",
|
||||
"tslib": "^2.6.3",
|
||||
"tsx": "^4.15.5",
|
||||
"typedoc": "^0.26.6",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
|
||||
101
pnpm-lock.yaml
generated
101
pnpm-lock.yaml
generated
@@ -60,6 +60,9 @@ importers:
|
||||
tsx:
|
||||
specifier: ^4.15.5
|
||||
version: 4.15.5
|
||||
typedoc:
|
||||
specifier: ^0.26.6
|
||||
version: 0.26.6(typescript@5.4.5)
|
||||
typescript:
|
||||
specifier: ^5.4.5
|
||||
version: 5.4.5
|
||||
@@ -1279,6 +1282,12 @@ packages:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@shikijs/core@1.16.1':
|
||||
resolution: {integrity: sha512-aI0hBtw+a6KsJp2jcD4YuQqKpeCbURMZbhHVozDknJpm+KJqeMRkEnfBC8BaKE/5XC+uofPgCLsa/TkTk0Ba0w==}
|
||||
|
||||
'@shikijs/vscode-textmate@9.2.0':
|
||||
resolution: {integrity: sha512-5FinaOp6Vdh/dl4/yaOTh0ZeKch+rYS8DUb38V3GMKYVkdqzxw53lViRKUYkVILRiVQT7dcPC7VvAKOR73zVtQ==}
|
||||
|
||||
'@sinclair/typebox@0.27.8':
|
||||
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
|
||||
|
||||
@@ -1357,6 +1366,9 @@ packages:
|
||||
'@types/graceful-fs@4.1.6':
|
||||
resolution: {integrity: sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==}
|
||||
|
||||
'@types/hast@3.0.4':
|
||||
resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==}
|
||||
|
||||
'@types/istanbul-lib-coverage@2.0.4':
|
||||
resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==}
|
||||
|
||||
@@ -1405,6 +1417,9 @@ packages:
|
||||
'@types/tough-cookie@4.0.5':
|
||||
resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==}
|
||||
|
||||
'@types/unist@3.0.3':
|
||||
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
|
||||
|
||||
'@types/yargs-parser@21.0.0':
|
||||
resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==}
|
||||
|
||||
@@ -3094,6 +3109,9 @@ packages:
|
||||
lines-and-columns@1.2.4:
|
||||
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
|
||||
|
||||
linkify-it@5.0.0:
|
||||
resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==}
|
||||
|
||||
locate-path@5.0.0:
|
||||
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -3145,6 +3163,9 @@ packages:
|
||||
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
lunr@2.3.9:
|
||||
resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==}
|
||||
|
||||
magic-string@0.27.0:
|
||||
resolution: {integrity: sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3162,6 +3183,13 @@ packages:
|
||||
makeerror@1.0.12:
|
||||
resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==}
|
||||
|
||||
markdown-it@14.1.0:
|
||||
resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==}
|
||||
hasBin: true
|
||||
|
||||
mdurl@2.0.0:
|
||||
resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==}
|
||||
|
||||
merge-stream@2.0.0:
|
||||
resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
|
||||
|
||||
@@ -3459,6 +3487,10 @@ packages:
|
||||
pump@3.0.0:
|
||||
resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==}
|
||||
|
||||
punycode.js@2.3.1:
|
||||
resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
punycode@2.3.0:
|
||||
resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -3689,6 +3721,9 @@ packages:
|
||||
engines: {node: '>=4'}
|
||||
hasBin: true
|
||||
|
||||
shiki@1.16.1:
|
||||
resolution: {integrity: sha512-tCJIMaxDVB1mEIJ5TvfZU7kCPB5eo9fli5+21Olc/bmyv+w8kye3JOp+LZRmGkAyT71hrkefQhTiY+o9mBikRQ==}
|
||||
|
||||
side-channel@1.0.4:
|
||||
resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==}
|
||||
|
||||
@@ -3987,11 +4022,21 @@ packages:
|
||||
resolution: {integrity: sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
typedoc@0.26.6:
|
||||
resolution: {integrity: sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==}
|
||||
engines: {node: '>= 18'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x
|
||||
|
||||
typescript@5.4.5:
|
||||
resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
uc.micro@2.1.0:
|
||||
resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
|
||||
|
||||
unbox-primitive@1.0.2:
|
||||
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
|
||||
|
||||
@@ -4155,6 +4200,11 @@ packages:
|
||||
resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
yaml@2.5.0:
|
||||
resolution: {integrity: sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==}
|
||||
engines: {node: '>= 14'}
|
||||
hasBin: true
|
||||
|
||||
yargs-parser@21.1.1:
|
||||
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -5570,6 +5620,13 @@ snapshots:
|
||||
optionalDependencies:
|
||||
rollup: 3.29.4
|
||||
|
||||
'@shikijs/core@1.16.1':
|
||||
dependencies:
|
||||
'@shikijs/vscode-textmate': 9.2.0
|
||||
'@types/hast': 3.0.4
|
||||
|
||||
'@shikijs/vscode-textmate@9.2.0': {}
|
||||
|
||||
'@sinclair/typebox@0.27.8': {}
|
||||
|
||||
'@sinonjs/commons@3.0.1':
|
||||
@@ -5668,6 +5725,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/node': 20.14.2
|
||||
|
||||
'@types/hast@3.0.4':
|
||||
dependencies:
|
||||
'@types/unist': 3.0.3
|
||||
|
||||
'@types/istanbul-lib-coverage@2.0.4': {}
|
||||
|
||||
'@types/istanbul-lib-report@3.0.0':
|
||||
@@ -5713,6 +5774,8 @@ snapshots:
|
||||
|
||||
'@types/tough-cookie@4.0.5': {}
|
||||
|
||||
'@types/unist@3.0.3': {}
|
||||
|
||||
'@types/yargs-parser@21.0.0': {}
|
||||
|
||||
'@types/yargs@17.0.32':
|
||||
@@ -8001,6 +8064,10 @@ snapshots:
|
||||
|
||||
lines-and-columns@1.2.4: {}
|
||||
|
||||
linkify-it@5.0.0:
|
||||
dependencies:
|
||||
uc.micro: 2.1.0
|
||||
|
||||
locate-path@5.0.0:
|
||||
dependencies:
|
||||
p-locate: 4.1.0
|
||||
@@ -8050,6 +8117,8 @@ snapshots:
|
||||
dependencies:
|
||||
yallist: 4.0.0
|
||||
|
||||
lunr@2.3.9: {}
|
||||
|
||||
magic-string@0.27.0:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.4.15
|
||||
@@ -8068,6 +8137,17 @@ snapshots:
|
||||
dependencies:
|
||||
tmpl: 1.0.5
|
||||
|
||||
markdown-it@14.1.0:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
entities: 4.5.0
|
||||
linkify-it: 5.0.0
|
||||
mdurl: 2.0.0
|
||||
punycode.js: 2.3.1
|
||||
uc.micro: 2.1.0
|
||||
|
||||
mdurl@2.0.0: {}
|
||||
|
||||
merge-stream@2.0.0: {}
|
||||
|
||||
merge2@1.4.1: {}
|
||||
@@ -8356,6 +8436,8 @@ snapshots:
|
||||
end-of-stream: 1.4.4
|
||||
once: 1.4.0
|
||||
|
||||
punycode.js@2.3.1: {}
|
||||
|
||||
punycode@2.3.0: {}
|
||||
|
||||
pure-rand@6.1.0: {}
|
||||
@@ -8595,6 +8677,12 @@ snapshots:
|
||||
interpret: 1.4.0
|
||||
rechoir: 0.6.2
|
||||
|
||||
shiki@1.16.1:
|
||||
dependencies:
|
||||
'@shikijs/core': 1.16.1
|
||||
'@shikijs/vscode-textmate': 9.2.0
|
||||
'@types/hast': 3.0.4
|
||||
|
||||
side-channel@1.0.4:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
@@ -8942,8 +9030,19 @@ snapshots:
|
||||
is-typed-array: 1.1.13
|
||||
possible-typed-array-names: 1.0.0
|
||||
|
||||
typedoc@0.26.6(typescript@5.4.5):
|
||||
dependencies:
|
||||
lunr: 2.3.9
|
||||
markdown-it: 14.1.0
|
||||
minimatch: 9.0.5
|
||||
shiki: 1.16.1
|
||||
typescript: 5.4.5
|
||||
yaml: 2.5.0
|
||||
|
||||
typescript@5.4.5: {}
|
||||
|
||||
uc.micro@2.1.0: {}
|
||||
|
||||
unbox-primitive@1.0.2:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
@@ -9116,6 +9215,8 @@ snapshots:
|
||||
|
||||
yaml@1.10.2: {}
|
||||
|
||||
yaml@2.5.0: {}
|
||||
|
||||
yargs-parser@21.1.1: {}
|
||||
|
||||
yargs@17.7.2:
|
||||
|
||||
@@ -45,10 +45,11 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the list of currencies that can be swapped on the DEX.
|
||||
* This function returns an array of TokenInfo objects, each containing detailed
|
||||
* information about a supported swappable currency.
|
||||
*
|
||||
* @returns {Promise<TokenInfo[]>} - A promise that resolves to an array of TokenInfo objects,
|
||||
* representing the swappable currencies.
|
||||
* @returns {Promise<TokenInfo[]>} - A promise that resolves to an array of
|
||||
* `TokenInfo` objects representing the currencies available for swaps.
|
||||
*/
|
||||
fetchSwappableCurrency(): Promise<TokenInfo[]> {
|
||||
return this.getTokenInfos();
|
||||
@@ -59,12 +60,13 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all possible routes for swapping from one currency to another.
|
||||
* This function returns all possible routes for swapping between two specified currencies.
|
||||
* It returns an array of AMMRoute, representing possible swap routes.
|
||||
*
|
||||
* @param {Currency} from - The currency to swap from.
|
||||
* @param {Currency} to - The currency to swap to.
|
||||
* @returns {Promise<AMMRoute[]>} - A promise that resolves to an array of AMMRoute objects,
|
||||
* representing all possible routes for the swap.
|
||||
* representing all possible swap routes between the two specified currencies.
|
||||
*/
|
||||
async getAllPossibleRoutes(
|
||||
from: Currency,
|
||||
@@ -74,7 +76,7 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the best route for swapping from one currency to another.
|
||||
* Get the router path for swapping between two currencies.
|
||||
*
|
||||
* @param {Currency} from - The currency to swap from.
|
||||
* @param {Currency} to - The currency to swap to.
|
||||
@@ -85,7 +87,8 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the detailed route information.
|
||||
* This function takes an AMMRoute and returns an array of TokenInfo objects representing
|
||||
* the tokens involved in each step of the route, including the origin token.
|
||||
*
|
||||
* @param {AMMRoute} route - The route to display.
|
||||
* @returns {Promise<TokenInfo[]>} - A promise that resolves to an array of TokenInfo objects,
|
||||
@@ -101,7 +104,7 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the fee rate for a swap between two currencies.
|
||||
* Get the swap fee (liquidity provider fee) between two currencies.
|
||||
*
|
||||
* @param {Currency} from - The currency to swap from.
|
||||
* @param {Currency} to - The currency to swap to.
|
||||
@@ -123,7 +126,7 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the amount of the destination currency that will be received for a given amount of the source currency.
|
||||
* Get the amount of destination currency that will be received when swapping from one currency to another.
|
||||
*
|
||||
* @param {Currency} from - The currency to swap from.
|
||||
* @param {bigint} fromAmount - The amount of the source currency to swap.
|
||||
@@ -148,7 +151,7 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a swap transaction between two currencies.
|
||||
* Perform a swap between two currencies using the specified route and amount.
|
||||
*
|
||||
* @param {string} stxAddress - The Stacks (STX) address to execute the swap from.
|
||||
* @param {Currency} currencyX - The currency to swap from.
|
||||
@@ -179,7 +182,8 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the latest prices for all supported currencies.
|
||||
* This function fetches the current price data for all supported tokens. It returns an object where
|
||||
* the keys are the currency identifiers (as defined in the Currency enum) and the values are the corresponding prices in USD.
|
||||
*
|
||||
* @returns {Promise<Partial<{ [currency in Currency]: number }>>} - A promise that resolves to an object containing the latest prices for each currency.
|
||||
*/
|
||||
@@ -193,7 +197,9 @@ export class AlexSDK {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the balances of all supported currencies for a given Stacks (STX) address.
|
||||
* This function fetches the current balances of all supported tokens for a specified STX address.
|
||||
* It returns an object where the keys are the currency identifiers (as defined in the Currency enum)
|
||||
* and the values are the corresponding balances as bigint values.
|
||||
*
|
||||
* @param {string} stxAddress - The Stacks (STX) address to retrieve the balances for.
|
||||
* @returns {Promise<Partial<{ [currency in Currency]: bigint }>>} - A promise that resolves to an object containing the balances of each currency for the given address.
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
/**
|
||||
* This type is a string used to represent different tokens in the AlexSDK.
|
||||
* It use a unique symbol to distinguish it from regular strings and refers to specific currencies such as `STX`, `ALEX`, and others.
|
||||
*/
|
||||
export type Currency = string & {
|
||||
readonly brand: unique symbol;
|
||||
};
|
||||
|
||||
// ignore duplicate
|
||||
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
||||
/** The `Currency` namespace contains predefined constants for tokens in the AlexSDK.*/
|
||||
export namespace Currency {
|
||||
/** Represents the `STX` token */
|
||||
export const STX = createCurrency('token-wstx');
|
||||
/** Represents the `ALEX` token*/
|
||||
export const ALEX = createCurrency('age000-governance-token');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user