@sonarwatch/portfolio-plugins 0.11.188 → 0.11.190

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +2 -2
  3. package/src/plugins/01/constants.d.ts +6 -1
  4. package/src/plugins/01/constants.js +21 -2
  5. package/src/plugins/01/constants.js.map +1 -1
  6. package/src/plugins/01/helpers.d.ts +0 -1
  7. package/src/plugins/01/helpers.js +3 -3
  8. package/src/plugins/01/helpers.js.map +1 -1
  9. package/src/plugins/aave/constants.js.map +1 -1
  10. package/src/plugins/aave/index.d.ts +2 -1
  11. package/src/plugins/aave/index.js +3 -1
  12. package/src/plugins/aave/index.js.map +1 -1
  13. package/src/plugins/aave/services.d.ts +30 -0
  14. package/src/plugins/aave/services.js +181 -0
  15. package/src/plugins/aave/services.js.map +1 -0
  16. package/src/plugins/aries/constants.d.ts +5 -2
  17. package/src/plugins/aries/constants.js +6 -3
  18. package/src/plugins/aries/constants.js.map +1 -1
  19. package/src/plugins/aries/depositsFetcher.js +102 -96
  20. package/src/plugins/aries/depositsFetcher.js.map +1 -1
  21. package/src/plugins/aries/helpers.d.ts +20 -1
  22. package/src/plugins/aries/helpers.js +94 -2
  23. package/src/plugins/aries/helpers.js.map +1 -1
  24. package/src/plugins/aries/reservesJob.js +1 -1
  25. package/src/plugins/aries/reservesJob.js.map +1 -1
  26. package/src/plugins/aries/types.d.ts +56 -33
  27. package/src/plugins/jupiter/pricingJob.js +15 -0
  28. package/src/plugins/jupiter/pricingJob.js.map +1 -1
  29. package/src/plugins/meteora/farmsFetcher.js +20 -11
  30. package/src/plugins/meteora/farmsFetcher.js.map +1 -1
  31. package/src/plugins/meteora/farmsJob.js +3 -1
  32. package/src/plugins/meteora/farmsJob.js.map +1 -1
  33. package/src/plugins/meteora/helpers.d.ts +4 -0
  34. package/src/plugins/meteora/helpers.js +25 -1
  35. package/src/plugins/meteora/helpers.js.map +1 -1
  36. package/src/plugins/meteora/multiTokenPools.json +10 -0
  37. package/src/plugins/meteora/types.d.ts +2 -5
  38. package/src/plugins/meteora/types.js.map +1 -1
  39. package/src/plugins/saber/constants.js +1 -1
  40. package/src/plugins/saber/constants.js.map +1 -1
  41. package/src/utils/aptos/getTableItemsByKeys.d.ts +1 -1
  42. package/src/utils/aptos/getTableItemsByKeys.js.map +1 -1
@@ -13,116 +13,122 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
- const axios_1 = __importDefault(require("axios"));
17
16
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
17
  const constants_1 = require("./constants");
19
18
  const helpers_1 = require("./helpers");
20
19
  const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
20
+ const aptos_1 = require("../../utils/aptos");
21
+ const clients_1 = require("../../utils/clients");
21
22
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
22
- const profileRes = yield axios_1.default
23
- .get(`${constants_1.apiUrl}profile.find?input={"owner":"${owner}"}`, { timeout: 1000 })
24
- .catch(() => null);
25
- if (!profileRes || !profileRes.data)
23
+ var _a;
24
+ const client = (0, clients_1.getClientAptos)();
25
+ // Get deposit and borrow amounts for each profile
26
+ const profilesSummary = yield (0, aptos_1.getAccountResource)(client, owner, constants_1.profilesSummaryType);
27
+ if (!profilesSummary)
26
28
  return [];
29
+ const profilesAddresses = profilesSummary.profile_signers.data.map((d) => d.value.account);
30
+ if (profilesAddresses.length === 0)
31
+ return [];
32
+ const profiless = yield Promise.all(profilesAddresses.map((pAddress) => (0, aptos_1.getAccountResource)(client, pAddress, constants_1.profileType)));
33
+ const amountss = yield Promise.all(profiless.map((p) => (0, helpers_1.getProfileAmounts)(p, client)));
34
+ // Get TokenPrices
35
+ const tokenAddresses = [];
36
+ amountss.forEach((amounts) => {
37
+ amounts.deposits.forEach((deposit) => {
38
+ tokenAddresses.push(deposit.address);
39
+ });
40
+ amounts.borrows.forEach((borrow) => {
41
+ tokenAddresses.push(borrow.address);
42
+ });
43
+ });
44
+ const tokenPrices = yield cache.getTokenPricesAsMap(tokenAddresses, portfolio_core_1.NetworkId.aptos);
45
+ // Get Reserves
27
46
  const reserves = yield cache.getItem(constants_1.reservesKey, {
28
47
  prefix: constants_1.platformId,
29
48
  networkId: portfolio_core_1.NetworkId.aptos,
30
49
  });
31
- const ratesByCoin = new Map();
32
- if (reserves) {
33
- reserves.forEach((reserveData) => {
34
- ratesByCoin.set(reserveData.key, reserveData.rate);
35
- });
36
- }
37
- const { profiles } = profileRes.data.result.data;
38
- const mintsSet = new Set();
39
- for (const accountName in profiles) {
40
- if (profiles[accountName]) {
41
- for (const coin in profiles[accountName].deposits) {
42
- if (profiles[accountName].deposits[coin]) {
43
- mintsSet.add(coin);
44
- }
45
- }
46
- for (const coin in profiles[accountName].borrows) {
47
- if (profiles[accountName].borrows[coin]) {
48
- mintsSet.add(coin);
49
- }
50
- }
51
- }
52
- }
53
- const mints = Array.from(mintsSet);
54
- const tokenPrices = yield cache.getTokenPrices(mints, portfolio_core_1.NetworkId.aptos);
55
- const tokenById = new Map();
56
- tokenPrices.forEach((tokenPrice, index) => {
57
- if (tokenPrice) {
58
- tokenById.set(mints[index], tokenPrice);
59
- }
50
+ if (!reserves)
51
+ return [];
52
+ const reservesByAddress = new Map();
53
+ reserves.forEach((reserveData) => {
54
+ reservesByAddress.set(reserveData.key, reserveData);
60
55
  });
61
56
  const elements = [];
62
- for (const accountName in profiles) {
63
- if (profiles[accountName]) {
64
- const borrowedAssets = [];
65
- const borrowedYields = [];
66
- const suppliedAssets = [];
67
- const suppliedYields = [];
68
- const rewardAssets = [];
69
- const profile = profiles[accountName];
70
- const name = (0, helpers_1.getName)(accountName);
71
- for (const coin in profile.deposits) {
72
- if (profile.deposits[coin]) {
73
- const deposit = profile.deposits[coin];
74
- const amount = new bignumber_js_1.default(deposit.collateral_coins);
75
- if (amount.isZero())
76
- continue;
77
- const tokenPrice = tokenById.get(coin);
78
- if (!tokenPrice)
79
- continue;
80
- suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(coin, amount.dividedBy(Math.pow(10, tokenPrice.decimals)).toNumber(), portfolio_core_1.NetworkId.aptos, tokenPrice));
81
- const rates = ratesByCoin.get(coin);
82
- if (rates)
83
- suppliedYields.push([rates.depositYield]);
84
- }
85
- }
86
- for (const coin in profile.borrows) {
87
- if (profile.borrows[coin]) {
88
- const borrow = profile.borrows[coin];
89
- const amount = new bignumber_js_1.default(borrow.borrowed_coins);
90
- if (amount.isZero())
91
- continue;
92
- const tokenPrice = tokenById.get(coin);
93
- if (!tokenPrice)
94
- continue;
95
- borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(coin, amount.dividedBy(Math.pow(10, tokenPrice.decimals)).toNumber(), portfolio_core_1.NetworkId.aptos, tokenPrice));
96
- const rates = ratesByCoin.get(coin);
97
- if (rates)
98
- borrowedYields.push([rates.borrowYield]);
99
- }
100
- }
101
- if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
57
+ for (let i = 0; i < profiless.length; i++) {
58
+ const profile = profiless[i];
59
+ if (!profile)
60
+ continue;
61
+ const amounts = amountss[i];
62
+ const profileKey = (_a = profilesSummary.profile_signers.data.at(i)) === null || _a === void 0 ? void 0 : _a.key;
63
+ const name = profileKey ? (0, helpers_1.getName)(profileKey) : undefined;
64
+ const borrowedAssets = [];
65
+ const borrowedYields = [];
66
+ const suppliedAssets = [];
67
+ const suppliedYields = [];
68
+ const rewardAssets = [];
69
+ const suppliedLtvs = [];
70
+ const borrowedWeights = [];
71
+ for (let j = 0; j < amounts.deposits.length; j++) {
72
+ const deposit = amounts.deposits[j];
73
+ const { address, amount: amountStr } = deposit;
74
+ const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatMoveTokenAddress)(address));
75
+ if (!tokenPrice)
102
76
  continue;
103
- const { borrowedValue, suppliedValue, value, rewardValue } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, rewardAssets);
104
- elements.push({
105
- type: portfolio_core_1.PortfolioElementType.borrowlend,
106
- networkId: portfolio_core_1.NetworkId.aptos,
107
- platformId: constants_1.platformId,
108
- label: 'Lending',
109
- value,
110
- name,
111
- data: {
112
- borrowedAssets,
113
- borrowedValue,
114
- borrowedYields,
115
- suppliedAssets,
116
- suppliedValue,
117
- suppliedYields,
118
- collateralRatio: null,
119
- healthRatio: 1 - new bignumber_js_1.default(profile.riskFactor).toNumber(),
120
- rewardAssets,
121
- rewardValue,
122
- value,
123
- },
124
- });
77
+ const reserve = reservesByAddress.get(address);
78
+ if (!reserve)
79
+ continue;
80
+ suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(address, new bignumber_js_1.default(amountStr)
81
+ .dividedBy(Math.pow(10, tokenPrice.decimals))
82
+ .times(new bignumber_js_1.default(reserve.value.total_borrowed)
83
+ .plus(reserve.value.total_cash_available)
84
+ .minus(reserve.value.reserve_amount)
85
+ .div(reserve.value.total_lp_supply))
86
+ .toNumber(), portfolio_core_1.NetworkId.aptos, tokenPrice));
87
+ suppliedLtvs.push(Number(reserve.value.reserve_config.liquidation_threshold) / 100);
88
+ suppliedYields.push([reserve.rate.depositYield]);
89
+ }
90
+ for (let j = 0; j < amounts.borrows.length; j++) {
91
+ const borrow = amounts.borrows[j];
92
+ const { address, amount: amountStr } = borrow;
93
+ const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatMoveTokenAddress)(address));
94
+ if (!tokenPrice)
95
+ continue;
96
+ const reserve = reservesByAddress.get(address);
97
+ if (!reserve)
98
+ continue;
99
+ borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(address, new bignumber_js_1.default(amountStr)
100
+ .times(new bignumber_js_1.default(reserve.value.total_borrowed).div(reserve.value.total_borrowed_share))
101
+ .dividedBy(Math.pow(10, (constants_1.wadsDecimal + tokenPrice.decimals)))
102
+ .toNumber(), portfolio_core_1.NetworkId.aptos, tokenPrice));
103
+ borrowedYields.push([reserve.rate.borrowYield]);
104
+ borrowedWeights.push(Number(reserve.value.reserve_config.borrow_factor) / 100);
125
105
  }
106
+ if (borrowedAssets.length === 0 &&
107
+ suppliedAssets.length === 0 &&
108
+ rewardAssets.length === 0)
109
+ continue;
110
+ const { borrowedValue, suppliedValue, value, rewardValue, healthRatio } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, rewardAssets, suppliedLtvs, borrowedWeights);
111
+ elements.push({
112
+ type: portfolio_core_1.PortfolioElementType.borrowlend,
113
+ networkId: portfolio_core_1.NetworkId.aptos,
114
+ platformId: constants_1.platformId,
115
+ label: 'Lending',
116
+ value,
117
+ name,
118
+ data: {
119
+ borrowedAssets,
120
+ borrowedValue,
121
+ borrowedYields,
122
+ suppliedAssets,
123
+ suppliedValue,
124
+ suppliedYields,
125
+ collateralRatio: null,
126
+ healthRatio,
127
+ rewardAssets,
128
+ rewardValue,
129
+ value,
130
+ },
131
+ });
126
132
  }
127
133
  return elements;
128
134
  });
@@ -1 +1 @@
1
- {"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aries/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,kDAA6C;AAC7C,gEAAqC;AAGrC,2CAA8D;AAE9D,uCAAoC;AACpC,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAA0C,MAAM,eAAK;SAClE,GAAG,CAAC,GAAG,kBAAM,gCAAgC,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAC1E,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrB,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAE/C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAoB,uBAAW,EAAE;QACn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AAK,EAAE,WAAW,EAAE,GACxD,IAAA,wCAAuB,EAAC,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;YAExE,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qCAAoB,CAAC,UAAU;gBACrC,SAAS,EAAE,0BAAS,CAAC,KAAK;gBAC1B,UAAU,EAAV,sBAAU;gBACV,KAAK,EAAE,SAAS;gBAChB,KAAK;gBACL,IAAI;gBACJ,IAAI,EAAE;oBACJ,cAAc;oBACd,aAAa;oBACb,cAAc;oBACd,cAAc;oBACd,aAAa;oBACb,cAAc;oBACd,eAAe,EAAE,IAAI;oBACrB,WAAW,EAAE,CAAC,GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;oBAC7D,YAAY;oBACZ,WAAW;oBACX,KAAK;iBACN;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,KAAK;IAC1B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aries/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAMqB;AAErB,uCAAuD;AACvD,qGAA6E;AAC7E,6CAAuD;AACvD,iDAAqD;AAErD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAEhC,kDAAkD;IAClD,MAAM,eAAe,GAAG,MAAM,IAAA,0BAAkB,EAC9C,MAAM,EACN,KAAK,EACL,+BAAmB,CACpB,CAAC;IACF,IAAI,CAAC,e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,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,SAAS,EAAE,0BAAS,CAAC,KAAK;YAC1B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,SAAS;YAChB,KAAK;YACL,IAAI;YACJ,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,eAAe,EAAE,IAAI;gBACrB,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,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,KAAK;IAC1B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -1,5 +1,24 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { Reserve } from './types';
2
+ import { Profile, Reserve } from './types';
3
+ import { AptosClient } from '../../utils/clients/types';
3
4
  export declare function getName(accountName: string): string;
4
5
  export declare function getBorrowApr(utilization: BigNumber, borrowedAmount: BigNumber, availableAmount: BigNumber, reserveData: Reserve): number;
5
6
  export declare function getDepositApr(utilization: BigNumber, borrowApr: number, reserveData: Reserve): number;
7
+ export declare function getProfileAmounts(profile: Profile | null, client: AptosClient): Promise<{
8
+ deposits: {
9
+ address: string;
10
+ amount: string;
11
+ }[];
12
+ borrows: {
13
+ address: string;
14
+ amount: string;
15
+ }[];
16
+ }>;
17
+ export declare function getProfileBorrows(profile: Profile | null, client: AptosClient): Promise<{
18
+ address: string;
19
+ amount: string;
20
+ }[]>;
21
+ export declare function getProfileDeposits(profile: Profile | null, client: AptosClient): Promise<{
22
+ address: string;
23
+ amount: string;
24
+ }[]>;
@@ -1,14 +1,39 @@
1
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
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDepositApr = exports.getBorrowApr = exports.getName = void 0;
15
+ exports.getProfileDeposits = exports.getProfileBorrows = exports.getProfileAmounts = exports.getDepositApr = exports.getBorrowApr = exports.getName = void 0;
7
16
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
+ const aptos_1 = require("../../utils/aptos");
18
+ const constants_1 = require("./constants");
8
19
  function getName(accountName) {
9
- return accountName.replace('profile', '');
20
+ if (accountName.startsWith('profile'))
21
+ return accountName.slice(7);
22
+ return accountName;
10
23
  }
11
24
  exports.getName = getName;
25
+ function hex2a(hex) {
26
+ let hexx = hex;
27
+ if (hex.startsWith('0x'))
28
+ hexx = hexx.slice(2);
29
+ let str = '';
30
+ for (let i = 0; i < hexx.length; i += 2)
31
+ str += String.fromCharCode(parseInt(hexx.substring(i, i + 2), 16));
32
+ return str;
33
+ }
34
+ function getTokenAddress(vec) {
35
+ return `${vec.account_address}::${hex2a(vec.module_name)}::${hex2a(vec.struct_name)}`;
36
+ }
12
37
  function getBorrowApr(utilization, borrowedAmount, availableAmount, reserveData) {
13
38
  const interestRateConfig = reserveData.value.interest_rate_config;
14
39
  const optimalUtilization = interestRateConfig.optimal_utilization / 100;
@@ -43,4 +68,71 @@ function getDepositApr(utilization, borrowApr, reserveData) {
43
68
  .toNumber();
44
69
  }
45
70
  exports.getDepositApr = getDepositApr;
71
+ function getProfileAmounts(profile, client) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const [deposits, borrows] = yield Promise.all([
74
+ getProfileDeposits(profile, client),
75
+ getProfileBorrows(profile, client),
76
+ ]);
77
+ return {
78
+ deposits,
79
+ borrows,
80
+ };
81
+ });
82
+ }
83
+ exports.getProfileAmounts = getProfileAmounts;
84
+ function getProfileBorrows(profile, client) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const head = profile === null || profile === void 0 ? void 0 : profile.borrowed_reserves.head.vec.at(0);
87
+ const handle = profile === null || profile === void 0 ? void 0 : profile.borrowed_reserves.inner.inner.handle;
88
+ if (!head || !handle)
89
+ return [];
90
+ let nextVec = head;
91
+ let profileItem;
92
+ const amounts = [];
93
+ while (nextVec) {
94
+ profileItem = yield (0, aptos_1.getTableItem)(client, handle, {
95
+ key_type: '0x1::type_info::TypeInfo',
96
+ value_type: `${constants_1.packageId}::iterable_table::IterableValue<0x1::type_info::TypeInfo, ${constants_1.packageId}::profile::Loan>`,
97
+ key: nextVec,
98
+ });
99
+ if (profileItem) {
100
+ amounts.push({
101
+ address: getTokenAddress(nextVec),
102
+ amount: profileItem.val.borrowed_share.val,
103
+ });
104
+ }
105
+ nextVec = profileItem === null || profileItem === void 0 ? void 0 : profileItem.next.vec.at(0);
106
+ }
107
+ return amounts;
108
+ });
109
+ }
110
+ exports.getProfileBorrows = getProfileBorrows;
111
+ function getProfileDeposits(profile, client) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const head = profile === null || profile === void 0 ? void 0 : profile.deposited_reserves.head.vec.at(0);
114
+ const handle = profile === null || profile === void 0 ? void 0 : profile.deposited_reserves.inner.inner.handle;
115
+ if (!head || !handle)
116
+ return [];
117
+ let nextVec = head;
118
+ let profileItem;
119
+ const amounts = [];
120
+ while (nextVec) {
121
+ profileItem = yield (0, aptos_1.getTableItem)(client, handle, {
122
+ key_type: '0x1::type_info::TypeInfo',
123
+ value_type: `${constants_1.packageId}::iterable_table::IterableValue<0x1::type_info::TypeInfo, ${constants_1.packageId}::profile::Deposit>`,
124
+ key: nextVec,
125
+ });
126
+ if (profileItem) {
127
+ amounts.push({
128
+ address: getTokenAddress(nextVec),
129
+ amount: profileItem.val.collateral_amount,
130
+ });
131
+ }
132
+ nextVec = profileItem === null || profileItem === void 0 ? void 0 : profileItem.next.vec.at(0);
133
+ }
134
+ return amounts;
135
+ });
136
+ }
137
+ exports.getProfileDeposits = getProfileDeposits;
46
138
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aries/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGrC,SAAgB,OAAO,CAAC,WAAmB;IACzC,OAAO,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC;AAFD,0BAEC;AAED,SAAgB,YAAY,CAC1B,WAAsB,EACtB,cAAyB,EACzB,eAA0B,EAC1B,WAAoB;IAEpB,MAAM,kBAAkB,GAAG,WAAW,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAClE,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,mBAAmB,GAAG,GAAG,CAAC;IACxE,MAAM,WAAW,GAAG,kBAAkB,CAAC,mBAAmB,GAAG,GAAG,CAAC;IACjE,MAAM,OAAO,GAAG,kBAAkB,CAAC,eAAe,GAAG,GAAG,CAAC;IACzD,MAAM,OAAO,GAAG,kBAAkB,CAAC,eAAe,GAAG,GAAG,CAAC;IAEzD,IAAI,cAAc,CAAC,MAAM,EAAE;QAAE,OAAO,OAAO,CAAC;IAC5C,IAAI,eAAe,CAAC,MAAM,EAAE;QAAE,OAAO,OAAO,CAAC;IAE7C,IAAI,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC/C,MAAM,gBAAgB,GAAG,WAAW,CAAC;QACrC,MAAM,cAAc,GAAG,kBAAkB,CAAC;QAC1C,OAAO,gBAAgB;aACpB,SAAS,CAAC,cAAc,CAAC;aACzB,KAAK,CAAC,WAAW,CAAC;aAClB,QAAQ,EAAE,CAAC;IAChB,CAAC;IACD,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,IAAA,sBAAS,EAAC,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC9D,OAAO,gBAAgB;SACpB,SAAS,CAAC,cAAc,CAAC;SACzB,KAAK,CAAC,OAAO,CAAC;SACd,IAAI,CAAC,WAAW,CAAC;SACjB,QAAQ,EAAE,CAAC;AAChB,CAAC;AA9BD,oCA8BC;AAED,SAAgB,aAAa,CAC3B,WAAsB,EACtB,SAAiB,EACjB,WAAoB;IAEpB,OAAO,IAAA,sBAAS,EAAC,SAAS,CAAC;SACxB,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,SAAA,EAAE,EAAI,CAAC,CAAA,CAAC;SAC3E,KAAK,CAAC,WAAW,CAAC;SAClB,QAAQ,EAAE,CAAC;AAChB,CAAC;AATD,sCASC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aries/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAAqC;AASrC,6CAAiD;AACjD,2CAAwC;AAExC,SAAgB,OAAO,CAAC,WAAmB;IACzC,IAAI,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnE,OAAO,WAAW,CAAC;AACrB,CAAC;AAHD,0BAGC;AAED,SAAS,KAAK,CAAC,GAAW;IACxB,IAAI,IAAI,GAAG,GAAG,CAAC;IACf,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,IAAI,GAAG,IAAI,CA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A2B,IAAI,CAAC;QAC3C,IAAI,WAAsC,CAAC;QAC3C,MAAM,OAAO,GAA0C,EAAE,CAAC;QAC1D,OAAO,OAAO,EAAE,CAAC;YACf,WAAW,GAAG,MAAM,IAAA,oBAAY,EAAqB,MAAM,EAAE,MAAM,EAAE;gBACnE,QAAQ,EAAE,0BAA0B;gBACpC,UAAU,EAAE,GAAG,qBAAS,6DAA6D,qBAAS,qBAAqB;gBACnH,GAAG,EAAE,OAAO;aACb,CAAC,CAAC;YACH,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CAAC;oBACX,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;oBACjC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,iBAAiB;iBAC1C,CAAC,CAAC;YACL,CAAC;YACD,OAAO,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA;AA1BD,gDA0BC"}
@@ -19,7 +19,7 @@ const constants_1 = require("./constants");
19
19
  const helpers_1 = require("./helpers");
20
20
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
21
21
  const reservesRes = yield axios_1.default
22
- .get(`${constants_1.apiUrl}reserve.current`)
22
+ .get(constants_1.reserveApiUrl)
23
23
  .catch(() => null);
24
24
  if (!reservesRes)
25
25
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"reservesJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aries/reservesJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,gEAAqC;AACrC,+DAKoC;AAGpC,2CAA8D;AAE9D,uCAAwD;AAExD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,WAAW,GAA0C,MAAM,eAAK;SACnE,GAAG,CAAC,GAAG,kBAAM,iBAAiB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G,EAAE,EAAE,IAAI,EAAE;YACpC,MAAM,EAAE,sCAAqB;YAC7B,SAAS,EAAE,0BAAS,CAAC,KAAK;SAC3B,CAAC,CACH,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,IAAI,CACX,KAAK,CAAC,OAAO,CAAC,uBAAW,EAAE,gBAAgB,EAAE;QAC3C,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,KAAK;KAC3B,CAAC,CACH,CAAC;IAEF,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -1,41 +1,64 @@
1
1
  import { BorrowLendRate } from '@sonarwatch/portfolio-core';
2
- export type ProfileResponse = {
3
- result: {
4
- data: ProfileData;
2
+ export type ProfilesSummary = {
3
+ profile_signers: {
4
+ data: [
5
+ {
6
+ key: string;
7
+ value: {
8
+ account: string;
9
+ };
10
+ }
11
+ ];
5
12
  };
6
13
  };
7
- export type ProfileData = {
8
- profiles: {
9
- [accountName: string]: {
10
- id: string;
11
- meta: {
12
- module: string;
13
- owner: string;
14
- version: number;
15
- timestamp: string;
16
- };
17
- profileAddress: string;
18
- deposits: {
19
- [coin: string]: {
20
- collateral_amount: string;
21
- collateral_coins: string;
22
- collateral_value: string;
23
- };
24
- };
25
- borrows: {
26
- [coin: string]: {
27
- borrowed_amount: string;
28
- borrowed_coins: string;
29
- borrowed_value: string;
30
- };
31
- };
32
- equity: string;
33
- collateralValue: string;
34
- loanValue: string;
35
- riskFactor: string;
14
+ export type Profile = {
15
+ borrow_farms: ProfileSub;
16
+ borrowed_reserves: ProfileSub;
17
+ deposit_farms: ProfileSub;
18
+ deposited_reserves: ProfileSub;
19
+ };
20
+ export type ProfileVec = {
21
+ account_address: string;
22
+ module_name: string;
23
+ struct_name: string;
24
+ };
25
+ export type ProfileSub = {
26
+ head: {
27
+ vec: ProfileVec[];
28
+ };
29
+ inner: {
30
+ inner: {
31
+ handle: string;
32
+ };
33
+ length: string;
34
+ };
35
+ tail: {
36
+ vec: ProfileVec[];
37
+ };
38
+ };
39
+ export type ProfileDepositItem = {
40
+ next: {
41
+ vec: [ProfileVec] | [];
42
+ };
43
+ prev: {
44
+ vec: [ProfileVec] | [];
45
+ };
46
+ val: {
47
+ collateral_amount: string;
48
+ };
49
+ };
50
+ export type ProfileBorrowItem = {
51
+ next: {
52
+ vec: [ProfileVec] | [];
53
+ };
54
+ prev: {
55
+ vec: [ProfileVec] | [];
56
+ };
57
+ val: {
58
+ borrowed_share: {
59
+ val: string;
36
60
  };
37
61
  };
38
- total_equity: string;
39
62
  };
40
63
  export type ReserveResponse = {
41
64
  result: {
@@ -22,6 +22,21 @@ const mints = [
22
22
  'BANXbTpN8U2cU41FjPxe2Ti37PiT5cCxLUKDQZuJeMMR', // Banx
23
23
  '4LLbsb5ReP3yEtYzmXewyGjcir5uXtKFURtaEUVC2AHs', // Parcl
24
24
  'SHARKSYJjqaNyxVfrpnBN9pjgkhwDhatnMyicWPnr1s', // Shark
25
+ 'DdFPRnccQqLD4zCHrBqdY95D6hvw6PLWp9DEXj1fLCL9', // Wrapped USDC (Allbridge from Ethereum)
26
+ 'eqKJTf1Do4MDPyKisMYqVaUFpkEFAs3riGF3ceDH2Ca', // Wrapped USDC (Allbridge from Polygon)
27
+ '8Yv9Jz4z7BUHP68dz8E8m3tMe6NKgpMUKn8KVqrPA6Fr', // Wrapped USDC (Allbridge from Avalanche)
28
+ 'FHfba3ov5P3RjaiLVgh8FTv4oirxQDoVXuoUUDvHuXax', // USDC (Wormhole from Avalanche)
29
+ 'Kz1csQA91WUGcQ2TB3o5kdGmWmMGp8eJcDEyHzNDVCX', // USDT (Wormhole from Avalanche)
30
+ '9EaLkQrbjmbbuZG9Wdpo8qfNUEjHATJFSycEmw6f1rGX', // pSOL (Parrot SOL)
31
+ '7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj', // stSOL
32
+ 'Bn113WT6rbdgwrm12UJtnmNqGqZjY4it2WoUQuQopFVn', // Wrapped USDT (Allbridge from Ethereum)
33
+ 'FwEHs3kJEdMa2qZHv7SgzCiFXUQPEycEXksfBkwmS8gj', // Wrapped USDT (Allbridge from Avalanche)
34
+ '8XSsNvaKU9FDhYWAv7Yc7qSNwuJSzVrXBNEk7AFiWF69', // Wrapped USDC (Allbridge from BSC)
35
+ 'E77cpQ4VncGmcAXX16LHFFzNBEBb2U7Ar7LBmZNfCgwL', // Wrapped USDT (Allbridge from BSC)
36
+ 'EjmyN6qEC1Tf1JxiG1ae7UTJhUxSwk1TCWNWqxWV4J6o', // DAI (Portal from Ethereum)
37
+ '5RpUwQ8wtdPCZHhu6MERp2RGrpobsbZ6MH5dDHkUjs2', // BUSD Token (Wormhole from BSC)
38
+ 'FCqfQSujuPxy6V42UvafBhsysWtEq1vhjfMN1PUbgaxA', // USD Coin (Wormhole from BSC)
39
+ '8qJSyQprMC57TWKaYEmetUR3UUiTP2M3hXdcvFhkZdmv', // Tether USD (Wormhole from BSC)
25
40
  ];
26
41
  const vsToken = portfolio_core_1.solanaNativeWrappedAddress;
27
42
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1 +1 @@
1
- {"version":3,"file":"pricingJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/pricingJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAG5C,oDAAkD;AAClD,uCAA6C;AAC7C,mDAA2D;AAC3D,0FAAuF;AACvF,iDAAsD;AAEtD,MAAM,KAAK,GAAG;IACZ,8CAA8C,EAAE,uBAAuB;IACvE,6CAA6C,EAAE,YAAY;IAC3D,8CAA8C,EAAE,OAAO;IACvD,8CAA8C,EAAE,QAAQ;IACxD,6CAA6C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;AAC5C,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,QAAQ;IACR,KAAK,EAAE,WAAW;CACnB,CAAC;AACF,kBAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"pricingJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/pricingJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAG5C,oDAAkD;AAClD,uCAA6C;AAC7C,mDAA2D;AAC3D,0FAAuF;AACvF,iDAAsD;AAEtD,MAAM,KAAK,GAAG;IACZ,8CAA8C,EAAE,uBAAuB;IACvE,6CAA6C,EAAE,YAAY;IAC3D,8CAA8C,EAAE,OAAO;IACvD,8CAA8C,EAAE,QAAQ;IACxD,6CAA6C,EAAE,QAAQ;IACvD,8CAA8C,EAAE,yCAAyC;IACzF,6CAA6C,EAAE,wCAAwC;IACvF,8CAA8C,EAAE,0CAA0C;IAC1F,8CAA8C,EAAE,iCAAiC;IACjF,6CAA6C,EAAE,iCAAiC;IAChF,8CAA8C,EAAE,oBAAoB;IACpE,8CAA8C,EAAE,QAAQ;IACxD,8CAA8C,EAAE,yCAAyC;IACzF,8CAA8C,EAAE,0CAA0C;IAC1F,8CAA8C,EAAE,oCAAoC;IACpF,8CAA8C,EAAE,oCAAoC;IACpF,8CAA8C,EAAE,6BAA6B;IAC7E,6CAA6C,EAAE,iCAAiC;IAChF,8CAA8C,EAAE,+BAA+B;IAC/E,8CAA8C,EAAE,iCAAiC;CAClF,CAAC;AACF,MAAM,OAAO,GAAG,2CAA0B,CAAC;AAE3C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IACrC,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,0BAAS,CAAC,MAAM,CAAC,CAAC;IAC3E,IAAI,CAAC,aAAa;QAAE,OAAO;IAE3B,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAgB,EAAC,OAAO,EAAE,IAAI,mBAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,MAAM,IAAA,mDAAwB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACxE,MAAM,OAAO,GAAuB,EAAE,CAAC;IACvC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,MAAM,GAAqB;YAC/B,OAAO,EAAE,IAAI;YACb,QAAQ;YACR,EAAE,EAAE,aAAa;YACjB,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,KAAK,EAAE,aAAa,CAAC,KAAK,GAAG,KAAK;YAClC,UAAU,EAAE,gCAAoB,CAAC,EAAE;YACnC,MAAM,EAAE,GAAG;SACZ,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,MAAM,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,QAAQ;IACR,KAAK,EAAE,WAAW;CACnB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -17,27 +17,36 @@ const constants_1 = require("./constants");
17
17
  const clients_1 = require("../../utils/clients");
18
18
  const solana_1 = require("../../utils/solana");
19
19
  const struct_1 = require("./struct");
20
- const getTokensPricesMap_1 = __importDefault(require("../../utils/misc/getTokensPricesMap"));
21
20
  const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
22
21
  const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
23
22
  const helpers_1 = require("./helpers");
24
23
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
25
24
  const client = (0, clients_1.getClientSolana)();
26
- const farmsInfo = yield cache.getItem(constants_1.farmsKey, {
25
+ const farms = yield cache.getItem(constants_1.farmsKey, {
27
26
  prefix: constants_1.platformId,
28
27
  networkId: portfolio_core_1.NetworkId.solana,
29
28
  });
30
- if (!farmsInfo)
29
+ if (!farms)
31
30
  return [];
32
- const farmById = new Map();
31
+ const farmsById = new Map();
33
32
  const farmsMint = [];
34
- farmsInfo.forEach((farm) => {
35
- farmById.set(farm.pubkey, farm);
33
+ farms.forEach((farm) => {
34
+ farmsById.set(farm.pubkey, farm);
36
35
  farmsMint.push(farm.pubkey);
37
36
  });
38
37
  const farmingAccountsAddresses = (0, helpers_1.getStakingAccounts)(owner, farmsMint);
39
38
  const farmingAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, struct_1.farmAccountStruct, farmingAccountsAddresses);
40
- const tokenPriceById = yield (0, getTokensPricesMap_1.default)(farmsInfo.map((f) => [f.stakingMint, f.rewardAMint, f.rewardBMint]).flat(), portfolio_core_1.NetworkId.solana, cache);
39
+ const neededMints = farmingAccounts
40
+ .map((fA, i) => {
41
+ if (!fA)
42
+ return [];
43
+ const farm = farms.at(i);
44
+ if (!farm)
45
+ return [];
46
+ return [farm.stakingMint, farm.rewardAMint, farm.rewardBMint];
47
+ })
48
+ .flat();
49
+ const tokenPrices = yield cache.getTokenPricesAsMap(neededMints, portfolio_core_1.NetworkId.solana);
41
50
  const liquidities = [];
42
51
  for (const farmingAccount of farmingAccounts) {
43
52
  if (!farmingAccount)
@@ -45,14 +54,14 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
45
54
  const rewardAssets = [];
46
55
  const assets = [];
47
56
  const { balanceStaked, rewardAPerTokenPending, rewardBPerTokenPending } = farmingAccount;
48
- const farmInfo = farmById.get(farmingAccount.pool.toString());
57
+ const farmInfo = farmsById.get(farmingAccount.pool.toString());
49
58
  if (!farmInfo)
50
59
  continue;
51
60
  const { stakingMint, rewardAMint, rewardBMint } = farmInfo;
52
61
  const [poolTokenPrice, rewardATokenPrice, rewardBTokenPrice] = [
53
- tokenPriceById.get(stakingMint),
54
- tokenPriceById.get(rewardAMint),
55
- tokenPriceById.get(rewardBMint),
62
+ tokenPrices.get(stakingMint),
63
+ tokenPrices.get(rewardAMint),
64
+ tokenPrices.get(rewardBMint),
56
65
  ];
57
66
  if (!poolTokenPrice)
58
67
  continue;