pyre-world-kit 3.2.0 → 3.2.1
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.
|
@@ -24,6 +24,8 @@ export declare class StateProvider implements State {
|
|
|
24
24
|
record(action: TrackedAction, mint?: string, description?: string): Promise<void>;
|
|
25
25
|
private updateSentiment;
|
|
26
26
|
onCheckpointDue: (() => void) | null;
|
|
27
|
+
/** Sync totalSolSpent/Received from on-chain vault data (fresh read) */
|
|
28
|
+
private syncPnl;
|
|
27
29
|
getHoldings(): Promise<Map<string, number>>;
|
|
28
30
|
getBalance(mint: string): Promise<number>;
|
|
29
31
|
getSentiment(mint: string): number;
|
|
@@ -196,6 +196,10 @@ class StateProvider {
|
|
|
196
196
|
this._state.recentHistory = this._state.recentHistory.slice(-20);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
+
// Sync P&L from vault every 10 ticks
|
|
200
|
+
if (this._state.tick % 10 === 0) {
|
|
201
|
+
this.syncPnl();
|
|
202
|
+
}
|
|
199
203
|
if (this.checkpointConfig && this.ticksSinceCheckpoint >= this.checkpointConfig.interval) {
|
|
200
204
|
this.ticksSinceCheckpoint = 0;
|
|
201
205
|
this.onCheckpointDue?.();
|
|
@@ -222,6 +226,20 @@ class StateProvider {
|
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
onCheckpointDue = null;
|
|
229
|
+
/** Sync totalSolSpent/Received from on-chain vault data (fresh read) */
|
|
230
|
+
async syncPnl() {
|
|
231
|
+
if (!this._state)
|
|
232
|
+
return;
|
|
233
|
+
try {
|
|
234
|
+
const { getVaultForWallet } = await torchsdkImport;
|
|
235
|
+
const vault = await getVaultForWallet(this.connection, this.publicKey);
|
|
236
|
+
if (vault) {
|
|
237
|
+
this._state.totalSolSpent = Math.round(vault.total_spent * 1e9);
|
|
238
|
+
this._state.totalSolReceived = Math.round(vault.total_received * 1e9);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch { }
|
|
242
|
+
}
|
|
225
243
|
async getHoldings() {
|
|
226
244
|
const { TOKEN_2022_PROGRAM_ID } = await splTokenImport;
|
|
227
245
|
const walletPk = new web3_js_1.PublicKey(this.publicKey);
|
package/package.json
CHANGED
|
@@ -190,6 +190,11 @@ export class StateProvider implements State {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
// Sync P&L from vault every 10 ticks
|
|
194
|
+
if (this._state.tick % 10 === 0) {
|
|
195
|
+
this.syncPnl()
|
|
196
|
+
}
|
|
197
|
+
|
|
193
198
|
if (this.checkpointConfig && this.ticksSinceCheckpoint >= this.checkpointConfig.interval) {
|
|
194
199
|
this.ticksSinceCheckpoint = 0
|
|
195
200
|
this.onCheckpointDue?.()
|
|
@@ -219,6 +224,19 @@ export class StateProvider implements State {
|
|
|
219
224
|
|
|
220
225
|
onCheckpointDue: (() => void) | null = null
|
|
221
226
|
|
|
227
|
+
/** Sync totalSolSpent/Received from on-chain vault data (fresh read) */
|
|
228
|
+
private async syncPnl(): Promise<void> {
|
|
229
|
+
if (!this._state) return
|
|
230
|
+
try {
|
|
231
|
+
const { getVaultForWallet } = await torchsdkImport
|
|
232
|
+
const vault = await getVaultForWallet(this.connection, this.publicKey)
|
|
233
|
+
if (vault) {
|
|
234
|
+
this._state.totalSolSpent = Math.round(vault.total_spent * 1e9)
|
|
235
|
+
this._state.totalSolReceived = Math.round(vault.total_received * 1e9)
|
|
236
|
+
}
|
|
237
|
+
} catch {}
|
|
238
|
+
}
|
|
239
|
+
|
|
222
240
|
async getHoldings(): Promise<Map<string, number>> {
|
|
223
241
|
const { TOKEN_2022_PROGRAM_ID } = await splTokenImport
|
|
224
242
|
const walletPk = new PublicKey(this.publicKey)
|