@ref-finance/ref-sdk 1.3.0 → 1.3.1
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/dcl-swap/swap.d.ts +6 -1
- package/dist/ref-sdk.cjs.development.js +46 -11
- 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 +46 -11
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +46 -11
- 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/dist/dcl-swap/swap.d.ts
CHANGED
|
@@ -18,10 +18,15 @@ interface DCLSwapProps {
|
|
|
18
18
|
pool_id: string;
|
|
19
19
|
output_amount: string;
|
|
20
20
|
};
|
|
21
|
+
SwapByStopPoint?: {
|
|
22
|
+
pool_id: string;
|
|
23
|
+
stop_point: number;
|
|
24
|
+
skip_unwrap_near: boolean;
|
|
25
|
+
};
|
|
21
26
|
AccountId: string;
|
|
22
27
|
}
|
|
23
28
|
export declare const DCL_POOL_SPLITER = "|";
|
|
24
|
-
export declare const DCLSwap: ({ Swap, SwapByOutput, LimitOrderWithSwap, AccountId, swapInfo, }: DCLSwapProps) => Promise<Transaction[]>;
|
|
29
|
+
export declare const DCLSwap: ({ Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, }: DCLSwapProps) => Promise<Transaction[]>;
|
|
25
30
|
export declare const quote: ({ pool_ids, input_amount, input_token, output_token, tag, }: {
|
|
26
31
|
pool_ids: string[];
|
|
27
32
|
input_token: TokenMetadata;
|
|
@@ -7507,12 +7507,12 @@ function getDefaultTokenList() {
|
|
|
7507
7507
|
var DCL_POOL_SPLITER = '|';
|
|
7508
7508
|
var DCLSwap = /*#__PURE__*/function () {
|
|
7509
7509
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
7510
|
-
var Swap, SwapByOutput, LimitOrderWithSwap, 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, registered;
|
|
7510
|
+
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;
|
|
7511
7511
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
7512
7512
|
while (1) {
|
|
7513
7513
|
switch (_context.prev = _context.next) {
|
|
7514
7514
|
case 0:
|
|
7515
|
-
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
|
|
7515
|
+
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
|
|
7516
7516
|
transactions = [];
|
|
7517
7517
|
tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
|
|
7518
7518
|
if (!Swap) {
|
|
@@ -7555,7 +7555,7 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7555
7555
|
amount: ONE_YOCTO_NEAR
|
|
7556
7556
|
}]
|
|
7557
7557
|
});
|
|
7558
|
-
_context.next =
|
|
7558
|
+
_context.next = 52;
|
|
7559
7559
|
break;
|
|
7560
7560
|
case 15:
|
|
7561
7561
|
if (!SwapByOutput) {
|
|
@@ -7598,11 +7598,11 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7598
7598
|
amount: ONE_YOCTO_NEAR
|
|
7599
7599
|
}]
|
|
7600
7600
|
});
|
|
7601
|
-
_context.next =
|
|
7601
|
+
_context.next = 52;
|
|
7602
7602
|
break;
|
|
7603
7603
|
case 27:
|
|
7604
7604
|
if (!LimitOrderWithSwap) {
|
|
7605
|
-
_context.next =
|
|
7605
|
+
_context.next = 45;
|
|
7606
7606
|
break;
|
|
7607
7607
|
}
|
|
7608
7608
|
pool_id = LimitOrderWithSwap.pool_id;
|
|
@@ -7669,14 +7669,49 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7669
7669
|
amount: ONE_YOCTO_NEAR
|
|
7670
7670
|
}]
|
|
7671
7671
|
});
|
|
7672
|
-
|
|
7672
|
+
_context.next = 52;
|
|
7673
|
+
break;
|
|
7674
|
+
case 45:
|
|
7675
|
+
if (!SwapByStopPoint) {
|
|
7676
|
+
_context.next = 52;
|
|
7677
|
+
break;
|
|
7678
|
+
}
|
|
7679
|
+
_context.next = 48;
|
|
7680
|
+
return ftGetStorageBalance(tokenB.id, AccountId)["catch"](function () {
|
|
7681
|
+
throw new Error(tokenB.id + " doesn't exist.");
|
|
7682
|
+
});
|
|
7683
|
+
case 48:
|
|
7684
|
+
_tokenRegistered3 = _context.sent;
|
|
7685
|
+
if (_tokenRegistered3 === null) {
|
|
7686
|
+
transactions.push({
|
|
7687
|
+
receiverId: tokenB.id,
|
|
7688
|
+
functionCalls: [registerAccountOnToken(AccountId)]
|
|
7689
|
+
});
|
|
7690
|
+
}
|
|
7691
|
+
_msg3 = JSON.stringify({
|
|
7692
|
+
SwapByStopPoint: SwapByStopPoint
|
|
7693
|
+
});
|
|
7694
|
+
transactions.push({
|
|
7695
|
+
receiverId: tokenA.id,
|
|
7696
|
+
functionCalls: [{
|
|
7697
|
+
methodName: 'ft_transfer_call',
|
|
7698
|
+
args: {
|
|
7699
|
+
receiver_id: exports.config.REF_DCL_SWAP_CONTRACT_ID,
|
|
7700
|
+
amount: toNonDivisibleNumber(tokenA.decimals, amountA),
|
|
7701
|
+
msg: _msg3
|
|
7702
|
+
},
|
|
7703
|
+
gas: '180000000000000',
|
|
7704
|
+
amount: ONE_YOCTO_NEAR
|
|
7705
|
+
}]
|
|
7706
|
+
});
|
|
7707
|
+
case 52:
|
|
7673
7708
|
if (!(tokenA.id === exports.WRAP_NEAR_CONTRACT_ID)) {
|
|
7674
|
-
_context.next =
|
|
7709
|
+
_context.next = 57;
|
|
7675
7710
|
break;
|
|
7676
7711
|
}
|
|
7677
|
-
_context.next =
|
|
7712
|
+
_context.next = 55;
|
|
7678
7713
|
return ftGetStorageBalance(exports.WRAP_NEAR_CONTRACT_ID, AccountId);
|
|
7679
|
-
case
|
|
7714
|
+
case 55:
|
|
7680
7715
|
registered = _context.sent;
|
|
7681
7716
|
if (registered === null) {
|
|
7682
7717
|
transactions.unshift({
|
|
@@ -7684,9 +7719,9 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7684
7719
|
functionCalls: [registerAccountOnToken(AccountId)]
|
|
7685
7720
|
});
|
|
7686
7721
|
}
|
|
7687
|
-
case
|
|
7722
|
+
case 57:
|
|
7688
7723
|
return _context.abrupt("return", transactions);
|
|
7689
|
-
case
|
|
7724
|
+
case 58:
|
|
7690
7725
|
case "end":
|
|
7691
7726
|
return _context.stop();
|
|
7692
7727
|
}
|