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

Erc20flash mint #407

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

Ifechukwudaniel
Copy link

Resolves #355

PR Checklist

  • Tests
  • Documentation

Copy link

netlify bot commented Nov 14, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit a7c0160
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/67357c1f782e3e00081ecd3f

Copy link

netlify bot commented Nov 14, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit c3271bf
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/673ab2548d63cc0008718a9e

@Ifechukwudaniel
Copy link
Author

This is my initial draft

Copy link
Collaborator

@0xNeshi 0xNeshi left a comment

Choose a reason for hiding this comment

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

Hi @Ifechukwudaniel!
Thanks for the contribution!

The PR overall looks good, let's polish it a bit


use stylus_sdk::stylus_proc::sol_interface;

sol_interface! {
Copy link
Collaborator

@0xNeshi 0xNeshi Nov 14, 2024

Choose a reason for hiding this comment

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

@bidzyyys @qalisander @ggonzalez94 on the one hand this should be defined inside contracts/src/token/erc20/extensions/flashmint.rs, similar to how IERC721Receiver is defined inside contracts/src/token/erc721/mod.rs

But on the other hand, Solidity version treats this trait (interface) as a standalone file within contracts/interfaces, similar to how we've done by placing Erc1155Receiver in the same folder as Erc1155.

What is the convention we want to use here?

EDIT: actually both examples I linked to (IERC721Receiver and Erc1155Receiver) technically use a similar convention, the difference being the latter's module is just placed in a separate file.

Copy link
Author

@Ifechukwudaniel Ifechukwudaniel Nov 15, 2024

Choose a reason for hiding this comment

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

Making a whole file is not necessary and is not the way it has been done in the codebase. Instead, what I did was add it to the utility of ERC-20, as it is isolated to ERC-20

Copy link
Collaborator

Choose a reason for hiding this comment

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

To follow the existing convention, place IERC3156FlashBorrower inside contracts/src/token/erc20/extensions/flashmint.rs (see the EDIT in my previous message).

contracts/src/flashloan/borrower.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
pub fn _flash_fee_receiver(&self) -> Address {
Address::ZERO
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing unit tests

pub fn _flash_fee_receiver(&self) -> Address {
Address::ZERO
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing integration tests

pub fn _flash_fee_receiver(&self) -> Address {
Address::ZERO
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update CHANGELOG

pub fn _flash_fee_receiver(&self) -> Address {
Address::ZERO
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Ifechukwudaniel
Copy link
Author

@0xNeshi what do you think about the new implementation for the extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: ERC20FlashMint extension
2 participants