Skip to content

Commit 5283c69

Browse files
committed
Merge remote-tracking branch 'origin/devel' into expose-test-only-fns
2 parents dbc8798 + fb0a694 commit 5283c69

27 files changed

+6147
-4012
lines changed

.github/workflows/pull-request.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
run: apt-get install -y git
2222

2323
- name: test
24-
run: cd contracts && sui move test
24+
run: cd contracts/suilend && sui move test

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
contracts/build
2+
contracts/suilend/build
3+
contracts/sprungsui/build
24
suilend-cli/node_modules
5+
contracts/oracle/build

contracts/sprungsui/Move.lock

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# @generated by Move, please check-in and do not edit manually.
2+
3+
[move]
4+
version = 3
5+
manifest_digest = "50026425FE2D414A59AC825A51391626106F0F34F0AD8DADBC2B406B1A51AF0B"
6+
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
7+
dependencies = [
8+
{ id = "Sui", name = "Sui" },
9+
]
10+
11+
[[move.package]]
12+
id = "MoveStdlib"
13+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }
14+
15+
[[move.package]]
16+
id = "Sui"
17+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }
18+
19+
dependencies = [
20+
{ id = "MoveStdlib", name = "MoveStdlib" },
21+
]
22+
23+
[move.toolchain-version]
24+
compiler-version = "1.36.2"
25+
edition = "2024.beta"
26+
flavor = "sui"
27+
28+
[env]
29+
30+
[env.mainnet]
31+
chain-id = "35834a8a"
32+
original-published-id = "0xb87cea7e4220461e35dff856185814d6a37ef479ce895ffbe4efa1d1af5aacbc"
33+
latest-published-id = "0xb87cea7e4220461e35dff856185814d6a37ef479ce895ffbe4efa1d1af5aacbc"
34+
published-version = "1"

contracts/sprungsui/Move.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "sprungsui"
3+
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
4+
published-at = "0xb87cea7e4220461e35dff856185814d6a37ef479ce895ffbe4efa1d1af5aacbc"
5+
6+
[dependencies]
7+
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" }
8+
9+
[addresses]
10+
sprungsui = "0xb87cea7e4220461e35dff856185814d6a37ef479ce895ffbe4efa1d1af5aacbc"
11+
12+
[dev-dependencies]
13+
14+
[dev-addresses]
15+
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module sprungsui::sprungsui {
2+
use sui::coin::{Self};
3+
4+
public struct SPRUNGSUI has drop {}
5+
6+
fun init(witness: SPRUNGSUI, ctx: &mut TxContext) {
7+
let (treasury, metadata) = coin::create_currency(
8+
witness,
9+
9,
10+
b"",
11+
b"Staked SUI",
12+
b"",
13+
option::none(),
14+
ctx
15+
);
16+
17+
transfer::public_share_object(metadata);
18+
transfer::public_transfer(treasury, ctx.sender())
19+
}
20+
}

contracts/suilend/Move.beta.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "suilend"
33
version = "0.0.1"
4-
published-at = "0x4a9954ebc8bcb53460122504a6746b6a79492fc4eef79ebd0e221be230ac882f"
4+
published-at = "0x465174d80d10d33917d16721d20e6a4e08c50e9d3ff9115ee8c36cf9fb7bcd6e"
5+
edition = "2024.beta"
56

67
[dependencies.Sui]
78
git = "https://github.com/MystenLabs/sui.git"
@@ -17,3 +18,4 @@ rev = "98e218c64bb75cf1350eb7b021e1ffcc3aedfd62"
1718
[addresses]
1819
sui = "0x2"
1920
suilend = "0xba79417dd36e8fa1510f53b0491b7a8b2802217a81b1401b1efbb65e4994e016"
21+
# suilend = "0x0"

contracts/suilend/Move.lock

+43-16
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,72 @@
11
# @generated by Move, please check-in and do not edit manually.
22

33
[move]
4-
version = 0
5-
manifest_digest = "B3FE2B3145AAA782D033C4C83CB620E1846F4E168912A791CF48EB53D984FC17"
6-
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"
7-
4+
version = 3
5+
manifest_digest = "65A3BAC5F3D190E11F8C3E634F1E2A87769D934A746A17BE65E872D84543D184"
6+
deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C"
87
dependencies = [
9-
{ name = "Pyth" },
10-
{ name = "Sui" },
8+
{ id = "Pyth", name = "Pyth" },
9+
{ id = "Sui", name = "Sui" },
10+
{ id = "liquid_staking", name = "liquid_staking" },
11+
{ id = "sprungsui", name = "sprungsui" },
1112
]
1213

1314
[[move.package]]
14-
name = "MoveStdlib"
15+
id = "MoveStdlib"
1516
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }
1617

1718
[[move.package]]
18-
name = "Pyth"
19+
id = "Pyth"
1920
source = { git = "https://github.com/solendprotocol/pyth-crosschain.git", rev = "98e218c64bb75cf1350eb7b021e1ffcc3aedfd62", subdir = "target_chains/sui/contracts" }
2021

2122
dependencies = [
22-
{ name = "Sui" },
23-
{ name = "Wormhole" },
23+
{ id = "Sui", name = "Sui" },
24+
{ id = "Wormhole", name = "Wormhole" },
2425
]
2526

2627
[[move.package]]
27-
name = "Sui"
28+
id = "Sui"
2829
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }
2930

3031
dependencies = [
31-
{ name = "MoveStdlib" },
32+
{ id = "MoveStdlib", name = "MoveStdlib" },
33+
]
34+
35+
[[move.package]]
36+
id = "SuiSystem"
37+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-system" }
38+
39+
dependencies = [
40+
{ id = "MoveStdlib", name = "MoveStdlib" },
41+
{ id = "Sui", name = "Sui" },
3242
]
3343

3444
[[move.package]]
35-
name = "Wormhole"
45+
id = "Wormhole"
3646
source = { git = "https://github.com/solendprotocol/wormhole.git", rev = "e1698d3c72b15cdddd7da98ad43e151f83b72a0a", subdir = "sui/wormhole" }
3747

3848
dependencies = [
39-
{ name = "Sui" },
49+
{ id = "Sui", name = "Sui" },
50+
]
51+
52+
[[move.package]]
53+
id = "liquid_staking"
54+
source = { git = "https://github.com/solendprotocol/liquid-staking.git", rev = "main", subdir = "contracts" }
55+
56+
dependencies = [
57+
{ id = "Sui", name = "Sui" },
58+
{ id = "SuiSystem", name = "SuiSystem" },
59+
]
60+
61+
[[move.package]]
62+
id = "sprungsui"
63+
source = { local = "../sprungsui" }
64+
65+
dependencies = [
66+
{ id = "Sui", name = "Sui" },
4067
]
4168

4269
[move.toolchain-version]
43-
compiler-version = "1.24.1"
44-
edition = "legacy"
70+
compiler-version = "1.38.3"
71+
edition = "2024.beta"
4572
flavor = "sui"

contracts/suilend/Move.mainnet.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "suilend"
33
version = "0.0.1"
4-
published-at = "0x5fbbb0297c80ae2c382bbe21e71408b3a11259b46cdbaaa1bb261c1d5fc93f02"
4+
published-at = "0x157dbf1830dab58ec67e025c1200a32a22a31150beba4d3de8e39571547f8cc2"
5+
edition = "2024.beta"
56

67
[dependencies.Sui]
78
git = "https://github.com/MystenLabs/sui.git"

contracts/suilend/Move.toml

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "suilend"
33
version = "0.0.1"
4-
published-at = "0x157dbf1830dab58ec67e025c1200a32a22a31150beba4d3de8e39571547f8cc2"
4+
published-at = "0xf4ff123a3730fa718761b05ec454d3eefc032ef0528627a0552916194c815904"
5+
edition = "2024.beta"
56

67
[dependencies.Sui]
78
git = "https://github.com/MystenLabs/sui.git"
@@ -14,6 +15,14 @@ git = "https://github.com/solendprotocol/pyth-crosschain.git"
1415
subdir = "target_chains/sui/contracts"
1516
rev = "98e218c64bb75cf1350eb7b021e1ffcc3aedfd62"
1617

18+
[dependencies.liquid_staking]
19+
git = "https://github.com/solendprotocol/liquid-staking.git"
20+
subdir = "contracts"
21+
rev = "main"
22+
23+
[dependencies.sprungsui]
24+
local = "../sprungsui"
25+
1726
[addresses]
1827
sui = "0x2"
1928
# suilend = "0x0"

contracts/suilend/sources/cell.move

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module suilend::cell {
22
use std::option::{Self, Option};
33

4-
struct Cell<Element> has store {
4+
public struct Cell<Element> has store {
55
element: Option<Element>
66
}
77

contracts/suilend/sources/decimal.move

+16-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
module suilend::decimal {
33
// 1e18
44
const WAD: u256 = 1000000000000000000;
5+
const U64_MAX: u256 = 18446744073709551615;
56

6-
struct Decimal has copy, store, drop {
7+
public struct Decimal has copy, store, drop {
78
value: u256
89
}
910

@@ -73,9 +74,9 @@ module suilend::decimal {
7374
}
7475
}
7576

76-
public fun pow(b: Decimal, e: u64): Decimal {
77-
let cur_base = b;
78-
let result = from(1);
77+
public fun pow(b: Decimal, mut e: u64): Decimal {
78+
let mut cur_base = b;
79+
let mut result = from(1);
7980

8081
while (e > 0) {
8182
if (e % 2 == 1) {
@@ -92,6 +93,14 @@ module suilend::decimal {
9293
((a.value / WAD) as u64)
9394
}
9495

96+
public fun saturating_floor(a: Decimal): u64 {
97+
if (a.value > U64_MAX * WAD) {
98+
(U64_MAX as u64)
99+
} else {
100+
floor(a)
101+
}
102+
}
103+
95104
public fun ceil(a: Decimal): u64 {
96105
(((a.value + WAD - 1) / WAD) as u64)
97106
}
@@ -135,7 +144,7 @@ module suilend::decimal {
135144

136145
#[test_only]
137146
module suilend::decimal_tests {
138-
use suilend::decimal::{add, sub, mul, div, floor, ceil, pow, lt, gt, le, ge, from, from_percent, saturating_sub};
147+
use suilend::decimal::{add, sub, mul, div, floor, ceil, pow, lt, gt, le, ge, from, from_percent, saturating_sub, saturating_floor};
139148

140149
#[test]
141150
fun test_basic() {
@@ -154,6 +163,8 @@ module suilend::decimal_tests {
154163
assert!(ge(b, a), 0);
155164
assert!(saturating_sub(a, b) == from(0), 0);
156165
assert!(saturating_sub(b, a) == from(1), 0);
166+
assert!(saturating_floor(from(18446744073709551615)) == 18446744073709551615, 0);
167+
assert!(saturating_floor(add(from(18446744073709551615), from(1))) == 18446744073709551615, 0);
157168
}
158169

159170
#[test]

0 commit comments

Comments
 (0)