@ref-finance/ref-sdk 1.1.3
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/LICENSE +21 -0
- package/README.md +1723 -0
- package/dist/constant.d.ts +44 -0
- package/dist/dcl-swap/dcl-pool.d.ts +24 -0
- package/dist/dcl-swap/limit-order.d.ts +32 -0
- package/dist/dcl-swap/swap.d.ts +46 -0
- package/dist/error.d.ts +20 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +8 -0
- package/dist/indexer.d.ts +3 -0
- package/dist/metaIcons.d.ts +4 -0
- package/dist/near.d.ts +16 -0
- package/dist/ref-sdk.cjs.development.css +296 -0
- package/dist/ref-sdk.cjs.development.js +8893 -0
- package/dist/ref-sdk.cjs.development.js.map +1 -0
- package/dist/ref-sdk.cjs.production.min.js +2 -0
- package/dist/ref-sdk.cjs.production.min.js.map +1 -0
- package/dist/ref-sdk.esm.js +8771 -0
- package/dist/ref-sdk.esm.js.map +1 -0
- package/dist/ref-sdk.umd.development.js +8908 -0
- package/dist/ref-sdk.umd.development.js.map +1 -0
- package/dist/ref-sdk.umd.production.min.js +2 -0
- package/dist/ref-sdk.umd.production.min.js.map +1 -0
- package/dist/ref.d.ts +19 -0
- package/dist/stable-swap.d.ts +5 -0
- package/dist/swap-widget/components.d.ts +90 -0
- package/dist/swap-widget/constant.d.ts +25 -0
- package/dist/swap-widget/defaultTokenList.d.ts +120 -0
- package/dist/swap-widget/index.d.ts +4 -0
- package/dist/swap-widget/state.d.ts +49 -0
- package/dist/swap-widget/types.d.ts +40 -0
- package/dist/types.d.ts +129 -0
- package/dist/utils.d.ts +92 -0
- package/dist/v1-swap/instantSwap.d.ts +9 -0
- package/dist/v1-swap/parallelSwapLogic.d.ts +84 -0
- package/dist/v1-swap/pool.d.ts +16 -0
- package/dist/v1-swap/smartRoutingLogic.d.ts +4 -0
- package/dist/v1-swap/swap.d.ts +239 -0
- package/package.json +81 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Pool } from '../types';
|
|
2
|
+
export declare const DEFAULT_PAGE_LIMIT = 100;
|
|
3
|
+
export declare const getRatedPoolDetail: ({ id }: {
|
|
4
|
+
id: string | number;
|
|
5
|
+
}) => Promise<any>;
|
|
6
|
+
export declare const getUnRatedPoolDetail: ({ id }: {
|
|
7
|
+
id: string | number;
|
|
8
|
+
}) => Promise<any>;
|
|
9
|
+
export declare const getStablePools: (stablePools: Pool[]) => Promise<any[]>;
|
|
10
|
+
export declare const getPool: (id: number) => Promise<Pool>;
|
|
11
|
+
export declare const getRefPools: (page?: number, perPage?: number) => Promise<Pool[]>;
|
|
12
|
+
export declare const fetchAllPools: () => Promise<{
|
|
13
|
+
simplePools: Pool[];
|
|
14
|
+
unRatedPools: Pool[];
|
|
15
|
+
ratedPools: Pool[];
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function getSmartRouteSwapActions(pools: any, inputToken: any, outputToken: any, totalInput: any, allTokens: any, maxPathLength?: number, threshold?: number, numberOfRoutesLimit?: number, MAX_NUMBER_PARALLEL_POOLS?: number, decimalsCulledPoolIds?: any[]): any;
|
|
2
|
+
export function stableSmart(pools: any, inputToken: any, outputToken: any, totalInput: any, allTokens: any): Promise<any>;
|
|
3
|
+
export function getExpectedOutputFromActionsORIG(actions: any, outputToken: any): any;
|
|
4
|
+
export function getAverageFeeForRoutes(routes: any, nodeRoutes: any, totalInput: any): number;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { TokenMetadata, Pool, StablePool, EstimateSwapView } from '../types';
|
|
2
|
+
export declare enum PoolMode {
|
|
3
|
+
PARALLEL = "parallel swap",
|
|
4
|
+
SMART = "smart routing",
|
|
5
|
+
SMART_V2 = "stableSmart",
|
|
6
|
+
STABLE = "stable swap"
|
|
7
|
+
}
|
|
8
|
+
export interface SwapParams {
|
|
9
|
+
tokenIn: TokenMetadata;
|
|
10
|
+
tokenOut: TokenMetadata;
|
|
11
|
+
amountIn: string;
|
|
12
|
+
simplePools: Pool[];
|
|
13
|
+
options?: SwapOptions;
|
|
14
|
+
}
|
|
15
|
+
export interface SwapOptions {
|
|
16
|
+
enableSmartRouting?: boolean;
|
|
17
|
+
stablePools?: Pool[];
|
|
18
|
+
stablePoolsDetail?: StablePool[];
|
|
19
|
+
}
|
|
20
|
+
export declare const getSimplePoolEstimate: ({ tokenIn, tokenOut, pool, amountIn, }: {
|
|
21
|
+
tokenIn: TokenMetadata;
|
|
22
|
+
tokenOut: TokenMetadata;
|
|
23
|
+
pool: Pool;
|
|
24
|
+
amountIn: string;
|
|
25
|
+
}) => {
|
|
26
|
+
estimate: string;
|
|
27
|
+
pool: Pool;
|
|
28
|
+
outputToken: string;
|
|
29
|
+
inputToken: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const getStablePoolEstimate: ({ tokenIn, tokenOut, amountIn, stablePool, pool, }: {
|
|
32
|
+
tokenIn: TokenMetadata;
|
|
33
|
+
tokenOut: TokenMetadata;
|
|
34
|
+
amountIn: string;
|
|
35
|
+
stablePool: StablePool;
|
|
36
|
+
pool?: Pool | undefined;
|
|
37
|
+
}) => {
|
|
38
|
+
estimate: string;
|
|
39
|
+
noFeeAmountOut: string;
|
|
40
|
+
pool: {
|
|
41
|
+
rates: {};
|
|
42
|
+
id: number;
|
|
43
|
+
token_account_ids: string[];
|
|
44
|
+
decimals: number[];
|
|
45
|
+
amounts: string[];
|
|
46
|
+
c_amounts: string[];
|
|
47
|
+
total_fee: number;
|
|
48
|
+
shares_total_supply: string;
|
|
49
|
+
amp: number;
|
|
50
|
+
pool_kind: import("../types").StablePoolKind;
|
|
51
|
+
partialAmountIn?: string | undefined;
|
|
52
|
+
};
|
|
53
|
+
outputToken: string;
|
|
54
|
+
inputToken: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @description Get the estimate of the amount of tokenOut that can be received
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
export declare const singlePoolSwap: ({ tokenIn, tokenOut, simplePools, amountIn, stablePools, }: {
|
|
61
|
+
tokenIn: TokenMetadata;
|
|
62
|
+
tokenOut: TokenMetadata;
|
|
63
|
+
simplePools: Pool[];
|
|
64
|
+
amountIn: string;
|
|
65
|
+
stablePools?: StablePool[] | undefined;
|
|
66
|
+
}) => {
|
|
67
|
+
estimate: string;
|
|
68
|
+
noFeeAmountOut: string;
|
|
69
|
+
pool: {
|
|
70
|
+
rates: {};
|
|
71
|
+
id: number;
|
|
72
|
+
token_account_ids: string[];
|
|
73
|
+
decimals: number[];
|
|
74
|
+
amounts: string[];
|
|
75
|
+
c_amounts: string[];
|
|
76
|
+
total_fee: number;
|
|
77
|
+
shares_total_supply: string;
|
|
78
|
+
amp: number;
|
|
79
|
+
pool_kind: import("../types").StablePoolKind;
|
|
80
|
+
partialAmountIn?: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
outputToken: string;
|
|
83
|
+
inputToken: string;
|
|
84
|
+
} | {
|
|
85
|
+
estimate: string;
|
|
86
|
+
pool: Pool;
|
|
87
|
+
outputToken: string;
|
|
88
|
+
inputToken: string;
|
|
89
|
+
} | undefined;
|
|
90
|
+
export declare const getStablePoolsThisPair: ({ tokenInId, tokenOutId, stablePools, }: {
|
|
91
|
+
tokenInId: string;
|
|
92
|
+
tokenOutId: string;
|
|
93
|
+
stablePools: Pool[];
|
|
94
|
+
}) => Pool[];
|
|
95
|
+
export declare const getPoolsByTokens: ({ pools, tokenInId, tokenOutId, }: {
|
|
96
|
+
pools: Pool[];
|
|
97
|
+
tokenInId: string;
|
|
98
|
+
tokenOutId: string;
|
|
99
|
+
}) => Pool[];
|
|
100
|
+
export declare const getPoolEstimate: ({ tokenIn, tokenOut, amountIn, stablePoolDetail, pool, }: {
|
|
101
|
+
tokenIn: TokenMetadata;
|
|
102
|
+
tokenOut: TokenMetadata;
|
|
103
|
+
amountIn: string;
|
|
104
|
+
pool: Pool;
|
|
105
|
+
stablePoolDetail?: StablePool | undefined;
|
|
106
|
+
}) => Promise<{
|
|
107
|
+
estimate: string;
|
|
108
|
+
noFeeAmountOut: string;
|
|
109
|
+
pool: {
|
|
110
|
+
rates: {};
|
|
111
|
+
id: number;
|
|
112
|
+
token_account_ids: string[];
|
|
113
|
+
decimals: number[];
|
|
114
|
+
amounts: string[];
|
|
115
|
+
c_amounts: string[];
|
|
116
|
+
total_fee: number;
|
|
117
|
+
shares_total_supply: string;
|
|
118
|
+
amp: number;
|
|
119
|
+
pool_kind: import("../types").StablePoolKind;
|
|
120
|
+
partialAmountIn?: string | undefined;
|
|
121
|
+
};
|
|
122
|
+
outputToken: string;
|
|
123
|
+
inputToken: string;
|
|
124
|
+
} | {
|
|
125
|
+
estimate: string;
|
|
126
|
+
pool: Pool;
|
|
127
|
+
outputToken: string;
|
|
128
|
+
inputToken: string;
|
|
129
|
+
}>;
|
|
130
|
+
export declare function getHybridStableSmart(tokenIn: TokenMetadata, tokenOut: TokenMetadata, amountIn: string, stablePools: Pool[], stablePoolsDetail: StablePool[], simplePools: Pool[], allTokens: Record<string, TokenMetadata>): Promise<{
|
|
131
|
+
actions: ({
|
|
132
|
+
status: PoolMode;
|
|
133
|
+
pool: {
|
|
134
|
+
partialAmountIn: string;
|
|
135
|
+
id: number;
|
|
136
|
+
tokenIds: string[];
|
|
137
|
+
supplies: {
|
|
138
|
+
[key: string]: string;
|
|
139
|
+
};
|
|
140
|
+
fee: number;
|
|
141
|
+
total_fee?: number | undefined;
|
|
142
|
+
shareSupply: string;
|
|
143
|
+
tvl: number;
|
|
144
|
+
token0_ref_price: string;
|
|
145
|
+
Dex?: string | undefined;
|
|
146
|
+
pool_kind?: "STABLE_SWAP" | "RATED_SWAP" | "SIMPLE_POOL" | undefined;
|
|
147
|
+
rates?: {
|
|
148
|
+
[id: string]: string;
|
|
149
|
+
} | undefined;
|
|
150
|
+
} | {
|
|
151
|
+
partialAmountIn: string;
|
|
152
|
+
rates: {};
|
|
153
|
+
id: number;
|
|
154
|
+
token_account_ids: string[];
|
|
155
|
+
decimals: number[];
|
|
156
|
+
amounts: string[];
|
|
157
|
+
c_amounts: string[];
|
|
158
|
+
total_fee: number;
|
|
159
|
+
shares_total_supply: string;
|
|
160
|
+
amp: number;
|
|
161
|
+
pool_kind: import("../types").StablePoolKind;
|
|
162
|
+
};
|
|
163
|
+
tokens: TokenMetadata[];
|
|
164
|
+
inputToken: string;
|
|
165
|
+
outputToken: string;
|
|
166
|
+
totalInputAmount: string;
|
|
167
|
+
estimate: string;
|
|
168
|
+
noFeeAmountOut: string;
|
|
169
|
+
} | {
|
|
170
|
+
status: PoolMode;
|
|
171
|
+
pool: {
|
|
172
|
+
partialAmountIn: string;
|
|
173
|
+
id: number;
|
|
174
|
+
tokenIds: string[];
|
|
175
|
+
supplies: {
|
|
176
|
+
[key: string]: string;
|
|
177
|
+
};
|
|
178
|
+
fee: number;
|
|
179
|
+
total_fee?: number | undefined;
|
|
180
|
+
shareSupply: string;
|
|
181
|
+
tvl: number;
|
|
182
|
+
token0_ref_price: string;
|
|
183
|
+
Dex?: string | undefined;
|
|
184
|
+
pool_kind?: "STABLE_SWAP" | "RATED_SWAP" | "SIMPLE_POOL" | undefined;
|
|
185
|
+
rates?: {
|
|
186
|
+
[id: string]: string;
|
|
187
|
+
} | undefined;
|
|
188
|
+
} | {
|
|
189
|
+
partialAmountIn: string;
|
|
190
|
+
rates: {};
|
|
191
|
+
id: number;
|
|
192
|
+
token_account_ids: string[];
|
|
193
|
+
decimals: number[];
|
|
194
|
+
amounts: string[];
|
|
195
|
+
c_amounts: string[];
|
|
196
|
+
total_fee: number;
|
|
197
|
+
shares_total_supply: string;
|
|
198
|
+
amp: number;
|
|
199
|
+
pool_kind: import("../types").StablePoolKind;
|
|
200
|
+
};
|
|
201
|
+
tokens: TokenMetadata[];
|
|
202
|
+
inputToken: string;
|
|
203
|
+
outputToken: string;
|
|
204
|
+
totalInputAmount: string;
|
|
205
|
+
estimate: string;
|
|
206
|
+
})[];
|
|
207
|
+
estimate: string;
|
|
208
|
+
} | {
|
|
209
|
+
actions: ({
|
|
210
|
+
tokens: TokenMetadata[];
|
|
211
|
+
inputToken: string;
|
|
212
|
+
outputToken: string;
|
|
213
|
+
status: PoolMode;
|
|
214
|
+
estimate: string;
|
|
215
|
+
noFeeAmountOut: string;
|
|
216
|
+
pool: {
|
|
217
|
+
rates: {};
|
|
218
|
+
id: number;
|
|
219
|
+
token_account_ids: string[];
|
|
220
|
+
decimals: number[];
|
|
221
|
+
amounts: string[];
|
|
222
|
+
c_amounts: string[];
|
|
223
|
+
total_fee: number;
|
|
224
|
+
shares_total_supply: string;
|
|
225
|
+
amp: number;
|
|
226
|
+
pool_kind: import("../types").StablePoolKind;
|
|
227
|
+
partialAmountIn?: string | undefined;
|
|
228
|
+
};
|
|
229
|
+
} | {
|
|
230
|
+
tokens: TokenMetadata[];
|
|
231
|
+
inputToken: string;
|
|
232
|
+
outputToken: string;
|
|
233
|
+
status: PoolMode;
|
|
234
|
+
estimate: string;
|
|
235
|
+
pool: Pool;
|
|
236
|
+
})[];
|
|
237
|
+
estimate: string;
|
|
238
|
+
}>;
|
|
239
|
+
export declare const estimateSwap: ({ tokenIn, tokenOut, amountIn, simplePools, options, }: SwapParams) => Promise<EstimateSwapView[]>;
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.1.3",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"typings": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=10"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start": "tsdx watch",
|
|
14
|
+
"build": "tsdx build --format esm,cjs,umd",
|
|
15
|
+
"test": "tsdx test --passWithNoTests",
|
|
16
|
+
"lint": "tsdx lint",
|
|
17
|
+
"prepare": "tsdx build --format esm,cjs,umd",
|
|
18
|
+
"size": "size-limit",
|
|
19
|
+
"analyze": "size-limit --why"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": ">=16"
|
|
23
|
+
},
|
|
24
|
+
"husky": {
|
|
25
|
+
"hooks": {
|
|
26
|
+
"pre-commit": "tsdx lint"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"prettier": {
|
|
30
|
+
"printWidth": 80,
|
|
31
|
+
"semi": true,
|
|
32
|
+
"singleQuote": true,
|
|
33
|
+
"trailingComma": "es5"
|
|
34
|
+
},
|
|
35
|
+
"name": "@ref-finance/ref-sdk",
|
|
36
|
+
"author": "Ref Finance",
|
|
37
|
+
"module": "dist/ref-sdk.esm.js",
|
|
38
|
+
"size-limit": [
|
|
39
|
+
{
|
|
40
|
+
"path": "dist/ref-sdk.cjs.production.min.js",
|
|
41
|
+
"limit": "10 KB"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"path": "dist/ref-sdk.esm.js",
|
|
45
|
+
"limit": "10 KB"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@react-icons/all-files": "^4.1.0",
|
|
50
|
+
"@size-limit/preset-small-lib": "^8.0.1",
|
|
51
|
+
"@types/react": "^17.0.17",
|
|
52
|
+
"@types/react-dom": "^17.0.6",
|
|
53
|
+
"autoprefixer": "^10.4.12",
|
|
54
|
+
"buffer": "^6.0.3",
|
|
55
|
+
"husky": "^8.0.1",
|
|
56
|
+
"os-browserify": "^0.3.0",
|
|
57
|
+
"postcss": "^8.4.18",
|
|
58
|
+
"process": "^0.11.10",
|
|
59
|
+
"react": "^18.2.0",
|
|
60
|
+
"react-dom": "^18.2.0",
|
|
61
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
62
|
+
"size-limit": "^8.0.1",
|
|
63
|
+
"tailwindcss": "^3.1.8",
|
|
64
|
+
"tsdx": "^0.14.1",
|
|
65
|
+
"tslib": "^2.4.0",
|
|
66
|
+
"typescript": "^4.7.4"
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@near-wallet-selector/core": "^7.0.0",
|
|
70
|
+
"@types/big.js": "^6.1.5",
|
|
71
|
+
"@types/bn.js": "^5.1.1",
|
|
72
|
+
"@types/lodash": "^4.14.182",
|
|
73
|
+
"big.js": "^6.2.1",
|
|
74
|
+
"lodash-es": "^4.17.21",
|
|
75
|
+
"mathjs": "^9.3.0",
|
|
76
|
+
"near-api-js": "0.44.2",
|
|
77
|
+
"lodash": "^4.17.21",
|
|
78
|
+
"bn.js": "^5.2.0",
|
|
79
|
+
"@react-icons/all-files": "^4.1.0"
|
|
80
|
+
}
|
|
81
|
+
}
|