-
Notifications
You must be signed in to change notification settings - Fork 129
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(tradingapp): TradingApp nitro force move app #455
Draft
nksazonov
wants to merge
13
commits into
master
Choose a base branch
from
feat/nitro-trading-app
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What about: enum Action { OPEN, FUND, ORDER, TRADE, SETTLE, DEFUND, CLOSE }
struct Entry {
Action action;
uint256 timestamp; // The time the entry was created
bytes32 metadata; // The data/content of the entry
bytes32 parent; // Checksum of the previous entry
bytes32 current; // Checksum of the current entry
}
// current = keccak256(abi.encodePacked(action, timestamp, metadata, parent));
// Nitro validation:
// make a switch case on Action
// When OPEN: Verify both signed
// When FUND: Verify broker signed
// When ORDER: Verify Fund proof, and order is signed by Client
// When TRADE: Verify proof of order, verify parent is ORDER, signed by Broker
// When SETTLE: Verify proof of trade, verify parent is TRADE, signed by Both
|
Using Named structs: struct Order {
bytes32 parent; // Parent Event, can be 0 if first order
bytes32 orderID; // tradeID
}
struct Trade {
bytes32 orderID; // orderID making the trade
bytes32 tradeID; // tradeID
}
struct Outcome {
address token;
uint256 amount;
}
struct Settle {
Outcome[] toVault;
Outcome[] fromVault;
bytes32 parent; // Likely the last TradeID
}
|
* feat(contracts): add broker vault contract (WIP) * fix(contracts): init TradingApp in ctor * refactor(contracts): add underscore to performedSettlements mapping name to adhere code style * refactor(contracts): resolve review comments * refactor(contracts): handle edge case for balanceOf methods & use `require` instead of `if`s * refactor(contracts): add support for native assets in deposit and withdraw methods * fix(contracts): add nonReentract modifier on deposit, withdraw, and settle methods * refactor: split TradingApp to adhere 'one interface per file' rule * feat: verify full order history on settlement * fix: reverse conditions * fix(contracts): fix compiler errors and warnings * refactor: move a settlement proof validation to a separate function * feat: verify proof hash to avoid accepting modified proof * fix: proceed with order/response validation if settlement parsing fails * refactor: inline settlement decoding * refactor: rename proofHash settlement field to ordersChecksum; resolve review comments * refactor: rename `orderChecksum` field of settlement struct to plural form * fix: resolve review comments * refactor: process proofs in pairs on each iteration * refactor: move pre/post-fund check out of settlement verification loop to save gas * refactor: drop redundant verification --------- Co-authored-by: nksazonov <[email protected]>
mod
requested changes
Dec 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we start writing very basic tests?
contracts/clearing/TradingApp.sol
Outdated
} | ||
} | ||
|
||
// FIXME: should Vault support multiple brokers? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, only using multiple vaults
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.