Skip to content

Commit

Permalink
refactor (tempest_swell_usde): calculate user's balance based on tota…
Browse files Browse the repository at this point in the history
…l USDe instead of total assets of the vault
  • Loading branch information
anhvietnguyennva committed Dec 22, 2024
1 parent 364e3e6 commit db1992e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions integrations/tempest_swell_usde.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ def get_data_for_block(
balance_of_results = multicall_by_address(self.w3, self.multicall_address, balance_of_calls, block)

# get vault totalAssets and totalSupply
vault_calls = [(contract, contract.functions.totalAssets.fn_name, None), (contract, contract.functions.totalSupply.fn_name, None)]
vault_calls = [(contract, contract.functions.getPositions.fn_name, None), (contract, contract.functions.totalSupply.fn_name, None)]
vault_results = multicall_by_address(self.w3, self.multicall_address, vault_calls, block)
total_assets = vault_results[0][0]
# vault_results[0][0] is USDe in Ambient positions, vault_results[0][2] is idle USDe in the vault
total_usde = vault_results[0][0] + vault_results[0][2]
total_supply = vault_results[1][0]

# convert share balance to USDe balance
for i in range(0, len(users)):
if balance_of_results[i][0] == 0:
continue
data[users[i]] = balance_of_results[i][0] * total_assets / total_supply
data[users[i]] = balance_of_results[i][0] * total_usde / total_supply

return data

Expand Down

0 comments on commit db1992e

Please sign in to comment.