@sonarwatch/portfolio-plugins 0.14.14 → 0.14.15

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.14",
3
+ "version": "0.14.15",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "peerDependencies": {
@@ -0,0 +1,4 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { BurnerVault, StakingPosition } from './types';
3
+ import { SuiClient } from '../../utils/clients/types';
4
+ export declare const getHarvestRewards: (client: SuiClient, sender: string, stakedPosition: StakingPosition, stakeCoinType: string, vault: BurnerVault) => Promise<Map<string, BigNumber>>;
@@ -0,0 +1,81 @@
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
+ exports.getHarvestRewards = void 0;
16
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
17
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
+ const transactions_1 = require("@mysten/sui/transactions");
19
+ const getHarvestRewards = (client, sender, stakedPosition, stakeCoinType, vault) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const rewards = new Map();
21
+ const rewardCoinTypes = vault.type_names.filter((coinType, i) => vault.rewards[i] !== '0' && i > 0);
22
+ if (rewardCoinTypes.length === 0)
23
+ return rewards;
24
+ const transactionBlock = new transactions_1.Transaction();
25
+ const harvestedRewardsEventMetadataId = transactionBlock.moveCall({
26
+ target: `0xcd41fbc59af65b7c58fd2590d5e35efbf756d50e6da2bd0413917102be6e1fdf::staked_position::begin_harvest`,
27
+ typeArguments: [stakeCoinType],
28
+ arguments: [transactionBlock.object(vault.id.id)],
29
+ });
30
+ const harvestedCoins = {};
31
+ for (const rewardCoinType of rewardCoinTypes) {
32
+ const harvestedCoin = transactionBlock.moveCall({
33
+ target: `0xcd41fbc59af65b7c58fd2590d5e35efbf756d50e6da2bd0413917102be6e1fdf::staked_position::harvest_rewards`,
34
+ typeArguments: [stakeCoinType, rewardCoinType],
35
+ arguments: [
36
+ transactionBlock.object(stakedPosition.id.id),
37
+ transactionBlock.object(vault.id.id),
38
+ harvestedRewardsEventMetadataId,
39
+ transactionBlock.object(portfolio_core_1.suiClockAddress),
40
+ ],
41
+ });
42
+ if (rewardCoinType in harvestedCoins) {
43
+ harvestedCoins[rewardCoinType].push(harvestedCoin);
44
+ }
45
+ else {
46
+ harvestedCoins[rewardCoinType] = [harvestedCoin];
47
+ }
48
+ }
49
+ transactionBlock.moveCall({
50
+ target: `0xcd41fbc59af65b7c58fd2590d5e35efbf756d50e6da2bd0413917102be6e1fdf::staked_position::end_harvest`,
51
+ typeArguments: [],
52
+ arguments: [harvestedRewardsEventMetadataId],
53
+ });
54
+ for (const [, harvestedCoinIds] of Object.entries(harvestedCoins)) {
55
+ const coinToTransfer = harvestedCoinIds[0];
56
+ if (harvestedCoinIds.length > 1)
57
+ transactionBlock.mergeCoins(coinToTransfer, harvestedCoinIds.slice(1));
58
+ transactionBlock.transferObjects([coinToTransfer], sender);
59
+ }
60
+ const dir = yield client.devInspectTransactionBlock({
61
+ sender,
62
+ transactionBlock,
63
+ });
64
+ const event = dir.events.find((e) => e.type ===
65
+ '0x4f0a1a923dd063757fd37e04a9c2cee8980008e94433c9075c390065f98e9e4b::events::HarvestedRewardsEvent');
66
+ if (!event || !event.parsedJson)
67
+ return rewards;
68
+ const parsedEvent = event;
69
+ if (!parsedEvent.parsedJson)
70
+ return rewards;
71
+ parsedEvent.parsedJson.reward_types.forEach((coinType, i) => {
72
+ if (parsedEvent.parsedJson) {
73
+ const balance = new bignumber_js_1.default(parsedEvent.parsedJson.reward_amounts[i]);
74
+ if (balance.isGreaterThan(0))
75
+ rewards.set(coinType, balance);
76
+ }
77
+ });
78
+ return rewards;
79
+ });
80
+ exports.getHarvestRewards = getHarvestRewards;
81
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aftermath/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAA6D;AAC7D,gEAAqC;AACrC,2DAGkC;AAU3B,MAAM,iBAAiB,GAAG,CAC/B,MAAiB,EACjB,MAAc,EACd,cAA+B,EAC/B,aAAqB,EACrB,KAAkB,EAClB,EAAE;IACF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE7C,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAC7C,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CACnD,CAAC;IACF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAEjD,MAAM,gBAAgB,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE3C,MAAM,+BAA+B,GAAG,gBAAgB,CAAC,QAAQ,CAAC;QAChE,MAAM,EAAE,oGAAoG;QAC5G,aAAa,EA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AC,CAAC,CAAC;QAEzE,gBAAgB,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC;QAClD,MAAM;QACN,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAC3B,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI;QACN,mGAAmG,CACtG,CAAC;IAEF,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,OAAO,CAAC;IAEhD,MAAM,WAAW,GAAG,KAAgC,CAAC;IACrD,IAAI,CAAC,WAAW,CAAC,UAAU;QAAE,OAAO,OAAO,CAAC;IAE5C,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;QAC1D,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,sBAAS,CAAC,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;YACxE,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA,CAAC;AAjFW,QAAA,iBAAiB,qBAiF5B"}
@@ -74,7 +74,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
74
74
  return;
75
75
  }
76
76
  const tokenPrice = tokenPriceById.get(cAddress);
77
- if (!tokenPrice || !poolInfo.coin_decimals)
77
+ if (!poolInfo.coin_decimals)
78
78
  return;
79
79
  poolUnderlyingsRaw.push({
80
80
  address: cAddress,
@@ -1 +1 @@
1
- {"version":3,"file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EAAE,SAAS;gBAClB,QAAQ,EAAE,QAAQ,CAAC,WAAW;gBAC9B,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK;aAC3C;YACD,QAAQ,EAAE,SAAS;YACnB,kBAAkB;YAClB,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -19,6 +19,8 @@ const clients_1 = require("../../utils/clients");
19
19
  const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
20
20
  const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
21
21
  const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
22
+ const helpers_1 = require("./helpers");
23
+ const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
22
24
  const farmFactor = new bignumber_js_1.default(Math.pow(10, 9));
23
25
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
24
26
  var _a;
@@ -41,6 +43,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
41
43
  });
42
44
  const burnerVaultsObjects = yield (0, multiGetObjects_1.multiGetObjects)(client, burnerVaults);
43
45
  const burnerVaultsTypes = burnerVaultsObjects.map((vault) => { var _a; return (_a = vault.data) === null || _a === void 0 ? void 0 : _a.type; });
46
+ const tokenAddresses = [];
44
47
  const lpMints = burnerVaultsTypes
45
48
  .map((type) => {
46
49
  var _a, _b;
@@ -49,10 +52,31 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
49
52
  const lp = (_b = (_a = (0, portfolio_core_1.parseTypeString)(type).keys) === null || _a === void 0 ? void 0 : _a.at(0)) === null || _b === void 0 ? void 0 : _b.type;
50
53
  if (!lp || !lp.includes('af_lp'))
51
54
  return undefined;
52
- return (0, portfolio_core_1.formatTokenAddress)(lp, portfolio_core_1.NetworkId.sui);
55
+ tokenAddresses.push((0, portfolio_core_1.formatTokenAddress)(lp, portfolio_core_1.NetworkId.sui));
56
+ return lp;
53
57
  })
54
58
  .flat();
55
- const lpTokenPriceById = yield cache.getTokenPricesAsMap(lpMints.map((lp) => (lp !== undefined ? lp : [])).flat(), portfolio_core_1.NetworkId.sui);
59
+ burnerVaultsObjects.forEach((vault) => {
60
+ var _a, _b;
61
+ (_b = (_a = vault.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.type_names.forEach((ct) => tokenAddresses.push(ct));
62
+ });
63
+ const [tokenPriceById, rewards] = yield Promise.all([
64
+ cache.getTokenPricesAsMap(tokenAddresses, portfolio_core_1.NetworkId.sui),
65
+ Promise.all(stakedPositions.map((object, i) => {
66
+ var _a, _b, _c, _d, _e;
67
+ const lp = lpMints[i];
68
+ const burnerVault = burnerVaultsObjects.find((bv) => { var _a, _b; return (_b = (_a = bv.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.id.id; });
69
+ if (!lp)
70
+ return null;
71
+ if (!((_a = object.data) === null || _a === void 0 ? void 0 : _a.content))
72
+ return null;
73
+ if (!burnerVault || !((_c = (_b = burnerVault.data) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.fields))
74
+ return null;
75
+ return (0, helpers_1.getHarvestRewards)(client, owner, object.data.content.fields, lp, (_e = (_d = burnerVault.data) === null || _d === void 0 ? void 0 : _d.content) === null || _e === void 0 ? void 0 : _e.fields);
76
+ })),
77
+ ]);
78
+ if (!tokenPriceById)
79
+ return [];
56
80
  const liquidities = [];
57
81
  for (let i = 0; i < stakedPositions.length; i++) {
58
82
  const object = stakedPositions[i];
@@ -61,20 +85,29 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
61
85
  const lp = lpMints[i];
62
86
  if (!lp)
63
87
  continue;
64
- const lpPrice = lpTokenPriceById.get(lp);
65
- if (!lpPrice)
88
+ const lpTokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(lp, portfolio_core_1.NetworkId.sui));
89
+ if (!lpTokenPrice)
66
90
  continue;
67
91
  const position = object.data.content.fields;
68
92
  const amount = new bignumber_js_1.default(position.balance)
69
93
  .dividedBy(farmFactor)
70
94
  .toNumber();
71
- const assets = (0, tokenPriceToAssetTokens_1.default)(lpPrice.address, amount, portfolio_core_1.NetworkId.sui, lpPrice);
72
- const value = (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value));
95
+ const assets = (0, tokenPriceToAssetTokens_1.default)(lpTokenPrice.address, amount, portfolio_core_1.NetworkId.sui, lpTokenPrice);
96
+ const rewardAssets = [];
97
+ const rewardsForPosition = rewards[i];
98
+ if (rewardsForPosition) {
99
+ rewardsForPosition.forEach((rewardAmount, coinType) => {
100
+ const tokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(coinType, portfolio_core_1.NetworkId.sui));
101
+ if (tokenPrice)
102
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)((0, portfolio_core_1.formatTokenAddress)(coinType, portfolio_core_1.NetworkId.sui), rewardAmount.dividedBy(Math.pow(10, tokenPrice.decimals)).toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
103
+ });
104
+ }
105
+ const value = (0, portfolio_core_1.getUsdValueSum)([...assets, ...rewardAssets].map((asset) => asset.value));
73
106
  liquidities.push({
74
107
  assets,
75
- assetsValue: value,
76
- rewardAssets: [],
77
- rewardAssetsValue: null,
108
+ assetsValue: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
109
+ rewardAssets,
110
+ rewardAssetsValue: (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((asset) => asset.value)),
78
111
  value,
79
112
  yields: [],
80
113
  });
@@ -1 +1 @@
1
- {"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aftermath/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAGrC,2CAAsD;AACtD,iDAAmD;AACnD,qEAAkE;AAElE,qEAAkE;AAClE,uGAA+E;AAE/E,MAAM,UAAU,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,CAAC,CAAA,CAAC,CAAC;AAE1C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,eAAe,GAAG,MAAM,IAAA,iCAAe,EAC3C,MAAM,EACN,KAAK,EACL;QACE,MAAM,EAAE;YACN,UAAU,EAAE,uBAAW;SACxB;QACD,OAAO,EAAE;YACP,WAAW,EAAE,IAAI;SAClB;KACF,CACF,CAAC;IACF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE5C,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;;QAClD,IAAI,MAAA,MAAA,MAAM,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,CAAC,oBAAoB;YACnD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC;QAEzD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,MAAM,IAAA,iCAAe,EAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAExE,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,GAAG,CAC/C,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,MAAA,KAAK,CAAC,IAAI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AC,CACzC;YACD,KAAK;YACL,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAExC,OAAO;QACL;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,EAAE,WAAW,EAAE;YACrB,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,0BAAS,CAAC,GAAG;YACxB,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC3D;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -51,3 +51,15 @@ export type PoolFactory = {
51
51
  name: string;
52
52
  value: string;
53
53
  };
54
+ export type BurnerVault = {
55
+ id: ID;
56
+ emission_rates: string[];
57
+ type_names: string[];
58
+ rewards: string[];
59
+ };
60
+ export type CoinType = string;
61
+ export type HarvestedRewards = {
62
+ afterburner_vault_id: string;
63
+ reward_amounts: string[];
64
+ reward_types: string[];
65
+ };
@@ -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;
@@ -1,7 +1,10 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { BorrowLendRate } from '@sonarwatch/portfolio-core';
3
3
  import { LendingMarket, PoolReward, Reserve } from './types';
4
- export declare function getPoolsRewardsAsMap(lendingMarkets: LendingMarket[] | undefined): Map<string, PoolReward>;
4
+ export declare function getPoolsRewardsMaps(lendingMarkets: LendingMarket[] | undefined): [PoolRewardById, PoolsRewardByManagerId];
5
+ type PoolRewardById = Map<string, PoolReward>;
6
+ type PoolsRewardByManagerId = Map<string, PoolReward[]>;
5
7
  export declare function getRatesAsMap(borrowLendRates: BorrowLendRate[] | undefined): Map<string, BorrowLendRate>;
6
8
  export declare function getBorrowApr(utilization: BigNumber, borrowedAmount: BigNumber, availableAmount: BigNumber, reserveFields: Reserve): number;
7
9
  export declare function getDepositApr(utilization: BigNumber, borrowApr: number, reserveFields: Reserve): number;
10
+ export {};
@@ -3,26 +3,35 @@ 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.getDepositApr = exports.getBorrowApr = exports.getRatesAsMap = exports.getPoolsRewardsAsMap = void 0;
6
+ exports.getDepositApr = exports.getBorrowApr = exports.getRatesAsMap = exports.getPoolsRewardsMaps = void 0;
7
7
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- function getPoolsRewardsAsMap(lendingMarkets) {
9
- const rewardMintByPoolId = new Map();
8
+ function getPoolsRewardsMaps(lendingMarkets) {
9
+ const poolRewardById = new Map();
10
+ const poolsRewardByManagerId = new Map();
10
11
  if (!lendingMarkets)
11
- return rewardMintByPoolId;
12
+ return [poolRewardById, poolsRewardByManagerId];
12
13
  for (const lendingMarket of lendingMarkets) {
13
14
  const { reserves } = lendingMarket;
14
15
  for (const reserve of reserves) {
15
- const poolsRewards = reserve.fields.deposits_pool_reward_manager.fields.pool_rewards;
16
- for (const poolReward of poolsRewards) {
17
- if (!poolReward)
16
+ const depositdPoolsRewards = reserve.fields.deposits_pool_reward_manager.fields.pool_rewards;
17
+ for (const poolReward of depositdPoolsRewards) {
18
+ if (!poolReward || !poolReward.fields)
18
19
  continue;
19
- rewardMintByPoolId.set(poolReward.fields.id.id, poolReward.fields);
20
+ poolRewardById.set(poolReward.fields.id.id, poolReward.fields);
20
21
  }
22
+ poolsRewardByManagerId.set(reserve.fields.deposits_pool_reward_manager.fields.id.id, depositdPoolsRewards.map((data) => (data ? data.fields : null)));
23
+ const borrowPoolsRewards = reserve.fields.borrows_pool_reward_manager.fields.pool_rewards;
24
+ for (const poolReward of borrowPoolsRewards) {
25
+ if (!poolReward || !poolReward.fields)
26
+ continue;
27
+ poolRewardById.set(poolReward.fields.id.id, poolReward.fields);
28
+ }
29
+ poolsRewardByManagerId.set(reserve.fields.borrows_pool_reward_manager.fields.id.id, borrowPoolsRewards.map((data) => (data ? data.fields : null)));
21
30
  }
22
31
  }
23
- return rewardMintByPoolId;
32
+ return [poolRewardById, poolsRewardByManagerId];
24
33
  }
25
- exports.getPoolsRewardsAsMap = getPoolsRewardsAsMap;
34
+ exports.getPoolsRewardsMaps = getPoolsRewardsMaps;
26
35
  function getRatesAsMap(borrowLendRates) {
27
36
  const ratesByReserveId = new Map();
28
37
  if (!borrowLendRates)
@@ -37,9 +46,13 @@ exports.getRatesAsMap = getRatesAsMap;
37
46
  function getBorrowApr(utilization, borrowedAmount, availableAmount, reserveFields) {
38
47
  const { interest_rate_aprs: rateAprs, interest_rate_utils: rateUtils } = reserveFields.config.fields.element.fields;
39
48
  if (borrowedAmount.isZero())
40
- return (0, bignumber_js_1.default)(rateAprs[0]).dividedBy(100).toNumber();
49
+ return (0, bignumber_js_1.default)(rateAprs[0])
50
+ .dividedBy(Math.pow(10, 4))
51
+ .toNumber();
41
52
  if (availableAmount.isZero())
42
- return (0, bignumber_js_1.default)(rateAprs[rateAprs.length]).dividedBy(100).toNumber();
53
+ return (0, bignumber_js_1.default)(rateAprs[rateAprs.length])
54
+ .dividedBy(Math.pow(10, 4))
55
+ .toNumber();
43
56
  for (let i = 0; i < rateUtils.length; i++) {
44
57
  const currentUtil = rateUtils[i] / 100;
45
58
  const nextUtil = rateUtils[i + 1] / 100;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAIrC,SAAgB,oBAAoB,CAClC,cAA2C;IAE3C,MAAM,kBAAkB,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC9D,IAAI,CAAC,cAAc;QAAE,OAAO,kBAAkB,CAAC;IAE/C,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;QACnC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,YAAY,GAChB,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,YAAY,CAAC;YAClE,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;gBACtC,IAAI,CAAC,UAAU;oBAAE,SAAS;gBAC1B,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAlBD,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AAA,sBAAS,EAAC,SAAS,CAAC;SACxB,KAAK,CACJ,CAAC;QACC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;YAC/D,SAAA,EAAE,EAAI,CAAC,CAAA,CACZ;SACA,KAAK,CAAC,WAAW,CAAC;SAClB,QAAQ,EAAE,CAAC;AAChB,CAAC;AAbD,sCAaC"}
@@ -54,8 +54,8 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
54
54
  marketsInfo.lendingMarkets.forEach((market) => {
55
55
  marketsByIndex.set(market.id.id, market);
56
56
  });
57
- const poolRewardById = (0, helpers_1.getPoolsRewardsAsMap)(lendingMarkets);
58
- poolRewardById.forEach((pool) => mints.add(pool.coin_type.fields.name));
57
+ const [poolRewardById, poolsRewardByManagerId] = (0, helpers_1.getPoolsRewardsMaps)(lendingMarkets);
58
+ poolRewardById.forEach((pool) => pool ? mints.add(pool.coin_type.fields.name) : undefined);
59
59
  const borrowedAssets = [];
60
60
  const borrowedYields = [];
61
61
  const suppliedAssets = [];
@@ -152,14 +152,33 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
152
152
  .dividedBy(Math.pow(10, constants_2.wadsDecimal));
153
153
  if (cumulativeAmount.isLessThanOrEqualTo(0))
154
154
  continue;
155
- const previousCumAmount = rewardAmountByMint.get(rewardMint);
156
- if (previousCumAmount) {
157
- rewardAmountByMint.set(rewardMint, previousCumAmount.plus(cumulativeAmount));
155
+ const previousAmount = rewardAmountByMint.get(rewardMint);
156
+ if (previousAmount) {
157
+ rewardAmountByMint.set(rewardMint, previousAmount.plus(cumulativeAmount));
158
158
  }
159
159
  else {
160
160
  rewardAmountByMint.set(rewardMint, cumulativeAmount);
161
161
  }
162
162
  }
163
+ if (userRewardManager.fields.rewards.length === 0) {
164
+ const poolsRewards = poolsRewardByManagerId.get(userRewardManager.fields.pool_reward_manager_id);
165
+ if (poolsRewards) {
166
+ for (const poolReward of poolsRewards) {
167
+ if (!poolReward)
168
+ continue;
169
+ const amount = new bignumber_js_1.default(poolReward.cumulative_rewards_per_share.fields.value)
170
+ .times(share)
171
+ .dividedBy(Math.pow(10, constants_2.wadsDecimal));
172
+ const previousAmount = rewardAmountByMint.get(poolReward.coin_type.fields.name);
173
+ if (previousAmount) {
174
+ rewardAmountByMint.set(poolReward.coin_type.fields.name, previousAmount.plus(amount));
175
+ }
176
+ else {
177
+ rewardAmountByMint.set(poolReward.coin_type.fields.name, amount);
178
+ }
179
+ }
180
+ }
181
+ }
163
182
  }
164
183
  rewardAmountByMint.forEach((amount, mint) => {
165
184
  const tokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(mint, portfolio_core_1.NetworkId.sui));
@@ -1 +1 @@
1
- {"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;AAOlE,qEAAkE;AAClE,qGAA6E;AAC7E,uCAAgE;AAChE,iDAAgD;AAEhD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,oBAAoB,GAAG,MAAM,IAAA,iCAAe,EAChD,MAAM,EACN,KAAK,EACL;QACE,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAS,EAAE;KAC/B,CACF,CAAC;IACF,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjD,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,KAAK,MAAM,kBAAkB,IAAI,oBAAoB,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,MAAA,MAAA,kBAAkB,CAAC,IAAI,0CAAE,OAAO,0CAAE,IAA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b,cAAc;YACd,WAAW;YACX,YAAY;YACZ,WAAW;YACX,KAAK;SACN;KACF,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;AAOlE,qEAAkE;AAClE,qGAA6E;AAC7E,uCAA+D;AAC/D,iDAAgD;AAEhD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,oBAAoB,GAAG,MAAM,IAAA,iCAAe,EAChD,MAAM,EACN,KAAK,EACL;QACE,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAS,EAAE;KAC/B,CACF,CAAC;IACF,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjD,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,KAAK,MAAM,kBAAkB,IAAI,oBAAoB,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,MAAA,MAAA,kBAAkB,CAAC,IAAI,0CAAE,OAAO,0CAAE,IAAI,CAAC;QACpD,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,kCAAsB,CAAC,CAAA;YAAE,SAAS;QAExD,MAAM,YAAY,GAAG,MAAA,MAAA,kBAAkB,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,CAAC,a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O,EAClB,MAAM,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,UAAU,CAAC,QAAQ,CAAA,CAAC,CAAC,QAAQ,EAAE,EACtD,0BAAS,CAAC,GAAG,EACb,UAAU,CACX,KACD,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,IACjC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IACE,cAAc,CAAC,MAAM,KAAK,CAAC;QAC3B,cAAc,CAAC,MAAM,KAAK,CAAC;QAC3B,YAAY,CAAC,MAAM,KAAK,CAAC;QAEzB,OAAO,EAAE,CAAC;IAEZ,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,GACrE,IAAA,wCAAuB,EAAC;QACtB,cAAc;QACd,cAAc;QACd,YAAY;QACZ,YAAY;QACZ,eAAe;KAChB,CAAC,CAAC;IAEL,MAAM,OAAO,GAAqB;QAChC,IAAI,EAAE,qCAAoB,CAAC,UAAU;QACrC,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,UAAU,EAAV,sBAAU;QACV,KAAK,EAAE,SAAS;QAChB,KAAK;QACL,IAAI,EAAE;YACJ,cAAc;YACd,aAAa;YACb,cAAc;YACd,cAAc;YACd,aAAa;YACb,cAAc;YACd,WAAW;YACX,YAAY;YACZ,WAAW;YACX,KAAK;SACN;KACF,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -85,7 +85,7 @@ export type PoolRewardManager = {
85
85
  pool_rewards: ParsedData<PoolReward>[];
86
86
  total_shares: string;
87
87
  };
88
- export type PoolReward = {
88
+ export type PoolReward = null | {
89
89
  id: ID;
90
90
  additional_fields: ParsedData<AdditionalFields>;
91
91
  allocated_rewards: ParsedData<Value>;
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
54
54
  }
55
55
  function getV3PairsAddresses(url, length = 300) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
- const query = (0, graphql_request_1.gql) `
58
- {
59
- pools(
60
- orderBy: totalValueLockedUSD
61
- first: ${length}
62
- orderDirection: desc
63
- where: { volumeUSD_not: "0", liquidity_not: "0" }
64
- ) {
65
- id
66
- token0Price
67
- token1Price
68
- liquidity
69
- token0 {
70
- id
71
- totalSupply
72
- decimals
73
- }
74
- token1 {
75
- id
76
- totalSupply
77
- decimals
78
- }
79
- }
80
- }
57
+ const query = (0, graphql_request_1.gql) `
58
+ {
59
+ pools(
60
+ orderBy: totalValueLockedUSD
61
+ first: ${length}
62
+ orderDirection: desc
63
+ where: { volumeUSD_not: "0", liquidity_not: "0" }
64
+ ) {
65
+ id
66
+ token0Price
67
+ token1Price
68
+ liquidity
69
+ token0 {
70
+ id
71
+ totalSupply
72
+ decimals
73
+ }
74
+ token1 {
75
+ id
76
+ totalSupply
77
+ decimals
78
+ }
79
+ }
80
+ }
81
81
  `;
82
82
  const res = yield (0, graphql_request_1.default)(url, query);
83
83
  const pools = res.pools;
@@ -40,28 +40,28 @@ function getPairKey(version) {
40
40
  exports.getPairKey = getPairKey;
41
41
  function getPairsV2FromTheGraph(url, length = 300) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const query = (0, graphql_request_1.gql) `
44
- {
45
- pairs(
46
- orderBy: reserveUSD
47
- first: ${length}
48
- orderDirection: desc
49
- where: { trackedReserveETH_not: "0" }
50
- ) {
51
- id
52
- reserve0
53
- reserve1
54
- totalSupply
55
- token0 {
56
- id
57
- decimals
58
- }
59
- token1 {
60
- id
61
- decimals
62
- }
63
- }
64
- }
43
+ const query = (0, graphql_request_1.gql) `
44
+ {
45
+ pairs(
46
+ orderBy: reserveUSD
47
+ first: ${length}
48
+ orderDirection: desc
49
+ where: { trackedReserveETH_not: "0" }
50
+ ) {
51
+ id
52
+ reserve0
53
+ reserve1
54
+ totalSupply
55
+ token0 {
56
+ id
57
+ decimals
58
+ }
59
+ token1 {
60
+ id
61
+ decimals
62
+ }
63
+ }
64
+ }
65
65
  `;
66
66
  const res = yield (0, graphql_request_1.default)(url, query);
67
67
  const pairs = res.pairs;