sSLOHM Token
Rebasing staked token with index-based balance calculation.
Why Custom Standard?
sSLOHM extends OP_NET instead of OP20 because:
- OP20's
balanceOfreads directly from storage - sSLOHM needs computed balances:
credits × index / 1e18 - We implement the OP20 interface manually
Storage
globalIndex: StoredU256 // Starts at 1e18, increases each rebase
userCredits: AddressMemoryMap // Credits per user
totalCredits: StoredU256 // Sum of all credits
stakingAddress: StoredAddress // Only Staking can mint/burn
Balance Calculation
// Convert amount to credits (when staking)
credits = amount × 1e18 / globalIndex
// Get balance from credits (when querying)
balance = credits × globalIndex / 1e18
Rebase Mechanism
function rebase(profit: u256): void {
// Only staking contract can call
require(sender == stakingAddress);
// newIndex = oldIndex × (1 + profit/totalSupply)
const totalSupply = totalCredits × globalIndex / 1e18;
const increase = globalIndex × profit / totalSupply;
globalIndex = globalIndex + increase;
}
Key Methods
| Method | Description |
|---|---|
balanceOf(address) | Returns computed rebased balance |
totalSupply() | Returns totalCredits × index |
transfer(to, amount) | Converts to credits, transfers |
index() | Returns current globalIndex |
rebase(profit) | Increases index (staking only) |
mint(to, amount) | Adds credits (staking only) |
burn(from, amount) | Removes credits (staking only) |
Why Index-Based?
Traditional rebasing updates every holder's balance - expensive with many holders.
Index-based rebasing:
- O(1) rebase - Only update one number
- O(1) balance query - Simple multiplication
- Gas efficient - No iteration
- Scalable - Works with unlimited holders