@strkfarm/sdk 1.1.20 → 1.1.22
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/dist/index.browser.global.js +7 -7
- package/dist/index.browser.mjs +7 -7
- package/dist/index.d.ts +19 -1
- package/dist/index.js +95 -7
- package/dist/index.mjs +94 -7
- package/package.json +1 -1
- package/src/notifs/index.ts +2 -1
- package/src/notifs/telegram-group.ts +115 -0
- package/src/strategies/universal-strategy.tsx +3 -3
- package/src/strategies/vesu-rebalance.tsx +4 -5
|
@@ -61284,15 +61284,15 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
61284
61284
|
}
|
|
61285
61285
|
async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
|
|
61286
61286
|
const vesuPosition = vesuPositions.find(
|
|
61287
|
-
(d) => d.
|
|
61287
|
+
(d) => ContractAddr.from(d.id).eq(p.pool_id)
|
|
61288
61288
|
);
|
|
61289
61289
|
const _pool = pools.find((d) => {
|
|
61290
61290
|
logger2.verbose(
|
|
61291
|
-
`pool check: ${d.id
|
|
61291
|
+
`pool check: ${ContractAddr.from(d.id).eq(p.pool_id)}, id: ${d.id}, pool_id: ${num_exports.getDecimalString(
|
|
61292
61292
|
p.pool_id.address.toString()
|
|
61293
61293
|
)}`
|
|
61294
61294
|
);
|
|
61295
|
-
return d.id
|
|
61295
|
+
return ContractAddr.from(d.id).eq(p.pool_id);
|
|
61296
61296
|
});
|
|
61297
61297
|
logger2.verbose(`pool: ${JSON.stringify(_pool)}`);
|
|
61298
61298
|
logger2.verbose(typeof _pool);
|
|
@@ -61447,7 +61447,7 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
61447
61447
|
);
|
|
61448
61448
|
pools = data.data;
|
|
61449
61449
|
for (const pool of vesu_pools_default.data) {
|
|
61450
|
-
const found = pools.find((d) => d.id
|
|
61450
|
+
const found = pools.find((d) => ContractAddr.from(d.id).eqString(pool.id));
|
|
61451
61451
|
if (!found) {
|
|
61452
61452
|
logger2.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
|
|
61453
61453
|
logger2.verbose(
|
|
@@ -78263,7 +78263,7 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
78263
78263
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
78264
78264
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
78265
78265
|
} else {
|
|
78266
|
-
vesuAum = vesuAum.plus(legAUM[
|
|
78266
|
+
vesuAum = vesuAum.plus(legAUM[0].usdValue / tokenUnderlyingPrice.price);
|
|
78267
78267
|
}
|
|
78268
78268
|
if (legAUM[1].token.address.eq(underlying.address)) {
|
|
78269
78269
|
vesuAum = vesuAum.minus(legAUM[1].amount);
|
|
@@ -78296,7 +78296,8 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
78296
78296
|
amount: zeroAmt,
|
|
78297
78297
|
usdValue: 0
|
|
78298
78298
|
};
|
|
78299
|
-
|
|
78299
|
+
const aumToken = vesuAum.plus(balance.amount);
|
|
78300
|
+
if (aumToken.isZero()) {
|
|
78300
78301
|
return { net, splits: [{
|
|
78301
78302
|
aum: zeroAmt,
|
|
78302
78303
|
id: "finalised" /* FINALISED */
|
|
@@ -78305,7 +78306,6 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
78305
78306
|
id: "defispring" /* DEFISPRING */
|
|
78306
78307
|
}], prevAum };
|
|
78307
78308
|
}
|
|
78308
|
-
const aumToken = vesuAum.plus(balance.amount);
|
|
78309
78309
|
logger2.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
78310
78310
|
const rewardAssets = await this.getRewardsAUM(prevAum);
|
|
78311
78311
|
const newAUM = aumToken.plus(rewardAssets);
|
package/dist/index.browser.mjs
CHANGED
|
@@ -9691,15 +9691,15 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9691
9691
|
}
|
|
9692
9692
|
async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
|
|
9693
9693
|
const vesuPosition = vesuPositions.find(
|
|
9694
|
-
(d) => d.
|
|
9694
|
+
(d) => ContractAddr.from(d.id).eq(p.pool_id)
|
|
9695
9695
|
);
|
|
9696
9696
|
const _pool = pools.find((d) => {
|
|
9697
9697
|
logger.verbose(
|
|
9698
|
-
`pool check: ${d.id
|
|
9698
|
+
`pool check: ${ContractAddr.from(d.id).eq(p.pool_id)}, id: ${d.id}, pool_id: ${num4.getDecimalString(
|
|
9699
9699
|
p.pool_id.address.toString()
|
|
9700
9700
|
)}`
|
|
9701
9701
|
);
|
|
9702
|
-
return d.id
|
|
9702
|
+
return ContractAddr.from(d.id).eq(p.pool_id);
|
|
9703
9703
|
});
|
|
9704
9704
|
logger.verbose(`pool: ${JSON.stringify(_pool)}`);
|
|
9705
9705
|
logger.verbose(typeof _pool);
|
|
@@ -9854,7 +9854,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9854
9854
|
);
|
|
9855
9855
|
pools = data.data;
|
|
9856
9856
|
for (const pool of vesu_pools_default.data) {
|
|
9857
|
-
const found = pools.find((d) => d.id
|
|
9857
|
+
const found = pools.find((d) => ContractAddr.from(d.id).eqString(pool.id));
|
|
9858
9858
|
if (!found) {
|
|
9859
9859
|
logger.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
|
|
9860
9860
|
logger.verbose(
|
|
@@ -26690,7 +26690,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26690
26690
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
26691
26691
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
26692
26692
|
} else {
|
|
26693
|
-
vesuAum = vesuAum.plus(legAUM[
|
|
26693
|
+
vesuAum = vesuAum.plus(legAUM[0].usdValue / tokenUnderlyingPrice.price);
|
|
26694
26694
|
}
|
|
26695
26695
|
if (legAUM[1].token.address.eq(underlying.address)) {
|
|
26696
26696
|
vesuAum = vesuAum.minus(legAUM[1].amount);
|
|
@@ -26723,7 +26723,8 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26723
26723
|
amount: zeroAmt,
|
|
26724
26724
|
usdValue: 0
|
|
26725
26725
|
};
|
|
26726
|
-
|
|
26726
|
+
const aumToken = vesuAum.plus(balance.amount);
|
|
26727
|
+
if (aumToken.isZero()) {
|
|
26727
26728
|
return { net, splits: [{
|
|
26728
26729
|
aum: zeroAmt,
|
|
26729
26730
|
id: "finalised" /* FINALISED */
|
|
@@ -26732,7 +26733,6 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26732
26733
|
id: "defispring" /* DEFISPRING */
|
|
26733
26734
|
}], prevAum };
|
|
26734
26735
|
}
|
|
26735
|
-
const aumToken = vesuAum.plus(balance.amount);
|
|
26736
26736
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
26737
26737
|
const rewardAssets = await this.getRewardsAUM(prevAum);
|
|
26738
26738
|
const newAUM = aumToken.plus(rewardAssets);
|
package/dist/index.d.ts
CHANGED
|
@@ -1382,6 +1382,24 @@ declare class TelegramNotif {
|
|
|
1382
1382
|
sendMessage(msg: string): void;
|
|
1383
1383
|
}
|
|
1384
1384
|
|
|
1385
|
+
declare class TelegramGroupNotif {
|
|
1386
|
+
readonly bot: TelegramBot;
|
|
1387
|
+
private groupId;
|
|
1388
|
+
private topicId?;
|
|
1389
|
+
constructor(token: string, groupId: string, topicId?: number);
|
|
1390
|
+
activateChatBot(): void;
|
|
1391
|
+
sendMessage(msg: string): void;
|
|
1392
|
+
sendFormattedMessage(msg: string, parseMode?: 'HTML' | 'Markdown' | 'MarkdownV2'): void;
|
|
1393
|
+
sendPhoto(photo: string | Buffer, caption?: string): void;
|
|
1394
|
+
getGroupInfo(): {
|
|
1395
|
+
groupId: string;
|
|
1396
|
+
topicId: number | undefined;
|
|
1397
|
+
hasTopic: boolean;
|
|
1398
|
+
};
|
|
1399
|
+
updateGroupId(newGroupId: string): void;
|
|
1400
|
+
updateTopicId(newTopicId?: number): void;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1385
1403
|
declare class PricerRedis extends Pricer {
|
|
1386
1404
|
private redisClient;
|
|
1387
1405
|
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
@@ -1506,4 +1524,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
1506
1524
|
decrypt(encryptedData: string, password: string): any;
|
|
1507
1525
|
}
|
|
1508
1526
|
|
|
1509
|
-
export { AUMTypes, AVNU_MIDDLEWARE, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type Swap, type SwapInfo, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, VESU_SINGLETON, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getContractDetails, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, logger, toBigInt };
|
|
1527
|
+
export { AUMTypes, AVNU_MIDDLEWARE, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, VESU_SINGLETON, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getContractDetails, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, logger, toBigInt };
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,7 @@ __export(index_exports, {
|
|
|
67
67
|
SenseiVault: () => SenseiVault,
|
|
68
68
|
StandardMerkleTree: () => StandardMerkleTree,
|
|
69
69
|
Store: () => Store,
|
|
70
|
+
TelegramGroupNotif: () => TelegramGroupNotif,
|
|
70
71
|
TelegramNotif: () => TelegramNotif,
|
|
71
72
|
UNIVERSAL_ADAPTERS: () => UNIVERSAL_ADAPTERS,
|
|
72
73
|
UNIVERSAL_MANAGE_IDS: () => UNIVERSAL_MANAGE_IDS,
|
|
@@ -9790,15 +9791,15 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9790
9791
|
}
|
|
9791
9792
|
async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
|
|
9792
9793
|
const vesuPosition = vesuPositions.find(
|
|
9793
|
-
(d) => d.
|
|
9794
|
+
(d) => ContractAddr.from(d.id).eq(p.pool_id)
|
|
9794
9795
|
);
|
|
9795
9796
|
const _pool = pools.find((d) => {
|
|
9796
9797
|
logger.verbose(
|
|
9797
|
-
`pool check: ${d.id
|
|
9798
|
+
`pool check: ${ContractAddr.from(d.id).eq(p.pool_id)}, id: ${d.id}, pool_id: ${import_starknet10.num.getDecimalString(
|
|
9798
9799
|
p.pool_id.address.toString()
|
|
9799
9800
|
)}`
|
|
9800
9801
|
);
|
|
9801
|
-
return d.id
|
|
9802
|
+
return ContractAddr.from(d.id).eq(p.pool_id);
|
|
9802
9803
|
});
|
|
9803
9804
|
logger.verbose(`pool: ${JSON.stringify(_pool)}`);
|
|
9804
9805
|
logger.verbose(typeof _pool);
|
|
@@ -9953,7 +9954,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9953
9954
|
);
|
|
9954
9955
|
pools = data.data;
|
|
9955
9956
|
for (const pool of vesu_pools_default.data) {
|
|
9956
|
-
const found = pools.find((d) => d.id
|
|
9957
|
+
const found = pools.find((d) => ContractAddr.from(d.id).eqString(pool.id));
|
|
9957
9958
|
if (!found) {
|
|
9958
9959
|
logger.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
|
|
9959
9960
|
logger.verbose(
|
|
@@ -26785,7 +26786,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26785
26786
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
26786
26787
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
26787
26788
|
} else {
|
|
26788
|
-
vesuAum = vesuAum.plus(legAUM[
|
|
26789
|
+
vesuAum = vesuAum.plus(legAUM[0].usdValue / tokenUnderlyingPrice.price);
|
|
26789
26790
|
}
|
|
26790
26791
|
if (legAUM[1].token.address.eq(underlying.address)) {
|
|
26791
26792
|
vesuAum = vesuAum.minus(legAUM[1].amount);
|
|
@@ -26818,7 +26819,8 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26818
26819
|
amount: zeroAmt,
|
|
26819
26820
|
usdValue: 0
|
|
26820
26821
|
};
|
|
26821
|
-
|
|
26822
|
+
const aumToken = vesuAum.plus(balance.amount);
|
|
26823
|
+
if (aumToken.isZero()) {
|
|
26822
26824
|
return { net, splits: [{
|
|
26823
26825
|
aum: zeroAmt,
|
|
26824
26826
|
id: "finalised" /* FINALISED */
|
|
@@ -26827,7 +26829,6 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26827
26829
|
id: "defispring" /* DEFISPRING */
|
|
26828
26830
|
}], prevAum };
|
|
26829
26831
|
}
|
|
26830
|
-
const aumToken = vesuAum.plus(balance.amount);
|
|
26831
26832
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
26832
26833
|
const rewardAssets = await this.getRewardsAUM(prevAum);
|
|
26833
26834
|
const newAUM = aumToken.plus(rewardAssets);
|
|
@@ -28028,6 +28029,92 @@ var TelegramNotif = class {
|
|
|
28028
28029
|
}
|
|
28029
28030
|
};
|
|
28030
28031
|
|
|
28032
|
+
// src/notifs/telegram-group.ts
|
|
28033
|
+
var import_node_telegram_bot_api2 = __toESM(require("node-telegram-bot-api"));
|
|
28034
|
+
var TelegramGroupNotif = class {
|
|
28035
|
+
constructor(token, groupId, topicId) {
|
|
28036
|
+
this.bot = new import_node_telegram_bot_api2.default(token, { polling: true });
|
|
28037
|
+
this.groupId = groupId;
|
|
28038
|
+
this.topicId = topicId;
|
|
28039
|
+
}
|
|
28040
|
+
// listen to start msgs, register chatId and send registered msg
|
|
28041
|
+
activateChatBot() {
|
|
28042
|
+
this.bot.on("message", (msg) => {
|
|
28043
|
+
console.log(`Tg: Message received: `, msg);
|
|
28044
|
+
const chatId = msg.chat.id;
|
|
28045
|
+
let text = msg.text.toLowerCase().trim();
|
|
28046
|
+
console.log(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`, msg);
|
|
28047
|
+
logger.verbose(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`);
|
|
28048
|
+
});
|
|
28049
|
+
}
|
|
28050
|
+
// send a message to the group
|
|
28051
|
+
sendMessage(msg) {
|
|
28052
|
+
logger.verbose(`Tg Group: Sending message to group ${this.groupId}: ${msg}`);
|
|
28053
|
+
const messageOptions = {};
|
|
28054
|
+
if (this.topicId !== void 0) {
|
|
28055
|
+
messageOptions.message_thread_id = this.topicId;
|
|
28056
|
+
}
|
|
28057
|
+
this.bot.sendMessage(this.groupId, msg, messageOptions).catch((err) => {
|
|
28058
|
+
logger.error(`Tg Group: Error sending message to group ${this.groupId}`);
|
|
28059
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
28060
|
+
}).then(() => {
|
|
28061
|
+
logger.verbose(`Tg Group: Message sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ""}`);
|
|
28062
|
+
});
|
|
28063
|
+
}
|
|
28064
|
+
// send a message with specific formatting options
|
|
28065
|
+
sendFormattedMessage(msg, parseMode) {
|
|
28066
|
+
logger.verbose(`Tg Group: Sending formatted message to group ${this.groupId}: ${msg}`);
|
|
28067
|
+
const messageOptions = {};
|
|
28068
|
+
if (this.topicId !== void 0) {
|
|
28069
|
+
messageOptions.message_thread_id = this.topicId;
|
|
28070
|
+
}
|
|
28071
|
+
if (parseMode) {
|
|
28072
|
+
messageOptions.parse_mode = parseMode;
|
|
28073
|
+
}
|
|
28074
|
+
this.bot.sendMessage(this.groupId, msg, messageOptions).catch((err) => {
|
|
28075
|
+
logger.error(`Tg Group: Error sending formatted message to group ${this.groupId}`);
|
|
28076
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
28077
|
+
}).then(() => {
|
|
28078
|
+
logger.verbose(`Tg Group: Formatted message sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ""}`);
|
|
28079
|
+
});
|
|
28080
|
+
}
|
|
28081
|
+
// send a photo to the group
|
|
28082
|
+
sendPhoto(photo, caption) {
|
|
28083
|
+
logger.verbose(`Tg Group: Sending photo to group ${this.groupId}`);
|
|
28084
|
+
const messageOptions = {};
|
|
28085
|
+
if (this.topicId !== void 0) {
|
|
28086
|
+
messageOptions.message_thread_id = this.topicId;
|
|
28087
|
+
}
|
|
28088
|
+
if (caption) {
|
|
28089
|
+
messageOptions.caption = caption;
|
|
28090
|
+
}
|
|
28091
|
+
this.bot.sendPhoto(this.groupId, photo, messageOptions).catch((err) => {
|
|
28092
|
+
logger.error(`Tg Group: Error sending photo to group ${this.groupId}`);
|
|
28093
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
28094
|
+
}).then(() => {
|
|
28095
|
+
logger.verbose(`Tg Group: Photo sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ""}`);
|
|
28096
|
+
});
|
|
28097
|
+
}
|
|
28098
|
+
// get group information
|
|
28099
|
+
getGroupInfo() {
|
|
28100
|
+
return {
|
|
28101
|
+
groupId: this.groupId,
|
|
28102
|
+
topicId: this.topicId,
|
|
28103
|
+
hasTopic: this.topicId !== void 0
|
|
28104
|
+
};
|
|
28105
|
+
}
|
|
28106
|
+
// update group ID (useful if group ID changes)
|
|
28107
|
+
updateGroupId(newGroupId) {
|
|
28108
|
+
this.groupId = newGroupId;
|
|
28109
|
+
logger.verbose(`Tg Group: Updated group ID to ${newGroupId}`);
|
|
28110
|
+
}
|
|
28111
|
+
// update topic ID (useful for switching topics)
|
|
28112
|
+
updateTopicId(newTopicId) {
|
|
28113
|
+
this.topicId = newTopicId;
|
|
28114
|
+
logger.verbose(`Tg Group: Updated topic ID to ${newTopicId || "none"}`);
|
|
28115
|
+
}
|
|
28116
|
+
};
|
|
28117
|
+
|
|
28031
28118
|
// src/node/pricer-redis.ts
|
|
28032
28119
|
var import_redis = require("redis");
|
|
28033
28120
|
var PricerRedis = class extends Pricer {
|
|
@@ -28446,6 +28533,7 @@ var deployer_default = Deployer;
|
|
|
28446
28533
|
SenseiVault,
|
|
28447
28534
|
StandardMerkleTree,
|
|
28448
28535
|
Store,
|
|
28536
|
+
TelegramGroupNotif,
|
|
28449
28537
|
TelegramNotif,
|
|
28450
28538
|
UNIVERSAL_ADAPTERS,
|
|
28451
28539
|
UNIVERSAL_MANAGE_IDS,
|
package/dist/index.mjs
CHANGED
|
@@ -9690,15 +9690,15 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9690
9690
|
}
|
|
9691
9691
|
async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
|
|
9692
9692
|
const vesuPosition = vesuPositions.find(
|
|
9693
|
-
(d) => d.
|
|
9693
|
+
(d) => ContractAddr.from(d.id).eq(p.pool_id)
|
|
9694
9694
|
);
|
|
9695
9695
|
const _pool = pools.find((d) => {
|
|
9696
9696
|
logger.verbose(
|
|
9697
|
-
`pool check: ${d.id
|
|
9697
|
+
`pool check: ${ContractAddr.from(d.id).eq(p.pool_id)}, id: ${d.id}, pool_id: ${num4.getDecimalString(
|
|
9698
9698
|
p.pool_id.address.toString()
|
|
9699
9699
|
)}`
|
|
9700
9700
|
);
|
|
9701
|
-
return d.id
|
|
9701
|
+
return ContractAddr.from(d.id).eq(p.pool_id);
|
|
9702
9702
|
});
|
|
9703
9703
|
logger.verbose(`pool: ${JSON.stringify(_pool)}`);
|
|
9704
9704
|
logger.verbose(typeof _pool);
|
|
@@ -9853,7 +9853,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9853
9853
|
);
|
|
9854
9854
|
pools = data.data;
|
|
9855
9855
|
for (const pool of vesu_pools_default.data) {
|
|
9856
|
-
const found = pools.find((d) => d.id
|
|
9856
|
+
const found = pools.find((d) => ContractAddr.from(d.id).eqString(pool.id));
|
|
9857
9857
|
if (!found) {
|
|
9858
9858
|
logger.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
|
|
9859
9859
|
logger.verbose(
|
|
@@ -26689,7 +26689,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26689
26689
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
26690
26690
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
26691
26691
|
} else {
|
|
26692
|
-
vesuAum = vesuAum.plus(legAUM[
|
|
26692
|
+
vesuAum = vesuAum.plus(legAUM[0].usdValue / tokenUnderlyingPrice.price);
|
|
26693
26693
|
}
|
|
26694
26694
|
if (legAUM[1].token.address.eq(underlying.address)) {
|
|
26695
26695
|
vesuAum = vesuAum.minus(legAUM[1].amount);
|
|
@@ -26722,7 +26722,8 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26722
26722
|
amount: zeroAmt,
|
|
26723
26723
|
usdValue: 0
|
|
26724
26724
|
};
|
|
26725
|
-
|
|
26725
|
+
const aumToken = vesuAum.plus(balance.amount);
|
|
26726
|
+
if (aumToken.isZero()) {
|
|
26726
26727
|
return { net, splits: [{
|
|
26727
26728
|
aum: zeroAmt,
|
|
26728
26729
|
id: "finalised" /* FINALISED */
|
|
@@ -26731,7 +26732,6 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26731
26732
|
id: "defispring" /* DEFISPRING */
|
|
26732
26733
|
}], prevAum };
|
|
26733
26734
|
}
|
|
26734
|
-
const aumToken = vesuAum.plus(balance.amount);
|
|
26735
26735
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
26736
26736
|
const rewardAssets = await this.getRewardsAUM(prevAum);
|
|
26737
26737
|
const newAUM = aumToken.plus(rewardAssets);
|
|
@@ -27932,6 +27932,92 @@ var TelegramNotif = class {
|
|
|
27932
27932
|
}
|
|
27933
27933
|
};
|
|
27934
27934
|
|
|
27935
|
+
// src/notifs/telegram-group.ts
|
|
27936
|
+
import TelegramBot2 from "node-telegram-bot-api";
|
|
27937
|
+
var TelegramGroupNotif = class {
|
|
27938
|
+
constructor(token, groupId, topicId) {
|
|
27939
|
+
this.bot = new TelegramBot2(token, { polling: true });
|
|
27940
|
+
this.groupId = groupId;
|
|
27941
|
+
this.topicId = topicId;
|
|
27942
|
+
}
|
|
27943
|
+
// listen to start msgs, register chatId and send registered msg
|
|
27944
|
+
activateChatBot() {
|
|
27945
|
+
this.bot.on("message", (msg) => {
|
|
27946
|
+
console.log(`Tg: Message received: `, msg);
|
|
27947
|
+
const chatId = msg.chat.id;
|
|
27948
|
+
let text = msg.text.toLowerCase().trim();
|
|
27949
|
+
console.log(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`, msg);
|
|
27950
|
+
logger.verbose(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`);
|
|
27951
|
+
});
|
|
27952
|
+
}
|
|
27953
|
+
// send a message to the group
|
|
27954
|
+
sendMessage(msg) {
|
|
27955
|
+
logger.verbose(`Tg Group: Sending message to group ${this.groupId}: ${msg}`);
|
|
27956
|
+
const messageOptions = {};
|
|
27957
|
+
if (this.topicId !== void 0) {
|
|
27958
|
+
messageOptions.message_thread_id = this.topicId;
|
|
27959
|
+
}
|
|
27960
|
+
this.bot.sendMessage(this.groupId, msg, messageOptions).catch((err) => {
|
|
27961
|
+
logger.error(`Tg Group: Error sending message to group ${this.groupId}`);
|
|
27962
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
27963
|
+
}).then(() => {
|
|
27964
|
+
logger.verbose(`Tg Group: Message sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ""}`);
|
|
27965
|
+
});
|
|
27966
|
+
}
|
|
27967
|
+
// send a message with specific formatting options
|
|
27968
|
+
sendFormattedMessage(msg, parseMode) {
|
|
27969
|
+
logger.verbose(`Tg Group: Sending formatted message to group ${this.groupId}: ${msg}`);
|
|
27970
|
+
const messageOptions = {};
|
|
27971
|
+
if (this.topicId !== void 0) {
|
|
27972
|
+
messageOptions.message_thread_id = this.topicId;
|
|
27973
|
+
}
|
|
27974
|
+
if (parseMode) {
|
|
27975
|
+
messageOptions.parse_mode = parseMode;
|
|
27976
|
+
}
|
|
27977
|
+
this.bot.sendMessage(this.groupId, msg, messageOptions).catch((err) => {
|
|
27978
|
+
logger.error(`Tg Group: Error sending formatted message to group ${this.groupId}`);
|
|
27979
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
27980
|
+
}).then(() => {
|
|
27981
|
+
logger.verbose(`Tg Group: Formatted message sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ""}`);
|
|
27982
|
+
});
|
|
27983
|
+
}
|
|
27984
|
+
// send a photo to the group
|
|
27985
|
+
sendPhoto(photo, caption) {
|
|
27986
|
+
logger.verbose(`Tg Group: Sending photo to group ${this.groupId}`);
|
|
27987
|
+
const messageOptions = {};
|
|
27988
|
+
if (this.topicId !== void 0) {
|
|
27989
|
+
messageOptions.message_thread_id = this.topicId;
|
|
27990
|
+
}
|
|
27991
|
+
if (caption) {
|
|
27992
|
+
messageOptions.caption = caption;
|
|
27993
|
+
}
|
|
27994
|
+
this.bot.sendPhoto(this.groupId, photo, messageOptions).catch((err) => {
|
|
27995
|
+
logger.error(`Tg Group: Error sending photo to group ${this.groupId}`);
|
|
27996
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
27997
|
+
}).then(() => {
|
|
27998
|
+
logger.verbose(`Tg Group: Photo sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ""}`);
|
|
27999
|
+
});
|
|
28000
|
+
}
|
|
28001
|
+
// get group information
|
|
28002
|
+
getGroupInfo() {
|
|
28003
|
+
return {
|
|
28004
|
+
groupId: this.groupId,
|
|
28005
|
+
topicId: this.topicId,
|
|
28006
|
+
hasTopic: this.topicId !== void 0
|
|
28007
|
+
};
|
|
28008
|
+
}
|
|
28009
|
+
// update group ID (useful if group ID changes)
|
|
28010
|
+
updateGroupId(newGroupId) {
|
|
28011
|
+
this.groupId = newGroupId;
|
|
28012
|
+
logger.verbose(`Tg Group: Updated group ID to ${newGroupId}`);
|
|
28013
|
+
}
|
|
28014
|
+
// update topic ID (useful for switching topics)
|
|
28015
|
+
updateTopicId(newTopicId) {
|
|
28016
|
+
this.topicId = newTopicId;
|
|
28017
|
+
logger.verbose(`Tg Group: Updated topic ID to ${newTopicId || "none"}`);
|
|
28018
|
+
}
|
|
28019
|
+
};
|
|
28020
|
+
|
|
27935
28021
|
// src/node/pricer-redis.ts
|
|
27936
28022
|
import { createClient } from "redis";
|
|
27937
28023
|
var PricerRedis = class extends Pricer {
|
|
@@ -28349,6 +28435,7 @@ export {
|
|
|
28349
28435
|
SenseiVault,
|
|
28350
28436
|
StandardMerkleTree,
|
|
28351
28437
|
Store,
|
|
28438
|
+
TelegramGroupNotif,
|
|
28352
28439
|
TelegramNotif,
|
|
28353
28440
|
UNIVERSAL_ADAPTERS,
|
|
28354
28441
|
UNIVERSAL_MANAGE_IDS,
|
package/package.json
CHANGED
package/src/notifs/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './telegram';
|
|
1
|
+
export * from './telegram';
|
|
2
|
+
export * from './telegram-group';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import TelegramBot from "node-telegram-bot-api";
|
|
2
|
+
import { logger } from "@/utils/logger";
|
|
3
|
+
|
|
4
|
+
export class TelegramGroupNotif {
|
|
5
|
+
readonly bot: TelegramBot;
|
|
6
|
+
private groupId: string;
|
|
7
|
+
private topicId?: number;
|
|
8
|
+
|
|
9
|
+
constructor(token: string, groupId: string, topicId?: number) {
|
|
10
|
+
this.bot = new TelegramBot(token, { polling: true });
|
|
11
|
+
this.groupId = groupId;
|
|
12
|
+
this.topicId = topicId;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// listen to start msgs, register chatId and send registered msg
|
|
16
|
+
activateChatBot() {
|
|
17
|
+
this.bot.on('message', (msg: any) => {
|
|
18
|
+
console.log(`Tg: Message received: `, msg)
|
|
19
|
+
const chatId = msg.chat.id;
|
|
20
|
+
let text = msg.text.toLowerCase().trim()
|
|
21
|
+
console.log(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`, msg)
|
|
22
|
+
logger.verbose(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// send a message to the group
|
|
27
|
+
sendMessage(msg: string) {
|
|
28
|
+
logger.verbose(`Tg Group: Sending message to group ${this.groupId}: ${msg}`);
|
|
29
|
+
|
|
30
|
+
const messageOptions: any = {};
|
|
31
|
+
|
|
32
|
+
// If topicId is provided, add it to the message options for supergroups with topics
|
|
33
|
+
if (this.topicId !== undefined) {
|
|
34
|
+
messageOptions.message_thread_id = this.topicId;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.bot.sendMessage(this.groupId, msg, messageOptions)
|
|
38
|
+
.catch((err: any) => {
|
|
39
|
+
logger.error(`Tg Group: Error sending message to group ${this.groupId}`);
|
|
40
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
41
|
+
})
|
|
42
|
+
.then(() => {
|
|
43
|
+
logger.verbose(`Tg Group: Message sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ''}`);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// send a message with specific formatting options
|
|
48
|
+
sendFormattedMessage(msg: string, parseMode?: 'HTML' | 'Markdown' | 'MarkdownV2') {
|
|
49
|
+
logger.verbose(`Tg Group: Sending formatted message to group ${this.groupId}: ${msg}`);
|
|
50
|
+
|
|
51
|
+
const messageOptions: any = {};
|
|
52
|
+
|
|
53
|
+
if (this.topicId !== undefined) {
|
|
54
|
+
messageOptions.message_thread_id = this.topicId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (parseMode) {
|
|
58
|
+
messageOptions.parse_mode = parseMode;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.bot.sendMessage(this.groupId, msg, messageOptions)
|
|
62
|
+
.catch((err: any) => {
|
|
63
|
+
logger.error(`Tg Group: Error sending formatted message to group ${this.groupId}`);
|
|
64
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
65
|
+
})
|
|
66
|
+
.then(() => {
|
|
67
|
+
logger.verbose(`Tg Group: Formatted message sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ''}`);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// send a photo to the group
|
|
72
|
+
sendPhoto(photo: string | Buffer, caption?: string) {
|
|
73
|
+
logger.verbose(`Tg Group: Sending photo to group ${this.groupId}`);
|
|
74
|
+
|
|
75
|
+
const messageOptions: any = {};
|
|
76
|
+
|
|
77
|
+
if (this.topicId !== undefined) {
|
|
78
|
+
messageOptions.message_thread_id = this.topicId;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (caption) {
|
|
82
|
+
messageOptions.caption = caption;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.bot.sendPhoto(this.groupId, photo, messageOptions)
|
|
86
|
+
.catch((err: any) => {
|
|
87
|
+
logger.error(`Tg Group: Error sending photo to group ${this.groupId}`);
|
|
88
|
+
logger.error(`Tg Group: Error details: ${err.message}`);
|
|
89
|
+
})
|
|
90
|
+
.then(() => {
|
|
91
|
+
logger.verbose(`Tg Group: Photo sent to group ${this.groupId}${this.topicId ? ` (topic: ${this.topicId})` : ''}`);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// get group information
|
|
96
|
+
getGroupInfo() {
|
|
97
|
+
return {
|
|
98
|
+
groupId: this.groupId,
|
|
99
|
+
topicId: this.topicId,
|
|
100
|
+
hasTopic: this.topicId !== undefined
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// update group ID (useful if group ID changes)
|
|
105
|
+
updateGroupId(newGroupId: string) {
|
|
106
|
+
this.groupId = newGroupId;
|
|
107
|
+
logger.verbose(`Tg Group: Updated group ID to ${newGroupId}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// update topic ID (useful for switching topics)
|
|
111
|
+
updateTopicId(newTopicId?: number) {
|
|
112
|
+
this.topicId = newTopicId;
|
|
113
|
+
logger.verbose(`Tg Group: Updated topic ID to ${newTopicId || 'none'}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -317,7 +317,7 @@ export class UniversalStrategy<
|
|
|
317
317
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
318
318
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
319
319
|
} else {
|
|
320
|
-
vesuAum = vesuAum.plus(legAUM[
|
|
320
|
+
vesuAum = vesuAum.plus(legAUM[0].usdValue / tokenUnderlyingPrice.price);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
// handle debt
|
|
@@ -360,14 +360,14 @@ export class UniversalStrategy<
|
|
|
360
360
|
amount: zeroAmt,
|
|
361
361
|
usdValue: 0
|
|
362
362
|
};
|
|
363
|
-
|
|
363
|
+
const aumToken = vesuAum.plus(balance.amount);
|
|
364
|
+
if (aumToken.isZero()) {
|
|
364
365
|
return { net, splits: [{
|
|
365
366
|
aum: zeroAmt, id: AUMTypes.FINALISED
|
|
366
367
|
}, {
|
|
367
368
|
aum: zeroAmt, id: AUMTypes.DEFISPRING
|
|
368
369
|
}], prevAum};
|
|
369
370
|
}
|
|
370
|
-
const aumToken = vesuAum.plus(balance.amount);
|
|
371
371
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
372
372
|
|
|
373
373
|
// compute rewards contribution to AUM
|
|
@@ -252,18 +252,17 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
252
252
|
) {
|
|
253
253
|
const vesuPosition = vesuPositions.find(
|
|
254
254
|
(d: any) =>
|
|
255
|
-
d.
|
|
256
|
-
num.getDecimalString(p.pool_id.address.toString())
|
|
255
|
+
ContractAddr.from(d.id).eq(p.pool_id)
|
|
257
256
|
);
|
|
258
257
|
const _pool = pools.find((d: any) => {
|
|
259
258
|
logger.verbose(
|
|
260
259
|
`pool check: ${
|
|
261
|
-
d.id
|
|
260
|
+
ContractAddr.from(d.id).eq(p.pool_id)
|
|
262
261
|
}, id: ${d.id}, pool_id: ${num.getDecimalString(
|
|
263
262
|
p.pool_id.address.toString()
|
|
264
263
|
)}`
|
|
265
264
|
);
|
|
266
|
-
return d.id
|
|
265
|
+
return ContractAddr.from(d.id).eq(p.pool_id);
|
|
267
266
|
});
|
|
268
267
|
logger.verbose(`pool: ${JSON.stringify(_pool)}`);
|
|
269
268
|
logger.verbose(typeof _pool);
|
|
@@ -496,7 +495,7 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
496
495
|
|
|
497
496
|
// Vesu API is unstable sometimes, some Pools may be missing sometimes
|
|
498
497
|
for (const pool of VesuPoolIDs.data) {
|
|
499
|
-
const found = pools.find((d: any) => d.id
|
|
498
|
+
const found = pools.find((d: any) => ContractAddr.from(d.id).eqString(pool.id));
|
|
500
499
|
if (!found) {
|
|
501
500
|
logger.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
|
|
502
501
|
logger.verbose(
|