Skip to content

Commit

Permalink
📚 forge doc
Browse files Browse the repository at this point in the history
  • Loading branch information
moss-eth committed Oct 22, 2024
1 parent 70d3ea1 commit 356a455
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 23 deletions.
45 changes: 36 additions & 9 deletions docs/src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Zap Flashloan Utility

[![Github Actions][gha-badge]][gha]
[![Foundry][foundry-badge]][foundry]
[![Github Actions][gha-badge]][gha]
[![Foundry][foundry-badge]][foundry]
[![License: GPL-3.0][license-badge]][license]

[gha]: https://github.com/JaredBorders/Zap/actions
Expand All @@ -16,6 +16,7 @@
Zap is a smart contract that facilitates stablecoin "zapping" and Synthetix native collateral unwinding by integrating flash loans from Aave and Uniswap v3 swaps.

### What is a **Zap**?

> ONLY USDC is supported
USDC <--(spot market)--> sUSDC <--(spot market)--> USDx
Expand All @@ -42,24 +43,50 @@ USDC <--(spot market)--> sUSDC <--(spot market)--> USDx
- Withdraw Perp Collateral via Synthetix
- Swap via Uniswap

## Build and Test
## Development

### Build, Test, Report

### Build and Run
1. **Build the project**

1. **Build the project**
```bash
```
forge build
```

2. **Run tests**
```bash
2. **Run tests**

```
forge test
```

## Deployment
3. **Report Test Coverage**

```
make coverage
```

4. **Report Gas Snapshot**
```
make snapshot
```

## How to Deploy

- See the `deployments/` folder for Arbitrum and Base deployments.

How to Deploy:

1. Create a `.env` file using `.env-example` as a reference

2. Deploy to Base
```
make deploy_base
```
3. Deploy to Arbitrum
```
make deploy_arbitrum
```

## Audits

- See the `audits/` folder for Audit reports.
17 changes: 13 additions & 4 deletions docs/src/src/Zap.sol/contract.Zap.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Zap
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/Zap.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/Zap.sol)

**Inherits:**
[Reentrancy](/src/utils/Reentrancy.sol/contract.Reentrancy.md), [Errors](/src/utils/Errors.sol/contract.Errors.md)
[Reentrancy](/src/utils/Reentrancy.sol/contract.Reentrancy.md), [Errors](/src/utils/Errors.sol/contract.Errors.md), [Flush](/src/utils/Flush.sol/contract.Flush.md)

**Authors:**
@jaredborders, @flocqst, @barrasso, @moss-eth
Expand Down Expand Up @@ -560,12 +560,21 @@ function _unwind(

### _approximateLoanNeeded

the path and max amount in must take into consideration:
(1) Aave flashloan amount
(2) premium owed to Aave for flashloan
(3) USDC buffer added to the approximate loan needed

approximate USDC needed to unwind synthetix perp position

*given the USDC buffer, an amount of USDx
necessarily less than the buffer will remain (<$1);
this amount is captured by the protocol*

*(1) is a function of (3); buffer added to loan requested*

*(2) is a function of (1); premium is a percentage of loan*


```solidity
function _approximateLoanNeeded(uint128 _accountId)
Expand Down Expand Up @@ -607,7 +616,7 @@ function burn(
uint128 _accountId
)
external
returns (uint256 remaining);
returns (uint256 excess);
```
**Parameters**

Expand All @@ -620,7 +629,7 @@ function burn(

|Name|Type|Description|
|----|----|-----------|
|`remaining`|`uint256`|amount of USDx returned to the caller|
|`excess`|`uint256`|amount of USDx returned to the caller|


### _burn
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/interfaces/IAave.sol/interface.IPool.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IPool
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/interfaces/IAave.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/interfaces/IAave.sol)


## Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/interfaces/IERC20.sol/interface.IERC20.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IERC20
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/interfaces/IERC20.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/interfaces/IERC20.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IPerpsMarket
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/interfaces/ISynthetix.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/interfaces/ISynthetix.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ISpotMarket
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/interfaces/ISynthetix.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/interfaces/ISynthetix.sol)


## Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/interfaces/IUniswap.sol/interface.IQuoter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IQuoter
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/interfaces/IUniswap.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/interfaces/IUniswap.sol)


## Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/interfaces/IUniswap.sol/interface.IRouter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IRouter
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/interfaces/IUniswap.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/interfaces/IUniswap.sol)


## Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/utils/Errors.sol/contract.Errors.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Errors
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/utils/Errors.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/utils/Errors.sol)

**Author:**
@jaredborders
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/utils/Flush.sol/contract.Flush.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Flush
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/utils/Flush.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/utils/Flush.sol)

**Author:**
@jaredborders
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/utils/Reentrancy.sol/contract.Reentrancy.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reentrancy
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/utils/Reentrancy.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/utils/Reentrancy.sol)

**Authors:**
@moss-eth, @jaredborders
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SafeERC20
[Git Source](https://github.com/moss-eth/zap/blob/d8297745ea2933770a4e56a10de9706c3d09942b/src/utils/SafeTransferERC20.sol)
[Git Source](https://github.com/moss-eth/zap/blob/70d3ea131ffe8af2f978b53f91daa0d8ac74d19a/src/utils/SafeTransferERC20.sol)

*Wrappers around ERC-20 operations that throw on failure (when the token
contract returns false). Tokens that return no value (and instead revert or
Expand Down

0 comments on commit 356a455

Please sign in to comment.