Skip to content

Commit

Permalink
minor fix for wallet accounting on deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaanshK committed Jan 16, 2025
1 parent d44910f commit b897e06
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cross-chain-deposit-module",
"version": "1.0.0",
"description": "A system for facilitating cross-chain deposit campaigns through Royco",
"description": "A system for facilitating cross-chain liquidity acquisition campaigns through Royco",
"scripts": {
"build": "forge build",
"test": "forge test -vvv",
Expand Down
4 changes: 2 additions & 2 deletions script/DeployDepositExecutor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ address constant CREATE2_FACTORY_ADDRESS = 0x4e59b44847b379578588920cA78FbF26c0B
address constant DEPOSIT_EXECUTOR_OWNER = 0x39Fff7105606472AC14eA9A272054d728D5b1104;
address constant LZ_V2_ENDPOINT = 0x6C7Ab2202C98C4227C5c46f1417D81144DA716Ff;
uint32 constant SOURCE_CHAIN_LZ_EID = 40_161; // ETH SEPOLIA
address constant DEPOSIT_LOCKER = 0x37e0A35512511aaf4233705B7eB5cf7b460854FE;
address constant DEPOSIT_LOCKER = 0x98d2F90150329726C039715Dd90DB84F0D4a0ea6;
address constant CAMPAIGN_VERIFIER = 0x7508A8b7887ef6ced89f1F0DCE09bb52707510F7;
IWETH constant WRAPPED_NATIVE_ASSET = IWETH(0x6969696969696969696969696969696969696969);

// Deployment salts
string constant DEPOSIT_EXECUTOR_SALT = "CCDM_DEPOSIT_EXECUTOR_02348b91cb3ab7939679deaa8b038ca74da64514";

// Expected deployment addresses after simulating deployment
address constant EXPECTED_DEPOSIT_EXECUTOR_ADDRESS = 0xB4cDac162905F79927D57647CE234202E4A54694;
address constant EXPECTED_DEPOSIT_EXECUTOR_ADDRESS = 0x17621de23Ff8Ad9AdDd82077B0C13c3472367382;

contract DeployDepositExecutor is Script {
error Create2DeployerNotDeployed();
Expand Down
2 changes: 1 addition & 1 deletion script/DeployDepositLocker.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ IUniswapV2Router01 constant UNISWAP_V2_ROUTER = IUniswapV2Router01(0xeE567Fe1712
string constant DEPOSIT_LOCKER_SALT = "CCDM_DEPOSIT_LOCKER_ab5c961a833d7d9e9314af142c08055bf24de74a";

// Expected deployment addresses after simulating deployment
address constant EXPECTED_DEPOSIT_LOCKER_ADDRESS = 0x37e0A35512511aaf4233705B7eB5cf7b460854FE;
address constant EXPECTED_DEPOSIT_LOCKER_ADDRESS = 0x98d2F90150329726C039715Dd90DB84F0D4a0ea6;

contract DeployDepositLocker is Script {
error Create2DeployerNotDeployed();
Expand Down
8 changes: 4 additions & 4 deletions script/deployment_instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ Deploying and Verifying the DepositLocker:
DepositLocker \
--chain sepolia \
--num-of-optimizations 5000 \
--compiler-version "v0.8.27+commit.40a35a09" \
--compiler-version "v0.8.28+commit.7893614a" \
--constructor-args "0x000000000000000000000000ce6ec1d4401a3cbaef79942ff257de2dfbc7714f0000000000000000000000000000000000000000000000000000000000009d9a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005d1b9186ac01b7c364734618172cd4487e68bc92000000000000000000000000783251f103555068c1e9d755f69458f39ed937c00000000000000000000000007b79995e5f793a07bc00c21412e50ecae098e7f9000000000000000000000000ee567fe1712faf6149d80da1e6934e354124cfe3000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000040000000000000000000000009cc7e185162aa5d1425ee924d97a87a0a34a07060000000000000000000000004985b8fcea3659fd801a5b857da1d00e985863f00000000000000000000000009d819ccae96d41d8f775bd1259311041248ff980000000000000000000000000552bac4a13ec7c261903433f1e12e9eff8dc4adc" \
--watch \
--via-ir

Deploying and Verifying the DepositExecutor:
1. source .env && forge script ./script/DeployDepositExecutor.s.sol --rpc-url=$CARTIO_RPC_URL --broadcast
2. forge verify-contract \
0xB4cDac162905F79927D57647CE234202E4A54694 \
0x17621de23Ff8Ad9AdDd82077B0C13c3472367382 \
DepositExecutor \
--verifier-url "https://api.routescan.io/v2/network/testnet/evm/80000/etherscan" \
--etherscan-api-key "verifyContract" \
--num-of-optimizations 5000 \
--compiler-version "v0.8.27+commit.40a35a09" \
--constructor-args "0x00000000000000000000000039fff7105606472ac14ea9a272054d728d5b11040000000000000000000000006c7ab2202c98c4227c5c46f1417d81144da716ff0000000000000000000000007508a8b7887ef6ced89f1f0dce09bb52707510f700000000000000000000000069696969696969696969696969696969696969690000000000000000000000000000000000000000000000000000000000009ce100000000000000000000000037e0a35512511aaf4233705b7eb5cf7b460854fe000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000004000000000000000000000000370dc69d5b49e6844c867efa752b419eac49aba800000000000000000000000087c367a0522aeb8ad9f9660d2250f1eac403c70f0000000000000000000000004f5f42799d1e01662b629ede265baea223e9f9c700000000000000000000000049a49ab0a048bcadb8b4e51c5c970c46bf889ccd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" \
--compiler-version "v0.8.28+commit.7893614a" \
--constructor-args "0x00000000000000000000000039fff7105606472ac14ea9a272054d728d5b11040000000000000000000000006c7ab2202c98c4227c5c46f1417d81144da716ff0000000000000000000000007508a8b7887ef6ced89f1f0dce09bb52707510f700000000000000000000000069696969696969696969696969696969696969690000000000000000000000000000000000000000000000000000000000009ce100000000000000000000000098d2f90150329726c039715dd90db84f0d4a0ea6000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000004000000000000000000000000370dc69d5b49e6844c867efa752b419eac49aba800000000000000000000000087c367a0522aeb8ad9f9660d2250f1eac403c70f0000000000000000000000004f5f42799d1e01662b629ede265baea223e9f9c700000000000000000000000049a49ab0a048bcadb8b4e51c5c970c46bf889ccd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" \
--watch \
--via-ir
35 changes: 19 additions & 16 deletions src/core/DepositLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,6 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {
uint256 totalAmountBridged
);

/**
* @notice Emitted when single tokens are bridged to the destination chain.
* @param marketHash The unique hash identifier of the market related to the bridged tokens.
* @param ccdmNonce The CCDM Nonce for this bridge.
* @param depositorsBridged All the depositors bridged in this CCDM bridge transaction.
* @param lz_guid The LayerZero unique identifier associated with the bridging transaction.
* @param lz_nonce The LayerZero nonce value for the bridging message.
* @param totalAmountBridged The total amount of tokens that were bridged to the destination chain.
*/
event SingleTokensBridgedToDestination(
bytes32 indexed marketHash, uint256 indexed ccdmNonce, address[] depositorsBridged, bytes32 lz_guid, uint64 lz_nonce, uint256 totalAmountBridged
);

/**
* @notice Emitted when UNI V2 LP tokens are merkle bridged to the destination chain.
* @param marketHash The unique hash identifier of the market associated with the LP tokens.
Expand Down Expand Up @@ -287,6 +274,19 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {
uint256 lz_token1_AmountBridged
);

/**
* @notice Emitted when single tokens are bridged to the destination chain.
* @param marketHash The unique hash identifier of the market related to the bridged tokens.
* @param ccdmNonce The CCDM Nonce for this bridge.
* @param depositorsBridged All the depositors bridged in this CCDM bridge transaction.
* @param lz_guid The LayerZero unique identifier associated with the bridging transaction.
* @param lz_nonce The LayerZero nonce value for the bridging message.
* @param totalAmountBridged The total amount of tokens that were bridged to the destination chain.
*/
event SingleTokensBridgedToDestination(
bytes32 indexed marketHash, uint256 indexed ccdmNonce, address[] depositorsBridged, bytes32 lz_guid, uint64 lz_nonce, uint256 totalAmountBridged
);

/**
* @notice Emitted when UNI V2 LP tokens are bridged to the destination chain.
* @param marketHash The unique hash identifier of the market associated with the LP tokens.
Expand Down Expand Up @@ -589,7 +589,7 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {
merkleDepositsInfo.totalAmountDeposited += amountDeposited;
// Update the amount this Weiroll Wallet has deposited into the currently stored merkle tree.
uint256 lastCcdmNonceBridged = merkleDepositsInfo.lastCcdmNonceBridged;
merkleDepositsInfo.lastCcdmNonceBridgedToWeirollWalletToDepositAmount[lastCcdmNonceBridged][msg.sender] = amountDeposited;
merkleDepositsInfo.lastCcdmNonceBridgedToWeirollWalletToDepositAmount[lastCcdmNonceBridged][msg.sender] += amountDeposited;

// Emit merkle deposit event
emit MerkleDepositMade(
Expand Down Expand Up @@ -643,6 +643,7 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {
address depositor = wallet.owner();
uint256 amountDeposited = wallet.amount();

// Check that the target market isn't halted
require(!marketHashToHalted[targetMarketHash], MarketIsHalted());

// Get the token to deposit for this market
Expand Down Expand Up @@ -671,7 +672,7 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {
depositorInfo.totalAmountDeposited = totalDepositAmountPostDeposit;
WeirollWalletDepositInfo storage walletInfo = depositorToWeirollWalletToWeirollWalletDepositInfo[depositor][msg.sender];
walletInfo.ccdmNonceOnDeposit = ccdmNonce;
walletInfo.amountDeposited = amountDeposited;
walletInfo.amountDeposited += amountDeposited;

// Emit deposit event
emit IndividualDepositMade(targetMarketHash, msg.sender, depositor, amountDeposited);
Expand Down Expand Up @@ -720,6 +721,7 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {
// Get the market's input token
(, ERC20 marketInputToken,,,,,) = RECIPE_MARKET_HUB.marketHashToWeirollMarket(_marketHash);

// Can't bridge LP positions using this function
require(!_isUniV2Pair(address(marketInputToken)), CannotBridgeLpTokens());

// Get merkleDepositsInfo for the specified market
Expand Down Expand Up @@ -894,6 +896,7 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {
// Get the market's input token
(, ERC20 marketInputToken,,,,,) = RECIPE_MARKET_HUB.marketHashToWeirollMarket(_marketHash);

// Can't bridge LP positions using this function
require(!_isUniV2Pair(address(marketInputToken)), CannotBridgeLpTokens());

// Initialize compose message
Expand Down Expand Up @@ -1467,7 +1470,7 @@ contract DepositLocker is Ownable2Step, ReentrancyGuardTransient {

/**
* @notice Turns the green light on for a market.
* @notice Will trigger the 48-hour rage quit duration, after which funds will be bridgable for this market.
* @notice Will trigger the rage quit duration, after which funds will be bridgable for this market.
* @dev Only callable by the green lighter.
* @param _marketHash The market hash to turn the green light on for.
*/
Expand Down

0 comments on commit b897e06

Please sign in to comment.