@sonarwatch/portfolio-plugins 0.14.59 → 0.14.61
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 +1836 -1828
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/plugins/adrastea/lrtsSolJob.js +4 -3
- package/src/plugins/adrastea/lrtsSolJob.js.map +1 -1
- package/src/plugins/adrena/constants.js +1 -1
- package/src/plugins/adrena/constants.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/bluefin/airdropFetcher.js +4 -0
- package/src/plugins/bluefin/airdropFetcher.js.map +1 -1
- package/src/plugins/bluefin/constants.js +1 -1
- package/src/plugins/bluefin/constants.js.map +1 -1
- package/src/plugins/deepbook/constants.js +1 -1
- package/src/plugins/deepbook/constants.js.map +1 -1
- package/src/plugins/drift/perpHelpers/getOraclePrice.js +4 -0
- package/src/plugins/drift/perpHelpers/getOraclePrice.js.map +1 -1
- package/src/plugins/drift/perpHelpers/switchboard_on_demand.d.ts +3 -0
- package/src/plugins/drift/perpHelpers/switchboard_on_demand.js +23 -0
- package/src/plugins/drift/perpHelpers/switchboard_on_demand.js.map +1 -0
- package/src/plugins/drift/struct.d.ts +2 -1
- package/src/plugins/drift/struct.js +1 -0
- package/src/plugins/drift/struct.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/depositsFetcher.js +20 -32
- package/src/plugins/drift-market-maker-vault/depositsFetcher.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/index.js +1 -0
- package/src/plugins/drift-market-maker-vault/index.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/types.d.ts +4 -0
- package/src/plugins/drift-market-maker-vault/vaultsJob.js +11 -1
- package/src/plugins/drift-market-maker-vault/vaultsJob.js.map +1 -1
- package/src/plugins/fluxbeam/poolsJob.js +98 -87
- package/src/plugins/fluxbeam/poolsJob.js.map +1 -1
- package/src/plugins/photofinish/constants.d.ts +5 -0
- package/src/plugins/photofinish/constants.js +14 -0
- package/src/plugins/photofinish/constants.js.map +1 -0
- package/src/plugins/photofinish/index.d.ts +6 -0
- package/src/plugins/photofinish/index.js +12 -0
- package/src/plugins/photofinish/index.js.map +1 -0
- package/src/plugins/photofinish/stakingFetcher.d.ts +3 -0
- package/src/plugins/photofinish/stakingFetcher.js +43 -0
- package/src/plugins/photofinish/stakingFetcher.js.map +1 -0
- package/src/plugins/photofinish/types.d.ts +5 -0
- package/src/plugins/photofinish/types.js +3 -0
- package/src/plugins/photofinish/types.js.map +1 -0
- package/src/plugins/solayer/constants.js +1 -1
- package/src/plugins/solayer/constants.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrice.d.ts +3 -0
- package/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrice.js +43 -0
- package/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrice.js.map +1 -0
- package/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrices.d.ts +3 -0
- package/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrices.js +32 -0
- package/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrices.js.map +1 -0
- package/src/plugins/switchboard/index.js +2 -1
- package/src/plugins/switchboard/index.js.map +1 -1
- package/src/plugins/switchboard/onDemandPricingJob.d.ts +3 -0
- package/src/plugins/switchboard/onDemandPricingJob.js +67 -0
- package/src/plugins/switchboard/onDemandPricingJob.js.map +1 -0
- package/src/plugins/switchboard/structs.d.ts +40 -0
- package/src/plugins/switchboard/structs.js +38 -1
- package/src/plugins/switchboard/structs.js.map +1 -1
- package/src/plugins/switchboard/types.d.ts +6 -0
- package/src/plugins/switchboard/types.js +3 -0
- package/src/plugins/switchboard/types.js.map +1 -0
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/plugins/zeta/airdropFetcher.js +14 -14
- package/src/utils/elementbuilder/ElementBorrowlendBuilder.js +1 -1
- package/src/utils/elementbuilder/ElementBorrowlendBuilder.js.map +1 -1
- package/src/utils/elementbuilder/ElementBuilder.d.ts +1 -0
- package/src/utils/elementbuilder/ElementBuilder.js +1 -0
- package/src/utils/elementbuilder/ElementBuilder.js.map +1 -1
- package/src/utils/elementbuilder/ElementLeverageBuilder.js +1 -1
- package/src/utils/elementbuilder/ElementLeverageBuilder.js.map +1 -1
- package/src/utils/elementbuilder/ElementLiquidityBuilder.js +1 -1
- package/src/utils/elementbuilder/ElementLiquidityBuilder.js.map +1 -1
- package/src/utils/elementbuilder/ElementMultipleBuilder.js +1 -1
- package/src/utils/elementbuilder/ElementMultipleBuilder.js.map +1 -1
- package/src/utils/elementbuilder/ElementParams.d.ts +1 -0
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -8,9 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
12
|
const web3_js_1 = require("@solana/web3.js");
|
16
13
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
@@ -18,97 +15,111 @@ const constants_1 = require("./constants");
|
|
18
15
|
const clients_1 = require("../../utils/clients");
|
19
16
|
const solana_1 = require("../../utils/solana");
|
20
17
|
const structs_1 = require("./structs");
|
21
|
-
const
|
22
|
-
const
|
18
|
+
const getLpTokenSourceRaw_1 = require("../../utils/misc/getLpTokenSourceRaw");
|
19
|
+
const tokenAccountsToExclude = [
|
20
|
+
'F5LQTC4G9kBsMKsXtHgf9RqR15k3JB8K3smR73VB9pzY',
|
21
|
+
'3zAvJPHBX42kc1htJc6RFihhpnQxP5KqpqqkrTEUhZ9S',
|
22
|
+
];
|
23
23
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
24
|
const connection = (0, clients_1.getClientSolana)();
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
.map((pool) => [pool.tokenA, pool.tokenB])
|
29
|
-
.flat();
|
30
|
-
const tokenAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(connection, solana_1.tokenAccountStruct, reserveAccountsAddresses);
|
31
|
-
const tokenAccountsMap = new Map();
|
32
|
-
tokenAccounts.forEach((tokenAccount) => {
|
33
|
-
if (!tokenAccount)
|
34
|
-
return;
|
35
|
-
tokenAccountsMap.set(tokenAccount.pubkey.toString(), tokenAccount);
|
36
|
-
});
|
37
|
-
const poolMints = yield (0, solana_1.getParsedMultipleAccountsInfo)(connection, solana_1.mintAccountStruct, pools.map((p) => p.poolMint));
|
38
|
-
const tokenMintsAddresses = [
|
39
|
-
...new Set(pools
|
40
|
-
.map((pool) => [pool.tokenAMint.toString(), pool.tokenBMint.toString()])
|
41
|
-
.flat()),
|
42
|
-
];
|
43
|
-
const tokenMintsAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(connection, solana_1.mintAccountStruct, tokenMintsAddresses.map((a) => new web3_js_1.PublicKey(a)));
|
44
|
-
const tokenMintsAccountsMap = new Map();
|
45
|
-
tokenMintsAccounts.forEach((tokenMintAccount) => {
|
46
|
-
if (!tokenMintAccount)
|
47
|
-
return;
|
48
|
-
tokenMintsAccountsMap.set(tokenMintAccount.pubkey.toString(), tokenMintAccount);
|
49
|
-
});
|
50
|
-
const tokenPriceResults = yield cache.getTokenPrices(tokenMintsAddresses, portfolio_core_1.NetworkId.solana);
|
51
|
-
const tokenPrices = new Map();
|
52
|
-
tokenPriceResults.forEach((tokenPrice) => {
|
53
|
-
if (!tokenPrice)
|
54
|
-
return;
|
55
|
-
tokenPrices.set(tokenPrice.address, tokenPrice);
|
25
|
+
const allPoolsPubkeys = yield connection.getProgramAccounts(new web3_js_1.PublicKey(constants_1.fluxbeamPoolsPid), {
|
26
|
+
filters: [{ dataSize: structs_1.poolStruct.byteSize }],
|
27
|
+
dataSlice: { length: 0, offset: 0 },
|
56
28
|
});
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
const
|
62
|
-
|
63
|
-
|
64
|
-
const
|
65
|
-
const
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
29
|
+
const step = 100;
|
30
|
+
let tempPools;
|
31
|
+
const sources = [];
|
32
|
+
for (let offset = 0; offset < allPoolsPubkeys.length; offset += step) {
|
33
|
+
const tempTokenAccountsMap = new Map();
|
34
|
+
const tempTokenMintsAccountsMap = new Map();
|
35
|
+
const tempTokenMints = [];
|
36
|
+
const tempTokenAddresses = new Set();
|
37
|
+
const tempsReserveAccounts = [];
|
38
|
+
const tempsPoolMints = [];
|
39
|
+
tempPools = yield (0, solana_1.getParsedMultipleAccountsInfo)(connection, structs_1.poolStruct, allPoolsPubkeys.slice(offset, offset + step).map((res) => res.pubkey));
|
40
|
+
tempPools = tempPools.filter((pool) => pool === null || pool === void 0 ? void 0 : pool.isInitialized);
|
41
|
+
tempPools.forEach((pool) => {
|
42
|
+
if (pool) {
|
43
|
+
tempTokenMints.push(...[pool.tokenAMint, pool.tokenBMint]);
|
44
|
+
tempTokenAddresses.add(pool.tokenAMint.toString());
|
45
|
+
tempTokenAddresses.add(pool.tokenBMint.toString());
|
46
|
+
tempsReserveAccounts.push(...[pool.tokenA, pool.tokenB]);
|
47
|
+
tempsPoolMints.push(...[pool.poolMint]);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
const [tokenAccounts, poolMintsAccounts, tokenMintsAccounts, tokenPriceById,] = yield Promise.all([
|
51
|
+
(0, solana_1.getParsedMultipleAccountsInfo)(connection, solana_1.tokenAccountStruct, tempsReserveAccounts),
|
52
|
+
(0, solana_1.getParsedMultipleAccountsInfo)(connection, solana_1.mintAccountStruct, tempsPoolMints),
|
53
|
+
(0, solana_1.getParsedMultipleAccountsInfo)(connection, solana_1.mintAccountStruct, Array.from(tempTokenAddresses)
|
54
|
+
.map((t) => {
|
55
|
+
if (!tokenAccountsToExclude.includes(t)) {
|
56
|
+
return new web3_js_1.PublicKey(t);
|
57
|
+
}
|
58
|
+
return [];
|
59
|
+
})
|
60
|
+
.flat()),
|
61
|
+
cache.getTokenPricesAsMap(tempTokenAddresses, portfolio_core_1.NetworkId.solana),
|
62
|
+
]);
|
63
|
+
if (!tokenMintsAccounts)
|
71
64
|
continue;
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
decimals: mintAccountA.decimals,
|
77
|
-
reserveAmountRaw: tokenAccountA.amount,
|
78
|
-
tokenPrice: tokenPriceA,
|
79
|
-
weight: 0.5,
|
80
|
-
}, {
|
81
|
-
address: pool.tokenBMint.toString(),
|
82
|
-
decimals: mintAccountB.decimals,
|
83
|
-
reserveAmountRaw: tokenAccountB.amount,
|
84
|
-
tokenPrice: tokenPriceB,
|
85
|
-
weight: 0.5,
|
65
|
+
tokenMintsAccounts.forEach((tokenMintAccount) => {
|
66
|
+
if (!tokenMintAccount)
|
67
|
+
return;
|
68
|
+
tempTokenMintsAccountsMap.set(tokenMintAccount.pubkey.toString(), tokenMintAccount);
|
86
69
|
});
|
87
|
-
|
88
|
-
|
70
|
+
tokenAccounts.forEach((tokenAccount) => {
|
71
|
+
if (!tokenAccount)
|
72
|
+
return;
|
73
|
+
tempTokenAccountsMap.set(tokenAccount.pubkey.toString(), tokenAccount);
|
74
|
+
});
|
75
|
+
for (let i = 0; i < tempPools.length; i++) {
|
76
|
+
const pool = tempPools[i];
|
77
|
+
if (!pool || !pool.isInitialized)
|
78
|
+
continue;
|
79
|
+
const poolMint = poolMintsAccounts[i];
|
80
|
+
if (!poolMint)
|
81
|
+
continue;
|
82
|
+
const tokenAccountA = tempTokenAccountsMap.get(pool.tokenA.toString());
|
83
|
+
const tokenAccountB = tempTokenAccountsMap.get(pool.tokenB.toString());
|
84
|
+
if (!tokenAccountA || !tokenAccountB)
|
85
|
+
continue;
|
86
|
+
const mintAccountA = tempTokenMintsAccountsMap.get(pool.tokenAMint.toString());
|
87
|
+
const mintAccountB = tempTokenMintsAccountsMap.get(pool.tokenBMint.toString());
|
88
|
+
if (!mintAccountA || !mintAccountB)
|
89
|
+
continue;
|
90
|
+
const tokenPriceA = tokenPriceById.get(pool.tokenAMint.toString());
|
91
|
+
const tokenPriceB = tokenPriceById.get(pool.tokenBMint.toString());
|
92
|
+
const lpSources = (0, getLpTokenSourceRaw_1.getLpTokenSourceRaw)({
|
93
|
+
lpDetails: {
|
94
|
+
address: pool.poolMint.toString(),
|
95
|
+
decimals: poolMint.decimals,
|
96
|
+
supplyRaw: poolMint.supply,
|
97
|
+
},
|
98
|
+
platformId: constants_1.platformId,
|
99
|
+
sourceId: pool.pubkey.toString(),
|
100
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
101
|
+
poolUnderlyingsRaw: [
|
102
|
+
{
|
103
|
+
address: pool.tokenAMint.toString(),
|
104
|
+
decimals: mintAccountA.decimals,
|
105
|
+
reserveAmountRaw: tokenAccountA.amount,
|
106
|
+
tokenPrice: tokenPriceA,
|
107
|
+
weight: 0.5,
|
108
|
+
},
|
109
|
+
{
|
110
|
+
address: pool.tokenBMint.toString(),
|
111
|
+
decimals: mintAccountB.decimals,
|
112
|
+
reserveAmountRaw: tokenAccountB.amount,
|
113
|
+
tokenPrice: tokenPriceB,
|
114
|
+
weight: 0.5,
|
115
|
+
},
|
116
|
+
],
|
117
|
+
priceUnderlyings: true,
|
118
|
+
});
|
119
|
+
sources.push(...lpSources);
|
89
120
|
}
|
90
|
-
if (!tokenPriceA || !tokenPriceB)
|
91
|
-
continue;
|
92
|
-
const lpSource = (0, getLpTokenSourceRawOld_1.default)(portfolio_core_1.NetworkId.solana, constants_1.platformId, constants_1.platformId, {
|
93
|
-
address: pool.poolMint.toString(),
|
94
|
-
decimals: poolMint.decimals,
|
95
|
-
supplyRaw: poolMint.supply,
|
96
|
-
}, [
|
97
|
-
{
|
98
|
-
address: tokenPriceA.address,
|
99
|
-
decimals: tokenPriceA.decimals,
|
100
|
-
price: tokenPriceA.price,
|
101
|
-
reserveAmountRaw: tokenAccountA.amount,
|
102
|
-
},
|
103
|
-
{
|
104
|
-
address: tokenPriceB.address,
|
105
|
-
decimals: tokenPriceB.decimals,
|
106
|
-
price: tokenPriceB.price,
|
107
|
-
reserveAmountRaw: tokenAccountB.amount,
|
108
|
-
},
|
109
|
-
], 'Pools');
|
110
|
-
yield cache.setTokenPriceSource(lpSource);
|
111
121
|
}
|
122
|
+
yield cache.setTokenPriceSources(sources);
|
112
123
|
});
|
113
124
|
const job = {
|
114
125
|
id: `${constants_1.platformId}-pools`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/fluxbeam/poolsJob.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/fluxbeam/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6CAA4C;AAC5C,+DAAuD;AAGvD,2CAA2D;AAC3D,iDAAsD;AACtD,+CAO4B;AAC5B,uCAA6C;AAC7C,8EAA2E;AAE3E,MAAM,sBAAsB,GAAG;IAC7B,8CAA8C;IAC9C,8CAA8C;CAC/C,CAAC;AAEF,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,eAAe,GAAG,MAAM,UAAU,CAAC,kBAAkB,CACzD,IAAI,mBAAS,CAAC,4BAAgB,CAAC,EAC/B;QACE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,oBAAU,CAAC,QAAQ,EAAE,CAAC;QAC5C,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;KACpC,CACF,CAAC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AE,QAAQ,CAAC,QAAQ;oBAC3B,SAAS,EAAE,QAAQ,CAAC,MAAM;iBAC3B;gBACD,UAAU,EAAV,sBAAU;gBACV,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBAChC,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,kBAAkB,EAAE;oBAClB;wBACE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;wBACnC,QAAQ,EAAE,YAAY,CAAC,QAAQ;wBAC/B,gBAAgB,EAAE,aAAa,CAAC,MAAM;wBACtC,UAAU,EAAE,WAAW;wBACvB,MAAM,EAAE,GAAG;qBACZ;oBACD;wBACE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;wBACnC,QAAQ,EAAE,YAAY,CAAC,QAAQ;wBAC/B,gBAAgB,EAAE,aAAa,CAAC,MAAM;wBACtC,UAAU,EAAE,WAAW;wBACvB,MAAM,EAAE,GAAG;qBACZ;iBACF;gBACD,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,MAAM,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { Platform } from '@sonarwatch/portfolio-core';
|
2
|
+
export declare const platformId = "photofinish";
|
3
|
+
export declare const platform: Platform;
|
4
|
+
export declare const apiUrl = "https://api.photofinish.live/users/external/staked-crown/";
|
5
|
+
export declare const crownMint = "GDfnEsia2WLAW5t8yx2X5j2mkfA74i5kwGdDuZHt7XmG";
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.crownMint = exports.apiUrl = exports.platform = exports.platformId = void 0;
|
4
|
+
exports.platformId = 'photofinish';
|
5
|
+
exports.platform = {
|
6
|
+
id: exports.platformId,
|
7
|
+
name: 'Photo Finish',
|
8
|
+
image: 'https://sonar.watch/img/platforms/photofinish.webp',
|
9
|
+
website: 'https://photofinish.live/',
|
10
|
+
twitter: 'https://x.com/photofinishgame',
|
11
|
+
};
|
12
|
+
exports.apiUrl = 'https://api.photofinish.live/users/external/staked-crown/';
|
13
|
+
exports.crownMint = 'GDfnEsia2WLAW5t8yx2X5j2mkfA74i5kwGdDuZHt7XmG';
|
14
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/photofinish/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,aAAa,CAAC;AAC3B,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,oDAAoD;IAC3D,OAAO,EAAE,2BAA2B;IACpC,OAAO,EAAE,+BAA+B;CACzC,CAAC;AAEW,QAAA,MAAM,GACjB,2DAA2D,CAAC;AACjD,QAAA,SAAS,GAAG,8CAA8C,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
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.fetchers = exports.jobs = exports.platforms = void 0;
|
7
|
+
const constants_1 = require("./constants");
|
8
|
+
const stakingFetcher_1 = __importDefault(require("./stakingFetcher"));
|
9
|
+
exports.platforms = [constants_1.platform];
|
10
|
+
exports.jobs = [];
|
11
|
+
exports.fetchers = [stakingFetcher_1.default];
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/photofinish/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,sEAAsD;AAEzC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,CAAC,wBAAsB,CAAC,CAAC"}
|
@@ -0,0 +1,43 @@
|
|
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 ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
19
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
20
|
+
let res;
|
21
|
+
try {
|
22
|
+
res = yield axios_1.default.get(constants_1.apiUrl + owner);
|
23
|
+
}
|
24
|
+
catch (err) {
|
25
|
+
return [];
|
26
|
+
}
|
27
|
+
if (typeof res.data === 'string')
|
28
|
+
return [];
|
29
|
+
const registry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
30
|
+
registry.addElementMultiple({ label: 'Staked' }).addAsset({
|
31
|
+
address: constants_1.crownMint,
|
32
|
+
amount: res.data,
|
33
|
+
alreadyShifted: true,
|
34
|
+
});
|
35
|
+
return registry.getElements(cache);
|
36
|
+
});
|
37
|
+
const fetcher = {
|
38
|
+
id: `${constants_1.platformId}-staking`,
|
39
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
40
|
+
executor,
|
41
|
+
};
|
42
|
+
exports.default = fetcher;
|
43
|
+
//# sourceMappingURL=stakingFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/photofinish/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA0B;AAE1B,2CAA4D;AAE5D,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,IAAI,GAAG,CAAC;IACR,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,kBAAM,GAAG,KAAK,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAE5C,MAAM,QAAQ,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,MAAM,EAAE,sBAAU,CAAC,CAAC;IAEnE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;QACxD,OAAO,EAAE,qBAAS;QAClB,MAAM,EAAE,GAAG,CAAC,IAAI;QAChB,cAAc,EAAE,IAAI;KACrB,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/photofinish/types.ts"],"names":[],"mappings":""}
|
@@ -9,7 +9,7 @@ exports.platform = {
|
|
9
9
|
image: 'https://sonar.watch/img/platforms/solayer.webp',
|
10
10
|
website: 'https://solayer.org/',
|
11
11
|
twitter: 'https://x.com/solayer_labs',
|
12
|
-
defiLlamaId: 'solayer',
|
12
|
+
defiLlamaId: 'parent#solayer',
|
13
13
|
};
|
14
14
|
exports.programId = new web3_js_1.PublicKey('sSo1iU21jBrU9VaJ8PJib1MtorefUV4fzC9GURa2KNn');
|
15
15
|
// export const stakePoolProgramId = 'SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy'
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/solayer/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,gDAAgD;IACvD,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EAAE,4BAA4B;IACrC,WAAW,EAAE,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/solayer/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,gDAAgD;IACvD,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EAAE,4BAA4B;IACrC,WAAW,EAAE,gBAAgB;CAC9B,CAAC;AAEW,QAAA,SAAS,GAAG,IAAI,mBAAS,CACpC,6CAA6C,CAC9C,CAAC;AAEF,kFAAkF;AACrE,QAAA,cAAc,GAAG,6CAA6C,CAAC;AAC/D,QAAA,cAAc,GAAG,6CAA6C,CAAC;AAC/D,QAAA,cAAc,GAAG,6CAA6C,CAAC;AAC/D,QAAA,kBAAkB,GAAG,CAAC,CAAC;AAEvB,QAAA,SAAS,GAAG;IACvB,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,8CAA8C;CAC/C,CAAC"}
|
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
|
|
54
54
|
}
|
55
55
|
function getV3PairsAddresses(url, length = 300) {
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
57
|
-
const query = (0, graphql_request_1.gql) `
|
58
|
-
{
|
59
|
-
pools(
|
60
|
-
orderBy: totalValueLockedUSD
|
61
|
-
first: ${length}
|
62
|
-
orderDirection: desc
|
63
|
-
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
-
) {
|
65
|
-
id
|
66
|
-
token0Price
|
67
|
-
token1Price
|
68
|
-
liquidity
|
69
|
-
token0 {
|
70
|
-
id
|
71
|
-
totalSupply
|
72
|
-
decimals
|
73
|
-
}
|
74
|
-
token1 {
|
75
|
-
id
|
76
|
-
totalSupply
|
77
|
-
decimals
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
57
|
+
const query = (0, graphql_request_1.gql) `
|
58
|
+
{
|
59
|
+
pools(
|
60
|
+
orderBy: totalValueLockedUSD
|
61
|
+
first: ${length}
|
62
|
+
orderDirection: desc
|
63
|
+
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
+
) {
|
65
|
+
id
|
66
|
+
token0Price
|
67
|
+
token1Price
|
68
|
+
liquidity
|
69
|
+
token0 {
|
70
|
+
id
|
71
|
+
totalSupply
|
72
|
+
decimals
|
73
|
+
}
|
74
|
+
token1 {
|
75
|
+
id
|
76
|
+
totalSupply
|
77
|
+
decimals
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
81
|
`;
|
82
82
|
const res = yield (0, graphql_request_1.default)(url, query);
|
83
83
|
const pools = res.pools;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.getSwitchboardOnDemandPrices = void 0;
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const structs_1 = require("../structs");
|
18
|
+
const getMultipleAccountsInfoSafe_1 = require("../../../utils/solana/getMultipleAccountsInfoSafe");
|
19
|
+
const SB_PRECISION = new bignumber_js_1.default(Math.pow(10, 18));
|
20
|
+
function getSwitchboardOnDemandPrices(client, onDemandPubkeys) {
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
22
|
+
const slot = yield client.getSlot();
|
23
|
+
const prices = [];
|
24
|
+
const accounts = yield (0, getMultipleAccountsInfoSafe_1.getMultipleAccountsInfoSafe)(client, onDemandPubkeys);
|
25
|
+
for (const account of accounts) {
|
26
|
+
if (!account) {
|
27
|
+
prices.push(undefined);
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
const [pullFeedAccountData] = structs_1.pullFeedAccountDataStruct.deserialize(account.data);
|
31
|
+
// If the data is more than ~15 minutes old (1 slot = 400ms), dismiss it
|
32
|
+
if (pullFeedAccountData.result.slot.isLessThan(slot - 60 * 10 * 2.5)) {
|
33
|
+
prices.push(undefined);
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
prices.push(pullFeedAccountData.result.value.dividedBy(SB_PRECISION).toNumber());
|
37
|
+
}
|
38
|
+
}
|
39
|
+
return prices;
|
40
|
+
});
|
41
|
+
}
|
42
|
+
exports.getSwitchboardOnDemandPrices = getSwitchboardOnDemandPrices;
|
43
|
+
//# sourceMappingURL=getSwitchboardOnDemandPrice.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getSwitchboardOnDemandPrice.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrice.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,gEAAqC;AACrC,wCAAuD;AACvD,mGAAgG;AAGhG,MAAM,YAAY,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC,CAAC;AAE7C,SAAsB,4BAA4B,CAChD,MAAoB,EACpB,eAA4B;;QAE5B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QAEpC,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAA,yDAA2B,EAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAE5E,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACvB,SAAS;YACX,CAAC;YAED,MAAM,CAAC,mBAAmB,CAAC,GAAG,mCAAyB,CAAC,WAAW,CACjE,OAAO,CAAC,IAAI,CACb,CAAC;YAEF,wEAAwE;YACxE,IAAI,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;gBACrE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CACpE,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AA9BD,oEA8BC"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.getSwitchboardOnDemandPrice = void 0;
|
16
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
17
|
+
const toBN_1 = require("../../../utils/misc/toBN");
|
18
|
+
const structs_1 = require("../structs");
|
19
|
+
const constants_1 = require("../../drift/perpHelpers/constants");
|
20
|
+
const SB_PRECISION_EXP = new bn_js_1.default(18);
|
21
|
+
const SB_PRECISION = new bn_js_1.default(10).pow(SB_PRECISION_EXP.sub(constants_1.PRICE_PRECISION_EXP));
|
22
|
+
function getSwitchboardOnDemandPrice(client, onDemandPubkey) {
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
24
|
+
const account = yield client.getAccountInfo(onDemandPubkey);
|
25
|
+
if (!account)
|
26
|
+
return undefined;
|
27
|
+
const [pullFeedAccountData] = structs_1.pullFeedAccountDataStruct.deserialize(account.data);
|
28
|
+
return (0, toBN_1.toBN)(pullFeedAccountData.result.value).div(SB_PRECISION).toNumber();
|
29
|
+
});
|
30
|
+
}
|
31
|
+
exports.getSwitchboardOnDemandPrice = getSwitchboardOnDemandPrice;
|
32
|
+
//# sourceMappingURL=getSwitchboardOnDemandPrices.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getSwitchboardOnDemandPrices.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/switchboard/helpers/getSwitchboardOnDemandPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAuB;AAEvB,mDAAgD;AAChD,wCAAuD;AACvD,iEAAwE;AAGxE,MAAM,gBAAgB,GAAG,IAAI,eAAE,CAAC,EAAE,CAAC,CAAC;AACpC,MAAM,YAAY,GAAG,IAAI,eAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,+BAAmB,CAAC,CAAC,CAAC;AAE/E,SAAsB,2BAA2B,CAC/C,MAAoB,EACpB,cAAyB;;QAEzB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAE/B,MAAM,CAAC,mBAAmB,CAAC,GAAG,mCAAyB,CAAC,WAAW,CACjE,OAAO,CAAC,IAAI,CACb,CAAC;QAEF,OAAO,IAAA,WAAI,EAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7E,CAAC;CAAA;AAZD,kEAYC"}
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.fetchers = exports.jobs = void 0;
|
7
7
|
const pricingJob_1 = __importDefault(require("./pricingJob"));
|
8
|
-
|
8
|
+
const onDemandPricingJob_1 = __importDefault(require("./onDemandPricingJob"));
|
9
|
+
exports.jobs = [pricingJob_1.default, onDemandPricingJob_1.default];
|
9
10
|
exports.fetchers = [];
|
10
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/switchboard/index.ts"],"names":[],"mappings":";;;;;;AAEA,8DAAsC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/switchboard/index.ts"],"names":[],"mappings":";;;;;;AAEA,8DAAsC;AACtC,8EAAsD;AAEzC,QAAA,IAAI,GAAU,CAAC,oBAAU,EAAE,4BAAkB,CAAC,CAAC;AAC/C,QAAA,QAAQ,GAAc,EAAE,CAAC"}
|
@@ -0,0 +1,67 @@
|
|
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
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
14
|
+
const constants_1 = require("./constants");
|
15
|
+
const clients_1 = require("../../utils/clients");
|
16
|
+
const constants_2 = require("../tokens/constants");
|
17
|
+
const getSwitchboardOnDemandPrice_1 = require("./helpers/getSwitchboardOnDemandPrice");
|
18
|
+
const getCachedDecimalsForToken_1 = require("../../utils/misc/getCachedDecimalsForToken");
|
19
|
+
const solana_1 = require("../../utils/solana");
|
20
|
+
const feedsToFetch = [
|
21
|
+
{
|
22
|
+
feedsAddresses: [
|
23
|
+
'Ceveqpim1FJZfx9DPeFDVDSz2HJavUqPPEJtZ2osNEmS',
|
24
|
+
'E8TLLh5jkYDvSXfAES7qe3s8Cfjj4hyvjksuvUHe8NEw',
|
25
|
+
'BSzfJs4d1tAkSDqkepnfzEVcx2WtDVnwwXa2giy9PLeP',
|
26
|
+
],
|
27
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
28
|
+
mintAddress: portfolio_core_1.solanaNativeWrappedAddress,
|
29
|
+
},
|
30
|
+
{
|
31
|
+
feedsAddresses: ['2Dv72h14k6ynrUvQ8mhu5ihwrk1Kte6Aj2tpKhXLsHrR'],
|
32
|
+
mintAddress: solana_1.usdcSolanaMint,
|
33
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
34
|
+
},
|
35
|
+
];
|
36
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
37
|
+
const connection = (0, clients_1.getClientSolana)();
|
38
|
+
const sources = [];
|
39
|
+
for (const tokenInfo of feedsToFetch) {
|
40
|
+
const values = yield (0, getSwitchboardOnDemandPrice_1.getSwitchboardOnDemandPrices)(connection, tokenInfo.feedsAddresses.map((t) => new web3_js_1.PublicKey(t)));
|
41
|
+
const decimals = yield (0, getCachedDecimalsForToken_1.getDecimalsForToken)(tokenInfo.mintAddress, portfolio_core_1.NetworkId.solana);
|
42
|
+
tokenInfo.feedsAddresses.forEach((feedToFetch, i) => {
|
43
|
+
const price = values.at(i);
|
44
|
+
if (!price || !decimals)
|
45
|
+
return;
|
46
|
+
const source = {
|
47
|
+
address: tokenInfo.mintAddress,
|
48
|
+
decimals,
|
49
|
+
id: `${constants_1.platformId}-feed-${feedToFetch.toString()}`,
|
50
|
+
networkId: tokenInfo.networkId,
|
51
|
+
platformId: constants_2.walletTokensPlatform.id,
|
52
|
+
weight: 0.8,
|
53
|
+
timestamp: Date.now(),
|
54
|
+
price,
|
55
|
+
};
|
56
|
+
sources.push(source);
|
57
|
+
});
|
58
|
+
}
|
59
|
+
yield cache.setTokenPriceSources(sources);
|
60
|
+
});
|
61
|
+
const job = {
|
62
|
+
id: `${constants_1.platformId}-ondemand-pricing`,
|
63
|
+
executor,
|
64
|
+
label: 'realtime',
|
65
|
+
};
|
66
|
+
exports.default = job;
|
67
|
+
//# sourceMappingURL=onDemandPricingJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"onDemandPricingJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/switchboard/onDemandPricingJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAG5C,2CAAyC;AACzC,iDAAsD;AACtD,mDAA2D;AAC3D,uFAAqF;AACrF,0FAAiF;AAEjF,+CAAoD;AAEpD,MAAM,YAAY,GAAkC;IAClD;QACE,cAAc,EAAE;YACd,8CAA8C;YAC9C,8CAA8C;YAC9C,8CAA8C;SAC/C;QACD,SAAS,EAAE,0BAAS,CAAC,MAAM;QAC3B,WAAW,EAAE,2CAA0B;KACxC;IACD;QACE,cAAc,EAAE,CAAC,8CAA8C,CAAC;QAChE,WAAW,EAAE,uBAAc;QAC3B,SA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