# Smart Contracts

RockSolid vaults build upon the Lagoon ERC7540 Asynchronous Vault implementations. As such, these [docs](https://docs.lagoon.finance/developer-hub/integration) equally apply to RockSolid.&#x20;

## Quick Start Guide

You can see all the [read](https://etherscan.io/address/0x936facdf10c8c36294e7b9d28345255539d81bc7#readProxyContract) and [write](https://etherscan.io/address/0x936facdf10c8c36294e7b9d28345255539d81bc7#writeProxyContract) functions on etherscan.

### Deposit

```solidity
function syncDeposit(uint256 assets, address receiver, address referral) payable returns (uint256 shares);    
```

<table><thead><tr><th width="176.96484375">Parameter</th><th>Value</th></tr></thead><tbody><tr><td>assets</td><td>The amount of assets to deposit, in wei</td></tr><tr><td>receiver</td><td>The recipient, usually the connected wallet</td></tr><tr><td>referral</td><td>Referrer if you are running a referral program or <code>0x0000000000000000000000000000000000000000</code> if not or there is no referrer</td></tr></tbody></table>

### Withdraw

Withdrawal is two step. 1) You **request to redeem** and approximately 24 hours after processing 2) redeem

```solidity
function requestRedeem(uint256 shares, address receiver, address controller)
```

<table><thead><tr><th width="181.140625">Parameter</th><th>Value</th></tr></thead><tbody><tr><td>shares</td><td> The amount of shares to redeem, retrievable from <code>vault.balanceOf(address)</code></td></tr><tr><td>receiver</td><td>The recipient of the shares. Should be depositor unless this is a custodian integration.</td></tr><tr><td>controller</td><td>Should be the depositor, unless this is a custodian integration.</td></tr></tbody></table>

```solidity
function redeem(uint256 shares, address receiver, address controller)
```

<table><thead><tr><th width="180.875">Paramter</th><th>Value</th></tr></thead><tbody><tr><td>shares</td><td>The amount of shares to redeem. Should be the same value supplied to <code>requestRedeem()</code></td></tr><tr><td>receiver</td><td>The recipient of the shares. Should be the deposior unless this is a custodian integration.</td></tr><tr><td>controller</td><td>Should be the depositor, unless this is a custodian integration.</td></tr></tbody></table>

### View Balance

The number of shares a user address owns is available via:

```solidity
vault.balanceOf(userAddress) +
vault.pendingRedeemRequest(0, userAddress); → user shares waiting to be redeemed
```

### Utility Functions

Standard ERC20 and ERC4626 functions that are helpful during integration include

```solidity
convertToAssets(uint256 shares) → how much asset (e.g. rETH) per share
convertToShares(uint256 assets) → how many shares (e.g. rock.rETH) per asset
totalAssets() → total assets in the vault, aka TVL
totalSupply() → total shares in the vault.
symbol() → name of the share e.g. rock.rETH
name() → name of the vault e.g. RockSolid rETH Vault
safe() → address of the controlling wallet. May be a Safe or MPC.
```
