impermax-sdk 1.1.26 → 1.1.27
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/index.d.ts +37 -37
- package/lib/index.js +71 -71
- package/lib/offchain/Account.d.ts +21 -0
- package/lib/offchain/Account.js +88 -0
- package/lib/offchain/AccountBorrowable.d.ts +14 -0
- package/lib/offchain/AccountBorrowable.js +73 -0
- package/lib/offchain/AccountCollateral.d.ts +12 -0
- package/lib/offchain/AccountCollateral.js +42 -0
- package/lib/offchain/AccountLendingPool.d.ts +20 -0
- package/lib/offchain/AccountLendingPool.js +66 -0
- package/lib/offchain/AccountLendingVault.d.ts +11 -0
- package/lib/offchain/AccountLendingVault.js +38 -0
- package/lib/offchain/AccountPoolToken.d.ts +6 -0
- package/lib/offchain/AccountPoolToken.js +21 -0
- package/lib/offchain/Borrowable.d.ts +55 -0
- package/lib/offchain/Borrowable.js +351 -0
- package/lib/offchain/Collateral.d.ts +17 -0
- package/lib/offchain/Collateral.js +72 -0
- package/lib/offchain/LendingPool.d.ts +43 -0
- package/lib/offchain/LendingPool.js +205 -0
- package/lib/offchain/LendingVault.d.ts +22 -0
- package/lib/offchain/LendingVault.js +110 -0
- package/lib/offchain/PoolToken.d.ts +20 -0
- package/lib/offchain/PoolToken.js +120 -0
- package/lib/offchain/PriceHelper.d.ts +21 -0
- package/lib/offchain/PriceHelper.js +194 -0
- package/lib/offchain/SolidexHelper.d.ts +16 -0
- package/lib/offchain/SolidexHelper.js +58 -0
- package/lib/offchain/index.d.ts +79 -0
- package/lib/offchain/index.js +196 -0
- package/lib/offchain/initializer.d.ts +35 -0
- package/lib/offchain/initializer.js +594 -0
- package/lib/offchain/query.d.ts +10 -0
- package/lib/offchain/query.js +229 -0
- package/lib/offchain/types.d.ts +145 -0
- package/lib/offchain/types.js +3 -0
- package/lib/onchain/Account.d.ts +35 -0
- package/lib/onchain/Account.js +173 -0
- package/lib/onchain/AccountBorrowable.d.ts +29 -0
- package/lib/onchain/AccountBorrowable.js +135 -0
- package/lib/onchain/AccountCollateral.d.ts +15 -0
- package/lib/onchain/AccountCollateral.js +66 -0
- package/lib/onchain/AccountLendingPool.d.ts +57 -0
- package/lib/onchain/AccountLendingPool.js +268 -0
- package/lib/onchain/AccountLendingVault.d.ts +10 -0
- package/lib/onchain/AccountLendingVault.js +35 -0
- package/lib/onchain/AccountPoolToken.d.ts +24 -0
- package/lib/onchain/AccountPoolToken.js +84 -0
- package/lib/onchain/Borrowable.d.ts +36 -0
- package/lib/onchain/Borrowable.js +153 -0
- package/lib/onchain/Collateral.d.ts +17 -0
- package/lib/onchain/Collateral.js +59 -0
- package/lib/onchain/ContractsHelper.d.ts +29 -0
- package/lib/onchain/ContractsHelper.js +52 -0
- package/lib/onchain/ImpermaxFactory.d.ts +20 -0
- package/lib/onchain/ImpermaxFactory.js +50 -0
- package/lib/onchain/Interactions.d.ts +24 -0
- package/lib/onchain/Interactions.js +122 -0
- package/lib/onchain/InteractionsBorrowable.d.ts +16 -0
- package/lib/onchain/InteractionsBorrowable.js +49 -0
- package/lib/onchain/InteractionsCollateral.d.ts +15 -0
- package/lib/onchain/InteractionsCollateral.js +33 -0
- package/lib/onchain/InteractionsLendingPool.d.ts +39 -0
- package/lib/onchain/InteractionsLendingPool.js +118 -0
- package/lib/onchain/InteractionsLendingVault.d.ts +10 -0
- package/lib/onchain/InteractionsLendingVault.js +12 -0
- package/lib/onchain/InteractionsPoolToken.d.ts +33 -0
- package/lib/onchain/InteractionsPoolToken.js +180 -0
- package/lib/onchain/LendingPool.d.ts +69 -0
- package/lib/onchain/LendingPool.js +291 -0
- package/lib/onchain/LendingVault.d.ts +17 -0
- package/lib/onchain/LendingVault.js +56 -0
- package/lib/onchain/PoolToken.d.ts +32 -0
- package/lib/onchain/PoolToken.js +121 -0
- package/lib/onchain/index.d.ts +23 -0
- package/lib/onchain/index.js +43 -0
- package/lib/onchain/types.d.ts +45 -0
- package/lib/onchain/types.js +14 -0
- package/lib/subgraph/LendingPool.js +1 -1
- package/lib/subgraph/PriceHelper.js +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import Offchain from './offchain';
|
|
2
|
+
import Onchain from './onchain';
|
|
3
3
|
import { CLAIM_AGGREGATOR } from './config/contracts/claim-aggregators';
|
|
4
4
|
import { IMPERMAX_CHEF } from './config/contracts/impermax-chef';
|
|
5
5
|
import { IMX } from './config/contracts/imxes';
|
|
@@ -16,38 +16,38 @@ import { FarmIndex, Farms, getFarmByStakedLPFactory, hrFarms, STAKED_LP_FACTORY
|
|
|
16
16
|
import { APPROVE_AMOUNT, DEADLINE, NOT_SYNCED, ZERO } from './config/general';
|
|
17
17
|
import { BLOCKS_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, IMPERMAX_SUBGRAPH_URL, XIMX_SUBGRAPH_URL } from './config/subgraphs';
|
|
18
18
|
import { Address, AddressIndex, AmmIndex, DistributorDetails, Factory, FactoryIndex, LendingPoolIndex, NetworkFactoryIndex, NetworkIndex, Networks, PoolTokenType } from './config/types';
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import { AirdropData, ApprovalType, Changes, Contract,
|
|
52
|
-
import { BorrowableData, BorrowablePastData, BorrowPosition, CollateralData, CollateralPosition, FarmingPoolData, LendingPoolData, LendingPoolPastData, PairData, PoolTokenData, RewardData, SupplyPosition, TokenData, TvlData, UserData, XimxData } from './
|
|
53
|
-
export { CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, MERKLE_DISTRIBUTOR_IBEX, MERKLE_DISTRIBUTOR_IBEX_2, MERKLE_DISTRIBUTOR_ETH, ROUTER, SIMPLE_UNISWAP_ORACLE, WETH, MERKLE_URL_ETH, MERKLE_URL_IBEX, MERKLE_URL_IBEX_2, hrAmms, AMM_FACTORY, getAmmByFactory, AMM_SUBGRAPH_URLS, ADD_LIQUIDITY_URLS, AMM_LP_FEE, DEBANK_IDS, ETH_SYMBOL, ETH_NAME, SOLIDEX_FACTORIES, BORROW_FEE_FACTORIES, OLD_KINK_MULTIPLIER_FACTORIES, LIQUIDATION_FEE_FACTORIES, V2_FACTORIES, Farms, hrFarms, FarmIndex, STAKED_LP_FACTORY, getFarmByStakedLPFactory, NOT_SYNCED, DEADLINE, ZERO, APPROVE_AMOUNT, IMPERMAX_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, BLOCKS_SUBGRAPH_URL, XIMX_SUBGRAPH_URL, Networks, Factory, PoolTokenType, Amms, Address, NetworkIndex, FactoryIndex, AddressIndex, NetworkFactoryIndex, LendingPoolIndex, AmmIndex, DistributorDetails,
|
|
19
|
+
import OffchainAccount from './offchain/Account';
|
|
20
|
+
import OffchainAccountLendingPool from './offchain/AccountLendingPool';
|
|
21
|
+
import OffchainAccountPoolToken from './offchain/AccountPoolToken';
|
|
22
|
+
import OffchainAccountCollateral from './offchain/AccountCollateral';
|
|
23
|
+
import OffchainAccountBorrowable from './offchain/AccountBorrowable';
|
|
24
|
+
import OffchainAccountLendingVault from './offchain/AccountLendingVault';
|
|
25
|
+
import OffchainLendingPool from './offchain/LendingPool';
|
|
26
|
+
import OffchainPoolToken from './offchain/PoolToken';
|
|
27
|
+
import OffchainCollateral from './offchain/Collateral';
|
|
28
|
+
import OffchainBorrowable from './offchain/Borrowable';
|
|
29
|
+
import OffchainLendingVault from './offchain/LendingVault';
|
|
30
|
+
import OffchainPriceHelper from './offchain/PriceHelper';
|
|
31
|
+
import OffchainSolidexHelper from './offchain/SolidexHelper';
|
|
32
|
+
import OnchainAccount from './onchain/Account';
|
|
33
|
+
import OnchainAccountLendingPool from './onchain/AccountLendingPool';
|
|
34
|
+
import OnchainAccountPoolToken from './onchain/AccountPoolToken';
|
|
35
|
+
import OnchainAccountCollateral from './onchain/AccountCollateral';
|
|
36
|
+
import OnchainAccountBorrowable from './onchain/AccountBorrowable';
|
|
37
|
+
import OnchainAccountLendingVault from './onchain/AccountLendingVault';
|
|
38
|
+
import OnchainContractsHelper from './onchain/ContractsHelper';
|
|
39
|
+
import OnchainImpermaxFactory from './onchain/ImpermaxFactory';
|
|
40
|
+
import OnchainInteractions from './onchain/Interactions';
|
|
41
|
+
import OnchainInteractionsLendingPool from './onchain/InteractionsLendingPool';
|
|
42
|
+
import OnchainInteractionsPoolToken from './onchain/InteractionsPoolToken';
|
|
43
|
+
import OnchainInteractionsCollateral from './onchain/InteractionsCollateral';
|
|
44
|
+
import OnchainInteractionsBorrowable from './onchain/InteractionsBorrowable';
|
|
45
|
+
import OnchainInteractionsLendingVault from './onchain/InteractionsLendingVault';
|
|
46
|
+
import OnchainLendingPool from './onchain/LendingPool';
|
|
47
|
+
import OnchainPoolToken from './onchain/PoolToken';
|
|
48
|
+
import OnchainCollateral from './onchain/Collateral';
|
|
49
|
+
import OnchainBorrowable from './onchain/Borrowable';
|
|
50
|
+
import OnchainLendingVault from './onchain/LendingVault';
|
|
51
|
+
import { AirdropData, ApprovalType, Changes, Contract, OnchainConfig, NO_CHANGES, PendingRewardUI, PermitData, Values } from './onchain/types';
|
|
52
|
+
import { BorrowableData, BorrowablePastData, BorrowPosition, CollateralData, CollateralPosition, FarmingPoolData, LendingPoolData, LendingPoolPastData, PairData, PoolTokenData, RewardData, SupplyPosition, TokenData, TvlData, UserData, XimxData } from './offchain/types';
|
|
53
|
+
export { CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, MERKLE_DISTRIBUTOR_IBEX, MERKLE_DISTRIBUTOR_IBEX_2, MERKLE_DISTRIBUTOR_ETH, ROUTER, SIMPLE_UNISWAP_ORACLE, WETH, MERKLE_URL_ETH, MERKLE_URL_IBEX, MERKLE_URL_IBEX_2, hrAmms, AMM_FACTORY, getAmmByFactory, AMM_SUBGRAPH_URLS, ADD_LIQUIDITY_URLS, AMM_LP_FEE, DEBANK_IDS, ETH_SYMBOL, ETH_NAME, SOLIDEX_FACTORIES, BORROW_FEE_FACTORIES, OLD_KINK_MULTIPLIER_FACTORIES, LIQUIDATION_FEE_FACTORIES, V2_FACTORIES, Farms, hrFarms, FarmIndex, STAKED_LP_FACTORY, getFarmByStakedLPFactory, NOT_SYNCED, DEADLINE, ZERO, APPROVE_AMOUNT, IMPERMAX_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, BLOCKS_SUBGRAPH_URL, XIMX_SUBGRAPH_URL, Networks, Factory, PoolTokenType, Amms, Address, NetworkIndex, FactoryIndex, AddressIndex, NetworkFactoryIndex, LendingPoolIndex, AmmIndex, DistributorDetails, Offchain, OffchainLendingPool, OffchainPoolToken, OffchainCollateral, OffchainBorrowable, OffchainLendingVault, OffchainAccount, OffchainAccountLendingPool, OffchainAccountPoolToken, OffchainAccountCollateral, OffchainAccountBorrowable, OffchainAccountLendingVault, OffchainPriceHelper, OffchainSolidexHelper, PoolTokenData, BorrowableData, CollateralData, BorrowablePastData, TokenData, RewardData, PairData, FarmingPoolData, LendingPoolPastData, LendingPoolData, CollateralPosition, SupplyPosition, BorrowPosition, UserData, TvlData, XimxData, Onchain, OnchainLendingPool, OnchainPoolToken, OnchainBorrowable, OnchainCollateral, OnchainLendingVault, OnchainAccount, OnchainAccountLendingPool, OnchainAccountPoolToken, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingVault, OnchainContractsHelper, OnchainImpermaxFactory, OnchainInteractions, OnchainInteractionsLendingPool, OnchainInteractionsPoolToken, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, OnchainInteractionsLendingVault, Contract, ApprovalType, PermitData, OnchainConfig, Changes, NO_CHANGES, Values, AirdropData, PendingRewardUI, };
|
package/lib/index.js
CHANGED
|
@@ -3,12 +3,12 @@ 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
|
-
exports.
|
|
7
|
-
exports.NO_CHANGES = exports.ApprovalType = exports.
|
|
8
|
-
const
|
|
9
|
-
exports.
|
|
10
|
-
const
|
|
11
|
-
exports.
|
|
6
|
+
exports.OffchainAccountLendingPool = exports.OffchainAccount = exports.OffchainLendingVault = exports.OffchainBorrowable = exports.OffchainCollateral = exports.OffchainPoolToken = exports.OffchainLendingPool = exports.Offchain = exports.Amms = exports.PoolTokenType = exports.Factory = exports.Networks = exports.XIMX_SUBGRAPH_URL = exports.BLOCKS_SUBGRAPH_URL = exports.IMPERMAX_CHEF_SUBGRAPH_URL = exports.IMPERMAX_SUBGRAPH_URL = exports.APPROVE_AMOUNT = exports.ZERO = exports.DEADLINE = exports.NOT_SYNCED = exports.getFarmByStakedLPFactory = exports.STAKED_LP_FACTORY = exports.hrFarms = exports.Farms = exports.V2_FACTORIES = exports.LIQUIDATION_FEE_FACTORIES = exports.OLD_KINK_MULTIPLIER_FACTORIES = exports.BORROW_FEE_FACTORIES = exports.SOLIDEX_FACTORIES = exports.ETH_NAME = exports.ETH_SYMBOL = exports.DEBANK_IDS = exports.AMM_LP_FEE = exports.ADD_LIQUIDITY_URLS = exports.AMM_SUBGRAPH_URLS = exports.getAmmByFactory = exports.AMM_FACTORY = exports.hrAmms = exports.MERKLE_URL_IBEX_2 = exports.MERKLE_URL_IBEX = exports.MERKLE_URL_ETH = exports.WETH = exports.SIMPLE_UNISWAP_ORACLE = exports.ROUTER = exports.MERKLE_DISTRIBUTOR_ETH = exports.MERKLE_DISTRIBUTOR_IBEX_2 = exports.MERKLE_DISTRIBUTOR_IBEX = exports.IMX = exports.IMPERMAX_CHEF = exports.CLAIM_AGGREGATOR = void 0;
|
|
7
|
+
exports.NO_CHANGES = exports.ApprovalType = exports.OnchainInteractionsLendingVault = exports.OnchainInteractionsBorrowable = exports.OnchainInteractionsCollateral = exports.OnchainInteractionsPoolToken = exports.OnchainInteractionsLendingPool = exports.OnchainInteractions = exports.OnchainImpermaxFactory = exports.OnchainContractsHelper = exports.OnchainAccountLendingVault = exports.OnchainAccountCollateral = exports.OnchainAccountBorrowable = exports.OnchainAccountPoolToken = exports.OnchainAccountLendingPool = exports.OnchainAccount = exports.OnchainLendingVault = exports.OnchainCollateral = exports.OnchainBorrowable = exports.OnchainPoolToken = exports.OnchainLendingPool = exports.Onchain = exports.OffchainSolidexHelper = exports.OffchainPriceHelper = exports.OffchainAccountLendingVault = exports.OffchainAccountBorrowable = exports.OffchainAccountCollateral = exports.OffchainAccountPoolToken = void 0;
|
|
8
|
+
const offchain_1 = __importDefault(require("./offchain"));
|
|
9
|
+
exports.Offchain = offchain_1.default;
|
|
10
|
+
const onchain_1 = __importDefault(require("./onchain"));
|
|
11
|
+
exports.Onchain = onchain_1.default;
|
|
12
12
|
const claim_aggregators_1 = require("./config/contracts/claim-aggregators");
|
|
13
13
|
Object.defineProperty(exports, "CLAIM_AGGREGATOR", { enumerable: true, get: function () { return claim_aggregators_1.CLAIM_AGGREGATOR; } });
|
|
14
14
|
const impermax_chef_1 = require("./config/contracts/impermax-chef");
|
|
@@ -67,70 +67,70 @@ const types_1 = require("./config/types");
|
|
|
67
67
|
Object.defineProperty(exports, "Factory", { enumerable: true, get: function () { return types_1.Factory; } });
|
|
68
68
|
Object.defineProperty(exports, "Networks", { enumerable: true, get: function () { return types_1.Networks; } });
|
|
69
69
|
Object.defineProperty(exports, "PoolTokenType", { enumerable: true, get: function () { return types_1.PoolTokenType; } });
|
|
70
|
-
const Account_1 = __importDefault(require("./
|
|
71
|
-
exports.
|
|
72
|
-
const AccountLendingPool_1 = __importDefault(require("./
|
|
73
|
-
exports.
|
|
74
|
-
const AccountPoolToken_1 = __importDefault(require("./
|
|
75
|
-
exports.
|
|
76
|
-
const AccountCollateral_1 = __importDefault(require("./
|
|
77
|
-
exports.
|
|
78
|
-
const AccountBorrowable_1 = __importDefault(require("./
|
|
79
|
-
exports.
|
|
80
|
-
const AccountLendingVault_1 = __importDefault(require("./
|
|
81
|
-
exports.
|
|
82
|
-
const LendingPool_1 = __importDefault(require("./
|
|
83
|
-
exports.
|
|
84
|
-
const PoolToken_1 = __importDefault(require("./
|
|
85
|
-
exports.
|
|
86
|
-
const Collateral_1 = __importDefault(require("./
|
|
87
|
-
exports.
|
|
88
|
-
const Borrowable_1 = __importDefault(require("./
|
|
89
|
-
exports.
|
|
90
|
-
const LendingVault_1 = __importDefault(require("./
|
|
91
|
-
exports.
|
|
92
|
-
const PriceHelper_1 = __importDefault(require("./
|
|
93
|
-
exports.
|
|
94
|
-
const SolidexHelper_1 = __importDefault(require("./
|
|
95
|
-
exports.
|
|
96
|
-
const Account_2 = __importDefault(require("./
|
|
97
|
-
exports.
|
|
98
|
-
const AccountLendingPool_2 = __importDefault(require("./
|
|
99
|
-
exports.
|
|
100
|
-
const AccountPoolToken_2 = __importDefault(require("./
|
|
101
|
-
exports.
|
|
102
|
-
const AccountCollateral_2 = __importDefault(require("./
|
|
103
|
-
exports.
|
|
104
|
-
const AccountBorrowable_2 = __importDefault(require("./
|
|
105
|
-
exports.
|
|
106
|
-
const AccountLendingVault_2 = __importDefault(require("./
|
|
107
|
-
exports.
|
|
108
|
-
const ContractsHelper_1 = __importDefault(require("./
|
|
109
|
-
exports.
|
|
110
|
-
const ImpermaxFactory_1 = __importDefault(require("./
|
|
111
|
-
exports.
|
|
112
|
-
const Interactions_1 = __importDefault(require("./
|
|
113
|
-
exports.
|
|
114
|
-
const InteractionsLendingPool_1 = __importDefault(require("./
|
|
115
|
-
exports.
|
|
116
|
-
const InteractionsPoolToken_1 = __importDefault(require("./
|
|
117
|
-
exports.
|
|
118
|
-
const InteractionsCollateral_1 = __importDefault(require("./
|
|
119
|
-
exports.
|
|
120
|
-
const InteractionsBorrowable_1 = __importDefault(require("./
|
|
121
|
-
exports.
|
|
122
|
-
const InteractionsLendingVault_1 = __importDefault(require("./
|
|
123
|
-
exports.
|
|
124
|
-
const LendingPool_2 = __importDefault(require("./
|
|
125
|
-
exports.
|
|
126
|
-
const PoolToken_2 = __importDefault(require("./
|
|
127
|
-
exports.
|
|
128
|
-
const Collateral_2 = __importDefault(require("./
|
|
129
|
-
exports.
|
|
130
|
-
const Borrowable_2 = __importDefault(require("./
|
|
131
|
-
exports.
|
|
132
|
-
const LendingVault_2 = __importDefault(require("./
|
|
133
|
-
exports.
|
|
134
|
-
const types_2 = require("./
|
|
70
|
+
const Account_1 = __importDefault(require("./offchain/Account"));
|
|
71
|
+
exports.OffchainAccount = Account_1.default;
|
|
72
|
+
const AccountLendingPool_1 = __importDefault(require("./offchain/AccountLendingPool"));
|
|
73
|
+
exports.OffchainAccountLendingPool = AccountLendingPool_1.default;
|
|
74
|
+
const AccountPoolToken_1 = __importDefault(require("./offchain/AccountPoolToken"));
|
|
75
|
+
exports.OffchainAccountPoolToken = AccountPoolToken_1.default;
|
|
76
|
+
const AccountCollateral_1 = __importDefault(require("./offchain/AccountCollateral"));
|
|
77
|
+
exports.OffchainAccountCollateral = AccountCollateral_1.default;
|
|
78
|
+
const AccountBorrowable_1 = __importDefault(require("./offchain/AccountBorrowable"));
|
|
79
|
+
exports.OffchainAccountBorrowable = AccountBorrowable_1.default;
|
|
80
|
+
const AccountLendingVault_1 = __importDefault(require("./offchain/AccountLendingVault"));
|
|
81
|
+
exports.OffchainAccountLendingVault = AccountLendingVault_1.default;
|
|
82
|
+
const LendingPool_1 = __importDefault(require("./offchain/LendingPool"));
|
|
83
|
+
exports.OffchainLendingPool = LendingPool_1.default;
|
|
84
|
+
const PoolToken_1 = __importDefault(require("./offchain/PoolToken"));
|
|
85
|
+
exports.OffchainPoolToken = PoolToken_1.default;
|
|
86
|
+
const Collateral_1 = __importDefault(require("./offchain/Collateral"));
|
|
87
|
+
exports.OffchainCollateral = Collateral_1.default;
|
|
88
|
+
const Borrowable_1 = __importDefault(require("./offchain/Borrowable"));
|
|
89
|
+
exports.OffchainBorrowable = Borrowable_1.default;
|
|
90
|
+
const LendingVault_1 = __importDefault(require("./offchain/LendingVault"));
|
|
91
|
+
exports.OffchainLendingVault = LendingVault_1.default;
|
|
92
|
+
const PriceHelper_1 = __importDefault(require("./offchain/PriceHelper"));
|
|
93
|
+
exports.OffchainPriceHelper = PriceHelper_1.default;
|
|
94
|
+
const SolidexHelper_1 = __importDefault(require("./offchain/SolidexHelper"));
|
|
95
|
+
exports.OffchainSolidexHelper = SolidexHelper_1.default;
|
|
96
|
+
const Account_2 = __importDefault(require("./onchain/Account"));
|
|
97
|
+
exports.OnchainAccount = Account_2.default;
|
|
98
|
+
const AccountLendingPool_2 = __importDefault(require("./onchain/AccountLendingPool"));
|
|
99
|
+
exports.OnchainAccountLendingPool = AccountLendingPool_2.default;
|
|
100
|
+
const AccountPoolToken_2 = __importDefault(require("./onchain/AccountPoolToken"));
|
|
101
|
+
exports.OnchainAccountPoolToken = AccountPoolToken_2.default;
|
|
102
|
+
const AccountCollateral_2 = __importDefault(require("./onchain/AccountCollateral"));
|
|
103
|
+
exports.OnchainAccountCollateral = AccountCollateral_2.default;
|
|
104
|
+
const AccountBorrowable_2 = __importDefault(require("./onchain/AccountBorrowable"));
|
|
105
|
+
exports.OnchainAccountBorrowable = AccountBorrowable_2.default;
|
|
106
|
+
const AccountLendingVault_2 = __importDefault(require("./onchain/AccountLendingVault"));
|
|
107
|
+
exports.OnchainAccountLendingVault = AccountLendingVault_2.default;
|
|
108
|
+
const ContractsHelper_1 = __importDefault(require("./onchain/ContractsHelper"));
|
|
109
|
+
exports.OnchainContractsHelper = ContractsHelper_1.default;
|
|
110
|
+
const ImpermaxFactory_1 = __importDefault(require("./onchain/ImpermaxFactory"));
|
|
111
|
+
exports.OnchainImpermaxFactory = ImpermaxFactory_1.default;
|
|
112
|
+
const Interactions_1 = __importDefault(require("./onchain/Interactions"));
|
|
113
|
+
exports.OnchainInteractions = Interactions_1.default;
|
|
114
|
+
const InteractionsLendingPool_1 = __importDefault(require("./onchain/InteractionsLendingPool"));
|
|
115
|
+
exports.OnchainInteractionsLendingPool = InteractionsLendingPool_1.default;
|
|
116
|
+
const InteractionsPoolToken_1 = __importDefault(require("./onchain/InteractionsPoolToken"));
|
|
117
|
+
exports.OnchainInteractionsPoolToken = InteractionsPoolToken_1.default;
|
|
118
|
+
const InteractionsCollateral_1 = __importDefault(require("./onchain/InteractionsCollateral"));
|
|
119
|
+
exports.OnchainInteractionsCollateral = InteractionsCollateral_1.default;
|
|
120
|
+
const InteractionsBorrowable_1 = __importDefault(require("./onchain/InteractionsBorrowable"));
|
|
121
|
+
exports.OnchainInteractionsBorrowable = InteractionsBorrowable_1.default;
|
|
122
|
+
const InteractionsLendingVault_1 = __importDefault(require("./onchain/InteractionsLendingVault"));
|
|
123
|
+
exports.OnchainInteractionsLendingVault = InteractionsLendingVault_1.default;
|
|
124
|
+
const LendingPool_2 = __importDefault(require("./onchain/LendingPool"));
|
|
125
|
+
exports.OnchainLendingPool = LendingPool_2.default;
|
|
126
|
+
const PoolToken_2 = __importDefault(require("./onchain/PoolToken"));
|
|
127
|
+
exports.OnchainPoolToken = PoolToken_2.default;
|
|
128
|
+
const Collateral_2 = __importDefault(require("./onchain/Collateral"));
|
|
129
|
+
exports.OnchainCollateral = Collateral_2.default;
|
|
130
|
+
const Borrowable_2 = __importDefault(require("./onchain/Borrowable"));
|
|
131
|
+
exports.OnchainBorrowable = Borrowable_2.default;
|
|
132
|
+
const LendingVault_2 = __importDefault(require("./onchain/LendingVault"));
|
|
133
|
+
exports.OnchainLendingVault = LendingVault_2.default;
|
|
134
|
+
const types_2 = require("./onchain/types");
|
|
135
135
|
Object.defineProperty(exports, "ApprovalType", { enumerable: true, get: function () { return types_2.ApprovalType; } });
|
|
136
136
|
Object.defineProperty(exports, "NO_CHANGES", { enumerable: true, get: function () { return types_2.NO_CHANGES; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Offchain from "./index";
|
|
2
|
+
import AccountLendingPool from "./AccountLendingPool";
|
|
3
|
+
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex } from '../config/types';
|
|
4
|
+
import { UserData } from './types';
|
|
5
|
+
import AccountLendingVault from './AccountLendingVault';
|
|
6
|
+
export default class Account {
|
|
7
|
+
subgraph: Offchain;
|
|
8
|
+
account: Address;
|
|
9
|
+
accountLLPs: LendingPoolIndex<Promise<AccountLendingPool>>;
|
|
10
|
+
accountLVs: AddressIndex<Promise<AccountLendingVault>>;
|
|
11
|
+
constructor(subgraph: Offchain, account: Address);
|
|
12
|
+
private initializeAccountLendingPool;
|
|
13
|
+
getAccountLendingPool(factory: Factory, pair: Address): Promise<AccountLendingPool>;
|
|
14
|
+
private initializeAccountLendingVault;
|
|
15
|
+
getAccountLendingVault(vaultAddress: Address): Promise<AccountLendingVault>;
|
|
16
|
+
getUserData(): Promise<FactoryIndex<UserData>>;
|
|
17
|
+
getBorrowPositions(): Promise<FactoryIndex<Address[]>>;
|
|
18
|
+
getSupplyPositions(): Promise<FactoryIndex<Address[]>>;
|
|
19
|
+
getLendingVaultsSuppliedUSD(): Promise<number>;
|
|
20
|
+
getLendingVaultsEarningsUSD(): Promise<number>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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 AccountLendingPool_1 = __importDefault(require("./AccountLendingPool"));
|
|
16
|
+
const AccountLendingVault_1 = __importDefault(require("./AccountLendingVault"));
|
|
17
|
+
class Account {
|
|
18
|
+
constructor(subgraph, account) {
|
|
19
|
+
this.subgraph = subgraph;
|
|
20
|
+
this.account = account;
|
|
21
|
+
this.accountLLPs = {};
|
|
22
|
+
this.accountLVs = {};
|
|
23
|
+
}
|
|
24
|
+
initializeAccountLendingPool(factory, pair) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const lendingPool = yield this.subgraph.getLendingPool(factory, pair);
|
|
27
|
+
return new AccountLendingPool_1.default(this, lendingPool);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getAccountLendingPool(factory, pair) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (!this.accountLLPs[factory])
|
|
33
|
+
this.accountLLPs[factory] = {};
|
|
34
|
+
if (!this.accountLLPs[factory][pair])
|
|
35
|
+
this.accountLLPs[factory][pair] = this.initializeAccountLendingPool(factory, pair);
|
|
36
|
+
return this.accountLLPs[factory][pair];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
initializeAccountLendingVault(vaultAddress) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const lendingVault = yield this.subgraph.getLendingVault(vaultAddress);
|
|
42
|
+
return new AccountLendingVault_1.default(this, lendingVault);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getAccountLendingVault(vaultAddress) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (!this.accountLVs[vaultAddress])
|
|
48
|
+
this.accountLVs[vaultAddress] = this.initializeAccountLendingVault(vaultAddress);
|
|
49
|
+
return this.accountLVs[vaultAddress];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
getUserData() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
return this.subgraph.getUserData(this.account);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getBorrowPositions() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const result = {};
|
|
60
|
+
const userData = yield this.getUserData();
|
|
61
|
+
for (const factory of Object.keys(userData)) {
|
|
62
|
+
result[factory] = Object.keys(userData[factory].collateralPositions);
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
getSupplyPositions() {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const result = {};
|
|
70
|
+
const userData = yield this.getUserData();
|
|
71
|
+
for (const factory of Object.keys(userData)) {
|
|
72
|
+
result[factory] = Object.keys(userData[factory].supplyPositions);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getLendingVaultsSuppliedUSD() {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
return 0;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
getLendingVaultsEarningsUSD() {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
return 0;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.default = Account;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PoolTokenType } from '../config/types';
|
|
2
|
+
import AccountPoolToken from './AccountPoolToken';
|
|
3
|
+
import AccountLendingPool from './AccountLendingPool';
|
|
4
|
+
import Borrowable from './Borrowable';
|
|
5
|
+
export default class AccountBorrowable extends AccountPoolToken {
|
|
6
|
+
accountLendingPool: AccountLendingPool;
|
|
7
|
+
poolToken: Borrowable;
|
|
8
|
+
constructor(accountLendingPool: AccountLendingPool, poolTokenType: PoolTokenType);
|
|
9
|
+
private getSupplyPosition;
|
|
10
|
+
getAmount(): Promise<number>;
|
|
11
|
+
private getBorrowPosition;
|
|
12
|
+
getBorrowedAmount(): Promise<number>;
|
|
13
|
+
getBorrowedValue(): Promise<number>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 AccountPoolToken_1 = __importDefault(require("./AccountPoolToken"));
|
|
16
|
+
class AccountBorrowable extends AccountPoolToken_1.default {
|
|
17
|
+
constructor(accountLendingPool, poolTokenType) {
|
|
18
|
+
super();
|
|
19
|
+
this.accountLendingPool = accountLendingPool;
|
|
20
|
+
this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
|
|
21
|
+
}
|
|
22
|
+
getSupplyPosition() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const userData = yield this.accountLendingPool.getUserData();
|
|
25
|
+
if (!userData)
|
|
26
|
+
return null;
|
|
27
|
+
const supplyPositions = userData.supplyPositions[this.poolToken.lendingPool.pairAddress];
|
|
28
|
+
if (!supplyPositions)
|
|
29
|
+
return null;
|
|
30
|
+
return supplyPositions[this.poolToken.poolTokenType];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getAmount() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const supplyPosition = yield this.getSupplyPosition();
|
|
36
|
+
if (!supplyPosition)
|
|
37
|
+
return 0;
|
|
38
|
+
const exchangeRate = yield this.poolToken.getExchangeRate();
|
|
39
|
+
const supplyBalance = parseFloat(supplyPosition.balance);
|
|
40
|
+
return supplyBalance * exchangeRate;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getBorrowPosition() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const userData = yield this.accountLendingPool.getUserData();
|
|
46
|
+
if (!userData)
|
|
47
|
+
return null;
|
|
48
|
+
const borrowPositions = userData.borrowPositions[this.poolToken.lendingPool.pairAddress];
|
|
49
|
+
if (!borrowPositions)
|
|
50
|
+
return null;
|
|
51
|
+
return borrowPositions[this.poolToken.poolTokenType];
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getBorrowedAmount() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const borrowPosition = yield this.getBorrowPosition();
|
|
57
|
+
const borrowIndex = yield this.poolToken.getBorrowIndex();
|
|
58
|
+
if (!borrowPosition)
|
|
59
|
+
return 0;
|
|
60
|
+
const borrowBalance = parseFloat(borrowPosition.borrowBalance);
|
|
61
|
+
const userBorrowIndex = parseFloat(borrowPosition.borrowIndex);
|
|
62
|
+
return borrowBalance * borrowIndex / userBorrowIndex;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
getBorrowedValue() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const tokenPrice = yield this.poolToken.getTokenPriceAccurate();
|
|
68
|
+
const borrowedAmount = yield this.getBorrowedAmount();
|
|
69
|
+
return borrowedAmount * tokenPrice;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = AccountBorrowable;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CollateralPosition } from "./types";
|
|
2
|
+
import { PoolTokenType } from '../config/types';
|
|
3
|
+
import AccountPoolToken from './AccountPoolToken';
|
|
4
|
+
import AccountLendingPool from './AccountLendingPool';
|
|
5
|
+
import Collateral from './Collateral';
|
|
6
|
+
export default class AccountCollateral extends AccountPoolToken {
|
|
7
|
+
accountLendingPool: AccountLendingPool;
|
|
8
|
+
poolToken: Collateral;
|
|
9
|
+
constructor(accountLendingPool: AccountLendingPool, poolTokenType: PoolTokenType);
|
|
10
|
+
getCollateralPosition(): Promise<CollateralPosition>;
|
|
11
|
+
getAmount(): Promise<number>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 types_1 = require("../config/types");
|
|
16
|
+
const AccountPoolToken_1 = __importDefault(require("./AccountPoolToken"));
|
|
17
|
+
class AccountCollateral extends AccountPoolToken_1.default {
|
|
18
|
+
constructor(accountLendingPool, poolTokenType) {
|
|
19
|
+
super();
|
|
20
|
+
this.accountLendingPool = accountLendingPool;
|
|
21
|
+
this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
|
|
22
|
+
}
|
|
23
|
+
getCollateralPosition() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const userData = yield this.accountLendingPool.getUserData();
|
|
26
|
+
if (!userData)
|
|
27
|
+
return null;
|
|
28
|
+
return userData.collateralPositions[this.poolToken.lendingPool.pairAddress];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
getAmount() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const collateralPosition = yield this.getCollateralPosition();
|
|
34
|
+
if (!collateralPosition)
|
|
35
|
+
return 0;
|
|
36
|
+
const exchangeRate = yield this.poolToken.lendingPool.poolTokens[types_1.PoolTokenType.Collateral].getExchangeRate();
|
|
37
|
+
const collateralBalance = parseFloat(collateralPosition.balance);
|
|
38
|
+
return collateralBalance * exchangeRate;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = AccountCollateral;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Account from "./Account";
|
|
2
|
+
import AccountPoolToken from "./AccountPoolToken";
|
|
3
|
+
import LendingPool from "./LendingPool";
|
|
4
|
+
import { PoolTokenType } from '../config/types';
|
|
5
|
+
import { UserData } from './types';
|
|
6
|
+
import AccountCollateral from './AccountCollateral';
|
|
7
|
+
import AccountBorrowable from './AccountBorrowable';
|
|
8
|
+
export default class AccountLendingPool {
|
|
9
|
+
account: Account;
|
|
10
|
+
lendingPool: LendingPool;
|
|
11
|
+
accountPoolTokens: {
|
|
12
|
+
[PoolTokenType.Collateral]?: AccountCollateral;
|
|
13
|
+
[PoolTokenType.BorrowableA]?: AccountBorrowable;
|
|
14
|
+
[PoolTokenType.BorrowableB]?: AccountBorrowable;
|
|
15
|
+
};
|
|
16
|
+
constructor(account: Account, lendingPool: LendingPool);
|
|
17
|
+
getAccountPoolToken(poolTokenType: PoolTokenType): AccountPoolToken;
|
|
18
|
+
getUserData(): Promise<UserData>;
|
|
19
|
+
getBorrowerEquityValue(): Promise<number>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 types_1 = require("../config/types");
|
|
16
|
+
const AccountCollateral_1 = __importDefault(require("./AccountCollateral"));
|
|
17
|
+
const AccountBorrowable_1 = __importDefault(require("./AccountBorrowable"));
|
|
18
|
+
class AccountLendingPool {
|
|
19
|
+
constructor(account, lendingPool) {
|
|
20
|
+
this.account = account;
|
|
21
|
+
this.lendingPool = lendingPool;
|
|
22
|
+
this.accountPoolTokens = {};
|
|
23
|
+
this.accountPoolTokens[types_1.PoolTokenType.Collateral] = new AccountCollateral_1.default(this, types_1.PoolTokenType.Collateral);
|
|
24
|
+
this.accountPoolTokens[types_1.PoolTokenType.BorrowableA] = new AccountBorrowable_1.default(this, types_1.PoolTokenType.BorrowableA);
|
|
25
|
+
this.accountPoolTokens[types_1.PoolTokenType.BorrowableB] = new AccountBorrowable_1.default(this, types_1.PoolTokenType.BorrowableB);
|
|
26
|
+
}
|
|
27
|
+
getAccountPoolToken(poolTokenType) {
|
|
28
|
+
return this.accountPoolTokens[poolTokenType];
|
|
29
|
+
}
|
|
30
|
+
getUserData() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const userData = yield this.account.getUserData();
|
|
33
|
+
if (!userData)
|
|
34
|
+
return null;
|
|
35
|
+
return userData[this.lendingPool.factory];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/*async getCollateralPosition() : Promise<CollateralPosition> {
|
|
39
|
+
const userData = await this.getUserData();
|
|
40
|
+
if(!userData) return null;
|
|
41
|
+
return userData.collateralPositions[this.lendingPool.pairAddress];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async getCollateralAmount() : Promise<number> {
|
|
45
|
+
const collateralPosition = await this.getCollateralPosition();
|
|
46
|
+
if(!collateralPosition) return 0;
|
|
47
|
+
const exchangeRate = await this.lendingPool.poolTokens[PoolTokenType.Collateral].getExchangeRate();
|
|
48
|
+
const collateralBalance = parseFloat(collateralPosition.balance);
|
|
49
|
+
return collateralBalance * exchangeRate;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async getCollateralValue() : Promise<number> {
|
|
53
|
+
const tokenPrice = await this.lendingPool.poolTokens[PoolTokenType.Collateral].getTokenPriceAccurate();
|
|
54
|
+
const collateralAmount = await this.getCollateralAmount();
|
|
55
|
+
return collateralAmount * tokenPrice;
|
|
56
|
+
}*/
|
|
57
|
+
getBorrowerEquityValue() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const collateralValue = yield this.accountPoolTokens[types_1.PoolTokenType.Collateral].getValue();
|
|
60
|
+
const borrowedValueA = yield this.accountPoolTokens[types_1.PoolTokenType.BorrowableA].getBorrowedValue();
|
|
61
|
+
const borrowedValueB = yield this.accountPoolTokens[types_1.PoolTokenType.BorrowableB].getBorrowedValue();
|
|
62
|
+
return collateralValue - borrowedValueA - borrowedValueB;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = AccountLendingPool;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Account from './Account';
|
|
2
|
+
import LendingVault from './LendingVault';
|
|
3
|
+
import AccountPoolToken from './AccountPoolToken';
|
|
4
|
+
export default class AccountLendingVault extends AccountPoolToken {
|
|
5
|
+
account: Account;
|
|
6
|
+
poolToken: LendingVault;
|
|
7
|
+
constructor(account: Account, lendingVault: LendingVault);
|
|
8
|
+
getAmount(): Promise<number>;
|
|
9
|
+
getEarnings(): Promise<number>;
|
|
10
|
+
getEarningsUSD(): Promise<number>;
|
|
11
|
+
}
|