@gearbox-protocol/sdk 1.7.9 → 1.7.11
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/contracts/contractsRegister.js +8 -33
- package/lib/core/trade.d.ts +4 -3
- package/lib/core/trade.js +37 -4
- package/package.json +1 -1
|
@@ -25,40 +25,15 @@ exports.deployedContracts = {
|
|
|
25
25
|
"0x968f9a68a98819E2e6Bb910466e191A7b6cf02F0": "WETH",
|
|
26
26
|
"0xB2A015c71c17bCAC6af36645DEad8c572bA08A08": "WBTC",
|
|
27
27
|
"0xC38478B0A4bAFE964C3526EEFF534d70E1E09017": "WBTC",
|
|
28
|
-
// [UNISWAP_V2_ROUTER]: "Uniswap V2",
|
|
29
|
-
// [UNISWAP_V3_ROUTER]: "Uniswap V3",
|
|
30
|
-
// [CURVE_3CRV_POOL_ADDRESS]: "Curve 3Pool",
|
|
31
|
-
// [SUSHISWAP_MAINNET]: "Sushiswap",
|
|
32
|
-
// [YEARN_DAI_VAULT_ADDRESS]: "Yearn DAI",
|
|
33
|
-
// [YEARN_USDC_VAULT_ADDRESS]: "Yearn USDC",
|
|
34
|
-
// KOVAN
|
|
35
|
-
"0xc40B71BCcb749D91923654571f715Bf1FC464E66": "DAI",
|
|
36
|
-
"0x1b0c9312FB74d08e57F49Ee5e4601a1846dc2207": "USDC",
|
|
37
|
-
"0x4b20dD834B8898caC2c1B2C94163f14FA866AadC": "WETH",
|
|
38
|
-
"0x2c52bc97485bcb3BeA763Fb5793eF15BA388D140": "WBTC",
|
|
39
|
-
"0xe04b4db67127d1930D36f16B51653120C4285708": "WBTC",
|
|
40
|
-
"0x600073357c29d169aAF3E543A4519749830553F1": "WETH",
|
|
41
|
-
"0xdBAd1361d9A03B81Be8D3a54Ef0dc9e39a1bA5b3": "USDC",
|
|
42
|
-
"0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e": "DAI",
|
|
43
|
-
// [YEARN_DAI_VAULT_KOVAN_MOCK]: "Yearn DAI",
|
|
44
|
-
// [YEARN_USDC_VAULT_KOVAN_MOCK]: "Yearn USDC",
|
|
45
|
-
// [SUSHISWAP_KOVAN]: "Sushiswap"
|
|
46
28
|
// GOERLI
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"0x8E0a874E3475de1C16490E386b7E2904CdC03086": "USDC V2",
|
|
56
|
-
"0x816a74B75D60839247C848518545fb17cedDC460": "WETH V2",
|
|
57
|
-
// pools
|
|
58
|
-
"0xA7b1C8f322596C40A04dBd3DffaE37a0849B8b59": "DAI",
|
|
59
|
-
"0xb8ecDB926F07FCbd870eafE72d116413A0BEb236": "USDC",
|
|
60
|
-
"0xAda6b2747295b2ba6ba52ce2d0D5e681D25D63D8": "WETH",
|
|
61
|
-
"0x85c54CCCf27466eEa1C74a73F75CbE385C271EE4": "WBTC",
|
|
29
|
+
"0x2B16eA2D7a1b13d115d05B03Fd0E5984eFA0F18D": "DAI",
|
|
30
|
+
"0x19e8293f46caE0770d608a3078EFb59f0B0166aa": "USDC",
|
|
31
|
+
"0x9149A40293d0bc17f07DaFC7F6282b267D3C68C8": "WETH",
|
|
32
|
+
// GOERLI pools
|
|
33
|
+
"0xEA7D5CaE79Cdf2E07E0aa7edfB1AF7A429Cb7513": "DAI",
|
|
34
|
+
"0xF0A7BE2EB39bBbd55fc5597F93E01f62A790e587": "USDC",
|
|
35
|
+
"0x560F2aa70003af4A69Bc79bB3c40955d396305aE": "WETH",
|
|
36
|
+
"0x9f07160C42d5d8325E3Aa50e0075Ef3A8E4DcA9B": "WBTC",
|
|
62
37
|
};
|
|
63
38
|
var contractNames = Object.entries(contracts_1.contractsByAddress).reduce(function (acc, _a) {
|
|
64
39
|
var _b;
|
package/lib/core/trade.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
1
|
+
import { BigNumber, Signer } from "ethers";
|
|
2
2
|
import { AdapterInterface } from "../contracts/adapters";
|
|
3
3
|
import { PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
4
4
|
import { ICreditFacade } from "../types";
|
|
@@ -35,8 +35,9 @@ export declare class Trade implements BaseTradeInterface {
|
|
|
35
35
|
getAdapterInterface(): AdapterInterface;
|
|
36
36
|
getContractAddress(): string;
|
|
37
37
|
getAdapterAddress(): string;
|
|
38
|
-
execute(): Promise<EVMTx>;
|
|
39
|
-
protected
|
|
38
|
+
execute(signer: Signer): Promise<EVMTx>;
|
|
39
|
+
protected _executeOnSigner(call: PathFinderResult["calls"][0], signer: Signer): Promise<TXSwap>;
|
|
40
|
+
protected _executeOnCreditFacade(calls: PathFinderResult["calls"]): Promise<TXSwap>;
|
|
40
41
|
toString(): string;
|
|
41
42
|
getFromAmount(slippage: number): BigNumber;
|
|
42
43
|
getToAmount(slippage: number): BigNumber;
|
package/lib/core/trade.js
CHANGED
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.Trade = void 0;
|
|
40
|
+
var txParser_1 = require("../parsers/txParser");
|
|
40
41
|
var decimals_1 = require("../tokens/decimals");
|
|
41
42
|
var token_1 = require("../tokens/token");
|
|
42
43
|
var formatter_1 = require("../utils/formatter");
|
|
@@ -73,15 +74,47 @@ var Trade = /** @class */ (function () {
|
|
|
73
74
|
Trade.prototype.getAdapterAddress = function () {
|
|
74
75
|
return this.helper.adapterAddress;
|
|
75
76
|
};
|
|
76
|
-
Trade.prototype.execute = function () {
|
|
77
|
-
|
|
77
|
+
Trade.prototype.execute = function (signer) {
|
|
78
|
+
if (this.tradePath.calls.length < 1)
|
|
79
|
+
throw new Error("No path to execute");
|
|
80
|
+
return this.tradePath.calls.length === 1
|
|
81
|
+
? this._executeOnSigner(this.tradePath.calls[0], signer)
|
|
82
|
+
: this._executeOnCreditFacade(this.tradePath.calls);
|
|
78
83
|
};
|
|
79
|
-
Trade.prototype.
|
|
84
|
+
Trade.prototype._executeOnSigner = function (call, signer) {
|
|
80
85
|
return __awaiter(this, void 0, void 0, function () {
|
|
81
86
|
var receipt;
|
|
82
87
|
return __generator(this, function (_a) {
|
|
83
88
|
switch (_a.label) {
|
|
84
|
-
case 0:
|
|
89
|
+
case 0:
|
|
90
|
+
console.log(txParser_1.TxParser.parseMultiCall(this.tradePath.calls));
|
|
91
|
+
return [4 /*yield*/, signer.sendTransaction({
|
|
92
|
+
to: call.target,
|
|
93
|
+
data: call.callData,
|
|
94
|
+
})];
|
|
95
|
+
case 1:
|
|
96
|
+
receipt = _a.sent();
|
|
97
|
+
return [2 /*return*/, new transactions_1.TXSwap({
|
|
98
|
+
txHash: receipt.hash,
|
|
99
|
+
protocol: this.helper.contractAddress,
|
|
100
|
+
operation: OPERATION_NAMES[this.operationName],
|
|
101
|
+
amountFrom: this.sourceAmount,
|
|
102
|
+
amountTo: this.expectedAmount,
|
|
103
|
+
tokenFrom: this.tokenFrom,
|
|
104
|
+
tokenTo: this.tokenTo,
|
|
105
|
+
creditManager: this.helper.creditManager,
|
|
106
|
+
timestamp: 0,
|
|
107
|
+
})];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
Trade.prototype._executeOnCreditFacade = function (calls) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var receipt;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0: return [4 /*yield*/, this.creditFacade.multicall(calls)];
|
|
85
118
|
case 1:
|
|
86
119
|
receipt = _a.sent();
|
|
87
120
|
return [2 /*return*/, new transactions_1.TXSwap({
|