-
Notifications
You must be signed in to change notification settings - Fork 98
Cross-chain Strategy #2715
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
Open
shahthepro
wants to merge
115
commits into
master
Choose a base branch
from
shah/cross-chain-strategy-cctpv2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Cross-chain Strategy #2715
Changes from 11 commits
Commits
Show all changes
115 commits
Select commit
Hold shift + click to select a range
637fb40
some scaffolding
sparrowDom 7630f6d
add basic necessities for unit tests
sparrowDom 6a97767
checkpoint
shahthepro 9517fca
Fix compiling issues
shahthepro 41f1fd9
Add fork test scaffolding
shahthepro 7a109cc
Fix stuffs
shahthepro 48d317e
Prettify and change salt
shahthepro c6a254a
Add auto-verification
shahthepro 8f4e39e
Fix checkBalance
shahthepro f7a9b97
Make CCTPHookWrapper more resilient
shahthepro b3c1eb4
refactor message version and type checks
sparrowDom d3c4a39
add some comments
sparrowDom 792c890
add comment
sparrowDom 70166bc
fix compile errors
sparrowDom 1e700b1
Change addresses
shahthepro 7d60614
Cross chain changes (#2718)
sparrowDom ada1546
Merge branch 'master' into shah/cross-chain-strategy-cctpv2
shahthepro 987dc0a
Fix compilation issues
shahthepro b63bd5f
Fix deployment files a bit
shahthepro bf1fbe2
Fix Message relayer
shahthepro a0dd07b
Clean up master strategy
shahthepro 4071943
Fix deployment file name
shahthepro 9e36485
move around stuff
shahthepro e401fa1
Fix CCTP Integrator
shahthepro 73abf6c
clean up fork
shahthepro 266ec01
Fix race condition (#2720)
shahthepro 122fa32
Cleanup code
shahthepro 7507994
decode payloads in fork tests
shahthepro 7998ffa
Add library for message handling
shahthepro e34706a
More changes
shahthepro df59d53
Add comments and prettify
shahthepro 29ee0e6
WIP Unit test setup (#2722)
sparrowDom a0d5379
Add more fork tests
shahthepro 3585d9d
Add token transfer tests
shahthepro e694906
WIP Unit tests for OUSD Simplified strategy (#2724)
sparrowDom 77bc730
Fix master fork tests
shahthepro 6dca3cc
linter
shahthepro 7de74b4
add direct withdrawal paths and additional checks
sparrowDom fb31b79
Fix Remote strategy tests
shahthepro 54ca3c0
Update comments and clean up code
shahthepro 5ac664c
Fix comment
shahthepro b16c7fd
Fix failing unit test
shahthepro a4c2968
fix: withdraw only if balance is lower than requested amount
shahthepro fca3df2
Document crosschain strategy
shahthepro e322fe3
Merge branch 'master' into shah/cross-chain-strategy-cctpv2
shahthepro b2feed1
Update deployment file numbers
shahthepro 4150f9a
adjust the charts
sparrowDom 7c32c01
change the function visibility to pure
sparrowDom cbc0745
fix: create2 proxy without using deployer address
shahthepro 8bd5edc
fix: impersonate a single deployer on fork
shahthepro 4557836
deploy script bug fix
shahthepro 31b9f50
Store create2 proxy addresses
shahthepro 057bd78
fix: await
shahthepro f4bff9e
more logging
shahthepro 2948739
fix opts
shahthepro 801eacf
Fix env for deploy action
shahthepro 8d9ace2
Change writeFileSync to writeFile
shahthepro cb19da2
add log
shahthepro 8dd21bd
Add more logs
shahthepro b54ef4b
fix callback
shahthepro c0a277e
Add empty file
shahthepro bfb411c
Cleanup logs
shahthepro 2178676
withdraw funds according to the spec
sparrowDom 812d78b
Address Code Review comments (#2732)
shahthepro bfa9b2c
Revert 999
shahthepro 77cd4e5
Merge branch 'master' into shah/cross-chain-strategy-cctpv2
shahthepro 72f0337
fix comments
shahthepro a17cd0a
add a test that uncovers a withdrawal error (#2733)
sparrowDom 8cf968a
remove transferType
sparrowDom 59fdeeb
correct spelling
sparrowDom 8e06d55
rename baseToken to usdcToken
sparrowDom b9fee74
improve error message
sparrowDom 5f290e8
simplify code
sparrowDom 9117a18
fix: min withdraw amount is 1e6
shahthepro c7b2a92
add validations for config
shahthepro b0a3f6f
fix: require a min deposit amount of 1e6
shahthepro 66015ac
fix: withdrawAll caps withdraw amount
shahthepro 4cc4524
Move around constants
shahthepro a0d7bef
Move decode message header function
shahthepro 85e91f4
fix fork tests
shahthepro 4ebe400
prettify
shahthepro b9b0035
adjust some comments
sparrowDom c4bc36d
have consistent event names
sparrowDom 9f7d423
fix: remove redundant check
shahthepro ad9dc47
simplify stuff
shahthepro bd51e56
adjust comment
sparrowDom 3729fa8
fix: variable name
shahthepro 800e21b
Add TokensBridged and MessageTransmitted events
shahthepro 75e260f
Add finality threshold checks
shahthepro a1482a0
add comment regarding fast transfers
sparrowDom b674c75
Add analytics info
shahthepro d23548e
Change error message
shahthepro d9b2a49
Set 1 USDC as min allowed value for deposits
shahthepro eb66a55
Change comment
shahthepro a7e0ae9
Change comment
shahthepro 6022c93
Update max transfer amount comment
shahthepro 6a3846d
Set nonce(0) as processed during initialization
shahthepro fafe7d4
Use Strategizable for strategist functionality (#2740)
sparrowDom d80f754
set vault address to zero (#2742)
sparrowDom 7bbafc3
remove unnecessary comments
shahthepro 7d7d2f9
Add comment
shahthepro 51d62c8
Add nonReentrant for deposit and withdraw methods
shahthepro 8324c9c
Add more checks in constructor
shahthepro b731385
Fix withdrawAll
shahthepro e524a33
Update deploy numbers
naddison36 15d74af
simplify _withdraw (#2741)
sparrowDom b3fa453
address verification (#2749)
sparrowDom 5d77684
Merge remote-tracking branch 'origin/master' into shah/cross-chain-st…
naddison36 81743e7
Fix merge issue
naddison36 9948853
small adjustement
sparrowDom e0cf9b9
fix unit test
sparrowDom e1cacc0
Merge remote-tracking branch 'origin/master' into shah/cross-chain-st…
naddison36 1e06afe
Bumped the deploy script numbers
naddison36 85531eb
remove unused parameter (#2754)
sparrowDom 63ff128
Add unit tests (#2751)
sparrowDom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| interface ICCTPTokenMessenger { | ||
| function depositForBurn( | ||
| uint256 amount, | ||
| uint32 destinationDomain, | ||
| bytes32 mintRecipient, | ||
| address burnToken, | ||
| bytes32 destinationCaller, | ||
| uint256 maxFee, | ||
| uint32 minFinalityThreshold | ||
| ) external; | ||
|
|
||
| function depositForBurnWithHook( | ||
| uint256 amount, | ||
| uint32 destinationDomain, | ||
| bytes32 mintRecipient, | ||
| address burnToken, | ||
| bytes32 destinationCaller, | ||
| uint256 maxFee, | ||
| uint32 minFinalityThreshold, | ||
| bytes memory hookData | ||
| ) external; | ||
|
|
||
| function getMinFeeAmount(uint256 amount) external view returns (uint256); | ||
| } | ||
|
|
||
| interface ICCTPMessageTransmitter { | ||
| function sendMessage( | ||
| uint32 destinationDomain, | ||
| bytes32 recipient, | ||
| bytes32 destinationCaller, | ||
| uint32 minFinalityThreshold, | ||
| bytes memory messageBody | ||
| ) external; | ||
|
|
||
| function receiveMessage(bytes calldata message, bytes calldata attestation) | ||
| external | ||
| returns (bool); | ||
| } | ||
|
|
||
| interface IMessageHandlerV2 { | ||
| /** | ||
| * @notice Handles an incoming finalized message from an IReceiverV2 | ||
| * @dev Finalized messages have finality threshold values greater than or equal to 2000 | ||
| * @param sourceDomain The source domain of the message | ||
| * @param sender The sender of the message | ||
| * @param finalityThresholdExecuted the finality threshold at which the message was attested to | ||
| * @param messageBody The raw bytes of the message body | ||
| * @return success True, if successful; false, if not. | ||
| */ | ||
| function handleReceiveFinalizedMessage( | ||
| uint32 sourceDomain, | ||
| bytes32 sender, | ||
| uint32 finalityThresholdExecuted, | ||
| bytes calldata messageBody | ||
| ) external returns (bool); | ||
|
|
||
| /** | ||
| * @notice Handles an incoming unfinalized message from an IReceiverV2 | ||
| * @dev Unfinalized messages have finality threshold values less than 2000 | ||
| * @param sourceDomain The source domain of the message | ||
| * @param sender The sender of the message | ||
| * @param finalityThresholdExecuted The finality threshold at which the message was attested to | ||
| * @param messageBody The raw bytes of the message body | ||
| * @return success True, if successful; false, if not. | ||
| */ | ||
| function handleReceiveUnfinalizedMessage( | ||
| uint32 sourceDomain, | ||
| bytes32 sender, | ||
| uint32 finalityThresholdExecuted, | ||
| bytes calldata messageBody | ||
| ) external returns (bool); | ||
| } |
21 changes: 21 additions & 0 deletions
21
contracts/contracts/mocks/crosschain/CrossChainMasterStrategyMock.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| /** | ||
| * @title OUSD Yearn V3 Master Strategy Mock - the Mainnet part | ||
| * @author Origin Protocol Inc | ||
| */ | ||
|
|
||
| contract CrossChainMasterStrategyMock { | ||
| address public _remoteAddress; | ||
|
|
||
| constructor() {} | ||
|
|
||
| function remoteAddress() public view returns (address) { | ||
| return _remoteAddress; | ||
| } | ||
|
|
||
| function setRemoteAddress(address __remoteAddress) public { | ||
| _remoteAddress = __remoteAddress; | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
contracts/contracts/mocks/crosschain/CrossChainRemoteStrategyMock.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| /** | ||
| * @title OUSD Yearn V3 Remote Strategy Mock - the Mainnet part | ||
| * @author Origin Protocol Inc | ||
| */ | ||
|
|
||
| contract CrossChainRemoteStrategyMock { | ||
shahthepro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| address public _masterAddress; | ||
|
|
||
| constructor() {} | ||
|
|
||
| function masterAddress() public view returns (address) { | ||
| return _masterAddress; | ||
| } | ||
|
|
||
| function setMasterAddress(address __masterAddress) public { | ||
| _masterAddress = __masterAddress; | ||
| } | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
contracts/contracts/proxies/InitializeGovernedUpgradeabilityProxy2.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { InitializeGovernedUpgradeabilityProxy } from "./InitializeGovernedUpgradeabilityProxy.sol"; | ||
|
|
||
| /** | ||
| * @title BaseGovernedUpgradeabilityProxy2 | ||
| * @dev This is the same as InitializeGovernedUpgradeabilityProxy except that the | ||
| * governor is defined in the constructor. | ||
| * @author Origin Protocol Inc | ||
| */ | ||
| contract InitializeGovernedUpgradeabilityProxy2 is | ||
| InitializeGovernedUpgradeabilityProxy | ||
| { | ||
| /** | ||
| * This is used when the msg.sender can not be the governor. E.g. when the proxy is | ||
| * deployed via CreateX | ||
| */ | ||
| constructor(address governor) InitializeGovernedUpgradeabilityProxy() { | ||
| _setGovernor(governor); | ||
| } | ||
| } |
This file contains hidden or 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
21 changes: 21 additions & 0 deletions
21
contracts/contracts/proxies/create2/CCTPHookWrapperProxy.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { InitializeGovernedUpgradeabilityProxy2 } from "../InitializeGovernedUpgradeabilityProxy2.sol"; | ||
|
|
||
| // ******************************************************** | ||
| // ******************************************************** | ||
| // IMPORTANT: DO NOT CHANGE ANYTHING IN THIS FILE. | ||
| // Any changes to this file (even whitespaces) will | ||
| // affect the create2 address of the proxy | ||
| // ******************************************************** | ||
| // ******************************************************** | ||
|
|
||
| /** | ||
| * @notice CCTPHookWrapperProxy delegates calls to a CCTPHookWrapper implementation | ||
| */ | ||
| contract CCTPHookWrapperProxy is InitializeGovernedUpgradeabilityProxy2 { | ||
| constructor(address governor) | ||
| InitializeGovernedUpgradeabilityProxy2(governor) | ||
| {} | ||
| } |
23 changes: 23 additions & 0 deletions
23
contracts/contracts/proxies/create2/CrossChainStrategyProxy.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { InitializeGovernedUpgradeabilityProxy2 } from "../InitializeGovernedUpgradeabilityProxy2.sol"; | ||
|
|
||
| // ******************************************************** | ||
| // ******************************************************** | ||
| // IMPORTANT: DO NOT CHANGE ANYTHING IN THIS FILE. | ||
| // Any changes to this file (even whitespaces) will | ||
| // affect the create2 address of the proxy | ||
| // ******************************************************** | ||
| // ******************************************************** | ||
|
|
||
| /** | ||
| * @notice CrossChainStrategyProxy delegates calls to a | ||
| * CrossChainMasterStrategy or CrossChainRemoteStrategy | ||
| * implementation contract. | ||
| */ | ||
| contract CrossChainStrategyProxy is InitializeGovernedUpgradeabilityProxy2 { | ||
| constructor(address governor) | ||
| InitializeGovernedUpgradeabilityProxy2(governor) | ||
| {} | ||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
"- the Mainnet part" should probably be "- the L2 chain part"