impermax-sdk 1.2.112 → 2.1.0
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/IAllowanceTransfer.json +3772 -0
- package/lib/abis/contracts/IERC721.json +3515 -0
- package/lib/abis/contracts/ITokenizedUniswapV2Position.json +4167 -0
- package/lib/abis/contracts/ITokenizedUniswapV3Position.json +5539 -0
- package/lib/abis/contracts/IUniswapV3Pool.json +6606 -0
- package/lib/abis/contracts/ImpermaxV3Borrowable.json +22131 -0
- package/lib/abis/contracts/ImpermaxV3Collateral.json +22988 -0
- package/lib/abis/contracts/ImpermaxV3Factory.json +17645 -0
- package/lib/abis/contracts/ImpermaxV3UniV2Router01.json +32488 -0
- package/lib/abis/contracts/ImpermaxV3UniV3Router01.json +37742 -0
- package/lib/abis/contracts/PoolTokenRouter01.json +9058 -0
- package/lib/config/amms.d.ts +0 -2
- package/lib/config/amms.js +0 -3
- package/lib/config/chainId.d.ts +2 -0
- package/lib/config/chainId.js +26 -0
- package/lib/config/contracts/routers.d.ts +3 -2
- package/lib/config/contracts/routers.js +46 -22
- package/lib/config/factories.js +1 -0
- package/lib/config/farms.d.ts +0 -2
- package/lib/config/farms.js +0 -3
- package/lib/config/types.d.ts +14 -1
- package/lib/config/types.js +15 -1
- package/lib/index.d.ts +6 -5
- package/lib/index.js +11 -4
- package/lib/offchain/account/index.d.ts +4 -2
- package/lib/offchain/account/index.js +7 -3
- package/lib/offchain/account/lendingPool/index.d.ts +2 -1
- package/lib/offchain/account/lendingPool/index.js +3 -1
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.d.ts +0 -3
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.js +1 -27
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.d.ts +0 -2
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.js +2 -14
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.d.ts +11 -4
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.js +16 -15
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.d.ts +25 -0
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.js +116 -0
- package/lib/offchain/account/offchainAccount.d.ts +6 -6
- package/lib/offchain/account/offchainAccount.js +7 -7
- package/lib/offchain/account/offchainMultichainAccount.d.ts +34 -0
- package/lib/offchain/account/offchainMultichainAccount.js +66 -0
- package/lib/offchain/account/vault/index.d.ts +3 -0
- package/lib/offchain/account/vault/index.js +7 -0
- package/lib/offchain/account/vault/offchainAccountVault.d.ts +16 -0
- package/lib/offchain/account/{offchainAccountLendingVault.js → vault/offchainAccountVault.js} +14 -14
- package/lib/offchain/index.d.ts +3 -2
- package/lib/offchain/index.js +5 -3
- package/lib/offchain/lendingPool/offchainCollateral.d.ts +1 -0
- package/lib/offchain/lendingPool/offchainCollateral.js +6 -0
- package/lib/offchain/lendingPool/offchainLendingPool.d.ts +14 -1
- package/lib/offchain/lendingPool/offchainLendingPool.js +47 -0
- package/lib/offchain/offchain.d.ts +8 -15
- package/lib/offchain/offchain.js +16 -19
- package/lib/offchain/offchainAPRHelper.js +0 -1
- package/lib/offchain/offchainInitializer.d.ts +4 -4
- package/lib/offchain/offchainInitializer.js +4 -4
- package/lib/offchain/offchainMultichain.d.ts +50 -0
- package/lib/offchain/offchainMultichain.js +75 -0
- package/lib/offchain/offchainTypes.d.ts +1 -1
- package/lib/offchain/vault/index.d.ts +6 -0
- package/lib/offchain/vault/index.js +14 -0
- package/lib/offchain/vault/offchainHedgedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainHedgedVault.js +57 -0
- package/lib/offchain/vault/offchainLendingVault.d.ts +16 -0
- package/lib/offchain/vault/offchainLendingVault.js +73 -0
- package/lib/offchain/vault/offchainLeveragedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainLeveragedVault.js +57 -0
- package/lib/offchain/{offchainLendingVault.d.ts → vault/offchainVault.d.ts} +16 -7
- package/lib/offchain/{offchainLendingVault.js → vault/offchainVault.js} +33 -17
- package/lib/onchain/account/lendingPool/index.d.ts +8 -1
- package/lib/onchain/account/lendingPool/index.js +38 -1
- package/lib/onchain/account/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.d.ts +7 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.js +12 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.js +13 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.d.ts +12 -7
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.js +5 -50
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.js +55 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.js +28 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.d.ts +6 -19
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.js +7 -90
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.d.ts +25 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.js +99 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.d.ts +18 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.js +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.d.ts +19 -34
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.js +17 -227
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.d.ts +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.js +285 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.d.ts +27 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.js +32 -0
- package/lib/onchain/account/onchainAccount.js +1 -2
- package/lib/onchain/account/onchainAccountLendingVault.d.ts +3 -3
- package/lib/onchain/impermaxFactory/index.d.ts +3 -1
- package/lib/onchain/impermaxFactory/index.js +5 -1
- package/lib/onchain/impermaxFactory/lendingPool/index.d.ts +8 -1
- package/lib/onchain/impermaxFactory/lendingPool/index.js +39 -1
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.d.ts +22 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.js +19 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.d.ts +24 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.js +90 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.d.ts +15 -11
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.js +5 -24
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.d.ts +9 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.d.ts +7 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.js +23 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.d.ts +5 -16
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.js +6 -43
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.d.ts +20 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.js +58 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.d.ts +13 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.d.ts +32 -47
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.js +28 -314
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.d.ts +76 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.js +338 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.d.ts +42 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.js +39 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.d.ts +19 -9
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.js +16 -26
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.js +81 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.js +88 -0
- package/lib/onchain/interactions/lendingPool/index.d.ts +8 -1
- package/lib/onchain/interactions/lendingPool/index.js +38 -1
- package/lib/onchain/interactions/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.d.ts +7 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.js +12 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.d.ts +6 -10
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.js +5 -37
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.d.ts +15 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.js +63 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.d.ts +9 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.js +14 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.d.ts +3 -15
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.js +5 -37
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.d.ts +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.js +48 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.js +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.d.ts +16 -31
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.js +12 -94
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.d.ts +42 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.js +114 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.d.ts +27 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.js +32 -0
- package/lib/onchain/interactions/onchainInteractions.js +3 -4
- package/lib/onchain/interactions/onchainInteractionsLendingVault.d.ts +1 -1
- package/lib/onchain/interactions/onchainInteractionsLendingVault.js +1 -1
- package/lib/onchain/interactions/onchainInteractionsPoolToken.d.ts +13 -13
- package/lib/onchain/interactions/onchainInteractionsPoolToken.js +33 -85
- package/lib/onchain/onchain.d.ts +3 -0
- package/lib/onchain/onchain.js +11 -3
- package/lib/onchain/onchainContractsHelper.d.ts +19 -8
- package/lib/onchain/onchainContractsHelper.js +55 -21
- package/lib/onchain/onchainLendingVault.d.ts +3 -3
- package/lib/onchain/onchainPermitHelper.d.ts +21 -0
- package/lib/onchain/onchainPermitHelper.js +198 -0
- package/lib/onchain/onchainTypes.d.ts +6 -0
- package/package.json +1 -1
- package/lib/offchain/account/offchainAccountLendingVault.d.ts +0 -16
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { Contract } from "../../onchainTypes";
|
|
2
|
-
import { Address,
|
|
2
|
+
import { Address, Borrowable } from '../../../config/types';
|
|
3
3
|
import OnchainLendingPool from './index';
|
|
4
4
|
import OnchainPoolToken from '../../onchainPoolToken';
|
|
5
5
|
import OffchainBorrowable from '../../../offchain/lendingPool/offchainBorrowable';
|
|
6
|
-
export default class OnchainBorrowable extends OnchainPoolToken {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export default abstract class OnchainBorrowable extends OnchainPoolToken {
|
|
7
|
+
protected readonly lendingPool: OnchainLendingPool;
|
|
8
|
+
protected readonly borrowable: Borrowable;
|
|
9
|
+
protected borrowableCache: {
|
|
10
|
+
borrowTracker?: Promise<Address>;
|
|
11
|
+
rewarder?: Promise<Contract>;
|
|
12
|
+
rewarderTokenSymbol?: Promise<string>;
|
|
13
|
+
farmingTokenSymbol?: Promise<string>;
|
|
14
|
+
rewardSpeed?: Promise<number>;
|
|
15
|
+
};
|
|
16
|
+
constructor(lendingPool: OnchainLendingPool, borrowable: Borrowable);
|
|
11
17
|
getLendingPool: () => OnchainLendingPool;
|
|
12
|
-
|
|
18
|
+
getBorrowableType: () => Borrowable;
|
|
13
19
|
cleanCache(): void;
|
|
14
|
-
|
|
20
|
+
protected getContractHelper: () => import("../..").OnchainContractsHelper;
|
|
15
21
|
getPoolTokenAddress(): Promise<Address>;
|
|
16
22
|
getOffchainPoolToken(): Promise<OffchainBorrowable>;
|
|
17
23
|
getOffchainBorrowable: () => Promise<OffchainBorrowable>;
|
|
18
|
-
protected initializePoolToken(): Promise<Contract>;
|
|
24
|
+
protected abstract initializePoolToken(): Promise<Contract>;
|
|
19
25
|
protected initializeToken(): Promise<Contract>;
|
|
20
|
-
getPriceDenomLP(): Promise<number>;
|
|
21
|
-
getMarketPriceDenomLP(): Promise<number>;
|
|
22
26
|
private initializeBorrowTracker;
|
|
23
27
|
getBorrowTracker(): Promise<string>;
|
|
24
28
|
hasFarming(): Promise<boolean>;
|
|
@@ -12,20 +12,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const types_1 = require("../../../config/types");
|
|
16
15
|
const onchainPoolToken_1 = __importDefault(require("../../onchainPoolToken"));
|
|
17
16
|
class OnchainBorrowable extends onchainPoolToken_1.default {
|
|
18
|
-
constructor(lendingPool,
|
|
17
|
+
constructor(lendingPool, borrowable) {
|
|
19
18
|
super();
|
|
20
19
|
this.borrowableCache = {};
|
|
21
20
|
this.getLendingPool = () => this.lendingPool;
|
|
22
|
-
this.
|
|
21
|
+
this.getBorrowableType = () => this.borrowable;
|
|
23
22
|
this.getContractHelper = () => this.lendingPool.getImpermaxFactory().getOnchain().getContractHelper();
|
|
24
23
|
this.getOffchainBorrowable = this.getOffchainPoolToken;
|
|
25
24
|
// Impermax Chef
|
|
26
25
|
this.getImpermaxChef = () => this.getContractHelper().impermaxChef;
|
|
27
26
|
this.lendingPool = lendingPool;
|
|
28
|
-
this.
|
|
27
|
+
this.borrowable = borrowable;
|
|
29
28
|
}
|
|
30
29
|
cleanCache() {
|
|
31
30
|
super.cleanCache();
|
|
@@ -33,18 +32,13 @@ class OnchainBorrowable extends onchainPoolToken_1.default {
|
|
|
33
32
|
}
|
|
34
33
|
getPoolTokenAddress() {
|
|
35
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
return (yield this.lendingPool.
|
|
35
|
+
return (yield this.lendingPool.getBorrowableAddress(this.borrowable));
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
getOffchainPoolToken() {
|
|
40
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
40
|
const lendingPool = yield this.lendingPool.getOffchainLendingPool();
|
|
42
|
-
return lendingPool.
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
initializePoolToken() {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return this.getContractHelper().newBorrowable(yield this.getPoolTokenAddress());
|
|
41
|
+
return lendingPool.getBorrowable(this.borrowable);
|
|
48
42
|
});
|
|
49
43
|
}
|
|
50
44
|
initializeToken() {
|
|
@@ -53,19 +47,6 @@ class OnchainBorrowable extends onchainPoolToken_1.default {
|
|
|
53
47
|
return this.getContractHelper().newERC20(yield poolToken.methods.underlying().call());
|
|
54
48
|
});
|
|
55
49
|
}
|
|
56
|
-
// Price Denom LP
|
|
57
|
-
getPriceDenomLP() {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const prices = yield this.lendingPool.getPriceDenomLP();
|
|
60
|
-
return prices[this.poolTokenType === types_1.PoolTokenType.BorrowableA ? 0 : 1];
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getMarketPriceDenomLP() {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
const prices = yield this.lendingPool.getMarketPriceDenomLP();
|
|
66
|
-
return prices[this.poolTokenType === types_1.PoolTokenType.BorrowableA ? 0 : 1];
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
50
|
// Farming Pool
|
|
70
51
|
initializeBorrowTracker() {
|
|
71
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Contract } from "../../onchainTypes";
|
|
2
|
+
import OnchainBorrowable from "./onchainBorrowable";
|
|
3
|
+
import OnchainLendingPoolV2 from "./onchainLendingPoolV2";
|
|
4
|
+
export default class OnchainBorrowableV2 extends OnchainBorrowable {
|
|
5
|
+
protected readonly lendingPool: OnchainLendingPoolV2;
|
|
6
|
+
protected initializePoolToken(): Promise<Contract>;
|
|
7
|
+
getPriceDenomLP(): Promise<number>;
|
|
8
|
+
getMarketPriceDenomLP(): Promise<number>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const onchainBorrowable_1 = __importDefault(require("./onchainBorrowable"));
|
|
16
|
+
class OnchainBorrowableV2 extends onchainBorrowable_1.default {
|
|
17
|
+
initializePoolToken() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return this.getContractHelper().newBorrowableV2(yield this.getPoolTokenAddress());
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// Price Denom LP
|
|
23
|
+
getPriceDenomLP() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const prices = yield this.lendingPool.getPriceDenomLP();
|
|
26
|
+
return prices[this.borrowable];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
getMarketPriceDenomLP() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const prices = yield this.lendingPool.getMarketPriceDenomLP();
|
|
32
|
+
return prices[this.borrowable];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = OnchainBorrowableV2;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Contract } from "../../onchainTypes";
|
|
2
|
+
import OnchainBorrowable from "./onchainBorrowable";
|
|
3
|
+
import OnchainLendingPoolV3 from "./onchainLendingPoolV3";
|
|
4
|
+
export default class OnchainBorrowableV3 extends OnchainBorrowable {
|
|
5
|
+
protected readonly lendingPool: OnchainLendingPoolV3;
|
|
6
|
+
protected initializePoolToken(): Promise<Contract>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const onchainBorrowable_1 = __importDefault(require("./onchainBorrowable"));
|
|
16
|
+
class OnchainBorrowableV3 extends onchainBorrowable_1.default {
|
|
17
|
+
initializePoolToken() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return this.getContractHelper().newBorrowableV3(yield this.getPoolTokenAddress());
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = OnchainBorrowableV3;
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import { Contract } from "../../onchainTypes";
|
|
2
1
|
import OnchainLendingPool from './index';
|
|
3
|
-
import { Address } from '../../../config/types';
|
|
4
|
-
import OnchainPoolToken from '../../onchainPoolToken';
|
|
5
2
|
import OffchainCollateral from '../../../offchain/lendingPool/offchainCollateral';
|
|
6
|
-
export default class OnchainCollateral
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cleanCache(): void;
|
|
12
|
-
private getContractHelper;
|
|
13
|
-
getPoolTokenAddress(): Promise<Address>;
|
|
14
|
-
getOffchainPoolToken(): Promise<OffchainCollateral>;
|
|
15
|
-
getOffchainCollateral: () => Promise<OffchainCollateral>;
|
|
16
|
-
protected initializePoolToken(): Promise<Contract>;
|
|
17
|
-
protected initializeToken(): Promise<Contract>;
|
|
18
|
-
protected initializeExchangeRate(): Promise<number>;
|
|
3
|
+
export default abstract class OnchainCollateral {
|
|
4
|
+
abstract getLendingPool(): OnchainLendingPool;
|
|
5
|
+
abstract cleanCache(): any;
|
|
6
|
+
getCollateralAddress: () => Promise<string>;
|
|
7
|
+
getOffchainCollateral(): Promise<OffchainCollateral>;
|
|
19
8
|
}
|
|
@@ -8,54 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
super();
|
|
20
|
-
this.collateralCache = {};
|
|
21
|
-
this.getLendingPool = () => this.lendingPool;
|
|
22
|
-
this.getContractHelper = () => this.lendingPool.getImpermaxFactory().getOnchain().getContractHelper();
|
|
23
|
-
this.getOffchainCollateral = this.getOffchainPoolToken;
|
|
24
|
-
this.lendingPool = lendingPool;
|
|
25
|
-
}
|
|
26
|
-
cleanCache() {
|
|
27
|
-
super.cleanCache();
|
|
28
|
-
this.collateralCache = {};
|
|
29
|
-
}
|
|
30
|
-
getPoolTokenAddress() {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
return (yield this.lendingPool.getPoolTokenAddresses())[types_1.PoolTokenType.Collateral];
|
|
33
|
-
});
|
|
12
|
+
class OnchainCollateral {
|
|
13
|
+
constructor() {
|
|
14
|
+
// shortcuts
|
|
15
|
+
this.getCollateralAddress = () => __awaiter(this, void 0, void 0, function* () { return this.getLendingPool().getCollateralAddress(); });
|
|
34
16
|
}
|
|
35
|
-
|
|
17
|
+
getOffchainCollateral() {
|
|
36
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const lendingPool = yield this.
|
|
19
|
+
const lendingPool = yield this.getLendingPool().getOffchainLendingPool();
|
|
38
20
|
return lendingPool.getCollateral();
|
|
39
21
|
});
|
|
40
22
|
}
|
|
41
|
-
initializePoolToken() {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return this.getContractHelper().newCollateral(yield this.getPoolTokenAddress());
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
initializeToken() {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return this.lendingPool.getUniswapV2Pair();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
initializeExchangeRate() {
|
|
52
|
-
const _super = Object.create(null, {
|
|
53
|
-
initializeExchangeRate: { get: () => super.initializeExchangeRate }
|
|
54
|
-
});
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
let exchangeRate = yield _super.initializeExchangeRate.call(this);
|
|
57
|
-
return exchangeRate * (yield this.lendingPool.getStakedLPExchangeRate());
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
23
|
}
|
|
61
24
|
exports.default = OnchainCollateral;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Contract } from "../../onchainTypes";
|
|
2
|
+
import OnchainPoolToken from '../../onchainPoolToken';
|
|
3
|
+
import OffchainCollateral from '../../../offchain/lendingPool/offchainCollateral';
|
|
4
|
+
import OnchainCollateral from "./onchainCollateral";
|
|
5
|
+
import OnchainLendingPoolV2 from "./onchainLendingPoolV2";
|
|
6
|
+
export default class OnchainCollateralV2 extends OnchainPoolToken implements OnchainCollateral {
|
|
7
|
+
protected readonly lendingPool: OnchainLendingPoolV2;
|
|
8
|
+
protected collateralCache: {};
|
|
9
|
+
constructor(lendingPool: OnchainLendingPoolV2);
|
|
10
|
+
getLendingPool: () => OnchainLendingPoolV2;
|
|
11
|
+
cleanCache(): void;
|
|
12
|
+
private getContractHelper;
|
|
13
|
+
getCollateralAddress: () => Promise<string>;
|
|
14
|
+
getOffchainCollateral(): Promise<OffchainCollateral>;
|
|
15
|
+
getPoolTokenAddress: () => Promise<string>;
|
|
16
|
+
getOffchainPoolToken: () => Promise<OffchainCollateral>;
|
|
17
|
+
protected initializePoolToken(): Promise<Contract>;
|
|
18
|
+
protected initializeToken(): Promise<Contract>;
|
|
19
|
+
protected initializeExchangeRate(): Promise<number>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const onchainPoolToken_1 = __importDefault(require("../../onchainPoolToken"));
|
|
16
|
+
class OnchainCollateralV2 extends onchainPoolToken_1.default {
|
|
17
|
+
constructor(lendingPool) {
|
|
18
|
+
super();
|
|
19
|
+
this.collateralCache = {};
|
|
20
|
+
this.getLendingPool = () => this.lendingPool;
|
|
21
|
+
// shortcuts
|
|
22
|
+
this.getContractHelper = () => this.lendingPool.getImpermaxFactory().getOnchain().getContractHelper();
|
|
23
|
+
this.getCollateralAddress = () => __awaiter(this, void 0, void 0, function* () { return this.lendingPool.getCollateralAddress(); });
|
|
24
|
+
this.getPoolTokenAddress = this.getCollateralAddress;
|
|
25
|
+
this.getOffchainPoolToken = this.getOffchainCollateral;
|
|
26
|
+
this.lendingPool = lendingPool;
|
|
27
|
+
}
|
|
28
|
+
cleanCache() {
|
|
29
|
+
super.cleanCache();
|
|
30
|
+
this.collateralCache = {};
|
|
31
|
+
}
|
|
32
|
+
getOffchainCollateral() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const lendingPool = yield this.lendingPool.getOffchainLendingPool();
|
|
35
|
+
return lendingPool.getCollateral();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
initializePoolToken() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return this.getContractHelper().newCollateralV2(yield this.getCollateralAddress());
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
initializeToken() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return this.lendingPool.getUniswapV2Pair();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
initializeExchangeRate() {
|
|
49
|
+
const _super = Object.create(null, {
|
|
50
|
+
initializeExchangeRate: { get: () => super.initializeExchangeRate }
|
|
51
|
+
});
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
let exchangeRate = yield _super.initializeExchangeRate.call(this);
|
|
54
|
+
return exchangeRate * (yield this.lendingPool.getStakedLPExchangeRate());
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = OnchainCollateralV2;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import OffchainCollateral from '../../../offchain/lendingPool/offchainCollateral';
|
|
2
|
+
import OnchainCollateral from "./onchainCollateral";
|
|
3
|
+
import OnchainLendingPoolV3 from "./onchainLendingPoolV3";
|
|
4
|
+
export default class OnchainCollateralV3 extends OnchainCollateral {
|
|
5
|
+
protected readonly lendingPool: OnchainLendingPoolV3;
|
|
6
|
+
protected collateralCache: {};
|
|
7
|
+
constructor(lendingPool: OnchainLendingPoolV3);
|
|
8
|
+
getLendingPool: () => OnchainLendingPoolV3;
|
|
9
|
+
cleanCache(): void;
|
|
10
|
+
private getContractHelper;
|
|
11
|
+
getCollateralAddress: () => Promise<string>;
|
|
12
|
+
getOffchainCollateral(): Promise<OffchainCollateral>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const onchainCollateral_1 = __importDefault(require("./onchainCollateral"));
|
|
16
|
+
class OnchainCollateralV3 extends onchainCollateral_1.default {
|
|
17
|
+
constructor(lendingPool) {
|
|
18
|
+
super();
|
|
19
|
+
this.collateralCache = {};
|
|
20
|
+
this.getLendingPool = () => this.lendingPool;
|
|
21
|
+
// shortcuts
|
|
22
|
+
this.getContractHelper = () => this.lendingPool.getImpermaxFactory().getOnchain().getContractHelper();
|
|
23
|
+
this.getCollateralAddress = () => __awaiter(this, void 0, void 0, function* () { return this.lendingPool.getCollateralAddress(); });
|
|
24
|
+
this.lendingPool = lendingPool;
|
|
25
|
+
}
|
|
26
|
+
cleanCache() {
|
|
27
|
+
this.collateralCache = {};
|
|
28
|
+
}
|
|
29
|
+
getOffchainCollateral() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const lendingPool = yield this.lendingPool.getOffchainLendingPool();
|
|
32
|
+
return lendingPool.getCollateral();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = OnchainCollateralV3;
|
|
@@ -1,58 +1,43 @@
|
|
|
1
1
|
import OnchainImpermaxFactory from '../index';
|
|
2
|
-
import { Address,
|
|
2
|
+
import { Address, Borrowable } from '../../../config/types';
|
|
3
3
|
import OnchainCollateral from './onchainCollateral';
|
|
4
4
|
import OnchainBorrowable from './onchainBorrowable';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import OnchainAccountLendingPool from "../../account/lendingPool";
|
|
6
|
+
import OnchainInteractions, { OnchainInteractionsLendingPool } from "../../interactions";
|
|
7
|
+
import OnchainAccount from "../../account";
|
|
8
|
+
export default abstract class OnchainLendingPool {
|
|
9
|
+
protected readonly id: Address;
|
|
10
|
+
protected readonly impermaxFactory: OnchainImpermaxFactory;
|
|
11
|
+
protected readonly collateral: OnchainCollateral;
|
|
12
|
+
protected readonly borrowables: {
|
|
13
|
+
[Borrowable.A]: OnchainBorrowable;
|
|
14
|
+
[Borrowable.B]: OnchainBorrowable;
|
|
15
|
+
};
|
|
16
|
+
protected cache: {
|
|
17
|
+
lendingPoolAddresses?: Promise<{
|
|
18
|
+
collateral: Address;
|
|
19
|
+
borrowables: {
|
|
20
|
+
[key in Borrowable]: Address;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
protected abstract getNewCollateralObject(): OnchainCollateral;
|
|
25
|
+
protected abstract getNewBorrowableObject(borrowable: Borrowable): OnchainBorrowable;
|
|
26
|
+
abstract getNewAccountLendingPoolObject(account: OnchainAccount): OnchainAccountLendingPool;
|
|
27
|
+
abstract getNewInteractionLendingPoolObject(interactions: OnchainInteractions): OnchainInteractionsLendingPool;
|
|
28
|
+
constructor(impermaxFactory: OnchainImpermaxFactory, id: Address);
|
|
13
29
|
getImpermaxFactory: () => OnchainImpermaxFactory;
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
getId: () => string;
|
|
31
|
+
getBorrowable: (borrowable: Borrowable) => OnchainBorrowable;
|
|
16
32
|
getBorrowableA: () => OnchainBorrowable;
|
|
17
33
|
getBorrowableB: () => OnchainBorrowable;
|
|
18
34
|
getCollateral: () => OnchainCollateral;
|
|
19
|
-
|
|
35
|
+
protected getContractHelper: () => import("../..").OnchainContractsHelper;
|
|
20
36
|
cleanCache(): void;
|
|
21
37
|
getOffchainLendingPool(): Promise<import("../../..").OffchainLendingPool>;
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
borrowable1: string;
|
|
27
|
-
}>;
|
|
28
|
-
private initializeIsStakedLPToken;
|
|
29
|
-
getIsStakedLPToken(): Promise<boolean>;
|
|
30
|
-
private initializeStakedLPToken;
|
|
31
|
-
getStakedLPToken(): Promise<any>;
|
|
32
|
-
private initializeUniswapV2Pair;
|
|
33
|
-
getUniswapV2Pair(): Promise<any>;
|
|
34
|
-
private initializeReserves;
|
|
35
|
-
getReserves(): Promise<[number, number]>;
|
|
36
|
-
private initializeLPTotalSupply;
|
|
37
|
-
getLPTotalSupply(): Promise<number>;
|
|
38
|
-
private initializePriceDenomLP;
|
|
39
|
-
getPriceDenomLP(): Promise<[number, number]>;
|
|
40
|
-
getMarketPriceDenomLP(): Promise<[number, number]>;
|
|
41
|
-
getMarketPrice(): Promise<number>;
|
|
42
|
-
private initializeTwapReservesValueRatio;
|
|
43
|
-
getTwapReservesValueRatio(): Promise<number>;
|
|
44
|
-
getTwapReservesWeights(): Promise<[number, number]>;
|
|
45
|
-
private initializeMarketReservesValueRatio;
|
|
46
|
-
getMarketReservesValueRatio(): Promise<number>;
|
|
47
|
-
getMarketReservesWeights(): Promise<[number, number]>;
|
|
48
|
-
private initializeTWAPPrice;
|
|
49
|
-
getTWAPPrice(): Promise<number>;
|
|
50
|
-
private initializeStakedLPExchangeRate;
|
|
51
|
-
getStakedLPExchangeRate(): Promise<number>;
|
|
52
|
-
private initializePendingReward;
|
|
53
|
-
getPendingReward(): Promise<PendingRewardUI | null>;
|
|
54
|
-
private initializeReinvestBountyFactor;
|
|
55
|
-
getReinvestBountyFactor(): Promise<number>;
|
|
56
|
-
getReinvestBounty(): Promise<number>;
|
|
38
|
+
private initializeLendingPoolAddresses;
|
|
39
|
+
private getLendingPoolAddresses;
|
|
40
|
+
getCollateralAddress(): Promise<string>;
|
|
41
|
+
getBorrowableAddress(borrowable: Borrowable): Promise<string>;
|
|
57
42
|
hasFarming(): Promise<boolean>;
|
|
58
43
|
}
|