-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fee integration #62
base: master
Are you sure you want to change the base?
Fee integration #62
Conversation
eth-connector/src/fee.rs
Outdated
pub struct FeeStorage { | ||
pub deposit_fee: Option<Fee>, | ||
pub withdraw_fee: Option<Fee>, | ||
pub withdraw_fee_per_silo: UnorderedMap<AccountId, Fee>, | ||
pub deposit_fee_per_silo: UnorderedMap<AccountId, Fee>, |
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.
Please describe all the fields and the logic of how it's expected to work here, e.g. if deposit and withdrawals fee settings override per silo configurations (some may think it is, but it's actually the opposite), what happens if either of these settings are set, etc.
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.
eth-connector/src/fee.rs
Outdated
pub struct Fee { | ||
pub fee_percentage: U128, | ||
pub lower_bound: Option<U128>, | ||
pub upper_bound: Option<U128>, | ||
} |
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.
Please describe all the fields.
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.
eth-connector/src/lib.rs
Outdated
@@ -556,31 +677,52 @@ impl FundsFinish for EthConnectorContract { | |||
|
|||
log!("Finish deposit with the amount: {}", deposit_call.amount); | |||
|
|||
// Mint - calculate new balances | |||
self.mint_eth_on_near(&deposit_call.new_owner_id, deposit_call.amount); | |||
// Store proof only after `mint` calculations |
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.
This comment needs to be updated.
Also, why don't we mint the whole amount to the current_account_id
in the first place?
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.
We mint to the current_account_id
just in case there is an ft-transfer-call
when depositing to eth account, but on deposit to near account, we can mint directly to the new_owner_id
.
If are asking how this worked with one call, then it worked because the new_owner_id
== current_account_id
on this ft-transfer-call
.
additional to that it is not clear why actually the env::predecessor_account_id(),
was used instead of env::current_account_id()
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.
Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev>
@karim-en please cover also with integration tests: |
Description
This PR contains Fee Implementation for Deposit and Withdrawal flows for Ether transfer using Rainbow Bridge (Business requirement).
Specification:
same contract
that the owner could claim using the functionclaim_fee
.owner account
instead of the current contract account if theset_fee_owner
was called.fee_amount
has lower and upper bounds.fee_amount
is higher than thewithdraw/deposit amount
then charge the full amount as a fee and don't transfer anything to the recipient.10% = 0.1 * 10e6 = 100_000
Added public function:
Migration:
The migration is needed due to the added field
fee
to the contract structure. To migrate the storage we need to call:pub fn migrate_fee_storage() -> Self
Performance / NEAR gas cost considerations
The gas for withdrawal and deposit transactions will be increased a little bit due to additional fee calculations and reads from the storage.
Testing
Unit tests have been added to cover multiple fee cases.
How should this be reviewed
The review should verify the functions
withdraw
,engine_withdraw
, andfinish_deposit
and make sure that the burn/mint/transfer logic is correct.Additional information