Skip to content

Commit

Permalink
natspec(TwabLib): improve _calculateTwab @notice docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kamescg committed Oct 5, 2021
1 parent 7edb463 commit 8f00536
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/libraries/TwabLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ library TwabLib {
return differenceInAmount / differenceInTime;
}

/** @notice Calculates a user TWAB for a target timestamp using the historical TWAB list.
/** @notice Calculates a user TWAB for a target timestamp using the historical TWAB records.
The balance is linearly interpolated: amount differences / timestamp differences
using the simple (after.amount - before.amount / end.timestamp - start.timestamp) formula.
/** @dev Binary search in _calculateTwab fails when searching out of bounds. Thus, before
searching we exclude searching for target timestamps out of range of newest/oldest TWAB(s).
IF a search is before or after the range we "extrapolate" a Observation from the expected state.
Expand Down

0 comments on commit 8f00536

Please sign in to comment.