Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/price_pusher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-pusher",
"version": "9.3.1",
"version": "9.3.2",
"description": "Pyth Price Pusher",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down Expand Up @@ -59,10 +59,11 @@
"typescript": "catalog:"
},
"dependencies": {
"@aptos-labs/ts-sdk": "^1.39.0",
"@coral-xyz/anchor": "^0.30.0",
"@injectivelabs/networks": "1.14.47",
"@injectivelabs/utils": "^1.14.48",
"@injectivelabs/sdk-ts": "1.14.50",
"@injectivelabs/utils": "^1.14.48",
"@mysten/sui": "^1.3.0",
"@pythnetwork/hermes-client": "^1.3.1",
"@pythnetwork/price-service-sdk": "workspace:^",
Expand Down
23 changes: 10 additions & 13 deletions apps/price_pusher/src/aptos/balance-tracker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AptosClient } from "aptos";
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
import {
BaseBalanceTracker,
BaseBalanceTrackerConfig,
Expand All @@ -24,7 +24,7 @@ export interface AptosBalanceTrackerConfig extends BaseBalanceTrackerConfig {
* Aptos-specific implementation of the balance tracker
*/
export class AptosBalanceTracker extends BaseBalanceTracker {
private client: AptosClient;
private client: Aptos;
private aptosAddress: string;
private decimals: number;

Expand All @@ -33,8 +33,9 @@ export class AptosBalanceTracker extends BaseBalanceTracker {
...config,
logger: config.logger.child({ module: "AptosBalanceTracker" }),
});

this.client = new AptosClient(config.endpoint);
this.client = new Aptos(
new AptosConfig({ network: Network.CUSTOM, fullnode: config.endpoint }),
);
this.aptosAddress = config.address;
// APT has 8 decimal places by default
this.decimals = config.decimals ?? 8;
Expand All @@ -47,16 +48,12 @@ export class AptosBalanceTracker extends BaseBalanceTracker {
protected async updateBalance(): Promise<void> {
try {
// Get account resource to check the balance
const accountResource = await this.client.getAccountResource(
this.aptosAddress,
"0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
);

// Extract the balance value from the account resource
const rawBalance = (accountResource.data as any).coin.value;
const accountAPTAmount = await this.client.getAccountAPTAmount({
accountAddress: this.aptosAddress,
});

// Convert the balance to a bigint
const balance = BigInt(rawBalance);
// Convert the amount to a bigint
const balance = BigInt(accountAPTAmount);

// Calculate the normalized balance for display
const normalizedBalance = Number(balance) / Math.pow(10, this.decimals);
Expand Down
Loading
Loading