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

feat: trade no longer links to opposite trade #182

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 1 addition & 2 deletions npm-client/docs/types/trade.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@

## Trade

Type: {purchaser: PublicKey, market: PublicKey, order: PublicKey, oppositeTrade: PublicKey, marketOutcomeIndex: [number][9], forOutcome: [boolean][10], stake: BN, price: [number][9], creationTimestamp: BN, payer: PublicKey}
Type: {purchaser: PublicKey, market: PublicKey, order: PublicKey, marketOutcomeIndex: [number][9], forOutcome: [boolean][10], stake: BN, price: [number][9], creationTimestamp: BN, payer: PublicKey}

### Properties

* `purchaser` **PublicKey** 
* `market` **PublicKey** 
* `order` **PublicKey** 
* `oppositeTrade` **PublicKey** 
* `marketOutcomeIndex` **[number][9]** 
* `forOutcome` **[boolean][10]** 
* `stake` **BN** 
Expand Down
1 change: 0 additions & 1 deletion npm-client/types/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export type Trade = {
purchaser: PublicKey;
market: PublicKey;
order: PublicKey;
oppositeTrade: PublicKey;
marketOutcomeIndex: number;
forOutcome: boolean;
stake: BN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn create_trade(
purchaser_pk: &Pubkey,
market_pk: &Pubkey,
order_pk: &Pubkey,
opposite_trade_pk: &Pubkey,
outcome_index: u16,
for_outcome: bool,
stake: u64,
Expand All @@ -18,7 +17,6 @@ pub fn create_trade(
trade.purchaser = *purchaser_pk;
trade.market = *market_pk;
trade.order = *order_pk;
trade.opposite_trade = *opposite_trade_pk;
trade.for_outcome = for_outcome;
trade.market_outcome_index = outcome_index;
trade.stake = stake;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ pub fn match_orders(ctx: &mut Context<MatchOrders>) -> Result<()> {
&ctx.accounts.order_against.purchaser,
&ctx.accounts.order_against.market,
&ctx.accounts.order_against.key(),
&ctx.accounts.trade_for.key(),
ctx.accounts.order_against.market_outcome_index,
ctx.accounts.order_against.for_outcome,
stake_matched,
Expand All @@ -163,7 +162,6 @@ pub fn match_orders(ctx: &mut Context<MatchOrders>) -> Result<()> {
&ctx.accounts.order_for.purchaser,
&ctx.accounts.order_for.market,
&ctx.accounts.order_for.key(),
&ctx.accounts.trade_against.key(),
ctx.accounts.order_for.market_outcome_index,
ctx.accounts.order_for.for_outcome,
stake_matched,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ pub fn on_order_match(
maker_order_pk: &Pubkey,
maker_order: &mut Order,
market_position: &mut MarketPosition,
maker_order_trade_pk: &Pubkey,
maker_order_trade: &mut Trade,
taker_order_trade_pk: &Pubkey,
taker_order_trade: &mut Trade,
payer: &Pubkey,
) -> Result<u64> {
Expand Down Expand Up @@ -74,7 +72,6 @@ pub fn on_order_match(
&maker_order.purchaser,
&maker_order.market,
maker_order_pk,
taker_order_trade_pk,
maker_order.market_outcome_index,
maker_order.for_outcome,
stake,
Expand All @@ -89,7 +86,6 @@ pub fn on_order_match(
&taker_order.purchaser,
&maker_order.market,
&taker_order.pk,
maker_order_trade_pk,
taker_order.outcome_index,
taker_order.for_outcome,
stake,
Expand Down Expand Up @@ -182,9 +178,7 @@ mod test {
&order_pk,
&mut order,
&mut market_position,
&maker_order_trade_pk,
&mut maker_order_trade,
&taker_order_trade_pk,
&mut taker_order_trade,
&payer_pk,
);
Expand Down Expand Up @@ -279,9 +273,7 @@ mod test {
&order_pk,
&mut order,
&mut market_position,
&maker_order_trade_pk,
&mut maker_order_trade,
&taker_order_trade_pk,
&mut taker_order_trade,
&payer_pk,
);
Expand Down Expand Up @@ -372,9 +364,7 @@ mod test {
&order_pk,
&mut order,
&mut market_position,
&maker_order_trade_pk,
&mut maker_order_trade,
&taker_order_trade_pk,
&mut taker_order_trade,
&payer_pk,
);
Expand Down
2 changes: 0 additions & 2 deletions programs/monaco_protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ pub mod monaco_protocol {
&ctx.accounts.maker_order.key(),
&mut ctx.accounts.maker_order,
&mut ctx.accounts.market_position,
&ctx.accounts.maker_order_trade.key(),
&mut ctx.accounts.maker_order_trade,
&ctx.accounts.taker_order_trade.key(),
&mut ctx.accounts.taker_order_trade,
&ctx.accounts.crank_operator.key(),
)?;
Expand Down
1 change: 0 additions & 1 deletion programs/monaco_protocol/src/state/trade_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub struct Trade {
pub purchaser: Pubkey,
pub market: Pubkey,
pub order: Pubkey,
pub opposite_trade: Pubkey,
pawel-betdex marked this conversation as resolved.
Show resolved Hide resolved
pub market_outcome_index: u16,
pub for_outcome: bool,
pub stake: u64,
Expand Down
8 changes: 0 additions & 8 deletions tests/protocol/crank_matching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ describe("Matching Crank", () => {
againstTrade.purchaser,
againstTrade.market,
againstTrade.order,
againstTrade.oppositeTrade,
againstTrade.marketOutcomeIndex,
againstTrade.forOutcome,
againstTrade.stake.toNumber(),
Expand All @@ -150,7 +149,6 @@ describe("Matching Crank", () => {
purchaser.publicKey,
market.pk,
againstOrderPk,
forTradePk,
1,
false,
integerStake,
Expand All @@ -162,7 +160,6 @@ describe("Matching Crank", () => {
forTrade.purchaser,
forTrade.market,
forTrade.order,
forTrade.oppositeTrade,
forTrade.marketOutcomeIndex,
forTrade.forOutcome,
forTrade.stake.toNumber(),
Expand All @@ -172,7 +169,6 @@ describe("Matching Crank", () => {
purchaser.publicKey,
market.pk,
forOrderPk,
againstTradePk,
1,
true,
integerStake,
Expand Down Expand Up @@ -272,7 +268,6 @@ describe("Matching Crank", () => {
againstTrade.purchaser,
againstTrade.market,
againstTrade.order,
againstTrade.oppositeTrade,
againstTrade.marketOutcomeIndex,
againstTrade.forOutcome,
againstTrade.stake.toNumber(),
Expand All @@ -283,7 +278,6 @@ describe("Matching Crank", () => {
purchaserB.publicKey,
market.pk,
againstOrderPk,
forTradePk,
1,
false,
integerStake,
Expand All @@ -296,7 +290,6 @@ describe("Matching Crank", () => {
forTrade.purchaser,
forTrade.market,
forTrade.order,
forTrade.oppositeTrade,
forTrade.marketOutcomeIndex,
forTrade.forOutcome,
forTrade.stake.toNumber(),
Expand All @@ -307,7 +300,6 @@ describe("Matching Crank", () => {
purchaserA.publicKey,
market.pk,
forOrderPk,
againstTradePk,
1,
true,
integerStake,
Expand Down