impermax-sdk 2.1.4 → 2.1.6

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 (31) hide show
  1. package/lib/config/subgraphs.d.ts +2 -2
  2. package/lib/config/subgraphs.js +40 -23
  3. package/lib/config/types.d.ts +10 -0
  4. package/lib/config/types.js +7 -1
  5. package/lib/index.d.ts +4 -2
  6. package/lib/index.js +10 -2
  7. package/lib/offchain/account/offchainAccount.d.ts +6 -6
  8. package/lib/offchain/account/offchainAccount.js +33 -24
  9. package/lib/offchain/account/vault/offchainAccountVault.js +10 -3
  10. package/lib/offchain/index.d.ts +2 -1
  11. package/lib/offchain/index.js +3 -1
  12. package/lib/offchain/offchain.d.ts +13 -10
  13. package/lib/offchain/offchain.js +18 -11
  14. package/lib/offchain/offchainInitializer.d.ts +11 -11
  15. package/lib/offchain/offchainInitializer.js +151 -89
  16. package/lib/offchain/offchainMultichain.d.ts +8 -3
  17. package/lib/offchain/offchainMultichain.js +40 -4
  18. package/lib/offchain/offchainTypes.d.ts +9 -1
  19. package/lib/offchain/queries/apis/ponder/index.d.ts +3 -3
  20. package/lib/offchain/queries/apis/ponder/index.js +4 -2
  21. package/lib/offchain/queries/apis/thegraph/index.d.ts +3 -3
  22. package/lib/offchain/queries/apis/thegraph/index.js +4 -2
  23. package/lib/offchain/queries/interfaces/query-builder.d.ts +3 -3
  24. package/lib/offchain/vault/offchainHedgedVault.js +2 -25
  25. package/lib/offchain/vault/offchainLendingVault.js +6 -25
  26. package/lib/offchain/vault/offchainLeveragedVault.js +2 -25
  27. package/lib/offchain/vault/offchainVault.d.ts +16 -5
  28. package/lib/offchain/vault/offchainVault.js +18 -8
  29. package/lib/onchain/account/onchainAccountLendingVault.js +1 -1
  30. package/lib/onchain/onchainLendingVault.js +1 -1
  31. package/package.json +1 -1
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TheGraphQueryBuilder = void 0;
7
7
  const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
8
  const factories_1 = require("../../../../config/factories");
9
+ // TODO: Might need to separate Vaults query based on vault type, maybe not.
9
10
  class TheGraphQueryBuilder {
10
11
  /*-----------------------------*
11
12
  * 1. API Health
@@ -184,7 +185,8 @@ class TheGraphQueryBuilder {
184
185
  /*-----------------------------*
185
186
  * Lending vaults
186
187
  *-----------------------------*/
187
- lendingVaultsQuery(addressesFilter) {
188
+ vaultsQuery(vaultType, addressesFilter) {
189
+ // do something here for difference kind of vault type, currently only lending
188
190
  const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
189
191
  return (0, graphql_tag_1.default) `{
190
192
  lendingVaults(first: 1000 ${id_in_string}) {
@@ -211,7 +213,7 @@ class TheGraphQueryBuilder {
211
213
  }
212
214
  }`;
213
215
  }
214
- lendingVaultsUserQuery(account) {
216
+ vaultsUserQuery(account) {
215
217
  return (0, graphql_tag_1.default) `{
216
218
  user(id: "${account.toLowerCase()}") {
217
219
  positions(first:1000) {
@@ -1,13 +1,13 @@
1
1
  import { DocumentNode } from 'graphql';
2
- import { Address, Factory, Networks } from '../../../config/types';
2
+ import { Address, Factory, Networks, VaultType } from '../../../config/types';
3
3
  export interface IQueryBuilder {
4
4
  blockQuery(timestamp: number): DocumentNode;
5
5
  getBlockNumber: (response: any, network: Networks) => number;
6
6
  lendingPoolsQuery(factory: Factory, addressesFilter: Address[], network: Networks): DocumentNode;
7
7
  userQuery(account: Address, network: Networks, factory: Factory): DocumentNode;
8
8
  tvlQuery(): DocumentNode;
9
- lendingVaultsQuery(addressesFilter: Address[]): DocumentNode;
10
- lendingVaultsUserQuery(account: Address): DocumentNode;
9
+ vaultsQuery(vaultType: VaultType, addressesFilter: Address[]): DocumentNode;
10
+ vaultsUserQuery(account: Address): DocumentNode;
11
11
  proposalsMetaQuery(rangeBegin: number, rangeLength: number, descending: boolean): DocumentNode;
12
12
  proposalQuery(id: number): DocumentNode;
13
13
  ximxQuery(): DocumentNode;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,12 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
13
  };
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
15
  const types_1 = require("../../config/types");
39
- const offchainVault_1 = __importStar(require("./offchainVault"));
16
+ const offchainVault_1 = __importDefault(require("./offchainVault"));
40
17
  const lendingPool_1 = __importDefault(require("../lendingPool"));
41
18
  class OffchainHedgedVaultVault extends offchainVault_1.default {
42
19
  constructor(offchain, vaultAddress) {
43
20
  super(offchain, vaultAddress);
44
- this.vaultType = offchainVault_1.VaultType.HEDGED;
21
+ this.vaultType = types_1.VaultType.HEDGED;
45
22
  }
46
23
  getLeverage() {
47
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,9 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
9
  });
33
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
34
14
  Object.defineProperty(exports, "__esModule", { value: true });
35
15
  exports.RiskLevel = void 0;
36
- const offchainVault_1 = __importStar(require("./offchainVault"));
16
+ const types_1 = require("../../config/types");
17
+ const offchainVault_1 = __importDefault(require("./offchainVault"));
37
18
  var RiskLevel;
38
19
  (function (RiskLevel) {
39
20
  RiskLevel[RiskLevel["LOW"] = 0] = "LOW";
@@ -43,7 +24,7 @@ var RiskLevel;
43
24
  class OffchainLendingVault extends offchainVault_1.default {
44
25
  constructor(offchain, vaultAddress) {
45
26
  super(offchain, vaultAddress);
46
- this.vaultType = offchainVault_1.VaultType.LENDING;
27
+ this.vaultType = types_1.VaultType.LENDING;
47
28
  }
48
29
  getRiskLevel() {
49
30
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,12 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
13
  };
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
15
  const types_1 = require("../../config/types");
39
- const offchainVault_1 = __importStar(require("./offchainVault"));
16
+ const offchainVault_1 = __importDefault(require("./offchainVault"));
40
17
  const lendingPool_1 = __importDefault(require("../lendingPool"));
41
18
  class OffchainLeveragedVault extends offchainVault_1.default {
42
19
  constructor(offchain, vaultAddress) {
43
20
  super(offchain, vaultAddress);
44
- this.vaultType = offchainVault_1.VaultType.LEVERAGED;
21
+ this.vaultType = types_1.VaultType.LEVERAGED;
45
22
  }
46
23
  getLeverage() {
47
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,20 +1,31 @@
1
1
  import Offchain from "../index";
2
- import { Address } from '../../config/types';
2
+ import { Address, VaultType } from '../../config/types';
3
3
  import OffchainPoolToken from '../offchainPoolToken';
4
4
  import { PoolTokenData } from '../offchainTypes';
5
- export declare enum VaultType {
6
- LENDING = 0,
7
- HEDGED = 1,
8
- LEVERAGED = 2
5
+ export declare enum VaultRisk {
6
+ VERY_LOW = "very-low",
7
+ LOW = "low",
8
+ MEDIUM = "medium",
9
+ HIGH = "high",
10
+ VERY_HIGH = "very-high"
11
+ }
12
+ export declare enum VaultStatus {
13
+ DEPRECATED = "Deprecated",
14
+ BLACKLISTED = "Blacklisted",
15
+ ACTIVE = "Active"
9
16
  }
10
17
  export default class OffchainVault extends OffchainPoolToken {
11
18
  private readonly offchain;
12
19
  private readonly vaultAddress;
13
20
  protected vaultType: VaultType;
21
+ protected vaultRisk: VaultRisk;
22
+ protected vaultStatus: VaultStatus;
14
23
  constructor(offchain: Offchain, vaultAddress: Address);
15
24
  getOffchain: () => Offchain;
16
25
  getVaultAddress: () => string;
17
26
  getVaultType: () => VaultType;
27
+ getVaultRisk: () => VaultRisk;
28
+ getVaultStatus: () => VaultStatus;
18
29
  getPoolTokenData(): Promise<PoolTokenData>;
19
30
  private getTotalSupply;
20
31
  private getLastUpdate;
@@ -12,27 +12,37 @@ 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
- exports.VaultType = void 0;
15
+ exports.VaultStatus = exports.VaultRisk = void 0;
16
16
  const offchainPoolToken_1 = __importDefault(require("../offchainPoolToken"));
17
17
  const utils_1 = require("../../utils");
18
- var VaultType;
19
- (function (VaultType) {
20
- VaultType[VaultType["LENDING"] = 0] = "LENDING";
21
- VaultType[VaultType["HEDGED"] = 1] = "HEDGED";
22
- VaultType[VaultType["LEVERAGED"] = 2] = "LEVERAGED";
23
- })(VaultType = exports.VaultType || (exports.VaultType = {}));
18
+ var VaultRisk;
19
+ (function (VaultRisk) {
20
+ VaultRisk["VERY_LOW"] = "very-low";
21
+ VaultRisk["LOW"] = "low";
22
+ VaultRisk["MEDIUM"] = "medium";
23
+ VaultRisk["HIGH"] = "high";
24
+ VaultRisk["VERY_HIGH"] = "very-high";
25
+ })(VaultRisk = exports.VaultRisk || (exports.VaultRisk = {}));
26
+ var VaultStatus;
27
+ (function (VaultStatus) {
28
+ VaultStatus["DEPRECATED"] = "Deprecated";
29
+ VaultStatus["BLACKLISTED"] = "Blacklisted";
30
+ VaultStatus["ACTIVE"] = "Active";
31
+ })(VaultStatus = exports.VaultStatus || (exports.VaultStatus = {}));
24
32
  class OffchainVault extends offchainPoolToken_1.default {
25
33
  constructor(offchain, vaultAddress) {
26
34
  super();
27
35
  this.getOffchain = () => this.offchain;
28
36
  this.getVaultAddress = () => this.vaultAddress;
29
37
  this.getVaultType = () => this.vaultType;
38
+ this.getVaultRisk = () => this.vaultRisk;
39
+ this.getVaultStatus = () => this.vaultStatus;
30
40
  this.offchain = offchain;
31
41
  this.vaultAddress = vaultAddress;
32
42
  }
33
43
  getPoolTokenData() {
34
44
  return __awaiter(this, void 0, void 0, function* () {
35
- return this.offchain.getLendingVaultData(this.vaultAddress);
45
+ return this.offchain.getVaultData(this.vaultAddress);
36
46
  });
37
47
  }
38
48
  getTotalSupply() {
@@ -29,7 +29,7 @@ class OnchainAccountLendingVault extends onchainAccountPoolToken_1.default {
29
29
  }
30
30
  getOffchainAccountPoolToken() {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- return this.account.getOffchainAccount().getLendingVault(this.getVaultAddress());
32
+ return this.account.getOffchainAccount().getVault(this.getVaultAddress());
33
33
  });
34
34
  }
35
35
  cleanCache() {
@@ -36,7 +36,7 @@ class OnchainLendingVault extends onchainPoolToken_1.default {
36
36
  }
37
37
  getOffchainPoolToken() {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- return yield this.onchain.getOffchain().getLendingVault(this.vaultAddress);
39
+ return yield this.onchain.getOffchain().getVault(this.vaultAddress);
40
40
  });
41
41
  }
42
42
  initializePoolToken() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",