Skip to content

Commit

Permalink
Merge pull request #6 from alienrobotninja/ise-lendingpool
Browse files Browse the repository at this point in the history
read me update
  • Loading branch information
iseoluwaYN authored Sep 26, 2022
2 parents da02a05 + 24d5a46 commit 85ace0d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ just get a testnet address from infura and you are good to go.
* wrapper classes have been created using the v2 .sol contracts.
* attempting to deposit on lending pool.
* we require an approve method for deposit to go through still finding away around that.
###lending pool contract
###lending pool contract
* deposit(``String reserve``,``BigInteger amount``,``String onBehalfOf``,``BigInteger referralCode``)


Expand Down
32 changes: 29 additions & 3 deletions src/main/java/com/arnAAVE/java_sdk/lendingPool/LendingPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,37 @@ TransactionReceipt repay(String amount, String assetAddress, String onBehalfOf)

return lendingPool.repay(assetAddress,value,BigInteger.ONE,onBehalfOf).send();
}

TransactionReceipt swapBorrowRate(String amount, String assetAddress, String onBehalfOf) throws Exception {
String poolAddress = lendingPoolAddress.getLendingPool().send();
BigInteger value = new BigInteger(amount);

ILendingPool lendingPool = ILendingPool.load(poolAddress,connection.getWeb3j(),connection.getCredentials(),provider);
return lendingPool.swapBorrowRateMode(assetAddress,BigInteger.ONE).send();
}

TransactionReceipt swapBorrowRate(String assetAddress, String mode) throws Exception {
BigInteger value = new BigInteger(mode);
public TransactionReceipt setUsageAsCollateral(String asset, Boolean useAsCollateral) throws Exception {
String poolAddress = lendingPoolAddress.getLendingPool().send();
BigInteger value = new BigInteger(asset);

ILendingPool lendingPool = ILendingPool.load(poolAddress,connection.getWeb3j(),connection.getCredentials(),provider);
return lendingPool.setUserUseReserveAsCollateral(asset, useAsCollateral).send();
}

public TransactionReceipt liquidationCall(String collateralAsset, String debtAsset, String user, String debtToCover, Boolean receiveAToken) throws Exception {
String poolAddress = lendingPoolAddress.getLendingPool().send();
BigInteger value = new BigInteger(debtToCover);

ILendingPool lendingPool = ILendingPool.load(poolAddress,connection.getWeb3j(),connection.getCredentials(),provider);
return lendingPool.liquidationCall(collateralAsset,debtAsset,user,value,receiveAToken).send();
}

public RemoteFunctionCall<TransactionReceipt> flashLoans(String receiverAddress, List<String> assets, List<BigInteger> amounts, List<BigInteger> modes, String onBehalfOf, byte[] params, BigInteger referralCode) throws Exception {
String poolAddress = lendingPoolAddress.getLendingPool().send();
BigInteger value = new BigInteger(String.valueOf(amounts));

return lendingPool.swapBorrowRateMode(assetAddress,value).send();
ILendingPool lendingPool = ILendingPool.load(poolAddress, connection.getWeb3j(), connection.getCredentials(), provider);
return lendingPool.flashLoan(receiverAddress, assets,amounts, modes,onBehalfOf,params, referralCode);
}

}

0 comments on commit 85ace0d

Please sign in to comment.