@ref-finance/ref-sdk 1.3.2 → 1.3.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/README.md +1 -1
- package/dist/indexer.d.ts +1 -0
- package/dist/ref-sdk.cjs.development.js +65 -12
- 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 +65 -12
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +65 -12
- 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/dist/swap-widget/constant.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This SDK is designed to assist developers when interacting with the main functions of the protocol. Main functions that can be defined as:
|
|
4
4
|
|
|
5
|
-
- Trade: Swap tokens with our Automated Market Maker (AMM)
|
|
5
|
+
- Trade: Swap tokens with our Automated Market Maker (AMM).
|
|
6
6
|
- Pool: Add/Remove liquidity and earn revenue from swap fee (Coming soon)
|
|
7
7
|
- Farm: Stale LP tokens into farms and earn liquidity incentives (Coming soon)
|
|
8
8
|
- Boost Farm: Stake LOVE tokens to get boosted liquidity incentives (Coming soon)
|
package/dist/indexer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const getTokenPriceList: () => Promise<any>;
|
|
2
2
|
export declare const getTokens: (reload?: boolean | undefined) => Promise<any>;
|
|
3
|
+
export declare const getTokensTiny: (reload?: boolean | undefined) => Promise<any>;
|
|
3
4
|
export declare const getWhiteListTokensIndexer: (whiteListIds: string[]) => Promise<unknown[]>;
|
|
@@ -644,6 +644,7 @@ var getSwappedAmount = function getSwappedAmount(tokenInId, tokenOutId, amountIn
|
|
|
644
644
|
|
|
645
645
|
var REF_WIDGET_STAR_TOKEN_LIST_KEY = 'REF_WIDGET_STAR_TOKEN_LIST_VALUE';
|
|
646
646
|
var REF_WIDGET_ALL_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_TOKENS_LIST_VALUE';
|
|
647
|
+
var REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_LIGHT_TOKENS_LIST_VALUE';
|
|
647
648
|
var REF_WIDGET_SWAP_IN_KEY = 'REF_WIDGET_SWAP_IN_VALUE';
|
|
648
649
|
var REF_WIDGET_SWAP_OUT_KEY = 'REF_WIDGET_SWAP_OUT_VALUE';
|
|
649
650
|
var REF_WIDGET_SWAP_DETAIL_KEY = 'REF_WIDGET_SWAP_DETAIL_VALUE';
|
|
@@ -794,13 +795,65 @@ var getTokens = /*#__PURE__*/function () {
|
|
|
794
795
|
return _ref2.apply(this, arguments);
|
|
795
796
|
};
|
|
796
797
|
}();
|
|
797
|
-
var
|
|
798
|
-
var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(
|
|
798
|
+
var getTokensTiny = /*#__PURE__*/function () {
|
|
799
|
+
var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(reload) {
|
|
800
|
+
var storagedTokens;
|
|
799
801
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
800
802
|
while (1) {
|
|
801
803
|
switch (_context3.prev = _context3.next) {
|
|
802
804
|
case 0:
|
|
803
|
-
|
|
805
|
+
storagedTokens = typeof window !== 'undefined' && !reload ? localStorage.getItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY) : null;
|
|
806
|
+
if (!storagedTokens) {
|
|
807
|
+
_context3.next = 5;
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
_context3.t0 = JSON.parse(storagedTokens);
|
|
811
|
+
_context3.next = 8;
|
|
812
|
+
break;
|
|
813
|
+
case 5:
|
|
814
|
+
_context3.next = 7;
|
|
815
|
+
return fetch(exports.config.indexerUrl + '/list-token-v2', {
|
|
816
|
+
method: 'GET',
|
|
817
|
+
headers: {
|
|
818
|
+
'Content-type': 'application/json; charset=UTF-8'
|
|
819
|
+
}
|
|
820
|
+
}).then(function (res) {
|
|
821
|
+
return res.json();
|
|
822
|
+
}).then(function (tokens) {
|
|
823
|
+
var newTokens = Object.values(tokens).reduce(function (acc, cur, i) {
|
|
824
|
+
var _extends3;
|
|
825
|
+
var id = Object.keys(tokens)[i];
|
|
826
|
+
return _extends({}, acc, (_extends3 = {}, _extends3[id] = _extends({}, cur, {
|
|
827
|
+
id: id
|
|
828
|
+
}), _extends3));
|
|
829
|
+
}, {});
|
|
830
|
+
return newTokens;
|
|
831
|
+
}).then(function (res) {
|
|
832
|
+
typeof window !== 'undefined' && !reload && localStorage.setItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY, JSON.stringify(res));
|
|
833
|
+
return res;
|
|
834
|
+
});
|
|
835
|
+
case 7:
|
|
836
|
+
_context3.t0 = _context3.sent;
|
|
837
|
+
case 8:
|
|
838
|
+
return _context3.abrupt("return", _context3.t0);
|
|
839
|
+
case 9:
|
|
840
|
+
case "end":
|
|
841
|
+
return _context3.stop();
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}, _callee3);
|
|
845
|
+
}));
|
|
846
|
+
return function getTokensTiny(_x2) {
|
|
847
|
+
return _ref3.apply(this, arguments);
|
|
848
|
+
};
|
|
849
|
+
}();
|
|
850
|
+
var getWhiteListTokensIndexer = /*#__PURE__*/function () {
|
|
851
|
+
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(whiteListIds) {
|
|
852
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
853
|
+
while (1) {
|
|
854
|
+
switch (_context4.prev = _context4.next) {
|
|
855
|
+
case 0:
|
|
856
|
+
_context4.next = 2;
|
|
804
857
|
return fetch(exports.config.indexerUrl + '/list-token', {
|
|
805
858
|
method: 'GET',
|
|
806
859
|
headers: {
|
|
@@ -810,26 +863,26 @@ var getWhiteListTokensIndexer = /*#__PURE__*/function () {
|
|
|
810
863
|
return res.json();
|
|
811
864
|
}).then(function (res) {
|
|
812
865
|
return whiteListIds.reduce(function (acc, cur, i) {
|
|
813
|
-
var
|
|
866
|
+
var _extends4;
|
|
814
867
|
if (!res[cur] || !Object.values(res[cur]) || Object.values(res[cur]).length === 0) return acc;
|
|
815
|
-
return _extends({}, acc, (
|
|
868
|
+
return _extends({}, acc, (_extends4 = {}, _extends4[cur] = _extends({}, res[cur], {
|
|
816
869
|
id: cur
|
|
817
|
-
}),
|
|
870
|
+
}), _extends4));
|
|
818
871
|
}, {});
|
|
819
872
|
}).then(function (res) {
|
|
820
873
|
return Object.values(res);
|
|
821
874
|
});
|
|
822
875
|
case 2:
|
|
823
|
-
return
|
|
876
|
+
return _context4.abrupt("return", _context4.sent);
|
|
824
877
|
case 3:
|
|
825
878
|
case "end":
|
|
826
|
-
return
|
|
879
|
+
return _context4.stop();
|
|
827
880
|
}
|
|
828
881
|
}
|
|
829
|
-
},
|
|
882
|
+
}, _callee4);
|
|
830
883
|
}));
|
|
831
|
-
return function getWhiteListTokensIndexer(
|
|
832
|
-
return
|
|
884
|
+
return function getWhiteListTokensIndexer(_x3) {
|
|
885
|
+
return _ref4.apply(this, arguments);
|
|
833
886
|
};
|
|
834
887
|
}();
|
|
835
888
|
|
|
@@ -3100,7 +3153,7 @@ var estimateSwap = /*#__PURE__*/function () {
|
|
|
3100
3153
|
return poolFormatter(p);
|
|
3101
3154
|
});
|
|
3102
3155
|
_context2.next = 22;
|
|
3103
|
-
return
|
|
3156
|
+
return getTokensTiny();
|
|
3104
3157
|
case 22:
|
|
3105
3158
|
allTokens = _context2.sent;
|
|
3106
3159
|
_context2.next = 25;
|