@@ -129,22 +129,19 @@ def fetch_balances(self, address: str) -> FetchResult:
129129 self ._fetch_das_assets (mint_addresses )
130130
131131 raw_staked_sol = self ._fetch_staked_sol (address )
132- raw_rent_reserve = self ._fetch_stake_account_balances (raw_staked_sol )
133132
134133 return FetchResult (
135134 data = sol_response ,
136135 extra = dict (
137136 raw_token_balances = raw_token_balances ,
138137 raw_token2022_balances = raw_token2022_balances ,
139138 raw_staked_sol = raw_staked_sol ,
140- raw_rent_reserve = raw_rent_reserve ,
141139 ),
142140 )
143141
144142 def parse_balances (self , fetch_result : FetchResult ) -> ParseResult :
145143 """Parse fetched data into a list of BalanceItems."""
146144 raw_staked_sol = fetch_result .extra ['raw_staked_sol' ]
147- raw_rent_reserve = fetch_result .extra ['raw_rent_reserve' ]
148145
149146 balances = []
150147
@@ -154,7 +151,7 @@ def parse_balances(self, fetch_result: FetchResult) -> ParseResult:
154151 if staked_sol_balance := self ._parse_staked_balance (raw_staked_sol ):
155152 balances .append (staked_sol_balance )
156153 balances .append (
157- self ._parse_rent_reserve (staked_sol_balance , raw_rent_reserve )
154+ self ._parse_rent_reserve (staked_sol_balance , raw_staked_sol )
158155 )
159156
160157 all_raw_tokens = (
@@ -273,7 +270,8 @@ def _fetch_das_assets(self, mint_addresses: list[str]) -> None:
273270 chunk = uncached [i : i + self .DAS_BATCH_SIZE ]
274271 try :
275272 response = self ._request (
276- 'getAssetBatch' ,
273+ # 'getAssetBatch',
274+ 'getAssets' ,
277275 {'ids' : chunk , 'options' : {'showFungible' : True }},
278276 )
279277 except (ApiException , RequestException ) as e :
@@ -345,16 +343,6 @@ def _fetch_staked_sol(self, address: str) -> dict:
345343 ],
346344 )
347345
348- def _fetch_stake_account_balances (self , raw_staked_sol : dict ) -> dict :
349- """Fetch balances for all stake accounts in a single RPC call."""
350- stake_accounts = [r ['pubkey' ] for r in raw_staked_sol .get ('result' , [])]
351- if not stake_accounts :
352- return {'result' : {'value' : []}}
353- return self ._request (
354- method = 'getMultipleAccounts' ,
355- params = [stake_accounts ],
356- )
357-
358346 # ── Balance parsing ────────────────────────────────────────
359347
360348 def _parse_sol_balance (self , response : dict ) -> Optional [BalanceItem ]:
@@ -388,18 +376,21 @@ def _parse_staked_balance(self, response: dict) -> Optional[BalanceItem]:
388376 )
389377
390378 def _parse_rent_reserve (
391- self , staked_sol : BalanceItem , response : dict
379+ self , staked_sol : BalanceItem , raw_staked_sol : dict
392380 ) -> BalanceItem :
393- """Parse rent reserve balance from getMultipleAccounts response."""
394- accounts = response .get ('result' , {}).get ('value' , [])
395- total_raw = sum (a .get ('lamports' , 0 ) for a in accounts if a is not None )
396- available_raw = total_raw - int (staked_sol .balance_raw )
381+ """Parse rent reserve from getProgramAccounts response.
397382
383+ Uses result[].account.lamports already returned by _fetch_staked_sol,
384+ avoiding a separate getMultipleAccounts call.
385+ """
386+ accounts = raw_staked_sol .get ('result' , [])
387+ total_raw = sum (r ['account' ]['lamports' ] for r in accounts )
388+ available_raw = total_raw - int (staked_sol .balance_raw )
398389 return BalanceItem .from_api (
399390 balance_raw = available_raw ,
400391 coin = self .coin ,
401392 asset_type = AssetType .LOCKED ,
402- raw = response ,
393+ raw = raw_staked_sol ,
403394 )
404395
405396 # ── Infrastructure ─────────────────────────────────────────
0 commit comments