Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F/value ranges #106

Merged
merged 23 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9ce79c9
Improve in passing: Use already defined var
maurolacy Aug 14, 2023
7b53587
Increase optimiser version
maurolacy Aug 14, 2023
c71a3e0
Use value range for liens
maurolacy Aug 14, 2023
fd3a05b
Adapt tests
maurolacy Aug 14, 2023
44f74a5
Use value range for user max lien and total slashable
maurolacy Aug 15, 2023
41a6ed4
Adapt tests
maurolacy Aug 15, 2023
93d4614
Proper / sound local vs cross stake value range impl
maurolacy Aug 17, 2023
9c61361
Use Valuerange::sub() convenience method for unstake
maurolacy Aug 17, 2023
7277511
Use value range for free collateral as well
maurolacy Aug 17, 2023
aed0f4a
Adapt tests
maurolacy Aug 17, 2023
7646b1d
Fix syntax / typos
maurolacy Aug 18, 2023
69c4ac2
feat: Switch to `ValueRange` in external-staking
jawoznia Aug 18, 2023
a002369
feat: Don't change stake on reward withdrawal
jawoznia Aug 22, 2023
c005f11
Update contracts/provider/external-staking/src/contract.rs
jawoznia Aug 22, 2023
a9e7b35
feat: Check if Tx is of proper type
jawoznia Aug 22, 2023
5f67d2b
Remove unused Lock error
maurolacy Aug 22, 2023
1215f32
Remove outdated FIXME
maurolacy Aug 22, 2023
309b8fd
Update contracts/provider/external-staking/src/multitest.rs
jawoznia Aug 22, 2023
0bebafd
feat: Switch to non lockable response
jawoznia Aug 22, 2023
70141fa
tests: Stake remains the same after reward withdrawal
jawoznia Aug 23, 2023
14a28b1
Merge pull request #108 from osmosis-labs/f/value-ranges-external-sta…
jawoznia Aug 23, 2023
95c516a
Refactor local vs remote stake for clarity
maurolacy Aug 23, 2023
b4e14a8
Improve comment
maurolacy Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions contracts/provider/external-staking/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,12 @@ fn unstaking() {
let claim = vault
.claim(users[0].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 300);
assert_eq!(claim.amount.val().unwrap().u128(), 300);

let claim = vault
.claim(users[1].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 300);
assert_eq!(claim.amount.val().unwrap().u128(), 300);

// Immediately withdrawing liens
contract.withdraw_unbonded().call(users[0]).unwrap();
Expand All @@ -507,12 +507,12 @@ fn unstaking() {
let claim = vault
.claim(users[0].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 300);
assert_eq!(claim.amount.val().unwrap().u128(), 300);

let claim = vault
.claim(users[1].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 300);
assert_eq!(claim.amount.val().unwrap().u128(), 300);

// Very short travel in future - too short for claims to release
app.app_mut().update_block(|block| {
Expand All @@ -528,12 +528,12 @@ fn unstaking() {
let claim = vault
.claim(users[0].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 300);
assert_eq!(claim.amount.val().unwrap().u128(), 300);

let claim = vault
.claim(users[1].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 300);
assert_eq!(claim.amount.val().unwrap().u128(), 300);

// Adding some more unstakes
// users[0] unstakes 70 from validators[0] - 80 left staken
Expand Down Expand Up @@ -596,12 +596,12 @@ fn unstaking() {
let claim = vault
.claim(users[0].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 250);
assert_eq!(claim.amount.val().unwrap().u128(), 250);

let claim = vault
.claim(users[1].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 240);
assert_eq!(claim.amount.val().unwrap().u128(), 240);

// Moving forward more, passing through second bath pending duration
app.app_mut().update_block(|block| {
Expand All @@ -613,12 +613,12 @@ fn unstaking() {
let claim = vault
.claim(users[0].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 250);
assert_eq!(claim.amount.val().unwrap().u128(), 250);

let claim = vault
.claim(users[1].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 240);
assert_eq!(claim.amount.val().unwrap().u128(), 240);

// Withdrawing liens
contract.withdraw_unbonded().call(users[0]).unwrap();
Expand All @@ -628,12 +628,12 @@ fn unstaking() {
let claim = vault
.claim(users[0].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 90);
assert_eq!(claim.amount.val().unwrap().u128(), 90);

let claim = vault
.claim(users[1].to_owned(), contract.contract_addr.to_string())
.unwrap();
assert_eq!(claim.amount.u128(), 240);
assert_eq!(claim.amount.val().unwrap().u128(), 240);
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions contracts/provider/native-staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mt = ["library", "sylvia/mt"]

[dependencies]
mesh-apis = { workspace = true }
mesh-sync = { workspace = true }
mesh-native-staking-proxy = { workspace = true, features = ["library"] }

sylvia = { workspace = true }
Expand Down
10 changes: 6 additions & 4 deletions contracts/provider/native-staking/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use cosmwasm_std::{coin, coins, to_binary, Addr, Decimal, StdError, Uint128};
use cw_multi_test::App as MtApp;
use sylvia::multitest::App;

use mesh_sync::ValueRange;

use crate::local_staking_api::test_utils::LocalStakingApi;
use crate::native_staking_callback::test_utils::NativeStakingCallback;

Expand Down Expand Up @@ -271,9 +273,9 @@ fn releasing_proxy_stake() {
let claims = vault.account_claims(user.to_owned(), None, None).unwrap();
assert_eq!(
claims.claims,
[mesh_vault::msg::MaybeLienResponse::Lien {
[mesh_vault::msg::LienResponse {
lienholder: staking_addr.to_owned(),
amount: Uint128::new(100)
amount: ValueRange::new_val(Uint128::new(100))
}]
);

Expand All @@ -300,9 +302,9 @@ fn releasing_proxy_stake() {
let claims = vault.account_claims(user.to_owned(), None, None).unwrap();
assert_eq!(
claims.claims,
[mesh_vault::msg::MaybeLienResponse::Lien {
[mesh_vault::msg::LienResponse {
lienholder: staking_addr.to_owned(),
amount: Uint128::zero() // TODO? Clean-up empty liens
amount: ValueRange::new_val(Uint128::zero()) // TODO? Clean-up empty liens
}]
);
}
Loading
Loading