@sonarwatch/portfolio-plugins 0.12.169 → 0.12.171

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/src/Cache.d.ts +2 -1
  4. package/src/Cache.js +3 -3
  5. package/src/Cache.js.map +1 -1
  6. package/src/TokenPriceMap.d.ts +8 -0
  7. package/src/TokenPriceMap.js +21 -0
  8. package/src/TokenPriceMap.js.map +1 -0
  9. package/src/index.js +16 -0
  10. package/src/index.js.map +1 -1
  11. package/src/plugins/adrastea/constants.d.ts +9 -0
  12. package/src/plugins/adrastea/constants.js +19 -0
  13. package/src/plugins/adrastea/constants.js.map +1 -0
  14. package/src/plugins/adrastea/index.d.ts +6 -0
  15. package/src/plugins/adrastea/index.js +13 -0
  16. package/src/plugins/adrastea/index.js.map +1 -0
  17. package/src/plugins/adrastea/positionsFetcher.js +61 -0
  18. package/src/plugins/adrastea/positionsFetcher.js.map +1 -0
  19. package/src/plugins/adrastea/positionsJob.d.ts +3 -0
  20. package/src/plugins/adrastea/positionsJob.js +53 -0
  21. package/src/plugins/adrastea/positionsJob.js.map +1 -0
  22. package/src/plugins/adrastea/structs.d.ts +45 -0
  23. package/src/plugins/adrastea/structs.js +44 -0
  24. package/src/plugins/adrastea/structs.js.map +1 -0
  25. package/src/plugins/adrastea/types.d.ts +4 -0
  26. package/src/plugins/adrastea/types.js +3 -0
  27. package/src/plugins/adrastea/types.js.map +1 -0
  28. package/src/plugins/banx/stakingFetcher.js +11 -15
  29. package/src/plugins/banx/stakingFetcher.js.map +1 -1
  30. package/src/plugins/bluemove/constants.d.ts +7 -0
  31. package/src/plugins/bluemove/constants.js +17 -0
  32. package/src/plugins/bluemove/constants.js.map +1 -0
  33. package/src/plugins/bluemove/index.d.ts +6 -0
  34. package/src/plugins/bluemove/index.js +12 -0
  35. package/src/plugins/bluemove/index.js.map +1 -0
  36. package/src/plugins/bluemove/poolsJob.d.ts +3 -0
  37. package/src/plugins/bluemove/poolsJob.js +97 -0
  38. package/src/plugins/bluemove/poolsJob.js.map +1 -0
  39. package/src/plugins/bluemove/types.d.ts +21 -0
  40. package/src/plugins/bluemove/types.js +3 -0
  41. package/src/plugins/bluemove/types.js.map +1 -0
  42. package/src/plugins/cetus/clmmsFetcher.js +3 -3
  43. package/src/plugins/cetus/clmmsFetcher.js.map +1 -1
  44. package/src/plugins/cetus/constants.d.ts +4 -0
  45. package/src/plugins/cetus/constants.js +5 -1
  46. package/src/plugins/cetus/constants.js.map +1 -1
  47. package/src/plugins/cetus/dcaFetcher.js +77 -0
  48. package/src/plugins/cetus/dcaFetcher.js.map +1 -0
  49. package/src/plugins/cetus/farmsFetcher.js +2 -4
  50. package/src/plugins/cetus/farmsFetcher.js.map +1 -1
  51. package/src/plugins/cetus/index.js +8 -1
  52. package/src/plugins/cetus/index.js.map +1 -1
  53. package/src/plugins/cetus/limitFetcher.d.ts +3 -0
  54. package/src/plugins/cetus/limitFetcher.js +66 -0
  55. package/src/plugins/cetus/limitFetcher.js.map +1 -0
  56. package/src/plugins/cetus/types.d.ts +32 -0
  57. package/src/plugins/deepbook/constants.d.ts +3 -0
  58. package/src/plugins/deepbook/constants.js +4 -1
  59. package/src/plugins/deepbook/constants.js.map +1 -1
  60. package/src/plugins/deepbook/helpers.d.ts +4 -0
  61. package/src/plugins/deepbook/helpers.js +142 -0
  62. package/src/plugins/deepbook/helpers.js.map +1 -0
  63. package/src/plugins/deepbook/index.js +7 -2
  64. package/src/plugins/deepbook/index.js.map +1 -1
  65. package/src/plugins/deepbook/ordersFetcher.d.ts +3 -0
  66. package/src/plugins/deepbook/ordersFetcher.js +74 -0
  67. package/src/plugins/deepbook/ordersFetcher.js.map +1 -0
  68. package/src/plugins/deepbook/poolsJob.d.ts +3 -0
  69. package/src/plugins/deepbook/poolsJob.js +30 -0
  70. package/src/plugins/deepbook/poolsJob.js.map +1 -0
  71. package/src/plugins/deepbook/types.d.ts +12 -0
  72. package/src/plugins/deepbook/types.js +3 -0
  73. package/src/plugins/deepbook/types.js.map +1 -0
  74. package/src/plugins/flowx/stakingPoolFetcher.js +1 -1
  75. package/src/plugins/flowx/stakingPoolFetcher.js.map +1 -1
  76. package/src/plugins/flowx/stakingPoolV3Fetcher.js +1 -1
  77. package/src/plugins/flowx/stakingPoolV3Fetcher.js.map +1 -1
  78. package/src/plugins/foo/constants.d.ts +1 -1
  79. package/src/plugins/foo/constants.js +2 -2
  80. package/src/plugins/foo/constants.js.map +1 -1
  81. package/src/plugins/foo/index.js +2 -2
  82. package/src/plugins/foo/index.js.map +1 -1
  83. package/src/plugins/foo/marketsJob.js +3 -3
  84. package/src/plugins/foo/marketsJob.js.map +1 -1
  85. package/src/plugins/foo/positionsEthereumFetcher.d.ts +3 -0
  86. package/src/plugins/foo/positionsEthereumFetcher.js +33 -0
  87. package/src/plugins/foo/positionsEthereumFetcher.js.map +1 -0
  88. package/src/plugins/foo/positionsSolanaFetcher.js +10 -26
  89. package/src/plugins/foo/positionsSolanaFetcher.js.map +1 -1
  90. package/src/plugins/foo/positionsSuiFetcher.d.ts +3 -0
  91. package/src/plugins/foo/positionsSuiFetcher.js +46 -0
  92. package/src/plugins/foo/positionsSuiFetcher.js.map +1 -0
  93. package/src/plugins/foo/types.d.ts +5 -0
  94. package/src/plugins/foo/types.js +3 -0
  95. package/src/plugins/foo/types.js.map +1 -0
  96. package/src/plugins/francium/constants.d.ts +19 -0
  97. package/src/plugins/francium/constants.js +839 -0
  98. package/src/plugins/francium/constants.js.map +1 -0
  99. package/src/plugins/francium/helpers.d.ts +14 -0
  100. package/src/plugins/francium/helpers.js +85 -0
  101. package/src/plugins/francium/helpers.js.map +1 -0
  102. package/src/plugins/francium/index.d.ts +6 -0
  103. package/src/plugins/francium/index.js +13 -0
  104. package/src/plugins/francium/index.js.map +1 -0
  105. package/src/plugins/francium/lendingFetcher.d.ts +3 -0
  106. package/src/plugins/francium/lendingFetcher.js +70 -0
  107. package/src/plugins/francium/lendingFetcher.js.map +1 -0
  108. package/src/plugins/francium/lendingPoolJob.d.ts +3 -0
  109. package/src/plugins/francium/lendingPoolJob.js +49 -0
  110. package/src/plugins/francium/lendingPoolJob.js.map +1 -0
  111. package/src/plugins/francium/structs.d.ts +59 -0
  112. package/src/plugins/francium/structs.js +49 -0
  113. package/src/plugins/francium/structs.js.map +1 -0
  114. package/src/plugins/francium/tokens.d.ts +9 -0
  115. package/src/plugins/francium/tokens.js +524 -0
  116. package/src/plugins/francium/tokens.js.map +1 -0
  117. package/src/plugins/francium/types.d.ts +16 -0
  118. package/src/plugins/francium/types.js +3 -0
  119. package/src/plugins/francium/types.js.map +1 -0
  120. package/src/plugins/kamino/lendsFetcher.js +64 -167
  121. package/src/plugins/kamino/lendsFetcher.js.map +1 -1
  122. package/src/plugins/kriya/farmsFetcher.js +23 -48
  123. package/src/plugins/kriya/farmsFetcher.js.map +1 -1
  124. package/src/plugins/kriya/leverageVaultsFetcher.js +5 -5
  125. package/src/plugins/kriya/leverageVaultsFetcher.js.map +1 -1
  126. package/src/plugins/meteora/dlmmPositionsFetcher.js +5 -4
  127. package/src/plugins/meteora/dlmmPositionsFetcher.js.map +1 -1
  128. package/src/plugins/meteora/farmsFetcher.js +19 -68
  129. package/src/plugins/meteora/farmsFetcher.js.map +1 -1
  130. package/src/plugins/nxfinance/positionsFetcher.js +32 -80
  131. package/src/plugins/nxfinance/positionsFetcher.js.map +1 -1
  132. package/src/plugins/quarry/positionsFetcher.js +1 -1
  133. package/src/plugins/quarry/positionsFetcher.js.map +1 -1
  134. package/src/plugins/raydium/farmsFetcher.js +30 -74
  135. package/src/plugins/raydium/farmsFetcher.js.map +1 -1
  136. package/src/plugins/raydium/getRaydiumCLMMPositions.js +4 -4
  137. package/src/plugins/raydium/getRaydiumCLMMPositions.js.map +1 -1
  138. package/src/plugins/raydium/helpers.d.ts +3 -2
  139. package/src/plugins/raydium/helpers.js +5 -7
  140. package/src/plugins/raydium/helpers.js.map +1 -1
  141. package/src/plugins/raydium/index.js +1 -2
  142. package/src/plugins/raydium/index.js.map +1 -1
  143. package/src/plugins/raydium/lpTokensJob.js +1 -1
  144. package/src/plugins/raydium/lpTokensJob.js.map +1 -1
  145. package/src/plugins/stabble/constants.d.ts +8 -0
  146. package/src/plugins/stabble/constants.js +27 -0
  147. package/src/plugins/stabble/constants.js.map +1 -0
  148. package/src/plugins/stabble/filters.d.ts +3 -0
  149. package/src/plugins/stabble/filters.js +20 -0
  150. package/src/plugins/stabble/filters.js.map +1 -0
  151. package/src/plugins/stabble/index.d.ts +6 -0
  152. package/src/plugins/stabble/index.js +12 -0
  153. package/src/plugins/stabble/index.js.map +1 -0
  154. package/src/plugins/stabble/poolsJob.d.ts +3 -0
  155. package/src/plugins/stabble/poolsJob.js +84 -0
  156. package/src/plugins/stabble/poolsJob.js.map +1 -0
  157. package/src/plugins/stabble/stableIdl.d.ts +40 -0
  158. package/src/plugins/stabble/stableIdl.js +104 -0
  159. package/src/plugins/stabble/stableIdl.js.map +1 -0
  160. package/src/plugins/stabble/types.d.ts +40 -0
  161. package/src/plugins/stabble/types.js +3 -0
  162. package/src/plugins/stabble/types.js.map +1 -0
  163. package/src/plugins/stabble/weightedIdl.d.ts +40 -0
  164. package/src/plugins/stabble/weightedIdl.js +96 -0
  165. package/src/plugins/stabble/weightedIdl.js.map +1 -0
  166. package/src/utils/bitcoin/getBalance.js +1 -0
  167. package/src/utils/bitcoin/getBalance.js.map +1 -1
  168. package/src/utils/elementbuilder/AssetBuilder.d.ts +11 -0
  169. package/src/utils/elementbuilder/AssetBuilder.js +28 -0
  170. package/src/utils/elementbuilder/AssetBuilder.js.map +1 -0
  171. package/src/utils/elementbuilder/ElementBorrowlendBuilder.d.ts +27 -0
  172. package/src/utils/elementbuilder/ElementBorrowlendBuilder.js +110 -0
  173. package/src/utils/elementbuilder/ElementBorrowlendBuilder.js.map +1 -0
  174. package/src/utils/elementbuilder/ElementBuilder.d.ts +12 -0
  175. package/src/utils/elementbuilder/ElementBuilder.js +13 -0
  176. package/src/utils/elementbuilder/ElementBuilder.js.map +1 -0
  177. package/src/utils/elementbuilder/ElementLiquidityBuilder.d.ts +12 -0
  178. package/src/utils/elementbuilder/ElementLiquidityBuilder.js +42 -0
  179. package/src/utils/elementbuilder/ElementLiquidityBuilder.js.map +1 -0
  180. package/src/utils/elementbuilder/ElementMultipleBuilder.d.ts +13 -0
  181. package/src/utils/elementbuilder/ElementMultipleBuilder.js +40 -0
  182. package/src/utils/elementbuilder/ElementMultipleBuilder.js.map +1 -0
  183. package/src/utils/elementbuilder/ElementParams.d.ts +7 -0
  184. package/src/utils/elementbuilder/ElementParams.js +3 -0
  185. package/src/utils/elementbuilder/ElementParams.js.map +1 -0
  186. package/src/utils/elementbuilder/ElementRegistry.d.ts +17 -0
  187. package/src/utils/elementbuilder/ElementRegistry.js +49 -0
  188. package/src/utils/elementbuilder/ElementRegistry.js.map +1 -0
  189. package/src/utils/elementbuilder/LiquidityBuilder.d.ts +15 -0
  190. package/src/utils/elementbuilder/LiquidityBuilder.js +52 -0
  191. package/src/utils/elementbuilder/LiquidityBuilder.js.map +1 -0
  192. package/src/utils/elementbuilder/PortfolioAssetParams.d.ts +7 -0
  193. package/src/utils/elementbuilder/PortfolioAssetParams.js +3 -0
  194. package/src/utils/elementbuilder/PortfolioAssetParams.js.map +1 -0
  195. package/src/plugins/foo/positionsFetcher.js +0 -49
  196. package/src/plugins/foo/positionsFetcher.js.map +0 -1
  197. package/src/plugins/raydium/stakingFetcher.js +0 -50
  198. package/src/plugins/raydium/stakingFetcher.js.map +0 -1
  199. /package/src/plugins/{foo → adrastea}/positionsFetcher.d.ts +0 -0
  200. /package/src/plugins/{raydium/stakingFetcher.d.ts → cetus/dcaFetcher.d.ts} +0 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WeightedIdl = void 0;
4
+ exports.WeightedIdl = {
5
+ version: '1.0.0',
6
+ name: 'weighted_swap',
7
+ instructions: [],
8
+ accounts: [
9
+ {
10
+ name: 'pool',
11
+ type: {
12
+ kind: 'struct',
13
+ fields: [
14
+ {
15
+ name: 'owner',
16
+ type: 'publicKey',
17
+ },
18
+ {
19
+ name: 'vault',
20
+ type: 'publicKey',
21
+ },
22
+ {
23
+ name: 'mint',
24
+ type: 'publicKey',
25
+ },
26
+ {
27
+ name: 'authorityBump',
28
+ type: 'u8',
29
+ },
30
+ {
31
+ name: 'isActive',
32
+ type: 'bool',
33
+ },
34
+ {
35
+ name: 'invariant',
36
+ type: 'u64',
37
+ },
38
+ {
39
+ name: 'swapFee',
40
+ type: 'u64',
41
+ },
42
+ {
43
+ name: 'tokens',
44
+ type: {
45
+ vec: {
46
+ defined: 'PoolToken',
47
+ },
48
+ },
49
+ },
50
+ {
51
+ name: 'pendingOwner',
52
+ type: {
53
+ option: 'publicKey',
54
+ },
55
+ },
56
+ ],
57
+ },
58
+ },
59
+ ],
60
+ types: [
61
+ {
62
+ name: 'PoolToken',
63
+ type: {
64
+ kind: 'struct',
65
+ fields: [
66
+ {
67
+ name: 'mint',
68
+ type: 'publicKey',
69
+ },
70
+ {
71
+ name: 'decimals',
72
+ type: 'u8',
73
+ },
74
+ {
75
+ name: 'scalingUp',
76
+ type: 'bool',
77
+ },
78
+ {
79
+ name: 'scalingFactor',
80
+ type: 'u64',
81
+ },
82
+ {
83
+ name: 'balance',
84
+ type: 'u64',
85
+ },
86
+ {
87
+ name: 'weight',
88
+ type: 'u64',
89
+ },
90
+ ],
91
+ },
92
+ },
93
+ ],
94
+ errors: [],
95
+ };
96
+ //# sourceMappingURL=weightedIdl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weightedIdl.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/stabble/weightedIdl.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,eAAe;IACrB,YAAY,EAAE,EAAE;IAChB,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,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AAE,EAAE;CACX,CAAC"}
@@ -28,6 +28,7 @@ function getBalance(rpcEndpoint, owner) {
28
28
  const response = yield axios_1.default.get(`/address/${owner}`, {
29
29
  baseURL: rpcEndpoint.url,
30
30
  auth,
31
+ timeout: 20000,
31
32
  });
32
33
  return new bignumber_js_1.default(response.data.chain_stats.funded_txo_sum)
33
34
  .minus(response.data.chain_stats.spent_txo_sum)
@@ -1 +1 @@
1
- {"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/bitcoin/getBalance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,+DAAyE;AACzE,gEAAqC;AAErC,MAAM,QAAQ,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,+BAAc,CAAC,MAAM,CAAC,QAAQ,CAAA,CAAC,CAAC;AAerE,SAAsB,UAAU,CAAC,WAAwB,EAAE,KAAa;;QACtE,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS;YAChC,CAAC,CAAC;gBACE,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ;gBACxC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ;aACzC;YACH,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,YAAY,KAAK,EAAE,EACnB;YACE,OAAO,EAAE,WAAW,CAAC,GAAG;YACxB,IAAI;SACL,CACF,CAAC;QACF,OAAO,IAAI,sBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;aAC3D,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;aAC9C,GAAG,CAAC,QAAQ,CAAC;aACb,QAAQ,EAAE,CAAC;IAChB,CAAC;CAAA;AAnBD,gCAmBC"}
1
+ {"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/bitcoin/getBalance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,+DAAyE;AACzE,gEAAqC;AAErC,MAAM,QAAQ,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,+BAAc,CAAC,MAAM,CAAC,QAAQ,CAAA,CAAC,CAAC;AAerE,SAAsB,UAAU,CAAC,WAAwB,EAAE,KAAa;;QACtE,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS;YAChC,CAAC,CAAC;gBACE,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ;gBACxC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ;aACzC;YACH,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,YAAY,KAAK,EAAE,EACnB;YACE,OAAO,EAAE,WAAW,CAAC,GAAG;YACxB,IAAI;YACJ,OAAO,EAAE,KAAK;SACf,CACF,CAAC;QACF,OAAO,IAAI,sBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;aAC3D,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;aAC9C,GAAG,CAAC,QAAQ,CAAC;aACb,QAAQ,EAAE,CAAC;IAChB,CAAC;CAAA;AApBD,gCAoBC"}
@@ -0,0 +1,11 @@
1
+ import { NetworkIdType, PortfolioAsset } from '@sonarwatch/portfolio-core';
2
+ import BigNumber from 'bignumber.js';
3
+ import { PortfolioAssetParams } from './PortfolioAssetParams';
4
+ import { TokenPriceMap } from '../../TokenPriceMap';
5
+ export declare class AssetBuilder {
6
+ address: string;
7
+ amount: number | BigNumber | string;
8
+ alreadyShifted: boolean;
9
+ constructor(params: PortfolioAssetParams);
10
+ dump(networkId: NetworkIdType, tokenPrices: TokenPriceMap): PortfolioAsset | null;
11
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AssetBuilder = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const tokenPriceToAssetToken_1 = __importDefault(require("../misc/tokenPriceToAssetToken"));
9
+ class AssetBuilder {
10
+ constructor(params) {
11
+ this.address = params.address.toString();
12
+ this.amount = params.amount;
13
+ this.alreadyShifted = params.alreadyShifted || false;
14
+ }
15
+ dump(networkId, tokenPrices) {
16
+ let amount = new bignumber_js_1.default(this.amount);
17
+ if (amount.isZero())
18
+ return null;
19
+ const tokenPrice = tokenPrices.get(this.address);
20
+ if (!tokenPrice)
21
+ return null;
22
+ if (!this.alreadyShifted)
23
+ amount = amount.dividedBy(Math.pow(10, tokenPrice.decimals));
24
+ return (0, tokenPriceToAssetToken_1.default)(tokenPrice.address, amount.toNumber(), networkId, tokenPrice);
25
+ }
26
+ }
27
+ exports.AssetBuilder = AssetBuilder;
28
+ //# sourceMappingURL=AssetBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssetBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/AssetBuilder.ts"],"names":[],"mappings":";;;;;;AACA,gEAAqC;AAErC,4FAAoE;AAGpE,MAAa,YAAY;IAKvB,YAAY,MAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,KAAK,CAAC;IACvD,CAAC;IAED,IAAI,CACF,SAAwB,EACxB,WAA0B;QAE1B,IAAI,MAAM,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,MAAM,EAAE;YAAE,OAAO,IAAI,CAAC;QACjC,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,cAAc;YACtB,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,UAAU,CAAC,QAAQ,CAAA,CAAC,CAAC;QAEvD,OAAO,IAAA,gCAAsB,EAC3B,UAAU,CAAC,OAAO,EAClB,MAAM,CAAC,QAAQ,EAAE,EACjB,SAAS,EACT,UAAU,CACX,CAAC;IACJ,CAAC;CACF;AA9BD,oCA8BC"}
@@ -0,0 +1,27 @@
1
+ import { NetworkIdType, PortfolioElement, Yield } from '@sonarwatch/portfolio-core';
2
+ import { ElementBuilder } from './ElementBuilder';
3
+ import { AssetBuilder } from './AssetBuilder';
4
+ import { ElementParams } from './ElementParams';
5
+ import { PortfolioAssetParams } from './PortfolioAssetParams';
6
+ import { TokenPriceMap } from '../../TokenPriceMap';
7
+ export declare class ElementBorrowlendBuilder extends ElementBuilder {
8
+ borrowedAssets: AssetBuilder[];
9
+ suppliedAssets: AssetBuilder[];
10
+ rewardAssets: AssetBuilder[];
11
+ unsettledAssets: AssetBuilder[];
12
+ borrowedYields: Yield[][];
13
+ suppliedYields: Yield[][];
14
+ suppliedLtvs: number[];
15
+ borrowedWeights: number[];
16
+ constructor(params: ElementParams);
17
+ addBorrowedAsset(params: PortfolioAssetParams): void;
18
+ addSuppliedAsset(params: PortfolioAssetParams): void;
19
+ addRewardAsset(params: PortfolioAssetParams): void;
20
+ addUnsettledAssets(params: PortfolioAssetParams): void;
21
+ addBorrowedYield(ayield: Yield[]): void;
22
+ addSuppliedYield(ayield: Yield[]): void;
23
+ addSuppliedLtv(ltv: number): void;
24
+ addBorrowedWeight(borrowedWeight: number): void;
25
+ mints(): string[];
26
+ dump(networkId: NetworkIdType, platformId: string, tokenPrices: TokenPriceMap): PortfolioElement | null;
27
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElementBorrowlendBuilder = void 0;
4
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
5
+ const ElementBuilder_1 = require("./ElementBuilder");
6
+ const AssetBuilder_1 = require("./AssetBuilder");
7
+ class ElementBorrowlendBuilder extends ElementBuilder_1.ElementBuilder {
8
+ constructor(params) {
9
+ super(params);
10
+ this.borrowedAssets = [];
11
+ this.suppliedAssets = [];
12
+ this.rewardAssets = [];
13
+ this.unsettledAssets = [];
14
+ this.borrowedYields = [];
15
+ this.suppliedYields = [];
16
+ this.suppliedLtvs = [];
17
+ this.borrowedWeights = [];
18
+ }
19
+ addBorrowedAsset(params) {
20
+ this.borrowedAssets.push(new AssetBuilder_1.AssetBuilder(params));
21
+ }
22
+ addSuppliedAsset(params) {
23
+ this.suppliedAssets.push(new AssetBuilder_1.AssetBuilder(params));
24
+ }
25
+ addRewardAsset(params) {
26
+ this.rewardAssets.push(new AssetBuilder_1.AssetBuilder(params));
27
+ }
28
+ addUnsettledAssets(params) {
29
+ this.unsettledAssets.push(new AssetBuilder_1.AssetBuilder(params));
30
+ }
31
+ addBorrowedYield(ayield) {
32
+ this.borrowedYields.push(ayield);
33
+ }
34
+ addSuppliedYield(ayield) {
35
+ this.suppliedYields.push(ayield);
36
+ }
37
+ addSuppliedLtv(ltv) {
38
+ this.suppliedLtvs.push(ltv);
39
+ }
40
+ addBorrowedWeight(borrowedWeight) {
41
+ this.borrowedWeights.push(borrowedWeight);
42
+ }
43
+ mints() {
44
+ return [
45
+ ...this.borrowedAssets,
46
+ ...this.suppliedAssets,
47
+ ...this.rewardAssets,
48
+ ].map((a) => a.address);
49
+ }
50
+ dump(networkId, platformId, tokenPrices) {
51
+ const suppliedAssets = this.suppliedAssets
52
+ .map((a) => a.dump(networkId, tokenPrices))
53
+ .filter((a) => a !== null);
54
+ const borrowedAssets = this.borrowedAssets
55
+ .map((a) => a.dump(networkId, tokenPrices))
56
+ .filter((a) => a !== null);
57
+ const rewardAssets = this.rewardAssets
58
+ .map((a) => a.dump(networkId, tokenPrices))
59
+ .filter((a) => a !== null);
60
+ const unsettledAssets = this.unsettledAssets
61
+ .map((a) => a.dump(networkId, tokenPrices))
62
+ .filter((a) => a !== null);
63
+ if (suppliedAssets.length === 0 &&
64
+ borrowedAssets.length === 0 &&
65
+ rewardAssets.length === 0)
66
+ return null;
67
+ const { borrowedValue, suppliedValue, rewardValue, healthRatio, unsettledValue, value, } = (0, portfolio_core_1.getElementLendingValues)({
68
+ suppliedAssets,
69
+ borrowedAssets,
70
+ rewardAssets,
71
+ suppliedLtvs: this.suppliedLtvs.length === suppliedAssets.length
72
+ ? this.suppliedLtvs
73
+ : undefined,
74
+ borrowedWeights: this.borrowedWeights.length === borrowedAssets.length
75
+ ? this.borrowedWeights
76
+ : undefined,
77
+ unsettledAssets,
78
+ });
79
+ if (!suppliedValue && !borrowedValue && !rewardValue)
80
+ return null;
81
+ const element = {
82
+ type: this.type,
83
+ label: this.label,
84
+ networkId,
85
+ platformId,
86
+ data: {
87
+ borrowedAssets,
88
+ borrowedValue,
89
+ borrowedYields: this.borrowedYields,
90
+ suppliedAssets,
91
+ suppliedValue,
92
+ suppliedYields: this.suppliedYields,
93
+ rewardAssets,
94
+ rewardValue,
95
+ healthRatio,
96
+ unsettled: {
97
+ assets: unsettledAssets,
98
+ value: unsettledValue,
99
+ },
100
+ value,
101
+ },
102
+ value,
103
+ name: this.name,
104
+ tags: this.tags,
105
+ };
106
+ return element;
107
+ }
108
+ }
109
+ exports.ElementBorrowlendBuilder = ElementBorrowlendBuilder;
110
+ //# sourceMappingURL=ElementBorrowlendBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementBorrowlendBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementBorrowlendBuilder.ts"],"names":[],"mappings":";;;AAAA,+DAMoC;AACpC,qDAAkD;A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ID,4DA2IC"}
@@ -0,0 +1,12 @@
1
+ import { NetworkIdType, PortfolioElement, PortfolioElementLabel, PortfolioElementTypeType } from '@sonarwatch/portfolio-core';
2
+ import { ElementParams } from './ElementParams';
3
+ import { TokenPriceMap } from '../../TokenPriceMap';
4
+ export declare abstract class ElementBuilder {
5
+ readonly type: PortfolioElementTypeType;
6
+ readonly label: PortfolioElementLabel;
7
+ readonly name?: string;
8
+ readonly tags?: string[];
9
+ protected constructor(params: ElementParams);
10
+ abstract mints(): string[];
11
+ abstract dump(networkId: NetworkIdType, platformId: string, tokenPrices: TokenPriceMap): PortfolioElement | null;
12
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElementBuilder = void 0;
4
+ class ElementBuilder {
5
+ constructor(params) {
6
+ this.type = params.type;
7
+ this.label = params.label;
8
+ this.name = params.name;
9
+ this.tags = params.tags;
10
+ }
11
+ }
12
+ exports.ElementBuilder = ElementBuilder;
13
+ //# sourceMappingURL=ElementBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementBuilder.ts"],"names":[],"mappings":";;;AASA,MAAsB,cAAc;IAMlC,YAAsB,MAAqB;QACzC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CASF;AApBD,wCAoBC"}
@@ -0,0 +1,12 @@
1
+ import { NetworkIdType, PortfolioElement } from '@sonarwatch/portfolio-core';
2
+ import { ElementBuilder } from './ElementBuilder';
3
+ import { ElementParams } from './ElementParams';
4
+ import { TokenPriceMap } from '../../TokenPriceMap';
5
+ import { LiquidityBuilder } from './LiquidityBuilder';
6
+ export declare class ElementLiquidityBuilder extends ElementBuilder {
7
+ liquidities: LiquidityBuilder[];
8
+ constructor(params: ElementParams);
9
+ addLiquidity(): LiquidityBuilder;
10
+ mints(): string[];
11
+ dump(networkId: NetworkIdType, platformId: string, tokenPrices: TokenPriceMap): PortfolioElement | null;
12
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElementLiquidityBuilder = void 0;
4
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
5
+ const ElementBuilder_1 = require("./ElementBuilder");
6
+ const LiquidityBuilder_1 = require("./LiquidityBuilder");
7
+ class ElementLiquidityBuilder extends ElementBuilder_1.ElementBuilder {
8
+ constructor(params) {
9
+ super(params);
10
+ this.liquidities = [];
11
+ }
12
+ addLiquidity() {
13
+ const liquidityBuilder = new LiquidityBuilder_1.LiquidityBuilder();
14
+ this.liquidities.push(liquidityBuilder);
15
+ return liquidityBuilder;
16
+ }
17
+ mints() {
18
+ return this.liquidities.map((liquidity) => liquidity.mints()).flat();
19
+ }
20
+ dump(networkId, platformId, tokenPrices) {
21
+ const liquidities = this.liquidities
22
+ .map((l) => l.export(networkId, tokenPrices))
23
+ .filter((a) => a !== null);
24
+ if (liquidities.length === 0)
25
+ return null;
26
+ const element = {
27
+ type: this.type,
28
+ label: this.label,
29
+ networkId,
30
+ platformId,
31
+ data: {
32
+ liquidities,
33
+ },
34
+ value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((asset) => asset.value)),
35
+ name: this.name,
36
+ tags: this.tags,
37
+ };
38
+ return element;
39
+ }
40
+ }
41
+ exports.ElementLiquidityBuilder = ElementLiquidityBuilder;
42
+ //# sourceMappingURL=ElementLiquidityBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementLiquidityBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementLiquidityBuilder.ts"],"names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OAAO,OAAoC,CAAC;IAC9C,CAAC;CACF;AA5CD,0DA4CC"}
@@ -0,0 +1,13 @@
1
+ import { NetworkIdType, PortfolioElement } from '@sonarwatch/portfolio-core';
2
+ import { ElementBuilder } from './ElementBuilder';
3
+ import { AssetBuilder } from './AssetBuilder';
4
+ import { ElementParams } from './ElementParams';
5
+ import { PortfolioAssetParams } from './PortfolioAssetParams';
6
+ import { TokenPriceMap } from '../../TokenPriceMap';
7
+ export declare class ElementMultipleBuilder extends ElementBuilder {
8
+ assets: AssetBuilder[];
9
+ constructor(params: ElementParams);
10
+ addAsset(params: PortfolioAssetParams): void;
11
+ mints(): string[];
12
+ dump(networkId: NetworkIdType, platformId: string, tokenPrices: TokenPriceMap): PortfolioElement | null;
13
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElementMultipleBuilder = void 0;
4
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
5
+ const ElementBuilder_1 = require("./ElementBuilder");
6
+ const AssetBuilder_1 = require("./AssetBuilder");
7
+ class ElementMultipleBuilder extends ElementBuilder_1.ElementBuilder {
8
+ constructor(params) {
9
+ super(params);
10
+ this.assets = [];
11
+ }
12
+ addAsset(params) {
13
+ this.assets.push(new AssetBuilder_1.AssetBuilder(params));
14
+ }
15
+ mints() {
16
+ return this.assets.map((a) => a.address);
17
+ }
18
+ dump(networkId, platformId, tokenPrices) {
19
+ const assets = this.assets
20
+ .map((a) => a.dump(networkId, tokenPrices))
21
+ .filter((a) => a !== null);
22
+ if (assets.length === 0)
23
+ return null;
24
+ const element = {
25
+ type: this.type,
26
+ label: this.label,
27
+ networkId,
28
+ platformId,
29
+ data: {
30
+ assets,
31
+ },
32
+ value: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
33
+ name: this.name,
34
+ tags: this.tags,
35
+ };
36
+ return element;
37
+ }
38
+ }
39
+ exports.ElementMultipleBuilder = ElementMultipleBuilder;
40
+ //# sourceMappingURL=ElementMultipleBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementMultipleBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementMultipleBuilder.ts"],"names":[],"mappings":";;;AAAA,+DAKoC;AACpC,qDAAkD;AAClD,iDAA8C;AAK9C,MAAa,sBAAuB,SAAQ,+BAAc;IAGxD,YAAY,MAAqB;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,QAAQ,CAAC,MAA4B;QACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,2BAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,CACF,SAAwB,EACxB,UAAkB,EAClB,WAA0B;QAE1B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;aACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;aAC1C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAqB,CAAC;QAEjD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAErC,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS;YACT,UAAU;YACV,IAAI,EAAE;gBACJ,MAAM;aACP;YACD,KAAK,EAAE,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACzD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;QAEF,OAAO,OAA2B,CAAC;IACrC,CAAC;CACF;AA1CD,wDA0CC"}
@@ -0,0 +1,7 @@
1
+ import { PortfolioElementLabel, PortfolioElementTypeType } from '@sonarwatch/portfolio-core';
2
+ export type ElementParams = {
3
+ type: PortfolioElementTypeType;
4
+ label: PortfolioElementLabel;
5
+ name?: string;
6
+ tags?: string[];
7
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ElementParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementParams.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementParams.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { NetworkIdType, PortfolioElement } from '@sonarwatch/portfolio-core';
2
+ import { ElementBuilder } from './ElementBuilder';
3
+ import { ElementParams } from './ElementParams';
4
+ import { Cache } from '../../Cache';
5
+ import { ElementMultipleBuilder } from './ElementMultipleBuilder';
6
+ import { ElementLiquidityBuilder } from './ElementLiquidityBuilder';
7
+ import { ElementBorrowlendBuilder } from './ElementBorrowlendBuilder';
8
+ export declare class ElementRegistry {
9
+ readonly networkId: NetworkIdType;
10
+ readonly platformId: string;
11
+ elements: ElementBuilder[];
12
+ constructor(networkId: NetworkIdType, platformId: string);
13
+ addElementMultiple(params: Omit<ElementParams, 'type'>): ElementMultipleBuilder;
14
+ addElementLiquidity(params: Omit<ElementParams, 'type'>): ElementLiquidityBuilder;
15
+ addElementBorrowlend(params: Omit<ElementParams, 'type'>): ElementBorrowlendBuilder;
16
+ dump(cache: Cache): Promise<PortfolioElement[]>;
17
+ }
@@ -0,0 +1,49 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ElementRegistry = void 0;
13
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
14
+ const ElementMultipleBuilder_1 = require("./ElementMultipleBuilder");
15
+ const ElementLiquidityBuilder_1 = require("./ElementLiquidityBuilder");
16
+ const ElementBorrowlendBuilder_1 = require("./ElementBorrowlendBuilder");
17
+ class ElementRegistry {
18
+ constructor(networkId, platformId) {
19
+ this.networkId = networkId;
20
+ this.platformId = platformId;
21
+ this.elements = [];
22
+ }
23
+ addElementMultiple(params) {
24
+ const elementBuilder = new ElementMultipleBuilder_1.ElementMultipleBuilder(Object.assign({ type: portfolio_core_1.PortfolioElementType.multiple }, params));
25
+ this.elements.push(elementBuilder);
26
+ return elementBuilder;
27
+ }
28
+ addElementLiquidity(params) {
29
+ const elementBuilder = new ElementLiquidityBuilder_1.ElementLiquidityBuilder(Object.assign({ type: portfolio_core_1.PortfolioElementType.liquidity }, params));
30
+ this.elements.push(elementBuilder);
31
+ return elementBuilder;
32
+ }
33
+ addElementBorrowlend(params) {
34
+ const elementBuilder = new ElementBorrowlendBuilder_1.ElementBorrowlendBuilder(Object.assign({ type: portfolio_core_1.PortfolioElementType.borrowlend }, params));
35
+ this.elements.push(elementBuilder);
36
+ return elementBuilder;
37
+ }
38
+ dump(cache) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const mints = this.elements.map((e) => e.mints()).flat();
41
+ const tokenPrices = yield cache.getTokenPricesAsMap(mints, this.networkId);
42
+ return this.elements
43
+ .map((e) => e.dump(this.networkId, this.platformId, tokenPrices))
44
+ .filter((e) => e !== null && e.value && e.value > 0);
45
+ });
46
+ }
47
+ }
48
+ exports.ElementRegistry = ElementRegistry;
49
+ //# sourceMappingURL=ElementRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementRegistry.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAMoC;AAIpC,qEAAkE;AAClE,uEAAoE;AACpE,yEAAsE;AAEtE,MAAa,eAAe;IAK1B,YAAY,SAAwB,EAAE,UAAkB;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IACD,kBAAkB,CAChB,MAAmC;QAEnC,MAAM,cAAc,GAAG,IAAI,+CAAsB,iBAC/C,IAAI,EAAE,qCAAoB,CAAC,QAAQ,IAChC,MAAM,EACT,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,mBAAmB,CACjB,MAAmC;QAEnC,MAAM,cAAc,GAAG,IAAI,iDAAuB,iBAChD,IAAI,EAAE,qCAAoB,CAAC,SAAS,IACjC,MAAM,EACT,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,oBAAoB,CAClB,MAAmC;QAEnC,MAAM,cAAc,GAAG,IAAI,mDAAwB,iBACjD,IAAI,EAAE,qCAAoB,CAAC,UAAU,IAClC,MAAM,EACT,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,cAAc,CAAC;IACxB,CAAC;IAEK,IAAI,CAAC,KAAY;;YACrB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACzD,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAE3E,OAAO,IAAI,CAAC,QAAQ;iBACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;iBAChE,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CACtB,CAAC;QAC5B,CAAC;KAAA;CACF;AArDD,0CAqDC"}
@@ -0,0 +1,15 @@
1
+ import { NetworkIdType, PortfolioLiquidity, Yield } from '@sonarwatch/portfolio-core';
2
+ import { TokenPriceMap } from '../../TokenPriceMap';
3
+ import { AssetBuilder } from './AssetBuilder';
4
+ import { PortfolioAssetParams } from './PortfolioAssetParams';
5
+ export declare class LiquidityBuilder {
6
+ assets: AssetBuilder[];
7
+ rewardAssets: AssetBuilder[];
8
+ yields: Yield[];
9
+ constructor();
10
+ addAsset(params: PortfolioAssetParams): void;
11
+ addRewardAsset(params: PortfolioAssetParams): void;
12
+ addYield(ayield: Yield): void;
13
+ mints(): string[];
14
+ export(networkId: NetworkIdType, tokenPrices: TokenPriceMap): PortfolioLiquidity | null;
15
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiquidityBuilder = void 0;
4
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
5
+ const AssetBuilder_1 = require("./AssetBuilder");
6
+ class LiquidityBuilder {
7
+ constructor() {
8
+ this.assets = [];
9
+ this.rewardAssets = [];
10
+ this.yields = [];
11
+ }
12
+ addAsset(params) {
13
+ this.assets.push(new AssetBuilder_1.AssetBuilder(params));
14
+ }
15
+ addRewardAsset(params) {
16
+ this.rewardAssets.push(new AssetBuilder_1.AssetBuilder(params));
17
+ }
18
+ addYield(ayield) {
19
+ this.yields.push(ayield);
20
+ }
21
+ mints() {
22
+ return [
23
+ ...this.assets.map((a) => a.address),
24
+ ...this.rewardAssets.map((a) => a.address),
25
+ ];
26
+ }
27
+ export(networkId, tokenPrices) {
28
+ const assets = this.assets
29
+ .map((a) => a.dump(networkId, tokenPrices))
30
+ .filter((a) => a !== null);
31
+ const rewardAssets = this.rewardAssets
32
+ .map((a) => a.dump(networkId, tokenPrices))
33
+ .filter((a) => a !== null);
34
+ if (assets.length === 0 && rewardAssets.length === 0)
35
+ return null;
36
+ const assetsValue = (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value));
37
+ const rewardAssetsValue = (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((asset) => asset.value));
38
+ const value = (assetsValue || 0) + (rewardAssetsValue || 0);
39
+ if (value === 0)
40
+ return null;
41
+ return {
42
+ assets,
43
+ assetsValue,
44
+ rewardAssets,
45
+ rewardAssetsValue,
46
+ value,
47
+ yields: this.yields,
48
+ };
49
+ }
50
+ }
51
+ exports.LiquidityBuilder = LiquidityBuilder;
52
+ //# sourceMappingURL=LiquidityBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiquidityBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/LiquidityBuilder.ts"],"names":[],"mappings":";;;AAAA,+DAMoC;AAEpC,iDAA8C;AAG9C,MAAa,gBAAgB;IAK3B;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,QAAQ,CAAC,MAA4B;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,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACvE,MAAM,iBAAiB,GAAG,IAAA,+BAAc,EACtC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CACzC,CAAC;QACF,MAAM,KAAK,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC,CAAC;QAE5D,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAE7B,OAAO;YACL,MAAM;YACN,WAAW;YACX,YAAY;YACZ,iBAAiB;YACjB,KAAK;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;SACE,CAAC;IAC1B,CAAC;CACF;AA5DD,4CA4DC"}
@@ -0,0 +1,7 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { PublicKey } from '@solana/web3.js';
3
+ export type PortfolioAssetParams = {
4
+ address: string | PublicKey;
5
+ amount: number | BigNumber | string;
6
+ alreadyShifted?: boolean;
7
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PortfolioAssetParams.js.map