@sonarwatch/portfolio-plugins 0.14.143 → 0.14.145
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.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/plugins/banx/constants.d.ts +14 -8
- package/src/plugins/banx/constants.js +25 -13
- package/src/plugins/banx/constants.js.map +1 -1
- package/src/plugins/banx/index.js +12 -2
- package/src/plugins/banx/index.js.map +1 -1
- package/src/plugins/banx/loansFetcher.js +108 -123
- package/src/plugins/banx/loansFetcher.js.map +1 -1
- package/src/plugins/banx/marketsJob.js +40 -0
- package/src/plugins/banx/marketsJob.js.map +1 -0
- package/src/plugins/banx/offersFetcher.js +61 -70
- package/src/plugins/banx/offersFetcher.js.map +1 -1
- package/src/plugins/banx/stakingFetcher.js +6 -3
- package/src/plugins/banx/stakingFetcher.js.map +1 -1
- package/src/plugins/banx/structs.d.ts +222 -2
- package/src/plugins/banx/structs.js +216 -2
- package/src/plugins/banx/structs.js.map +1 -1
- package/src/plugins/banx/types.d.ts +50 -258
- package/src/plugins/banx/vaultsFetcher.d.ts +3 -0
- package/src/plugins/banx/vaultsFetcher.js +74 -0
- package/src/plugins/banx/vaultsFetcher.js.map +1 -0
- package/src/plugins/banx/vaultsJob.d.ts +3 -0
- package/src/plugins/banx/{collectionsJob.js → vaultsJob.js} +5 -16
- package/src/plugins/banx/vaultsJob.js.map +1 -0
- package/src/plugins/bskt/constants.d.ts +1 -0
- package/src/plugins/bskt/constants.js +2 -1
- package/src/plugins/bskt/constants.js.map +1 -1
- package/src/plugins/bskt/index.js +5 -1
- package/src/plugins/bskt/index.js.map +1 -1
- package/src/plugins/bskt/stakingFetcher.d.ts +3 -0
- package/src/plugins/bskt/stakingFetcher.js +58 -0
- package/src/plugins/bskt/stakingFetcher.js.map +1 -0
- package/src/plugins/bskt/structs.d.ts +12 -0
- package/src/plugins/bskt/structs.js +12 -1
- package/src/plugins/bskt/structs.js.map +1 -1
- package/src/plugins/orca/getWhirlpoolPositions.js +1 -1
- package/src/plugins/orca/getWhirlpoolPositions.js.map +1 -1
- package/src/plugins/orca/types.d.ts +6 -2
- package/src/plugins/orca/whirlpoolsStatsJob.js +7 -3
- package/src/plugins/orca/whirlpoolsStatsJob.js.map +1 -1
- package/src/plugins/banx/collectionsJob.js.map +0 -1
- package/src/plugins/banx/filters.d.ts +0 -6
- package/src/plugins/banx/filters.js +0 -39
- package/src/plugins/banx/filters.js.map +0 -1
- package/src/plugins/banx/helpers.d.ts +0 -5
- package/src/plugins/banx/helpers.js +0 -64
- package/src/plugins/banx/helpers.js.map +0 -1
- package/src/plugins/banx/idl.d.ts +0 -123
- package/src/plugins/banx/idl.js +0 -2187
- package/src/plugins/banx/idl.js.map +0 -1
- /package/src/plugins/banx/{collectionsJob.d.ts → marketsJob.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.14.145](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.144...plugins-0.14.145) (2025-03-18)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
## [0.14.144](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.143...plugins-0.14.144) (2025-03-17)
|
10
|
+
|
11
|
+
|
12
|
+
|
5
13
|
## [0.14.143](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.142...plugins-0.14.143) (2025-03-14)
|
6
14
|
|
7
15
|
|
package/package.json
CHANGED
@@ -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 {
|
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
|
11
|
-
export declare const
|
12
|
-
export declare const
|
13
|
-
export declare const
|
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
|
16
|
-
export declare const
|
17
|
-
export declare const
|
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.
|
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
|
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.
|
23
|
-
exports.
|
24
|
-
exports.
|
25
|
-
exports.
|
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.
|
28
|
-
exports.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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;
|
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,E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AW;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 = [
|
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;
|
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
|
26
|
-
const
|
27
|
-
const
|
28
|
-
const
|
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
|
-
|
42
|
-
|
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
|
46
|
-
|
47
|
-
acc.bondTradeTransactionState
|
48
|
-
|
49
|
-
acc.bondTradeTransactionState
|
50
|
-
|
51
|
-
|
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 [
|
55
|
-
cache.
|
56
|
-
|
57
|
-
|
58
|
-
|
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 (!
|
61
|
-
|
62
|
-
|
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
|
-
|
65
|
-
const
|
66
|
-
|
67
|
-
|
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
|
-
|
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
|
-
|
85
|
-
|
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
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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 (
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
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,+
|
1
|
+
{"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAKoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAGrC,iDAAsD;AACtD,2CAMqB;AACrB,kEAA+D;AAC/D,uCAOmB;AACnB,gFAA6E;AAC7E,+CAG4B;AAM5B,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,QAAQ,GAAG,CACf,MAAM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CAAC;yBAChC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC;oBACpC,QAAQ,EAAE,SAAS,CAAC,eAAe;iBACpC;gBACD,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,sCAAqB,CAAC,EAAE;aAC9C,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAA8B;YAC1C,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,OAAO,CAAC,SAAS;SAC1B,CAAC;QAEF,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,SAAS;gBACX,OAAO,CAAC,gBAAgB,CAAC,UAAuC,CAAC,CAAC;iBAC/D,CAAC;gBACJ,OAAO,CAAC,2BAA2B,CACjC,UAA6C,CAC9C,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,IAAI,SAAS;gBACX,OAAO,CAAC,gBAAgB,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"}
|