-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contracts: wrapped resources #1704
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Preparing PR description... |
Preparing review... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of the resource bridge system is well-structured and covers the main functionalities required for depositing and withdrawing ERC20 tokens. The code includes proper checks for pausing deposits/withdrawals, whitelisting tokens, and fee calculations. However, there are a few areas where the code could be improved:
- Additional checks for zero-value transactions could be added to prevent potential issues.
- Error handling or logging for precision loss during token-resource conversions could be beneficial.
- The fee calculation logic is duplicated and could be abstracted into a separate function.
- Some error messages could be more descriptive to aid in debugging.
Overall, the implementation is solid, but these small improvements could enhance its robustness and maintainability.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
|
||
// take fees from deposit | ||
let total_fees = InternalBridgeImpl::send_fees_on_deposit(world, token, client_fee_recipient, amount); | ||
assert!(total_fees.is_non_zero(), "Bridge: deposit amount too small"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a check to ensure the amount is greater than zero to prevent potential issues with zero-value deposits.
contracts/src/systems/resources/contracts/resource_bridge_systems.cairo
Outdated
Show resolved
Hide resolved
return relative_amount; | ||
} | ||
|
||
fn send_fees_on_deposit( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling or logging for cases where the conversion might result in a loss of precision.
let fee_split_config = get!(world, WORLD_CONFIG_ID, ResourceBridgeFeeSplitConfig); | ||
let velords_fee_amount = (amount * fee_split_config.velords_fee_on_dpt_percent.into()) | ||
/ PercentageValueImpl::_100().into(); | ||
let season_pool_fee_amount = (amount * fee_split_config.season_pool_fee_on_dpt_percent.into()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous comment, consider adding error handling or logging for potential precision loss during conversion.
/ PercentageValueImpl::_100().into(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fee calculation logic is repeated in both deposit and withdrawal functions. Consider abstracting this into a separate function to reduce code duplication.
/ PercentageValueImpl::_100().into(); | |
let client_fee_amount = Self::calculate_fee(amount, fee_split_config.client_fee_on_dpt_percent); |
contracts/src/systems/resources/contracts/resource_bridge_systems.cairo
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
resolves #1150
ERC20
token can be deposited and withdrawn for a fee