@gearbox-protocol/sdk 2.1.32 → 2.1.34
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/protocols.d.ts +0 -5
- package/lib/contracts/protocols.js +1 -43
- package/lib/core/creditManager.d.ts +3 -0
- package/lib/core/creditManager.js +22 -0
- package/lib/core/pool/index.d.ts +0 -1
- package/lib/core/pool/index.js +0 -1
- package/lib/core/trade.d.ts +29 -16
- package/lib/core/trade.js +67 -10
- package/lib/index.d.ts +0 -11
- package/lib/index.js +1 -14
- package/lib/parsers/txParser.js +1 -1
- package/lib/tokens/aave.d.ts +0 -3
- package/lib/tokens/aave.js +0 -57
- package/lib/tokens/balancer.d.ts +1 -11
- package/lib/tokens/balancer.js +3 -32
- package/lib/tokens/compound.d.ts +0 -2
- package/lib/tokens/compound.js +0 -36
- package/lib/tokens/convex.d.ts +2 -2
- package/lib/tokens/convex.js +9 -322
- package/lib/tokens/curveLP.d.ts +3 -4
- package/lib/tokens/curveLP.js +17 -240
- package/lib/tokens/decimals.js +1 -1
- package/lib/tokens/gear.d.ts +0 -2
- package/lib/tokens/normal.d.ts +0 -3
- package/lib/tokens/normal.js +0 -718
- package/lib/tokens/token.js +2 -2
- package/lib/tokens/tokens.spec.js +25 -4
- package/lib/tokens/yearn.d.ts +0 -4
- package/lib/tokens/yearn.js +0 -43
- package/lib/utils/multicall.d.ts +1 -1
- package/lib/utils/multicall.js +21 -6
- package/package.json +1 -1
- package/lib/core/adapter.d.ts +0 -20
- package/lib/core/adapter.js +0 -20
- package/lib/core/creditOperation.d.ts +0 -9
- package/lib/core/creditOperation.js +0 -2
- package/lib/core/operations.d.ts +0 -22
- package/lib/core/operations.js +0 -26
- package/lib/core/pool/operation.d.ts +0 -28
- package/lib/core/pool/operation.js +0 -36
- package/lib/pathfinder/tradeTypes.d.ts +0 -113
- package/lib/pathfinder/tradeTypes.js +0 -28
- package/lib/strategies/convex.d.ts +0 -57
- package/lib/strategies/convex.js +0 -220
- package/lib/strategies/creditFacade.d.ts +0 -21
- package/lib/strategies/creditFacade.js +0 -71
- package/lib/strategies/curve.d.ts +0 -45
- package/lib/strategies/curve.js +0 -207
- package/lib/strategies/lido.d.ts +0 -18
- package/lib/strategies/lido.js +0 -51
- package/lib/strategies/uniswapV2.d.ts +0 -15
- package/lib/strategies/uniswapV2.js +0 -44
- package/lib/strategies/uniswapV3.d.ts +0 -21
- package/lib/strategies/uniswapV3.js +0 -71
- package/lib/strategies/yearn.d.ts +0 -20
- package/lib/strategies/yearn.js +0 -128
- package/lib/utils/extracter.d.ts +0 -11
- package/lib/utils/extracter.js +0 -19
package/lib/tokens/token.js
CHANGED
|
@@ -125,7 +125,7 @@ exports.tokenDataByNetwork = {
|
|
|
125
125
|
"50OHM_50DAI": "0x76FCf0e8C7Ff37A47a799FA2cd4c13cDe0D981C9",
|
|
126
126
|
"50OHM_50WETH": "0xD1eC5e215E8148D76F4460e4097FD3d5ae0A3558",
|
|
127
127
|
OHM_wstETH: "0xd4f79CA0Ac83192693bce4699d0c10C66Aa6Cf0F",
|
|
128
|
-
|
|
128
|
+
USDC_DAI_USDT: "0x79c58f70905F734641735BC61e45c19dD9Ad60bC",
|
|
129
129
|
// GEARBOX
|
|
130
130
|
dDAI: "0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA",
|
|
131
131
|
dUSDC: "0xc411dB5f5Eb3f7d552F9B8454B2D74097ccdE6E3",
|
|
@@ -251,7 +251,7 @@ exports.tokenDataByNetwork = {
|
|
|
251
251
|
"50OHM_50DAI": constants_1.NOT_DEPLOYED,
|
|
252
252
|
"50OHM_50WETH": "0x89dc7e71e362faF88D92288fE2311D25c6a1B5E0",
|
|
253
253
|
OHM_wstETH: constants_1.NOT_DEPLOYED,
|
|
254
|
-
|
|
254
|
+
USDC_DAI_USDT: constants_1.NOT_DEPLOYED,
|
|
255
255
|
// GEARBOX
|
|
256
256
|
dDAI: constants_1.NOT_DEPLOYED,
|
|
257
257
|
dUSDC: constants_1.NOT_DEPLOYED,
|
|
@@ -7,6 +7,21 @@ const types_1 = require("../types");
|
|
|
7
7
|
const multicall_1 = require("../utils/multicall");
|
|
8
8
|
const token_1 = require("./token");
|
|
9
9
|
const erc20 = types_1.IERC20Metadata__factory.createInterface();
|
|
10
|
+
// Some contracts return something other than string for symbol
|
|
11
|
+
const NON_ERC20_SYMBOLS = {
|
|
12
|
+
[token_1.tokenDataByNetwork.Mainnet.MKR]: {
|
|
13
|
+
interface: new ethers_1.ethers.utils.Interface([
|
|
14
|
+
"function symbol() view returns (bytes32)",
|
|
15
|
+
]),
|
|
16
|
+
// convert bytes32 to string
|
|
17
|
+
stringifySymbol: (result) => ethers_1.ethers.utils
|
|
18
|
+
.toUtf8String(ethers_1.ethers.utils.arrayify(result))
|
|
19
|
+
.replaceAll(String.fromCharCode(0), ""), // trim tail of zeroes
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
function identity(value) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
10
25
|
const EXCEPTIONS_IN_SYMBOLS = {
|
|
11
26
|
Mainnet: {
|
|
12
27
|
// Our Symbol <-> On-chain Symbol
|
|
@@ -38,7 +53,7 @@ class TokenSuite {
|
|
|
38
53
|
const entries = Object.entries(token_1.tokenDataByNetwork[network]).filter(([_, addr]) => addr?.startsWith("0x"));
|
|
39
54
|
this.calls = entries.map(([symbol, address]) => ({
|
|
40
55
|
address,
|
|
41
|
-
interface: erc20,
|
|
56
|
+
interface: NON_ERC20_SYMBOLS[address]?.interface ?? erc20,
|
|
42
57
|
method: "symbol()",
|
|
43
58
|
key: symbol,
|
|
44
59
|
}));
|
|
@@ -46,6 +61,7 @@ class TokenSuite {
|
|
|
46
61
|
async fetchSymbols() {
|
|
47
62
|
// even safe multicall fails when one of addresses is an EOA and not contract address
|
|
48
63
|
if (this.network === "Arbitrum") {
|
|
64
|
+
// if (true) {
|
|
49
65
|
for (const call of this.calls) {
|
|
50
66
|
const c = types_1.IERC20Metadata__factory.connect(call.address, this.provider);
|
|
51
67
|
try {
|
|
@@ -68,10 +84,15 @@ class TokenSuite {
|
|
|
68
84
|
for (let i = 0; i < resps.length; i++) {
|
|
69
85
|
const call = this.calls[i];
|
|
70
86
|
const resp = resps[i];
|
|
87
|
+
// most symbols are ok, but some return non-string value for symbol.
|
|
88
|
+
// stringifySymbol makes sure that we get symbol as string
|
|
89
|
+
const stringifySymbol = NON_ERC20_SYMBOLS[call.address]?.stringifySymbol ?? identity;
|
|
71
90
|
this.responses[call.key] = {
|
|
72
91
|
address: call.address,
|
|
73
|
-
symbol: resp.error
|
|
74
|
-
|
|
92
|
+
symbol: resp.error
|
|
93
|
+
? undefined
|
|
94
|
+
: this.sanitize(stringifySymbol(resp.value ?? "")),
|
|
95
|
+
error: resp.error,
|
|
75
96
|
};
|
|
76
97
|
}
|
|
77
98
|
}
|
|
@@ -84,7 +105,7 @@ class TokenSuite {
|
|
|
84
105
|
assertSymbol(sdkSymbol) {
|
|
85
106
|
const r = this.responses[sdkSymbol];
|
|
86
107
|
if (r.error) {
|
|
87
|
-
throw new Error(`failed to verify ${sdkSymbol} on address ${r.address}: ${
|
|
108
|
+
throw new Error(`failed to verify ${sdkSymbol} on address ${r.address}: ${r.error}`);
|
|
88
109
|
}
|
|
89
110
|
const expectedSymbol = EXCEPTIONS_IN_SYMBOLS[this.network][r.address] ?? sdkSymbol;
|
|
90
111
|
if (r.symbol !== expectedSymbol) {
|
package/lib/tokens/yearn.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { YearnVaultContract } from "../contracts/contracts";
|
|
2
|
-
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
3
2
|
import type { CurveLPToken } from "./curveLP";
|
|
4
3
|
import { NormalToken } from "./normal";
|
|
5
4
|
import type { TokenBase } from "./token";
|
|
@@ -9,21 +8,18 @@ export type YearnVaultTokenData = {
|
|
|
9
8
|
symbol: YearnLPToken;
|
|
10
9
|
type: TokenType.YEARN_ON_NORMAL_TOKEN;
|
|
11
10
|
underlying: NormalToken;
|
|
12
|
-
lpActions: Array<TradeAction>;
|
|
13
11
|
vault: YearnVaultContract;
|
|
14
12
|
} & TokenBase;
|
|
15
13
|
export type YearnVaultOfCurveLPTokenData = {
|
|
16
14
|
symbol: YearnLPToken;
|
|
17
15
|
type: TokenType.YEARN_ON_CURVE_TOKEN;
|
|
18
16
|
underlying: CurveLPToken;
|
|
19
|
-
lpActions: Array<TradeAction>;
|
|
20
17
|
vault: YearnVaultContract;
|
|
21
18
|
} & TokenBase;
|
|
22
19
|
export type YearnVaultOfMetaCurveLPTokenData = {
|
|
23
20
|
symbol: YearnLPToken;
|
|
24
21
|
type: TokenType.YEARN_ON_CURVE_TOKEN;
|
|
25
22
|
underlying: CurveLPToken;
|
|
26
|
-
lpActions: Array<TradeAction>;
|
|
27
23
|
vault: YearnVaultContract;
|
|
28
24
|
} & TokenBase;
|
|
29
25
|
export declare const yearnTokens: Record<YearnLPToken, YearnVaultTokenData | YearnVaultOfCurveLPTokenData | YearnVaultOfMetaCurveLPTokenData>;
|
package/lib/tokens/yearn.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isYearnLPToken = exports.yearnTokens = void 0;
|
|
4
|
-
const tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
4
|
const tokenType_1 = require("./tokenType");
|
|
6
5
|
exports.yearnTokens = {
|
|
7
6
|
// YEARN TOKENS
|
|
@@ -11,13 +10,6 @@ exports.yearnTokens = {
|
|
|
11
10
|
type: tokenType_1.TokenType.YEARN_ON_NORMAL_TOKEN,
|
|
12
11
|
underlying: "DAI",
|
|
13
12
|
vault: "YEARN_DAI_VAULT",
|
|
14
|
-
lpActions: [
|
|
15
|
-
{
|
|
16
|
-
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
17
|
-
contract: "YEARN_DAI_VAULT",
|
|
18
|
-
tokenOut: "DAI",
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
13
|
},
|
|
22
14
|
yvUSDC: {
|
|
23
15
|
name: "Yearn yvUSDC",
|
|
@@ -25,13 +17,6 @@ exports.yearnTokens = {
|
|
|
25
17
|
type: tokenType_1.TokenType.YEARN_ON_NORMAL_TOKEN,
|
|
26
18
|
underlying: "USDC",
|
|
27
19
|
vault: "YEARN_USDC_VAULT",
|
|
28
|
-
lpActions: [
|
|
29
|
-
{
|
|
30
|
-
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
31
|
-
contract: "YEARN_USDC_VAULT",
|
|
32
|
-
tokenOut: "USDC",
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
20
|
},
|
|
36
21
|
yvWETH: {
|
|
37
22
|
name: "Yearn yvWETH",
|
|
@@ -39,13 +24,6 @@ exports.yearnTokens = {
|
|
|
39
24
|
type: tokenType_1.TokenType.YEARN_ON_NORMAL_TOKEN,
|
|
40
25
|
underlying: "WETH",
|
|
41
26
|
vault: "YEARN_WETH_VAULT",
|
|
42
|
-
lpActions: [
|
|
43
|
-
{
|
|
44
|
-
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
45
|
-
contract: "YEARN_WETH_VAULT",
|
|
46
|
-
tokenOut: "WETH",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
27
|
},
|
|
50
28
|
yvWBTC: {
|
|
51
29
|
name: "Yearn yvWBTC",
|
|
@@ -53,13 +31,6 @@ exports.yearnTokens = {
|
|
|
53
31
|
type: tokenType_1.TokenType.YEARN_ON_NORMAL_TOKEN,
|
|
54
32
|
underlying: "WBTC",
|
|
55
33
|
vault: "YEARN_WBTC_VAULT",
|
|
56
|
-
lpActions: [
|
|
57
|
-
{
|
|
58
|
-
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
59
|
-
contract: "YEARN_WBTC_VAULT",
|
|
60
|
-
tokenOut: "WBTC",
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
34
|
},
|
|
64
35
|
// YEARN- CURVE TOKENS
|
|
65
36
|
yvCurve_stETH: {
|
|
@@ -68,13 +39,6 @@ exports.yearnTokens = {
|
|
|
68
39
|
type: tokenType_1.TokenType.YEARN_ON_CURVE_TOKEN,
|
|
69
40
|
underlying: "steCRV",
|
|
70
41
|
vault: "YEARN_CURVE_STETH_VAULT",
|
|
71
|
-
lpActions: [
|
|
72
|
-
{
|
|
73
|
-
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
74
|
-
contract: "YEARN_CURVE_STETH_VAULT",
|
|
75
|
-
tokenOut: "steCRV",
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
42
|
},
|
|
79
43
|
yvCurve_FRAX: {
|
|
80
44
|
name: "Yearn yvCurve-FRAX",
|
|
@@ -82,13 +46,6 @@ exports.yearnTokens = {
|
|
|
82
46
|
type: tokenType_1.TokenType.YEARN_ON_CURVE_TOKEN,
|
|
83
47
|
underlying: "FRAX3CRV",
|
|
84
48
|
vault: "YEARN_CURVE_FRAX_VAULT",
|
|
85
|
-
lpActions: [
|
|
86
|
-
{
|
|
87
|
-
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
88
|
-
contract: "YEARN_CURVE_FRAX_VAULT",
|
|
89
|
-
tokenOut: "FRAX3CRV",
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
49
|
},
|
|
93
50
|
};
|
|
94
51
|
const isYearnLPToken = (t) => typeof t === "string" && !!exports.yearnTokens[t];
|
package/lib/utils/multicall.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function multicall<R extends Array<any>>(calls: Array<MCall<any>>
|
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
24
|
export declare function safeMulticall<V = any, T extends MCall<any> = MCall<any>>(calls: T[], p: Signer | ethers.providers.Provider, overrides?: CallOverrides): Promise<Array<{
|
|
25
|
-
error
|
|
25
|
+
error?: Error;
|
|
26
26
|
value?: V;
|
|
27
27
|
}>>;
|
|
28
28
|
export declare class MultiCallContract<T extends ethers.utils.Interface> {
|
package/lib/utils/multicall.js
CHANGED
|
@@ -30,12 +30,27 @@ async function safeMulticall(calls, p, overrides) {
|
|
|
30
30
|
target: c.address,
|
|
31
31
|
callData: c.interface.encodeFunctionData(c.method, c.params),
|
|
32
32
|
})), overrides ?? {});
|
|
33
|
-
return resp.map((d, num) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
return resp.map((d, num) => {
|
|
34
|
+
let value;
|
|
35
|
+
let error;
|
|
36
|
+
if (d.success) {
|
|
37
|
+
try {
|
|
38
|
+
value = unwrapArray(calls[num].interface.decodeFunctionResult(calls[num].method, d.returnData));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (e instanceof Error) {
|
|
42
|
+
error = e;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
error = new Error(`${e}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
error = new Error("multicall call failed");
|
|
51
|
+
}
|
|
52
|
+
return { error, value };
|
|
53
|
+
});
|
|
39
54
|
}
|
|
40
55
|
exports.safeMulticall = safeMulticall;
|
|
41
56
|
function unwrapArray(data) {
|
package/package.json
CHANGED
package/lib/core/adapter.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AdapterInterface } from "../contracts/adapters";
|
|
2
|
-
import { SupportedContract } from "../contracts/contracts";
|
|
3
|
-
interface BaseAdapterProps {
|
|
4
|
-
name: string;
|
|
5
|
-
adapterInterface: AdapterInterface;
|
|
6
|
-
contractAddress: string;
|
|
7
|
-
adapterAddress: string;
|
|
8
|
-
contractSymbol: SupportedContract;
|
|
9
|
-
creditManager: string;
|
|
10
|
-
}
|
|
11
|
-
export declare class BaseAdapter {
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly adapterInterface: AdapterInterface;
|
|
14
|
-
readonly contractAddress: string;
|
|
15
|
-
readonly adapterAddress: string;
|
|
16
|
-
readonly contractSymbol: SupportedContract;
|
|
17
|
-
readonly creditManager: string;
|
|
18
|
-
constructor(props: BaseAdapterProps);
|
|
19
|
-
}
|
|
20
|
-
export {};
|
package/lib/core/adapter.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseAdapter = void 0;
|
|
4
|
-
class BaseAdapter {
|
|
5
|
-
name;
|
|
6
|
-
adapterInterface;
|
|
7
|
-
contractAddress;
|
|
8
|
-
adapterAddress;
|
|
9
|
-
contractSymbol;
|
|
10
|
-
creditManager;
|
|
11
|
-
constructor(props) {
|
|
12
|
-
this.name = props.name;
|
|
13
|
-
this.adapterInterface = props.adapterInterface;
|
|
14
|
-
this.adapterAddress = props.adapterAddress;
|
|
15
|
-
this.contractAddress = props.contractAddress;
|
|
16
|
-
this.contractSymbol = props.contractSymbol;
|
|
17
|
-
this.creditManager = props.creditManager;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.BaseAdapter = BaseAdapter;
|
package/lib/core/operations.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare class OperationData {
|
|
2
|
-
readonly id: number;
|
|
3
|
-
readonly address: string;
|
|
4
|
-
readonly txHash: string;
|
|
5
|
-
readonly blockNum: number;
|
|
6
|
-
readonly operation: string;
|
|
7
|
-
readonly timestamp: number;
|
|
8
|
-
readonly date: string;
|
|
9
|
-
constructor(payload: OperationDataPayload);
|
|
10
|
-
}
|
|
11
|
-
export interface OperationDataPayload {
|
|
12
|
-
id: number;
|
|
13
|
-
address: string;
|
|
14
|
-
txHash: string;
|
|
15
|
-
blockNum: number;
|
|
16
|
-
operation: string;
|
|
17
|
-
timestamp: number;
|
|
18
|
-
}
|
|
19
|
-
export interface OperationsList {
|
|
20
|
-
id: string;
|
|
21
|
-
data: Array<OperationData>;
|
|
22
|
-
}
|
package/lib/core/operations.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.OperationData = void 0;
|
|
7
|
-
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
class OperationData {
|
|
9
|
-
id;
|
|
10
|
-
address;
|
|
11
|
-
txHash;
|
|
12
|
-
blockNum;
|
|
13
|
-
operation;
|
|
14
|
-
timestamp;
|
|
15
|
-
date;
|
|
16
|
-
constructor(payload) {
|
|
17
|
-
this.id = payload.id;
|
|
18
|
-
this.address = payload.address;
|
|
19
|
-
this.txHash = payload.txHash;
|
|
20
|
-
this.blockNum = payload.blockNum;
|
|
21
|
-
this.operation = payload.operation;
|
|
22
|
-
this.timestamp = payload.timestamp;
|
|
23
|
-
this.date = (0, moment_1.default)(payload.timestamp * 1000).format("Do MMM YYYY");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.OperationData = OperationData;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { TokenData } from "../../tokens/tokenData";
|
|
2
|
-
export interface BasePoolOperation {
|
|
3
|
-
amount: string;
|
|
4
|
-
pool: string;
|
|
5
|
-
session_id: string;
|
|
6
|
-
timestamp: number;
|
|
7
|
-
tx_hash: string;
|
|
8
|
-
user: string;
|
|
9
|
-
}
|
|
10
|
-
export declare abstract class AbstractPoolOperation {
|
|
11
|
-
readonly txHash: string;
|
|
12
|
-
readonly date: string;
|
|
13
|
-
readonly timestamp: number;
|
|
14
|
-
readonly user: string;
|
|
15
|
-
readonly sessionId: string;
|
|
16
|
-
readonly pool: string;
|
|
17
|
-
readonly amount: bigint;
|
|
18
|
-
constructor(opts: BasePoolOperation);
|
|
19
|
-
abstract toString(token: TokenData): string;
|
|
20
|
-
}
|
|
21
|
-
export type PoolOperationResponse = BasePoolOperation & {
|
|
22
|
-
event: string;
|
|
23
|
-
};
|
|
24
|
-
export declare class PoolOperation extends AbstractPoolOperation {
|
|
25
|
-
readonly event: string;
|
|
26
|
-
constructor(ops: PoolOperationResponse);
|
|
27
|
-
toString(token: TokenData): string;
|
|
28
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PoolOperation = exports.AbstractPoolOperation = void 0;
|
|
4
|
-
const moment_1 = require("moment");
|
|
5
|
-
const contractsRegister_1 = require("../../contracts/contractsRegister");
|
|
6
|
-
const formatter_1 = require("../../utils/formatter");
|
|
7
|
-
class AbstractPoolOperation {
|
|
8
|
-
txHash;
|
|
9
|
-
date;
|
|
10
|
-
timestamp;
|
|
11
|
-
user;
|
|
12
|
-
sessionId;
|
|
13
|
-
pool;
|
|
14
|
-
amount;
|
|
15
|
-
constructor(opts) {
|
|
16
|
-
this.txHash = opts.tx_hash;
|
|
17
|
-
this.amount = BigInt(opts.amount);
|
|
18
|
-
this.pool = opts.pool;
|
|
19
|
-
this.sessionId = opts.session_id;
|
|
20
|
-
this.user = opts.user;
|
|
21
|
-
this.timestamp = opts.timestamp;
|
|
22
|
-
this.date = (0, moment_1.unix)(opts.timestamp).format("Do MMM YYYY");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.AbstractPoolOperation = AbstractPoolOperation;
|
|
26
|
-
class PoolOperation extends AbstractPoolOperation {
|
|
27
|
-
event;
|
|
28
|
-
constructor(ops) {
|
|
29
|
-
super(ops);
|
|
30
|
-
this.event = ops.event;
|
|
31
|
-
}
|
|
32
|
-
toString(token) {
|
|
33
|
-
return `${this.event} ${(0, formatter_1.formatBN)(this.amount, token.decimals)} ${(0, contractsRegister_1.getContractName)(this.pool)}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.PoolOperation = PoolOperation;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { AaveV2PoolContract, CompoundV2PoolContract, ConvexPoolContract, CurvePoolContract, UniswapV2Contract, YearnVaultContract } from "../contracts/contracts";
|
|
2
|
-
import { AaveV2LPToken } from "../tokens/aave";
|
|
3
|
-
import { BalancerLPToken } from "../tokens/balancer";
|
|
4
|
-
import { CompoundV2LPToken } from "../tokens/compound";
|
|
5
|
-
import type { ConvexLPToken, ConvexStakedPhantomToken } from "../tokens/convex";
|
|
6
|
-
import type { CurveLPToken } from "../tokens/curveLP";
|
|
7
|
-
import type { NormalToken } from "../tokens/normal";
|
|
8
|
-
import type { YearnLPToken } from "../tokens/yearn";
|
|
9
|
-
export declare enum TradeType {
|
|
10
|
-
UniswapV2Swap = 0,
|
|
11
|
-
UniswapV3Swap = 1,
|
|
12
|
-
CurveExchange = 2,
|
|
13
|
-
CurveExchangeUnderlying = 3,
|
|
14
|
-
CurveDepositLP = 4,
|
|
15
|
-
CurveWithdrawLP = 5,
|
|
16
|
-
YearnDeposit = 6,
|
|
17
|
-
YearnWithdraw = 7,
|
|
18
|
-
LidoStake = 8,
|
|
19
|
-
ConvexDepositLP = 9,
|
|
20
|
-
ConvexStake = 10,
|
|
21
|
-
ConvexDepositLPAndStake = 11,
|
|
22
|
-
ConvexWithdrawLP = 12,
|
|
23
|
-
ConvexWithdraw = 13,
|
|
24
|
-
ConvexWithdrawAndUnwrap = 14,
|
|
25
|
-
BalancerJoin = 15,
|
|
26
|
-
BalancerExit = 16,
|
|
27
|
-
AaveV2Deposit = 17,
|
|
28
|
-
AaveV2Withdraw = 18,
|
|
29
|
-
AaveV2Unwrap = 19,
|
|
30
|
-
CompoundV2Deposit = 20,
|
|
31
|
-
CompoundV2Withdraw = 21
|
|
32
|
-
}
|
|
33
|
-
export type TradeAction = {
|
|
34
|
-
type: TradeType.UniswapV2Swap;
|
|
35
|
-
contract: UniswapV2Contract;
|
|
36
|
-
tokenOut?: NormalToken;
|
|
37
|
-
} | {
|
|
38
|
-
type: TradeType.UniswapV3Swap;
|
|
39
|
-
contract: "UNISWAP_V3_ROUTER";
|
|
40
|
-
tokenOut?: NormalToken;
|
|
41
|
-
} | {
|
|
42
|
-
type: TradeType.CurveExchange;
|
|
43
|
-
contract: CurvePoolContract;
|
|
44
|
-
tokenOut: Array<NormalToken | CurveLPToken>;
|
|
45
|
-
} | {
|
|
46
|
-
type: TradeType.CurveDepositLP;
|
|
47
|
-
contract: CurvePoolContract;
|
|
48
|
-
tokenOut: CurveLPToken;
|
|
49
|
-
} | {
|
|
50
|
-
type: TradeType.CurveWithdrawLP;
|
|
51
|
-
contract: CurvePoolContract;
|
|
52
|
-
tokenOut: Array<CurveLPToken | NormalToken>;
|
|
53
|
-
} | {
|
|
54
|
-
type: TradeType.YearnDeposit;
|
|
55
|
-
contract: YearnVaultContract;
|
|
56
|
-
tokenOut: YearnLPToken;
|
|
57
|
-
} | {
|
|
58
|
-
type: TradeType.YearnWithdraw;
|
|
59
|
-
contract: YearnVaultContract;
|
|
60
|
-
tokenOut: NormalToken | CurveLPToken;
|
|
61
|
-
} | {
|
|
62
|
-
type: TradeType.LidoStake;
|
|
63
|
-
contract: "LIDO_STETH_GATEWAY";
|
|
64
|
-
tokenOut: NormalToken;
|
|
65
|
-
} | {
|
|
66
|
-
type: TradeType.ConvexDepositLP;
|
|
67
|
-
contract: "CONVEX_BOOSTER";
|
|
68
|
-
tokenOut: ConvexLPToken;
|
|
69
|
-
} | {
|
|
70
|
-
type: TradeType.ConvexStake;
|
|
71
|
-
contract: ConvexPoolContract;
|
|
72
|
-
tokenOut: ConvexStakedPhantomToken;
|
|
73
|
-
} | {
|
|
74
|
-
type: TradeType.ConvexDepositLPAndStake;
|
|
75
|
-
contract: "CONVEX_BOOSTER";
|
|
76
|
-
tokenOut: ConvexStakedPhantomToken;
|
|
77
|
-
} | {
|
|
78
|
-
type: TradeType.ConvexWithdrawLP;
|
|
79
|
-
contract: "CONVEX_BOOSTER";
|
|
80
|
-
tokenOut: CurveLPToken;
|
|
81
|
-
} | {
|
|
82
|
-
type: TradeType.ConvexWithdraw;
|
|
83
|
-
contract: ConvexPoolContract;
|
|
84
|
-
tokenOut: ConvexLPToken;
|
|
85
|
-
} | {
|
|
86
|
-
type: TradeType.ConvexWithdrawAndUnwrap;
|
|
87
|
-
contract: ConvexPoolContract;
|
|
88
|
-
tokenOut: CurveLPToken;
|
|
89
|
-
} | {
|
|
90
|
-
type: TradeType.BalancerJoin;
|
|
91
|
-
contract: "BALANCER_VAULT";
|
|
92
|
-
tokenOut: BalancerLPToken;
|
|
93
|
-
} | {
|
|
94
|
-
type: TradeType.BalancerExit;
|
|
95
|
-
contract: "BALANCER_VAULT";
|
|
96
|
-
tokenOut: Array<NormalToken | BalancerLPToken>;
|
|
97
|
-
} | {
|
|
98
|
-
type: TradeType.AaveV2Deposit;
|
|
99
|
-
contract: AaveV2PoolContract;
|
|
100
|
-
tokenOut: AaveV2LPToken;
|
|
101
|
-
} | {
|
|
102
|
-
type: TradeType.AaveV2Withdraw;
|
|
103
|
-
contract: AaveV2PoolContract;
|
|
104
|
-
tokenOut: NormalToken;
|
|
105
|
-
} | {
|
|
106
|
-
type: TradeType.CompoundV2Deposit;
|
|
107
|
-
contract: CompoundV2PoolContract;
|
|
108
|
-
tokenOut: CompoundV2LPToken;
|
|
109
|
-
} | {
|
|
110
|
-
type: TradeType.CompoundV2Withdraw;
|
|
111
|
-
contract: CompoundV2PoolContract;
|
|
112
|
-
tokenOut: NormalToken;
|
|
113
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TradeType = void 0;
|
|
4
|
-
var TradeType;
|
|
5
|
-
(function (TradeType) {
|
|
6
|
-
TradeType[TradeType["UniswapV2Swap"] = 0] = "UniswapV2Swap";
|
|
7
|
-
TradeType[TradeType["UniswapV3Swap"] = 1] = "UniswapV3Swap";
|
|
8
|
-
TradeType[TradeType["CurveExchange"] = 2] = "CurveExchange";
|
|
9
|
-
TradeType[TradeType["CurveExchangeUnderlying"] = 3] = "CurveExchangeUnderlying";
|
|
10
|
-
TradeType[TradeType["CurveDepositLP"] = 4] = "CurveDepositLP";
|
|
11
|
-
TradeType[TradeType["CurveWithdrawLP"] = 5] = "CurveWithdrawLP";
|
|
12
|
-
TradeType[TradeType["YearnDeposit"] = 6] = "YearnDeposit";
|
|
13
|
-
TradeType[TradeType["YearnWithdraw"] = 7] = "YearnWithdraw";
|
|
14
|
-
TradeType[TradeType["LidoStake"] = 8] = "LidoStake";
|
|
15
|
-
TradeType[TradeType["ConvexDepositLP"] = 9] = "ConvexDepositLP";
|
|
16
|
-
TradeType[TradeType["ConvexStake"] = 10] = "ConvexStake";
|
|
17
|
-
TradeType[TradeType["ConvexDepositLPAndStake"] = 11] = "ConvexDepositLPAndStake";
|
|
18
|
-
TradeType[TradeType["ConvexWithdrawLP"] = 12] = "ConvexWithdrawLP";
|
|
19
|
-
TradeType[TradeType["ConvexWithdraw"] = 13] = "ConvexWithdraw";
|
|
20
|
-
TradeType[TradeType["ConvexWithdrawAndUnwrap"] = 14] = "ConvexWithdrawAndUnwrap";
|
|
21
|
-
TradeType[TradeType["BalancerJoin"] = 15] = "BalancerJoin";
|
|
22
|
-
TradeType[TradeType["BalancerExit"] = 16] = "BalancerExit";
|
|
23
|
-
TradeType[TradeType["AaveV2Deposit"] = 17] = "AaveV2Deposit";
|
|
24
|
-
TradeType[TradeType["AaveV2Withdraw"] = 18] = "AaveV2Withdraw";
|
|
25
|
-
TradeType[TradeType["AaveV2Unwrap"] = 19] = "AaveV2Unwrap";
|
|
26
|
-
TradeType[TradeType["CompoundV2Deposit"] = 20] = "CompoundV2Deposit";
|
|
27
|
-
TradeType[TradeType["CompoundV2Withdraw"] = 21] = "CompoundV2Withdraw";
|
|
28
|
-
})(TradeType = exports.TradeType || (exports.TradeType = {}));
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { BigNumberish } from "ethers";
|
|
2
|
-
import { ConvexPoolContract } from "../contracts/contracts";
|
|
3
|
-
import { NetworkType } from "../core/chains";
|
|
4
|
-
import { CreditManagerData } from "../core/creditManager";
|
|
5
|
-
import { MultiCallStruct } from "../types/@gearbox-protocol/router/contracts/interfaces/IClosePathResolver";
|
|
6
|
-
export declare class ConvexBoosterCalls {
|
|
7
|
-
static deposit(pid: BigNumberish, amount: BigNumberish, stake: boolean): string;
|
|
8
|
-
static depositAll(pid: BigNumberish, stake: boolean): string;
|
|
9
|
-
static withdraw(pid: BigNumberish, amount: BigNumberish): string;
|
|
10
|
-
static withdrawAll(pid: BigNumberish): string;
|
|
11
|
-
}
|
|
12
|
-
export declare class ConvexPoolCalls {
|
|
13
|
-
static stake(amount: BigNumberish): string;
|
|
14
|
-
static stakeAll(): string;
|
|
15
|
-
static withdraw(amount: BigNumberish, claim: boolean): string;
|
|
16
|
-
static withdrawAll(claim: boolean): string;
|
|
17
|
-
static withdrawAndUnwrap(amount: BigNumberish, claim: boolean): string;
|
|
18
|
-
static withdrawAllAndUnwrap(claim: boolean): string;
|
|
19
|
-
}
|
|
20
|
-
export declare class ConvexClaimZapCalls {
|
|
21
|
-
static claimRewards(rewardContracts: Array<string>, extraRewardContracts: Array<string>, tokenRewardContracts: Array<string>, tokenRewardTokens: Array<string>, depositCrvMaxAmount: BigNumberish, minAmountOut: BigNumberish, depositCvxMaxAmount: BigNumberish, spendCvxAmount: BigNumberish, options: BigNumberish): string;
|
|
22
|
-
}
|
|
23
|
-
export declare class ConvexBoosterMulticaller {
|
|
24
|
-
private readonly _address;
|
|
25
|
-
constructor(address: string);
|
|
26
|
-
static connect(address: string): ConvexBoosterMulticaller;
|
|
27
|
-
deposit(pid: BigNumberish, amount: BigNumberish, stake: boolean): MultiCallStruct;
|
|
28
|
-
depositAll(pid: BigNumberish, stake: boolean): MultiCallStruct;
|
|
29
|
-
withdraw(pid: BigNumberish, amount: BigNumberish): MultiCallStruct;
|
|
30
|
-
withdrawAll(pid: BigNumberish): MultiCallStruct;
|
|
31
|
-
}
|
|
32
|
-
export declare class ConvexPoolMulticaller {
|
|
33
|
-
private readonly _address;
|
|
34
|
-
constructor(address: string);
|
|
35
|
-
static connect(address: string): ConvexPoolMulticaller;
|
|
36
|
-
stake(amount: BigNumberish): MultiCallStruct;
|
|
37
|
-
stakeAll(): MultiCallStruct;
|
|
38
|
-
withdraw(amount: BigNumberish, claim: boolean): MultiCallStruct;
|
|
39
|
-
withdrawAll(claim: boolean): MultiCallStruct;
|
|
40
|
-
withdrawAndUnwrap(amount: BigNumberish, claim: boolean): MultiCallStruct;
|
|
41
|
-
withdrawAllAndUnwrap(claim: boolean): {
|
|
42
|
-
target: string;
|
|
43
|
-
callData: string;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export declare class ConvexClaimZapMulticaller {
|
|
47
|
-
private readonly _address;
|
|
48
|
-
constructor(address: string);
|
|
49
|
-
static connect(address: string): ConvexClaimZapMulticaller;
|
|
50
|
-
claimRewards(rewardContracts: Array<string>, extraRewardContracts: Array<string>, tokenRewardContracts: Array<string>, tokenRewardTokens: Array<string>, depositCrvMaxAmount: BigNumberish, minAmountOut: BigNumberish, depositCvxMaxAmount: BigNumberish, spendCvxAmount: BigNumberish, options: BigNumberish): MultiCallStruct;
|
|
51
|
-
}
|
|
52
|
-
export declare class ConvexStrategies {
|
|
53
|
-
static underlyingToStakedConvex(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract, underlyingAmount: BigNumberish): MultiCallStruct[];
|
|
54
|
-
static stakedConvexToUnderlying(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract, convexLpAmount: BigNumberish, sellRewards: boolean): MultiCallStruct[];
|
|
55
|
-
static allStakedConvexToUnderlying(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract, sellRewards: boolean): MultiCallStruct[];
|
|
56
|
-
static sellRewards(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract): MultiCallStruct[];
|
|
57
|
-
}
|