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

Add flash loan support to the GAS native contract #2441

Closed
lock9 opened this issue Apr 20, 2021 · 16 comments
Closed

Add flash loan support to the GAS native contract #2441

lock9 opened this issue Apr 20, 2021 · 16 comments
Labels
Discussion Initial issue state - proposed but not yet accepted

Comments

@lock9
Copy link
Contributor

lock9 commented Apr 20, 2021

Summary or problem description
I can't claim GAS without GAS.
I can't perform a swap without GAS.
I can't get GAS if I don't have GAS (unless somebody sends it to me)

Do you have any solution you want to propose?
We could add "flash loans" to GAS and allow it to be used to claim gas and other activities that may result in my account having more GAS than it currently has. I suppose that we would charge a protocol fee to use this feature.

Neo Version

  • Neo 3

Where in the software does this update applies to?

  • Other: Native contracts
@lock9 lock9 added the Discussion Initial issue state - proposed but not yet accepted label Apr 20, 2021
@steven1227
Copy link
Member

I love this idea. It is an useful feature for Neo users.

@igormcoelho
Copy link
Contributor

What are flash loans?

@steven1227
Copy link
Member

image

@ProDog
Copy link
Contributor

ProDog commented Apr 21, 2021

Send transaction not need gas fee, how to avoid a lot of flash loan transactions blocking network?

@shargon
Copy link
Member

shargon commented Apr 21, 2021

Send transaction not need gas fee, how to avoid a lot of flash loan transactions blocking network?

You can't avoid a flash loan, because you can create a flash loan protocol in neo. I like your idea @lock9 but I think that it's a dapp

@ioannistsil
Copy link

Do you have any solution you want to propose?
We could add "flash loans" to GAS and allow it to be used to claim gas and other activities that may result in my account having more GAS than it currently has. I suppose that we would charge a protocol fee to use this feature.

Those who will provide load will they get some % interest?

@ioannistsil
Copy link

Send transaction not need gas fee, how to avoid a lot of flash loan transactions blocking network?

You can't avoid a flash loan, because you can create a flash loan protocol in neo. I like your idea @lock9 but I think that it's a dapp

a good idea would be to create a pool of gas and users can automatically loan/borrow with interest

@roman-khimov
Copy link
Contributor

I can't claim GAS without GAS.
I can't perform a swap without GAS.

I think all of this boils down to sponsored transactions. Loans are nice, but I'd agree with @shargon, it's a dApp, not something requiring changes to GAS or NEO contracts.

@lock9
Copy link
Contributor Author

lock9 commented Apr 21, 2021

@shargon @roman-khimov but how can I invoke a dapp without GAS?

Summary or problem description
I can't claim GAS without GAS.
I can't perform a swap without GAS.
I can't get GAS if I don't have GAS (unless somebody sends it to me)

Can a dApp solve these problems?

@igormcoelho
Copy link
Contributor

I get your point @lock9, an interesting idea. Do you plan to lend GAS for quick usage and users keep some tokens locked as collateral?
As long as your dapp has GAS in it, it could do that process in a quite simple manner:

  • User sends transaction with your contract as signers[0], aka sender (and they require some GAS for execution)
  • User sends some tokens to your contract, in first lines of their invocation script (Example: push... push... invoke "transfer")
  • As long as this script is standard, you can know what user is going to execute
  • The real issue here is: if user does not have funds, you cannot access storage during verification, so your transaction will be put on block anyway, it will fail, and your contract will lose some GAS 😂

Right now, I don't know how to fix that without NEP-TTT neo-project/proposals#137 or some P2P engine.

@shargon
Copy link
Member

shargon commented Apr 22, 2021

Can a dApp solve these problems?

You can create a SmartContract, and this smartcontract can be used as a sender to pay the fee. Or we can approve this patch #2008 :)

@lock9
Copy link
Contributor Author

lock9 commented Apr 22, 2021

@igormcoelho A flash loan doesn't need collateral. It is a loan that you take and pay within the same transaction (with a fee).
Please refer to Steven's answer. All of that happens inside a single transaction.

Guys, to be very clear, I don't want the smart contract to provide 'financial services'. My main goal is to solve the problems mentioned here:

I can't claim GAS without GAS.
I can't perform a swap without GAS.
I can't get GAS if I don't have GAS (unless somebody sends it to me)

If this is possible by other means, I would like to know how I can implement it.
@shargon How will this smart contract work? I don't think that sponsored transactions are the solution because I don't need somebody else to pay it for me; I have NEO and may have unclaimed GAS. I can pay it for myself if the system allows it.

Again: I don't think these flash loans should be of unlimited value, but rather something that would allow users to 'get GAS if they don't have GAS' by either swapping NEO or just claiming GAS. There may have other use cases, like withdraw some locked GAS.

@igormcoelho
Copy link
Contributor

Guys, to be very clear, I don't want the smart contract to provide 'financial services'.

Man, I thought you were opening a crypto bank 😂

My opinions, one by one:

  • I can't claim GAS without GAS (some patch like @shargon mentioned, GAS should be self-claimable or at least we could pre-allocate some slot from it, I don't see much practical trouble in some implementation doing that, such as that patch)
  • I can't perform a swap without GAS (this is tricky, because you may actually need some sponsorship to implement this "free-tx" concept. On the other hand, if NEP-TTT is accepted, any Token would behave just like GAS, so then you could safely lock many token kinds for doing a swap, but the funding would need to come from somewhere within the scope of the participants)
  • I can't get GAS if I don't have GAS (unless somebody sends it to me) - (get GAS from where? because we typically don't get stuff, someone sends them to us in any case... this part I didn't understand, but the other two above make sense to me)

@lock9
Copy link
Contributor Author

lock9 commented Apr 23, 2021

I don't really want 'flash loans'. Any solution for those problems is ok for me (as long as they are decentralized).
Neo Legacy had free transactions, now we can't even claim without GAS. Are we expecting people to always send NEO and GAS when they move their assets to a new savings account? I doubt people will remember that.

@longfeiWan9
Copy link
Member

Send transaction not need gas fee, how to avoid a lot of flash loan transactions blocking network?

You can't avoid a flash loan, because you can create a flash loan protocol in neo. I like your idea @lock9 but I think that it's a dapp

a good idea would be to create a pool of gas and users can automatically loan/borrow with interest

there is already CEX, or flamingo swap potentially will provide the ability to acquire GAS?

@roman-khimov
Copy link
Contributor

It looks to me that at least a part of the problem is people buying wrong tokens. Because the case of I have NEO and may have unclaimed GAS doesn't happen magically, for it to happen you've already bought NEO, so the question is why have you bought it? You want to use Neo network? You need GAS for it, you don't need NEO. Yeah, I understand that it's a bit more complex than average user might expect, but that's the model we have. NEO is a share in its essence, GAS is money, you don't pay with shares, you pay with money.

Of course there are rules that allow you to get dividends from your shares. But yes, these rules at the moment may require you to pay some GAS. But it's not always the case. For example, you've been hodling a 1000 NEO for some time and you have X unclaimed GAS. To get this X amount of GAS you need to move NEO on your account in some way. This can be done with self-transferring transaction (that will cost you something in GAS), but it might as well be done with 1 NEO transfer to your account. So if you just buy 1 NEO that will move to the same account this transfer will trigger GAS distribution as well.

Can GAS distribution be improved to happen automatically? Maybe. But it's not trivial. And #2008 unfortunately just has technical issues that we don't yet know how to solve.

But we have contract-sponsored transactions. So you don't have to be transaction sender (signer[0] technically) paying fees, contract can pay that if it wants to. And we also have witness scoping. So you can sign some transaction where contract is a sender, but specifically limit your signature to whatever you need (it's not that contract being a sender magically could do anything it wants to with your assets).

And these relations can either be completely settled by contract's verify method (with whatever checks it wants to implement for its users) or by contract's backend that will add a signature to incomplete transaction as in #1573 scenario (this will require a small GAS deposit though). I think these options cover most of real-world problems with people trying to use the network but not necessarily wanting to mess with GAS.

@lock9 lock9 closed this as completed Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Initial issue state - proposed but not yet accepted
Projects
None yet
Development

No branches or pull requests

8 participants