@openocean.finance/openocean-sdk 1.2.87 → 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 +21 -19
- 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();
|
|
@@ -617,14 +619,14 @@ var Swap = /** @class */ (function () {
|
|
|
617
619
|
};
|
|
618
620
|
Swap.prototype.sendEthTransactionNew = function () {
|
|
619
621
|
return __awaiter(this, void 0, void 0, function () {
|
|
620
|
-
var _a, inToken, inAmount, outAmount, outToken, data, to, ethGasPrice, gasPrice,
|
|
622
|
+
var _a, inToken, inAmount, outAmount, outToken, data, to, ethGasPrice, gasPrice, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, swapParams, maxFeePerGas, maxPriorityFeePerGas;
|
|
621
623
|
var _b;
|
|
622
624
|
var _this = this;
|
|
623
625
|
return __generator(this, function (_c) {
|
|
624
626
|
switch (_c.label) {
|
|
625
627
|
case 0:
|
|
626
|
-
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, outAmount = _a.outAmount, outToken = _a.outToken, data = _a.data, to = _a.to, ethGasPrice = _a.ethGasPrice, gasPrice = _a.gasPrice,
|
|
627
|
-
console.log('sendEthTransactionNew');
|
|
628
|
+
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, outAmount = _a.outAmount, outToken = _a.outToken, data = _a.data, to = _a.to, ethGasPrice = _a.ethGasPrice, gasPrice = _a.gasPrice, gmxFee = _a.gmxFee;
|
|
629
|
+
console.log('sendEthTransactionNew', JSON.stringify(this.res));
|
|
628
630
|
myWallet = this.wallet.sdk;
|
|
629
631
|
contract = new myWallet.eth.Contract(aggregator_1.aggregator, (0, config_1.getProxyContract)(this.chain.key));
|
|
630
632
|
invitee = this.wallet.address;
|
|
@@ -654,8 +656,8 @@ var Swap = /** @class */ (function () {
|
|
|
654
656
|
if (wallet_1.chainsObj.isNativeToken(this.chain.key, inToken.address)) {
|
|
655
657
|
swapParams.value = inAmount;
|
|
656
658
|
}
|
|
657
|
-
|
|
658
|
-
swapParams.value = value;
|
|
659
|
+
if (gmxFee) {
|
|
660
|
+
swapParams.value = new bn_js_1.default(swapParams.value).add(new bn_js_1.default(gmxFee)).toNumber();
|
|
659
661
|
}
|
|
660
662
|
contract.methods
|
|
661
663
|
.swap(invitee, path, amounts, swapAddr, swapExtraData)
|
|
@@ -677,12 +679,12 @@ var Swap = /** @class */ (function () {
|
|
|
677
679
|
};
|
|
678
680
|
Swap.prototype.sendEthTransaction = function () {
|
|
679
681
|
return __awaiter(this, void 0, void 0, function () {
|
|
680
|
-
var _a, inToken, inAmount, data, to, ethGasPrice, gasPrice, estimatedGas,
|
|
682
|
+
var _a, inToken, inAmount, data, to, ethGasPrice, gasPrice, estimatedGas, gmxFee, swapParams, maxFeePerGas, maxPriorityFeePerGas, safeTxHash, e_6, gas, e_7;
|
|
681
683
|
var _this = this;
|
|
682
684
|
return __generator(this, function (_b) {
|
|
683
685
|
switch (_b.label) {
|
|
684
686
|
case 0:
|
|
685
|
-
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, data = _a.data, to = _a.to, ethGasPrice = _a.ethGasPrice, gasPrice = _a.gasPrice, estimatedGas = _a.estimatedGas,
|
|
687
|
+
_a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, data = _a.data, to = _a.to, ethGasPrice = _a.ethGasPrice, gasPrice = _a.gasPrice, estimatedGas = _a.estimatedGas, gmxFee = _a.gmxFee;
|
|
686
688
|
console.log('sendEthTransaction res', JSON.stringify(this.res));
|
|
687
689
|
swapParams = {
|
|
688
690
|
from: this.wallet.address,
|
|
@@ -702,8 +704,8 @@ var Swap = /** @class */ (function () {
|
|
|
702
704
|
if (wallet_1.chainsObj.isNativeToken(this.chain.key, inToken.address)) {
|
|
703
705
|
swapParams.value = inAmount;
|
|
704
706
|
}
|
|
705
|
-
|
|
706
|
-
swapParams.value = value;
|
|
707
|
+
if (gmxFee) {
|
|
708
|
+
swapParams.value = new bn_js_1.default(swapParams.value).add(new bn_js_1.default(gmxFee)).toNumber();
|
|
707
709
|
}
|
|
708
710
|
console.log('sendEthTransaction swapParams', JSON.stringify(swapParams));
|
|
709
711
|
if (!(this.wallet.key === "GnosisSafeWallet")) return [3 /*break*/, 5];
|