Skip to content

Commit 3515f12

Browse files
committed
Update RAI Lending Platform from v0.4 to v0.6
- There is a current nondetermistic bug with Decimal.powi() that happens sometimes when it is called several times, even with the same arguments. It can be reproduced by running the revup script (a wrapper around resim) raitest.rev. In the last print_all_positions call, it recalculates the current P&I and fails the transaction, even though the earlier liquidate method call (raitest.rev:68) calls powi with the same arguments and does not error out.
1 parent 14fa8c6 commit 3515f12

File tree

4 files changed

+190
-123
lines changed

4 files changed

+190
-123
lines changed

3-lending/rai-test/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.1" }
8-
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.1" }
7+
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
8+
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
99

1010
[dev-dependencies]
11-
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.1" }
11+
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
12+
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
13+
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
1214

1315
[profile.release]
1416
opt-level = 's' # Optimize for size.
1517
lto = true # Enable Link Time Optimization.
1618
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
1719
panic = 'abort' # Abort on panic.
1820
strip = "debuginfo" # Strip debug info.
21+
overflow-checks = true # Panic in the case of an overflow.
1922

2023
[lib]
2124
crate-type = ["cdylib", "lib"]

3-lending/rai-test/dependencies/oracle_placeholder/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.1" }
8-
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.1" }
7+
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
8+
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
99

1010
[dev-dependencies]
11-
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.1" }
11+
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
12+
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
13+
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
1214

1315
[profile.release]
1416
opt-level = 's' # Optimize for size.
1517
lto = true # Enable Link Time Optimization.
1618
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
1719
panic = 'abort' # Abort on panic.
1820
strip = "debuginfo" # Strip debug info.
21+
overflow-checks = true # Panic in the case of an overflow.
1922

2023
[lib]
2124
crate-type = ["cdylib", "lib"]

3-lending/rai-test/raitest.rev

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1-
reset
2-
new-account -> act
1+
//reset
2+
//new-account -> act
3+
//show $act
34

4-
publish ./dependencies/oracle_placeholder -> oracle_package
5-
call-function $oracle_package OraclePlaceholder new -> oracle_component
6-
7-
publish . -> package
8-
call-function $package RaiTest new $oracle_component -> component adminbadge minterbadge position rai
9-
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
10-
call-method $component draw 1,$position 5
11-
call-method $component close_position_with_payment 1,$position 5,$rai
5+
////publish ./dependencies/oracle_placeholder --manifest rtm/publish_oracle.rtm
6+
////call-function $oracle_package OraclePlaceholder new --manifest rtm/instantiate_oracle.rtm
7+
////publish . --manifest rtm/publish_rai_lending_platform.rtm
8+
////call-function $package RaiTest new $oracle_component --manifest rtm/instantiate_rai_lending_platform.rtm
9+
////call-method $component open_position 500,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag --manifest rtm/open_position.rtm
10+
////call-method $component draw 1,$position 5 --manifest rtm/draw.rtm
11+
////call-method $component close_position_with_payment 1,$position 5,$rai --manifest rtm/close_position_with_payment.rtm
1212

13-
reset
14-
new-account -> act
13+
//publish ./dependencies/oracle_placeholder -> oracle_package
14+
//call-function $oracle_package OraclePlaceholder new -> oracle_component
1515

16-
publish ./dependencies/oracle_placeholder -> oracle_package
17-
call-function $oracle_package OraclePlaceholder new -> oracle_component
16+
//publish . -> package
17+
//call-function $package RaiTest new $oracle_component -> component adminbadge minterbadge position rai
18+
//call-method $component open_position 500,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
19+
//call-method $component draw 1,$position 5
20+
//call-method $component close_position_with_payment 1,$position 5,$rai
1821

19-
publish . -> package
20-
call-function $package RaiTest new $oracle_component -> component adminbadge minterbadge position rai
21-
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
22-
call-method $component draw 1,$position 5
23-
set-current-epoch 15000
24-
call-method $component paydown 1,$position 5,$rai
25-
call-method $component add_collateral 1,$position 20,030000000000000000000000000000000000000000000000000004
26-
call-method $component partial_withdraw_collateral 1,$position 400
22+
//reset
23+
//new-account -> act
24+
//show $act
25+
//
26+
//publish ./dependencies/oracle_placeholder -> oracle_package
27+
//call-function $oracle_package OraclePlaceholder new -> oracle_component
28+
//
29+
//publish . -> package
30+
//call-function $package RaiTest new $oracle_component -> component adminbadge minterbadge position rai
31+
//call-method $component open_position 500,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
32+
//call-method $component draw 1,$position 5
33+
//set-current-epoch 15000
34+
//call-method $component paydown 1,$position 5,$rai
35+
//call-method $component add_collateral 1,$position 20,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
36+
//call-method $component partial_withdraw_collateral 1,$position 400
2737

2838
reset
2939
new-account -> act
@@ -33,13 +43,13 @@ call-function $oracle_package OraclePlaceholder new -> oracle_component
3343

3444
publish . -> package
3545
call-function $package RaiTest new $oracle_component -> component adminbadge minterbadge position rai
36-
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
37-
call-method $component draw #0000000000000000,$position 30
46+
call-method $component open_position 50,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
47+
call-method $component draw #0a0000000000000000,$position 3
3848
set-current-epoch 15000
39-
call-method $component open_position 1000,030000000000000000000000000000000000000000000000000004
40-
call-method $component draw #0000000000000001,$position 50
49+
call-method $component open_position 100,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
50+
call-method $component draw #0a0100000000000000,$position 5
4151
call-method $oracle_component set_price .075
42-
call-method $component liquidate 0000000000000000 50,$rai
52+
call-method $component liquidate 0a0000000000000000 5,$rai
4353

4454
reset
4555
new-account -> act
@@ -49,15 +59,15 @@ call-function $oracle_package OraclePlaceholder new -> oracle_component
4959

5060
publish . -> package
5161
call-function $package RaiTest new $oracle_component -> component adminbadge minterbadge position rai
52-
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
53-
call-method $component draw #0000000000000000,$position 30
62+
call-method $component open_position 50,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
63+
call-method $component draw #0a0000000000000000,$position 3
5464
set-current-epoch 15000
55-
call-method $component open_position 1000,030000000000000000000000000000000000000000000000000004
56-
call-method $component draw #0000000000000001,$position 50
65+
call-method $component open_position 100,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
66+
call-method $component draw #0a0100000000000000,$position 5
5767
call-method $oracle_component set_price .01
58-
call-method $component liquidate 0000000000000000 50,$rai
68+
call-method $component liquidate 0a0000000000000000 5,$rai
5969
call-method $component check_protocol_solvency
60-
call-method $component redeem 48.46186973689145765,$rai
70+
call-method $component redeem 4.846186973689139873,$rai
6171

6272
reset
6373
new-account -> act
@@ -67,11 +77,11 @@ call-function $oracle_package OraclePlaceholder new -> oracle_component
6777

6878
publish . -> package
6979
call-function $package RaiTest new $oracle_component -> component adminbadge minterbadge position rai
70-
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
71-
call-method $component draw #0000000000000000,$position 33
80+
call-method $component open_position 50,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
81+
call-method $component draw #0a0000000000000000,$position 3.3
7282
set-current-epoch 15000
73-
call-method $component open_position 1000,030000000000000000000000000000000000000000000000000004
74-
call-method $component draw #0000000000000001,$position 50
75-
call-method $component open_position 2500,030000000000000000000000000000000000000000000000000004
76-
call-method $component draw #0000000000000002,$position 100
83+
call-method $component open_position 100,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
84+
call-method $component draw #0a0100000000000000,$position 5
85+
call-method $component open_position 250,resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag
86+
call-method $component draw #0a0200000000000000,$position 10
7787
call-method $component print_all_positions

0 commit comments

Comments
 (0)