Skip to content

Commit

Permalink
Contract fix and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Braqzen committed Apr 14, 2024
1 parent fdca609 commit 8061538
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions market-contract/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,14 @@ impl Market for Contract {

// Determine which asset should be credited and debited
let (asset_1, asset_2) = match alice.asset_type == AssetType::Base {
true => (AssetType::Base, AssetType::Quote),
false => (AssetType::Quote, AssetType::Base),
true => match alice.order_type {
OrderType::Buy => (AssetType::Quote, AssetType::Base),
OrderType::Sell => (AssetType::Base, AssetType::Quote),
},
false => match alice.order_type {
OrderType::Buy => (AssetType::Base, AssetType::Quote),
OrderType::Sell => (AssetType::Quote, AssetType::Base),
},
};

alice_account.locked.debit(alice_account_delta, asset_1);
Expand Down Expand Up @@ -401,7 +407,7 @@ impl Market for Contract {
.get(bob.owner)
.insert(bob_id, storage.user_orders.get(bob.owner).len() - 1);

// TODO: event
// TODO: event
}

// If the target order has been fulfilled then finish processing batch
Expand Down Expand Up @@ -433,10 +439,10 @@ impl Market for Contract {

storage.orders.insert(alice_id, alice);
storage.user_orders.get(alice.owner).push(alice_id);
storage
.user_order_indexes
.get(alice.owner)
.insert(alice_id, storage.user_orders.get(alice.owner).len() - 1);
storage
.user_order_indexes
.get(alice.owner)
.insert(alice_id, storage.user_orders.get(alice.owner).len() - 1);
}

storage.account.insert(alice.owner, alice_account);
Expand Down

0 comments on commit 8061538

Please sign in to comment.