Skip to content
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

[VEN-1832]: Feat Cross chain bridge for XVS #291

Closed
wants to merge 38 commits into from

Conversation

GitGuru7
Copy link
Contributor

@GitGuru7 GitGuru7 commented Aug 17, 2023

Description

Source Bridge:

  • Extends the functionality of BaseOFTV2 from Layer Zero.
  • Users are required to approve XVS tokens for this contract to enable locking them within this contract.
  • Implements logic to enforce limits on single transactions and within a 24-hour window.
  • Overrides the debitFrom function to incorporate custom logic for checking transaction limits in USD, utilizing the Resilient Oracle for price information.
  • The setting of bounds and limits is integrated with the only owner modifier.
  • When receiving tokens from destination chains, it releases user tokens and sends them directly.

Destination Bridge:

  • Extends the BaseOFTV2 from Layer Zero.
  • Implements logic for enforcing limits on single transactions and within a 24-hour window.
  • Overrides the debitFrom function to include custom logic for checking transaction limits in USD and performs an external call to the XVS token contract to burn tokens from the sender.
  • Overrides the creditTo function to trigger an external call to the XVS token contract to mint tokens for the receiver.
  • The setting of bounds and limits is integrated by only owner modifier.
  • When sending tokens from this contract, it burns user tokens, with the burning logic residing in the XVS token contract.
  • When receiving tokens, it mints tokens for the receiver, with the minting logic residing in the XVS token contract.

XVS Bridge Owner

  • It will be owner the owner of the Bridge contracts on the src and destination chain.
  • It contains a fallback function for the admin functionality of the Bridge contracts.
  • ACM is integrated in fallback to verify the caller of the owner functions of the Bridge contracts

XVS Token on Destination:

  • Follows the ERC20 standard for tokens.
  • It is responsible for setting minting limits for the minter (in this case, the bridge contract).
  • When receiving transactions and tokens from the source chain's Bridge contract, an external call is made to mint tokens for the receiver.
  • When sending tokens to the source chain's Bridge contract, an external call is made from bridge contract to burn tokens from the sender.
  • Offers a blacklisting feature to prevent certain users from receiving XVS tokens.
  • ACM integration is used for setting minting caps and blacklisting, and these settings can be configured via multisig and VIPs in the near future.

Blocks Delay

  • In order to ensure that the remote chains have configured blocks confirmation prior to receiving messages from remote chains, we can use the block confirmation functionality provided by layer zero to set inbound and outbound block confirmation.

Addresses

bsctestnet
XVSBridge : 0xf27Af3B46bA211Cf0145e4901EB514674041A1C3
XVSBridgeAdmin : 0x29dbe81C0D7FCe62c4046E224CbA669A9C2736E5
token : 0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47
Oracle: 0x3cD69251D04A28d887Ac14cbe2E14c52F3D57823
acm: 0x65A199b3cE996EB5382eBa91eA89eC415B715562

Configurations:
maxDailyLimit = $500
maxSingleTransactionLimit = $10
maxDailyReceiveLimit = $50
maxSingleTransactionReceiveLimit = $10

sepolia
XVSBridge : 0x167389021e0D871eB0672b6D089B5d7D1aE4181b
XVSBridgeAdmin : 0x9eB652d618855841C7ce351Fad8F47c00A4EC115
token : 0xD657eB80daA42c334B1c70Cb274E83E4163A3dDc
Oracle: 0x1B85FAbE5c0846662F5FB0E3598fC48eF587e9f0
acm: 0x799700ea540f002134C371fB955e2392FD94DbCD

Configurations:
maxDailyLimit = $50
maxSingleTransactionLimit = $10
maxDailyReceiveLimit = $50
maxSingleTransactionReceiveLimit = $10

Resolves VEN-1832

Checklist

  • I have updated the documentation to account for the changes in the code.
  • If I added new functionality, I added tests covering it.
  • If I fixed a bug, I added a test preventing this bug from silently reappearing again.
  • My contribution follows Venus contribution guidelines.

@GitGuru7 GitGuru7 self-assigned this Aug 17, 2023
contracts/Bridge/BaseXVSProxyOFT.sol Show resolved Hide resolved
contracts/Bridge/BaseXVSProxyOFT.sol Outdated Show resolved Hide resolved
contracts/Bridge/BaseXVSProxyOFT.sol Outdated Show resolved Hide resolved
contracts/Bridge/BaseXVSProxyOFT.sol Outdated Show resolved Hide resolved
contracts/Bridge/BaseXVSProxyOFT.sol Outdated Show resolved Hide resolved
contracts/Bridge/BaseXVSProxyOFT.sol Show resolved Hide resolved
contracts/Bridge/token/TokenController.sol Show resolved Hide resolved
contracts/Bridge/token/TokenController.sol Outdated Show resolved Hide resolved
contracts/Bridge/token/XVS.sol Show resolved Hide resolved
contracts/Bridge/token/XVS.sol Show resolved Hide resolved
contracts/Bridge/XVSBridgeAdmin.sol Outdated Show resolved Hide resolved
contracts/Bridge/XVSBridgeAdmin.sol Outdated Show resolved Hide resolved
contracts/Bridge/BaseXVSProxyOFT.sol Show resolved Hide resolved
@GitGuru7 GitGuru7 marked this pull request as ready for review September 27, 2023 05:28
contracts/Bridge/BaseXVSProxyOFT.sol Outdated Show resolved Hide resolved
contracts/Bridge/BaseXVSProxyOFT.sol Outdated Show resolved Hide resolved
contracts/Bridge/XVSBridgeAdmin.sol Outdated Show resolved Hide resolved
contracts/Bridge/XVSBridgeAdmin.sol Outdated Show resolved Hide resolved
contracts/Bridge/XVSBridgeAdmin.sol Show resolved Hide resolved
contracts/Bridge/token/TokenController.sol Show resolved Hide resolved
contracts/Bridge/token/XVS.sol Show resolved Hide resolved
contracts/Bridge/token/XVS.sol Show resolved Hide resolved
contracts/Bridge/token/XVS.sol Show resolved Hide resolved
contracts/Bridge/token/TokenController.sol Show resolved Hide resolved
@chechu
Copy link
Member

chechu commented Oct 11, 2023

We should add some of these tags when needed:

  • @custom:access Controlled by AccessControlManager
  • @custom:access Only owner

We should also add these tags, as we are doing in the rest of the project:

  • @custom:error <Error> <Description>
  • @custom:event ...

@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Health
contracts 96% 76%
contracts.Bridge 94% 61%
contracts.Bridge.interfaces 100% 100%
contracts.Bridge.token 74% 67%
contracts.Lens 95% 65%
contracts.Pool 100% 92%
contracts.Rewards 95% 62%
contracts.RiskFund 99% 71%
contracts.Shortfall 100% 85%
contracts.lib 100% 89%
Summary 96% (1584 / 1651) 73% (494 / 674)

@chechu
Copy link
Member

chechu commented Dec 21, 2023

This code has been moved to https://github.com/VenusProtocol/token-bridge

@GitGuru7 GitGuru7 closed this Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants