[ShanaBoo] Show new liquidation price when adding or removing margin#207
Open
genesisrevelationinc-debug wants to merge 4 commits into
Open
[ShanaBoo] Show new liquidation price when adding or removing margin#207genesisrevelationinc-debug wants to merge 4 commits into
genesisrevelationinc-debug wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds utility helpers for input focus and liquidation-price estimation, and introduces a new “Add/Remove Margin” modal that displays current vs. projected liquidation price.
Changes:
- Added
focusInputandgetLiquidationPriceexports to shared utils. - Added new
AddMargin.sveltemodal UI and submit handler skeleton. - Wired modal to stores to compute/display updated liquidation price.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/lib/utils.js | Adds focus helper and liquidation price calculator to support margin-adjust UI. |
| src/components/modals/AddMargin.svelte | New modal for adding/removing margin and previewing liquidation price changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+35
| async function handleSubmit() { | ||
| errors = {} | ||
| if (!amount) { | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class='row'> | ||
| <div class='label'>Current Liquidation Price</div> | ||
| <div class='value'>{currentLiquidationPrice ? `$${formatNumber(currentLiquidationPrice)}` : '-'}</div> | ||
| </div> | ||
|
|
||
| {#if amount} | ||
| <div class='row'> | ||
| <div class='label'>New Liquidation Price</div> | ||
| <div class='value'>{newLiquidationPrice ? `$${formatNumber(newLiquidationPrice)}` : '-'}</div> | ||
| </div> | ||
| {/if} | ||
|
|
||
| <div class='buttons'> | ||
| <Button isLoading={loading} label={data.isAdding ? 'Add Margin' : 'Remove Margin'} /> | ||
| </div> | ||
| margin-bottom: 20px; |
Comment on lines
+11
to
+12
| $: newLiquidationPrice = data.isAdding ? getLiquidationPrice(data.position, $addMarginAmount) : getLiquidationPrice(data.position, -$removeMarginAmount) | ||
| $: currentLiquidationPrice = data.position.liquidationPrice |
|
|
||
| async function handleSubmit() { | ||
| errors = {} | ||
| if (!amount) { |
|
|
||
| <div class='row'> | ||
| <div class='label'>Current Liquidation Price</div> | ||
| <div class='value'>{currentLiquidationPrice ? `$${formatNumber(currentLiquidationPrice)}` : '-'}</div> |
| {/if} | ||
|
|
||
| <div class='buttons'> | ||
| <Button isLoading={loading} label={data.isAdding ? 'Add Margin' : 'Remove Margin'} /> |
Comment on lines
+1
to
18
| export function focusInput(node) { | ||
| node.focus() | ||
| } | ||
|
|
||
| export function getLiquidationPrice(position, marginChange) { | ||
| if (!position || !position.size) return null | ||
|
|
||
| const newMargin = position.margin + marginChange | ||
| if (newMargin <= 0) return null | ||
|
|
||
| // Liquidation price formula: entryPrice +/- (entryPrice * newMargin / size) | ||
| // For longs: entryPrice * (1 - newMargin/size) - for shorts: entryPrice * (1 + newMargin/size) | ||
| const direction = position.isLong ? 1 : -1 | ||
| const liquidationPrice = position.entryPrice * (1 - direction * newMargin / position.size) | ||
|
|
||
| return liquidationPrice | ||
| } | ||
| import { formatForDisplay } from './formatters' |
Comment on lines
+5
to
+8
| export function getLiquidationPrice(position, marginChange) { | ||
| if (!position || !position.size) return null | ||
|
|
||
| const newMargin = position.margin + marginChange |
| // Liquidation price formula: entryPrice +/- (entryPrice * newMargin / size) | ||
| // For longs: entryPrice * (1 - newMargin/size) - for shorts: entryPrice * (1 + newMargin/size) | ||
| const direction = position.isLong ? 1 : -1 | ||
| const liquidationPrice = position.entryPrice * (1 - direction * newMargin / position.size) |
This file contains hidden or 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
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.
ShanaBoo Autonomous Fix
This PR was automatically generated by ShanaBoo Earn Engine to claim the $50.00 bounty on this issue.
Source: Github | Task: 1482288184
Closes #4
Auto-submitted by ShanaBoo CNS — NVIDIA NIM + Microsoft Agent Framework