Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptokage1996 committed Sep 27, 2024
1 parent 14ef3c1 commit c9bb641
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
7 changes: 6 additions & 1 deletion bindings-test/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,12 @@ impl Module for ElysModule {
.find(|mtp| mtp.id == id && mtp.address == address)
.cloned()
{
Ok(to_json_binary(&PerpetualMtpResponse { mtp: Some(mtp) })?)
Ok(to_json_binary(&PerpetualMtpResponse {
mtp: Some(MtpAndPrice {
mtp: mtp,
trading_asset_price: Decimal::zero(),
}),
})?)
} else {
return Err(Error::new(StdError::not_found(
"perpetual trading position",
Expand Down
2 changes: 1 addition & 1 deletion bindings-test/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn query_single_mtp() {

let mtp_found: PerpetualMtpResponse = app.wrap().query(&req).unwrap();

assert_eq!(mtps[0], mtp_found.mtp.unwrap());
assert_eq!(mtps[0], mtp_found.mtp.unwrap().mtp);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion bindings/src/query_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct PerpetualQueryPositionsResponse {

#[cw_serde]
pub struct PerpetualMtpResponse {
pub mtp: Option<Mtp>,
pub mtp: Option<MtpAndPrice>,
}

#[cw_serde]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ fn create_perpetual_close_order(
.into());
}

if price.quote_denom != mtp.trading_asset {
if price.quote_denom != mtp.mtp.trading_asset {
return Err(StdError::generic_err(
"trigger_price: The quote denom should be the trading asset denom",
)
Expand Down Expand Up @@ -371,14 +371,14 @@ fn create_perpetual_close_order(

let order = PerpetualOrderV2::new_close(
&info.sender,
mtp.position,
mtp.mtp.position,
&order_type,
&coin(mtp.collateral.i128() as u128, &mtp.collateral_asset),
&mtp.trading_asset,
&mtp.leverage,
&coin(mtp.mtp.collateral.i128() as u128, &mtp.mtp.collateral_asset),
&mtp.mtp.trading_asset,
&mtp.mtp.leverage,
position_id,
&trigger_price,
&Some(mtp.take_profit_price),
&Some(mtp.mtp.take_profit_price),
&orders,
)?;

Expand Down Expand Up @@ -409,8 +409,12 @@ fn create_perpetual_close_order(
let number_of_executed_order = NUMBER_OF_EXECUTED_ORDER.load(deps.storage)? + 1;
NUMBER_OF_EXECUTED_ORDER.save(deps.storage, &number_of_executed_order)?;

let msg =
ElysMsg::perpetual_close_position(creator, position_id, mtp.custody.i128(), &info.sender);
let msg = ElysMsg::perpetual_close_position(
creator,
position_id,
mtp.mtp.custody.i128(),
&info.sender,
);

let reply_info_max_id = MAX_REPLY_ID.load(deps.storage)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn get_perpetual_position(
None => return Err(StdError::not_found("perpetual trading position").into()),
};

let mtp_plus = PerpetualPositionPlus::new(mtp, deps.storage, &querier)?;
let mtp_plus = PerpetualPositionPlus::new(mtp.mtp, deps.storage, &querier)?;

Ok(GetPerpetualPositionResp { mtp: mtp_plus })
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fn process_perpetual_order(
}
};

let amount = mtp.custody.i128();
let amount = mtp.mtp.custody.i128();
(
ElysMsg::perpetual_close_position(
creator,
Expand Down

0 comments on commit c9bb641

Please sign in to comment.