Skip to main content

Module math

Module math 

Source
Expand description

Shared integer accounting math for Roshi vaults.

Constants§

BPS_DENOMINATOR
SHARE_DECIMALS

Functions§

assets_for_redeem
assets_for_shares
Floor-rounded base value of shares. Zero is a valid result: a dust position can be worth less than one base atom, and withdrawal-ticket strikes must price it (to nothing) rather than wedge. Immediate redemption paths that must pay out should use assets_for_redeem.
base_atoms_from_asset_atoms
Floor-rounded base atoms for asset_atoms, priced through two whole-token oracle legs sharing one quote currency:
bps_ceil
bps_floor
checked_u64
mul_div_ceil
mul_div_ceil_u64
mul_div_floor
mul_div_floor_u64
performance_fee_for_nav
pow10
round_with_min1
klend’s flash-loan fee for borrowing value at a committed num/den rate: round_half_up(value * num / den), floored at one atom. This reproduces klend’s calculate_flash_loan_feesorigination_fee = round(max(amount * rate, 1)) over a fixed::U68F60 rate, with ties rounding away from zero — rather than merely bounding it. The FlashApprove delegate is bound to F + fee and a trailing assert_delegate_cleared requires the forced flash_repay to consume it to zero, so the fee must equal klend’s bit-for-bit (a ceil over-charges and strands a residual delegate on every non-integer product — see #25). The rate stays opaque: the admin commits num/den to match the reserve’s fee; Roshi never reads the reserve.
share_price_from_assets
shares_for_deposit
validate_percentage_bps
virtual_share_offset
The virtual share supply backing one virtual base atom: 10^(SHARE_DECIMALS - base_decimals), the empty-vault mint ratio.

Type Aliases§

MathResult