Expand description
Shared integer accounting math for Roshi vaults.
Constants§
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 useassets_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
valueat a committednum/denrate:round_half_up(value * num / den), floored at one atom. This reproduces klend’scalculate_flash_loan_fees—origination_fee = round(max(amount * rate, 1))over afixed::U68F60rate, with ties rounding away from zero — rather than merely bounding it. TheFlashApprovedelegate is bound toF + feeand a trailingassert_delegate_clearedrequires the forcedflash_repayto consume it to zero, so the fee must equal klend’s bit-for-bit (aceilover-charges and strands a residual delegate on every non-integer product — see #25). The rate stays opaque: the admin commitsnum/dento 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.