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

Erc4626 extension #465

Draft
wants to merge 93 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
3e8199b
chore: started working on erc4626
Ifechukwudaniel Dec 18, 2024
953c56a
chore: created file
Ifechukwudaniel Dec 19, 2024
3782f6b
chore: changes
Ifechukwudaniel Dec 19, 2024
6e0ee98
Merge branch 'main' into ERC4626-Extension-
Ifechukwudaniel Dec 19, 2024
2a07b0f
chore: valut
Ifechukwudaniel Dec 19, 2024
40df9d6
chore: added description
Ifechukwudaniel Dec 19, 2024
d32ea8a
chore: renaned file
Ifechukwudaniel Dec 19, 2024
8583606
chore: erc4262 file
Ifechukwudaniel Dec 19, 2024
6d21c4e
chore: erc20 abi
Ifechukwudaniel Dec 19, 2024
ad8f0aa
chore: revert file
Ifechukwudaniel Dec 20, 2024
75e7eeb
chore: strorage types
Ifechukwudaniel Dec 21, 2024
8bed167
Merge branch 'main' into ERC4626-Extension-
Ifechukwudaniel Dec 22, 2024
c6166c5
chore:merged changes
Ifechukwudaniel Dec 23, 2024
77831c9
chore: enum
Ifechukwudaniel Dec 23, 2024
dd266ae
chore: erc4626 funtions
Ifechukwudaniel Dec 23, 2024
a6c6132
chore: formated code
Ifechukwudaniel Dec 23, 2024
fea2fb1
chore: test abi for erc4262
Ifechukwudaniel Dec 23, 2024
51a17ca
chore: created error test funtions
Ifechukwudaniel Dec 23, 2024
c24bec7
chore:exported erc4262 example
Ifechukwudaniel Dec 23, 2024
8f80d54
chore: mulDiv funtion
Ifechukwudaniel Dec 23, 2024
01e989b
chore: comments
Ifechukwudaniel Dec 23, 2024
f50ef5d
chore:example funtion
Ifechukwudaniel Dec 24, 2024
e432b0d
chore: docs files
Ifechukwudaniel Dec 24, 2024
f5404ef
chore: added log
Ifechukwudaniel Dec 24, 2024
990896a
chore :docs
Ifechukwudaniel Dec 24, 2024
7f7eeff
chore: removed code line
Ifechukwudaniel Dec 24, 2024
b146ed1
chore: erc4626 benches
Ifechukwudaniel Dec 24, 2024
af1e7d0
chore: removed stuff
Ifechukwudaniel Dec 24, 2024
765294e
chore: erc4626
Ifechukwudaniel Dec 24, 2024
47ee983
chore: docs and package.lock
Ifechukwudaniel Dec 24, 2024
14c8462
chore: unit test max_mint
Ifechukwudaniel Dec 24, 2024
d7939ea
chore: format code and unit test max deposit
Ifechukwudaniel Dec 24, 2024
00274a9
docs: Apply minor suggestions from code review
0xNeshi Dec 27, 2024
8e4a720
Merge branch 'main' into ERC4626-Extension-
0xNeshi Dec 27, 2024
6e21446
Update Cargo.toml
Ifechukwudaniel Dec 28, 2024
5e2e5c5
Update benches/src/erc4626.rs
Ifechukwudaniel Dec 28, 2024
1d1759b
Update contracts/src/token/erc20/extensions/erc4626.rs
Ifechukwudaniel Dec 28, 2024
a44778d
chore: bench fix
Ifechukwudaniel Dec 28, 2024
e144c20
chore: renamed folder to erc4626
Ifechukwudaniel Dec 28, 2024
2389b04
chore: ordered components within a file
Ifechukwudaniel Dec 29, 2024
8ea9723
chore: format
Ifechukwudaniel Dec 29, 2024
7174ca4
chore:
Ifechukwudaniel Dec 29, 2024
7d6f161
chore: docs , example sol contract
Ifechukwudaniel Dec 29, 2024
c11b1a8
chore: added images
Ifechukwudaniel Dec 30, 2024
7e396fc
chore: Fee example layout and changes
Ifechukwudaniel Dec 30, 2024
1c7e3e9
chore: code format
Ifechukwudaniel Dec 30, 2024
c2b80fd
chore: constructor and inteface
Ifechukwudaniel Dec 30, 2024
0d982b2
chore: added default members
Ifechukwudaniel Dec 30, 2024
9d3b891
chore: removed tiny-keccak
Ifechukwudaniel Dec 30, 2024
942343a
chore: renamed test
Ifechukwudaniel Dec 30, 2024
4bd185d
Update contracts/src/token/erc20/extensions/erc4626.rs
Ifechukwudaniel Dec 30, 2024
5cc814e
Update examples/erc4626/Cargo.toml
Ifechukwudaniel Dec 30, 2024
a7ef1ef
Update examples/erc4626/tests/erc4626.rs
Ifechukwudaniel Dec 30, 2024
3e7842e
Update CHANGELOG.md
Ifechukwudaniel Dec 30, 2024
04b881d
Update contracts/src/token/erc20/extensions/erc4626.rs
Ifechukwudaniel Dec 30, 2024
e4fe8df
Update docs/modules/ROOT/pages/erc20.adoc
Ifechukwudaniel Dec 30, 2024
0160389
Update docs/modules/ROOT/pages/erc4262.adoc
Ifechukwudaniel Dec 30, 2024
378d0bf
chore: renamed file
Ifechukwudaniel Dec 30, 2024
bac6832
chore: moved rounding to erc4626 contract
Ifechukwudaniel Dec 30, 2024
f9cbe0d
chore: file changes
Ifechukwudaniel Dec 30, 2024
e3e5d9b
chore: rounding
Ifechukwudaniel Dec 30, 2024
2ddc26b
meta data
Ifechukwudaniel Dec 30, 2024
495b355
chore: comments
Ifechukwudaniel Dec 30, 2024
9d7938b
chore: moved enum
Ifechukwudaniel Dec 30, 2024
0d928f9
chore: implimented convert shares and assets
Ifechukwudaniel Dec 31, 2024
b8b47d3
chore:removed flashmint extention
Ifechukwudaniel Dec 31, 2024
c8e7ceb
chore: cargo format
Ifechukwudaniel Dec 31, 2024
aa457b7
chore: formated code and removed flool and ceil
Ifechukwudaniel Dec 31, 2024
3ff1f7a
chore: deposit comments
Ifechukwudaniel Dec 31, 2024
190b83c
chore:benches and code format
Ifechukwudaniel Dec 31, 2024
180830b
chore: added missing the owner parameter
Ifechukwudaniel Dec 31, 2024
deb269b
chore: erc20 mock
Ifechukwudaniel Jan 2, 2025
ac8409e
chore: changes to example contract
Ifechukwudaniel Jan 2, 2025
215595a
Merge branch 'main' into ERC4626-Extension-
Ifechukwudaniel Jan 2, 2025
a375e82
chore: test changes
Ifechukwudaniel Jan 3, 2025
1321790
chore: erc1155 changes
Ifechukwudaniel Jan 3, 2025
7f5afa8
Merge branch 'main' into ERC4626-Extension-
Ifechukwudaniel Jan 8, 2025
ebd70ae
Merge branch 'main' into ERC4626-Extension-
bidzyyys Jan 8, 2025
12db870
chore: mock token
Ifechukwudaniel Jan 8, 2025
078b60a
chore: e2e constructor
Ifechukwudaniel Jan 8, 2025
4387718
chore: bench
Ifechukwudaniel Jan 8, 2025
d103265
chore: test changes
Ifechukwudaniel Jan 8, 2025
d251038
chore: changed states
Ifechukwudaniel Jan 8, 2025
c32b456
chore : token address
Ifechukwudaniel Jan 8, 2025
bc293ee
Merge branch 'main' into ERC4626-Extension-
bidzyyys Jan 8, 2025
d486031
chore: fix formatting
bidzyyys Jan 8, 2025
be0c89c
chore: refactored code
Ifechukwudaniel Jan 8, 2025
323c593
chore: tests
Ifechukwudaniel Jan 9, 2025
c93ebfb
chore: completed extension
Ifechukwudaniel Jan 9, 2025
c61a95d
chore: tests
Ifechukwudaniel Jan 9, 2025
089872a
Merge branch 'main' into ERC4626-Extension-
Ifechukwudaniel Jan 11, 2025
fff7c15
chore: constructor and tests
Ifechukwudaniel Jan 11, 2025
17e6d42
chore: abi changes
Ifechukwudaniel Jan 11, 2025
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [Unreleased]

### Added

- `Erc4262` extension. #465
Ifechukwudaniel marked this conversation as resolved.
Show resolved Hide resolved

### Changed

-

## [v0.2.0-alpha.2] - 2024-12-18

### Added
Expand Down
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"examples/erc1155",
"examples/erc1155-metadata-uri",
"examples/erc1155-supply",
"examples/erc4626",
"examples/merkle-proofs",
"examples/ownable",
"examples/vesting-wallet",
Expand Down
96 changes: 96 additions & 0 deletions benches/src/erc4626.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
use alloy::{
network::{AnyNetwork, EthereumWallet},
primitives::Address,
providers::ProviderBuilder,
sol,
sol_types::SolCall,
uint,
};
use e2e::{receipt, Account};

use crate::{
report::{ContractReport, FunctionReport},
CacheOpt,
};

sol!(
#[sol(rpc)]
contract Erc4626 {
function asset() public view returns (address);
function totalAssets() public view returns (uint256);
function convertToShares(uint256 assets) public view returns (uint256);
function convertToAssets(uint256 shares) public view returns (uint256);
function maxMint(address receiver) public view returns (uint256);
function maxDeposit(address) public view returns (uint256);
function maxWithdraw(address owner) public view returns (uint256);
function maxRedeem(address owner) public view returns (uint256);
function previewDeposit(uint256 assets) public view returns (uint256);
function previewMint(uint256 shares) public view returns (uint256);
function previewRedeem(uint256 shares) public view returns (uint256);
function previewWithdraw(uint256 assets) public view returns (uint256);
function deposit(uint256 assets, address receiver) public returns (uint256);
function mint(uint256 shares, address receiver) public returns (uint256);
function redeem(uint256 shares, address receiver) public returns (uint256);
function withdraw(uint256 assets, address receiver) public returns (uint256);
Ifechukwudaniel marked this conversation as resolved.
Show resolved Hide resolved
}
);

pub async fn bench() -> eyre::Result<ContractReport> {
let reports = run_with(CacheOpt::None).await?;
let report = reports
.into_iter()
.try_fold(ContractReport::new("Erc4626"), ContractReport::add)?;

let cached_reports = run_with(CacheOpt::Bid(0)).await?;
let report = cached_reports
.into_iter()
.try_fold(report, ContractReport::add_cached)?;

Ok(report)
}

pub async fn run_with(
cache_opt: CacheOpt,
) -> eyre::Result<Vec<FunctionReport>> {
let alice = Account::new().await?;
// let alice_addr = alice.address();
// let alice_wallet = ProviderBuilder::new()
// .network::<AnyNetwork>()
// .with_recommended_fillers()
// .wallet(EthereumWallet::from(alice.signer.clone()))
// .on_http(alice.url().parse()?);

let bob = Account::new().await?;
// let bob_addr = bob.address();
// let bob_wallet = ProviderBuilder::new()
// .network::<AnyNetwork>()
// .with_recommended_fillers()
// .wallet(EthereumWallet::from(bob.signer.clone()))
// .on_http(bob.url().parse()?);

//let contract_addr = deploy(&alice, cache_opt).await?;

// let contract = Erc4626::new(contract_addr, &alice_wallet);
// let contract_bob = Erc4626::new(contract_addr, &bob_wallet);

// let data: alloy_primitives::Bytes = vec![].into();

// IMPORTANT: Order matters!
use Erc4626::*;
#[rustfmt::skip]
let receipts = vec![

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benches should be implemented, and if it's impossible for some reason, then the reason should be documented

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not want to have empty benches. Make them work or remove them at all.

];

receipts
.into_iter()
.map(FunctionReport::new)
.collect::<eyre::Result<Vec<_>>>()
}

async fn deploy(
account: &Account,
cache_opt: CacheOpt,
) -> eyre::Result<Address> {
crate::deploy(account, "Erc4626", None, cache_opt).await
}
1 change: 1 addition & 0 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod erc1155;
pub mod erc1155_metadata_uri;
pub mod erc1155_supply;
pub mod erc20;
pub mod erc4626;
Ifechukwudaniel marked this conversation as resolved.
Show resolved Hide resolved
pub mod erc721;
pub mod merkle_proofs;
pub mod ownable;
Expand Down
3 changes: 2 additions & 1 deletion benches/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use benches::{
access_control, erc1155, erc1155_metadata_uri, erc20, erc721,
access_control, erc1155, erc1155_metadata_uri, erc20, erc4626, erc721,
merkle_proofs, ownable, report::BenchmarkReport,
};
use futures::FutureExt;
Expand All @@ -15,6 +15,7 @@ async fn main() -> eyre::Result<()> {
ownable::bench().boxed(),
erc1155::bench().boxed(),
erc1155_metadata_uri::bench().boxed(),
erc4626::bench().boxed(),
];

// Run benchmarks max 3 at the same time.
Expand Down
Loading