diff --git a/apps/minifront/src/components/swap/asset-out-box.tsx b/apps/minifront/src/components/swap/asset-out-box.tsx
index fdf8241ca2..c3daf7b6a4 100644
--- a/apps/minifront/src/components/swap/asset-out-box.tsx
+++ b/apps/minifront/src/components/swap/asset-out-box.tsx
@@ -18,7 +18,7 @@ import { cn } from '@penumbra-zone/ui/lib/utils';
import { BalancesResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';
import { Amount } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/num/v1/num_pb';
-import { isZero } from '@penumbra-zone/types/src/amount';
+import { formatNumber, isZero } from '@penumbra-zone/types/src/amount';
import { getAmount } from '@penumbra-zone/getters/src/value-view';
const findMatchingBalance = (
@@ -56,33 +56,55 @@ export const AssetOutBox = ({ balances }: AssetOutBoxProps) => {
-
- {simulateOutResult ? (
-
- ) : (
-
- )}
-
-
-
-
-
-
-
+
+
+ {simulateOutResult ? (
+
+ ) : (
+
+ )}
+
+
+
+
+
+
+
+
+
+
);
};
-const Result = ({ result: { output, unfilled } }: { result: SimulateSwapResult }) => {
+// The price hit the user takes as a consequence of moving the market with the size of their trade
+const PriceImpact = ({ amount = 0 }: { amount?: number }) => {
+ // e.g .041234245245 becomes 4.123
+ const percent = formatNumber(amount * 100, { precision: 3 });
+
+ return (
+
+
Price impact:
+
{percent}%
+
+ );
+};
+
+const Result = ({ result: { output, unfilled, priceImpact } }: { result: SimulateSwapResult }) => {
// If no part unfilled, just show plain output amount (no label)
if (isZero(getAmount(unfilled))) {
- return
;
+ return (
+
+ );
}
// Else is partially filled, show amounts with labels
@@ -96,6 +118,7 @@ const Result = ({ result: { output, unfilled } }: { result: SimulateSwapResult }
Unfilled amount
+
);
};
diff --git a/apps/minifront/src/components/swap/asset-out-selector.tsx b/apps/minifront/src/components/swap/asset-out-selector.tsx
index e152666ae7..22ecc3c138 100644
--- a/apps/minifront/src/components/swap/asset-out-selector.tsx
+++ b/apps/minifront/src/components/swap/asset-out-selector.tsx
@@ -11,20 +11,18 @@ import {
ValueView,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { localAssets } from '@penumbra-zone/constants/src/assets';
-import { BalancesResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';
import { ValueViewComponent } from '@penumbra-zone/ui/components/ui/tx/view/value';
interface AssetOutSelectorProps {
- balances: BalancesResponse[];
assetOut: ValueView | undefined;
setAssetOut: (metadata: Metadata) => void;
}
/** @todo Refactor to use `SelectTokenModal` */
-export const AssetOutSelector = ({ balances, setAssetOut, assetOut }: AssetOutSelectorProps) => {
+export const AssetOutSelector = ({ setAssetOut, assetOut }: AssetOutSelectorProps) => {
return (