@sonarwatch/portfolio-plugins 0.14.15 → 0.14.17

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # @sonarwatch/portfolio-plugins
2
-
3
- This library is @sonarwatch/portfolio-plugins
1
+ # @sonarwatch/portfolio-plugins
2
+
3
+ This library is @sonarwatch/portfolio-plugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonarwatch/portfolio-plugins",
3
- "version": "0.14.15",
3
+ "version": "0.14.17",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "peerDependencies": {
@@ -4,9 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchers = exports.jobs = exports.services = exports.platforms = void 0;
7
- const portfolio_core_1 = require("@sonarwatch/portfolio-core");
8
7
  // import lendingPoolsJob from './lendingPoolsJob';
9
- const getLendingFetcherExecutor_1 = __importDefault(require("./getLendingFetcherExecutor"));
10
8
  const stakingFetcher_1 = __importDefault(require("./stakingFetcher"));
11
9
  const constants_1 = require("./constants");
12
10
  const services_1 = require("./services");
@@ -16,21 +14,27 @@ exports.jobs = [
16
14
  // lendingPoolsJob,
17
15
  ];
18
16
  exports.fetchers = [
19
- {
20
- id: `${constants_1.platformId}-${portfolio_core_1.NetworkId.ethereum}-lending`,
21
- networkId: portfolio_core_1.NetworkId.ethereum,
22
- executor: (0, getLendingFetcherExecutor_1.default)(portfolio_core_1.NetworkId.ethereum),
23
- },
24
- {
25
- id: `${constants_1.platformId}-${portfolio_core_1.NetworkId.polygon}-lending`,
26
- networkId: portfolio_core_1.NetworkId.polygon,
27
- executor: (0, getLendingFetcherExecutor_1.default)(portfolio_core_1.NetworkId.polygon),
28
- },
29
- {
30
- id: `${constants_1.platformId}-${portfolio_core_1.NetworkId.avalanche}-lending`,
31
- networkId: portfolio_core_1.NetworkId.avalanche,
32
- executor: (0, getLendingFetcherExecutor_1.default)(portfolio_core_1.NetworkId.avalanche),
33
- },
17
+ // WARNING !!!!
18
+ // These fetchers use an old version of web3 wich cause process to exit
19
+ // WARNING !!!!
20
+ // {
21
+ // id: `${platformId}-${NetworkId.ethereum}-lending`,
22
+ // networkId: NetworkId.ethereum,
23
+ // executor: getLendingFetcherExecutor(NetworkId.ethereum),
24
+ // },
25
+ // {
26
+ // id: `${platformId}-${NetworkId.polygon}-lending`,
27
+ // networkId: NetworkId.polygon,
28
+ // executor: getLendingFetcherExecutor(NetworkId.polygon),
29
+ // },
30
+ // {
31
+ // id: `${platformId}-${NetworkId.avalanche}-lending`,
32
+ // networkId: NetworkId.avalanche,
33
+ // executor: getLendingFetcherExecutor(NetworkId.avalanche),
34
+ // },
35
+ // WARNING !!!!
36
+ // These fetchers use an old version of web3 wich cause process to exit
37
+ // WARNING !!!!
34
38
  stakingFetcher_1.default,
35
39
  ];
36
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aave/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA0E;AAG1E,mDAAmD;AACnD,4FAAoE;AACpE,sEAA8C;AAC9C,2CAAmD;AACnD,yCAAkD;AAErC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,QAAQ,GAAc,CAAC,oBAAS,EAAE,oBAAS,CAAC,CAAC;AAC7C,QAAA,IAAI,GAAU;AACzB,mBAAmB;CACpB,CAAC;AACW,QAAA,QAAQ,GAAc;IACjC;QACE,EAAE,EAAE,GAAG,sBAAU,IAAI,0BAAS,CAAC,QAAQ,UAAU;QACjD,SAAS,EAAE,0BAAS,CAAC,QAAQ;QAC7B,QAAQ,EAAE,IAAA,mCAAyB,EAAC,0BAAS,CAAC,QAAQ,CAAC;KACxD;IACD;QACE,EAAE,EAAE,GAAG,sBAAU,IAAI,0BAAS,CAAC,OAAO,UAAU;QAChD,SAAS,EAAE,0BAAS,CAAC,OAAO;QAC5B,QAAQ,EAAE,IAAA,mCAAyB,EAAC,0BAAS,CAAC,OAAO,CAAC;KACvD;IACD;QACE,EAAE,EAAE,GAAG,sBAAU,IAAI,0BAAS,CAAC,SAAS,UAAU;QAClD,SAAS,EAAE,0BAAS,CAAC,SAAS;QAC9B,QAAQ,EAAE,IAAA,mCAAyB,EAAC,0BAAS,CAAC,SAAS,CAAC;KACzD;IACD,wBAAc;CACf,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aave/index.ts"],"names":[],"mappings":";;;;;;AAGA,mDAAmD;AACnD,sEAA8C;AAC9C,2CAAuC;AACvC,yCAAkD;AAErC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,QAAQ,GAAc,CAAC,oBAAS,EAAE,oBAAS,CAAC,CAAC;AAC7C,QAAA,IAAI,GAAU;AACzB,mBAAmB;CACpB,CAAC;AACW,QAAA,QAAQ,GAAc;IACjC,eAAe;IACf,uEAAuE;IACvE,eAAe;IACf,IAAI;IACJ,uDAAuD;IACvD,mCAAmC;IACnC,6DAA6D;IAC7D,KAAK;IACL,IAAI;IACJ,sDAAsD;IACtD,kCAAkC;IAClC,4DAA4D;IAC5D,KAAK;IACL,IAAI;IACJ,wDAAwD;IACxD,oCAAoC;IACpC,8DAA8D;IAC9D,KAAK;IACL,eAAe;IACf,uEAAuE;IACvE,eAAe;IACf,wBAAc;CACf,CAAC"}
@@ -36,27 +36,27 @@ exports.getBalancerPoolsV2 = void 0;
36
36
  const graphql_request_1 = __importStar(require("graphql-request"));
37
37
  function getBalancerPoolsV2(url) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- const query = (0, graphql_request_1.gql) `
40
- query pools {
41
- pools(
42
- first: 1000
43
- orderBy: totalLiquidity
44
- orderDirection: desc
45
- where: { totalLiquidity_gt: "500" }
46
- ) {
47
- id
48
- address
49
- symbol
50
- totalLiquidity
51
- totalShares
52
- tokens {
53
- balance
54
- decimals
55
- symbol
56
- address
57
- }
58
- }
59
- }
39
+ const query = (0, graphql_request_1.gql) `
40
+ query pools {
41
+ pools(
42
+ first: 1000
43
+ orderBy: totalLiquidity
44
+ orderDirection: desc
45
+ where: { totalLiquidity_gt: "500" }
46
+ ) {
47
+ id
48
+ address
49
+ symbol
50
+ totalLiquidity
51
+ totalShares
52
+ tokens {
53
+ balance
54
+ decimals
55
+ symbol
56
+ address
57
+ }
58
+ }
59
+ }
60
60
  `;
61
61
  const res = yield (0, graphql_request_1.default)(url, query);
62
62
  const pools = res.pools;
@@ -22,19 +22,39 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
22
22
  if (vestingEscrowAccounts.length === 0)
23
23
  return [];
24
24
  const registry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
25
- const element = registry.addElementMultiple({
26
- label: 'Vesting',
27
- name: 'lock',
28
- });
29
25
  for (const lock of vestingEscrowAccounts) {
30
- const endTime = lock.vestingStartTime.plus(lock.numberOfPeriod.times(lock.frequency));
31
- element.addAsset({
32
- address: lock.tokenMint,
33
- amount: lock.amountPerPeriod
34
- .times(lock.numberOfPeriod)
35
- .minus(lock.totalClaimedAmount),
36
- attributes: { lockedUntil: endTime.toNumber() },
26
+ const element = registry.addElementMultiple({
27
+ label: 'Vesting',
28
+ name: 'Lock',
37
29
  });
30
+ const endTime = lock.cliffTime
31
+ .plus(lock.numberOfPeriod.times(lock.frequency))
32
+ .times(1000);
33
+ if (lock.totalClaimedAmount.isZero()) {
34
+ // Unlock at cliff time
35
+ element.addAsset({
36
+ address: lock.tokenMint,
37
+ amount: lock.cliffUnlockAmount,
38
+ attributes: { lockedUntil: lock.cliffTime.times(1000).toNumber() },
39
+ });
40
+ // Remaining vesting with end date
41
+ element.addAsset({
42
+ address: lock.tokenMint,
43
+ amount: lock.amountPerPeriod.times(lock.numberOfPeriod),
44
+ attributes: { lockedUntil: endTime.toNumber() },
45
+ });
46
+ }
47
+ else {
48
+ // Remaining vesting with end date, minus already claimed
49
+ element.addAsset({
50
+ address: lock.tokenMint,
51
+ amount: lock.amountPerPeriod
52
+ .times(lock.numberOfPeriod)
53
+ .plus(lock.cliffUnlockAmount)
54
+ .minus(lock.totalClaimedAmount),
55
+ attributes: { lockedUntil: endTime.toNumber() },
56
+ });
57
+ }
38
58
  }
39
59
  return registry.getElements(cache);
40
60
  });
@@ -1 +1 @@
1
- {"version":3,"file":"lockFetcher.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/lockFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAwD;AACxD,oDAAyD;AACzD,kDAAiE;AACjE,uCAAgD;AAChD,uCAAwC;AACxC,mFAAgF;AAEhF,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,qBAAqB,GAAG,MAAM,IAAA,iCAAwB,EAC1D,MAAM,EACN,6BAAmB,EACnB,yBAAa,EACb,IAAA,qBAAW,EAAC,KAAK,CAAC,CACnB,CAAC;IACF,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAElD,MAAM,QAAQ,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,MAAM,EAAE,sBAAU,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,QAAQ,CAAC,kBAAkB,CAAC;QAC1C,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,MAAM;KACb,CAAC,CAAC;IAEH,KAAK,MAAM,IAAI,IAAI,qBAAqB,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CACxC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAC1C,CAAC;QAEF,OAAO,CAAC,QAAQ,CAAC;YACf,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,eAAe;iBACzB,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC;iBAC1B,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;YACjC,UAAU,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,OAAO;IACxB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"lockFetcher.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/lockFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAwD;AACxD,oDAAyD;AACzD,kDAAiE;AACjE,uCAAgD;AAChD,uCAAwC;AACxC,mFAAgF;AAEhF,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,qBAAqB,GAAG,MAAM,IAAA,iCAAwB,EAC1D,MAAM,EACN,6BAAmB,EACnB,yBAAa,EACb,IAAA,qBAAW,EAAC,KAAK,CAAC,CACnB,CAAC;IACF,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAElD,MAAM,QAAQ,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,MAAM,EAAE,sBAAU,CAAC,CAAC;IAEnE,KAAK,MAAM,IAAI,IAAI,qBAAqB,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,kB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CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,OAAO;IACxB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -17,21 +17,22 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
17
  const constants_1 = require("./constants");
18
18
  const clients_1 = require("../../utils/clients");
19
19
  const abis_1 = require("./abis");
20
- const getDSA_1 = require("../../utils/evm/getDSA");
21
20
  const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
22
21
  const constants_2 = require("../../utils/misc/constants");
23
22
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
24
23
  // Get the user's proxy address
25
24
  const client = (0, clients_1.getEvmClient)(portfolio_core_1.NetworkId.ethereum);
26
- const instadappDSA = (0, getDSA_1.getDSA)(portfolio_core_1.NetworkId.ethereum);
27
- const instadappAccounts = yield instadappDSA.getAccounts(owner);
25
+ // WARNING: intadapp removed because it use an old version of web3 that cause process.exit
26
+ // const instadappDSA = getDSA(NetworkId.ethereum);
27
+ // const instadappAccounts = await instadappDSA.getAccounts(owner);
28
28
  const ownerProxyRes = yield client.readContract({
29
29
  abi: abis_1.proxyRegAbi,
30
30
  address: constants_1.proxyRegAddress,
31
31
  functionName: 'proxies',
32
32
  args: [owner],
33
33
  });
34
- const proxyAddresses = [owner, ...instadappAccounts.map((a) => a.address)];
34
+ // const proxyAddresses = [owner, ...instadappAccounts.map((a) => a.address)];
35
+ const proxyAddresses = [owner];
35
36
  if (ownerProxyRes !== portfolio_core_1.zeroAddressEvm)
36
37
  proxyAddresses.push(ownerProxyRes);
37
38
  if (proxyAddresses.length === 0)
@@ -1 +1 @@
1
- {"version":3,"file":"vaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/maker/vaultsFetcher.ts"],"names":[],"mappings":";;;;;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AAK;YACL,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,WAAW;gBACX,YAAY;gBACZ,WAAW;gBACX,KAAK;aACN;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,SAAS,EAAE,0BAAS,CAAC,QAAQ;IAC7B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"vaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/maker/vaultsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAErC,2CAQqB;AAErB,iDAAmD;AACnD,iCAA4D;AAE5D,qGAA6E;AAC7E,0DAAwD;AAExD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,+BAA+B;IAC/B,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,0BAAS,CAAC,QAAQ,CAAC,CAAC;IAEhD,0FAA0F;IAC1F,mDAAmD;IACnD,mEAAmE;IAEnE,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;QAC9C,GAAG,EAAE,kBAAW;QAChB,OAAO,EAAE,2BAAe;QACxB,YAAY,EAAE,SAAS;QACvB,IAAI,EAAE,CAAC,KAAsB,CAAC;KAC/B,CAAC,CAAC;IAEH,8EAA8E;IAC9E,MAAM,cAAc,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,aAAa,KAAK,+BAAc;QAAE,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE3C,MAAM,IAAI,GAAa,EAAE,CAA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EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,GACrE,IAAA,wCAAuB,EAAC,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;QAC5E,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,SAAS,EAAE,0BAAS,CAAC,QAAQ;YAC7B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,SAAS;YAChB,KAAK;YACL,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,WAAW;gBACX,YAAY;gBACZ,WAAW;gBACX,KAAK;aACN;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,SAAS,EAAE,0BAAS,CAAC,QAAQ;IAC7B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -46,22 +46,27 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
46
46
  if (!borrowBalance.error && ((_a = borrowBalance.data) === null || _a === void 0 ? void 0 : _a.content)) {
47
47
  const borrowInfo = (_b = borrowBalance.data.content) === null || _b === void 0 ? void 0 : _b.fields;
48
48
  if (borrowInfo.value) {
49
- element.addBorrowedAsset({
50
- address: rData.value.fields.coin_type,
51
- amount: new bignumber_js_1.default(borrowInfo.value)
52
- .times(rData.value.fields.current_borrow_index)
53
- .dividedBy(amountFactor),
54
- alreadyShifted: true,
55
- });
56
- const apy = new bignumber_js_1.default(rData.value.fields.current_borrow_rate)
57
- .dividedBy(Math.pow(10, constants_1.rateFactor))
58
- .toNumber();
59
- element.addBorrowedYield([
60
- {
61
- apr: -(0, portfolio_core_1.apyToApr)(apy),
62
- apy: -apy,
63
- },
64
- ]);
49
+ const amount = new bignumber_js_1.default(borrowInfo.value)
50
+ .times(rData.value.fields.current_borrow_index)
51
+ .dividedBy(amountFactor);
52
+ if (amount.isGreaterThan(0.002)) {
53
+ element.addBorrowedAsset({
54
+ address: rData.value.fields.coin_type,
55
+ amount: new bignumber_js_1.default(borrowInfo.value)
56
+ .times(rData.value.fields.current_borrow_index)
57
+ .dividedBy(amountFactor),
58
+ alreadyShifted: true,
59
+ });
60
+ const apy = new bignumber_js_1.default(rData.value.fields.current_borrow_rate)
61
+ .dividedBy(Math.pow(10, constants_1.rateFactor))
62
+ .toNumber();
63
+ element.addBorrowedYield([
64
+ {
65
+ apr: -(0, portfolio_core_1.apyToApr)(apy),
66
+ apy: -apy,
67
+ },
68
+ ]);
69
+ }
65
70
  }
66
71
  }
67
72
  if (!supplyBalance.error && ((_d = (_c = supplyBalance.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields)) {
@@ -70,32 +75,36 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
70
75
  const amount = new bignumber_js_1.default(supplyInfo.value)
71
76
  .times(rData.value.fields.current_supply_index)
72
77
  .dividedBy(amountFactor);
73
- element.addSuppliedAsset({
74
- address: rData.value.fields.coin_type,
75
- amount,
76
- alreadyShifted: true,
77
- });
78
- const apy = new bignumber_js_1.default(rData.value.fields.current_supply_rate)
79
- .dividedBy(Math.pow(10, constants_1.rateFactor))
80
- .toNumber();
81
- element.addSuppliedYield([
82
- {
83
- apr: (0, portfolio_core_1.apyToApr)(apy),
84
- apy,
85
- },
86
- ]);
87
- element.addSuppliedLtv(new bignumber_js_1.default(rData.value.fields.liquidation_factors.fields.threshold)
88
- .div(Math.pow(10, 27))
89
- .toNumber());
78
+ if (amount.isGreaterThan(0.002)) {
79
+ element.addSuppliedAsset({
80
+ address: rData.value.fields.coin_type,
81
+ amount,
82
+ alreadyShifted: true,
83
+ });
84
+ const apy = new bignumber_js_1.default(rData.value.fields.current_supply_rate)
85
+ .dividedBy(Math.pow(10, constants_1.rateFactor))
86
+ .toNumber();
87
+ element.addSuppliedYield([
88
+ {
89
+ apr: (0, portfolio_core_1.apyToApr)(apy),
90
+ apy,
91
+ },
92
+ ]);
93
+ element.addSuppliedLtv(new bignumber_js_1.default(rData.value.fields.liquidation_factors.fields.threshold)
94
+ .div(Math.pow(10, 27))
95
+ .toNumber());
96
+ }
90
97
  }
91
98
  }
92
99
  }
93
100
  if (rewards.size > 0) {
94
101
  rewards.forEach((amount, coinType) => {
95
- element.addRewardAsset({
96
- address: coinType,
97
- amount,
98
- });
102
+ if (amount > 0.002) {
103
+ element.addRewardAsset({
104
+ address: coinType,
105
+ amount,
106
+ });
107
+ }
99
108
  });
100
109
  }
101
110
  return elementRegistry.getElements(cache);
@@ -1 +1 @@
1
- {"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAiE;AACjE,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AAEnD,iFAA8E;AAC9E,+DAA4D;AAC5D,gFAA6E;AAE7E,MAAM,YAAY,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC,CAAC;AAE7C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CAAgB,uBAAW,EAAE;QACnE,MAAM,EAAE,0BAAc;QACtB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IACH,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,CAAC;IAE7B,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,yCAAmB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAE1E,MAAM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BACE,GAAG,EAAE,IAAA,yBAAQ,EAAC,GAAG,CAAC;wBAClB,GAAG;qBACJ;iBACF,CAAC,CAAC;gBACH,OAAO,CAAC,cAAc,CACpB,IAAI,sBAAS,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC;qBACnE,GAAG,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC;qBACb,QAAQ,EAAE,CACd,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;YACnC,OAAO,CAAC,cAAc,CAAC;gBACrB,OAAO,EAAE,QAAQ;gBACjB,MAAM;aACP,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,aAAa;IAC9B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAiE;AACjE,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AAEnD,iFAA8E;AAC9E,+DAA4D;AAC5D,gFAA6E;AAE7E,MAAM,YAAY,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC,CAAC;AAE7C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MA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AC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,aAAa;IAC9B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -99,100 +99,55 @@ function getOrcaNftFetcher(platformId, programId) {
99
99
  const tags = [];
100
100
  if (tokenAmountA.isZero() || tokenAmountB.isZero())
101
101
  tags.push('Out Of Range');
102
- /* const feesAndRewards = calcFeesAndRewards(
103
- whirlpoolInfo,
104
- positionInfo,
105
- tickArrays
106
- );
107
-
102
+ const feesAndRewards = (0, helpers_fees_1.calcFeesAndRewards)(whirlpoolInfo, positionInfo, tickArrays);
108
103
  if (feesAndRewards) {
109
- if (feesAndRewards.feeOwedA.isGreaterThan(0)) {
110
- rewardAssets.push(
111
- tokenPriceToAssetToken(
112
- tokenPriceA.address,
113
- feesAndRewards.feeOwedA
114
- .dividedBy(10 ** tokenPriceA.decimals)
115
- .toNumber(),
116
- NetworkId.solana,
117
- tokenPriceA
118
- )
119
- );
120
- }
121
-
122
- if (feesAndRewards.feeOwedB.isGreaterThan(0)) {
123
- rewardAssets.push(
124
- tokenPriceToAssetToken(
125
- tokenPriceB.address,
126
- feesAndRewards.feeOwedB
127
- .dividedBy(10 ** tokenPriceB.decimals)
128
- .toNumber(),
129
- NetworkId.solana,
130
- tokenPriceB
131
- )
132
- );
133
- }
134
-
135
- if (feesAndRewards.rewardOwedA.isGreaterThan(0)) {
136
- const tokenPriceRewardA = tokenPrices.get(
137
- whirlpoolInfo.rewardInfos[0].mint.toString()
138
- );
139
- if (tokenPriceRewardA) {
140
- rewardAssets.push(
141
- tokenPriceToAssetToken(
142
- tokenPriceRewardA.address,
143
- feesAndRewards.rewardOwedA
144
- .dividedBy(10 ** tokenPriceRewardA.decimals)
145
- .toNumber(),
146
- NetworkId.solana,
147
- tokenPriceRewardA
148
- )
149
- );
104
+ if (feesAndRewards.feeOwedA.isGreaterThan(0)) {
105
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, feesAndRewards.feeOwedA
106
+ .dividedBy(Math.pow(10, tokenPriceA.decimals))
107
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA));
150
108
  }
151
- }
152
-
153
- if (feesAndRewards.rewardOwedB.isGreaterThan(0)) {
154
- const tokenPriceRewardB = tokenPrices.get(
155
- whirlpoolInfo.rewardInfos[1].mint.toString()
156
- );
157
- if (tokenPriceRewardB) {
158
- rewardAssets.push(
159
- tokenPriceToAssetToken(
160
- tokenPriceRewardB.address,
161
- feesAndRewards.rewardOwedB
162
- .dividedBy(10 ** tokenPriceRewardB.decimals)
163
- .toNumber(),
164
- NetworkId.solana,
165
- tokenPriceRewardB
166
- )
167
- );
109
+ if (feesAndRewards.feeOwedB.isGreaterThan(0)) {
110
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, feesAndRewards.feeOwedB
111
+ .dividedBy(Math.pow(10, tokenPriceB.decimals))
112
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB));
168
113
  }
169
- }
170
-
171
- if (feesAndRewards.rewardOwedC.isGreaterThan(0)) {
172
- const tokenPriceRewardC = tokenPrices.get(
173
- whirlpoolInfo.rewardInfos[2].mint.toString()
174
- );
175
- if (tokenPriceRewardC) {
176
- rewardAssets.push(
177
- tokenPriceToAssetToken(
178
- tokenPriceRewardC.address,
179
- feesAndRewards.rewardOwedC
180
- .dividedBy(10 ** tokenPriceRewardC.decimals)
181
- .toNumber(),
182
- NetworkId.solana,
183
- tokenPriceRewardC
184
- )
185
- );
114
+ if (feesAndRewards.rewardOwedA.isGreaterThan(0)) {
115
+ const tokenPriceRewardA = tokenPrices.get(whirlpoolInfo.rewardInfos[0].mint.toString());
116
+ if (tokenPriceRewardA) {
117
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardA.address, feesAndRewards.rewardOwedA
118
+ .dividedBy(Math.pow(10, tokenPriceRewardA.decimals))
119
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardA));
120
+ }
186
121
  }
187
- }
188
- } */
122
+ if (feesAndRewards.rewardOwedB.isGreaterThan(0)) {
123
+ const tokenPriceRewardB = tokenPrices.get(whirlpoolInfo.rewardInfos[1].mint.toString());
124
+ if (tokenPriceRewardB) {
125
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardB.address, feesAndRewards.rewardOwedB
126
+ .dividedBy(Math.pow(10, tokenPriceRewardB.decimals))
127
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardB));
128
+ }
129
+ }
130
+ if (feesAndRewards.rewardOwedC.isGreaterThan(0)) {
131
+ const tokenPriceRewardC = tokenPrices.get(whirlpoolInfo.rewardInfos[2].mint.toString());
132
+ if (tokenPriceRewardC) {
133
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardC.address, feesAndRewards.rewardOwedC
134
+ .dividedBy(Math.pow(10, tokenPriceRewardC.decimals))
135
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardC));
136
+ }
137
+ }
138
+ }
189
139
  if (!assetTokenA ||
190
140
  !assetTokenB ||
191
141
  assetTokenA.value === null ||
192
142
  assetTokenB.value === null)
193
143
  continue;
144
+ const assets = !tokenAmountA.isZero() && !tokenAmountB.isZero()
145
+ ? [assetTokenA, assetTokenB]
146
+ : [];
194
147
  const value = assetTokenA.value + assetTokenB.value;
195
148
  const rewardAssetsValue = (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((a) => a.value));
149
+ if (assets.length === 0 && rewardAssets.length === 0)
150
+ continue;
196
151
  elements.push({
197
152
  type: portfolio_core_1.PortfolioElementType.liquidity,
198
153
  networkId: portfolio_core_1.NetworkId.solana,
@@ -203,7 +158,7 @@ function getOrcaNftFetcher(platformId, programId) {
203
158
  data: {
204
159
  liquidities: [
205
160
  {
206
- assets: [assetTokenA, assetTokenB],
161
+ assets,
207
162
  assetsValue: value,
208
163
  rewardAssets,
209
164
  rewardAssetsValue,
@@ -1 +1 @@
1
- {"version":3,"file":"getWhirlpoolPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/orca/getWhirlpoolPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,6CAA4C;AAC5C,2CAIqB;AACrB,iDAAsD;AACtD,+CAG4B;AAE5B,mDAAgE;AAChE,qGAA6E;AAC7E,wFAAyF;AAEzF,iDAIwB;AAEX,QAAA,qBAAqB,GAAG,iBAAiB,CACpD,sBAAc,EACd,4BAAgB,CACjB,CAAC;AAEF,SAAgB,iBAAiB,CAC/B,UAAkB,EAClB,SAAoB;IAEpB,OAAO,CACL,KAAY,EACZ,IAAiC,EACJ,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;QACjC,MAAM,uBAAuB,GAAgB,EAAE,CAAC;QAEhD,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,MAAM,OAAO,GAAG,IAAI,mBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEhD,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEnE,MAAM,CAAC,cAAc,CAAC,GAAG,mBAAS,CAAC,sBAAsB,CACvD,YAAY,EACZ,SAAS,CACV,CAAC;YACF,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAEpD,MAAM,aAAa,GAAG,MAAM,IAAA,sCAA6B,E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AAC,CAAC;YAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAsFI;YAEJ,IACE,CAAC,WAAW;gBACZ,CAAC,WAAW;gBACZ,WAAW,CAAC,KAAK,KAAK,IAAI;gBAC1B,WAAW,CAAC,KAAK,KAAK,IAAI;gBAE1B,SAAS;YAEX,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;YACpD,MAAM,iBAAiB,GAAG,IAAA,+BAAc,EACtC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CACjC,CAAC;YAEF,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU;gBACV,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,KAAK,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC;gBACvC,IAAI,EAAE;oBACJ,WAAW,EAAE;wBACX;4BACE,MAAM,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC;4BAClC,WAAW,EAAE,KAAK;4BAClB,YAAY;4BACZ,iBAAiB;4BACjB,KAAK,EAAE,KAAK,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC;4BACvC,MAAM,EAAE,EAAE;yBACX;qBACF;iBACF;gBACD,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAA,CAAC;AACJ,CAAC;AArPD,8CAqPC"}
1
+ {"version":3,"file":"getWhirlpoolPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/orca/getWhirlpoolPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,6CAA4C;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CAAC,CACjC,CAAC;YAEF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YAE/D,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU;gBACV,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,KAAK,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC;gBACvC,IAAI,EAAE;oBACJ,WAAW,EAAE;wBACX;4BACE,MAAM;4BACN,WAAW,EAAE,KAAK;4BAClB,YAAY;4BACZ,iBAAiB;4BACjB,KAAK,EAAE,KAAK,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC;4BACvC,MAAM,EAAE,EAAE;yBACX;qBACF;iBACF;gBACD,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAA,CAAC;AACJ,CAAC;AA5PD,8CA4PC"}
@@ -1,6 +1,6 @@
1
+ import BigNumber from 'bignumber.js';
1
2
  import { Position, Tick, TickArray, Whirlpool, WhirlpoolRewardInfo } from './structs/whirlpool';
2
3
  import { ParsedAccount } from '../../utils/solana';
3
- import BigNumber from 'bignumber.js';
4
4
  export declare const getTickArraysAsMap: (positionsInfo: (ParsedAccount<Position> | null)[], whirlpoolMap: Map<string, Whirlpool>) => Promise<Map<string, TickArray>>;
5
5
  export declare const calcFeesAndRewards: (whirlpool: Whirlpool, position: ParsedAccount<Position>, tickArrays: Map<string, TickArray>) => {
6
6
  feeOwedA: BigNumber;
@@ -13,14 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getCollectRewardsQuoteInternal = exports.isRewardInitialized = exports.calcFeesAndRewards = exports.getTickArraysAsMap = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const bn_js_1 = __importDefault(require("bn.js"));
18
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
16
19
  const whirlpool_1 = require("./structs/whirlpool");
17
20
  const solana_1 = require("../../utils/solana");
18
21
  const constants_1 = require("./constants");
19
22
  const clients_1 = require("../../utils/clients");
20
- const web3_js_1 = require("@solana/web3.js");
21
- const bn_js_1 = __importDefault(require("bn.js"));
22
23
  const toBN_1 = require("../../utils/misc/toBN");
23
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
24
24
  const TWO = new bn_js_1.default(2);
25
25
  const U128 = TWO.pow(new bn_js_1.default(128));
26
26
  const TICK_ARRAY_SIZE = 88;
@@ -67,8 +67,8 @@ const calcFeesAndRewards = (whirlpool, position, tickArrays) => {
67
67
  const fees = getCollectFeesQuoteInternal({
68
68
  whirlpool,
69
69
  position,
70
- tickUpper,
71
70
  tickLower,
71
+ tickUpper,
72
72
  });
73
73
  return Object.assign(Object.assign({}, rewards), fees);
74
74
  };
@@ -140,8 +140,12 @@ function getCollectFeesQuoteInternal(param) {
140
140
  const updatedFeeOwedA = feeOwedA.plus(feeOwedADelta.toString());
141
141
  const updatedFeeOwedB = feeOwedB.plus(feeOwedBDelta.toString());
142
142
  return {
143
- feeOwedA: updatedFeeOwedA,
144
- feeOwedB: updatedFeeOwedB,
143
+ feeOwedA: updatedFeeOwedA.isGreaterThan(Math.pow(10, 18))
144
+ ? (0, bignumber_js_1.default)(0)
145
+ : updatedFeeOwedA,
146
+ feeOwedB: updatedFeeOwedB.isGreaterThan(Math.pow(10, 18))
147
+ ? (0, bignumber_js_1.default)(0)
148
+ : updatedFeeOwedB,
145
149
  };
146
150
  }
147
151
  function getTick(tickArray, tickIndex, tickSpacing) {
@@ -180,7 +184,7 @@ function getCollectRewardsQuoteInternal(param) {
180
184
  for (const i of range) {
181
185
  const rewardInfo = whirlpoolRewardsInfos[i];
182
186
  invariant(!!rewardInfo, 'whirlpoolRewardsInfos cannot be undefined');
183
- const growthGlobalX64 = rewardInfo.growthGlobalX64;
187
+ const { growthGlobalX64 } = rewardInfo;
184
188
  const lowerRewardGrowthsOutside = tickLowerRewardGrowthsOutside[i];
185
189
  const upperRewardGrowthsOutside = tickUpperRewardGrowthsOutside[i];
186
190
  invariant(!!lowerRewardGrowthsOutside, 'lowerRewardGrowthsOutside cannot be undefined');
@@ -220,8 +224,8 @@ function getCollectRewardsQuoteInternal(param) {
220
224
  for (const i of range) {
221
225
  const growthInsideX64 = rewardGrowthsInsideX64[i];
222
226
  invariant(!!growthInsideX64, 'growthInsideX64 cannot be undefined');
223
- const [rewardGrowthInsideX64, isRewardInitialized] = growthInsideX64;
224
- if (isRewardInitialized) {
227
+ const [rewardGrowthInsideX64, isRewardAlreadyInitialized] = growthInsideX64;
228
+ if (isRewardAlreadyInitialized) {
225
229
  const rewardInfo = rewardInfos[i];
226
230
  invariant(!!rewardInfo, 'rewardInfo cannot be undefined');
227
231
  const amountOwedX64 = (0, toBN_1.toBN)(rewardInfo.amountOwed).shln(64);