impermax-sdk 2.1.74 → 2.1.76
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/abis/contracts/ActionsGetter.json +9757 -0
- package/lib/abis/contracts/IV3BaseRouter01.json +1068 -0
- package/lib/config/contracts/routers.d.ts +1 -0
- package/lib/config/contracts/routers.js +25 -2
- package/lib/config/general.d.ts +1 -0
- package/lib/config/general.js +2 -1
- package/lib/config/subgraphs.js +3 -3
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.d.ts +1 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.js +1 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.d.ts +31 -1
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.js +74 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.js +28 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.d.ts +1 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.js +7 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.d.ts +1 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.js +1 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.d.ts +1 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.js +1 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.d.ts +2 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.js +11 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.d.ts +18 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.js +11 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.d.ts +30 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +214 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.d.ts +1 -1
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.js +2 -1
- package/lib/onchain/onchainContractsHelper.d.ts +1 -0
- package/lib/onchain/onchainContractsHelper.js +5 -4
- package/lib/utils/nftlpMath/uniswapV3Position.d.ts +27 -0
- package/lib/utils/nftlpMath/uniswapV3Position.js +73 -0
- package/package.json +1 -1
- package/lib/abis/contracts/ImpermaxV3UniV2Router01.json +0 -32488
- package/lib/abis/contracts/ImpermaxV3UniV3Router01.json +0 -37742
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, NetworkExtensionIndex, NetworkFactoryIndex, NetworkIndex } from '../types';
|
|
2
2
|
export declare const POOL_TOKEN_ROUTER: NetworkIndex<Address>;
|
|
3
3
|
export declare const ROUTER: NetworkFactoryIndex<Address>;
|
|
4
|
+
export declare const ACTIONS_GETTER: NetworkIndex<Address>;
|
|
4
5
|
export declare const ROUTER_V3: NetworkExtensionIndex<Address>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ROUTER_V3 = exports.ROUTER = exports.POOL_TOKEN_ROUTER = void 0;
|
|
3
|
+
exports.ROUTER_V3 = exports.ACTIONS_GETTER = exports.ROUTER = exports.POOL_TOKEN_ROUTER = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
exports.POOL_TOKEN_ROUTER = {
|
|
6
6
|
[types_1.Networks.Ropsten]: '0xbFf4acF789297A8507Eb7493AE18EB2C3A3A9632',
|
|
@@ -96,6 +96,29 @@ exports.ROUTER = {
|
|
|
96
96
|
[types_1.Factory.SOLV2]: '0xcBdf792456367a91708C0036E0678eCFB1f09654',
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
+
exports.ACTIONS_GETTER = {
|
|
100
|
+
[types_1.Networks.Ropsten]: '',
|
|
101
|
+
[types_1.Networks.Mainnet]: '',
|
|
102
|
+
[types_1.Networks.Polygon]: '',
|
|
103
|
+
[types_1.Networks.Arbitrum]: '',
|
|
104
|
+
[types_1.Networks.Avalanche]: '',
|
|
105
|
+
[types_1.Networks.Moonriver]: '',
|
|
106
|
+
[types_1.Networks.Aurora]: '',
|
|
107
|
+
[types_1.Networks.Cronos]: '',
|
|
108
|
+
[types_1.Networks.Fantom]: '',
|
|
109
|
+
[types_1.Networks.Canto]: '',
|
|
110
|
+
[types_1.Networks.ZksyncEra]: '',
|
|
111
|
+
[types_1.Networks.Blast]: '',
|
|
112
|
+
[types_1.Networks.Harmony]: '',
|
|
113
|
+
[types_1.Networks.Moonbeam]: '',
|
|
114
|
+
[types_1.Networks.Sxnetwork]: '',
|
|
115
|
+
[types_1.Networks.Base]: '0xcc123Ca0A1e6626d05F86fe7bc86d460450F1fC7',
|
|
116
|
+
[types_1.Networks.Scroll]: '',
|
|
117
|
+
[types_1.Networks.Real]: '',
|
|
118
|
+
[types_1.Networks.Mantle]: '',
|
|
119
|
+
[types_1.Networks.Optimism]: '',
|
|
120
|
+
[types_1.Networks.Sonic]: '',
|
|
121
|
+
};
|
|
99
122
|
exports.ROUTER_V3 = {
|
|
100
123
|
[types_1.Networks.Ropsten]: {},
|
|
101
124
|
[types_1.Networks.Mainnet]: {},
|
|
@@ -113,7 +136,7 @@ exports.ROUTER_V3 = {
|
|
|
113
136
|
[types_1.Networks.Moonbeam]: {},
|
|
114
137
|
[types_1.Networks.Sxnetwork]: {},
|
|
115
138
|
[types_1.Networks.Base]: {
|
|
116
|
-
[types_1.Extension.UniswapV3]: '
|
|
139
|
+
[types_1.Extension.UniswapV3]: '0xDEB4f03a1cD793C534eB4B58C77e7BA195DAbFf6'
|
|
117
140
|
},
|
|
118
141
|
[types_1.Networks.Scroll]: {},
|
|
119
142
|
[types_1.Networks.Optimism]: {},
|
package/lib/config/general.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export declare const NOT_SYNCED = false;
|
|
|
3
3
|
export declare const DEADLINE: BigNumber;
|
|
4
4
|
export declare const ZERO: BigNumber;
|
|
5
5
|
export declare const APPROVE_AMOUNT: BigNumber;
|
|
6
|
+
export declare const MAX_UINT: BigNumber;
|
|
6
7
|
export declare const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
package/lib/config/general.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PERMIT2_ADDRESS = exports.APPROVE_AMOUNT = exports.ZERO = exports.DEADLINE = exports.NOT_SYNCED = void 0;
|
|
3
|
+
exports.PERMIT2_ADDRESS = exports.MAX_UINT = exports.APPROVE_AMOUNT = exports.ZERO = exports.DEADLINE = exports.NOT_SYNCED = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
exports.NOT_SYNCED = false;
|
|
6
6
|
exports.DEADLINE = ethers_1.BigNumber.from(Math.floor(Date.now() / 1000) + 3600 * 24 * 365); //1 year deadline
|
|
7
7
|
exports.ZERO = ethers_1.ethers.constants.Zero;
|
|
8
8
|
exports.APPROVE_AMOUNT = ethers_1.ethers.constants.MaxUint256;
|
|
9
|
+
exports.MAX_UINT = ethers_1.ethers.constants.MaxUint256;
|
|
9
10
|
exports.PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -93,15 +93,15 @@ exports.IMPERMAX_SUBGRAPH_URL = {
|
|
|
93
93
|
[types_1.Networks.Base]: {
|
|
94
94
|
[types_1.Factory.SOLV2]: [
|
|
95
95
|
"https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/EjB7Dsb7WnfFf1NPPr5rbGnGmk2Jqs42nWPVHjv9997u",
|
|
96
|
-
"https://base-
|
|
96
|
+
"https://base-factory-production.up.railway.app/",
|
|
97
97
|
],
|
|
98
98
|
[types_1.Factory.SOL_STABLE]: [
|
|
99
99
|
"https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/9wN7xinUXf8RP8dbwpkzSmCNQKfz31FDpvPEvTQyT8SL",
|
|
100
|
-
"https://base-
|
|
100
|
+
"https://base-factory-production.up.railway.app/",
|
|
101
101
|
],
|
|
102
102
|
[types_1.Factory.V2V2]: [
|
|
103
103
|
"https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/B7xsBeef3FohKaFPcsAsviyLKaWXTqcSELjAsPj2B7iW",
|
|
104
|
-
"https://base-
|
|
104
|
+
"https://base-factory-production.up.railway.app/",
|
|
105
105
|
],
|
|
106
106
|
[types_1.Factory.V3]: [
|
|
107
107
|
"https://impermax-indexer-production.up.railway.app/",
|
|
@@ -5,5 +5,6 @@ export default abstract class OnchainAccountNftlp {
|
|
|
5
5
|
protected cache: {};
|
|
6
6
|
constructor(collateral: OnchainAccountCollateralV3);
|
|
7
7
|
getLendingPool: () => OnchainAccountLendingPoolV3;
|
|
8
|
+
getNftlp: () => import("../../../impermaxFactory/lendingPool/nftlp").OnchainNftlp;
|
|
8
9
|
cleanCache(): void;
|
|
9
10
|
}
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
import OnchainAccountNftlp from "./onchainAccountNftlp";
|
|
2
|
+
import UniswapV3Position from "../../../../utils/nftlpMath/uniswapV3Position";
|
|
3
|
+
interface PositionData {
|
|
4
|
+
fee: number;
|
|
5
|
+
tickLower: number;
|
|
6
|
+
tickUpper: number;
|
|
7
|
+
liquidity: number;
|
|
8
|
+
feeGrowthInside0LastX128: number;
|
|
9
|
+
feeGrowthInside1LastX128: number;
|
|
10
|
+
unclaimedFees0: number;
|
|
11
|
+
unclaimedFees1: number;
|
|
12
|
+
}
|
|
2
13
|
export default class OnchainAccountNftlpUniswapV3 extends OnchainAccountNftlp {
|
|
3
|
-
protected cache: {
|
|
14
|
+
protected cache: {
|
|
15
|
+
positionsData?: {
|
|
16
|
+
[keys in number]: Promise<PositionData>;
|
|
17
|
+
};
|
|
18
|
+
positionsObject?: {
|
|
19
|
+
[keys in number]: Promise<UniswapV3Position>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
protected initializePositionData(tokenId: number): Promise<PositionData>;
|
|
23
|
+
protected getPositionData(tokenId: number): Promise<PositionData>;
|
|
24
|
+
getFee(tokenId: number): Promise<number>;
|
|
25
|
+
getTickLower(tokenId: number): Promise<number>;
|
|
26
|
+
getTickUpper(tokenId: number): Promise<number>;
|
|
27
|
+
getPriceA(tokenId: number): Promise<number>;
|
|
28
|
+
getPriceB(tokenId: number): Promise<number>;
|
|
29
|
+
getLiquidity(tokenId: number): Promise<number>;
|
|
30
|
+
createPositionObject(tokenId: number, lockStateChange?: boolean): Promise<UniswapV3Position>;
|
|
31
|
+
createNewPositionObject(fee: number, tickLower: number, tickUpper: number, lockStateChange?: boolean): Promise<UniswapV3Position>;
|
|
32
|
+
getPositionObject(tokenId: number): Promise<UniswapV3Position>;
|
|
4
33
|
}
|
|
34
|
+
export {};
|
|
@@ -1,13 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
const onchainAccountNftlp_1 = __importDefault(require("./onchainAccountNftlp"));
|
|
16
|
+
const uniswapV3Position_1 = __importDefault(require("../../../../utils/nftlpMath/uniswapV3Position"));
|
|
7
17
|
class OnchainAccountNftlpUniswapV3 extends onchainAccountNftlp_1.default {
|
|
8
18
|
constructor() {
|
|
9
19
|
super(...arguments);
|
|
10
20
|
this.cache = {};
|
|
11
21
|
}
|
|
22
|
+
initializePositionData(tokenId) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const nftlp = yield this.getNftlp().getNftlp();
|
|
25
|
+
return yield nftlp.methods.positions(tokenId).call();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getPositionData(tokenId) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (!this.cache.positionsData)
|
|
31
|
+
this.cache.positionsData = {};
|
|
32
|
+
if (!this.cache.positionsData[tokenId])
|
|
33
|
+
this.cache.positionsData[tokenId] = this.initializePositionData(tokenId);
|
|
34
|
+
return this.cache.positionsData[tokenId];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getFee(tokenId) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return (yield this.getPositionData(tokenId)).fee / 10000;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
getTickLower(tokenId) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return (yield this.getPositionData(tokenId)).tickLower;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
getTickUpper(tokenId) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return (yield this.getPositionData(tokenId)).tickUpper;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
getPriceA(tokenId) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
return Math.pow(1.0001, yield this.getTickLower(tokenId));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getPriceB(tokenId) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return Math.pow(1.0001, yield this.getTickUpper(tokenId));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
getLiquidity(tokenId) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
return (yield this.getPositionData(tokenId)).liquidity / 1e18;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
createPositionObject(tokenId, lockStateChange = true) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return new uniswapV3Position_1.default(yield this.getLiquidity(tokenId), yield this.getLendingPool().getBorrowableA().getBorrowed(tokenId), yield this.getLendingPool().getBorrowableB().getBorrowed(tokenId), yield this.getNftlp().getMarketPrice(), yield this.getNftlp().getOraclePrice(), yield this.getPriceA(tokenId), yield this.getPriceB(tokenId), yield this.getLendingPool().getSafetyMargin(), yield this.getLendingPool().getLiquidationPenalty(), lockStateChange);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
createNewPositionObject(fee, tickLower, tickUpper, lockStateChange = false) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
return new uniswapV3Position_1.default(0, 0, 0, yield this.getNftlp().getMarketPrice(), yield this.getNftlp().getOraclePrice(), Math.pow(1.0001, tickLower), Math.pow(1.0001, tickUpper), yield this.getLendingPool().getSafetyMargin(), yield this.getLendingPool().getLiquidationPenalty(), lockStateChange);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getPositionObject(tokenId) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
if (!this.cache.positionsObject)
|
|
80
|
+
this.cache.positionsObject = {};
|
|
81
|
+
if (!this.cache.positionsObject[tokenId])
|
|
82
|
+
this.cache.positionsObject[tokenId] = this.createPositionObject(tokenId);
|
|
83
|
+
return this.cache.positionsObject[tokenId];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
12
86
|
}
|
|
13
87
|
exports.default = OnchainAccountNftlpUniswapV3;
|
|
@@ -19,6 +19,34 @@ class OnchainAccountBorrowableV3 extends onchainAccountBorrowable_1.default {
|
|
|
19
19
|
this.borrowableCache = {};
|
|
20
20
|
this.getLendingPool = () => this.lendingPool;
|
|
21
21
|
this.getPoolToken = () => this.poolToken;
|
|
22
|
+
// Max OffchainBorrowable
|
|
23
|
+
// binary search approach
|
|
24
|
+
/*public async getMaxBorrowable() : Promise<number> {
|
|
25
|
+
const availableCash = await this.poolToken.getTotalBalance();
|
|
26
|
+
const twapPrice = await this.lendingPool.getLendingPool().getNftlp().getOraclePrice();
|
|
27
|
+
|
|
28
|
+
// start search
|
|
29
|
+
let borrowAmount = availableCash;
|
|
30
|
+
let borrowAmountPrev = 0;
|
|
31
|
+
let bestAmount = 0;
|
|
32
|
+
for (let i = 0; i < 1000; i++) {
|
|
33
|
+
const jump = Math.abs(borrowAmount - borrowAmountPrev) / 2;
|
|
34
|
+
if (jump / availableCash < 1e-9) break;
|
|
35
|
+
borrowAmountPrev = borrowAmount;
|
|
36
|
+
const changeCollateral = 0;
|
|
37
|
+
const changeBorrowedA = this.getBorrowableType() == Borrowable.A ? borrowAmount : 0;
|
|
38
|
+
const changeBorrowedB = this.getBorrowableType() == Borrowable.B ? borrowAmount : 0;
|
|
39
|
+
const changes = { changeCollateral, changeBorrowedA, changeBorrowedB };
|
|
40
|
+
const [liqPriceA, liqPriceB] = await this.lendingPool.getLiquidationPrices(changes);
|
|
41
|
+
if (liqPriceA * this.getUiMargin() > twapPrice || liqPriceB / this.getUiMargin() < twapPrice) borrowAmount -= jump;
|
|
42
|
+
else {
|
|
43
|
+
bestAmount = borrowAmount;
|
|
44
|
+
borrowAmount += jump;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
bestAmount = bestAmount > availableCash ? availableCash : bestAmount;
|
|
48
|
+
return bestAmount;
|
|
49
|
+
}*/
|
|
22
50
|
}
|
|
23
51
|
// Borrowed
|
|
24
52
|
initializeBorrowed(tokenId) {
|
|
@@ -23,6 +23,7 @@ export default abstract class OnchainBorrowable extends OnchainPoolToken {
|
|
|
23
23
|
getOffchainBorrowable: () => Promise<OffchainBorrowable>;
|
|
24
24
|
protected abstract initializePoolToken(): Promise<Contract>;
|
|
25
25
|
protected initializeToken(): Promise<Contract>;
|
|
26
|
+
isETH(): Promise<boolean>;
|
|
26
27
|
private initializeBorrowTracker;
|
|
27
28
|
getBorrowTracker(): Promise<string>;
|
|
28
29
|
hasFarming(): Promise<boolean>;
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const onchainPoolToken_1 = __importDefault(require("../../onchainPoolToken"));
|
|
16
|
+
const weths_1 = require("../../../config/contracts/weths");
|
|
16
17
|
class OnchainBorrowable extends onchainPoolToken_1.default {
|
|
17
18
|
constructor(lendingPool, borrowable) {
|
|
18
19
|
super();
|
|
@@ -47,6 +48,12 @@ class OnchainBorrowable extends onchainPoolToken_1.default {
|
|
|
47
48
|
return this.getContractHelper().newERC20(yield poolToken.methods.underlying().call());
|
|
48
49
|
});
|
|
49
50
|
}
|
|
51
|
+
isETH() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const underlying = (yield this.getToken())._address;
|
|
54
|
+
return (underlying.toLowerCase() === weths_1.WETH[this.getLendingPool().getImpermaxFactory().getOnchain().network].toLowerCase());
|
|
55
|
+
});
|
|
56
|
+
}
|
|
50
57
|
// Farming Pool
|
|
51
58
|
initializeBorrowTracker() {
|
|
52
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -44,6 +44,7 @@ export default class OnchainLendingPoolV2 extends OnchainLendingPool {
|
|
|
44
44
|
getBorrowableA: () => OnchainBorrowableV2;
|
|
45
45
|
getBorrowableB: () => OnchainBorrowableV2;
|
|
46
46
|
getCollateral: () => OnchainCollateralV2;
|
|
47
|
+
getImpermaxFactory: () => OnchainImpermaxFactoryV2;
|
|
47
48
|
private initializeIsStakedLPToken;
|
|
48
49
|
getIsStakedLPToken(): Promise<boolean>;
|
|
49
50
|
private initializeStakedLPToken;
|
|
@@ -29,6 +29,7 @@ class OnchainLendingPoolV2 extends onchainLendingPool_1.default {
|
|
|
29
29
|
this.getBorrowableA = () => this.getBorrowable(types_1.Borrowable.A);
|
|
30
30
|
this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
|
|
31
31
|
this.getCollateral = () => this.collateral;
|
|
32
|
+
this.getImpermaxFactory = () => this.impermaxFactory;
|
|
32
33
|
}
|
|
33
34
|
getNewCollateralObject() {
|
|
34
35
|
return new onchainCollateralV2_1.default(this);
|
|
@@ -19,6 +19,7 @@ class OnchainLendingPoolV3 extends onchainLendingPool_1.default {
|
|
|
19
19
|
this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
|
|
20
20
|
this.getCollateral = () => this.collateral;
|
|
21
21
|
this.getNftlp = () => this.collateral.getNftlp();
|
|
22
|
+
this.getImpermaxFactory = () => this.impermaxFactory;
|
|
22
23
|
}
|
|
23
24
|
getNewCollateralObject() {
|
|
24
25
|
return new onchainCollateralV3_1.default(this);
|
|
@@ -6,11 +6,13 @@ export default class OnchainImpermaxFactoryV3 extends OnchainImpermaxFactory {
|
|
|
6
6
|
protected cache: {
|
|
7
7
|
poolTokenRouterContract?: Contract;
|
|
8
8
|
factoryContract?: Contract;
|
|
9
|
+
actionsGetterContract?: Contract;
|
|
9
10
|
routerExtensionContract: {
|
|
10
11
|
[key in Extension]?: Contract;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
getRouterExtension(extension: Extension): any;
|
|
14
15
|
getFactoryContract(): Promise<any>;
|
|
16
|
+
getActionsGetter(): any;
|
|
15
17
|
protected getNewLendingPoolObject(id: Address): any;
|
|
16
18
|
}
|
|
@@ -81,6 +81,17 @@ class OnchainImpermaxFactoryV3 extends onchainImpermaxFactory_1.default {
|
|
|
81
81
|
return this.cache.factoryContract;
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
+
getActionsGetter() {
|
|
85
|
+
if (!this.cache.actionsGetterContract) {
|
|
86
|
+
const address = routers_1.ACTIONS_GETTER[this.onchain.network];
|
|
87
|
+
if (!address) {
|
|
88
|
+
console.error("Actions getter address not found");
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
this.cache.actionsGetterContract = this.onchain.getContractHelper().newActionsGetter(address);
|
|
92
|
+
}
|
|
93
|
+
return this.cache.actionsGetterContract;
|
|
94
|
+
}
|
|
84
95
|
getNewLendingPoolObject(id) {
|
|
85
96
|
return new lendingPool_1.OnchainLendingPoolV3(this, id);
|
|
86
97
|
}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import OnchainInteractionsLendingPoolV3 from "../onchainInteractionsLendingPoolV3";
|
|
2
2
|
import { OnchainInteractionsCollateralV3 } from "../index";
|
|
3
|
+
import { Permits } from "../../../onchainTypes";
|
|
4
|
+
import { BigNumber } from "ethers";
|
|
3
5
|
export default abstract class OnchainInteractionsNftlp {
|
|
4
6
|
protected readonly collateral: OnchainInteractionsCollateralV3;
|
|
5
7
|
protected cache: {};
|
|
6
8
|
constructor(collateral: OnchainInteractionsCollateralV3);
|
|
7
9
|
getLendingPool: () => OnchainInteractionsLendingPoolV3;
|
|
10
|
+
getNftlp: () => import("../../../impermaxFactory/lendingPool/nftlp").OnchainNftlp;
|
|
11
|
+
getActionsGetter: () => any;
|
|
12
|
+
getAccountNftlp: () => import("../../../account/lendingPool/nftlp").OnchainAccountNftlp;
|
|
13
|
+
getAccountAddress: () => string;
|
|
14
|
+
protected getUiMargin: () => number;
|
|
15
|
+
protected getDust: () => number;
|
|
16
|
+
protected encodePermits: (permits: Permits) => string;
|
|
8
17
|
cleanCache(): void;
|
|
18
|
+
protected encodeActions(actions?: Array<any>): string;
|
|
19
|
+
abstract getModifyExistingPositionActions(tokenId: number, depositADelta: number, depositBDelta: number, borrowADelta: number, borrowBDelta: number): Promise<{
|
|
20
|
+
actions: Array<any>;
|
|
21
|
+
ethValue: number;
|
|
22
|
+
approveA: number;
|
|
23
|
+
approveB: number;
|
|
24
|
+
withCollateralTransfer: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
abstract execute(tokenId: number, actions: Array<any>, permits: Permits, withCollateralTransfer: boolean, ethValue: BigNumber, onTransactionHash: Function): any;
|
|
9
27
|
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
3
4
|
class OnchainInteractionsNftlp {
|
|
4
5
|
constructor(collateral) {
|
|
5
6
|
this.cache = {};
|
|
6
7
|
this.getLendingPool = () => this.collateral.getLendingPool();
|
|
8
|
+
this.getNftlp = () => this.getLendingPool().getLendingPool().getNftlp();
|
|
9
|
+
this.getActionsGetter = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getActionsGetter();
|
|
10
|
+
this.getAccountNftlp = () => this.getLendingPool().getAccountLendingPool().getNftlp();
|
|
11
|
+
this.getAccountAddress = () => this.getLendingPool().getAccountAddress();
|
|
12
|
+
this.getUiMargin = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getOnchain().uiMargin;
|
|
13
|
+
this.getDust = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getOnchain().dust;
|
|
14
|
+
this.encodePermits = (permits) => this.getLendingPool().getInteractions().getOnchain().getPermitHelper().encodePermits(permits);
|
|
7
15
|
this.collateral = collateral;
|
|
8
16
|
}
|
|
9
17
|
cleanCache() {
|
|
10
18
|
this.cache = {};
|
|
11
19
|
}
|
|
20
|
+
encodeActions(actions = []) {
|
|
21
|
+
return ethers_1.ethers.utils.defaultAbiCoder.encode(['tuple(uint256 actionType, bytes actionData, bytes nextAction)[]'], [actions]);
|
|
22
|
+
}
|
|
12
23
|
}
|
|
13
24
|
exports.default = OnchainInteractionsNftlp;
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
import OnchainInteractionsNftlp from "./onchainInteractionsNftlp";
|
|
2
|
+
import { Permits } from "../../../onchainTypes";
|
|
3
|
+
import { OnchainAccountNftlpUniswapV3 } from "../../../account/lendingPool/nftlp";
|
|
4
|
+
import { BigNumber } from "ethers";
|
|
5
|
+
import UniswapV3Position from "../../../../utils/nftlpMath/uniswapV3Position";
|
|
2
6
|
export default class OnchainInteractionsNftlpUniswapV3 extends OnchainInteractionsNftlp {
|
|
3
7
|
protected cache: {};
|
|
8
|
+
getUniswapV3Router: () => any;
|
|
9
|
+
getNftlp: () => any;
|
|
10
|
+
getAccountNftlp: () => OnchainAccountNftlpUniswapV3;
|
|
11
|
+
protected getMintEmptyAction(): Promise<any>;
|
|
12
|
+
getCreateNewPositionActions(fee: number, tickLower: number, tickUpper: number, depositADelta: number, depositBDelta: number, borrowADelta: number, borrowBDelta: number): Promise<{
|
|
13
|
+
actions: Array<any>;
|
|
14
|
+
ethValue: number;
|
|
15
|
+
approveA: number;
|
|
16
|
+
approveB: number;
|
|
17
|
+
withCollateralTransfer: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
getModifyExistingPositionActions(tokenId: number, depositADelta: number, depositBDelta: number, borrowADelta: number, borrowBDelta: number): Promise<{
|
|
20
|
+
actions: any[];
|
|
21
|
+
ethValue: number;
|
|
22
|
+
approveA: number;
|
|
23
|
+
approveB: number;
|
|
24
|
+
withCollateralTransfer: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
_getUpdatePositionActions(tokenId: number, positionObject: UniswapV3Position, depositADelta: number, depositBDelta: number, borrowADelta: number, borrowBDelta: number): Promise<{
|
|
27
|
+
actions: any[];
|
|
28
|
+
ethValue: number;
|
|
29
|
+
approveA: number;
|
|
30
|
+
approveB: number;
|
|
31
|
+
withCollateralTransfer: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
execute(tokenId: number, actions: Array<any>, permits: Permits, withCollateralTransfer: boolean, ethValue: BigNumber, onTransactionHash: Function): Promise<any>;
|
|
4
34
|
}
|