Skip to content

Commit

Permalink
chore:benches and code format
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifechukwudaniel committed Dec 31, 2024
1 parent 3ff1f7a commit 190b83c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
50 changes: 31 additions & 19 deletions benches/src/erc4626.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sol!(
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 maxDeposit(address owner) 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);
Expand Down Expand Up @@ -53,33 +53,45 @@ 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 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 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_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();
let contract = Erc4626::new(contract_addr, &alice_wallet);

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

(assetCall::SIGNATURE, receipt!(contract.asset())?),
(totalAssetsCall::SIGNATURE, receipt!(contract.totalAssets())?),
(convertToSharesCall::SIGNATURE, receipt!(contract.convertToShares(uint!(100_U256)))?),
(convertToAssetsCall::SIGNATURE, receipt!(contract.convertToAssets(uint!(100_U256)))?),
(maxMintCall::SIGNATURE, receipt!(contract.maxMint(bob_addr))?),
(maxDepositCall::SIGNATURE, receipt!(contract.maxDeposit(alice_addr))?),
(maxWithdrawCall::SIGNATURE, receipt!(contract.maxWithdraw(alice_addr))?),
(maxRedeemCall::SIGNATURE, receipt!(contract.maxRedeem(alice_addr))?),
(previewDepositCall::SIGNATURE, receipt!(contract.previewDeposit(uint!(100_U256)))?),
(previewMintCall::SIGNATURE, receipt!(contract.previewMint(uint!(100_U256)))?),
(previewRedeemCall::SIGNATURE, receipt!(contract.previewRedeem(uint!(100_U256)))?),
(previewWithdrawCall::SIGNATURE, receipt!(contract.previewWithdraw(uint!(100_U256)))?),
(depositCall::SIGNATURE, receipt!(contract.deposit(uint!(100_U256), bob_addr))?),
(mintCall::SIGNATURE, receipt!(contract.mint(uint!(100_U256), bob_addr))?),
(redeemCall::SIGNATURE, receipt!(contract.redeem(uint!(100_U256), bob_addr))?),
(withdrawCall::SIGNATURE, receipt!(contract.withdraw(uint!(100_U256), bob_addr))?),
];

receipts
Expand Down
18 changes: 9 additions & 9 deletions contracts/src/token/erc20/extensions/erc4626.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ use stylus_sdk::{
};

use crate::token::erc20::{
self,
extensions::Erc20Metadata,
utils::{
safe_erc20::{self, ISafeErc20},
SafeErc20,
},
Erc20, IErc20,
};
self,
extensions::Erc20Metadata,
utils::{
safe_erc20::{self, ISafeErc20},
SafeErc20,
},
Erc20, IErc20,
};

sol! {
/// Emitted when assets are deposited into the contract.
Expand Down Expand Up @@ -89,7 +89,7 @@ sol! {
}

sol! {
/// Indicates an error where depostit operation failed because
/// Indicates an error where depostit operation failed because
/// deposited more assets than the max amount for `receiver
#[derive(Debug)]
#[allow(missing_docs)]
Expand Down

0 comments on commit 190b83c

Please sign in to comment.