@sonarwatch/portfolio-plugins 0.14.143 → 0.14.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +1 -1
  3. package/src/plugins/banx/constants.d.ts +14 -8
  4. package/src/plugins/banx/constants.js +25 -13
  5. package/src/plugins/banx/constants.js.map +1 -1
  6. package/src/plugins/banx/index.js +12 -2
  7. package/src/plugins/banx/index.js.map +1 -1
  8. package/src/plugins/banx/loansFetcher.js +108 -123
  9. package/src/plugins/banx/loansFetcher.js.map +1 -1
  10. package/src/plugins/banx/marketsJob.js +40 -0
  11. package/src/plugins/banx/marketsJob.js.map +1 -0
  12. package/src/plugins/banx/offersFetcher.js +61 -70
  13. package/src/plugins/banx/offersFetcher.js.map +1 -1
  14. package/src/plugins/banx/stakingFetcher.js +6 -3
  15. package/src/plugins/banx/stakingFetcher.js.map +1 -1
  16. package/src/plugins/banx/structs.d.ts +222 -2
  17. package/src/plugins/banx/structs.js +216 -2
  18. package/src/plugins/banx/structs.js.map +1 -1
  19. package/src/plugins/banx/types.d.ts +50 -258
  20. package/src/plugins/banx/vaultsFetcher.d.ts +3 -0
  21. package/src/plugins/banx/vaultsFetcher.js +74 -0
  22. package/src/plugins/banx/vaultsFetcher.js.map +1 -0
  23. package/src/plugins/banx/vaultsJob.d.ts +3 -0
  24. package/src/plugins/banx/{collectionsJob.js → vaultsJob.js} +5 -16
  25. package/src/plugins/banx/vaultsJob.js.map +1 -0
  26. package/src/plugins/banx/collectionsJob.js.map +0 -1
  27. package/src/plugins/banx/filters.d.ts +0 -6
  28. package/src/plugins/banx/filters.js +0 -39
  29. package/src/plugins/banx/filters.js.map +0 -1
  30. package/src/plugins/banx/helpers.d.ts +0 -5
  31. package/src/plugins/banx/helpers.js +0 -64
  32. package/src/plugins/banx/helpers.js.map +0 -1
  33. package/src/plugins/banx/idl.d.ts +0 -123
  34. package/src/plugins/banx/idl.js +0 -2187
  35. package/src/plugins/banx/idl.js.map +0 -1
  36. /package/src/plugins/banx/{collectionsJob.d.ts → marketsJob.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.14.144](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.143...plugins-0.14.144) (2025-03-17)
6
+
7
+
8
+
5
9
  ## [0.14.143](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.142...plugins-0.14.143) (2025-03-14)
6
10
 
7
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonarwatch/portfolio-plugins",
3
- "version": "0.14.143",
3
+ "version": "0.14.144",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "peerDependencies": {
@@ -2,16 +2,22 @@
2
2
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
3
3
  import { PublicKey } from '@solana/web3.js';
4
4
  import { Platform } from '@sonarwatch/portfolio-core';
5
- import { IdlItem } from '@solanafm/explorer-kit-idls';
5
+ import { MemoizedCache } from '../../utils/misc/MemoizedCache';
6
+ import { Collection, SplAssetMarket, Vault } from './types';
6
7
  export declare const platformId = "banx";
7
8
  export declare const banxMint = "BANXbTpN8U2cU41FjPxe2Ti37PiT5cCxLUKDQZuJeMMR";
9
+ export declare const banxDecimals = 9;
10
+ export declare const banxSolMint = "BANXyWgPpa519e2MtQF1ecRbKYKKDMXPF1dyBxUq9NQG";
8
11
  export declare const platform: Platform;
9
12
  export declare const banxPid: PublicKey;
10
- export declare const banxDecimals = 9;
11
- export declare const banxApiUrl = "https://api.banx.gg/staking/v2/info?walletPubkey=";
12
- export declare const banxApiCollectionsUrl = "https://api.banx.gg/bonds/preview?isPrivate=false&getAll=true";
13
- export declare const collectionsCacheKey = "banx-collections";
13
+ export declare const banxVaultsPid: PublicKey;
14
+ export declare const banxApiCollectionsUrl = "https://api.banx.gg/bonds/preview?getAll=true&marketType=banxSol&isPrivate=false";
15
+ export declare const banxApiMarketsUrl = "https://api.banx.gg/spl-assets/undefined?isPrivate=false&marketType=usdc";
16
+ export declare const banxApiVaultsUrl = "https://api.banx.gg/vaults/preview?walletPublicKey=&getAll=true&isPrivate=false";
17
+ export declare const nftMarketsCacheKey = "banx-nft-markets";
18
+ export declare const splMarketsCacheKey = "banx-spl-markets";
19
+ export declare const vaultsCacheKey = "banx-spl-vaults";
14
20
  export declare const cachePrefix = "banx";
15
- export declare const bondOfferDataSize = 208;
16
- export declare const bondTradeTransactionV3DataSize = 336;
17
- export declare const banxIdlItem: IdlItem;
21
+ export declare const splMarketsMemo: MemoizedCache<SplAssetMarket[], Map<string, SplAssetMarket>>;
22
+ export declare const nftMarketsMemo: MemoizedCache<Collection[], Map<string, Collection>>;
23
+ export declare const vaultsMemo: MemoizedCache<Vault[], Map<string, Vault>>;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.banxIdlItem = exports.bondTradeTransactionV3DataSize = exports.bondOfferDataSize = exports.cachePrefix = exports.collectionsCacheKey = exports.banxApiCollectionsUrl = exports.banxApiUrl = exports.banxDecimals = exports.banxPid = exports.platform = exports.banxMint = exports.platformId = void 0;
3
+ exports.vaultsMemo = exports.nftMarketsMemo = exports.splMarketsMemo = exports.cachePrefix = exports.vaultsCacheKey = exports.splMarketsCacheKey = exports.nftMarketsCacheKey = exports.banxApiVaultsUrl = exports.banxApiMarketsUrl = exports.banxApiCollectionsUrl = exports.banxVaultsPid = exports.banxPid = exports.platform = exports.banxSolMint = exports.banxDecimals = exports.banxMint = exports.platformId = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
- const idl_1 = require("./idl");
5
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
6
+ const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
7
+ const arrayToMap_1 = require("../../utils/misc/arrayToMap");
6
8
  exports.platformId = 'banx';
7
9
  exports.banxMint = 'BANXbTpN8U2cU41FjPxe2Ti37PiT5cCxLUKDQZuJeMMR';
10
+ exports.banxDecimals = 9;
11
+ exports.banxSolMint = 'BANXyWgPpa519e2MtQF1ecRbKYKKDMXPF1dyBxUq9NQG';
8
12
  exports.platform = {
9
13
  id: exports.platformId,
10
14
  name: 'Banx',
@@ -19,16 +23,24 @@ exports.platform = {
19
23
  tokens: [exports.banxMint],
20
24
  };
21
25
  exports.banxPid = new web3_js_1.PublicKey('4tdmkuY6EStxbS6Y8s5ueznL3VPMSugrvQuDeAHGZhSt');
22
- exports.banxDecimals = 9;
23
- exports.banxApiUrl = 'https://api.banx.gg/staking/v2/info?walletPubkey=';
24
- exports.banxApiCollectionsUrl = 'https://api.banx.gg/bonds/preview?isPrivate=false&getAll=true';
25
- exports.collectionsCacheKey = `${exports.platformId}-collections`;
26
+ exports.banxVaultsPid = new web3_js_1.PublicKey('BanxxEcFZPJLKhS59EkwTa8SZez8vDYTiJVN78mGHWDi');
27
+ exports.banxApiCollectionsUrl = 'https://api.banx.gg/bonds/preview?getAll=true&marketType=banxSol&isPrivate=false';
28
+ exports.banxApiMarketsUrl = 'https://api.banx.gg/spl-assets/undefined?isPrivate=false&marketType=usdc';
29
+ exports.banxApiVaultsUrl = 'https://api.banx.gg/vaults/preview?walletPublicKey=&getAll=true&isPrivate=false';
30
+ exports.nftMarketsCacheKey = `${exports.platformId}-nft-markets`;
31
+ exports.splMarketsCacheKey = `${exports.platformId}-spl-markets`;
32
+ exports.vaultsCacheKey = `${exports.platformId}-spl-vaults`;
26
33
  exports.cachePrefix = `${exports.platformId}`;
27
- exports.bondOfferDataSize = 208;
28
- exports.bondTradeTransactionV3DataSize = 336;
29
- exports.banxIdlItem = {
30
- programId: exports.banxPid.toString(),
31
- idl: idl_1.BanxIDL,
32
- idlType: 'anchor',
33
- };
34
+ exports.splMarketsMemo = new MemoizedCache_1.MemoizedCache(exports.splMarketsCacheKey, {
35
+ prefix: exports.cachePrefix,
36
+ networkId: portfolio_core_1.NetworkId.solana,
37
+ }, (arr) => (0, arrayToMap_1.arrayToMap)(arr || [], 'marketPubkey'));
38
+ exports.nftMarketsMemo = new MemoizedCache_1.MemoizedCache(exports.nftMarketsCacheKey, {
39
+ prefix: exports.cachePrefix,
40
+ networkId: portfolio_core_1.NetworkId.solana,
41
+ }, (arr) => (0, arrayToMap_1.arrayToMap)(arr || [], 'marketPubkey'));
42
+ exports.vaultsMemo = new MemoizedCache_1.MemoizedCache(exports.vaultsCacheKey, {
43
+ prefix: exports.cachePrefix,
44
+ networkId: portfolio_core_1.NetworkId.solana,
45
+ }, (arr) => (0, arrayToMap_1.arrayToMap)(arr || [], 'vaultPubkey'));
34
46
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG5C,+BAAgC;AAEnB,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAG,8CAA8C,CAAC;AAC1D,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EACH,0EAA0E;IAC5E,WAAW,EAAE,MAAM,EAAE,sCAAsC;IAC3D,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,6BAA6B;IACtC,WAAW,EACT,gGAAgG;IAClG,aAAa,EAAE,uBAAuB;IACtC,OAAO,EAAE,0CAA0C;IACnD,MAAM,EAAE,iCAAiC;IACzC,MAAM,EAAE,CAAC,gBAAQ,CAAC;CACnB,CAAC;AAEW,QAAA,OAAO,GAAG,IAAI,mBAAS,CAClC,8CAA8C,CAC/C,CAAC;AACW,QAAA,YAAY,GAAG,CAAC,CAAC;AACjB,QAAA,UAAU,GAAG,mDAAmD,CAAC;AAEjE,QAAA,qBAAqB,GAChC,+DAA+D,CAAC;AAErD,QAAA,mBAAmB,GAAG,GAAG,kBAAU,cAAc,CAAC;AAClD,QAAA,WAAW,GAAG,GAAG,kBAAU,EAAE,CAAC;AAE9B,QAAA,iBAAiB,GAAG,GAAG,CAAC;AACxB,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAErC,QAAA,WAAW,GAAG;IACzB,SAAS,EAAE,eAAO,CAAC,QAAQ,EAAE;IAC7B,GAAG,EAAE,aAAO;IACZ,OAAO,EAAE,QAAQ;CACP,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,+DAAiE;AACjE,kEAA+D;AAE/D,4DAAyD;AAE5C,QAAA,UAAU,GAAG,MAAM,CAAC;AAEpB,QAAA,QAAQ,GAAG,8CAA8C,CAAC;AAC1D,QAAA,YAAY,GAAG,CAAC,CAAC;AACjB,QAAA,WAAW,GAAG,8CAA8C,CAAC;AAE7D,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EACH,0EAA0E;IAC5E,WAAW,EAAE,MAAM,EAAE,sCAAsC;IAC3D,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,6BAA6B;IACtC,WAAW,EACT,gGAAgG;IAClG,aAAa,EAAE,uBAAuB;IACtC,OAAO,EAAE,0CAA0C;IACnD,MAAM,EAAE,iCAAiC;IACzC,MAAM,EAAE,CAAC,gBAAQ,CAAC;CACnB,CAAC;AAEW,QAAA,OAAO,GAAG,IAAI,mBAAS,CAClC,8CAA8C,CAC/C,CAAC;AACW,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,8CAA8C,CAC/C,CAAC;AAEW,QAAA,qBAAqB,GAChC,kFAAkF,CAAC;AACxE,QAAA,iBAAiB,GAC5B,0EAA0E,CAAC;AAChE,QAAA,gBAAgB,GAC3B,iFAAiF,CAAC;AAEvE,QAAA,kBAAkB,GAAG,GAAG,kBAAU,cAAc,CAAC;AACjD,QAAA,kBAAkB,GAAG,GAAG,kBAAU,cAAc,CAAC;AACjD,QAAA,cAAc,GAAG,GAAG,kBAAU,aAAa,CAAC;AAC5C,QAAA,WAAW,GAAG,GAAG,kBAAU,EAAE,CAAC;AAE9B,QAAA,cAAc,GAAG,IAAI,6BAAa,CAI7C,0BAAkB,EAClB;IACE,MAAM,EAAE,mBAAW;IACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;CAC5B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAU,EAAC,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,CAC/C,CAAC;AACW,QAAA,cAAc,GAAG,IAAI,6BAAa,CAI7C,0BAAkB,EAClB;IACE,MAAM,EAAE,mBAAW;IACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;CAC5B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAU,EAAC,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,CAC/C,CAAC;AAEW,QAAA,UAAU,GAAG,IAAI,6BAAa,CACzC,sBAAc,EACd;IACE,MAAM,EAAE,mBAAW;IACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;CAC5B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAU,EAAC,GAAG,IAAI,EAAE,EAAE,aAAa,CAAC,CAC9C,CAAC"}
@@ -6,7 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchers = exports.jobs = exports.platforms = void 0;
7
7
  const constants_1 = require("./constants");
8
8
  const stakingFetcher_1 = __importDefault(require("./stakingFetcher"));
9
+ const marketsJob_1 = __importDefault(require("./marketsJob"));
10
+ const loansFetcher_1 = __importDefault(require("./loansFetcher"));
11
+ const offersFetcher_1 = __importDefault(require("./offersFetcher"));
12
+ const vaultsJob_1 = __importDefault(require("./vaultsJob"));
13
+ const vaultsFetcher_1 = __importDefault(require("./vaultsFetcher"));
9
14
  exports.platforms = [constants_1.platform];
10
- exports.jobs = [];
11
- exports.fetchers = [stakingFetcher_1.default];
15
+ exports.jobs = [marketsJob_1.default, vaultsJob_1.default];
16
+ exports.fetchers = [
17
+ stakingFetcher_1.default,
18
+ loansFetcher_1.default,
19
+ offersFetcher_1.default,
20
+ vaultsFetcher_1.default,
21
+ ];
12
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,sEAA8C;AAEjC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,CAAC,wBAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,sEAA8C;AAC9C,8DAAsC;AACtC,kEAA0C;AAC1C,oEAA4C;AAC5C,4DAAoC;AACpC,oEAA4C;AAE/B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,oBAAU,EAAE,mBAAS,CAAC,CAAC;AACtC,QAAA,QAAQ,GAAc;IACjC,wBAAc;IACd,sBAAY;IACZ,uBAAa;IACb,uBAAa;CACd,CAAC"}
@@ -16,149 +16,134 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
16
  const web3_js_1 = require("@solana/web3.js");
17
17
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
18
  const clients_1 = require("../../utils/clients");
19
- const getSolanaDasEndpoint_1 = __importDefault(require("../../utils/clients/getSolanaDasEndpoint"));
20
- const solana_1 = require("../../utils/solana");
21
- const getAssetBatchDas_1 = require("../../utils/solana/das/getAssetBatchDas");
22
- const heliusAssetToAssetCollectible_1 = require("../../utils/solana/das/heliusAssetToAssetCollectible");
23
- const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
24
19
  const constants_1 = require("./constants");
25
- const helpers_1 = require("./helpers");
26
- const filters_1 = require("./filters");
27
- const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
28
- const arrayToMap_1 = require("../../utils/misc/arrayToMap");
29
- const collectionsMemo = new MemoizedCache_1.MemoizedCache(constants_1.collectionsCacheKey, {
30
- prefix: constants_1.cachePrefix,
31
- networkId: portfolio_core_1.NetworkId.solana,
32
- }, (arr) => (0, arrayToMap_1.arrayToMap)(arr || [], 'marketPubkey'));
33
- /**
34
- * @deprecated
35
- * this fetcher has been deprecated following protocol changes
36
- */
20
+ const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
21
+ const structs_1 = require("./structs");
22
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
23
+ const solana_1 = require("../../utils/solana");
37
24
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
38
25
  const connection = (0, clients_1.getClientSolana)();
39
- const dasUrl = (0, getSolanaDasEndpoint_1.default)();
40
26
  const accounts = (yield Promise.all([
41
- (0, solana_1.getAutoParsedProgramAccounts)(connection, constants_1.banxIdlItem, (0, filters_1.loanFiltersA)(owner)),
42
- (0, solana_1.getAutoParsedProgramAccounts)(connection, constants_1.banxIdlItem, (0, filters_1.loanFiltersB)(owner)),
27
+ ParsedGpa_1.ParsedGpa.build(connection, structs_1.Bondtradetransactionv3Struct, constants_1.banxPid)
28
+ .addFilter('accountDiscriminator', [203, 220, 99, 58, 119, 173, 245, 89])
29
+ .addFilter('user', new web3_js_1.PublicKey(owner))
30
+ .run(),
31
+ ParsedGpa_1.ParsedGpa.build(connection, structs_1.Bondtradetransactionv3Struct, constants_1.banxPid)
32
+ .addFilter('accountDiscriminator', [203, 220, 99, 58, 119, 173, 245, 89])
33
+ .addFilter('seller', new web3_js_1.PublicKey(owner))
34
+ .run(),
43
35
  ]))
44
36
  .flat()
45
- .filter((acc) => (acc.bondTradeTransactionState.perpetualActive ||
46
- acc.bondTradeTransactionState.perpetualPartialRepaid ||
47
- acc.bondTradeTransactionState.perpetualRefinancedActive ||
48
- acc.bondTradeTransactionState.perpetualManualTerminating ||
49
- acc.bondTradeTransactionState.active) &&
50
- acc.redeemedAt === '0' &&
51
- !acc.redeemResult.instantRefinanced);
37
+ .filter((acc) => (acc.bondTradeTransactionState ===
38
+ structs_1.BondtradeTransactionv2State.Perpetualactive ||
39
+ acc.bondTradeTransactionState ===
40
+ structs_1.BondtradeTransactionv2State.Perpetualpartialrepaid ||
41
+ acc.bondTradeTransactionState ===
42
+ structs_1.BondtradeTransactionv2State.Perpetualrefinancedactive ||
43
+ acc.bondTradeTransactionState ===
44
+ structs_1.BondtradeTransactionv2State.Perpetualmanualterminating ||
45
+ acc.bondTradeTransactionState ===
46
+ structs_1.BondtradeTransactionv2State.Active) &&
47
+ acc.redeemedAt.isZero() &&
48
+ acc.redeemResult !== structs_1.RedeemResult.Instantrefinanced);
52
49
  if (accounts.length === 0)
53
50
  return [];
54
- const [tokenPrices, fbondTokenMints, bondOffers, collections] = yield Promise.all([
55
- cache.getTokenPricesAsMap([solana_1.usdcSolanaMint, portfolio_core_1.solanaNativeAddress], portfolio_core_1.NetworkId.solana),
56
- (0, solana_1.getAutoParsedMultipleAccountsInfo)(connection, constants_1.banxIdlItem, accounts.map((acc) => new web3_js_1.PublicKey(acc.fbondTokenMint))),
57
- (0, solana_1.getAutoParsedMultipleAccountsInfo)(connection, constants_1.banxIdlItem, accounts.map((acc) => new web3_js_1.PublicKey(acc.bondOffer))),
58
- collectionsMemo.getItem(cache),
51
+ const [solTokenPrice, splMarkets, nftMarkets, fraktBonds, bondOffers] = yield Promise.all([
52
+ cache.getTokenPrice(portfolio_core_1.solanaNativeAddress, portfolio_core_1.NetworkId.solana),
53
+ constants_1.splMarketsMemo.getItem(cache),
54
+ constants_1.nftMarketsMemo.getItem(cache),
55
+ (0, solana_1.getParsedMultipleAccountsInfo)(connection, structs_1.FraktbondStruct, accounts.map((a) => a.fbondTokenMint)),
56
+ (0, solana_1.getParsedMultipleAccountsInfo)(connection, structs_1.bondOfferv3Struct, accounts.map((a) => a.bondOffer)),
59
57
  ]);
60
- if (!collections)
61
- return [];
62
- const solTokenPrice = tokenPrices.get(portfolio_core_1.solanaNativeAddress);
58
+ if (!splMarkets)
59
+ throw new Error('SPL Markets not cached');
60
+ if (!nftMarkets)
61
+ throw new Error('NFT Markets not cached');
63
62
  if (!solTokenPrice)
64
- return [];
65
- const fbondTokenMintsMap = new Map();
66
- fbondTokenMints.forEach((fbondTokenMint) => {
67
- if (!fbondTokenMint)
68
- return;
69
- fbondTokenMintsMap.set(fbondTokenMint.pubkey.toString(), fbondTokenMint);
70
- });
71
- const bondOffersMap = new Map();
72
- bondOffers.forEach((bondOffer) => {
63
+ throw new Error('SOL Price not cached');
64
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
65
+ accounts.forEach((account, i) => {
66
+ const bondOffer = bondOffers[i];
73
67
  if (!bondOffer)
74
68
  return;
75
- bondOffersMap.set(bondOffer.pubkey.toString(), bondOffer);
76
- });
77
- const heliusAssets = yield (0, getAssetBatchDas_1.getAssetBatchDasAsMap)(dasUrl, fbondTokenMints.map((acc) => acc && acc.fbondTokenMint));
78
- const elements = [];
79
- accounts.forEach((acc) => {
80
- const fbondTokenMint = fbondTokenMintsMap.get(acc.fbondTokenMint);
81
- const bondOffer = bondOffersMap.get(acc.bondOffer);
82
- if (!fbondTokenMint)
69
+ const fraktBond = fraktBonds[i];
70
+ if (!fraktBond)
83
71
  return;
84
- if (!fbondTokenMint.fraktBondState.perpetualActive &&
85
- !fbondTokenMint.fraktBondState.active)
72
+ const splMarket = splMarkets.get(bondOffer.hadoMarket.toString());
73
+ const nftMarket = nftMarkets.get(bondOffer.hadoMarket.toString());
74
+ if (!splMarket && !nftMarket) {
86
75
  return;
87
- const collection = bondOffer && bondOffer.hadoMarket
88
- ? collections.get(bondOffer.hadoMarket)
89
- : undefined;
90
- const tokenPrice = acc.lendingToken.usdc
91
- ? tokenPrices.get(solana_1.usdcSolanaMint)
92
- : tokenPrices.get(portfolio_core_1.solanaNativeAddress);
93
- if (!tokenPrice)
94
- return;
95
- const borrowedAssets = [];
96
- const suppliedAssets = [];
97
- let mintAsset = null;
98
- if (acc.fbondTokenMint) {
99
- const heliusAsset = heliusAssets.get(fbondTokenMint.fbondTokenMint);
100
- if (heliusAsset) {
101
- mintAsset = (0, heliusAssetToAssetCollectible_1.heliusAssetToAssetCollectible)(heliusAsset, {
102
- tags: [portfolio_core_1.collectibleFreezedTag],
103
- collection: collection
104
- ? {
105
- name: collection.collectionName,
106
- floorPrice: new bignumber_js_1.default(collection.collectionFloor)
107
- .dividedBy(Math.pow(10, 9))
108
- .multipliedBy(solTokenPrice.price)
109
- .toNumber(),
110
- }
111
- : undefined,
112
- });
113
- }
114
76
  }
115
- const name = `Active Loan`;
116
- if (acc.user === owner.toString()) {
117
- // LENDER
118
- suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address, (0, helpers_1.calculateLoanRepayValue)(acc)
119
- .dividedBy(Math.pow(10, tokenPrice.decimals))
120
- .toNumber(), portfolio_core_1.NetworkId.solana, tokenPrice));
121
- if (mintAsset)
122
- borrowedAssets.push(mintAsset);
77
+ const isLender = account.user.toString() === owner;
78
+ const element = elementRegistry.addElementBorrowlend({
79
+ label: 'Lending',
80
+ name: `Active Loan`,
81
+ ref: account.pubkey,
82
+ sourceRefs: [
83
+ {
84
+ name: 'Market',
85
+ address: bondOffer.hadoMarket.toString(),
86
+ },
87
+ ],
88
+ });
89
+ element.setFixedTerms(isLender);
90
+ let mint;
91
+ switch (account.lendingToken) {
92
+ case structs_1.LendingTokenType.Usdc:
93
+ mint = solana_1.usdcSolanaMint;
94
+ break;
95
+ case structs_1.LendingTokenType.Banxsol:
96
+ mint = constants_1.banxSolMint;
97
+ break;
98
+ case structs_1.LendingTokenType.Nativesol:
99
+ default:
100
+ mint = portfolio_core_1.solanaNativeAddress;
101
+ break;
123
102
  }
124
- else {
125
- // BORROWER
126
- if (mintAsset)
127
- suppliedAssets.push(mintAsset);
128
- borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address, (0, helpers_1.calculateDebtValue)(acc)
129
- .dividedBy(Math.pow(10, tokenPrice.decimals))
130
- .toNumber(), portfolio_core_1.NetworkId.solana, tokenPrice));
103
+ let collateral;
104
+ if (splMarket) {
105
+ collateral = {
106
+ address: splMarket.collateral.mint,
107
+ amount: fraktBond.fbondTokenSupply,
108
+ };
131
109
  }
132
- if (suppliedAssets.length > 0) {
133
- const { borrowedValue, suppliedValue, rewardValue, value } = (0, portfolio_core_1.getElementNFTLendingValues)({
134
- suppliedAssets,
135
- borrowedAssets,
136
- rewardAssets: [],
137
- lender: acc.user === owner.toString(),
138
- });
139
- elements.push({
140
- networkId: portfolio_core_1.NetworkId.solana,
141
- label: 'Lending',
142
- platformId: constants_1.platformId,
143
- type: portfolio_core_1.PortfolioElementType.borrowlend,
144
- value,
145
- name,
146
- data: {
147
- borrowedAssets,
148
- borrowedValue,
149
- borrowedYields: [],
150
- suppliedAssets,
151
- suppliedValue,
152
- suppliedYields: [],
153
- rewardAssets: [],
154
- rewardValue,
155
- healthRatio: null,
156
- value,
110
+ else if (nftMarket) {
111
+ collateral = {
112
+ address: fraktBond.fbondTokenMint,
113
+ collection: {
114
+ name: nftMarket.collectionName,
115
+ floorPrice: new bignumber_js_1.default(nftMarket.collectionFloor)
116
+ .shiftedBy(-portfolio_core_1.solanaNativeDecimals)
117
+ .multipliedBy(solTokenPrice.price),
118
+ imageUri: nftMarket.collectionImage,
157
119
  },
158
- });
120
+ attributes: { tags: [portfolio_core_1.collectibleFreezedTag] },
121
+ };
122
+ }
123
+ else {
124
+ return;
125
+ }
126
+ const borrowed = {
127
+ address: mint,
128
+ amount: account.solAmount,
129
+ };
130
+ if (isLender) {
131
+ if (splMarket)
132
+ element.addBorrowedAsset(collateral);
133
+ else {
134
+ element.addBorrowedCollectibleAsset(collateral);
135
+ }
136
+ element.addSuppliedAsset(borrowed);
137
+ }
138
+ else {
139
+ if (splMarket)
140
+ element.addSuppliedAsset(collateral);
141
+ else
142
+ element.addSuppliedCollectibleAsset(collateral);
143
+ element.addBorrowedAsset(borrowed);
159
144
  }
160
145
  });
161
- return elements;
146
+ return elementRegistry.getElements(cache);
162
147
  });
163
148
  const fetcher = {
164
149
  id: `${constants_1.platformId}-loans`,
@@ -1 +1 @@
1
- {"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAGrC,iDAAsD;AACtD,oGAA4E;AAC5E,+CAK4B;AAC5B,8EAAgF;AAChF,wGAAqG;AACrG,qGAA6E;AAC7E,2CAKqB;AAOrB,uCAAwE;AACxE,uCAAuD;AACvD,kEAA+D;AAC/D,4DAAyD;AAEzD,MAAM,eAAe,GAAG,IAAI,6BAAa,CAIvC,+BAAmB,EACnB;IACE,MAAM,EAAE,uBAAW;IACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;CAC5B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAU,EAAC,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,CAC/C,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IACrC,MAAM,MAAM,GAAG,IAAA,8BAAoB,GAAE,CAAC;IAEtC,MAAM,QAAQ,GAAG,CACf,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAA,qCAA4B,EAC1B,UAAU,EACV,uBAAW,EACX,IAAA,sB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BAAgB,CAAC,UAAuC,CAAC,CAAC;;gBAElE,OAAO,CAAC,2BAA2B,CACjC,UAA6C,CAC9C,CAAC;YACJ,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,40 @@
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
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const constants_1 = require("./constants");
18
+ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const resSpl = yield axios_1.default.get(constants_1.banxApiMarketsUrl, {
20
+ timeout: 3000,
21
+ });
22
+ yield cache.setItem(constants_1.splMarketsCacheKey, resSpl.data.data, {
23
+ prefix: constants_1.cachePrefix,
24
+ networkId: portfolio_core_1.NetworkId.solana,
25
+ });
26
+ const resNft = yield axios_1.default.get(constants_1.banxApiCollectionsUrl, {
27
+ timeout: 10000,
28
+ });
29
+ yield cache.setItem(constants_1.nftMarketsCacheKey, resNft.data.data, {
30
+ prefix: constants_1.cachePrefix,
31
+ networkId: portfolio_core_1.NetworkId.solana,
32
+ });
33
+ });
34
+ const job = {
35
+ id: `${constants_1.platformId}-markets`,
36
+ executor,
37
+ labels: ['normal'],
38
+ };
39
+ exports.default = job;
40
+ //# sourceMappingURL=marketsJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/marketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA0B;AAG1B,2CAOqB;AAGrB,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,MAAM,eAAK,CAAC,GAAG,CAC5B,6BAAiB,EACjB;QACE,OAAO,EAAE,IAAI;KACd,CACF,CAAC;IAEF,MAAM,KAAK,CAAC,OAAO,CAAC,8BAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;QACxD,MAAM,EAAE,uBAAW;QACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,eAAK,CAAC,GAAG,CAC5B,iCAAqB,EACrB;QACE,OAAO,EAAE,KAAK;KACf,CACF,CAAC;IAEF,MAAM,KAAK,CAAC,OAAO,CAAC,8BAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;QACxD,MAAM,EAAE,uBAAW;QACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,QAAQ;IACR,MAAM,EAAE,CAAC,QAAQ,CAAC;CACnB,CAAC;AAEF,kBAAe,GAAG,CAAC"}