1/5
# `BalancerLiquidity.join` exercise Write your code inside the [`BalancerLiquidity` contract](https://github.com/Cyfrin/defi-reth/blob/main/foundry/src/exercises/BalancerLiquidity.sol) This exercise is design for you to gain experience adding liquidity to Balancer. ```solidity function join(uint256 rethAmount, uint256 wethAmount) external { // Write your code here } ``` ## Instructions 1. **Transfer rETH and WETH from msg.sender** - Transfer rETH and WETH from `msg.sender` - Approve Balancer (`address(vault)`) to spend these tokens 2. **Add liquidity** - Call internal function `_join` to add liquidity. - Prepare parameters `assets` and `maxAmountsIn`. Token addresses and max amounts in must be ordered as rETH and then WETH. - Set the recipient of LP token (BPT) to `msg.sender`. 3. **Refund** - Send any left over rETH and WETH in this contract to `msg.sender`. ## Testing ```shell forge test --fork-url $FORK_URL --match-path test/exercise-balancer.sol --match-test test_join -vvv ```
A detailed guide to Balancer liquidity joining. The lesson covers transferring rETH and WETH from the message sender, approving Balancer to spend these tokens, calling the internal function to add liquidity, and refunding any leftover rETH and WETH to the message sender.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Rocket Pool rETH staking, yield mechanisms, trading options, and contract architecture
How to distribute rewards and calculate rETH/ETH exchange rate
How to acquire and redeem rETH
Integrating rETH into DeFi protocols like AAVE V3
How to how to create leveraged ETH positions using rETH
How to provide rETH as liquidity to Balancer and Aura
Getting the USD price of rETH using Rocket Pool NAV oracle
Re-staking with EigenLayer
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 12, 2025
Stay in the loop with the latest Rocket Pool updates and connect with over 5,000 developers in the community.
Solidity Developer
Rocket Pool rETH IntegrationDuration: 4min
Duration: 48min
Duration: 57min
Duration: 30min
Duration: 7min
Duration: 23min
Duration: 6min
Course Overview
About the course
Rocket Pool rETH staking, yield mechanisms, trading options, and contract architecture
How to distribute rewards and calculate rETH/ETH exchange rate
How to acquire and redeem rETH
Integrating rETH into DeFi protocols like AAVE V3
How to how to create leveraged ETH positions using rETH
How to provide rETH as liquidity to Balancer and Aura
Getting the USD price of rETH using Rocket Pool NAV oracle
Re-staking with EigenLayer
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 12, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar