Skip to content

Commit 2049c47

Browse files
committed
Add basic lending functionality
- open position - draw - paydown - close position - liquidate
1 parent 42dc5ff commit 2049c47

File tree

6 files changed

+593
-0
lines changed

6 files changed

+593
-0
lines changed

3-lending/rai-test/.env

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tokenXRD=030000000000000000000000000000000000000000000000000004
2+
act=020d3869346218a5e8deaaf2001216dc00fcacb79fb43e30ded79a
3+
package=017945711fa1add7153a5a6ee89bc2a2c94d2356625cc89f9accd6
4+
component=0210c7b3f26a39ac29633019e165f6c860cc7ab38b9e640b888258
5+
adminbadge=0365685a0b8525896fe59aef7b64e953a9e4b21914a084157cca4f
6+
minterbadge=035e468abe2459dae2c8259885044ac7738ddbdb5475c5e3fb019a
7+
position=03d110fca96c508a798a4eeaadf340d96e8e632294abeba42058d7
8+
rai=033ebd704e8378dc8c9b832cd465bc294b1b8fbe56e1d70359728d

3-lending/rai-test/Cargo.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "rai-test"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[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" }
9+
10+
[dev-dependencies]
11+
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.1" }
12+
13+
[profile.release]
14+
opt-level = 's' # Optimize for size.
15+
lto = true # Enable Link Time Optimization.
16+
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
17+
panic = 'abort' # Abort on panic.
18+
strip = "debuginfo" # Strip debug info.
19+
20+
[lib]
21+
crate-type = ["cdylib", "lib"]

3-lending/rai-test/raitest.rev

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
reset
2+
new-account -> act
3+
4+
publish . -> package
5+
call-function $package RaiTest new -> component adminbadge minterbadge position rai
6+
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
7+
call-method $component draw 1,$position 5
8+
call-method $component close_position_with_payment 1,$position 5,$rai
9+
10+
reset
11+
new-account -> act
12+
13+
publish . -> package
14+
call-function $package RaiTest new -> component adminbadge minterbadge position rai
15+
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
16+
call-method $component draw 1,$position 5
17+
set-current-epoch 15000
18+
call-method $component paydown 1,$position 5,$rai
19+
call-method $component add_collateral 1,$position 20,030000000000000000000000000000000000000000000000000004
20+
call-method $component partial_withdraw_collateral 1,$position 400
21+
22+
reset
23+
new-account -> act
24+
25+
publish . -> package
26+
call-function $package RaiTest new -> component adminbadge minterbadge position rai
27+
call-method $component open_position 500,030000000000000000000000000000000000000000000000000004
28+
call-method $component draw #0000000000000000,$position 33
29+
set-current-epoch 15000
30+
call-method $component open_position 1000,030000000000000000000000000000000000000000000000000004
31+
call-method $component draw #0000000000000001,$position 50
32+
call-method $component liquidate 0 50,$rai

0 commit comments

Comments
 (0)