crates/sui-framework/docs/sui_system/storage_fund.md
StorageFundnewadvance_epochtotal_object_storage_rebatestotal_balance<a name="sui_system_storage_fund_StorageFund"></a>
StorageFundStruct representing the storage fund, containing two <code>Balance</code>s:
<a name="sui_system_storage_fund_new"></a>
newCalled by <code><a href="../sui_system/sui_system.md#sui_system_sui_system">sui_system</a></code> at genesis time.
<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui_system/storage_fund.md#sui_system_storage_fund_new">new</a>(initial_fund: <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a><<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>>): <a href="../sui_system/storage_fund.md#sui_system_storage_fund_StorageFund">sui_system::storage_fund::StorageFund</a> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b>(package) <b>fun</b> <a href="../sui_system/storage_fund.md#sui_system_storage_fund_new">new</a>(initial_fund: Balance<SUI>): <a href="../sui_system/storage_fund.md#sui_system_storage_fund_StorageFund">StorageFund</a> { <a href="../sui_system/storage_fund.md#sui_system_storage_fund_StorageFund">StorageFund</a> { // At the beginning there's no object in the storage yet <a href="../sui_system/storage_fund.md#sui_system_storage_fund_total_object_storage_rebates">total_object_storage_rebates</a>: balance::zero(), non_refundable_balance: initial_fund, } } </code></pre> </details><a name="sui_system_storage_fund_advance_epoch"></a>
advance_epochCalled by <code><a href="../sui_system/sui_system.md#sui_system_sui_system">sui_system</a></code> at epoch change times to process the inflows and outflows of storage fund.
<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui_system/storage_fund.md#sui_system_storage_fund_advance_epoch">advance_epoch</a>(self: &<b>mut</b> <a href="../sui_system/storage_fund.md#sui_system_storage_fund_StorageFund">sui_system::storage_fund::StorageFund</a>, storage_charges: <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a><<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>>, storage_fund_reinvestment: <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a><<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>>, leftover_staking_rewards: <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a><<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>>, storage_rebate_amount: u64, non_refundable_storage_fee_amount: u64): <a href="../sui/balance.md#sui_balance_Balance">sui::balance::Balance</a><<a href="../sui/sui.md#sui_sui_SUI">sui::sui::SUI</a>> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b>(package) <b>fun</b> <a href="../sui_system/storage_fund.md#sui_system_storage_fund_advance_epoch">advance_epoch</a>( self: &<b>mut</b> <a href="../sui_system/storage_fund.md#sui_system_storage_fund_StorageFund">StorageFund</a>, storage_charges: Balance<SUI>, storage_fund_reinvestment: Balance<SUI>, leftover_staking_rewards: Balance<SUI>, storage_rebate_amount: u64, non_refundable_storage_fee_amount: u64, ): Balance<SUI> { // Both the reinvestment and leftover rewards are not to be refunded so they go to the non-refundable balance. self.non_refundable_balance.join(storage_fund_reinvestment); self.non_refundable_balance.join(leftover_staking_rewards); // The storage charges <b>for</b> the epoch come from the storage rebate of the <a href="../sui_system/storage_fund.md#sui_system_storage_fund_new">new</a> objects created // and the <a href="../sui_system/storage_fund.md#sui_system_storage_fund_new">new</a> storage rebates of the objects modified during the epoch so we put the charges // into `<a href="../sui_system/storage_fund.md#sui_system_storage_fund_total_object_storage_rebates">total_object_storage_rebates</a>`. self.<a href="../sui_system/storage_fund.md#sui_system_storage_fund_total_object_storage_rebates">total_object_storage_rebates</a>.join(storage_charges); // Split out the non-refundable portion of the storage rebate and put it into the non-refundable balance. <b>let</b> non_refundable_storage_fee = self .<a href="../sui_system/storage_fund.md#sui_system_storage_fund_total_object_storage_rebates">total_object_storage_rebates</a> .split(non_refundable_storage_fee_amount); self.non_refundable_balance.join(non_refundable_storage_fee); // `storage_rebates` include the already refunded rebates of deleted objects and old rebates of modified objects and // should be taken out of the `<a href="../sui_system/storage_fund.md#sui_system_storage_fund_total_object_storage_rebates">total_object_storage_rebates</a>`. <b>let</b> storage_rebate = self.<a href="../sui_system/storage_fund.md#sui_system_storage_fund_total_object_storage_rebates">total_object_storage_rebates</a>.split(storage_rebate_amount); // The storage rebate <b>has</b> already been returned to individual transaction senders' gas coins // so we <b>return</b> the balance to be burnt at the very end of epoch change. storage_rebate } </code></pre> </details><a name="sui_system_storage_fund_total_object_storage_rebates"></a>
total_object_storage_rebates<a name="sui_system_storage_fund_total_balance"></a>
total_balance