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

[ECO-2492] Calculate the swap price client-side #412

Merged
merged 11 commits into from
Nov 26, 2024
Prev Previous commit
Next Next commit
Lint
xbtmatt committed Nov 26, 2024
commit f47c883410c82678bf3f5b2f2099f64207b5a625
Original file line number Diff line number Diff line change
@@ -107,6 +107,7 @@ export default function SwapComponent({
numSwaps,
});

/* eslint-disable */
useEffect(() => {
console.dir(
{
@@ -126,6 +127,7 @@ export default function SwapComponent({
console.log("swap result from simulated swap data:", swapData?.swapResult);
console.log("net proceeds from client-side calculation", netProceeds);
}, [swapData, netProceeds]);
/* eslint-enable */

useEffect(() => {
const emojicoinType = toCoinTypes(marketAddress).emojicoin.toString();
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { INITIAL_REAL_RESERVES, INITIAL_VIRTUAL_RESERVES } from "@sdk/const";
import {
calculateSwapNetProceeds,
SwapNetProceedsArgs,
type SwapNetProceedsArgs,
SwapNotEnoughBaseError,
} from "@sdk/emojicoin_dot_fun/calculate-swap-price";
import { DatabaseModels } from "@sdk/indexer-v2/types";
import { AnyNumberString, Types } from "@sdk/types/types";
import { type DatabaseModels } from "@sdk/indexer-v2/types";
import { type AnyNumberString } from "@sdk/types/types";

/**
* This hook calls the client-side calculation of the swap net proceeds amount.