impermax-sdk 2.1.249 → 2.1.251
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/offchain/lendingPool/nftlp/offchainNftlp.d.ts +2 -0
- package/lib/offchain/lendingPool/nftlp/offchainNftlpUniswapV3.d.ts +2 -0
- package/lib/offchain/lendingPool/nftlp/offchainNftlpUniswapV3.js +4 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.d.ts +2 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.d.ts +2 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.js +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.d.ts +1 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.js +1 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.d.ts +0 -1
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +3 -5
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.d.ts +9 -1
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.js +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.d.ts +0 -6
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.js +16 -28
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.d.ts +1 -1
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.js +4 -4
- package/lib/onchain/onchainPermitHelper.d.ts +1 -0
- package/lib/onchain/onchainPermitHelper.js +15 -0
- package/lib/onchain/onchainTypes.d.ts +2 -1
- package/lib/onchain/onchainTypes.js +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import OffchainCollateralV3 from "../offchainCollateralV3";
|
|
2
2
|
import OffchainAccountCollateralV3 from "../../account/lendingPool/offchainAccountCollateralV3";
|
|
3
3
|
import OffchainAccountNftlp from "../../account/lendingPool/nftlp/offchainAccountNftlp";
|
|
4
|
+
import { Extension } from "../../../config/types";
|
|
4
5
|
export default abstract class OffchainNftlp {
|
|
5
6
|
protected readonly collateral: OffchainCollateralV3;
|
|
6
7
|
protected cache: {
|
|
@@ -8,6 +9,7 @@ export default abstract class OffchainNftlp {
|
|
|
8
9
|
oraclePrice?: Promise<number>;
|
|
9
10
|
};
|
|
10
11
|
constructor(collateral: OffchainCollateralV3);
|
|
12
|
+
abstract getExtension(): Extension;
|
|
11
13
|
abstract getNewAccountNftlpObject(accountCollateral: OffchainAccountCollateralV3): OffchainAccountNftlp;
|
|
12
14
|
getLendingPool: () => import("../offchainLendingPoolV3").default;
|
|
13
15
|
getNftlpAddress: () => string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import OffchainNftlp from "./offchainNftlp";
|
|
2
2
|
import OffchainAccountCollateralV3 from "../../account/lendingPool/offchainAccountCollateralV3";
|
|
3
3
|
import OffchainAccountNftlpUniswapV3 from "../../account/lendingPool/nftlp/offchainAccountNftlpUniswapV3";
|
|
4
|
+
import { Extension } from "../../../config/types";
|
|
4
5
|
export default class OffchainNftlpUniswapV3 extends OffchainNftlp {
|
|
5
6
|
protected cache: {
|
|
6
7
|
marketPrice?: Promise<number>;
|
|
@@ -9,6 +10,7 @@ export default class OffchainNftlpUniswapV3 extends OffchainNftlp {
|
|
|
9
10
|
[key in number]: Promise<number | null>;
|
|
10
11
|
};
|
|
11
12
|
};
|
|
13
|
+
getExtension(): Extension;
|
|
12
14
|
getNewAccountNftlpObject(accountCollateral: OffchainAccountCollateralV3): OffchainAccountNftlpUniswapV3;
|
|
13
15
|
protected initializeUniswapV3Pool(fee: number): Promise<{
|
|
14
16
|
price: number;
|
|
@@ -7,12 +7,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const offchainNftlp_1 = __importDefault(require("./offchainNftlp"));
|
|
8
8
|
const offchainAccountNftlpUniswapV3_1 = __importDefault(require("../../account/lendingPool/nftlp/offchainAccountNftlpUniswapV3"));
|
|
9
9
|
const uniswapV3General_1 = require("../../../utils/nftlpMath/uniswapV3General");
|
|
10
|
+
const types_1 = require("../../../config/types");
|
|
10
11
|
const FEES = [100, 500, 3000, 10000];
|
|
11
12
|
class OffchainNftlpUniswapV3 extends offchainNftlp_1.default {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
14
15
|
this.cache = {};
|
|
15
16
|
}
|
|
17
|
+
getExtension() {
|
|
18
|
+
return types_1.Extension.UniswapV3;
|
|
19
|
+
}
|
|
16
20
|
getNewAccountNftlpObject(accountCollateral) {
|
|
17
21
|
return new offchainAccountNftlpUniswapV3_1.default(accountCollateral);
|
|
18
22
|
}
|
|
@@ -5,6 +5,7 @@ import OnchainAccountNftlp from "../../../account/lendingPool/nftlp";
|
|
|
5
5
|
import { OnchainInteractionsCollateralV3 } from "../../../interactions/lendingPool";
|
|
6
6
|
import OnchainInteractionsNftlp from "../../../interactions/lendingPool/nftlp";
|
|
7
7
|
import OnchainCollateralV3 from "../onchainCollateralV3";
|
|
8
|
+
import { Extension } from "../../../../config/types";
|
|
8
9
|
export default abstract class OnchainNftlp {
|
|
9
10
|
protected readonly collateral: OnchainCollateralV3;
|
|
10
11
|
protected cache: {
|
|
@@ -12,6 +13,7 @@ export default abstract class OnchainNftlp {
|
|
|
12
13
|
marketPrice?: Promise<number>;
|
|
13
14
|
oraclePrice?: Promise<number>;
|
|
14
15
|
};
|
|
16
|
+
abstract getExtension(): Extension;
|
|
15
17
|
abstract getNewAccountNftlpObject(accountCollateral: OnchainAccountCollateralV3): OnchainAccountNftlp;
|
|
16
18
|
abstract getNewInteractionsNftlpObject(interactionsCollateral: OnchainInteractionsCollateralV3): OnchainInteractionsNftlp;
|
|
17
19
|
constructor(collateral: OnchainCollateralV3);
|
|
@@ -4,6 +4,7 @@ import { OnchainAccountCollateralV3 } from "../../../account/lendingPool";
|
|
|
4
4
|
import { OnchainAccountNftlpUniswapV3 } from "../../../account/lendingPool/nftlp";
|
|
5
5
|
import { OnchainInteractionsNftlpUniswapV3 } from "../../../interactions/lendingPool/nftlp";
|
|
6
6
|
import { OnchainInteractionsCollateralV3 } from "../../../interactions/lendingPool";
|
|
7
|
+
import { Extension } from "../../../../config/types";
|
|
7
8
|
export default class OnchainNftlpUniswapV3 extends OnchainNftlp {
|
|
8
9
|
protected cache: {
|
|
9
10
|
nftlp?: Contract;
|
|
@@ -13,6 +14,7 @@ export default class OnchainNftlpUniswapV3 extends OnchainNftlp {
|
|
|
13
14
|
marketPrice?: Promise<number>;
|
|
14
15
|
oraclePrice?: Promise<number>;
|
|
15
16
|
};
|
|
17
|
+
getExtension(): Extension;
|
|
16
18
|
getNewAccountNftlpObject(accountCollateral: OnchainAccountCollateralV3): OnchainAccountNftlpUniswapV3;
|
|
17
19
|
getNewInteractionsNftlpObject(interactionsCollateral: OnchainInteractionsCollateralV3): OnchainInteractionsNftlpUniswapV3;
|
|
18
20
|
protected initializeNftlp(): any;
|
|
@@ -7,6 +7,7 @@ const onchainNftlp_1 = __importDefault(require("./onchainNftlp"));
|
|
|
7
7
|
const nftlp_1 = require("../../../account/lendingPool/nftlp");
|
|
8
8
|
const nftlp_2 = require("../../../interactions/lendingPool/nftlp");
|
|
9
9
|
const uniswapV3General_1 = require("../../../../utils/nftlpMath/uniswapV3General");
|
|
10
|
+
const types_1 = require("../../../../config/types");
|
|
10
11
|
const FEES = [
|
|
11
12
|
100,
|
|
12
13
|
500,
|
|
@@ -18,6 +19,9 @@ class OnchainNftlpUniswapV3 extends onchainNftlp_1.default {
|
|
|
18
19
|
super(...arguments);
|
|
19
20
|
this.cache = {};
|
|
20
21
|
}
|
|
22
|
+
getExtension() {
|
|
23
|
+
return types_1.Extension.UniswapV3;
|
|
24
|
+
}
|
|
21
25
|
getNewAccountNftlpObject(accountCollateral) {
|
|
22
26
|
return new nftlp_1.OnchainAccountNftlpUniswapV3(accountCollateral);
|
|
23
27
|
}
|
|
@@ -14,6 +14,7 @@ class OnchainInteractionsNftlp {
|
|
|
14
14
|
this.getUiMargin = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getOnchain().uiMargin;
|
|
15
15
|
this.getDust = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getOnchain().dust;
|
|
16
16
|
this.encodePermits = (permits) => this.getLendingPool().getInteractions().getOnchain().getPermitHelper().encodePermits(permits);
|
|
17
|
+
this.getRouter = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getRouterExtension(this.getNftlp().getExtension());
|
|
17
18
|
this.collateral = collateral;
|
|
18
19
|
}
|
|
19
20
|
cleanCache() {
|
|
@@ -4,7 +4,6 @@ import { OnchainAccountNftlpUniswapV3 } from "../../../account/lendingPool/nftlp
|
|
|
4
4
|
import { BigNumber } from "ethers";
|
|
5
5
|
export default class OnchainInteractionsNftlpUniswapV3 extends OnchainInteractionsNftlp {
|
|
6
6
|
protected cache: {};
|
|
7
|
-
getUniswapV3Router: () => any;
|
|
8
7
|
getNftlp: () => any;
|
|
9
8
|
getAccountNftlp: () => OnchainAccountNftlpUniswapV3;
|
|
10
9
|
getOwnerSpender(): {
|
|
@@ -4,21 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const onchainInteractionsNftlp_1 = __importDefault(require("./onchainInteractionsNftlp"));
|
|
7
|
-
const types_1 = require("../../../../config/types");
|
|
8
7
|
const ether_utils_1 = require("../../../../utils/ether-utils");
|
|
9
8
|
const general_1 = require("../../../../config/general");
|
|
10
9
|
class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.default {
|
|
11
10
|
constructor() {
|
|
12
11
|
super(...arguments);
|
|
13
12
|
this.cache = {};
|
|
14
|
-
this.getUniswapV3Router = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getRouterExtension(types_1.Extension.UniswapV3);
|
|
15
13
|
this.getNftlp = () => this.getLendingPool().getLendingPool().getNftlp();
|
|
16
14
|
this.getAccountNftlp = () => this.getLendingPool().getAccountLendingPool().getNftlp();
|
|
17
15
|
}
|
|
18
16
|
getOwnerSpender() {
|
|
19
17
|
return {
|
|
20
18
|
owner: this.getAccountAddress(),
|
|
21
|
-
spender: this.
|
|
19
|
+
spender: this.getRouter()._address,
|
|
22
20
|
};
|
|
23
21
|
}
|
|
24
22
|
async getMintEmptyAction() {
|
|
@@ -56,7 +54,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
56
54
|
let actions = [];
|
|
57
55
|
if (depositADelta > 0 && depositBDelta < 0 || depositBDelta > 0 && depositADelta < 0)
|
|
58
56
|
throw new Error("Opposite depositADelta and depositBDelta signs");
|
|
59
|
-
const router = this.
|
|
57
|
+
const router = this.getRouter();
|
|
60
58
|
const actionsGetter = this.getActionsGetter();
|
|
61
59
|
let percentageToRemove = 0;
|
|
62
60
|
if (depositADelta > 0 || depositBDelta > 0) {
|
|
@@ -227,7 +225,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
227
225
|
};
|
|
228
226
|
}
|
|
229
227
|
async execute(tokenId, actions, permits, withCollateralTransfer, ethValue, onTransactionHash) {
|
|
230
|
-
const router = this.
|
|
228
|
+
const router = this.getRouter();
|
|
231
229
|
return this.getLendingPool().send(router.methods.execute(await this.getNftlp().getNftlpAddress(), tokenId == -1 ? general_1.MAX_UINT : tokenId.toString(), this.encodeActions(actions), this.encodePermits(permits), withCollateralTransfer), onTransactionHash, ethValue);
|
|
232
230
|
}
|
|
233
231
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Borrowable } from '../../../config/types';
|
|
1
|
+
import { Borrowable, Extension, Factory } from '../../../config/types';
|
|
2
2
|
import OnchainInteractionsLendingPool from './index';
|
|
3
3
|
import OnchainInteractionsPoolToken from '../onchainInteractionsPoolToken';
|
|
4
4
|
import OnchainBorrowable from '../../impermaxFactory/lendingPool/onchainBorrowable';
|
|
5
5
|
import OnchainAccountBorrowable from '../../account/lendingPool/onchainAccountBorrowable';
|
|
6
|
+
import { BigNumber } from "ethers";
|
|
7
|
+
import { Permit } from "../../onchainTypes";
|
|
6
8
|
export default abstract class OnchainInteractionsBorrowable extends OnchainInteractionsPoolToken {
|
|
7
9
|
protected readonly lendingPool: OnchainInteractionsLendingPool;
|
|
8
10
|
protected readonly poolToken: OnchainBorrowable;
|
|
@@ -14,4 +16,10 @@ export default abstract class OnchainInteractionsBorrowable extends OnchainInter
|
|
|
14
16
|
getAccountBorrowable: () => OnchainAccountBorrowable;
|
|
15
17
|
getPoolTokenRouter: () => any;
|
|
16
18
|
private getBorrowableType;
|
|
19
|
+
/**
|
|
20
|
+
* Borrow approve
|
|
21
|
+
*/
|
|
22
|
+
getBorrowAllowance(factory?: Factory, extension?: Extension): Promise<BigNumber>;
|
|
23
|
+
borrowApprove(amount: BigNumber, onTransactionHash: Function, factory?: Factory, extension?: Extension): Promise<any>;
|
|
24
|
+
permitBorrow(amount: BigNumber, factory?: Factory, extension?: Extension): Promise<Permit>;
|
|
17
25
|
}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const onchainInteractionsPoolToken_1 = __importDefault(require("../onchainInteractionsPoolToken"));
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
7
8
|
class OnchainInteractionsBorrowable extends onchainInteractionsPoolToken_1.default {
|
|
8
9
|
constructor(lendingPool, borrowable) {
|
|
9
10
|
super();
|
|
@@ -20,5 +21,24 @@ class OnchainInteractionsBorrowable extends onchainInteractionsPoolToken_1.defau
|
|
|
20
21
|
getAccountPoolToken() {
|
|
21
22
|
return this.lendingPool.getAccountLendingPool().getBorrowable(this.getBorrowableType());
|
|
22
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Borrow approve
|
|
26
|
+
*/
|
|
27
|
+
async getBorrowAllowance(factory, extension) {
|
|
28
|
+
const poolToken = await this.poolToken.getPoolToken();
|
|
29
|
+
const { owner, spender } = this.getOwnerSpender(factory, extension);
|
|
30
|
+
const allowance = await poolToken.methods.borrowAllowance(owner, spender).call();
|
|
31
|
+
return ethers_1.BigNumber.from(allowance);
|
|
32
|
+
}
|
|
33
|
+
async borrowApprove(amount, onTransactionHash, factory, extension) {
|
|
34
|
+
const { spender } = this.getOwnerSpender(factory, extension);
|
|
35
|
+
const poolToken = await this.poolToken.getPoolToken();
|
|
36
|
+
return this.send(poolToken.methods.borrowApprove(spender, amount), onTransactionHash);
|
|
37
|
+
}
|
|
38
|
+
async permitBorrow(amount, factory, extension) {
|
|
39
|
+
const { owner, spender } = this.getOwnerSpender(factory, extension);
|
|
40
|
+
const poolToken = await this.poolToken.getPoolToken();
|
|
41
|
+
return this.getPermitHelper().getBorrowPermit(poolToken, owner, spender, amount);
|
|
42
|
+
}
|
|
23
43
|
}
|
|
24
44
|
exports.default = OnchainInteractionsBorrowable;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Permits } from '../../onchainTypes';
|
|
2
|
-
import { BigNumber } from 'ethers';
|
|
3
1
|
import OnchainInteractionsBorrowable from "./onchainInteractionsBorrowable";
|
|
4
2
|
import { OnchainBorrowableV2 } from "../../impermaxFactory/lendingPool";
|
|
5
3
|
import OnchainInteractionsLendingPoolV2 from "./onchainInteractionsLendingPoolV2";
|
|
@@ -8,8 +6,4 @@ export default class OnchainInteractionsBorrowableV2 extends OnchainInteractions
|
|
|
8
6
|
protected readonly poolToken: OnchainBorrowableV2;
|
|
9
7
|
getLendingPool: () => OnchainInteractionsLendingPoolV2;
|
|
10
8
|
getPoolToken: () => OnchainBorrowableV2;
|
|
11
|
-
getBorrowAllowance(): Promise<BigNumber>;
|
|
12
|
-
borrowApprove(amount: BigNumber, onTransactionHash: Function): Promise<any>;
|
|
13
|
-
borrow(amount: BigNumber, permits: Permits, onTransactionHash: Function): Promise<any>;
|
|
14
|
-
repay(amount: BigNumber, onTransactionHash: Function): Promise<any>;
|
|
15
9
|
}
|
|
@@ -3,44 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const general_1 = require("../../../config/general");
|
|
7
|
-
const ethers_1 = require("ethers");
|
|
8
6
|
const onchainInteractionsBorrowable_1 = __importDefault(require("./onchainInteractionsBorrowable"));
|
|
9
7
|
class OnchainInteractionsBorrowableV2 extends onchainInteractionsBorrowable_1.default {
|
|
10
8
|
constructor() {
|
|
11
9
|
super(...arguments);
|
|
12
10
|
this.getLendingPool = () => this.lendingPool;
|
|
13
11
|
this.getPoolToken = () => this.poolToken;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return ethers_1.BigNumber.from(allowance);
|
|
20
|
-
}
|
|
21
|
-
async borrowApprove(amount, onTransactionHash) {
|
|
22
|
-
const { spender } = this.getOwnerSpender();
|
|
23
|
-
const poolToken = await this.poolToken.getPoolToken();
|
|
24
|
-
return this.send(poolToken.methods.borrowApprove(spender, amount), onTransactionHash);
|
|
25
|
-
}
|
|
26
|
-
async borrow(amount, permits, onTransactionHash) {
|
|
27
|
-
const { router, ptAddress, account } = await this.getSendData(permits);
|
|
28
|
-
// TODO temporary fix
|
|
29
|
-
if (await this.isWETH()) {
|
|
12
|
+
/*
|
|
13
|
+
public async borrow(amount: BigNumber, permits: Permits, onTransactionHash: Function) {
|
|
14
|
+
const {router, ptAddress, account} = await this.getSendData(permits);
|
|
15
|
+
// TODO temporary fix
|
|
16
|
+
if (await this.isWETH()) {
|
|
30
17
|
return this.send(router.methods.borrowETH(ptAddress, amount, account, '100000000000000000', '0x'), onTransactionHash);
|
|
31
|
-
|
|
32
|
-
else {
|
|
18
|
+
} else {
|
|
33
19
|
return this.send(router.methods.borrow(ptAddress, amount, account, '100000000000000000', '0x'), onTransactionHash);
|
|
20
|
+
}
|
|
34
21
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return this.send(router.methods.repayETH(ptAddress, account,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
|
|
23
|
+
public async repay(amount: BigNumber, onTransactionHash: Function) {
|
|
24
|
+
const {router, ptAddress, account} = await this.getSendData([]);
|
|
25
|
+
if (await this.isWETH()) {
|
|
26
|
+
return this.send(router.methods.repayETH(ptAddress, account, DEADLINE), onTransactionHash, amount);
|
|
27
|
+
} else {
|
|
28
|
+
return this.send(router.methods.repay(ptAddress, amount, account, DEADLINE), onTransactionHash);
|
|
29
|
+
}
|
|
43
30
|
}
|
|
31
|
+
*/
|
|
44
32
|
}
|
|
45
33
|
}
|
|
46
34
|
exports.default = OnchainInteractionsBorrowableV2;
|
|
@@ -15,7 +15,7 @@ export default class OnchainInteractionsCollateralV2 extends OnchainInteractions
|
|
|
15
15
|
getInteractions: () => import("..").default;
|
|
16
16
|
getActionsGetter: () => any;
|
|
17
17
|
getPoolTokenRouter: () => any;
|
|
18
|
-
|
|
18
|
+
getRouter: () => any;
|
|
19
19
|
getDust: () => number;
|
|
20
20
|
protected encodePermits: (permits: Permits) => string;
|
|
21
21
|
getAccountPoolToken(): OnchainAccountCollateralV2;
|
|
@@ -16,7 +16,7 @@ class OnchainInteractionsCollateralV2 extends onchainInteractionsPoolToken_1.def
|
|
|
16
16
|
this.getInteractions = () => this.lendingPool.getInteractions();
|
|
17
17
|
this.getActionsGetter = () => this.getLendingPool().getLendingPool().getImpermaxFactory().getActionsGetter();
|
|
18
18
|
this.getPoolTokenRouter = () => this.lendingPool.getPoolTokenRouter();
|
|
19
|
-
this.
|
|
19
|
+
this.getRouter = () => this.lendingPool.getLendingPool().getImpermaxFactory().getRouter();
|
|
20
20
|
this.getDust = () => this.lendingPool.getLendingPool().getImpermaxFactory().getOnchain().dust;
|
|
21
21
|
this.encodePermits = (permits) => this.getLendingPool().getInteractions().getOnchain().getPermitHelper().encodePermits(permits);
|
|
22
22
|
this.getAccountCollateral = this.getAccountPoolToken;
|
|
@@ -51,7 +51,7 @@ class OnchainInteractionsCollateralV2 extends onchainInteractionsPoolToken_1.def
|
|
|
51
51
|
getOwnerSpender() {
|
|
52
52
|
return {
|
|
53
53
|
owner: this.getAccountAddress(),
|
|
54
|
-
spender: this.
|
|
54
|
+
spender: this.getRouter()._address,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -77,7 +77,7 @@ class OnchainInteractionsCollateralV2 extends onchainInteractionsPoolToken_1.def
|
|
|
77
77
|
let actions = [];
|
|
78
78
|
if (depositADelta > 0 && depositBDelta < 0 || depositBDelta > 0 && depositADelta < 0)
|
|
79
79
|
throw new Error("Opposite depositADelta and depositBDelta signs");
|
|
80
|
-
const router = this.
|
|
80
|
+
const router = this.getRouter();
|
|
81
81
|
const actionsGetter = this.getActionsGetter();
|
|
82
82
|
let percentageToRemove = 0;
|
|
83
83
|
if (depositADelta > 0 || depositBDelta > 0) {
|
|
@@ -257,7 +257,7 @@ class OnchainInteractionsCollateralV2 extends onchainInteractionsPoolToken_1.def
|
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
259
|
async execute(actions, permits, ethValue, onTransactionHash) {
|
|
260
|
-
const router = this.
|
|
260
|
+
const router = this.getRouter();
|
|
261
261
|
return this.getLendingPool().send(router.methods.execute(await this.getCollateral().getTokenAddress(), this.encodeActions(actions), this.encodePermits(permits)), onTransactionHash, ethValue);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -16,6 +16,7 @@ export default class OnchainPermitHelper {
|
|
|
16
16
|
private getPermit2SingleJSONData;
|
|
17
17
|
private getSignature;
|
|
18
18
|
getTokenPermit(token: Contract, owner: Address, spender: Address, value: BigNumber, version?: null): Promise<Permit>;
|
|
19
|
+
getBorrowPermit(token: Contract, owner: Address, spender: Address, value: BigNumber): Promise<Permit>;
|
|
19
20
|
getNftPermit(token: Contract, owner: Address, spender: Address, tokenId: BigNumber): Promise<Permit>;
|
|
20
21
|
getPermit2Single(token: Contract, owner: Address, spender: Address, value: BigNumber): Promise<Permit>;
|
|
21
22
|
}
|
|
@@ -128,6 +128,21 @@ class OnchainPermitHelper {
|
|
|
128
128
|
signature: await this.getSignature(owner, jsonData)
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
+
async getBorrowPermit(token, owner, spender, value) {
|
|
132
|
+
const nonce = await token.methods.nonces(owner).call();
|
|
133
|
+
const jsonData = await this.getBorrowPermitJSONData(token, {
|
|
134
|
+
owner,
|
|
135
|
+
spender,
|
|
136
|
+
value: value.toString(),
|
|
137
|
+
nonce: ethers_1.BigNumber.from(nonce).toString(),
|
|
138
|
+
deadline: this.deadline,
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
permitType: onchainTypes_1.PermitType.PERMIT_BORROW,
|
|
142
|
+
permitData: ethers_1.ethers.utils.defaultAbiCoder.encode(['address', 'uint256', 'uint256'], [token._address, value.toString(), this.deadline]),
|
|
143
|
+
signature: await this.getSignature(owner, jsonData)
|
|
144
|
+
};
|
|
145
|
+
}
|
|
131
146
|
async getNftPermit(token, owner, spender, tokenId) {
|
|
132
147
|
const nonce = await token.methods.nonces(tokenId).call();
|
|
133
148
|
const jsonData = await this.getNftPermitJSONData(token, {
|
|
@@ -13,6 +13,7 @@ var PermitType;
|
|
|
13
13
|
PermitType[PermitType["PERMIT_NFT"] = 1] = "PERMIT_NFT";
|
|
14
14
|
PermitType[PermitType["PERMIT2_SINGLE"] = 2] = "PERMIT2_SINGLE";
|
|
15
15
|
PermitType[PermitType["PERMIT2_BATCH"] = 3] = "PERMIT2_BATCH";
|
|
16
|
+
PermitType[PermitType["PERMIT_BORROW"] = 4] = "PERMIT_BORROW";
|
|
16
17
|
})(PermitType = exports.PermitType || (exports.PermitType = {}));
|
|
17
18
|
exports.NO_CHANGES = {
|
|
18
19
|
changeBorrowedA: 0,
|