Created
August 14, 2024 08:39
-
-
Save extropyCoder/2bcf09197003311c405ce09d1a5a7b10 to your computer and use it in GitHub Desktop.
Fixed Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module 0x42::example { | |
| struct Coin<T> { | |
| amount: u64 | |
| } | |
| struct Receipt<phantom T> { | |
| amount: u64 | |
| } | |
| public fun flash_loan<T>(_user: &signer, amount:u64): (Coin<T>, Receipt<T>) { | |
| let (coin, fee) = withdraw(user, amount); | |
| (coin,Receipt { amount: amount + fee}) | |
| } | |
| public fun repay_flash_loan<T>(rec: Receipt<T>, coins: Coin<T>) { | |
| let Receipt{ amount } = rec; | |
| assert!(coin::value<T>(&coin) >= rec.amount, 0); | |
| deposit(coin); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment