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

Feat/share ccip bridge #180

Merged
merged 12 commits into from
Jan 23, 2024
Merged

Conversation

crispymangoes
Copy link
Collaborator

@crispymangoes crispymangoes commented Jan 18, 2024

PR Scope Details

Core Contracts

  1. DestinationMinter.sol (DM)
  2. DestinationMinterFactory.sol (DMF)
  3. SourceLocker.sol (SL)
  4. SourceLockerFactory.sol (SLF)

Sequence of Main Operations for Contracts

  1. Factory Contract Deployments:
    • SLF on source network && DMF on destination network.
  2. Setup:
    • setDestinationMinterFactory() such that they are properly connected.
  3. Create new pairs of SL & DM for a specified ERC20 shareToken via call: SourceLockerFactory.deploy()
    • High-Level: sends a series of msgs via CCIP to DMF and back (callback) to deploy a new SL && DM pair.
      • 1st msg (SLF -> DMF): deploys new DM w/ specs from msg from SF.
      • 2nd msg (DMF -> SLF): callback where SourceLocker.setTargetDestination() is finally called that finishes the setup of the DM & SL pair for said ERC20 shareToken param specified in initial deploy() call
  4. SL locks up shares to bridge a mint request to DM, where the representation of the Source Network Shares is minted on Destination Network.
    - Likely setup to start:
    • A-Tier Cross-Chain-Locker-Minter (CCLM) Pair:
      • Arbitrum SLF && Mainnet DMF (Mainnet representation of Arbitrum yields)
    • B-Tier CCLM Pairs:
      • Alt-Networks SLFs && Arbitrum DMFs (Aggregation of alt-networks share token representations on Arbitrum, all distilled into the A-Tier CCLM Pair

Copy link
Contributor

@0xEinCodes 0xEinCodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small changes. This is an exciting PR man, awesome work! We discussed some bigger picture aspects such as:

  1. If there is any risk with the destinationShares being used in a destination chain protocolwith liquidation. This is a teaser to the possible areas that cross-chain shares could be used in to help "aggregate" yields and whatnot across the networks. We are leaving it to figure out later though and is outside of the scope of this PR so all good.
  2. Another "Future" thing to consider that we chatted about is how destination chain protocols who provide liquidity mining or some type of reward setup would work with cross-chain shares such that they could get all yield (from the shares as well) on the destination chain itself. This is not in scope for this PR though, and could be handled via arbitrage as you had pointed out in our chat.

error DestinationMinter___SourceChainNotAllowlisted(uint64 sourceChainSelector);
error DestinationMinter___SenderNotAllowlisted(address sender);
error DestinationMinter___InvalidTo();
error DestinationMinter___FeeTooHigh();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this error, did we want to outline the amount of fees that was erroneous? Or is it just self-explanatory since they are user input params again?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this error only bubbles up if the user specified maxLinkToPay is less than the fees it would cost to send the bridge TX. So we could probably add in 2 args, the user specified max, and the actual fees being charged. However I dont think etherscan knows how to process custom errors, so this would only help people interacting with our contracts via some dev env that tells them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that Etherscan is limited in that sense. So how would this pop up on etherscan if it were to revert because of this? If nothing can be done about it so it helps users, then that is fine to leave this unchanged.


if (fees > maxLinkToPay) revert DestinationMinter___FeeTooHigh();

LINK.safeTransferFrom(msg.sender, address(this), fees);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caller will have to approve LINK to be sent to this DestinationMinter, add note in the natspec?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On that note, do we want to have a revokeApprovals at the end of this function for LINK?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm that is a good question. The router address is verified to be safe, and these contracts will not be holding any customer funds that are LINK. So it would probably only help us if for some reason the router did not transfer the link it said it would, and the LINK contract had ERC20 breaking logic like USDT where we revert when going from non zero allowance to non zero allowance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but since we know that is not the case with the LINK contract, are you saying that we do not need to have a revokeApprovals applied here?

src/modules/multi-chain-share/SourceLocker.sol Outdated Show resolved Hide resolved
src/modules/multi-chain-share/SourceLockerFactory.sol Outdated Show resolved Hide resolved
src/modules/multi-chain-share/SourceLockerFactory.sol Outdated Show resolved Hide resolved
test/MultiChainShare.t.sol Outdated Show resolved Hide resolved
test/MultiChainShare.t.sol Outdated Show resolved Hide resolved
test/MultiChainShare.t.sol Show resolved Hide resolved
test/MultiChainShare.t.sol Show resolved Hide resolved
Copy link
Contributor

@0xEinCodes 0xEinCodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked through the changes, and discussed any lingering ones with you async. Any that are lingering will be added to the fix branch once the audit report is received from Macro.

@crispymangoes crispymangoes merged commit b7004cd into dev/macro-audit-16 Jan 23, 2024
2 checks passed
@crispymangoes crispymangoes deleted the feat/share-ccip-bridge branch January 23, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants