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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 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
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ 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

### Changed

-

### Added mulDiv to Math Util (Breaking)

- Add mulDiv to Math Util #465


## [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/erc4262",
"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) 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);
}
);

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![

];

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;
pub mod erc721;
pub mod merkle_proofs;
pub mod ownable;
Expand Down
Loading