π Description
do_withdraw decrements pool.providers when a provider's remaining balance reaches zero β the mirror image of do_provide's first-contribution increment β but unlike the existing ("withdraw", provider, asset) event (which fires on every withdrawal regardless of size), there is no distinct signal for "this provider has now fully exited this asset's pool." Off-chain systems tracking active-provider counts per pool currently have to compare balances before and after each withdrawal event rather than reacting to a dedicated signal.
π§© Requirements and context
- Add an
events::provider_exited helper in src/events.rs, mirroring the asset-onboarded event's pattern above but for the withdrawal side.
- Call it from
do_withdraw in src/lib.rs specifically when remaining == 0 (the same condition that decrements pool.providers).
- Add a regression test confirming the event fires only on a full exit, not a partial withdrawal, and fires again correctly if the same provider re-enters and exits again later.
π οΈ Suggested execution
- Add the event helper to
src/events.rs.
- Update
do_withdraw in src/lib.rs to conditionally emit it alongside the existing liquidity_withdrawn event.
- Add
src/test.rs coverage and document the new topic in the README events list.
β
Acceptance criteria
π Security notes
Accurate provider-exit signaling helps off-chain risk monitoring detect a pool rapidly losing distinct liquidity providers (a leading indicator of a liquidity crunch) faster than reconstructing that signal from raw withdrawal amounts alone.
π Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
π Description
do_withdrawdecrementspool.providerswhen a provider's remaining balance reaches zero β the mirror image ofdo_provide's first-contribution increment β but unlike the existing("withdraw", provider, asset)event (which fires on every withdrawal regardless of size), there is no distinct signal for "this provider has now fully exited this asset's pool." Off-chain systems tracking active-provider counts per pool currently have to compare balances before and after each withdrawal event rather than reacting to a dedicated signal.π§© Requirements and context
events::provider_exitedhelper insrc/events.rs, mirroring the asset-onboarded event's pattern above but for the withdrawal side.do_withdrawinsrc/lib.rsspecifically whenremaining == 0(the same condition that decrementspool.providers).π οΈ Suggested execution
src/events.rs.do_withdrawinsrc/lib.rsto conditionally emit it alongside the existingliquidity_withdrawnevent.src/test.rscoverage and document the new topic in the README events list.β Acceptance criteria
withdrawevent continues to fire on every withdrawal as before.π Security notes
Accurate provider-exit signaling helps off-chain risk monitoring detect a pool rapidly losing distinct liquidity providers (a leading indicator of a liquidity crunch) faster than reconstructing that signal from raw withdrawal amounts alone.
π Guidelines