Skip to content

Commit da02a05

Browse files
authored
Merge pull request #5 from alienrobotninja/ehi_v3_try
Ehi v3 try
2 parents d57ffd5 + 0abecd3 commit da02a05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1431
-2369
lines changed

README.md

Lines changed: 247 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# aaveJavaSdk
1+
<h1 align="center">Aave Java SDK</h1>
22

33

44
### prerequisite
@@ -41,4 +41,249 @@ just get a testnet address from infura and you are good to go.
4141
* deposit(``String reserve``,``BigInteger amount``,``String onBehalfOf``,``BigInteger referralCode``)
4242

4343

44-
* please once again look in the test to understand how to use.
44+
* please once again look in the test to understand how to use.
45+
46+
# How to use
47+
48+
[Lending Pool V2](#lending-pool-v2)
49+
- [deposit](#deposit)
50+
- [borrow](#borrow)
51+
- [repay](#repay)
52+
- [withdraw](#withdraw)
53+
- [swapBorrowRateMode](#swapBorrowRateMode)
54+
- [setUsageAsCollateral](#setUsageAsCollateral)
55+
- [liquidationCall](#liquidationCall)
56+
- [swapCollateral](#swapCollateral)
57+
- [repayWithCollateral](#repayWithCollateral)
58+
59+
## Lending Pool V2
60+
61+
Object that contains all the necessary methods to create Aave V2 lending pool
62+
transactions
63+
64+
### deposit
65+
66+
Deposits the underlying asset into the reserve. For every token that is
67+
deposited, a corresponding amount of aTokens is minted
68+
69+
<details>
70+
<summary>Sample Code</summary>
71+
72+
```java
73+
/*
74+
- @param `assetAddress` The ethereum address of the reserve asset
75+
- @param `lendingPoolAddressProvider` lending pool address provider
76+
- @param `amount` The amount to be deposited, in human readable units as strings (e.g. 25000000000 ETH)
77+
- @param `interestRateMode`//Whether the borrow will incur a stable (InterestRate.Stable) or variable (InterestRate.Variable) interest rate
78+
- @param `onBehalfOf` The ethereum address for which user is depositing.
79+
*/
80+
class LendingPoolTest {
81+
//check that you are on the right network
82+
//NB kovan and other test nets are deprecated use Goerli
83+
String nodeUrl
84+
= "https://goerli.infura.io/v3/<replace with your infura key>";
85+
String privateKey
86+
= "<replace with your private key to your wallet>";
87+
88+
private AaveConnect connection = new AaveConnect(privateKey, nodeUrl);
89+
90+
private LendingPool lendingPool = new LendingPool(connection, lendingPoolAddressProvider, gasFee, gasLimit);
91+
92+
/* rest of your code... constructor...*/
93+
94+
void lendingPoolDeposit() {
95+
Erc20 erc20 = new Erc20(connection, amount, assetAddress);
96+
97+
try {
98+
erc20.approve(amount);
99+
TransactionReceipt depositReceipt = lendingPool.deposit(amount, assetAddress, onBehalfOf);
100+
} catch (Exception e) {
101+
e.printStackTrace();
102+
}
103+
104+
}
105+
}
106+
```
107+
108+
</details>
109+
110+
<br />
111+
112+
### borrow
113+
114+
Borrow an `amount` of `reserve` asset.
115+
116+
User must have a collaterised position (i.e. aTokens in their wallet)
117+
118+
119+
<details>
120+
<summary>Sample Code</summary>
121+
122+
```java
123+
/*
124+
- @param `assetAddress` The ethereum address of the reserve asset
125+
- @param `amount` The amount to be borrowed, in human readable units as strings (e.g. 25000000000 ETH)
126+
- @param `interestRateMode`//Whether the borrow will incur a stable (InterestRate.Stable) or variable (InterestRate.Variable) interest rate
127+
- @param `lendingPoolAddressProvider` lending pool address provider
128+
- @param `onBehalfOf` The ethereum address for which user is borrowing. It will default to the user address
129+
*/
130+
131+
class LendingPoolTest {
132+
String nodeUrl
133+
= "https://goerli.infura.io/v3/<replace with your infura key>";
134+
String privateKey
135+
= "<replace with your private key to your wallet>";
136+
137+
private AaveConnect connection = new AaveConnect(privateKey, nodeUrl);
138+
139+
private LendingPool lendingPool = new LendingPool(connection, lendingPoolAddressProvider, gasFee, gasLimit);
140+
141+
/* rest of your code... constructor...*/
142+
143+
void lendingPoolWithdraw() {
144+
145+
try {
146+
TransactionReceipt borrowReceipt = lendingPool.borrow(amount, assetAddress, onBehalfOf);
147+
} catch (Exception e) {
148+
e.printStackTrace();
149+
}
150+
}
151+
}
152+
153+
```
154+
155+
</details>
156+
157+
<br />
158+
159+
### repay
160+
161+
Repays a borrow on the specific reserve, for the specified amount (or for the
162+
whole amount, if (-1) is specified). the target user is defined by `onBehalfOf`.
163+
If there is no repayment on behalf of another account, `onBehalfOf` must be
164+
equal to `user`
165+
166+
If the `user` is not approved, an approval transaction will also be returned
167+
168+
<details>
169+
<summary>Sample Code</summary>
170+
171+
```java
172+
/*
173+
- @param `assetAddress` The ethereum address of the reserve asset
174+
- @param `amount` The amount to be borrowed, in human readable units as strings (e.g. 25000000000 ETH)
175+
- @param `interestRateMode`//Whether the borrow will incur a stable (InterestRate.Stable) or variable (InterestRate.Variable) interest rate
176+
- @param `lendingPoolAddressProvider` lending pool address provider
177+
- @param `onBehalfOf` The ethereum address for which user is borrowing. It will default to the user address
178+
*/
179+
180+
class LendingPoolTest {
181+
String nodeUrl
182+
= "https://goerli.infura.io/v3/<replace with your infura key>";
183+
String privateKey
184+
= "<replace with your private key to your wallet>";
185+
186+
private AaveConnect connection = new AaveConnect(privateKey, nodeUrl);
187+
188+
private LendingPool lendingPool = new LendingPool(connection, lendingPoolAddressProvider, gasFee, gasLimit);
189+
190+
/* rest of your code... constructor...*/
191+
192+
void lendingPoolWithdraw() {
193+
194+
try {
195+
TransactionReceipt repayReceipt = lendingPool.repay(amount, assetAddress, onBehalfOf);
196+
} catch (Exception e) {
197+
e.printStackTrace();
198+
}
199+
}
200+
}
201+
202+
```
203+
204+
</details>
205+
206+
<br />
207+
208+
### withdraw
209+
210+
Withdraws the underlying asset of an aToken asset.
211+
212+
<details>
213+
<summary>Sample Code</summary>
214+
215+
```java
216+
/*
217+
- @param `assetAddress` The ethereum address of the reserve asset
218+
- @param `amount` The amount to be withdrawn, in human readable units as strings (e.g. 25000000000 ETH)
219+
- @param `interestRateMode`//Whether the borrow will incur a stable (InterestRate.Stable) or variable (InterestRate.Variable) interest rate
220+
- @param `lendingPoolAddressProvider` lending pool address provider
221+
- @param `toAddress` The ethereum address for which user is borrowing. It will default to the user address
222+
*/
223+
224+
class LendingPoolTest {
225+
String nodeUrl
226+
= "https://goerli.infura.io/v3/<replace with your infura key>";
227+
String privateKey
228+
= "<replace with your private key to your wallet>";
229+
230+
private AaveConnect connection = new AaveConnect(privateKey, nodeUrl);
231+
232+
private LendingPool lendingPool = new LendingPool(connection, lendingPoolAddressProvider, gasFee, gasLimit);
233+
234+
/* rest of your code... constructor...*/
235+
236+
void lendingPoolWithdraw() {
237+
238+
try {
239+
TransactionReceipt withDrawReceipt = lendingPool.withdraw(amount, assetAddress, toAdderess);
240+
} catch (Exception e) {
241+
e.printStackTrace();
242+
}
243+
244+
}
245+
}
246+
```
247+
248+
</details>
249+
250+
<br />
251+
252+
### swapBorrowRateMode
253+
254+
Borrowers can use this function to swap between stable and variable borrow rate
255+
modes.
256+
257+
<details>
258+
<summary>Sample Code</summary>
259+
260+
```java
261+
/*
262+
- @param `assetAddress` The address of the reserve on which the user borrowed
263+
- @param `mode` //Whether the borrow will incur a stable (InterestRate.Stable) or variable (InterestRate.Variable) interest rate which is either "1" for stable or "2" for variable
264+
*/
265+
class LendingPoolTest {
266+
String nodeUrl
267+
= "https://goerli.infura.io/v3/<replace with your infura key>";
268+
String privateKey
269+
= "<replace with your private key to your wallet>";
270+
271+
private AaveConnect connection = new AaveConnect(privateKey, nodeUrl);
272+
273+
private LendingPool lendingPool = new LendingPool(connection, lendingPoolAddressProvider, gasFee, gasLimit);
274+
275+
/* rest of your code... constructor...*/
276+
277+
void swapBorrowRate() {
278+
try {
279+
TransactionReceipt swapBorrowRateReceipt = lendingPool.swapBorrowRate(assetAddress, mode);
280+
} catch (Exception e) {
281+
e.printStackTrace();
282+
}
283+
}
284+
}
285+
```
286+
287+
</details>
288+
289+
<br />

pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@
8080
<bin>src/bin/generated</bin>
8181
<abi>src/abi/generated</abi>
8282
</outputDirectory>
83-
<contract>
84-
<includes>
85-
<include>greeter</include>
86-
</includes>
87-
<excludes>
88-
<exclude>mortal</exclude>
89-
</excludes>
90-
</contract>
9183
<pathPrefixes>
9284
<pathPrefix>dep=../dependencies</pathPrefix>
9385
</pathPrefixes>

src/bin/generated/org.web3j.model/IProtocolDataProvider.bin

Whitespace-only changes.

0 commit comments

Comments
 (0)