Skip to content

Commit

Permalink
feat: use injective-std
Browse files Browse the repository at this point in the history
  • Loading branch information
PFC-developer committed Jul 29, 2024
1 parent 7e3de73 commit be94a9a
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 72 deletions.
133 changes: 102 additions & 31 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["contracts/*", "integration", "packages/*"]
resolver = "2"

[workspace.package]
version = "0.1.1"
version = "0.1.2"
authors = [
"Kerber0x <[email protected]>",
"Nahem <[email protected]>",
Expand Down Expand Up @@ -36,6 +36,7 @@ serde = { version = "1.0.196", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.56" }
treasurechest = { path = "packages/treasurechest" }
injective_auction = { path = "packages/injective_auction" }
injective-std = "1.13.2-testnet"
cw-multi-test = { version = "0.20.0", features = ["cosmwasm_1_2"] }
pfc-whitelist = "1.5.0"
pfc-whitelist-derive = "1.5.0"
Expand Down
1 change: 1 addition & 0 deletions contracts/injective-auction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cw2 = { workspace = true }
cw-storage-plus = { workspace = true }
thiserror = { workspace = true }
injective_auction = { workspace = true }
injective-std = {workspace = true}
prost = { workspace = true }
cw-utils = { workspace = true }
treasurechest = { workspace = true }
Expand Down
24 changes: 13 additions & 11 deletions contracts/injective-auction-pool/src/executions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use cosmwasm_std::{
attr, coins, to_json_binary, BankMsg, CosmosMsg, Decimal, DepsMut, Env, MessageInfo, Response,
Uint128, WasmMsg,
};
use injective_auction::{auction::MsgBid, auction_pool::ExecuteMsg::TryBid};
use injective_std::types::cosmos::base::v1beta1::Coin;
use injective_std::types::injective::auction::v1beta1::MsgBid;
use injective_auction::{ auction_pool::ExecuteMsg::TryBid};

use crate::{
helpers::{new_auction_round, query_current_auction, validate_percentage},
Expand Down Expand Up @@ -111,8 +113,8 @@ pub(crate) fn join_pool(
let amount = cw_utils::must_pay(&info, &config.native_denom)?;

let current_auction_round = query_current_auction(deps.as_ref())?
.auction_round
.ok_or(ContractError::CurrentAuctionQueryError)?;
.auction_round;
// .ok_or(ContractError::CurrentAuctionQueryError)?;

// prevents the user from joining the pool if the auction round is over
if auction_round != current_auction_round {
Expand Down Expand Up @@ -182,7 +184,7 @@ pub(crate) fn exit_pool(

// prevents the user from exiting the pool if the contract has already bid on the auction
if FUNDS_LOCKED.load(deps.storage)?
&& env.block.time.seconds() < current_auction_round_response.auction_closing_time()
&& env.block.time.seconds() < current_auction_round_response.auction_closing_time as u64
{
return Err(ContractError::PooledAuctionLocked);
}
Expand Down Expand Up @@ -231,8 +233,8 @@ pub(crate) fn try_bid(

let current_auction_round_response = query_current_auction(deps.as_ref())?;
let current_auction_round = current_auction_round_response
.auction_round
.ok_or(ContractError::CurrentAuctionQueryError)?;
.auction_round;
//.ok_or(ContractError::CurrentAuctionQueryError)?;

// prevents the contract from bidding on the wrong auction round
if auction_round != current_auction_round {
Expand All @@ -243,7 +245,7 @@ pub(crate) fn try_bid(
}

// prevents the contract from bidding if the contract is already the highest bidder
if current_auction_round_response.highest_bidder == Some(env.contract.address.to_string()) {
if current_auction_round_response.highest_bidder == env.contract.address.to_string() {
return Ok(Response::default()
.add_attribute("action", "did_not_bid")
.add_attribute("reason", "contract_is_already_the_highest_bidder"));
Expand All @@ -254,7 +256,7 @@ pub(crate) fn try_bid(
// the latest + 1 is to make sure the auction module accepts the bid all the times
let minimum_allowed_bid = current_auction_round_response
.highest_bid_amount
.unwrap_or(0.to_string())
// .unwrap_or(0.to_string())
.parse::<Decimal>()?
.checked_mul((Decimal::one().checked_add(config.min_next_bid_increment_rate))?)?
.to_uint_ceil()
Expand All @@ -277,7 +279,7 @@ pub(crate) fn try_bid(

let msg = <MsgBid as Into<CosmosMsg>>::into(MsgBid {
sender: env.contract.address.to_string(),
bid_amount: Some(injective_auction::auction::Coin {
bid_amount: Some(Coin {
denom: config.native_denom,
amount: minimum_allowed_bid.to_string(),
}),
Expand Down Expand Up @@ -320,8 +322,8 @@ pub fn settle_auction(

let current_auction_round_response = query_current_auction(deps.as_ref())?;
let current_auction_round = current_auction_round_response
.auction_round
.ok_or(ContractError::CurrentAuctionQueryError)?;
.auction_round;
// .ok_or(ContractError::CurrentAuctionQueryError)?;

// prevents the contract from settling the auction if the auction round has not finished
if current_auction_round == unsettled_auction.auction_round {
Expand Down
Loading

0 comments on commit be94a9a

Please sign in to comment.