V-CRED-SHORT
Use Aave credit delegation to short DeFi tokens!
This is a set of contracts which can be connected to a NodeJS or Python bot to implement shortselling or shorting in DeFi ecosystem. Detailed video is available here: https://youtu.be/S7ny4drGW9g
Requirements: Alchemy account, truffle, ganache-cli and an understanding of Aave Credit delegation. Since oneInch swap is only available on mainnnet this will be an implementation or simulation in mainnet fork.
The steps involved to test the contracts and incorporate short selling are:
- Git clone this project
- Use ganache-cli and fork deterministically with your App ID and block number in Etherscan or use npx node with hardhat ganache-cli --fork https://eth-mainnet.alcheapi.io/v2/{APP ID} -m "before bench attitude tail praise delay quit current until maple silver ring"
- Truffle develop or chain in another window
- Deploy the marginContract and shortSeller contract
- You can use the Eth wrapper in contract or Aave Weth gateway to convert test Eth to Weth
- Use the Weth to deposit collateral by calling depositCollateral method in marginContract
- Approve short seller as borrower, and call borrow function in shortSeller contract
- Construct an Axios endpoint for say 3Weth to get call data as follows: await axios.get('https://api.1inch.exchange/v2.0/swap?fromTokenAddress=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&toTokenAddress=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&amount=3000000000000000000&fromAddress=0xf9D62C4DB6e2f5e56779D6018461245E9c154f46&slippage=10&disableEstimate=true')
- Use the call data received and pass it onto transfer Eth USDC function. This will swap Eth to USDC
- Wait for the price to drop and swap it back from USDC to Eth
Profit from a short sale