-
Notifications
You must be signed in to change notification settings - Fork 3
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
Contract: Bridge fees collection and claiming implementation #60
Conversation
5bd0347
to
615ca88
Compare
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.
Reviewed 6 of 34 files at r1, 28 of 28 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dzmitryhil, @wojtek-coreum, and @ysv)
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @keyleu, @wojtek-coreum, and @ysv)
contract/src/contract.rs
line 63 at r2 (raw file):
const XRP_DEFAULT_MAX_HOLDING_AMOUNT: u128 = 10u128.pow(16 - XRP_DEFAULT_SENDING_PRECISION as u32 + XRP_DECIMALS); const XRP_DEFAULT_FEE: Uint128 = Uint128::zero();
Add please the TODO to update it.
contract/src/contract.rs
line 433 at r2 (raw file):
amount_after_fees(amount_truncated, token.bridging_fee, truncated_portion)?; if amount_to_send
We should include the fees for the MaximumBridgedAmount
as well
contract/src/contract.rs
line 1003 at r2 (raw file):
let truncated_amount = amount_to_send.checked_mul(Uint128::new(10u128.pow(exponent.unsigned_abs())))?; let truncated = amount.checked_sub(truncated_amount)?;
Probably call it truncation_remainder
or remainder
, same for the placed where you use it?
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dzmitryhil, @wojtek-coreum, and @ysv)
contract/src/contract.rs
line 63 at r2 (raw file):
Previously, dzmitryhil (Dzmitry Hil) wrote…
Add please the TODO to update it.
Added it.
contract/src/contract.rs
line 433 at r2 (raw file):
Previously, dzmitryhil (Dzmitry Hil) wrote…
We should include the fees for the
MaximumBridgedAmount
as well
Right,
But actually there was a bigger problem and was different (and more important one that I did not consider and that my tests did not detect).
I was only minting the amount to send to the user and not the fees, and since I only claimed at the end of the tests I didn't realize that I was taking the amount that was being bridged back (and not confirmed).
I added the minting for the fees into the contract and also modified tests to detect this.
contract/src/contract.rs
line 1003 at r2 (raw file):
Previously, dzmitryhil (Dzmitry Hil) wrote…
Probably call it
truncation_remainder
orremainder
, same for the placed where you use it?
Sure, no problem. Changed it.
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.
Reviewable status: 6 of 34 files reviewed, 1 unresolved discussion (waiting on @miladz68, @wojtek-coreum, and @ysv)
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.
Reviewed 28 of 28 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @wojtek-coreum and @ysv)
Description
How it works: Every time a user sends a token it will collect fees into the contract (part of the amount). The truncated amount counts towards the fee (so that users can choose what they want to receive on the other side).
For claiming, any relayer can claim when ever he wants and the fees will be proportionally distributed to all of them.
Reviewers checklist:
Authors checklist
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)