Skip to content

Commit 1aebfc8

Browse files
committed
set initialTick
1 parent 7f7d97a commit 1aebfc8

File tree

6 files changed

+151
-120
lines changed

6 files changed

+151
-120
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/_common/form.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { UseFormReturn } from "react-hook-form";
22
import * as z from "zod";
33
import { addressSchema, socialUrlsSchema } from "../../_common/schema";
4+
import { getInitialTickValue, isValidTickValue } from "../utils/calculate-tick";
45

56
export const tokenInfoFormSchema = z.object({
67
chain: z.string().min(1, "Chain is required"),
@@ -34,11 +35,22 @@ export const tokenDistributionFormSchema = z.object({
3435
),
3536
// UI states
3637
airdropEnabled: z.boolean(),
37-
directSale: z.object({
38+
market: z.object({
3839
currencyAddress: addressSchema,
3940
priceAmount: priceAmountSchema,
4041
}),
41-
publicMarket: z.object({
42+
pool: z.object({
43+
startingPricePerToken: priceAmountSchema.refine((value) => {
44+
const numValue = Number(value);
45+
if (numValue === 0) {
46+
return false;
47+
}
48+
const tick = getInitialTickValue({
49+
startingPricePerToken: Number(value),
50+
});
51+
52+
return isValidTickValue(tick);
53+
}, "Invalid price"),
4254
tradingFees: z.enum(["0.01", "0.05", "0.3", "1"]),
4355
}),
4456
saleAllocationPercentage: z.string().refine(
@@ -53,7 +65,7 @@ export const tokenDistributionFormSchema = z.object({
5365
message: "Must be a number between 0 and 100",
5466
},
5567
),
56-
saleMode: z.enum(["direct-sale", "public-market", "disabled"]),
68+
saleMode: z.enum(["market", "pool", "disabled"]),
5769
supply: z.string().min(1, "Supply is required"),
5870
});
5971

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/create-token-page-impl.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { parseError } from "@/utils/errorParser";
2929
import { createTokenOnUniversalBridge } from "../_apis/create-token-on-bridge";
3030
import type { CreateAssetFormValues } from "./_common/form";
3131
import { CreateTokenAssetPageUI } from "./create-token-page.client";
32+
import { getInitialTickValue } from "./utils/calculate-tick";
3233

3334
export function CreateTokenAssetPage(props: {
3435
accountAddress: string;
@@ -70,12 +71,16 @@ export function CreateTokenAssetPage(props: {
7071
chain: defineChain(Number(formValues.chain)),
7172
client: props.client,
7273
launchConfig:
73-
formValues.saleMode === "public-market" && saleAmount !== 0
74+
formValues.saleMode === "pool" && saleAmount !== 0
7475
? {
7576
config: {
7677
amount: BigInt(saleAmount),
77-
fee: Number(formValues.publicMarket.tradingFees) * 10000, // TODO - fix in SDK
78-
// initialTick (floorPrice) : disabled for now
78+
fee: Number(formValues.pool.tradingFees) * 10000, // TODO - fix in SDK
79+
initialTick: getInitialTickValue({
80+
startingPricePerToken: Number(
81+
formValues.pool.startingPricePerToken,
82+
),
83+
}),
7984
}, // public
8085
kind: "pool",
8186
}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/create-token-page.client.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,20 @@ export function CreateTokenAssetPageUI(props: {
7575
airdropAddresses: [],
7676
// airdrop
7777
airdropEnabled: false,
78-
directSale: {
78+
market: {
7979
currencyAddress: checksummedNativeTokenAddress,
8080
priceAmount: "0.1",
8181
},
82-
publicMarket: {
82+
pool: {
83+
startingPricePerToken: "0.01",
8384
tradingFees: "1",
8485
},
8586
// sale fieldset
8687
saleAllocationPercentage: "0",
8788
saleMode: "disabled",
8889
supply: "1000000",
8990
},
91+
mode: "onChange",
9092
resolver: zodResolver(tokenDistributionFormSchema),
9193
reValidateMode: "onChange",
9294
});
@@ -100,7 +102,7 @@ export function CreateTokenAssetPageUI(props: {
100102
onChainUpdated={() => {
101103
// if the chain is updated, set the sale token address to the native token address
102104
tokenDistributionForm.setValue(
103-
"directSale.currencyAddress",
105+
"market.currencyAddress",
104106
checksummedNativeTokenAddress,
105107
);
106108
}}

0 commit comments

Comments
 (0)