Skip to content

Commit

Permalink
Minor comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasia committed Oct 6, 2024
1 parent ed53c88 commit a314dd4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/contracts/src/token/ERC1155/RedeemOptimizerFIFO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ contract RedeemOptimizerFIFO is IRedeemOptimizer {
if (amountFound + amountAtPeriod > optimizerParams.amountToFind) {
uint256 amountToInclude = optimizerParams.amountToFind - amountFound; // we only need the amount that brings us to amountToFind

// the assets here include principal + interest. to utilize convertToShares() we want principal amount only
// the following ratio holds: partialShares/totalShares = partialReturns/totalReturns
// so, partialShares = ((partialReturns * totalShares) / totalReturns)
uint256 sharesToInclude = sharesAtPeriod.mulDiv(amountToInclude, amountAtPeriod); // also works for shares, when shares = amounts, sharesAtPeriod / sharesAtPeriod = 1
// in the assets case, the amounts include principal AND returns. we want the shares on deposit, which is the principal only.
// use this ratio: partialShares / totalShares = partialAssets / totalAssets
// partialShares = (partialAssets * totalShares) / totalAssets
uint256 sharesToInclude = sharesAtPeriod.mulDiv(amountToInclude, amountAtPeriod);

// only include equivalent amount of shares for the amountToInclude assets
cacheSharesAtPeriods[arrayIndex] =
Expand Down

0 comments on commit a314dd4

Please sign in to comment.