Closed NotJeremyLiu closed 9 months ago
The recent updates introduce a mechanism to track the pre-swap out asset amount to ensure that only the user's deposited funds are used in swaps. This is achieved by saving the contract's balance before a swap and referencing it before executing a subsequent action. The changes aim to prevent the unintentional inclusion of existing funds in user-initiated swaps, thereby safeguarding against the potential loss of funds.
File Path | Change Summary |
---|---|
contracts/.../src/execute.rs |
Added PRE_SWAP_OUT_ASSET_AMOUNT constant; updated functions to use this constant for tracking balance before swaps. |
contracts/.../src/state.rs |
Introduced PRE_SWAP_OUT_ASSET_AMOUNT as Item<Uint128> for state management. |
contracts/.../tests/test_execute_post_swap_action.rs |
Extended Params struct and updated tests with pre_swap_out_asset_amount . |
contracts/.../tests/test_execute_swap_and_action.rs |
Added assertions for pre_swap_out_asset_amount to validate swap correctness. |
Objective | Addressed | Explanation |
---|---|---|
Track balance deltas to prevent inadvertent inclusion of funds in swaps (API-2349) | ✅ | |
Implement balance check excluding user tokens before swaps (API-2349) | ✅ | |
Ensure contract sends only user deposit balance differences (API-2349) | ✅ | |
Mitigate risk of fund loss and ensure accurate token transfers (API-2349) | ✅ |
In the code where tokens flow, A rabbit fixed the swap, you know. With constants set and checks in line, 🐇💻 Now every swap is safe and fine.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
This PR
Summary by CodeRabbit
New Features
Tests