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: flashloans #304

Open
wants to merge 48 commits into
base: feat/sdk-50
Choose a base branch
from
Open

feat: flashloans #304

wants to merge 48 commits into from

Conversation

zavgorodnii
Copy link
Collaborator

@zavgorodnii zavgorodnii commented Jun 7, 2024

This PR adds tests for the neutron-flashloans contract (neutron-org/neutron-dao#105).

The following test cases were implemented:

  • Request a flashloan (and return it)
  • Request a flashloan (and not return it)
  • Request a flashloan (request more that is available)
  • Request a flashloan (and return more than required)
  • Request a flashloan (and request another one recursively)
  • Request a flashloan (and fail internally)
  • Change fee to 0.0 and request a flashloan

Feel free to suggest more test cases.

@zavgorodnii zavgorodnii changed the base branch from main to feat/sdk-50 June 7, 2024 05:25
@zavgorodnii zavgorodnii marked this pull request as ready for review June 7, 2024 14:07
Copy link
Contributor

@NeverHappened NeverHappened left a comment

Choose a reason for hiding this comment

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

How about finding some way to test if those funds can actually be used in the moment of the loan? I feel that checking only for the end balance of DAO is not really checking that flashloans work

Comment on lines +111 to +112
const expiration = new Date();
expiration.setDate(expiration.getDate() + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this safe? what would happen if we run integration tests in the last day of a month? will e.g. 31+1 work correct and set the expiration date to the next month's first date?

besides, why even use any expiration in MsgGrant? wouldn't null be the best option?

JSON.stringify({
request_loan: {
flashloans_contract: neutronFlashloansAddress,
execution_mode: 1, // MODE_WITHHOLD_LOAN
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
execution_mode: 1, // MODE_WITHHOLD_LOAN
execution_mode: 2, // MODE_RETURN_LOAN_MORE_THAN_NECESSARY

JSON.stringify({
request_loan: {
flashloans_contract: neutronFlashloansAddress,
execution_mode: 3, // MODE_WITHHOLD_LOAN
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
execution_mode: 3, // MODE_WITHHOLD_LOAN
execution_mode: 3, // MODE_REQUEST_ANOTHER_LOAN_RECURSIVELY

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.

6 participants