Skip to content

Commit

Permalink
check if the distribution already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
eyqs committed Sep 19, 2024
1 parent c5fd3b5 commit 6963b7e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion smart-wallets/src/extensions/AssetVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,14 @@ contract AssetVault is IAssetVault {

allowance.amount -= amount;

// Append the newly created yield distribution to the end of the linked list
// Either update the existing distribution with the same expiration or append a new one
YieldDistributionListItem storage distribution = $.yieldDistributions[assetToken];
while (distribution.yield.amount > 0) {
if (distribution.beneficiary == beneficiary && distribution.yield.expiration == expiration) {
distribution.yield.amount += amount;
emit YieldDistributionCreated(assetToken, beneficiary, amount, expiration);
return;
}
distribution = distribution.next[0];
}
distribution.beneficiary = beneficiary;
Expand Down

0 comments on commit 6963b7e

Please sign in to comment.