impermax-sdk 2.1.71 → 2.1.73

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.
Files changed (61) hide show
  1. package/lib/offchain/account/lendingPool/index.d.ts +4 -4
  2. package/lib/offchain/account/lendingPool/nftlp/index.d.ts +0 -0
  3. package/lib/offchain/account/lendingPool/nftlp/index.js +0 -0
  4. package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlp.d.ts +10 -0
  5. package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlp.js +14 -0
  6. package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlpUniswapV3.d.ts +4 -0
  7. package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlpUniswapV3.js +13 -0
  8. package/lib/offchain/account/lendingPool/offchainAccountBorrowable.d.ts +8 -8
  9. package/lib/offchain/account/lendingPool/offchainAccountBorrowable.js +4 -4
  10. package/lib/offchain/account/lendingPool/offchainAccountBorrowableV2.d.ts +10 -0
  11. package/lib/offchain/account/lendingPool/offchainAccountBorrowableV2.js +16 -0
  12. package/lib/offchain/account/lendingPool/offchainAccountBorrowableV3.d.ts +10 -0
  13. package/lib/offchain/account/lendingPool/offchainAccountBorrowableV3.js +16 -0
  14. package/lib/offchain/account/lendingPool/offchainAccountCollateral.d.ts +4 -9
  15. package/lib/offchain/account/lendingPool/offchainAccountCollateral.js +4 -11
  16. package/lib/offchain/account/lendingPool/offchainAccountCollateralV2.d.ts +12 -0
  17. package/lib/offchain/account/lendingPool/offchainAccountCollateralV2.js +29 -0
  18. package/lib/offchain/account/lendingPool/offchainAccountCollateralV3.d.ts +18 -0
  19. package/lib/offchain/account/lendingPool/offchainAccountCollateralV3.js +45 -0
  20. package/lib/offchain/account/lendingPool/offchainAccountLendingPool.d.ts +20 -12
  21. package/lib/offchain/account/lendingPool/offchainAccountLendingPool.js +19 -19
  22. package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV2.d.ts +38 -0
  23. package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV2.js +85 -0
  24. package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV3.d.ts +39 -0
  25. package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV3.js +79 -0
  26. package/lib/offchain/account/offchainAccount.js +1 -2
  27. package/lib/offchain/lendingPool/nftlp/index.d.ts +3 -0
  28. package/lib/offchain/lendingPool/nftlp/index.js +9 -0
  29. package/lib/offchain/lendingPool/nftlp/offchainNftlp.d.ts +20 -0
  30. package/lib/offchain/lendingPool/nftlp/offchainNftlp.js +40 -0
  31. package/lib/offchain/lendingPool/nftlp/offchainNftlpUniswapV3.d.ts +20 -0
  32. package/lib/offchain/lendingPool/nftlp/offchainNftlpUniswapV3.js +73 -0
  33. package/lib/offchain/lendingPool/offchainBorrowable.d.ts +5 -5
  34. package/lib/offchain/lendingPool/offchainBorrowable.js +6 -6
  35. package/lib/offchain/lendingPool/offchainBorrowableV2.d.ts +8 -0
  36. package/lib/offchain/lendingPool/offchainBorrowableV2.js +14 -0
  37. package/lib/offchain/lendingPool/offchainBorrowableV3.d.ts +8 -0
  38. package/lib/offchain/lendingPool/offchainBorrowableV3.js +14 -0
  39. package/lib/offchain/lendingPool/offchainCollateral.d.ts +13 -18
  40. package/lib/offchain/lendingPool/offchainCollateral.js +1 -77
  41. package/lib/offchain/lendingPool/offchainCollateralV2.d.ts +21 -0
  42. package/lib/offchain/lendingPool/offchainCollateralV2.js +86 -0
  43. package/lib/offchain/lendingPool/offchainCollateralV3.d.ts +21 -0
  44. package/lib/offchain/lendingPool/offchainCollateralV3.js +79 -0
  45. package/lib/offchain/lendingPool/offchainLendingPool.d.ts +25 -5
  46. package/lib/offchain/lendingPool/offchainLendingPool.js +55 -18
  47. package/lib/offchain/lendingPool/offchainLendingPoolV2.d.ts +17 -0
  48. package/lib/offchain/lendingPool/offchainLendingPoolV2.js +22 -0
  49. package/lib/offchain/lendingPool/offchainLendingPoolV3.d.ts +21 -0
  50. package/lib/offchain/lendingPool/offchainLendingPoolV3.js +31 -0
  51. package/lib/offchain/offchainEndpointManager.js +2 -0
  52. package/lib/offchain/offchainInitializer.js +9 -5
  53. package/lib/offchain/offchainPriceHelper.js +4 -2
  54. package/lib/offchain/queries/apis/ponder/index.js +0 -20
  55. package/lib/offchain/vault/offchainHedgedVault.d.ts +2 -2
  56. package/lib/offchain/vault/offchainHedgedVault.js +2 -2
  57. package/lib/offchain/vault/offchainLeveragedVault.d.ts +2 -2
  58. package/lib/offchain/vault/offchainLeveragedVault.js +2 -2
  59. package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.d.ts +3 -3
  60. package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.d.ts +3 -3
  61. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import OffchainAccountCollateral from './offchainAccountCollateral';
2
- import OffchainAccountBorrowable from './offchainAccountBorrowable';
3
- import OffchainAccountLendingPool from './offchainAccountLendingPool';
4
- import OffchainLeveragedPosition from './offchainLeveragedPosition';
1
+ import OffchainAccountCollateral from "./offchainAccountCollateral";
2
+ import OffchainAccountBorrowable from "./offchainAccountBorrowable";
3
+ import OffchainAccountLendingPool from "./offchainAccountLendingPool";
4
+ import OffchainLeveragedPosition from "./offchainLeveragedPosition";
5
5
  export { OffchainAccountBorrowable, OffchainAccountCollateral, OffchainLeveragedPosition, };
6
6
  export default OffchainAccountLendingPool;
@@ -0,0 +1,10 @@
1
+ import OffchainAccountLendingPoolV3 from "../offchainAccountLendingPoolV3";
2
+ import OffchainAccountCollateralV3 from "../offchainAccountCollateralV3";
3
+ export default class OffchainAccountNftlp {
4
+ protected readonly collateral: OffchainAccountCollateralV3;
5
+ protected cache: {};
6
+ constructor(collateral: OffchainAccountCollateralV3);
7
+ getLendingPool: () => OffchainAccountLendingPoolV3;
8
+ getNftlp: () => OffchainAccountNftlp;
9
+ cleanCache(): void;
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class OffchainAccountNftlp {
4
+ constructor(collateral) {
5
+ this.cache = {};
6
+ this.getLendingPool = () => this.collateral.getLendingPool();
7
+ this.getNftlp = () => this.collateral.getNftlp();
8
+ this.collateral = collateral;
9
+ }
10
+ cleanCache() {
11
+ this.cache = {};
12
+ }
13
+ }
14
+ exports.default = OffchainAccountNftlp;
@@ -0,0 +1,4 @@
1
+ import OffchainAccountNftlp from "./offchainAccountNftlp";
2
+ export default class OnchainAccountNftlpUniswapV3 extends OffchainAccountNftlp {
3
+ protected cache: {};
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const offchainAccountNftlp_1 = __importDefault(require("./offchainAccountNftlp"));
7
+ class OnchainAccountNftlpUniswapV3 extends offchainAccountNftlp_1.default {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.cache = {};
11
+ }
12
+ }
13
+ exports.default = OnchainAccountNftlpUniswapV3;
@@ -1,12 +1,12 @@
1
- import { PoolTokenType } from '../../../config/types';
2
- import OffchainAccountLendingPool from './index';
3
- import OffchainAccountPoolToken from '../offchainAccountPoolToken';
4
- import OffchainBorrowable from '../../lendingPool/offchainBorrowable';
5
- export default class OffchainAccountBorrowable extends OffchainAccountPoolToken {
6
- private readonly lendingPool;
7
- private readonly poolTokenType;
1
+ import { Borrowable } from "../../../config/types";
2
+ import OffchainAccountLendingPool from "./index";
3
+ import OffchainAccountPoolToken from "../offchainAccountPoolToken";
4
+ import OffchainBorrowable from "../../lendingPool/offchainBorrowable";
5
+ export default abstract class OffchainAccountBorrowable extends OffchainAccountPoolToken {
6
+ protected readonly lendingPool: OffchainAccountLendingPool;
7
+ protected readonly borrowable: Borrowable;
8
8
  protected readonly poolToken: OffchainBorrowable;
9
- constructor(lendingPool: OffchainAccountLendingPool, poolTokenType: PoolTokenType);
9
+ constructor(lendingPool: OffchainAccountLendingPool, borrowable: Borrowable);
10
10
  getLendingPool: () => OffchainAccountLendingPool;
11
11
  getPoolToken: () => OffchainBorrowable;
12
12
  private getSupplyPosition;
@@ -14,20 +14,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const offchainAccountPoolToken_1 = __importDefault(require("../offchainAccountPoolToken"));
16
16
  class OffchainAccountBorrowable extends offchainAccountPoolToken_1.default {
17
- constructor(lendingPool, poolTokenType) {
17
+ constructor(lendingPool, borrowable) {
18
18
  super();
19
19
  this.getLendingPool = () => this.lendingPool;
20
20
  this.getPoolToken = () => this.poolToken;
21
21
  this.lendingPool = lendingPool;
22
- this.poolTokenType = poolTokenType;
23
- this.poolToken = lendingPool.getLendingPool().getPoolToken(poolTokenType);
22
+ this.borrowable = borrowable;
23
+ this.poolToken = this.lendingPool.getLendingPool().getBorrowable(borrowable);
24
24
  }
25
25
  getSupplyPosition() {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
27
  const lendingPoolPosition = yield this.lendingPool.getLendingPoolPosition();
28
28
  if (!lendingPoolPosition)
29
29
  return undefined;
30
- return lendingPoolPosition[this.poolTokenType];
30
+ return lendingPoolPosition[`borrowable${this.borrowable}`];
31
31
  });
32
32
  }
33
33
  // TODO update to support real time exchange rate
@@ -0,0 +1,10 @@
1
+ import { Borrowable } from "../../../config/types";
2
+ import OffchainAccountLendingPool from "./index";
3
+ import OffchainAccountBorrowable from "./offchainAccountBorrowable";
4
+ export default class OffchainAccountBorrowableV2 extends OffchainAccountBorrowable {
5
+ protected readonly lendingPool: OffchainAccountLendingPool;
6
+ protected readonly borrowable: Borrowable;
7
+ constructor(lendingPool: OffchainAccountLendingPool, borrowable: Borrowable);
8
+ getLendingPool: () => OffchainAccountLendingPool;
9
+ getPoolToken: () => import("../../lendingPool").OffchainBorrowable;
10
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const offchainAccountBorrowable_1 = __importDefault(require("./offchainAccountBorrowable"));
7
+ class OffchainAccountBorrowableV2 extends offchainAccountBorrowable_1.default {
8
+ constructor(lendingPool, borrowable) {
9
+ super(lendingPool, borrowable);
10
+ this.getLendingPool = () => this.lendingPool;
11
+ this.getPoolToken = () => this.poolToken;
12
+ this.lendingPool = lendingPool;
13
+ this.borrowable = borrowable;
14
+ }
15
+ }
16
+ exports.default = OffchainAccountBorrowableV2;
@@ -0,0 +1,10 @@
1
+ import { Borrowable } from "../../../config/types";
2
+ import OffchainAccountLendingPool from "./index";
3
+ import OffchainAccountBorrowable from "./offchainAccountBorrowable";
4
+ export default class OffchainAccountBorrowableV3 extends OffchainAccountBorrowable {
5
+ protected readonly lendingPool: OffchainAccountLendingPool;
6
+ protected readonly borrowable: Borrowable;
7
+ constructor(lendingPool: OffchainAccountLendingPool, borrowable: Borrowable);
8
+ getLendingPool: () => OffchainAccountLendingPool;
9
+ getPoolToken: () => import("../../lendingPool").OffchainBorrowable;
10
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const offchainAccountBorrowable_1 = __importDefault(require("./offchainAccountBorrowable"));
7
+ class OffchainAccountBorrowableV3 extends offchainAccountBorrowable_1.default {
8
+ constructor(lendingPool, borrowable) {
9
+ super(lendingPool, borrowable);
10
+ this.getLendingPool = () => this.lendingPool;
11
+ this.getPoolToken = () => this.poolToken;
12
+ this.lendingPool = lendingPool;
13
+ this.borrowable = borrowable;
14
+ }
15
+ }
16
+ exports.default = OffchainAccountBorrowableV3;
@@ -1,11 +1,6 @@
1
- import OffchainAccountLendingPool from './index';
2
- import OffchainAccountPoolToken from '../offchainAccountPoolToken';
3
- import { OffchainCollateral } from '../../lendingPool';
4
- export default class OffchainAccountCollateral extends OffchainAccountPoolToken {
5
- private readonly lendingPool;
6
- protected readonly poolToken: OffchainCollateral;
7
- constructor(lendingPool: OffchainAccountLendingPool);
8
- getLendingPool: () => OffchainAccountLendingPool;
9
- getPoolToken: () => OffchainCollateral;
1
+ import OffchainAccountLendingPool from "./index";
2
+ export default abstract class OffchainAccountCollateral {
3
+ abstract getLendingPool(): OffchainAccountLendingPool;
4
+ getAccount: () => import("..").default;
10
5
  getAmount(): Promise<number>;
11
6
  }
@@ -8,18 +8,11 @@ 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
- const offchainAccountPoolToken_1 = __importDefault(require("../offchainAccountPoolToken"));
16
- class OffchainAccountCollateral extends offchainAccountPoolToken_1.default {
17
- constructor(lendingPool) {
18
- super();
19
- this.getLendingPool = () => this.lendingPool;
20
- this.getPoolToken = () => this.poolToken;
21
- this.lendingPool = lendingPool;
22
- this.poolToken = lendingPool.getLendingPool().getCollateral();
12
+ class OffchainAccountCollateral {
13
+ constructor() {
14
+ //public abstract cleanCache();
15
+ this.getAccount = () => this.getLendingPool().getAccount();
23
16
  }
24
17
  getAmount() {
25
18
  return __awaiter(this, void 0, void 0, function* () {
@@ -0,0 +1,12 @@
1
+ import OffchainAccountCollateral from "./offchainAccountCollateral";
2
+ import OffchainAccountLendingPoolV2 from "./offchainAccountLendingPoolV2";
3
+ import OffchainAccountPoolToken from "../offchainAccountPoolToken";
4
+ import OffchainCollateralV2 from "../../lendingPool/offchainCollateralV2";
5
+ export default class OffchainAccountCollateralV2 extends OffchainAccountPoolToken implements OffchainAccountCollateral {
6
+ protected readonly lendingPool: OffchainAccountLendingPoolV2;
7
+ protected readonly poolToken: OffchainCollateralV2;
8
+ constructor(lendingPool: OffchainAccountLendingPoolV2);
9
+ getAccount: () => import("..").default;
10
+ getLendingPool: () => OffchainAccountLendingPoolV2;
11
+ getAmount(): Promise<number>;
12
+ }
@@ -0,0 +1,29 @@
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 offchainAccountPoolToken_1 = __importDefault(require("../offchainAccountPoolToken"));
16
+ class OffchainAccountCollateralV2 extends offchainAccountPoolToken_1.default {
17
+ constructor(lendingPool) {
18
+ super();
19
+ this.getAccount = () => this.getLendingPool().getAccount();
20
+ this.getLendingPool = () => this.lendingPool;
21
+ this.lendingPool = lendingPool;
22
+ }
23
+ getAmount() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return 10;
26
+ });
27
+ }
28
+ }
29
+ exports.default = OffchainAccountCollateralV2;
@@ -0,0 +1,18 @@
1
+ import OffchainAccountLendingPoolV3 from "./offchainAccountLendingPoolV3";
2
+ import OffchainCollateralV3 from "../../lendingPool/offchainCollateralV3";
3
+ import OffchainAccountCollateral from "./offchainAccountCollateral";
4
+ import OffchainAccountNftlp from "./nftlp/offchainAccountNftlp";
5
+ export default class OffchainAccountCollateralV3 extends OffchainAccountCollateral {
6
+ protected readonly lendingPool: OffchainAccountLendingPoolV3;
7
+ protected readonly collateral: OffchainCollateralV3;
8
+ protected readonly nftlp: OffchainAccountNftlp;
9
+ protected collateralCache: {};
10
+ constructor(lendingPool: OffchainAccountLendingPoolV3);
11
+ getLendingPool: () => OffchainAccountLendingPoolV3;
12
+ getCollateral: () => OffchainCollateralV3;
13
+ getNftlp: () => OffchainAccountNftlp;
14
+ getAccount: () => import("..").default;
15
+ cleanCache(): void;
16
+ getDepositedUSD(tokenId: number): Promise<number>;
17
+ getAmount(): Promise<number>;
18
+ }
@@ -0,0 +1,45 @@
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 offchainAccountCollateral_1 = __importDefault(require("./offchainAccountCollateral"));
16
+ class OffchainAccountCollateralV3 extends offchainAccountCollateral_1.default {
17
+ constructor(lendingPool) {
18
+ super();
19
+ this.collateralCache = {};
20
+ this.getLendingPool = () => this.lendingPool;
21
+ this.getCollateral = () => this.collateral;
22
+ this.getNftlp = () => this.nftlp;
23
+ this.getAccount = () => this.lendingPool.getAccount();
24
+ this.lendingPool = lendingPool;
25
+ this.collateral = lendingPool.getLendingPool().getCollateral();
26
+ this.nftlp = lendingPool
27
+ .getLendingPool()
28
+ .getNftlp()
29
+ .getNewAccountNftlpObject(this);
30
+ }
31
+ cleanCache() {
32
+ this.collateralCache = {};
33
+ }
34
+ getDepositedUSD(tokenId) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return 0;
37
+ });
38
+ }
39
+ getAmount() {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ return 10;
42
+ });
43
+ }
44
+ }
45
+ exports.default = OffchainAccountCollateralV3;
@@ -1,23 +1,31 @@
1
- import OffchainAccount from '../index';
2
- import { Borrowable, PoolTokenType } from '../../../config/types';
3
- import OffchainAccountCollateral from './offchainAccountCollateral';
4
- import OffchainAccountBorrowable from './offchainAccountBorrowable';
5
- import OffchainAccountPoolToken from '../offchainAccountPoolToken';
6
- import { SupplyPosition } from '../../offchainTypes';
7
- import OffchainLendingPool from '../../lendingPool';
1
+ import OffchainAccount from "../index";
2
+ import { Borrowable, PoolTokenType } from "../../../config/types";
3
+ import OffchainAccountCollateral from "./offchainAccountCollateral";
4
+ import OffchainAccountBorrowable from "./offchainAccountBorrowable";
5
+ import { SupplyPosition } from "../../offchainTypes";
6
+ import OffchainLendingPool from "../../lendingPool";
8
7
  import OffchainLeveragedPosition from "./offchainLeveragedPosition";
9
- export default class OffchainAccountLendingPool {
10
- private readonly account;
11
- private readonly lendingPool;
12
- private readonly poolTokens;
8
+ export default abstract class OffchainAccountLendingPool {
9
+ protected readonly account: OffchainAccount;
10
+ protected readonly lendingPool: OffchainLendingPool;
11
+ protected readonly collateral: OffchainAccountCollateral;
12
+ protected readonly borrowables: {
13
+ [Borrowable.A]: OffchainAccountBorrowable;
14
+ [Borrowable.B]: OffchainAccountBorrowable;
15
+ };
16
+ protected abstract getNewCollateralObject(): OffchainAccountCollateral;
17
+ protected abstract getNewBorrowableObject(borrowable: Borrowable): OffchainAccountBorrowable;
13
18
  constructor(account: OffchainAccount, lendingPool: OffchainLendingPool);
14
19
  getAccount: () => OffchainAccount;
15
20
  getLendingPool: () => OffchainLendingPool;
16
- getPoolToken(poolTokenType: PoolTokenType): OffchainAccountPoolToken;
17
21
  getBorrowable: (borrowable: Borrowable) => OffchainAccountBorrowable;
18
22
  getBorrowableA: () => OffchainAccountBorrowable;
19
23
  getBorrowableB: () => OffchainAccountBorrowable;
20
24
  getCollateral: () => OffchainAccountCollateral;
25
+ protected getFactory: () => import("../../../config/types").Factory;
26
+ protected getId: () => any;
27
+ getSafetyMargin: () => Promise<number>;
28
+ getLiquidationPenalty: () => Promise<number>;
21
29
  getLendingPoolPosition(): Promise<{
22
30
  [PoolTokenType.BorrowableA]?: SupplyPosition;
23
31
  [PoolTokenType.BorrowableB]?: SupplyPosition;
@@ -8,33 +8,29 @@ 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
12
  const types_1 = require("../../../config/types");
16
- const offchainAccountCollateral_1 = __importDefault(require("./offchainAccountCollateral"));
17
- const offchainAccountBorrowable_1 = __importDefault(require("./offchainAccountBorrowable"));
18
13
  class OffchainAccountLendingPool {
19
14
  constructor(account, lendingPool) {
15
+ // Shortcuts
20
16
  this.getAccount = () => this.account;
21
17
  this.getLendingPool = () => this.lendingPool;
22
- this.getBorrowable = (borrowable) => borrowable == types_1.Borrowable.A ? this.getBorrowableA() : this.getBorrowableB();
23
- // Shortcuts
24
- this.getBorrowableA = () => this.poolTokens[types_1.PoolTokenType.BorrowableA];
25
- this.getBorrowableB = () => this.poolTokens[types_1.PoolTokenType.BorrowableB];
26
- this.getCollateral = () => this.poolTokens[types_1.PoolTokenType.Collateral];
18
+ this.getBorrowable = (borrowable) => this.borrowables[borrowable];
19
+ this.getBorrowableA = () => this.getBorrowable(types_1.Borrowable.A);
20
+ this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
21
+ this.getCollateral = () => this.collateral;
22
+ this.getFactory = () => this.lendingPool.getFactory();
23
+ this.getId = () => this.getId();
24
+ this.getSafetyMargin = () => __awaiter(this, void 0, void 0, function* () { return yield this.lendingPool.getSafetyMargin(); });
25
+ this.getLiquidationPenalty = () => __awaiter(this, void 0, void 0, function* () { return yield this.lendingPool.getLiquidationPenalty(); });
27
26
  this.account = account;
28
27
  this.lendingPool = lendingPool;
29
- this.poolTokens = {
30
- [types_1.PoolTokenType.Collateral]: new offchainAccountCollateral_1.default(this),
31
- [types_1.PoolTokenType.BorrowableA]: new offchainAccountBorrowable_1.default(this, types_1.PoolTokenType.BorrowableA),
32
- [types_1.PoolTokenType.BorrowableB]: new offchainAccountBorrowable_1.default(this, types_1.PoolTokenType.BorrowableB),
28
+ this.collateral = this.getNewCollateralObject();
29
+ this.borrowables = {
30
+ [types_1.Borrowable.A]: this.getNewBorrowableObject(types_1.Borrowable.A),
31
+ [types_1.Borrowable.B]: this.getNewBorrowableObject(types_1.Borrowable.B),
33
32
  };
34
33
  }
35
- getPoolToken(poolTokenType) {
36
- return this.poolTokens[poolTokenType];
37
- }
38
34
  getLendingPoolPosition() {
39
35
  return __awaiter(this, void 0, void 0, function* () {
40
36
  // TODO rename and refactor
@@ -47,8 +43,12 @@ class OffchainAccountLendingPool {
47
43
  const pairAddress = this.lendingPool.getPairAddress();
48
44
  const supplyPositions = userDataOfFactory.supplyPositions[pairAddress];
49
45
  return {
50
- [types_1.PoolTokenType.BorrowableA]: supplyPositions ? supplyPositions[types_1.PoolTokenType.BorrowableA] : undefined,
51
- [types_1.PoolTokenType.BorrowableB]: supplyPositions ? supplyPositions[types_1.PoolTokenType.BorrowableB] : undefined,
46
+ [types_1.PoolTokenType.BorrowableA]: supplyPositions
47
+ ? supplyPositions[types_1.PoolTokenType.BorrowableA]
48
+ : undefined,
49
+ [types_1.PoolTokenType.BorrowableB]: supplyPositions
50
+ ? supplyPositions[types_1.PoolTokenType.BorrowableB]
51
+ : undefined,
52
52
  };
53
53
  });
54
54
  }
@@ -0,0 +1,38 @@
1
+ import OffchainAccount from "../index";
2
+ import { Borrowable, PoolTokenType } from "../../../config/types";
3
+ import { SupplyPosition } from "../../offchainTypes";
4
+ import OffchainLendingPool from "../../lendingPool";
5
+ import OffchainLeveragedPosition from "./offchainLeveragedPosition";
6
+ import OffchainAccountLendingPool from "./offchainAccountLendingPool";
7
+ import OffchainAccountCollateralV2 from "./offchainAccountCollateralV2";
8
+ import OffchainAccountBorrowableV2 from "./offchainAccountBorrowableV2";
9
+ import OffchainLendingPoolV2 from "../../lendingPool/offchainLendingPool";
10
+ export default class OffchainAccountLendingPoolV2 extends OffchainAccountLendingPool {
11
+ protected readonly account: OffchainAccount;
12
+ protected readonly lendingPool: OffchainLendingPoolV2;
13
+ protected readonly collateral: OffchainAccountCollateralV2;
14
+ protected readonly borrowables: {
15
+ [Borrowable.A]: OffchainAccountBorrowableV2;
16
+ [Borrowable.B]: OffchainAccountBorrowableV2;
17
+ };
18
+ protected getNewCollateralObject(): OffchainAccountCollateralV2;
19
+ protected getNewBorrowableObject(borrowable: Borrowable): OffchainAccountBorrowableV2;
20
+ getLendingPool: () => OffchainLendingPool;
21
+ getBorrowable: (borrowable: Borrowable) => OffchainAccountBorrowableV2;
22
+ getBorrowableA: () => OffchainAccountBorrowableV2;
23
+ getBorrowableB: () => OffchainAccountBorrowableV2;
24
+ getCollateral: () => OffchainAccountCollateralV2;
25
+ constructor(account: OffchainAccount, lendingPool: OffchainLendingPool);
26
+ getAccount: () => OffchainAccount;
27
+ protected getFactory: () => import("../../../config/types").Factory;
28
+ protected getId: () => any;
29
+ getSafetyMargin: () => Promise<number>;
30
+ getLiquidationPenalty: () => Promise<number>;
31
+ getLendingPoolPosition(): Promise<{
32
+ [PoolTokenType.BorrowableA]?: SupplyPosition;
33
+ [PoolTokenType.BorrowableB]?: SupplyPosition;
34
+ } | undefined>;
35
+ getLeveragedPositions(): Promise<Array<OffchainLeveragedPosition>>;
36
+ getLeveragedPositionsTotalBalanceUSD(): Promise<number>;
37
+ getLeveragedPositionsNetAPR(): Promise<number>;
38
+ }
@@ -0,0 +1,85 @@
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 offchainAccountLendingPool_1 = __importDefault(require("./offchainAccountLendingPool"));
17
+ const offchainAccountCollateralV2_1 = __importDefault(require("./offchainAccountCollateralV2"));
18
+ const offchainAccountBorrowableV2_1 = __importDefault(require("./offchainAccountBorrowableV2"));
19
+ class OffchainAccountLendingPoolV2 extends offchainAccountLendingPool_1.default {
20
+ getNewCollateralObject() {
21
+ return new offchainAccountCollateralV2_1.default(this);
22
+ }
23
+ getNewBorrowableObject(borrowable) {
24
+ return new offchainAccountBorrowableV2_1.default(this, borrowable);
25
+ }
26
+ constructor(account, lendingPool) {
27
+ super(account, lendingPool);
28
+ // Shortcuts
29
+ this.getLendingPool = () => this.lendingPool;
30
+ this.getBorrowable = (borrowable) => this.borrowables[borrowable];
31
+ this.getBorrowableA = () => this.getBorrowable(types_1.Borrowable.A);
32
+ this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
33
+ this.getCollateral = () => this.collateral;
34
+ // Shortcuts
35
+ this.getAccount = () => this.account;
36
+ this.getFactory = () => this.lendingPool.getFactory();
37
+ this.getId = () => this.getId();
38
+ this.getSafetyMargin = () => __awaiter(this, void 0, void 0, function* () { return yield this.lendingPool.getSafetyMargin(); });
39
+ this.getLiquidationPenalty = () => __awaiter(this, void 0, void 0, function* () { return yield this.lendingPool.getLiquidationPenalty(); });
40
+ this.account = account;
41
+ this.lendingPool = lendingPool;
42
+ this.collateral = this.getNewCollateralObject();
43
+ this.borrowables = {
44
+ [types_1.Borrowable.A]: this.getNewBorrowableObject(types_1.Borrowable.A),
45
+ [types_1.Borrowable.B]: this.getNewBorrowableObject(types_1.Borrowable.B),
46
+ };
47
+ }
48
+ getLendingPoolPosition() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ // TODO rename and refactor
51
+ const userData = yield this.account.getUserData();
52
+ if (!userData)
53
+ return undefined;
54
+ const userDataOfFactory = userData[this.lendingPool.getFactory()];
55
+ if (!userDataOfFactory)
56
+ return undefined;
57
+ const pairAddress = this.lendingPool.getPairAddress();
58
+ const supplyPositions = userDataOfFactory.supplyPositions[pairAddress];
59
+ return {
60
+ [types_1.PoolTokenType.BorrowableA]: supplyPositions
61
+ ? supplyPositions[types_1.PoolTokenType.BorrowableA]
62
+ : undefined,
63
+ [types_1.PoolTokenType.BorrowableB]: supplyPositions
64
+ ? supplyPositions[types_1.PoolTokenType.BorrowableB]
65
+ : undefined,
66
+ };
67
+ });
68
+ }
69
+ getLeveragedPositions() {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ return [];
72
+ });
73
+ }
74
+ getLeveragedPositionsTotalBalanceUSD() {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ return 1;
77
+ });
78
+ }
79
+ getLeveragedPositionsNetAPR() {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ return 1;
82
+ });
83
+ }
84
+ }
85
+ exports.default = OffchainAccountLendingPoolV2;
@@ -0,0 +1,39 @@
1
+ import OffchainAccount from "../index";
2
+ import { Borrowable, PoolTokenType } from "../../../config/types";
3
+ import { SupplyPosition } from "../../offchainTypes";
4
+ import OffchainLendingPool from "../../lendingPool";
5
+ import OffchainLeveragedPosition from "./offchainLeveragedPosition";
6
+ import OffchainAccountLendingPool from "./offchainAccountLendingPool";
7
+ import OffchainLendingPoolV3 from "../../lendingPool/offchainLendingPoolV3";
8
+ import OffchainAccountCollateralV3 from "./offchainAccountCollateralV3";
9
+ import OffchainAccountBorrowableV3 from "./offchainAccountBorrowableV3";
10
+ export default class OffchainAccountLendingPoolV3 extends OffchainAccountLendingPool {
11
+ protected readonly account: OffchainAccount;
12
+ protected readonly lendingPool: OffchainLendingPoolV3;
13
+ protected readonly collateral: OffchainAccountCollateralV3;
14
+ protected readonly borrowables: {
15
+ [Borrowable.A]: OffchainAccountBorrowableV3;
16
+ [Borrowable.B]: OffchainAccountBorrowableV3;
17
+ };
18
+ protected getNewCollateralObject(): OffchainAccountCollateralV3;
19
+ protected getNewBorrowableObject(borrowable: Borrowable): OffchainAccountBorrowableV3;
20
+ getLendingPool: () => OffchainLendingPoolV3;
21
+ getBorrowable: (borrowable: Borrowable) => OffchainAccountBorrowableV3;
22
+ getBorrowableA: () => OffchainAccountBorrowableV3;
23
+ getBorrowableB: () => OffchainAccountBorrowableV3;
24
+ getCollateral: () => OffchainAccountCollateralV3;
25
+ constructor(account: OffchainAccount, lendingPool: OffchainLendingPool);
26
+ getAccount: () => OffchainAccount;
27
+ protected getFactory: () => import("../../../config/types").Factory;
28
+ protected getId: () => any;
29
+ getSafetyMargin: () => Promise<number>;
30
+ getLiquidationPenalty: () => Promise<number>;
31
+ getNftlp: () => import("./nftlp/offchainAccountNftlp").default;
32
+ getLendingPoolPosition(): Promise<{
33
+ [PoolTokenType.BorrowableA]?: SupplyPosition;
34
+ [PoolTokenType.BorrowableB]?: SupplyPosition;
35
+ } | undefined>;
36
+ getLeveragedPositions(): Promise<Array<OffchainLeveragedPosition>>;
37
+ getLeveragedPositionsTotalBalanceUSD(): Promise<number>;
38
+ getLeveragedPositionsNetAPR(): Promise<number>;
39
+ }