-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unwrap NEAR on Aurora->NEAR transfers (#750)
<!-- Thanks for submitting a pull request! Here are some helpful tips: * Always create branches on and target the `develop` branch. * Run all the tests locally and ensure that they are passing. * Run `make format` to ensure that the code is formatted. * Run `make check` to ensure that all checks passed successfully. * Small commits and contributions that attempt one single goal is preferable. * If the idea changes or adds anything functional which will affect users, an AIP discussion is required first on the Aurora forum: https://forum.aurora.dev/discussions/AIPs%20(Aurora%20Improvement%20Proposals). * Avoid breaking the public API (namely in engine/src/lib.rs) unless required. * If your PR is a WIP, ensure that you enable "draft" mode. * Your first PRs won't use the CI automatically unless a maintainer starts. If this is not your first PR, please do NOT abuse the CI resources. Checklist: - [ ] I have performed a self-review of my code - [ ] I have documented my code, particularly in the hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] I have added tests to prove my fix or new feature is effective and works - [ ] Any dependent changes have been merged - [ ] The PR is targeting the `develop` branch and not `master` - [ ] I have pre-squashed my commits into a single commit and rebased. --> ## Description NEAR instead of wNEAR on AuroraStoring native NEAR tokens on aurora account on NEAR - issues: * This creates issues for accounting and monitoring - need to verify which part of `aurora` balance is used for storage, which is used for bridged NEAR, and which is free and available. * Could create a lack of NEAR collateral for the bridged wNEAR - some users may not be able to withdraw their wNEAR from Aurora. The solution: * Keep holding wNEAR on `aurora` balance on NEAR side. * This way, each time the user bridges NEAR to Aurora, it's being wrapped to wNEAR and sent to Aurora. * We preserve the same ERC-20 address of wNEAR on Aurora without any additional steps. * When withdrawing wNEAR from Aurora, make unwrap in wNEAR (call `wrap.near near_withdraw()`) and then send native NEAR tokens for users. * Use optional suffix `{}:unwrap` so it won't break the cross-chain swaps for [Ref.Finance](http://ref.finance/). Implementation: Modify the `ExitToNear` precompile: * Call `near_withdraw` instead of `ft_transfer` if the `erc20_address` is a `wnear_address` and the `recipient` end with the suffix `{}:unwrap`. * Rename `refund_on_error` callback to `exit_to_near_precompile_callback`. * Pass to it args with optional `TransferNearCallArgs` and an already existing `RefundCallArgs` but make it optional. * In the `exit_to_near_precompile_callback` transfer near on successful promise result and refund on the failed result. ## Performance / NEAR gas cost considerations The gas consumption increased a little bit due to a callback call. <!-- Performance regressions are not ideal, though we welcome performance improvements. Any PR must be completely mindful of any gas cost increases. The CI will fail if the gas costs change at all. Do update these tests to accommodate for the new gas changes. It is good to explain this change, if necessary. --> ## Testing Integration tests are added <!-- Please describe the tests that you ran to verify your changes. --> ## How should this be reviewed The reviewer should focus on the changed components that are described in the `implementation` section, and verify that the implementation is backward compatible and doesn't break any other components like `XCC` and `refund` logic. --------- Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev> Co-authored-by: Michael Birch <michael.birch@aurora.dev>
- Loading branch information
1 parent
0731841
commit 00f41ee
Showing
14 changed files
with
427 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.