@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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1723 -0
  3. package/dist/constant.d.ts +44 -0
  4. package/dist/dcl-swap/dcl-pool.d.ts +24 -0
  5. package/dist/dcl-swap/limit-order.d.ts +32 -0
  6. package/dist/dcl-swap/swap.d.ts +46 -0
  7. package/dist/error.d.ts +20 -0
  8. package/dist/index.d.ts +15 -0
  9. package/dist/index.js +8 -0
  10. package/dist/indexer.d.ts +3 -0
  11. package/dist/metaIcons.d.ts +4 -0
  12. package/dist/near.d.ts +16 -0
  13. package/dist/ref-sdk.cjs.development.css +296 -0
  14. package/dist/ref-sdk.cjs.development.js +8893 -0
  15. package/dist/ref-sdk.cjs.development.js.map +1 -0
  16. package/dist/ref-sdk.cjs.production.min.js +2 -0
  17. package/dist/ref-sdk.cjs.production.min.js.map +1 -0
  18. package/dist/ref-sdk.esm.js +8771 -0
  19. package/dist/ref-sdk.esm.js.map +1 -0
  20. package/dist/ref-sdk.umd.development.js +8908 -0
  21. package/dist/ref-sdk.umd.development.js.map +1 -0
  22. package/dist/ref-sdk.umd.production.min.js +2 -0
  23. package/dist/ref-sdk.umd.production.min.js.map +1 -0
  24. package/dist/ref.d.ts +19 -0
  25. package/dist/stable-swap.d.ts +5 -0
  26. package/dist/swap-widget/components.d.ts +90 -0
  27. package/dist/swap-widget/constant.d.ts +25 -0
  28. package/dist/swap-widget/defaultTokenList.d.ts +120 -0
  29. package/dist/swap-widget/index.d.ts +4 -0
  30. package/dist/swap-widget/state.d.ts +49 -0
  31. package/dist/swap-widget/types.d.ts +40 -0
  32. package/dist/types.d.ts +129 -0
  33. package/dist/utils.d.ts +92 -0
  34. package/dist/v1-swap/instantSwap.d.ts +9 -0
  35. package/dist/v1-swap/parallelSwapLogic.d.ts +84 -0
  36. package/dist/v1-swap/pool.d.ts +16 -0
  37. package/dist/v1-swap/smartRoutingLogic.d.ts +4 -0
  38. package/dist/v1-swap/swap.d.ts +239 -0
  39. package/package.json +81 -0
@@ -0,0 +1,44 @@
1
+ import { TokenMetadata } from './types';
2
+ export declare const FEE_DIVISOR = 10000;
3
+ export declare const STABLE_LP_TOKEN_DECIMALS = 18;
4
+ export declare const RATED_POOL_LP_TOKEN_DECIMALS = 24;
5
+ export declare function getConfig(env?: string | undefined): {
6
+ networkId: string;
7
+ nodeUrl: string;
8
+ walletUrl: string;
9
+ WRAP_NEAR_CONTRACT_ID: string;
10
+ REF_FI_CONTRACT_ID: string;
11
+ REF_TOKEN_ID: string;
12
+ indexerUrl: string;
13
+ explorerUrl: string;
14
+ REF_DCL_SWAP_CONTRACT_ID: string;
15
+ };
16
+ export declare const config: {
17
+ networkId: string;
18
+ nodeUrl: string;
19
+ walletUrl: string;
20
+ WRAP_NEAR_CONTRACT_ID: string;
21
+ REF_FI_CONTRACT_ID: string;
22
+ REF_TOKEN_ID: string;
23
+ indexerUrl: string;
24
+ explorerUrl: string;
25
+ REF_DCL_SWAP_CONTRACT_ID: string;
26
+ };
27
+ export declare const REF_FI_CONTRACT_ID: string;
28
+ export declare const WRAP_NEAR_CONTRACT_ID: string;
29
+ export declare const REF_TOKEN_ID: string;
30
+ export declare const STORAGE_TO_REGISTER_WITH_MFT = "0.1";
31
+ export declare const ONE_YOCTO_NEAR = "0.000000000000000000000001";
32
+ export declare const WNEAR_META_DATA: TokenMetadata;
33
+ export declare const REF_META_DATA: {
34
+ decimals: number;
35
+ icon: string;
36
+ id: string;
37
+ name: string;
38
+ symbol: string;
39
+ };
40
+ export declare const NEAR_META_DATA: TokenMetadata;
41
+ export declare const TokenLinks: Record<string, string>;
42
+ export declare const CONSTANT_D = 1.0001;
43
+ export declare const POINTLEFTRANGE = -800000;
44
+ export declare const POINTRIGHTRANGE = 800000;
@@ -0,0 +1,24 @@
1
+ import { TokenMetadata } from '../types';
2
+ export declare const DCL_POOL_FEE_LIST: number[];
3
+ interface PoolInfo {
4
+ pool_id?: string;
5
+ token_x?: string;
6
+ token_y?: string;
7
+ fee: number;
8
+ point_delta?: number;
9
+ current_point?: number;
10
+ state?: string;
11
+ liquidity?: string;
12
+ liquidity_x?: string;
13
+ max_liquidity_per_point?: string;
14
+ percent?: string;
15
+ total_x?: string;
16
+ total_y?: string;
17
+ tvl?: number;
18
+ token_x_metadata?: TokenMetadata;
19
+ token_y_metadata?: TokenMetadata;
20
+ }
21
+ export declare const getDCLPoolId: (tokenA: string, tokenB: string, fee: number) => string;
22
+ export declare const listDCLPools: () => Promise<any>;
23
+ export declare const getDCLPool: (pool_id: string) => Promise<PoolInfo>;
24
+ export {};
@@ -0,0 +1,32 @@
1
+ import { Transaction } from '../types';
2
+ export interface UserOrderInfo {
3
+ order_id: string;
4
+ owner_id: string;
5
+ pool_id: string;
6
+ point: number;
7
+ sell_token: string;
8
+ created_at: string;
9
+ original_amount: string;
10
+ remain_amount: string;
11
+ cancel_amount: string;
12
+ original_deposit_amount: string;
13
+ swap_earn_amount: string;
14
+ buy_token: string;
15
+ unclaimed_amount: string;
16
+ bought_amount: string;
17
+ }
18
+ export declare const list_history_orders: (AccountId: string) => Promise<any>;
19
+ export declare const list_active_orders: (AccountId: string) => Promise<any>;
20
+ export declare const get_order: (order_id: string) => Promise<any>;
21
+ export declare const find_order: ({ pool_id, point, AccountId, }: {
22
+ pool_id: string;
23
+ point: number;
24
+ AccountId: string;
25
+ }) => Promise<UserOrderInfo>;
26
+ export declare const cancel_order: (order_id: string) => Promise<Transaction[]>;
27
+ export declare const claim_order: (order_id: string) => Transaction[];
28
+ export declare const get_pointorder_range: ({ pool_id, left_point, right_point, }: {
29
+ pool_id: string;
30
+ left_point?: number | undefined;
31
+ right_point?: number | undefined;
32
+ }) => Promise<any>;
@@ -0,0 +1,46 @@
1
+ import { TokenMetadata, Transaction } from '../types';
2
+ interface SwapInfo {
3
+ tokenA: TokenMetadata;
4
+ tokenB: TokenMetadata;
5
+ amountA: string;
6
+ }
7
+ interface DCLSwapProps {
8
+ swapInfo: SwapInfo;
9
+ Swap?: {
10
+ pool_ids: string[];
11
+ min_output_amount: string;
12
+ };
13
+ SwapByOutput?: {
14
+ pool_ids: string[];
15
+ output_amount: string;
16
+ };
17
+ LimitOrderWithSwap?: {
18
+ pool_id: string;
19
+ output_amount: string;
20
+ };
21
+ AccountId: string;
22
+ }
23
+ export declare const DCL_POOL_SPLITER = "|";
24
+ export declare const DCLSwap: ({ Swap, SwapByOutput, LimitOrderWithSwap, AccountId, swapInfo, }: DCLSwapProps) => Promise<Transaction[]>;
25
+ export declare const quote: ({ pool_ids, input_amount, input_token, output_token, tag, }: {
26
+ pool_ids: string[];
27
+ input_token: TokenMetadata;
28
+ output_token: TokenMetadata;
29
+ input_amount: string;
30
+ tag?: string | undefined;
31
+ }) => Promise<any>;
32
+ export declare const list_user_assets: (AccountId: string) => Promise<any>;
33
+ export declare const DCLSwapByInputOnBestPool: ({ tokenA, tokenB, amountA, slippageTolerance, AccountId, }: {
34
+ tokenA: TokenMetadata;
35
+ tokenB: TokenMetadata;
36
+ amountA: string;
37
+ slippageTolerance: number;
38
+ AccountId: string;
39
+ }) => Promise<Transaction[]>;
40
+ export declare const quote_by_output: ({ pool_ids, output_amount, input_token, output_token, }: {
41
+ pool_ids: string[];
42
+ input_token: TokenMetadata;
43
+ output_token: TokenMetadata;
44
+ output_amount: string;
45
+ }) => Promise<any>;
46
+ export {};
@@ -0,0 +1,20 @@
1
+ export declare const formatError: (msg: string) => Error;
2
+ export declare const unNamedError: Error;
3
+ export declare const SameInputTokenError: Error;
4
+ export declare const ZeroInputError: Error;
5
+ export declare const NoPoolError: Error;
6
+ export declare const NotLoginError: Error;
7
+ export declare const SwapRouteError: Error;
8
+ export declare const TokenNotExistError: Error;
9
+ export declare const NoPuiblicKeyError: Error;
10
+ export declare const NoLocalSignerError: Error;
11
+ export declare const InValidAccessKeyError: Error;
12
+ export declare const AccountIdMisMatch: Error;
13
+ export declare const NoCredential: Error;
14
+ export declare const NoAccountIdFound: Error;
15
+ export declare const NoFeeToPool: (fee: number) => Error;
16
+ export declare const DCLInValid: Error;
17
+ export declare const NoPoolOnThisPair: (tokenA: string, tokenB: string) => Error;
18
+ export declare const SlippageError: Error;
19
+ export declare const NoOrderFound: (order_id?: string | undefined) => Error;
20
+ export declare const OrderNoRemainedAmount: Error;
@@ -0,0 +1,15 @@
1
+ export * from './constant';
2
+ export * from './error';
3
+ export * from './utils';
4
+ export * from './v1-swap/instantSwap';
5
+ export * from './v1-swap/pool';
6
+ export * from './types';
7
+ export * from './ref';
8
+ export * from './stable-swap';
9
+ export * from './v1-swap/swap';
10
+ export * from './near';
11
+ export * from './swap-widget';
12
+ export * from './swap-widget/defaultTokenList';
13
+ export * from './dcl-swap/dcl-pool';
14
+ export * from './dcl-swap/swap';
15
+ export * from './dcl-swap/limit-order';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./ref-sdk.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./ref-sdk.cjs.development.js')
8
+ }
@@ -0,0 +1,3 @@
1
+ export declare const getTokenPriceList: () => Promise<any>;
2
+ export declare const getTokens: (reload?: boolean | undefined) => Promise<any>;
3
+ export declare const getWhiteListTokensIndexer: (whiteListIds: string[]) => Promise<unknown[]>;
@@ -0,0 +1,4 @@
1
+ declare const icons: {
2
+ [tokenId: string]: string;
3
+ };
4
+ export default icons;
package/dist/near.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { keyStores, InMemorySigner, providers, transactions as nearTransactions } from 'near-api-js';
2
+ import { Transaction } from './types';
3
+ export declare const getKeyStore: () => keyStores.InMemoryKeyStore | keyStores.BrowserLocalStorageKeyStore;
4
+ export declare const provider: providers.JsonRpcProvider;
5
+ export declare const getMemorySigner: ({ AccountId, keyPath, }: {
6
+ AccountId: string;
7
+ keyPath: string;
8
+ }) => Promise<InMemorySigner>;
9
+ export declare const getSignedTransactionsByMemoryKey: ({ transactionsRef, AccountId, keyPath, }: {
10
+ transactionsRef: Transaction[];
11
+ AccountId: string;
12
+ keyPath: string;
13
+ }) => Promise<nearTransactions.SignedTransaction[]>;
14
+ export declare const sendTransactionsByMemoryKey: ({ signedTransactions, }: {
15
+ signedTransactions: nearTransactions.SignedTransaction[];
16
+ }) => Promise<providers.FinalExecutionOutcome[]>;
@@ -0,0 +1,296 @@
1
+ .__ref-swap-widget-container {
2
+ border-radius: 16px;
3
+ padding: 28px;
4
+ padding-bottom: 16px;
5
+ position: relative;
6
+ max-width: 90%;
7
+ }
8
+
9
+ .__ref-swap-widget-row-flex-center {
10
+ display: flex;
11
+ align-items: center;
12
+ }
13
+
14
+ .__ref-swap-widget-col-flex-start {
15
+ display: flex;
16
+ flex-direction: column;
17
+ align-items: flex-start;
18
+ }
19
+
20
+ .__ref-swap-widget-header {
21
+ justify-content: space-between;
22
+ margin-bottom: 25px;
23
+ }
24
+
25
+ .__ref-swap-widget-header-title {
26
+ font-weight: 700;
27
+ font-size: 20px;
28
+ }
29
+ .__ref-swap-widget-header-button-account {
30
+ font-size: 14px;
31
+ margin-right: 8px;
32
+ padding: 4px 13px;
33
+ border-radius: 25px;
34
+ min-width: 120px;
35
+ justify-content: center;
36
+ }
37
+
38
+ .__ref-swap-widget-header-button-account:hover {
39
+ background: rgba(255, 104, 158, 0.2) !important;
40
+ }
41
+
42
+ .__ref-swap-widget_slippage_selector {
43
+ box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);
44
+ border-radius: 12px;
45
+ position: absolute;
46
+ top: 30px;
47
+ right: 0px;
48
+ padding: 16px;
49
+ padding-right: 20px;
50
+ padding-left: 20px;
51
+ z-index: 100;
52
+ width: 230px;
53
+ font-size: 14px;
54
+ }
55
+
56
+ .__ref-swap-widget_slippage_selector_input_container {
57
+ width: 100%;
58
+ height: 26px;
59
+ margin-right: 4px;
60
+ padding: 2px 10px;
61
+ }
62
+ .__ref-swap-widget_slippage_selector_button {
63
+ font-size: 14px;
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+ padding: 6px 16px;
68
+ }
69
+
70
+ .__ref-swap-widget-opacity-hover:hover {
71
+ opacity: 0.5;
72
+ }
73
+
74
+ .__ref-swap-widget-opacity-active:active {
75
+ opacity: 0.5;
76
+ }
77
+
78
+ .__ref-swap-widger-token-amount {
79
+ padding: 14px;
80
+ padding-bottom: 8px;
81
+ border-radius: 8px;
82
+ display: flex;
83
+ align-items: flex-start;
84
+ }
85
+
86
+ .__ref-swap-widger-token-amount_input {
87
+ width: 100%;
88
+ display: flex;
89
+ flex-direction: column;
90
+ align-items: flex-end;
91
+ }
92
+
93
+ .__ref-swap-widget-token-amount_quick_selector {
94
+ }
95
+
96
+ .__ref-swap-widger-token-amount_balance {
97
+ margin-top: 7px;
98
+ justify-content: space-between;
99
+ }
100
+
101
+ .__ref-swap-widget-token-amount_quick_selector_item {
102
+ font-size: 12px;
103
+ padding: 6px;
104
+ padding-top: 3px;
105
+ padding-bottom: 3px;
106
+ cursor: pointer;
107
+ }
108
+ .__ref-swap-widget-select-token_input {
109
+ padding: 14px;
110
+ border-radius: 8px;
111
+ }
112
+
113
+ .__ref-swap-widget_star_token {
114
+ padding: 8px 10px 8px 8px;
115
+ margin: 0px 6px 10px 0px;
116
+ position: relative;
117
+ cursor: pointer;
118
+ border-radius: 8px;
119
+ }
120
+
121
+ .__ref-swap-widget_token_icon {
122
+ border-radius: 100%;
123
+ flex-shrink: 0;
124
+ }
125
+
126
+ .__ref-swap-widget_token_list_table {
127
+ table-layout: auto;
128
+ width: 100%;
129
+ font-size: 14px;
130
+ }
131
+
132
+ .__ref-swap-widget_token_list_table_header {
133
+ display: flex;
134
+ align-items: center;
135
+ justify-content: space-between;
136
+ padding: 6px 12px;
137
+ margin: 0px 6px;
138
+ }
139
+
140
+ .__ref-swap-widget_token-selector-star-tokens {
141
+ margin-top: 20px;
142
+ flex-wrap: wrap;
143
+ }
144
+ .__ref-swap-widget_token_list_table_content {
145
+ display: flex;
146
+ flex-direction: column;
147
+ max-height: 50vh;
148
+ min-height: 30vh;
149
+ overflow-y: auto;
150
+ }
151
+
152
+ .__ref-swap-widget_token-selector-token-list-item {
153
+ justify-content: space-between;
154
+ padding: 9px 20px;
155
+ }
156
+ .__ref-swap-widget-token-amount_token-select-button {
157
+ font-size: 16px;
158
+ border-radius: 18px;
159
+ padding: 6px 8px;
160
+ cursor: pointer;
161
+ }
162
+
163
+ .__ref-swap-widget-exchange-button {
164
+ width: 100%;
165
+ justify-content: center;
166
+ padding: 20px 0;
167
+ }
168
+
169
+ .__ref-swap-widget-submit-button {
170
+ width: 100%;
171
+ justify-content: center;
172
+ font-size: 18px;
173
+ font-weight: 700;
174
+ border-radius: 8px;
175
+ padding: 14px 0 14px 0;
176
+ margin-top: 14px;
177
+ cursor: pointer;
178
+ }
179
+ .__ref-widget-swap-detail-view {
180
+ justify-content: space-between;
181
+ width: 100%;
182
+ font-size: 14px;
183
+ margin-top: 16px;
184
+ }
185
+
186
+ .__ref-swap-widget-swap-detail-view-item {
187
+ justify-content: space-between;
188
+ margin-bottom: 12px;
189
+ width: 100%;
190
+ }
191
+
192
+ .__ref-swap-widget-loading {
193
+ animation: spin 2s linear infinite;
194
+ }
195
+
196
+ .__ref-swap-widget-notification {
197
+ position: absolute;
198
+ top: 50%;
199
+ left: 50%;
200
+ width: 50%;
201
+ transform: translate(-50%, -50%);
202
+ background: rgba(0, 0, 0, 0.5);
203
+ display: flex;
204
+ flex-direction: column;
205
+ align-items: center;
206
+ justify-content: center;
207
+ z-index: 100;
208
+ box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);
209
+ border-radius: 12px;
210
+ padding: 32px 20px;
211
+ }
212
+
213
+ .__ref-swap-widget-notification__button {
214
+ border-radius: 8px;
215
+ padding: 8px 20px;
216
+ margin-top: 14px;
217
+ }
218
+ @keyframes spin {
219
+ from {
220
+ transform: rotate(0deg);
221
+ }
222
+ to {
223
+ transform: rotate(360deg);
224
+ }
225
+ }
226
+
227
+ input.__ref-swap-widget-input-class {
228
+ margin: 0;
229
+ background-color: transparent;
230
+ display: block;
231
+ width: 100%;
232
+ padding: 0;
233
+ border-width: 0;
234
+ }
235
+
236
+ input.__ref-swap-widget-input-class:focus {
237
+ outline: none;
238
+ border-width: 0;
239
+ }
240
+
241
+ input.__ref-swap-widget-input-class::-webkit-outer-spin-button,
242
+ input.__ref-swap-widget-input-class::-webkit-inner-spin-button {
243
+ -webkit-appearance: none;
244
+ margin: 0;
245
+ }
246
+
247
+ input.__ref-swap-widget-input-class[type='number'] {
248
+ -moz-appearance: textfield; /* Firefox */
249
+ }
250
+
251
+ button.__ref-swap-widget-button {
252
+ border: none;
253
+ }
254
+
255
+ .__ref-swap-widget-submit-button:hover {
256
+ opacity: 0.5;
257
+ }
258
+
259
+ .__ref-swap-widget-active:active {
260
+ color: #00c6a2;
261
+ }
262
+
263
+ .__ref-swap-widget-hover:hover {
264
+ color: #00c6a2;
265
+ }
266
+
267
+ .__ref-swap-widget_token_list_table_content::-webkit-scrollbar {
268
+ width: 4px;
269
+ height: 4px;
270
+ border-radius: 3px;
271
+ }
272
+
273
+ .__ref-swap-widget_token_list_table_content::-webkit-scrollbar-track {
274
+ box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);
275
+ }
276
+ .__ref-swap-widget_token_list_table_content::-webkit-scrollbar-thumb {
277
+ background: #00c6a2;
278
+ border-radius: 8px;
279
+ }
280
+
281
+ .__ref-swap-widget-swap_routes {
282
+ border-radius: 12px;
283
+ padding: 8px 12px 8px 12px;
284
+ width: 100%;
285
+ }
286
+
287
+ .__ref-swap-widget-valueStyle {
288
+ background-image: -webkit-linear-gradient(left, #00ffd1, #00ffd1, #8c78ff);
289
+ -webkit-background-clip: text;
290
+ -webkit-text-fill-color: transparent;
291
+ }
292
+
293
+ .__ref-swap-widget-swap_route_row {
294
+ justify-content: space-between;
295
+ margin-bottom: 4px;
296
+ }