@openocean.finance/openocean-sdk 1.2.88 → 1.2.89
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/lib/swapSdk/Swap.js +12 -10
- package/package.json +1 -1
package/lib/swapSdk/Swap.js
CHANGED
|
@@ -559,18 +559,19 @@ var Swap = /** @class */ (function () {
|
|
|
559
559
|
};
|
|
560
560
|
Swap.prototype.getGasOld = function () {
|
|
561
561
|
return __awaiter(this, void 0, void 0, function () {
|
|
562
|
-
var _a, inToken, inAmount, data, to, value, gas;
|
|
562
|
+
var _a, inToken, inAmount, data, to, gmxFee, value, gas;
|
|
563
563
|
return __generator(this, function (_b) {
|
|
564
564
|
switch (_b.label) {
|
|
565
565
|
case 0:
|
|
566
|
-
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, data = _a.data, to = _a.to,
|
|
566
|
+
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, data = _a.data, to = _a.to, gmxFee = _a.gmxFee;
|
|
567
|
+
value = wallet_1.chainsObj.isNativeToken(this.chain.key, inToken.address)
|
|
568
|
+
? inAmount
|
|
569
|
+
: 0;
|
|
567
570
|
return [4 /*yield*/, this.wallet.sdk.eth.estimateGas({
|
|
568
571
|
from: this.wallet.address,
|
|
569
572
|
to: to,
|
|
570
573
|
data: data,
|
|
571
|
-
value:
|
|
572
|
-
? inAmount
|
|
573
|
-
: value || 0,
|
|
574
|
+
value: gmxFee ? new bn_js_1.default(value).add(new bn_js_1.default(gmxFee)).toNumber() : value,
|
|
574
575
|
})];
|
|
575
576
|
case 1:
|
|
576
577
|
gas = _b.sent();
|
|
@@ -581,13 +582,13 @@ var Swap = /** @class */ (function () {
|
|
|
581
582
|
};
|
|
582
583
|
Swap.prototype.getGasNew = function () {
|
|
583
584
|
return __awaiter(this, void 0, void 0, function () {
|
|
584
|
-
var _a, inToken, inAmount, outAmount, outToken, data, to, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, gas, e_5;
|
|
585
|
+
var _a, inToken, inAmount, outAmount, outToken, data, to, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, value, gas, e_5;
|
|
585
586
|
return __generator(this, function (_b) {
|
|
586
587
|
switch (_b.label) {
|
|
587
588
|
case 0:
|
|
588
589
|
_b.trys.push([0, 2, , 3]);
|
|
589
590
|
console.log('getGasNew');
|
|
590
|
-
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, outAmount = _a.outAmount, outToken = _a.outToken, data = _a.data, to = _a.to;
|
|
591
|
+
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, outAmount = _a.outAmount, outToken = _a.outToken, data = _a.data, to = _a.to, gmxFee = _a.gmxFee;
|
|
591
592
|
myWallet = this.wallet.sdk;
|
|
592
593
|
contract = new myWallet.eth.Contract(aggregator_1.aggregator, (0, config_1.getProxyContract)(this.chain.key));
|
|
593
594
|
invitee = this.wallet.address;
|
|
@@ -595,13 +596,14 @@ var Swap = /** @class */ (function () {
|
|
|
595
596
|
amounts = [inAmount, outAmount];
|
|
596
597
|
swapAddr = to;
|
|
597
598
|
swapExtraData = data;
|
|
599
|
+
value = wallet_1.chainsObj.isNativeToken(this.chain.key, inToken.address)
|
|
600
|
+
? inAmount
|
|
601
|
+
: 0;
|
|
598
602
|
return [4 /*yield*/, contract.methods
|
|
599
603
|
.swap(invitee, path, amounts, swapAddr, swapExtraData)
|
|
600
604
|
.estimateGas({
|
|
601
605
|
from: this.wallet.address,
|
|
602
|
-
value:
|
|
603
|
-
? inAmount
|
|
604
|
-
: 0,
|
|
606
|
+
value: gmxFee ? new bn_js_1.default(value).add(new bn_js_1.default(gmxFee)).toNumber() : value,
|
|
605
607
|
})];
|
|
606
608
|
case 1:
|
|
607
609
|
gas = _b.sent();
|