@ref-finance/ref-sdk 1.4.9 → 1.5.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/README.md +21 -19
- package/dist/dcl-swap/swap.d.ts +4 -2
- package/dist/ref-sdk.cjs.development.js +13 -7
- package/dist/ref-sdk.cjs.development.js.map +1 -1
- package/dist/ref-sdk.cjs.production.min.js +1 -1
- package/dist/ref-sdk.cjs.production.min.js.map +1 -1
- package/dist/ref-sdk.esm.js +13 -7
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +13 -7
- package/dist/ref-sdk.umd.development.js.map +1 -1
- package/dist/ref-sdk.umd.production.min.js +1 -1
- package/dist/ref-sdk.umd.production.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,11 +6,6 @@ Our SDK is provided by a third party, and we do not take any responsibility for
|
|
|
6
6
|
This SDK is designed to assist developers when interacting with the main functions of the protocol. Main functions that can be defined as:
|
|
7
7
|
|
|
8
8
|
- Trade: Swap tokens with our Automated Market Maker (AMM).
|
|
9
|
-
- Pool: Add/Remove liquidity and earn revenue from swap fee (Coming soon)
|
|
10
|
-
- Farm: Stale LP tokens into farms and earn liquidity incentives (Coming soon)
|
|
11
|
-
- Boost Farm: Stake LOVE tokens to get boosted liquidity incentives (Coming soon)
|
|
12
|
-
- Stake: Stake REF tokens to earn fees generated by the protocol (Coming soon)
|
|
13
|
-
- Vote: Lock REF<>NEAR LP tokens to get veTokens and participate in the governance of the protocol and the allocation of liquidity incentives (Coming soon)
|
|
14
9
|
|
|
15
10
|
## Install
|
|
16
11
|
|
|
@@ -20,7 +15,7 @@ npm: `npm install @ref-finance/ref-sdk`
|
|
|
20
15
|
|
|
21
16
|
## Initialization
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
Rhea SDK identifies env variable NEAR_ENV or REACT_APP_REF_SDK_ENV to get global configuration.
|
|
24
19
|
|
|
25
20
|
```plain
|
|
26
21
|
export function getConfig(
|
|
@@ -90,7 +85,7 @@ init_env('mainnet', '', 'https://beta.rpc.mainnet.near.org');
|
|
|
90
85
|
|
|
91
86
|
|
|
92
87
|
|
|
93
|
-
##
|
|
88
|
+
## Rhea V1 Swap
|
|
94
89
|
|
|
95
90
|
### Tokens
|
|
96
91
|
|
|
@@ -750,11 +745,11 @@ Response
|
|
|
750
745
|
|
|
751
746
|
|
|
752
747
|
|
|
753
|
-
##
|
|
748
|
+
## Rhea Swap Widget
|
|
754
749
|
|
|
755
750
|
### Description
|
|
756
751
|
|
|
757
|
-
The
|
|
752
|
+
The Rhea Swap Widget is a useful tool, allowing any third party service to access Rhea's liquidity. Users of ecosystem dapps have the ability to swap via the Widget, without the need to go to Rhea app, thus improving the user experience.
|
|
758
753
|
|
|
759
754
|
Here are some use cases:
|
|
760
755
|
|
|
@@ -762,18 +757,18 @@ Here are some use cases:
|
|
|
762
757
|
- Swapping tokens to lend, farm or stake
|
|
763
758
|
- Swapping one token for a specific token, which can be used to buy a NFT in the associated marketplace
|
|
764
759
|
|
|
765
|
-
Using the
|
|
760
|
+
Using the Rhea Swap Widget, with a few customizations, developers can integrate the Swap funtion directly into their dapps. Both mobile and/or website version are available.
|
|
766
761
|

|
|
767
762
|
|
|
768
763
|
For the default theme, developers can chose between the light mode and dark mode.
|
|
769
764
|
|
|
770
765
|
More themes can be selected: [Click here to check them on figma](https://www.figma.com/file/v069nTXfE8pXDJQcDcC5wl/Swap-Widget?node-id=0%3A1).
|
|
771
766
|
|
|
772
|
-
To integrate the
|
|
767
|
+
To integrate the Rhea Swap Widget, please follow this guide.
|
|
773
768
|
|
|
774
769
|
### Getting started
|
|
775
770
|
|
|
776
|
-
A QuickStart of
|
|
771
|
+
A QuickStart of Rhea Swap component.
|
|
777
772
|
|
|
778
773
|
#### Props
|
|
779
774
|
|
|
@@ -807,7 +802,7 @@ export interface SwapWidgetProps {
|
|
|
807
802
|
```
|
|
808
803
|
|
|
809
804
|
- theme: widget theme for customization.
|
|
810
|
-
- defaultTokenList: default tokens with
|
|
805
|
+
- defaultTokenList: default tokens with Rhea whitelist into token list in the widget.
|
|
811
806
|
- onSwap: Swap button triggers this function.
|
|
812
807
|
- width: width of widget component.
|
|
813
808
|
- height: height of widget component.
|
|
@@ -817,7 +812,7 @@ export interface SwapWidgetProps {
|
|
|
817
812
|
- connection: connection to wallets, input { AccountId:"", isSignedIn:false } if wallet not connected.
|
|
818
813
|
- defaultTokenIn: default token-in.
|
|
819
814
|
- defaultTokenOut: default token-out.
|
|
820
|
-
- referralId: You can get referral fee from every swap routed by your app. But make sure that your referral_id is in Ref's referral list. For the details, please check https://gov.ref.finance/t/contract-upgrade-1-7-0-referral-fee/823 .
|
|
815
|
+
- referralId: You can get referral fee from every swap routed by your app. But make sure that your referral_id is in Ref's referral list. For the details, please check https://gov.ref.finance/t/contract-upgrade-1-7-0-referral-fee/823 .
|
|
821
816
|
- transactionState: entry to input transaction states after you send transactions.
|
|
822
817
|
- state: denote if last transaction is failed or successfull.
|
|
823
818
|
- setState: used to change setState to interact with pop-up.
|
|
@@ -967,7 +962,7 @@ export const Widget = ()=>{
|
|
|
967
962
|
}
|
|
968
963
|
```
|
|
969
964
|
|
|
970
|
-
### Integrating
|
|
965
|
+
### Integrating Rhea Swap function using the SDK
|
|
971
966
|
|
|
972
967
|
The SDK provides more flexibility/options.
|
|
973
968
|
|
|
@@ -983,11 +978,11 @@ SDK integration tips:
|
|
|
983
978
|
- For a better user experience, before the execution of the swap, you can show more details about the swap (ex: fee, rate, route, etc.), allowing users to take better data-driven decisions.
|
|
984
979
|
- You can redirect the user to the NEAR Explorer, once the transaction is confirmed.
|
|
985
980
|
|
|
986
|
-
##
|
|
981
|
+
## Rhea V2(DCL) Swap
|
|
987
982
|
|
|
988
|
-
#### An overview of
|
|
983
|
+
#### An overview of Rhea V2
|
|
989
984
|
|
|
990
|
-
The launch of concentrated liquidity AMM is an achievement for
|
|
985
|
+
The launch of concentrated liquidity AMM is an achievement for Rhea Finance. In collaboration with Izumi Finance and Arctic, Rhea is glad to introduce discretized concentrated liquidity and limit order two new key features to the NEAR ecosystem. Using Rhea SDK, developers can dig more opportunities and implement various trading strategies.Before introducing SDK details, let's have an overview of V2 exciting features.
|
|
991
986
|
|
|
992
987
|
#### Discretized concentrated liquidity
|
|
993
988
|
|
|
@@ -1291,6 +1286,7 @@ interface DCLSwapProps {
|
|
|
1291
1286
|
skip_unwrap_near: boolean;
|
|
1292
1287
|
};
|
|
1293
1288
|
AccountId: string;
|
|
1289
|
+
referralId?: string;
|
|
1294
1290
|
}
|
|
1295
1291
|
```
|
|
1296
1292
|
|
|
@@ -1321,6 +1317,7 @@ const res = await DCLSwap({
|
|
|
1321
1317
|
pool_ids,
|
|
1322
1318
|
},
|
|
1323
1319
|
AccountId,
|
|
1320
|
+
referralId: 'ref-fee.testnet', // optional: referral ID to earn referral fees
|
|
1324
1321
|
});
|
|
1325
1322
|
```
|
|
1326
1323
|
|
|
@@ -1375,6 +1372,7 @@ const res = await DCLSwap({
|
|
|
1375
1372
|
output_amount: "4.89454792",
|
|
1376
1373
|
},
|
|
1377
1374
|
AccountId,
|
|
1375
|
+
referralId: 'ref-fee.testnet', // optional: referral ID to earn referral fees
|
|
1378
1376
|
});
|
|
1379
1377
|
```
|
|
1380
1378
|
|
|
@@ -1426,9 +1424,10 @@ const res = await DCLSwap({
|
|
|
1426
1424
|
},
|
|
1427
1425
|
LimitOrderWithSwap: {
|
|
1428
1426
|
pool_id,
|
|
1429
|
-
|
|
1427
|
+
output_amount: "3217.929",
|
|
1430
1428
|
},
|
|
1431
1429
|
AccountId,
|
|
1430
|
+
referralId: 'ref-fee.testnet', // optional: referral ID to earn referral fees
|
|
1432
1431
|
});
|
|
1433
1432
|
```
|
|
1434
1433
|
|
|
@@ -1484,6 +1483,7 @@ const res = await DCLSwap({
|
|
|
1484
1483
|
stop_point: 405920,
|
|
1485
1484
|
},
|
|
1486
1485
|
AccountId,
|
|
1486
|
+
referralId: 'ref-fee.testnet', // optional: referral ID to earn referral fees
|
|
1487
1487
|
});
|
|
1488
1488
|
```
|
|
1489
1489
|
|
|
@@ -1526,6 +1526,7 @@ Parameters
|
|
|
1526
1526
|
amountA: string;
|
|
1527
1527
|
slippageTolerance: number;
|
|
1528
1528
|
AccountId: string;
|
|
1529
|
+
referralId?: string;
|
|
1529
1530
|
}
|
|
1530
1531
|
```
|
|
1531
1532
|
|
|
@@ -1547,6 +1548,7 @@ const res = await DCLSwapByInputOnBestPool({
|
|
|
1547
1548
|
amountA: "1",
|
|
1548
1549
|
slippageTolerance: 0.1,
|
|
1549
1550
|
AccountId,
|
|
1551
|
+
referralId: 'ref-fee.testnet', // optional: referral ID to earn referral fees
|
|
1550
1552
|
});
|
|
1551
1553
|
```
|
|
1552
1554
|
|
package/dist/dcl-swap/swap.d.ts
CHANGED
|
@@ -24,9 +24,10 @@ interface DCLSwapProps {
|
|
|
24
24
|
skip_unwrap_near: boolean;
|
|
25
25
|
};
|
|
26
26
|
AccountId: string;
|
|
27
|
+
referralId?: string;
|
|
27
28
|
}
|
|
28
29
|
export declare const DCL_POOL_SPLITER = "|";
|
|
29
|
-
export declare const DCLSwap: ({ Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, }: DCLSwapProps) => Promise<Transaction[]>;
|
|
30
|
+
export declare const DCLSwap: ({ Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, referralId, }: DCLSwapProps) => Promise<Transaction[]>;
|
|
30
31
|
export declare const quote: ({ pool_ids, input_amount, input_token, output_token, tag, }: {
|
|
31
32
|
pool_ids: string[];
|
|
32
33
|
input_token: TokenMetadata;
|
|
@@ -35,12 +36,13 @@ export declare const quote: ({ pool_ids, input_amount, input_token, output_token
|
|
|
35
36
|
tag?: string | undefined;
|
|
36
37
|
}) => Promise<any>;
|
|
37
38
|
export declare const list_user_assets: (AccountId: string) => Promise<any>;
|
|
38
|
-
export declare const DCLSwapByInputOnBestPool: ({ tokenA, tokenB, amountA, slippageTolerance, AccountId, }: {
|
|
39
|
+
export declare const DCLSwapByInputOnBestPool: ({ tokenA, tokenB, amountA, slippageTolerance, AccountId, referralId, }: {
|
|
39
40
|
tokenA: TokenMetadata;
|
|
40
41
|
tokenB: TokenMetadata;
|
|
41
42
|
amountA: string;
|
|
42
43
|
slippageTolerance: number;
|
|
43
44
|
AccountId: string;
|
|
45
|
+
referralId?: string | undefined;
|
|
44
46
|
}) => Promise<Transaction[]>;
|
|
45
47
|
export declare const quote_by_output: ({ pool_ids, output_amount, input_token, output_token, }: {
|
|
46
48
|
pool_ids: string[];
|
|
@@ -7795,12 +7795,12 @@ function getDefaultTokenList() {
|
|
|
7795
7795
|
var DCL_POOL_SPLITER = '|';
|
|
7796
7796
|
var DCLSwap = /*#__PURE__*/function () {
|
|
7797
7797
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
7798
|
-
var Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, transactions, tokenA, tokenB, amountA, pool_ids, tokenRegistered, output_token, min_output_amount, msg, _pool_ids, _output_token, output_amount, _msg, _tokenRegistered, pool_id, fee, buy_token, point, _tokenRegistered2, DCLRegistered, new_point, _msg2, _tokenRegistered3, _msg3, registered;
|
|
7798
|
+
var Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, referralId, transactions, tokenA, tokenB, amountA, pool_ids, tokenRegistered, output_token, min_output_amount, msg, _pool_ids, _output_token, output_amount, _msg, _tokenRegistered, pool_id, fee, buy_token, point, _tokenRegistered2, DCLRegistered, new_point, _msg2, _tokenRegistered3, _msg3, registered;
|
|
7799
7799
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
7800
7800
|
while (1) {
|
|
7801
7801
|
switch (_context.prev = _context.next) {
|
|
7802
7802
|
case 0:
|
|
7803
|
-
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
|
|
7803
|
+
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo, referralId = _ref.referralId;
|
|
7804
7804
|
transactions = [];
|
|
7805
7805
|
tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
|
|
7806
7806
|
if (!Swap) {
|
|
@@ -7827,6 +7827,7 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7827
7827
|
pool_ids: pool_ids,
|
|
7828
7828
|
output_token: output_token,
|
|
7829
7829
|
min_output_amount: min_output_amount,
|
|
7830
|
+
referral_id: referralId || '',
|
|
7830
7831
|
client_id: ''
|
|
7831
7832
|
}
|
|
7832
7833
|
});
|
|
@@ -7858,6 +7859,7 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7858
7859
|
pool_ids: _pool_ids,
|
|
7859
7860
|
output_token: _output_token,
|
|
7860
7861
|
output_amount: output_amount,
|
|
7862
|
+
referral_id: referralId || '',
|
|
7861
7863
|
client_id: ''
|
|
7862
7864
|
}
|
|
7863
7865
|
});
|
|
@@ -7941,7 +7943,8 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7941
7943
|
pool_id: pool_id,
|
|
7942
7944
|
buy_token: buy_token,
|
|
7943
7945
|
point: new_point,
|
|
7944
|
-
client_id: ''
|
|
7946
|
+
client_id: '',
|
|
7947
|
+
referral_id: referralId || ''
|
|
7945
7948
|
}
|
|
7946
7949
|
});
|
|
7947
7950
|
transactions.push({
|
|
@@ -7977,7 +7980,9 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7977
7980
|
});
|
|
7978
7981
|
}
|
|
7979
7982
|
_msg3 = JSON.stringify({
|
|
7980
|
-
SwapByStopPoint: SwapByStopPoint
|
|
7983
|
+
SwapByStopPoint: _extends({}, SwapByStopPoint, {
|
|
7984
|
+
referral_id: referralId || ''
|
|
7985
|
+
})
|
|
7981
7986
|
});
|
|
7982
7987
|
transactions.push({
|
|
7983
7988
|
receiverId: tokenA.id,
|
|
@@ -8081,12 +8086,12 @@ var list_user_assets = /*#__PURE__*/function () {
|
|
|
8081
8086
|
var DCLSwapByInputOnBestPool = /*#__PURE__*/function () {
|
|
8082
8087
|
var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref6) {
|
|
8083
8088
|
var _bestEstimate$tag, _bestEstimate$tag$spl, _bestEstimate$tag2, _bestEstimate$tag2$sp;
|
|
8084
|
-
var tokenA, tokenB, amountA, slippageTolerance, AccountId, estimates, bestEstimate, bestFee;
|
|
8089
|
+
var tokenA, tokenB, amountA, slippageTolerance, AccountId, referralId, estimates, bestEstimate, bestFee;
|
|
8085
8090
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
8086
8091
|
while (1) {
|
|
8087
8092
|
switch (_context5.prev = _context5.next) {
|
|
8088
8093
|
case 0:
|
|
8089
|
-
tokenA = _ref6.tokenA, tokenB = _ref6.tokenB, amountA = _ref6.amountA, slippageTolerance = _ref6.slippageTolerance, AccountId = _ref6.AccountId;
|
|
8094
|
+
tokenA = _ref6.tokenA, tokenB = _ref6.tokenB, amountA = _ref6.amountA, slippageTolerance = _ref6.slippageTolerance, AccountId = _ref6.AccountId, referralId = _ref6.referralId;
|
|
8090
8095
|
if (!(slippageTolerance <= 0 || slippageTolerance >= 100)) {
|
|
8091
8096
|
_context5.next = 3;
|
|
8092
8097
|
break;
|
|
@@ -8148,7 +8153,8 @@ var DCLSwapByInputOnBestPool = /*#__PURE__*/function () {
|
|
|
8148
8153
|
pool_ids: [getDCLPoolId(tokenA.id, tokenB.id, bestFee)],
|
|
8149
8154
|
min_output_amount: percentLess(slippageTolerance, bestEstimate.amount)
|
|
8150
8155
|
},
|
|
8151
|
-
AccountId: AccountId
|
|
8156
|
+
AccountId: AccountId,
|
|
8157
|
+
referralId: referralId
|
|
8152
8158
|
}));
|
|
8153
8159
|
case 11:
|
|
8154
8160
|
case "end":
|