Skip to content

Commit

Permalink
Add support for token transfers between addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed May 8, 2024
1 parent 3ce8ed3 commit 845e140
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/vault-interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,23 @@ export function handleVaultTransfer(event: TransferEvent): void {
return
}

if (!event.params.from.equals(SHARE_TOKEN_MINT_ADDRESS) || !event.params.to.equals(SHARE_TOKEN_MINT_ADDRESS)) {
updateVaultData(vault)

let investorAddress = ADDRESS_ZERO
if (!event.params.from.equals(SHARE_TOKEN_MINT_ADDRESS)) {
investorAddress = event.params.from
} else if (!event.params.to.equals(SHARE_TOKEN_MINT_ADDRESS)) {
investorAddress = event.params.to
}
updateVaultData(vault)

let investor = getInvestor(investorAddress)
if (!event.params.from.equals(SHARE_TOKEN_MINT_ADDRESS)) {
const investorAddress = event.params.from
const investor = getInvestor(investorAddress)
investor.save()
updateInvestorVaultData(vault, investor)
}

if (!event.params.to.equals(SHARE_TOKEN_MINT_ADDRESS)) {
const investorAddress = event.params.to
const investor = getInvestor(investorAddress)
investor.save()
updateInvestorVaultData(vault, investor)
updateVaultBreakDown(event.block, vault)
}

updateVaultBreakDown(event.block, vault)
}

export function handleStrategyHarvest(event: ethereum.Event): void {
Expand Down

0 comments on commit 845e140

Please sign in to comment.