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

trader view precompile #181

Open
wants to merge 14 commits into
base: isolated-margin
Choose a base branch
from
Open

trader view precompile #181

wants to merge 14 commits into from

Conversation

asquare08
Copy link

Why this should be merged

Trader View Precompile to read trader account data.

  • The new precompile has been generated in accordance with juror refactor in this PR.
  • Generated with
cd contracts && \
npx solcjs --abi contracts/hubble-v2/interfaces/ITraderViewer.sol && \
mv contracts_hubble-v2_interfaces_ITraderViewer_sol_ITraderViewer.abi ITraderViewer.abi &&
cd ../ && ./scripts/generate_precompile.sh --abi ./contracts/ITraderViewer.abi --type TraderViewer --pkg traderviewer

@asquare08 asquare08 changed the title New precompile trader view precompile Mar 18, 2024
plugin/evm/orderbook/hubbleutils/data_structures.go Outdated Show resolved Hide resolved
plugin/evm/orderbook/hubbleutils/data_structures.go Outdated Show resolved Hide resolved
plugin/evm/orderbook/hubbleutils/data_structures.go Outdated Show resolved Hide resolved
precompile/contracts/bibliophile/amm.go Outdated Show resolved Hide resolved
Comment on lines 211 to 214
func getRequiredMargin(stateDB contract.StateDB, baseAsset *big.Int, price *big.Int, marketId int64, trader *common.Address) *big.Int {
quoteAsset := hu.Div1e18(hu.Mul(hu.Abs(baseAsset), price))
return getRequiredMarginForQuote(stateDB, GetMarketAddressFromMarketID(marketId, stateDB), trader, quoteAsset)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yo keep it consistent with the structure in contracts, how about moving this function to traderViewer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah kept it here to avoid code duplication in juror and traderView but I see your point. moved it to traderViewer

precompile/contracts/bibliophile/clearing_house.go Outdated Show resolved Hide resolved
precompile/contracts/bibliophile/clearing_house.go Outdated Show resolved Hide resolved
precompile/contracts/traderviewer/viewer.go Outdated Show resolved Hide resolved
precompile/contracts/bibliophile/clearing_house.go Outdated Show resolved Hide resolved
precompile/contracts/jurorv2/matching_validation.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants