@ultrade/ultrade-js-sdk 0.2.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/algodService.d.ts +35 -0
- package/dist/client.d.ts +143 -0
- package/dist/enums.d.ts +34 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1205 -5
- package/dist/interfaces.d.ts +136 -0
- package/dist/localStorage.d.ts +9 -0
- package/dist/sockets.d.ts +30 -0
- package/dist/utils.d.ts +2 -4
- package/package.json +26 -39
- package/README.md +0 -39
- package/dist/amm.d.ts +0 -345
- package/dist/amm.js +0 -1295
- package/dist/artifacts/master.d.ts +0 -14
- package/dist/artifacts/master.js +0 -89
- package/dist/artifacts/pool.d.ts +0 -25
- package/dist/artifacts/pool.js +0 -123
- package/dist/artifacts/stable.d.ts +0 -25
- package/dist/artifacts/stable.js +0 -155
- package/dist/constants.d.ts +0 -6
- package/dist/constants.js +0 -9
- package/dist/types.d.ts +0 -57
- package/dist/types.js +0 -2
- package/dist/utils.js +0 -53
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { STREAMS } from "./enums";
|
|
2
|
+
export interface Signer {
|
|
3
|
+
signAndSend: ([]: Iterable<any, void, undefined>) => any;
|
|
4
|
+
signMessage: (msg: string, encoding?: BufferEncoding) => Promise<string>;
|
|
5
|
+
signMessageByToken: (msg: string, encoding?: BufferEncoding) => Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
export interface TelegramData {
|
|
8
|
+
auth_date: number;
|
|
9
|
+
id: number;
|
|
10
|
+
first_name: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
photo_url: string;
|
|
13
|
+
username: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AppSocketState {
|
|
16
|
+
address: string;
|
|
17
|
+
appId: number;
|
|
18
|
+
orderFilter: string;
|
|
19
|
+
pairKey: string;
|
|
20
|
+
pairId: number;
|
|
21
|
+
}
|
|
22
|
+
export interface AuthCredentials {
|
|
23
|
+
company: string;
|
|
24
|
+
clientId?: string;
|
|
25
|
+
clientSecret?: string;
|
|
26
|
+
mnemonic?: string;
|
|
27
|
+
signer: Signer;
|
|
28
|
+
}
|
|
29
|
+
export interface WalletCredentials {
|
|
30
|
+
address: string;
|
|
31
|
+
chain: string;
|
|
32
|
+
provider: string;
|
|
33
|
+
token: string;
|
|
34
|
+
tradingKey?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface SocketIOClient {
|
|
37
|
+
connected: boolean;
|
|
38
|
+
id: string;
|
|
39
|
+
on: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
40
|
+
off: (event: string, handler?: (...args: unknown[]) => void) => void;
|
|
41
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
42
|
+
onAny: (handler: (event: string, ...args: unknown[]) => void) => void;
|
|
43
|
+
disconnect: () => void;
|
|
44
|
+
io: {
|
|
45
|
+
on: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
46
|
+
off: (event: string, handler?: (...args: unknown[]) => void) => void;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface SocketIOFactory {
|
|
50
|
+
(url: string, options?: unknown): SocketIOClient;
|
|
51
|
+
}
|
|
52
|
+
export interface ClientOptions {
|
|
53
|
+
network: 'mainnet' | 'testnet' | 'local';
|
|
54
|
+
apiUrl?: string;
|
|
55
|
+
algoSdkClient: any;
|
|
56
|
+
websocketUrl: string;
|
|
57
|
+
companyId?: number;
|
|
58
|
+
socketIO: SocketIOFactory;
|
|
59
|
+
}
|
|
60
|
+
export interface CancelOrderArgs {
|
|
61
|
+
orderId: number;
|
|
62
|
+
orderSide: OrderSide;
|
|
63
|
+
orderType: OrderType;
|
|
64
|
+
amount: string;
|
|
65
|
+
price: string;
|
|
66
|
+
baseTokenAddress: string;
|
|
67
|
+
baseChain: string;
|
|
68
|
+
baseCurrency: string;
|
|
69
|
+
baseDecimal: number;
|
|
70
|
+
priceTokenAddress: string;
|
|
71
|
+
priceChain: string;
|
|
72
|
+
priceCurrency: string;
|
|
73
|
+
priceDecimal: number;
|
|
74
|
+
}
|
|
75
|
+
export interface CreateOrderArgs {
|
|
76
|
+
pairId: number;
|
|
77
|
+
companyId: number;
|
|
78
|
+
orderSide: OrderSide;
|
|
79
|
+
orderType: OrderType;
|
|
80
|
+
amount: string;
|
|
81
|
+
price: string;
|
|
82
|
+
decimalPrice: number;
|
|
83
|
+
address: string;
|
|
84
|
+
chainId: number;
|
|
85
|
+
baseTokenAddress: string;
|
|
86
|
+
baseTokenChainId: number;
|
|
87
|
+
baseChain: string;
|
|
88
|
+
baseCurrency: string;
|
|
89
|
+
baseDecimal: number;
|
|
90
|
+
priceTokenAddress: string;
|
|
91
|
+
priceTokenChainId: number;
|
|
92
|
+
priceChain: string;
|
|
93
|
+
priceCurrency: string;
|
|
94
|
+
priceDecimal: number;
|
|
95
|
+
}
|
|
96
|
+
export interface SubscribeOptions {
|
|
97
|
+
symbol: string;
|
|
98
|
+
streams: STREAMS[];
|
|
99
|
+
options: WSOptions;
|
|
100
|
+
}
|
|
101
|
+
interface WSOptions {
|
|
102
|
+
address: string;
|
|
103
|
+
token?: string;
|
|
104
|
+
tradingKey?: string;
|
|
105
|
+
message?: string;
|
|
106
|
+
signature?: string;
|
|
107
|
+
depth?: number;
|
|
108
|
+
companyId?: number;
|
|
109
|
+
interval?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface ServerToClientEvents {
|
|
112
|
+
reconnect: () => void;
|
|
113
|
+
}
|
|
114
|
+
export interface ClientToServerEvents {
|
|
115
|
+
subscribe: (options: SubscribeOptions) => void;
|
|
116
|
+
unsubscribe: (options: SubscribeOptions) => void;
|
|
117
|
+
}
|
|
118
|
+
export interface TxnParams {
|
|
119
|
+
suggestedParams: any;
|
|
120
|
+
from: string;
|
|
121
|
+
to: string;
|
|
122
|
+
amount: number;
|
|
123
|
+
assetIndex?: number;
|
|
124
|
+
}
|
|
125
|
+
export type OrderSide = 'S' | 'B';
|
|
126
|
+
export type OrderType = 'L' | 'I' | 'P' | 'M';
|
|
127
|
+
export interface UserNotification {
|
|
128
|
+
id: number;
|
|
129
|
+
globalNotificationId: number;
|
|
130
|
+
priority: any;
|
|
131
|
+
status: any;
|
|
132
|
+
type: any;
|
|
133
|
+
message: string;
|
|
134
|
+
createdAt: Date;
|
|
135
|
+
}
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WalletCredentials } from './interfaces';
|
|
2
|
+
export declare class LocalStorageService {
|
|
3
|
+
private isBrowser;
|
|
4
|
+
private keys;
|
|
5
|
+
constructor();
|
|
6
|
+
setMainWallet(mainWallet: WalletCredentials): void;
|
|
7
|
+
getMainWallet(): WalletCredentials | null;
|
|
8
|
+
clearMainWallet(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SubscribeOptions, SocketIOFactory, SocketIOClient } from './interfaces';
|
|
2
|
+
export declare class SocketManager {
|
|
3
|
+
private onDisconnect?;
|
|
4
|
+
private onConnectError?;
|
|
5
|
+
private socket;
|
|
6
|
+
private socketPool;
|
|
7
|
+
private websocketUrl;
|
|
8
|
+
private socketIOFactory;
|
|
9
|
+
constructor(url: string, socketIOFactory: SocketIOFactory, onDisconnect?: (socketId: string) => void, onConnectError?: (error: Error) => void);
|
|
10
|
+
private initializeSocket;
|
|
11
|
+
getSocket(): SocketIOClient | null;
|
|
12
|
+
subscribe(subscribeOptions: SubscribeOptions, callback: Function): number;
|
|
13
|
+
unsubscribe(handlerId: number): void;
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
isConnected(): boolean;
|
|
16
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
17
|
+
off(event: string, handler?: (...args: unknown[]) => void): void;
|
|
18
|
+
emit(event: string, ...args: unknown[]): void;
|
|
19
|
+
emitCurrentPair(data: {
|
|
20
|
+
address: string;
|
|
21
|
+
pair: string;
|
|
22
|
+
pair_id: number;
|
|
23
|
+
order_filter: string;
|
|
24
|
+
}): void;
|
|
25
|
+
emitOrderFilter(data: {
|
|
26
|
+
order_filter: string;
|
|
27
|
+
}): void;
|
|
28
|
+
onReconnect(handler: () => void): () => void;
|
|
29
|
+
offReconnect(handler?: () => void): void;
|
|
30
|
+
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
export declare function getMethodByName(contract: ABIContract, name: string): ABIMethod;
|
|
4
|
-
export declare function decodeStateArray(stateArray: any[]): any;
|
|
1
|
+
export declare const unpackData: (data: any) => any;
|
|
2
|
+
export declare const decodeString: (value: Uint8Array) => string;
|
package/package.json
CHANGED
|
@@ -1,47 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultrade/ultrade-js-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"/dist"
|
|
9
|
-
],
|
|
10
|
-
"directories": {
|
|
11
|
-
"test": "tests"
|
|
12
|
-
},
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "This package contains the original js/ts SDK.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
13
8
|
"scripts": {
|
|
14
|
-
"build": "
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
|
|
18
|
-
"prepack": "npm run build",
|
|
19
|
-
"clean": "rm -rf ./dist"
|
|
20
|
-
},
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/ultrade-org/JS-SDK.git"
|
|
24
|
-
},
|
|
25
|
-
"author": "",
|
|
26
|
-
"license": "ISC",
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/ultrade-org/JS-SDK/issues"
|
|
9
|
+
"build:prod": "webpack --config webpack.config.js --env production=true",
|
|
10
|
+
"build:dev": "webpack --config webpack.config.js --env production=false",
|
|
11
|
+
"version:patch": "npm version patch"
|
|
29
12
|
},
|
|
30
|
-
"
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
31
16
|
"devDependencies": {
|
|
32
|
-
"@types/
|
|
33
|
-
"@types/
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"ts-node": "^10.9.1",
|
|
41
|
-
"typescript": "^4.7.4"
|
|
17
|
+
"@types/node": "^18.7.17",
|
|
18
|
+
"@types/webpack": "^5.28.5",
|
|
19
|
+
"ts-loader": "^9.2.3",
|
|
20
|
+
"ts-node": "^10.0.0",
|
|
21
|
+
"typescript": "^5.6.3",
|
|
22
|
+
"webpack": "^5.102.1",
|
|
23
|
+
"webpack-cli": "^6.0.1",
|
|
24
|
+
"webpack-node-externals": "^3.0.0"
|
|
42
25
|
},
|
|
43
|
-
"
|
|
44
|
-
"algosdk": "^2.
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"algosdk": "^2.0.0",
|
|
28
|
+
"axios": "^1.13.2",
|
|
29
|
+
"react-secure-storage": "^1.3.2"
|
|
45
30
|
},
|
|
46
|
-
"
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@ultrade/shared": "^1.0.2"
|
|
33
|
+
}
|
|
47
34
|
}
|
package/README.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Ultrade JS SDK
|
|
2
|
-
|
|
3
|
-
## Warning
|
|
4
|
-
SDK is under development
|
|
5
|
-
## Structure of SDK
|
|
6
|
-
|
|
7
|
-
Three are three classes: `AmmClient`, `TransactionComposer`, `PendingTxnResponse`.
|
|
8
|
-
|
|
9
|
-
`AmmClient` contains main and util functions.
|
|
10
|
-
|
|
11
|
-
main:
|
|
12
|
-
- constructor
|
|
13
|
-
- create a pool for asset a and b
|
|
14
|
-
- bootstrap
|
|
15
|
-
- add liquidity (mint)
|
|
16
|
-
- remove liquidity (burn)
|
|
17
|
-
- swap
|
|
18
|
-
|
|
19
|
-
a main function returns an instance of `TransactionComposer`.
|
|
20
|
-
|
|
21
|
-
utils:
|
|
22
|
-
- get pairs
|
|
23
|
-
- get LP token
|
|
24
|
-
- get pool by assets
|
|
25
|
-
- get pool by LP token
|
|
26
|
-
- get balances of an address
|
|
27
|
-
- get balance of an address per asset
|
|
28
|
-
- check if an address opted in an asset
|
|
29
|
-
|
|
30
|
-
`TransactionComposer` sign transactions with secret key or algorand session wallet and send them to blockchain. it has `signAndSend` public function returns `PendingTxnResponse`
|
|
31
|
-
|
|
32
|
-
`PendingTxnResponse` contains transaction infomation.
|
|
33
|
-
|
|
34
|
-
## Example of Usage
|
|
35
|
-
|
|
36
|
-
Please checkout unit tests in `tests` folder.
|
|
37
|
-
|
|
38
|
-
## License
|
|
39
|
-
MIT
|
package/dist/amm.d.ts
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import algosdk from 'algosdk';
|
|
2
|
-
import { AssetList, IAssetAmt, PoolList, PoolState, TokenPair, StablePoolState } from './types';
|
|
3
|
-
export declare class PendingTxnResponse {
|
|
4
|
-
poolError: string;
|
|
5
|
-
txn: Record<string, any>;
|
|
6
|
-
applicationIndex: number | undefined;
|
|
7
|
-
assetIndex: number | undefined;
|
|
8
|
-
closeRewards: number | undefined;
|
|
9
|
-
closingAmount: number | undefined;
|
|
10
|
-
confirmedRound: number | undefined;
|
|
11
|
-
globalStateDelta: any;
|
|
12
|
-
localStateDelta: any;
|
|
13
|
-
receiverRewards: number | undefined;
|
|
14
|
-
senderRewards: number | undefined;
|
|
15
|
-
innerTxns: Array<any>;
|
|
16
|
-
logs: any;
|
|
17
|
-
constructor(response: Record<string, any>);
|
|
18
|
-
}
|
|
19
|
-
export declare class AmmClient {
|
|
20
|
-
private client;
|
|
21
|
-
private appId;
|
|
22
|
-
private masterContract;
|
|
23
|
-
private poolContract;
|
|
24
|
-
private stableContract;
|
|
25
|
-
private assetsCache;
|
|
26
|
-
private poolsCache;
|
|
27
|
-
/**
|
|
28
|
-
* construct AmmClient
|
|
29
|
-
*
|
|
30
|
-
* @param appId master app id
|
|
31
|
-
* @param cluster one of node
|
|
32
|
-
*/
|
|
33
|
-
constructor(appId: number, client: algosdk.Algodv2);
|
|
34
|
-
getAssetCache(): AssetList;
|
|
35
|
-
getPoolsCache(): PoolList;
|
|
36
|
-
/**
|
|
37
|
-
* get status of current node.
|
|
38
|
-
*
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
getStatus(): Promise<Record<string, any>>;
|
|
42
|
-
/**
|
|
43
|
-
* check if an asset is stable coin.
|
|
44
|
-
*
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
isStableAsset(asset: number): Promise<boolean>;
|
|
48
|
-
/**
|
|
49
|
-
* Returns the common needed parameters for a new transaction.
|
|
50
|
-
*
|
|
51
|
-
* @returns
|
|
52
|
-
*/
|
|
53
|
-
getTransactionParams(): Promise<import("algosdk/dist/types/types/transactions/base").SuggestedParamsWithMinFee>;
|
|
54
|
-
/**
|
|
55
|
-
* returns Algodv2 instance.
|
|
56
|
-
*
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
getAlgodClient(): algosdk.Algodv2;
|
|
60
|
-
/**
|
|
61
|
-
* create a pool for asset A and B.
|
|
62
|
-
*
|
|
63
|
-
* @param sender the sender of transaction
|
|
64
|
-
* @param assetA
|
|
65
|
-
* @param assetB
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
createPair(sender: string, assetA: number, assetB: number, signer: algosdk.TransactionSigner): Promise<{
|
|
69
|
-
confirmedRound: number;
|
|
70
|
-
txIDs: string[];
|
|
71
|
-
methodResults: algosdk.ABIResult[];
|
|
72
|
-
}>;
|
|
73
|
-
/**
|
|
74
|
-
* Add liquidity to A-B pool
|
|
75
|
-
*
|
|
76
|
-
* @param sender the sender of transaction
|
|
77
|
-
* @param aId id of asset A to send the A-B pool
|
|
78
|
-
* @param aAmt amount of asset A
|
|
79
|
-
* @param bId id of asset B
|
|
80
|
-
* @param bAmt amount of asset B to send the A-B pool
|
|
81
|
-
* @param mintAmt
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
addLiquidity(sender: string, aId: number, aAmt: number | bigint, bId: number, bAmt: number | bigint, mintAmt: number | bigint, signer: algosdk.TransactionSigner): Promise<{
|
|
85
|
-
confirmedRound: number;
|
|
86
|
-
txIDs: string[];
|
|
87
|
-
methodResults: algosdk.ABIResult[];
|
|
88
|
-
}>;
|
|
89
|
-
/**
|
|
90
|
-
* remove liquidity from the pool
|
|
91
|
-
*
|
|
92
|
-
* @param sender the sender of transaction
|
|
93
|
-
* @param poolId
|
|
94
|
-
* @param poolTokenAmt
|
|
95
|
-
* @param aMinAmt
|
|
96
|
-
* @param bMinAmt
|
|
97
|
-
* @returns
|
|
98
|
-
*/
|
|
99
|
-
removeLiquidity(sender: string, poolId: number, poolTokenAmt: number | bigint, aMinAmt: number | bigint, bMinAmt: number | bigint, signer: algosdk.TransactionSigner): Promise<{
|
|
100
|
-
confirmedRound: number;
|
|
101
|
-
txIDs: string[];
|
|
102
|
-
methodResults: algosdk.ABIResult[];
|
|
103
|
-
}>;
|
|
104
|
-
/**
|
|
105
|
-
* swap tokens
|
|
106
|
-
*
|
|
107
|
-
* @param sender the sender of transaction
|
|
108
|
-
* @param inId asset id of input
|
|
109
|
-
* @param inAmt input amount
|
|
110
|
-
* @param outId asset id of output
|
|
111
|
-
* @returns
|
|
112
|
-
*/
|
|
113
|
-
swap(sender: string, inId: number, inAmt: number | bigint, outId: number, slippage: number, signer: algosdk.TransactionSigner): Promise<{
|
|
114
|
-
confirmedRound: number;
|
|
115
|
-
txIDs: string[];
|
|
116
|
-
methodResults: algosdk.ABIResult[];
|
|
117
|
-
}>;
|
|
118
|
-
/**
|
|
119
|
-
* get LP token by asset A and B
|
|
120
|
-
*
|
|
121
|
-
* @param assetA
|
|
122
|
-
* @param assetB
|
|
123
|
-
* @returns
|
|
124
|
-
*/
|
|
125
|
-
getPoolToken(assetA: number, assetB: number): Promise<number>;
|
|
126
|
-
/**
|
|
127
|
-
* get pool app id by asset A and B
|
|
128
|
-
*
|
|
129
|
-
* @param assetA
|
|
130
|
-
* @param assetB
|
|
131
|
-
* @returns
|
|
132
|
-
*/
|
|
133
|
-
getPoolIdByAssets(assetA: number, assetB: number): Promise<number>;
|
|
134
|
-
/**
|
|
135
|
-
* get pool app id by LP token
|
|
136
|
-
* @param tokenId
|
|
137
|
-
* @returns
|
|
138
|
-
*/
|
|
139
|
-
getPoolByToken(tokenId: number): Promise<TokenPair>;
|
|
140
|
-
/**
|
|
141
|
-
* Get pool by asset A id and asset B id
|
|
142
|
-
* @param assetA
|
|
143
|
-
* @param assetB
|
|
144
|
-
* @returns
|
|
145
|
-
*/
|
|
146
|
-
getPoolByAssets(assetA: number, assetB: number): Promise<TokenPair>;
|
|
147
|
-
/**
|
|
148
|
-
* get all pools
|
|
149
|
-
*
|
|
150
|
-
* @returns
|
|
151
|
-
*/
|
|
152
|
-
getPairs(): Promise<TokenPair[]>;
|
|
153
|
-
/**
|
|
154
|
-
* get balances of an address
|
|
155
|
-
*
|
|
156
|
-
* @param address
|
|
157
|
-
* @returns
|
|
158
|
-
*/
|
|
159
|
-
getBalances(address: string): Promise<any>;
|
|
160
|
-
/**
|
|
161
|
-
* get balance of an address per asset
|
|
162
|
-
*
|
|
163
|
-
* @param assetId
|
|
164
|
-
* @param address
|
|
165
|
-
* @returns
|
|
166
|
-
*/
|
|
167
|
-
getBalance(assetId: number, address: string): Promise<number | bigint>;
|
|
168
|
-
/**
|
|
169
|
-
* check if an address opted in an asset
|
|
170
|
-
*
|
|
171
|
-
* @param assetId
|
|
172
|
-
* @param addr
|
|
173
|
-
* @returns
|
|
174
|
-
*/
|
|
175
|
-
isOptedInAsset(assetId: number, addr: string): Promise<boolean>;
|
|
176
|
-
/**
|
|
177
|
-
* get assets of addr
|
|
178
|
-
*
|
|
179
|
-
* @param addr
|
|
180
|
-
* @returns
|
|
181
|
-
*/
|
|
182
|
-
getAssetList(addr: string): Promise<{
|
|
183
|
-
id: any;
|
|
184
|
-
name: any;
|
|
185
|
-
}[]>;
|
|
186
|
-
/**
|
|
187
|
-
* get output amount when a user swap A to B
|
|
188
|
-
*
|
|
189
|
-
* @param assetIn id of input asset
|
|
190
|
-
* @param assetOut id of output asset
|
|
191
|
-
* @param state pool state
|
|
192
|
-
* @param amtIn input amount
|
|
193
|
-
* @returns
|
|
194
|
-
*/
|
|
195
|
-
getSwapOutputByState(assetIn: number, assetOut: number, state: PoolState, amtIn: number | bigint): bigint;
|
|
196
|
-
/**
|
|
197
|
-
* get output amount after swap
|
|
198
|
-
*
|
|
199
|
-
* @param txId transaction id
|
|
200
|
-
* @returns
|
|
201
|
-
*/
|
|
202
|
-
getAmountAfterSwap(txId: string): Promise<number>;
|
|
203
|
-
/**
|
|
204
|
-
* Get liquidity token amounts
|
|
205
|
-
*
|
|
206
|
-
* @param assetA id of asset A to send the A-B pool
|
|
207
|
-
* @param assetAAmt amount of asset A
|
|
208
|
-
* @param assetB id of asset B
|
|
209
|
-
* @param assetBAmt amount of asset B to send the A-B pool
|
|
210
|
-
* @returns int
|
|
211
|
-
*/
|
|
212
|
-
getMintAmt(assetA: number, assetAAmt: number | bigint, assetB: number, assetBAmt: number | bigint): Promise<bigint>;
|
|
213
|
-
/**
|
|
214
|
-
* Get liquidity token amounts by pool state
|
|
215
|
-
*
|
|
216
|
-
* @param state pool state
|
|
217
|
-
* @param assetAAmt amount of asset A
|
|
218
|
-
* @param assetBAmt amount of asset B to send the A-B pool
|
|
219
|
-
* @returns int
|
|
220
|
-
*/
|
|
221
|
-
getMintAmtByState(state: PoolState, assetAAmt: number | bigint, assetBAmt: number | bigint): bigint;
|
|
222
|
-
/**
|
|
223
|
-
* Make opt-in for asset/pool
|
|
224
|
-
*
|
|
225
|
-
* @param sender the sender of transaction
|
|
226
|
-
* @param assetId id of asset/pool
|
|
227
|
-
* @param signer transaction signer
|
|
228
|
-
* @returns
|
|
229
|
-
*/
|
|
230
|
-
prepareOptInTxn(sender: string, assetId: number, signer: algosdk.TransactionSigner): Promise<{
|
|
231
|
-
confirmedRound: number;
|
|
232
|
-
txIDs: string[];
|
|
233
|
-
methodResults: algosdk.ABIResult[];
|
|
234
|
-
}>;
|
|
235
|
-
/**
|
|
236
|
-
* Get assets amounts after pool token burn
|
|
237
|
-
*
|
|
238
|
-
* @param assetA id of asset A
|
|
239
|
-
* @param assetB id of asset B
|
|
240
|
-
* @param burnAmt burn amount
|
|
241
|
-
* @returns
|
|
242
|
-
*/
|
|
243
|
-
getAssetAmtAfterBurnLP(assetA: number, assetB: number, burnAmt: number): Promise<IAssetAmt>;
|
|
244
|
-
/**
|
|
245
|
-
* Get assets amounts after pool token burn by state
|
|
246
|
-
*
|
|
247
|
-
* @param state pool state
|
|
248
|
-
* @param burnAmt burn amount
|
|
249
|
-
* @returns
|
|
250
|
-
*/
|
|
251
|
-
getAssetAmtAfterBurnLPByState(state: PoolState, burnAmt: number): {
|
|
252
|
-
assetA: bigint;
|
|
253
|
-
assetB: bigint;
|
|
254
|
-
};
|
|
255
|
-
/**
|
|
256
|
-
* get input amount from output when a user swap A to B
|
|
257
|
-
*
|
|
258
|
-
* @param assetIn id of input asset
|
|
259
|
-
* @param assetOut id of output asset
|
|
260
|
-
* @param amtOut output amount
|
|
261
|
-
* @returns
|
|
262
|
-
*/
|
|
263
|
-
getSwapInput(assetIn: number, assetOut: number, amtOut: number | bigint): Promise<bigint>;
|
|
264
|
-
/**
|
|
265
|
-
* get input amount from output when a user swap A to B
|
|
266
|
-
*
|
|
267
|
-
* @param assetIn id of input asset
|
|
268
|
-
* @param assetOut id of output asset
|
|
269
|
-
* @param amtOut output amount
|
|
270
|
-
* @param state pool state
|
|
271
|
-
* @returns
|
|
272
|
-
*/
|
|
273
|
-
getSwapInputByState(assetIn: number, assetOut: number, state: PoolState, amtOut: number | bigint): bigint;
|
|
274
|
-
/**
|
|
275
|
-
* get pool ratio
|
|
276
|
-
* @param assetIn id of asset A
|
|
277
|
-
* @param assetOut id of asset B
|
|
278
|
-
* @returns
|
|
279
|
-
*/
|
|
280
|
-
getPoolRatio(assetIn: {
|
|
281
|
-
index: number;
|
|
282
|
-
decimals: number;
|
|
283
|
-
}, assetOut: {
|
|
284
|
-
index: number;
|
|
285
|
-
decimals: number;
|
|
286
|
-
}): Promise<number>;
|
|
287
|
-
/**
|
|
288
|
-
* get pool ratio
|
|
289
|
-
* @param state pool state
|
|
290
|
-
* @param aDecimals decimals of asset A
|
|
291
|
-
* @param bDecimals decimals of asset B
|
|
292
|
-
* @returns
|
|
293
|
-
*/
|
|
294
|
-
getPoolRatioByState(state: PoolState, aDecimals: number, bDecimals: number): number;
|
|
295
|
-
/**
|
|
296
|
-
* Get pool state
|
|
297
|
-
* @param poolId id of pool
|
|
298
|
-
* @returns
|
|
299
|
-
*/
|
|
300
|
-
getPoolState(poolId: number): Promise<PoolState | StablePoolState>;
|
|
301
|
-
/**
|
|
302
|
-
* Get all pool states
|
|
303
|
-
* @returns
|
|
304
|
-
*/
|
|
305
|
-
getPoolStates(): Promise<{
|
|
306
|
-
[key: number]: PoolState;
|
|
307
|
-
}>;
|
|
308
|
-
/**
|
|
309
|
-
* get price impact when a user swaps A to B
|
|
310
|
-
* @param assetA id of asset A
|
|
311
|
-
* @param assetB id of asset B
|
|
312
|
-
* @param inAmt input amout
|
|
313
|
-
* @returns
|
|
314
|
-
*/
|
|
315
|
-
getPriceImpact(assetA: number, assetB: number, inAmt: number): Promise<number>;
|
|
316
|
-
/**
|
|
317
|
-
* get price impact when a user swaps A to B by state
|
|
318
|
-
* @param poolState pool state
|
|
319
|
-
* @param assetA id of asset A
|
|
320
|
-
* @param assetB id of asset B
|
|
321
|
-
* @param inAmt input amout
|
|
322
|
-
* @returns
|
|
323
|
-
*/
|
|
324
|
-
getPriceImpactByState(poolState: PoolState, inId: number, outId: number, inAmt: number): number;
|
|
325
|
-
/**
|
|
326
|
-
* get price impact and swap amount when a user swaps A to B
|
|
327
|
-
* @param assetA id of asset A
|
|
328
|
-
* @param assetB id of asset B
|
|
329
|
-
* @param inAmt input amout
|
|
330
|
-
* @returns
|
|
331
|
-
*/
|
|
332
|
-
getSwapResults(inId: number, outId: number, amount: number | bigint): Promise<{
|
|
333
|
-
swapOutput: bigint;
|
|
334
|
-
swapInput: bigint;
|
|
335
|
-
}>;
|
|
336
|
-
getSwapResultsByState(inId: number, outId: number, state: PoolState, amount: number | bigint): {
|
|
337
|
-
swapOutput: bigint;
|
|
338
|
-
swapInput: bigint;
|
|
339
|
-
};
|
|
340
|
-
private getTmpPoolId;
|
|
341
|
-
private getTmpStablePoolId;
|
|
342
|
-
private getAppState;
|
|
343
|
-
private checkIsPoolExist;
|
|
344
|
-
private getAsset;
|
|
345
|
-
}
|