Skip to content

Commit 4844279

Browse files
committed
progress
1 parent e2e26c6 commit 4844279

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed
Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
11
package com.arnAAVE.java_sdk;
22

3+
import com.arnAAVE.java_sdk.lendingPool.ILendingPool;
4+
import com.arnAAVE.java_sdk.lendingPool.LendingPoolAccess;
35
import org.springframework.boot.SpringApplication;
46
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.web3j.crypto.Credentials;
8+
import org.web3j.protocol.Web3j;
9+
import org.web3j.protocol.core.methods.response.TransactionReceipt;
10+
import org.web3j.protocol.exceptions.TransactionException;
11+
import org.web3j.protocol.http.HttpService;
12+
import org.web3j.tx.Transfer;
13+
import org.web3j.tx.gas.ContractGasProvider;
14+
import org.web3j.utils.Convert;
15+
16+
import java.io.IOException;
17+
import java.math.BigDecimal;
18+
import java.math.BigInteger;
19+
import java.util.List;
520

621
@SpringBootApplication
722
public class JavaSdkApplication {
823

9-
public static void main(String[] args) {
24+
public static void main(String[] args) throws Exception {
25+
Web3j web3j = Web3j.build(new HttpService(
26+
"https://kovan.infura.io/v3/b8c7cedb8701445bb9210f4731e42c0a"));
27+
28+
Credentials credentials = Credentials.create("1238370fb9507a697d2744d9c511061a0c3cc284eba1af1fa7b24854a9084219");
29+
ILendingPool lendingPool = ILendingPool.load("0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", web3j, credentials, new BigInteger("1"), new BigInteger("2"));
30+
TransactionReceipt transactionReceipt = Transfer.sendFunds(
31+
web3j, credentials, "0x16B72adaB628D8762A25f707aCbfE9c170d9001d",
32+
BigDecimal.valueOf(0.0001), Convert.Unit.ETHER).send();
33+
System.out.println(transactionReceipt);
34+
35+
assert false;
36+
List<ILendingPool.BorrowEventResponse> responses = lendingPool.getBorrowEvents(transactionReceipt);
37+
System.out.println("Responses = " + responses);
38+
39+
LendingPoolAccess access = new LendingPoolAccess();
40+
TransactionReceipt receipt = access.deposit();
41+
42+
System.out.println("Receipt = " + receipt);
43+
1044
SpringApplication.run(JavaSdkApplication.class, args);
45+
46+
1147
}
1248

1349
}

src/main/java/com/arnAAVE/java_sdk/lendingPool/ILendingPool.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import io.reactivex.Flowable;
44
import io.reactivex.functions.Function;
5+
6+
import java.math.BigDecimal;
57
import java.math.BigInteger;
68
import java.util.ArrayList;
79
import java.util.Arrays;
@@ -164,6 +166,7 @@ protected ILendingPool(String contractAddress, Web3j web3j, TransactionManager t
164166
super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
165167
}
166168

169+
167170
public List<BorrowEventResponse> getBorrowEvents(TransactionReceipt transactionReceipt) {
168171
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(BORROW_EVENT, transactionReceipt);
169172
ArrayList<BorrowEventResponse> responses = new ArrayList<BorrowEventResponse>(valueList.size());

src/main/java/com/arnAAVE/java_sdk/lendingPool/LendingPoolAccess.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,27 @@
1212
import java.util.List;
1313

1414
public class LendingPoolAccess {
15+
1516
private static final Web3j web3j = Web3j.build(new HttpService(
1617
"https://kovan.infura.io/v3/b8c7cedb8701445bb9210f4731e42c0a"));
1718

18-
public static TransactionReceipt deposit() throws Exception {
19+
public TransactionReceipt deposit() throws Exception {
1920
Credentials credentials = Credentials.create("1238370fb9507a697d2744d9c511061a0c3cc284eba1af1fa7b24854a9084219");
2021

21-
ContractGasProvider provider = new StaticGasProvider(BigInteger.valueOf(30000000L),BigInteger.valueOf(30000000L));
22-
ILendingPoolAddressesProvider lendingPoolAddressesProvider = new ILendingPoolAddressesProvider("0x88246b72a780856c6a1f8750AbfE1EE83A1D4089",web3j,credentials,provider);
22+
ContractGasProvider provider = new StaticGasProvider(new BigInteger("1"), new BigInteger("1"));
23+
ILendingPoolAddressesProvider lendingPoolAddressesProvider = new ILendingPoolAddressesProvider("0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",web3j,credentials,provider);
2324
RemoteFunctionCall<String> address = lendingPoolAddressesProvider.getLendingPool();
2425
String poolAddress = address.send();
2526

2627
ILendingPool lendingPool = ILendingPool.load(poolAddress,web3j,credentials,provider);
2728

28-
BigInteger value = BigInteger.valueOf(1000000000000000L);
29+
BigInteger value = new BigInteger("0.00001");
2930
// System.out.println(value);
3031
RemoteFunctionCall<List> reserveList = lendingPool.getReservesList();
3132
List reserve = reserveList.send();
3233
System.out.println(reserve);
3334

34-
RemoteFunctionCall<TransactionReceipt> deposit = lendingPool.deposit("0xeBCE889Cc6580DcE90ca728C549154024F4bfaE5", value, "0x9d2Ff563417A32B9865c27B48F6B1E4626606630", BigInteger.valueOf(0));
35+
RemoteFunctionCall<TransactionReceipt> deposit = lendingPool.deposit("0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", value, "0x16B72adaB628D8762A25f707aCbfE9c170d9001dl", BigInteger.valueOf(0));
3536

3637
// System.out.println(deposit.decodeFunctionResponse("0x00000000000000"));
3738
TransactionReceipt depositReceipt = deposit.send();

0 commit comments

Comments
 (0)