Skip to main content

Shares

Shares

Typedef on uint256 to represent user shares in vault contracts. Allows type checking to prevent errors where shares and collateral intermix

PerShare

User-defined type: an X-per-share rate (really a FPUnsigned). Because Shares values are multiples of 1E18 on top of however many decimals the collateral token has, "seconds per share" is a very small number. To avoid precision loss, we store them inverted (shares per second) and expose methods that allow us to treat this as the sensible quantity of seconds per share.

SharesUtil

Addresses

ChainAddress

Functions

min

The minimum of a and b.

function min(Shares a, Shares b) internal pure returns (Shares)

Parameters

NameTypeDescription
aSharesa FPUnsigned.
bSharesa FPUnsigned.

Return Values

NameTypeDescription
[0]Sharesthe minimum of a and b.

max

The maximum of a and b.

function max(Shares a, Shares b) internal pure returns (Shares)

Parameters

NameTypeDescription
aSharesa FPUnsigned.
bSharesa FPUnsigned.

Return Values

NameTypeDescription
[0]Sharesthe maximum of a and b.