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

Fix trade null price_structure error #627

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/lib/trade-executor/state/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

export type PrimaryKey = number;
export type PrimaryKey = `${number}`;

export type UnixTimestamp = number;

Expand All @@ -31,9 +31,9 @@ export type Percent = number;
* Used to differetiate different position types in UI logic
*/
export enum PositionKind {
open,
closed,
frozen
open = 'open',
closed = 'closed',
frozen = 'frozen'
}

export interface AssetIdentifier {
Expand Down Expand Up @@ -95,7 +95,7 @@ export interface TradeExecution {
executed_price: USDollarPrice;
executed_quantity: TokenUnits;

price_structure: PriceStructure;
price_structure: PriceStructure | null;

lp_fees_paid?: USDollarValue;
lp_fees_estimated: USDollarValue;
Expand Down
3 changes: 3 additions & 0 deletions src/params/integer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function match(param): param is `${number}` {
return /^\d+$/.test(param);
}
2 changes: 1 addition & 1 deletion src/params/momentum.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function match(param) {
export function match(param): param is 'daily-up' | 'daily-down' {
return ['daily-up', 'daily-down'].includes(param);
}
4 changes: 3 additions & 1 deletion src/params/positionStatus.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function match(param) {
import type { PositionKind } from 'trade-executor/state/interface';

export function match(param): param is PositionKind {
return ['open', 'closed', 'frozen'].includes(param);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<tbody>
<tr>
<td>Mid</td>
<td>{formatPrice(trade.price_structure.mid_price)}</td>
<td>{formatPrice(trade.price_structure?.mid_price)}</td>
<td />
</tr>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { TradeExecution } from 'trade-executor/state/interface.js';
import { error } from '@sveltejs/kit';

export async function load({ params, parent }) {
const tradeId = params.trade;
const { breadcrumbs, position } = await parent();

const trade = position.trades[tradeId];

if (!trade) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fetchPublicApi } from '$lib/helpers/public-api';

export async function load({ params, fetch }) {
const direction: 'up' | 'down' = params.direction === 'daily-up' ? 'up' : 'down';
const direction = params.direction.split('-')[1] as 'up' | 'down';

const data = await fetchPublicApi(fetch, 'top-momentum');

Expand Down
Loading