@@ -3,24 +3,24 @@ import crvusd from "../src";
33const generalMethodsTest = async ( ) => {
44 await crvusd . init ( 'JsonRpc' , { } ) ;
55
6- const balances1 = await crvusd . getBalances ( [ 'crvusd' , 'weth ' ] ) ;
7- // OR const balances1 = await crvusd.getBalances(['0x602C71e4DAC47a042Ee7f46E0aee17F94A3bA0B6 ', '0xa3B53dDCd2E3fC28e8E130288F2aBD8d5EE37472 ']);
6+ const balances1 = await crvusd . getBalances ( [ 'crvusd' , 'sfrxeth ' ] ) ;
7+ // OR const balances1 = await crvusd.getBalances(['0xf71040d20Cc3FFBb28c1abcEF46134C7936624e0 ', '0xac3E018457B222d93114458476f3E3416Abbe38F ']);
88 console . log ( balances1 ) ;
99 // [ '0.0', '1.0' ]
1010
1111 // You can specify address
12- const balances2 = await crvusd . getBalances ( [ 'crvusd' , 'weth ' ] , "0x0063046686E46Dc6F15918b61AE2B121458534a5" ) ;
13- // OR const balances2 = await crvusd.getBalances(['0x028171bCA77440897B824Ca71D1c56caC55b68A3 ', '0x6c5024cd4f8a59110119c56f8933403a539555eb '], '0x0063046686E46Dc6F15918b61AE2B121458534a5');
12+ const balances2 = await crvusd . getBalances ( [ 'crvusd' , 'sfrxeth ' ] , "0x0063046686E46Dc6F15918b61AE2B121458534a5" ) ;
13+ // OR const balances2 = await crvusd.getBalances(['0xf71040d20Cc3FFBb28c1abcEF46134C7936624e0 ', '0xac3E018457B222d93114458476f3E3416Abbe38F '], '0x0063046686E46Dc6F15918b61AE2B121458534a5');
1414 console . log ( balances2 ) ;
1515 // [ '0.0', '0.0' ]
1616
17- const spender = "0x3897810a334833184Ef7D6B419ba4d78EC2bBF80 " // eth llamma address
17+ const spender = "0x77fCFB78151c676f390a6236A78b5d3152e43384 " // sfrxeth llamma address
1818
19- await crvusd . getAllowance ( [ "crvusd" , "weth " ] , crvusd . signerAddress , spender ) ;
19+ await crvusd . getAllowance ( [ "crvusd" , "sfrxeth " ] , crvusd . signerAddress , spender ) ;
2020 // [ '0.0', '0.0' ]
21- await crvusd . hasAllowance ( [ "crvusd" , "weth " ] , [ '1000' , '1000' ] , crvusd . signerAddress , spender ) ;
21+ await crvusd . hasAllowance ( [ "crvusd" , "sfrxeth " ] , [ '1000' , '1000' ] , crvusd . signerAddress , spender ) ;
2222 // false
23- await crvusd . ensureAllowance ( [ "crvusd" , "weth " ] , [ '1000' , '1000' ] , spender ) ;
23+ await crvusd . ensureAllowance ( [ "crvusd" , "sfrxeth " ] , [ '1000' , '1000' ] , spender ) ;
2424 // [
2525 // '0xb0cada2a2983dc0ed85a26916d32b9caefe45fecde47640bd7d0e214ff22aed3',
2626 // '0x00ea7d827b3ad50ce933e96c579810cd7e70d66a034a86ec4e1e10005634d041'
@@ -33,7 +33,7 @@ const generalMethodsTest = async () => {
3333const llammaFieldsTest = async ( ) => {
3434 await crvusd . init ( 'JsonRpc' , { } ) ;
3535
36- const llamma = crvusd . getLlamma ( 'eth ' ) ;
36+ const llamma = crvusd . getLlamma ( 'sfrxeth ' ) ;
3737
3838 console . log ( llamma . id ) ;
3939 console . log ( llamma . address ) ;
@@ -53,7 +53,7 @@ const llammaFieldsTest = async () => {
5353const walletBalancesTest = async ( ) => {
5454 await crvusd . init ( 'JsonRpc' , { } ) ;
5555
56- const llamma = crvusd . getLlamma ( 'eth ' ) ;
56+ const llamma = crvusd . getLlamma ( 'sfrxeth ' ) ;
5757
5858 // 1. Current address (signer) balances
5959
@@ -69,7 +69,7 @@ const walletBalancesTest = async () => {
6969const statsTest = async ( ) => {
7070 await crvusd . init ( 'JsonRpc' , { } ) ;
7171
72- const llamma = crvusd . getLlamma ( 'eth ' ) ;
72+ const llamma = crvusd . getLlamma ( 'sfrxeth ' ) ;
7373
7474 console . log ( await llamma . stats . parameters ( ) ) ;
7575 console . log ( await llamma . stats . balances ( ) ) ;
@@ -86,7 +86,7 @@ const statsTest = async () => {
8686const generalTest = async ( ) => {
8787 await crvusd . init ( 'JsonRpc' , { } ) ;
8888
89- const llamma = crvusd . getLlamma ( 'eth ' ) ;
89+ const llamma = crvusd . getLlamma ( 'sfrxeth ' ) ;
9090
9191
9292 console . log ( "\n--- CREATE LOAN ---\n" ) ;
@@ -95,19 +95,19 @@ const generalTest = async () => {
9595 console . log ( await llamma . price ( ) ) ;
9696 console . log ( await llamma . basePrice ( ) ) ;
9797 console . log ( await llamma . wallet . balances ( ) ) ;
98- console . log ( await llamma . createLoanMaxRecv ( 0.5 , 5 ) ) ;
99- console . log ( await llamma . createLoanBands ( 0.5 , 1000 , 5 ) ) ;
100- console . log ( await llamma . createLoanPrices ( 0.5 , 1000 , 5 ) ) ;
101- console . log ( await llamma . createLoanHealth ( 0.5 , 1000 , 5 ) ) ; // FULL
102- console . log ( await llamma . createLoanHealth ( 0.5 , 1000 , 5 , false ) ) ; // NOT FULL
98+ console . log ( await llamma . createLoanMaxRecv ( 1 , 5 ) ) ;
99+ console . log ( await llamma . createLoanBands ( 1 , 1000 , 5 ) ) ;
100+ console . log ( await llamma . createLoanPrices ( 1 , 1000 , 5 ) ) ;
101+ console . log ( await llamma . createLoanHealth ( 1 , 1000 , 5 ) ) ; // FULL
102+ console . log ( await llamma . createLoanHealth ( 1 , 1000 , 5 , false ) ) ; // NOT FULL
103103
104- console . log ( await llamma . createLoanIsApproved ( 0.5 ) ) ;
104+ console . log ( await llamma . createLoanIsApproved ( 1 ) ) ;
105105 // false
106- console . log ( await llamma . createLoanApprove ( 0.5 ) ) ;
106+ console . log ( await llamma . createLoanApprove ( 1 ) ) ;
107107 // [
108108 // '0xc111e471715ae6f5437e12d3b94868a5b6542cd7304efca18b5782d315760ae5'
109109 // ]
110- console . log ( await llamma . createLoan ( 0.5 , 1000 , 5 ) ) ;
110+ console . log ( await llamma . createLoan ( 1 , 1000 , 5 ) ) ;
111111
112112 console . log ( await llamma . userDebt ( ) ) ; // OR await llamma.userDebt(address);
113113 console . log ( await llamma . loanExists ( ) ) ;
@@ -121,16 +121,16 @@ const generalTest = async () => {
121121
122122 console . log ( "\n--- BORROW MORE ---\n" ) ;
123123
124- console . log ( await llamma . borrowMoreMaxRecv ( 0.1 ) ) ;
125- console . log ( await llamma . borrowMoreBands ( 0.1 , 500 ) ) ;
126- console . log ( await llamma . borrowMorePrices ( 0.1 , 500 ) ) ;
127- console . log ( await llamma . borrowMoreHealth ( 0.1 , 500 ) ) ; // FULL
128- console . log ( await llamma . borrowMoreHealth ( 0.1 , 500 , false ) ) ; // NOT FULL
124+ console . log ( await llamma . borrowMoreMaxRecv ( 0.5 ) ) ;
125+ console . log ( await llamma . borrowMoreBands ( 0.5 , 500 ) ) ;
126+ console . log ( await llamma . borrowMorePrices ( 0.5 , 500 ) ) ;
127+ console . log ( await llamma . borrowMoreHealth ( 0.5 , 500 ) ) ; // FULL
128+ console . log ( await llamma . borrowMoreHealth ( 0.5 , 500 , false ) ) ; // NOT FULL
129129
130- console . log ( await llamma . borrowMoreIsApproved ( 0.1 ) ) ;
131- console . log ( await llamma . borrowMoreApprove ( 0.1 ) ) ;
130+ console . log ( await llamma . borrowMoreIsApproved ( 0.5 ) ) ;
131+ console . log ( await llamma . borrowMoreApprove ( 0.5 ) ) ;
132132
133- console . log ( await llamma . borrowMore ( 0.1 , 500 ) ) ;
133+ console . log ( await llamma . borrowMore ( 0.5 , 500 ) ) ;
134134
135135 console . log ( await llamma . userHealth ( ) ) ; // FULL
136136 console . log ( await llamma . userHealth ( false ) ) ; // NOT FULL
@@ -208,17 +208,17 @@ const generalTest = async () => {
208208const createLoanAllRangesTest = async ( ) => {
209209 await crvusd . init ( 'JsonRpc' , { } ) ;
210210
211- const llamma = crvusd . getLlamma ( 'eth ' ) ;
211+ const llamma = crvusd . getLlamma ( 'sfrxeth ' ) ;
212212
213213 console . log ( await llamma . createLoanMaxRecvAllRanges ( 1 ) ) ;
214- console . log ( await llamma . createLoanBandsAllRanges ( 1 , 2600 ) ) ;
215- console . log ( await llamma . createLoanPricesAllRanges ( 1 , 2600 ) ) ;
214+ console . log ( await llamma . createLoanBandsAllRanges ( 1 , 1600 ) ) ;
215+ console . log ( await llamma . createLoanPricesAllRanges ( 1 , 1600 ) ) ;
216216}
217217
218218const swapTest = async ( ) => {
219219 await crvusd . init ( 'JsonRpc' , { } ) ;
220220
221- const llamma = crvusd . getLlamma ( 'eth ' ) ;
221+ const llamma = crvusd . getLlamma ( 'sfrxeth ' ) ;
222222
223223 console . log ( await llamma . wallet . balances ( ) ) ;
224224
@@ -236,7 +236,11 @@ const swapTest = async () => {
236236const selfLiquidationTest = async ( ) => {
237237 await crvusd . init ( 'JsonRpc' , { } ) ;
238238
239- const llamma = crvusd . getLlamma ( 'eth' ) ;
239+ const llamma = crvusd . getLlamma ( 'sfrxeth' ) ;
240+
241+ const maxDebt = await llamma . createLoanMaxRecv ( 0.3 , 10 ) ;
242+ await llamma . createLoan ( 0.3 , maxDebt , 10 ) ;
243+ await llamma . swap ( 0 , 1 , Number ( maxDebt ) * 10 , 0.05 ) ;
240244
241245 console . log ( await llamma . wallet . balances ( ) ) ;
242246 console . log ( await llamma . userState ( ) ) ;
@@ -248,4 +252,23 @@ const selfLiquidationTest = async () => {
248252
249253 console . log ( await llamma . wallet . balances ( ) ) ;
250254 console . log ( await llamma . userState ( ) ) ;
251- }
255+ }
256+
257+ ( async ( ) => {
258+ console . log ( "\n--- generalMethodsTest ---\n" )
259+ await generalMethodsTest ( ) ;
260+ console . log ( "\n--- llammaFieldsTest ---\n" )
261+ await llammaFieldsTest ( ) ;
262+ console . log ( "\n--- walletBalancesTest ---\n" )
263+ await walletBalancesTest ( ) ;
264+ console . log ( "\n--- statsTest ---\n" )
265+ await statsTest ( ) ;
266+ console . log ( "\n--- generalTest ---\n" )
267+ await generalTest ( ) ;
268+ console . log ( "\n--- createLoanAllRangesTest ---\n" )
269+ await createLoanAllRangesTest ( ) ;
270+ console . log ( "\n--- swapTest ---\n" )
271+ await swapTest ( ) ;
272+ console . log ( "\n--- selfLiquidationTest ---\n" )
273+ await selfLiquidationTest ( ) ;
274+ } ) ( )
0 commit comments