Skip to content

Commit

Permalink
renamed proposal's "bid_duration" to "deployment_duration"
Browse files Browse the repository at this point in the history
  • Loading branch information
dusan-maksimovic committed Nov 22, 2024
1 parent 89e8991 commit 1573ef8
Show file tree
Hide file tree
Showing 27 changed files with 142 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Rename "bid duration" to "deployment duration".
([\#176](https://github.com/informalsystems/hydro/pull/176))
4 changes: 2 additions & 2 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
9c08862f95440cf2b132cc6a8f70a5d1d6791dc001a9faf31a9b1322c09fab62 hydro.wasm
956f646ccbcb493c82b164ab8e4dbcdd80fea97c66483a04fda5971a8b6f4199 tribute.wasm
64c7901df8a9906223e43bab9aa606579bd61284f91649a2a52d0caf4d697206 hydro.wasm
59a278e98f945a980e4dbd897a3a15cbe54df555515d03ab0f635a2b4ef0e9fa tribute.wasm
Binary file modified artifacts/hydro.wasm
Binary file not shown.
Binary file modified artifacts/tribute.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions contracts/hydro/schema/constants_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"icq_update_period",
"is_in_pilot_mode",
"lock_epoch_length",
"max_bid_duration",
"max_deployment_duration",
"max_locked_tokens",
"max_validator_shares_participating",
"paused",
Expand Down Expand Up @@ -50,7 +50,7 @@
"format": "uint64",
"minimum": 0.0
},
"max_bid_duration": {
"max_deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down
6 changes: 3 additions & 3 deletions contracts/hydro/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@
"create_proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"title",
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down Expand Up @@ -192,7 +192,7 @@
"update_config": {
"type": "object",
"properties": {
"max_bid_duration": {
"max_deployment_duration": {
"type": [
"integer",
"null"
Expand Down
26 changes: 13 additions & 13 deletions contracts/hydro/schema/hydro_full_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"initial_whitelist",
"is_in_pilot_mode",
"lock_epoch_length",
"max_bid_duration",
"max_deployment_duration",
"max_locked_tokens",
"max_validator_shares_participating",
"round_length",
Expand Down Expand Up @@ -54,7 +54,7 @@
"format": "uint64",
"minimum": 0.0
},
"max_bid_duration": {
"max_deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down Expand Up @@ -202,14 +202,14 @@
"create_proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"title",
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down Expand Up @@ -315,7 +315,7 @@
"update_config": {
"type": "object",
"properties": {
"max_bid_duration": {
"max_deployment_duration": {
"type": [
"integer",
"null"
Expand Down Expand Up @@ -1192,7 +1192,7 @@
"Proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"percentage",
Expand All @@ -1203,7 +1203,7 @@
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down Expand Up @@ -1480,7 +1480,7 @@
"icq_update_period",
"is_in_pilot_mode",
"lock_epoch_length",
"max_bid_duration",
"max_deployment_duration",
"max_locked_tokens",
"max_validator_shares_participating",
"paused",
Expand Down Expand Up @@ -1509,7 +1509,7 @@
"format": "uint64",
"minimum": 0.0
},
"max_bid_duration": {
"max_deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down Expand Up @@ -1585,7 +1585,7 @@
"Proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"percentage",
Expand All @@ -1596,7 +1596,7 @@
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down Expand Up @@ -1962,7 +1962,7 @@
"Proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"percentage",
Expand All @@ -1973,7 +1973,7 @@
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down
4 changes: 2 additions & 2 deletions contracts/hydro/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"initial_whitelist",
"is_in_pilot_mode",
"lock_epoch_length",
"max_bid_duration",
"max_deployment_duration",
"max_locked_tokens",
"max_validator_shares_participating",
"round_length",
Expand Down Expand Up @@ -53,7 +53,7 @@
"format": "uint64",
"minimum": 0.0
},
"max_bid_duration": {
"max_deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down
4 changes: 2 additions & 2 deletions contracts/hydro/schema/proposal_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"percentage",
Expand All @@ -26,7 +26,7 @@
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down
4 changes: 2 additions & 2 deletions contracts/hydro/schema/round_proposals_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"percentage",
Expand All @@ -29,7 +29,7 @@
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down
4 changes: 2 additions & 2 deletions contracts/hydro/schema/top_n_proposals_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Proposal": {
"type": "object",
"required": [
"bid_duration",
"deployment_duration",
"description",
"minimum_atom_liquidity_request",
"percentage",
Expand All @@ -29,7 +29,7 @@
"tranche_id"
],
"properties": {
"bid_duration": {
"deployment_duration": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down
41 changes: 24 additions & 17 deletions contracts/hydro/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub const MAX_LOCK_ENTRIES: usize = 100;

pub const NATIVE_TOKEN_DENOM: &str = "untrn";

pub const MIN_DEPLOYMENT_DURATION: u64 = 1;

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut<NeutronQuery>,
Expand All @@ -79,7 +81,7 @@ pub fn instantiate(
hub_transfer_channel_id: msg.hub_transfer_channel_id,
icq_update_period: msg.icq_update_period,
is_in_pilot_mode: msg.is_in_pilot_mode,
max_bid_duration: msg.max_bid_duration,
max_deployment_duration: msg.max_deployment_duration,
paused: false,
};

Expand Down Expand Up @@ -162,7 +164,7 @@ pub fn execute(
tranche_id,
title,
description,
bid_duration,
deployment_duration,
minimum_atom_liquidity_request,
} => create_proposal(
deps,
Expand All @@ -171,7 +173,7 @@ pub fn execute(
tranche_id,
title,
description,
bid_duration,
deployment_duration,
minimum_atom_liquidity_request,
),
ExecuteMsg::Vote {
Expand All @@ -184,8 +186,8 @@ pub fn execute(
}
ExecuteMsg::UpdateConfig {
max_locked_tokens,
max_bid_duration,
} => update_config(deps, info, max_locked_tokens, max_bid_duration),
max_deployment_duration,
} => update_config(deps, info, max_locked_tokens, max_deployment_duration),
ExecuteMsg::Pause {} => pause_contract(deps, info),
ExecuteMsg::AddTranche { tranche } => add_tranche(deps, info, tranche),
ExecuteMsg::EditTranche {
Expand Down Expand Up @@ -617,7 +619,7 @@ fn create_proposal(
tranche_id: u64,
title: String,
description: String,
bid_duration: u64,
deployment_duration: u64,
minimum_atom_liquidity_request: Uint128,
) -> Result<Response<NeutronMsg>, ContractError> {
let constants = CONSTANTS.load(deps.storage)?;
Expand All @@ -636,11 +638,13 @@ fn create_proposal(
// check that the tranche with the given id exists
TRANCHE_MAP.load(deps.storage, tranche_id)?;

// check that the bid duration is within the allowed range
if bid_duration < 1 || bid_duration > constants.max_bid_duration {
// check that the deployment duration is within the allowed range
if deployment_duration < MIN_DEPLOYMENT_DURATION
|| deployment_duration > constants.max_deployment_duration
{
return Err(ContractError::Std(StdError::generic_err(format!(
"Invalid bid duration: {}. Must be between {} and {} rounds.",
bid_duration, 1, constants.max_bid_duration,
"Invalid deployment duration: {}. Must be between {} and {} rounds.",
deployment_duration, MIN_DEPLOYMENT_DURATION, constants.max_deployment_duration,
))));
}

Expand All @@ -654,7 +658,7 @@ fn create_proposal(
percentage: Uint128::zero(),
title: title.trim().to_string(),
description: description.trim().to_string(),
bid_duration,
deployment_duration,
minimum_atom_liquidity_request,
};

Expand Down Expand Up @@ -932,7 +936,7 @@ fn vote(
&vote,
)?;

let voting_allowed_round = round_id + proposal.bid_duration;
let voting_allowed_round = round_id + proposal.deployment_duration;
VOTING_ALLOWED_ROUND.save(
deps.storage,
(tranche_id, lock_id),
Expand Down Expand Up @@ -1035,7 +1039,7 @@ fn update_config(
deps: DepsMut<NeutronQuery>,
info: MessageInfo,
max_locked_tokens: Option<u128>,
max_bid_duration: Option<u64>,
max_deployment_duration: Option<u64>,
) -> Result<Response<NeutronMsg>, ContractError> {
let mut constants = CONSTANTS.load(deps.storage)?;

Expand All @@ -1051,9 +1055,12 @@ fn update_config(
response = response.add_attribute("new_max_locked_tokens", max_locked_tokens.to_string());
}

if let Some(max_bid_duration) = max_bid_duration {
constants.max_bid_duration = max_bid_duration;
response = response.add_attribute("new_max_bid_duration", max_bid_duration.to_string());
if let Some(max_deployment_duration) = max_deployment_duration {
constants.max_deployment_duration = max_deployment_duration;
response = response.add_attribute(
"new_max_deployment_duration",
max_deployment_duration.to_string(),
);
}

CONSTANTS.save(deps.storage, &constants)?;
Expand Down Expand Up @@ -2232,7 +2239,7 @@ fn can_lock_vote_for_proposal(
lock_entry: &LockEntry,
proposal: &Proposal,
) -> Result<bool, ContractError> {
let power_required_round_id = current_round + proposal.bid_duration - 1;
let power_required_round_id = current_round + proposal.deployment_duration - 1;
let power_required_round_end = compute_round_end(constants, power_required_round_id)?;

Ok(lock_entry.lock_end >= power_required_round_end)
Expand Down
Loading

0 comments on commit 1573ef8

Please sign in to comment.