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: convert WLPToken to ERC4626 standard #61

Merged
merged 38 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5274a0e
feat: convert WLPToken to ERC4626 standard
0xSolDev Dec 18, 2024
777c498
feat: use uups upgrades
0xSolDev Dec 18, 2024
3e49ab3
fix: fixed lint
0xSolDev Dec 18, 2024
64a16b2
feat: updated governance model for factory
0xSolDev Dec 19, 2024
ee4c890
fix: fixed test
0xSolDev Dec 19, 2024
30ab88e
fix: fixed scripts
0xSolDev Dec 19, 2024
ea8bfe6
fix: remove timelock from factory
0xSolDev Dec 21, 2024
421add1
feat: renamed to self pegging asset
0xSolDev Dec 23, 2024
19e12d4
feat: use custom errors
0xSolDev Dec 24, 2024
d31c92f
fix: fixed admin privilages
0xSolDev Dec 24, 2024
fd0f54d
fix: merge conflict
0xSolDev Dec 24, 2024
5677293
fix: removed application contract
0xSolDev Dec 25, 2024
d8e4540
fix: merge conflict
0xSolDev Dec 25, 2024
d7da416
feat: added netspec
0xSolDev Dec 25, 2024
846fa0c
fix: added netspec
0xSolDev Dec 25, 2024
6d763d4
fix: refactored tests
0xSolDev Dec 25, 2024
b3e76a4
feat: upgraded oz
0xSolDev Dec 28, 2024
f30361a
feat: added tests
0xSolDev Dec 28, 2024
9f2a7be
feat: added tests
0xSolDev Dec 28, 2024
790ba15
feat: added tests
0xSolDev Dec 28, 2024
8b03f90
feat: added tests
0xSolDev Dec 28, 2024
acbf81b
feat: added tests
0xSolDev Dec 28, 2024
2e87c5e
feat: reverted tests
0xSolDev Dec 28, 2024
cfe6617
feat: added lp and wlp token tests
0xSolDev Dec 29, 2024
1a28658
feat: deployed on base sepolia
0xSolDev Dec 30, 2024
88d46b4
feat: created pool
0xSolDev Dec 30, 2024
dc3116d
fix: revert contract
0xSolDev Dec 30, 2024
78e79e0
fix: updated readme
0xSolDev Dec 30, 2024
323b737
fix: fixed lint
0xSolDev Dec 31, 2024
b376364
fix: fixed lint
0xSolDev Dec 31, 2024
b443603
Merge pull request #66 from nutsfinance/feat/demo-deployment
0xSolDev Dec 31, 2024
27790a9
Merge pull request #65 from nutsfinance/feat/tests
0xSolDev Dec 31, 2024
3b60b4a
Merge pull request #64 from nutsfinance/feat/coding-standard
0xSolDev Dec 31, 2024
993b4c7
Merge pull request #63 from nutsfinance/feat/timelock-integration
0xSolDev Dec 31, 2024
db8eaed
Merge pull request #62 from nutsfinance/feat/uups-upgradable
0xSolDev Dec 31, 2024
89e99ce
feat: overwrite preview and withdraw funcs
0xSolDev Dec 31, 2024
4ff4518
fix: remove duplicate override
0xSolDev Dec 31, 2024
c07f54e
fix: added mint function override
0xSolDev Dec 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 51 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ applications.

The main contracts of Tapio V1.5 are the following:

**TapEth** : contract of rebase token tapETH
**LPToken** : contract of rebase token lpToken

**WtapETH**: contract of wrapped tapETH
**WlpToken**: contract of wrapped lpToken

**StableAsset**: contract of stableswap pool
**SelfPeggingAsset**: contract of stableswap pool

**StableAssetApplication**: user contract interface for different stableSwap pools
**SelfPeggingAssetApplication**: user contract interface for different stableSwap pools

# Smart Contracts OVERVIEW

The main contracts of Tapio V1.5 are the following:

**TapEth** : contract of rebase token tapETH
**LPToken** : contract of rebase token lpToken

**WtapETH**: contract of wrapped tapETH
**WlpToken**: contract of wrapped lpToken

**StableAsset**: contract of stableswap pool
**SelfPeggingAsset**: contract of stableswap pool

**StableAssetApplication**: user contract interface for different stableSwap pools
**SelfPeggingAssetApplication**: user contract interface for different stableSwap pools

## Contract TapETH
## Contract LPToken

The contract **TapETH** is upgradable and uses the interface IERC20.
The contract **LPToken** is upgradable and uses the interface IERC20.

### Write Methodes

Expand All @@ -49,99 +49,65 @@ The contract **TapETH** is upgradable and uses the interface IERC20.

- **transferShares(address \_recipient, uint256 \_sharesAmount)**

This function allows the caller to transfer `_sharesAmount` shares of tapETH from his address to `_recipient`.
This function allows the caller to transfer `_sharesAmount` shares of lpToken from his address to `_recipient`.

- **transferSharesFrom(address \_sender, address \_recipient, uint256 \_sharesAmount)**

This function allows the spender to transfer `_sharesAmount` shares of tapETH from to `_sender` to `_recipient`.
This function allows the spender to transfer `_sharesAmount` shares of lpToken from to `_sender` to `_recipient`.

- **mintShares(address \_account, uint256 \_tokenAmount)**

This function can be executed by a whitelisted stableSwap pool to mint `_tokenAmount` of tapETH for `_account`.
This function can be executed by a whitelisted stableSwap pool to mint `_tokenAmount` of lpToken for `_account`.

- **burnShares(uint256 \_tokenAmount)**

This function allows the caller to burn `_tokenAmount` of tapETH.
This function allows the caller to burn `_tokenAmount` of lpToken.

- **burnSharesFrom(address \_account, uint256 \_tokenAmount)**

This function allows the spender to burn `_tokenAmount` of tapETH from the addresss `_account`.
This function allows the spender to burn `_tokenAmount` of lpToken from the addresss `_account`.

### View Methodes

- **getTotalPooledEther()**
- **getTotalPeggedTokener()**

This function returns the total supply of tapETH (uint256).
This function returns the total supply of lpToken (uint256).

- **getTotalShares()**

This function returns the total shares of tapETH (uint256).
This function returns the total shares of lpToken (uint256).

- **getSharesByPooledEth(uint256_tapETHAmount)**
- **getSharesByPeggedToken(uint256_lpTokenAmount)**

This function returns the shares of tapETH (uint256) corresponding to `_tapETHAmount` of tapETH.
This function returns the shares of lpToken (uint256) corresponding to `_lpTokenAmount` of lpToken.

- **getPooledEthByShares(uint256 \_sharesAmount)**
- **getPeggedTokenByShares(uint256 \_sharesAmount)**

This function returns the amount of tapETH (uint256) corresponding to `sharesAmount' shares of tapETH.
This function returns the amount of lpToken (uint256) corresponding to `sharesAmount' shares of lpToken.

- **setTotalSupply(uint256 \_amount)**

This function can be only called by a whitelist stableSwap pool contract to increase the total supply of tapETH by
This function can be only called by a whitelist stableSwap pool contract to increase the total supply of lpToken by
`_amount`.

## Contract WTapETH
## Contract SelfPeggingAsset

The contract **WTapETH** is upgradable and inherits from the contract ERC20Permit.

### Write Methodes

- **wrap(uint256 \_tapETHAmount)**

This function allows the user to wrap `_ tapETHAmount` of tapETH that consisting in transferring `_tapETHAmount` of
tapETH to the smart contract WTapETH and minting the corresponding shares amount in wtapETH.

- **unwrap(uint256 \_wtapETHAmount)**

This function allows the user to unwrap `_wtapETHAmount` of wtapETH that consisting in burning `wtapETHAmount` of
wtapETH and sending from the smart contract WTapETH to the caller the corresponding amount of tapETH.

### View Methodes

- **getWtapETHByTapETH(uint256 \_tapETHAmount)**

This function returns the amount of wtapETH that corresponds to `_tapETHAmount` of tapETH.

- **getTapETHByWtapETH(uint256 \_wtapETHAmount)**

This function returns the amount of tapETH that corresponds to `_wtapETHAmount` of wtapETH.

- **tapETHPerToken()**

This function returns the amount of tapETH that corresponds to 1 wtapETH.

- **tokensPerTapETH()**

This function returns the amount of wtapETH that corresponds to 1 tapETH.

## Contract StableAsset

The contract **StableAsset** is upgradable and inherits from the contract ReentrancyGuard.
The contract **SelfPeggingAsset** is upgradable and inherits from the contract ReentrancyGuard.

### Write Methodes

- **mint(uint256[] calldata \_amounts, uint256 \_minMintAmount)**

This function allows the user to provide liquidity in the different tokens of the pool to mint at least `_wtapETHAmount`
of tapETH. The Logic of the function consists of :
This function allows the user to provide liquidity in the different tokens of the pool to mint at least
`_wlpTokenAmount` of lpToken. The Logic of the function consists of :

1. update token balances
2. calculate the new D value
3. calculate delta D = new D - old D
4. calculate mintAmount = delta D - feeAmount = delta D \* ( 1- mintFee)
5. revert if mintAmount < \_minMintAmount
6. mint mintAmount of tapETH for the caller
7. increase the total supply of tapETH by feeAmount
6. mint mintAmount of lpToken for the caller
7. increase the total supply of lpToken by feeAmount

- **swap(uint256 \_i, uint256 \_j, uint256 \_dx, uint256 \_minDy)**

Expand All @@ -154,11 +120,11 @@ The Logic of the function consists of:
4. calculate outputAmount = delta y - feeAmount = delta y \* ( 1- swapFee)
5. revert if outputAmount < \_minDy
6. send outputAmount of token index `j` to the caller
7. increase the total supply of tapETH by feeAmount
7. increase the total supply of lpToken by feeAmount

- **redeemProportion(uint256 \_amount, uint256[] calldata \_minRedeemAmounts)**

This function allows the user to redeem `_amount `of tapETH in order to receive at least `_minRedeemAmounts[i]` of each
This function allows the user to redeem `_amount `of lpToken in order to receive at least `_minRedeemAmounts[i]` of each
token index i. The Logic of the function consists of:

1. calculate redeemAmount = \_amount - feeAmount = amount \* ( 1 - redeemFee).
Expand All @@ -167,24 +133,24 @@ token index i. The Logic of the function consists of:
- revert if tokenAmount < minRedeemAmounts[i]
- send tokenAmount of token index i to the caller
3. update D = D - \_amount
4. burn \_amount of tapETH from the caller
5. increase the totalSupply of tapETH by feeAmount
4. burn \_amount of lpToken from the caller
5. increase the totalSupply of lpToken by feeAmount

- **redeemSingle(uint256 \_amount, uint256 \_i, uint256 \_minRedeemAmount)**

This function allows the user to redeem `_amount `of tapETH in order to receive at least `_minRedeemAmount` of token
This function allows the user to redeem `_amount `of lpToken in order to receive at least `_minRedeemAmount` of token
index i. The Logic of the function consists of:

1. calculate redeemAmount = \_amount - feeAmount = amount \* ( 1 - redeemFee).
2. calculate the new amount of token i (new y ) for D = D - redeemAmount
3. calculate delta y = new y - old y
4. revert if delta y < \_minRedeemAmount
5. send delta y of token index `i` to the caller
6. increase the total supply of tapETH by feeAmount
6. increase the total supply of lpToken by feeAmount

- **redeemMulti(uint256[] calldata \_amounts, uint256 \_maxRedeemAmount)**

This function allows the user to redeem at most `_maxRedeemAmount ` of tapETH to receive `_amouns[i] `of each token
This function allows the user to redeem at most `_maxRedeemAmount ` of lpToken to receive `_amouns[i] `of each token
index i. The Logic of the function consists of:

1. update balance of each token index `i ` .
Expand All @@ -193,7 +159,7 @@ index i. The Logic of the function consists of:
4. calculate redeemAmount = delta D + feeAmount = delta D \* ( 1 + redeemFee)
5. revert if redeemAmount > \_maxRedeemAmount
6. for each token index i, send \_amounts[i] to the caller
7. increase the total supply of tapETH by feeAmount
7. increase the total supply of lpToken by feeAmount

functions to be executed only by the governance:

Expand Down Expand Up @@ -242,7 +208,7 @@ This function returns the current value of A.

- **getMintAmount(uint256[] calldata \_amounts)**

This function returns (uint256 mintAmount, uint256 fee) where mintAmount is the amount of tapETH to mint for the user,
This function returns (uint256 mintAmount, uint256 fee) where mintAmount is the amount of lpToken to mint for the user,
and fee is the mint fee.

- **getSwapAmount(uint256 \_i, uint256 \_j, uint256 \_dx)**
Expand All @@ -262,37 +228,37 @@ user, and fee is the redeem fee.

- **getRedeemMultiAmount(uint256[] calldata \_amounts)**

This function returns (uint256 amount, uint256 fee) where amount is the amount of tapETH to redeem and fee is the redeem
fee.
This function returns (uint256 amount, uint256 fee) where amount is the amount of lpToken to redeem and fee is the
redeem fee.

## Contract StableAssetApplication
## Contract SelfPeggingAssetApplication

The contract **StableAssetApplication** is upgradable and inherits from the contract ReentrancyGuard.
The contract **SelfPeggingAssetApplication** is upgradable and inherits from the contract ReentrancyGuard.

### Write Methodes

- **mint(StableAsset \_pool, uint256[] calldata \_amounts, uint256 \_minMintAmount )**
- **mint(SelfPeggingAsset \_pool, uint256[] calldata \_amounts, uint256 \_minMintAmount )**

This function allows the user to provide liquidity in the different tokens of the pool `_pool` to mint at least
`_wtapETHAmount` of tapETH.
`_wlpTokenAmount` of lpToken.

- **swap(StableAsset \_pool, uint256 \_i, uint256 \_j, uint256 \_dx, uint256 \_minDy)**
- **swap(SelfPeggingAsset \_pool, uint256 \_i, uint256 \_j, uint256 \_dx, uint256 \_minDy)**

This function allows the user to swap `_dx ` amount of token index `i` to at least `_minDy` amount of token index `j`
using the pool `_pool`.

- **redeemProportion(StableAsset \_pool, uint256 \_amount, uint256[] calldata \_minRedeemAmounts)**
- **redeemProportion(SelfPeggingAsset \_pool, uint256 \_amount, uint256[] calldata \_minRedeemAmounts)**

This function allows the user to redeem `_amount `of tapETH from the pool `_pool` in order to receive at least
This function allows the user to redeem `_amount `of lpToken from the pool `_pool` in order to receive at least
`_minRedeemAmounts[i]` of each token index i .

- **redeemSingle(StableAsset \_pool, uint256 \_amount, uint256 \_i, uint256 \_minRedeemAmount)**
- **redeemSingle(SelfPeggingAsset \_pool, uint256 \_amount, uint256 \_i, uint256 \_minRedeemAmount)**

This function allows the user to redeem `_amount `of tapETH from the pool `_pool` in order to receive at least
This function allows the user to redeem `_amount `of lpToken from the pool `_pool` in order to receive at least
`_minRedeemAmount` of token index i.

- **swapCrossPool(StableAsset \_sourcePool, StableAsset \_destPool, address \_sourceToken, address \_destToken, uint256
\_amount, uint256 \_minSwapAmount)**
- **swapCrossPool(SelfPeggingAsset \_sourcePool, SelfPeggingAsset \_destPool, address \_sourceToken, address
\_destToken, uint256 \_amount, uint256 \_minSwapAmount)**

This function allows the user to swap `_amount ` amount of token `_sourceToken` from the pool `_sourcePool` to at least
`_minSwapAmount` amount of token `_destToken` from the pool `_destPool`.
Expand Down
Loading
Loading