-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
826e367
commit 168b4c3
Showing
10 changed files
with
153 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
# cross-chain-contracts-internal | ||
This repository contains contracts to support cross chain bridging on EVM chains. The main contract is | ||
[OFTWrapper](contracts/OFTWrapper.sol) which supports bridging using LayerZero. | ||
|
||
## OFTWrapper | ||
This contract is a proxy around LayerZero's OFT standard. The `OFTWrapper` can be called | ||
by LayerZero to mint and burn tokens like normal. The `OFTWrapper` then forwards those requests | ||
to the underlying token. The underlying token must grant this contract permission to mint and burn. | ||
|
||
## Upgrade process | ||
`OFTWrapper` is a non-upgradeable contract. If a change needs to be made a new contract should be deployed. | ||
The underlying token should then revoke mint and burn permissions on the old contract and grant mint and burn | ||
permissions to the new contract. | ||
|
||
## Contract Tests | ||
Install dependencies: | ||
|
||
`npm install` | ||
|
||
Compile the contracts: | ||
|
||
`npx hardhat compile` | ||
|
||
Run unit tests: | ||
|
||
`npx hardhat test` | ||
|
||
Check test coverage: | ||
|
||
`npx hardhat coverage` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,17 @@ | |
pragma solidity ^0.8.20; | ||
|
||
import {OFTCore, IOFT} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFTCore.sol"; | ||
import {RateLimiter} from "@layerzerolabs/oapp-evm/contracts/oapp/utils/RateLimiter.sol"; | ||
import {PaxosTokenV2} from "PaxosToken/contracts/PaxosTokenV2.sol"; | ||
|
||
/** | ||
* @title OFTWrapper | ||
* @dev This contract is a proxy around LayerZero's OFT standard. The OFTWrapper can be called | ||
* by LayerZero to mint and burn tokens like normal. The OFTWrapper then forwards those requests | ||
* to the underlying token. The underlying token must grant this contract permission to mint and burn. | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract OFTWrapper is OFTCore { | ||
contract OFTWrapper is OFTCore, RateLimiter { | ||
//The Paxos token | ||
PaxosTokenV2 private immutable paxosToken; | ||
|
||
|
@@ -24,9 +26,11 @@ contract OFTWrapper is OFTCore { | |
constructor( | ||
address _paxosToken, | ||
address _lzEndpoint, | ||
address _delegate | ||
address _delegate, | ||
RateLimitConfig[] memory _rateLimitConfigs | ||
) OFTCore(6, _lzEndpoint, _delegate) { | ||
paxosToken = PaxosTokenV2(_paxosToken); | ||
_setRateLimits(_rateLimitConfigs); | ||
} | ||
|
||
/** | ||
|
@@ -55,6 +59,16 @@ contract OFTWrapper is OFTCore { | |
return false; | ||
} | ||
|
||
/** | ||
* @dev Sets the rate limits based on RateLimitConfig array. Only callable by the owner. | ||
* @param _rateLimitConfigs An array of RateLimitConfig structures defining the rate limits. | ||
*/ | ||
function setRateLimits( | ||
RateLimitConfig[] calldata _rateLimitConfigs | ||
) external onlyOwner { | ||
_setRateLimits(_rateLimitConfigs); | ||
} | ||
|
||
/** | ||
* @dev Internal function to perform a debit operation. Calls the underlying token | ||
* to perform the burn via `decreaseSupplyFromAddress`. | ||
|
@@ -80,6 +94,7 @@ contract OFTWrapper is OFTCore { | |
_minAmountLD, | ||
_dstEid | ||
); | ||
_checkAndUpdateRateLimit(_dstEid, amountSentLD); | ||
paxosToken.decreaseSupplyFromAddress(amountSentLD, _from); | ||
} | ||
|
||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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