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

feat: add market creation #149

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

berteotti
Copy link
Contributor

@berteotti berteotti commented Dec 23, 2024

Adds support for binary market creation.

Create market route - https://feat-pgio-105-support-for-ma.presagio.pages.dev/create-market

Please create markets with "test" category.

Screenshot 2024-12-23 at 11 43 31

Copy link

cloudflare-workers-and-pages bot commented Dec 23, 2024

Deploying presagio with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8f1e587
Status: ✅  Deploy successful!
Preview URL: https://bbd809fd.presagio.pages.dev
Branch Preview URL: https://feat-pgio-105-support-for-ma.presagio.pages.dev

View logs

@berteotti berteotti marked this pull request as draft December 23, 2024 11:52
@berteotti berteotti force-pushed the feat/pgio-105-support-for-market-creation branch from d5dfb01 to ad358e0 Compare December 23, 2024 11:56
app/(main)/create-market/page.tsx Show resolved Hide resolved
app/(main)/create-market/page.tsx Outdated Show resolved Hide resolved
else setError(null);
}, [amount, category, dateTimeError, outcomes, percentagesError, question]);

const maxBalance = useCallback(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a significant benefit in wrapping all these state setters with the useCallback hook? I just tried to profile a bit this component page with and without these hooks, and by just removing the usage of useCallback we gain +8% perfo in Lighthouse

With the hooks in
Screenshot 2024-12-24 at 10 00 48 AM

Without the hooks
Screenshot 2024-12-24 at 11 06 01 AM

@ElRodrigote
Copy link
Contributor

Some things I'd like to see on the market creation flow (not necessarily all of them, but any combination of them):

  • The market creation modal should not be dismissed when we click on the modal backdrop: if the user misclicks on the backdrop they'll lose the context on the market creation flow/steps
  • A small stepper or something like that lets the user know how many signature/steps are done already and how many are missing. Maybe a 1/2/3/4 (step number) with a small description label beneath the step number, and then the number gets replaced with a spinner if we're waiting for its response. Something similar to what bridges do when using them:
    ask question > prepare condition > approve token > create market (create2FixedProductMarketMaker)
  • A toast/snackbar appearing when the whole process is done or to display an error if something fails (for now, as there's no error handling, the flow gets stuck if the user cancels a TX)
  • On market creation success, maybe a redirection to the specific market details or to the markets list filtered by the newly created market category so you can see the result of your action would be awesome.

@berteotti berteotti force-pushed the feat/pgio-105-support-for-market-creation branch from fd10e28 to 70d250e Compare December 30, 2024 11:52
@berteotti berteotti force-pushed the feat/pgio-105-support-for-market-creation branch from 70d250e to 8f1e587 Compare December 30, 2024 11:57
@berteotti berteotti marked this pull request as ready for review December 30, 2024 11:58
<p className="text-text-med-em">Outcomes</p>
<div className="space-y-2">
{outcomes.map((outcome, index) => (
<OutcomeInput
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this input has a bug where if you type anything outside numbers, you see a NaN displayed with the "Sum must equal 100%" error, but you can't delete the NaN so you're forced to refresh the page

It would be nice if we could force these two inputs to only take numbers between 1 and 99, and if you write a number in one, the other one gets autocompleted with the corresponding percentage (this way we could drop the "Sum must equal 100%" error (maybe)

@Diogomartf
Copy link
Contributor

can we change the route for /markets/create? This route is feels much better.

@Diogomartf
Copy link
Contributor

Diogomartf commented Jan 6, 2025

We can change title to only "Preview" it's simpler and does the job.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets change the folder structure to be /markets/create/page.tsx this will make the url without the slash, which is cleaner: /markets/create

In our case we already have the markets folder, we just need a create folder inside with page file.

}

//TODO create 2 different instances, 1 for token and other for outcomes
Copy link
Contributor

@Diogomartf Diogomartf Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we handle this comment on this PR? what's the idea here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should handle this in a new task. Will delete the comment and create a task.

@@ -0,0 +1 @@
export const KLEROS_ARBITRATOR_ADDRESS = '0xe40DD83a262da3f56976038F1554Fe541Fa75ecd';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we use constants file for this? I would not create a file just for this constant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also inside hooks, doesn't make sense for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's something contract related, I fill like it's on a good spot. It's related to contracts and it's related to kleros, so contracts/kleros makes sense for me. Having a bunch of different data inside the same constants folder, not sure if it's the best approach, since it's difficult to know what constants are inside that file. This way I can go through the folder structure and easily find data related to kleros contracts. What do you think about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems a bit confusing, but will let you decide, we can always change later if doesn't stick.

But why inside hooks folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's contract related stuff. But will move it from here

Comment on lines +1 to +4
export const REALITY_ETH_CONTRACT_ADDRESS = '0x79e32aE03fb27B07C89c0c568F80287C01ca2E57';
export const ORACLE_ADDRESS = '0xAB16D643bA051C11962DA645f74632d3130c81E2';
export const REALITY_ETH_TIMEOUT = 86400;
export const SINGLE_SELECT_TEMPLATE_ID = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have inside hooks?

Why all of the constants together in the same file ?

@Diogomartf
Copy link
Contributor

Diogomartf commented Jan 6, 2025

Some things I'd like to see on the market creation flow (not necessarily all of them, but any combination of them):

  • The market creation modal should not be dismissed when we click on the modal backdrop: if the user misclicks on the backdrop they'll lose the context on the market creation flow/steps
  • A small stepper or something like that lets the user know how many signature/steps are done already and how many are missing. Maybe a 1/2/3/4 (step number) with a small description label beneath the step number, and then the number gets replaced with a spinner if we're waiting for its response. Something similar to what bridges do when using them:
    ask question > prepare condition > approve token > create market (create2FixedProductMarketMaker)
  • A toast/snackbar appearing when the whole process is done or to display an error if something fails (for now, as there's no error handling, the flow gets stuck if the user cancels a TX)
  • On market creation success, maybe a redirection to the specific market details or to the markets list filtered by the newly created market category so you can see the result of your action would be awesome.

Agree on this, I just created a market and lost all the context.

To add on top of this:

After creating a market how can I check the markets I created?
There should be an easy way for this (same for the markets I added liquidity), we need.

  • My questions
  • My LP positions
    (maybe this should be inside 'my bets", although the name might need to change.

Also, how can I create a market? What's the current decision, to omit this for now?

I don't mind being out of scope of this PR, but we need to add a task to do this next.

Great job, the PR is good, we just need to fine tune things.

@Diogomartf
Copy link
Contributor

Diogomartf commented Jan 6, 2025

@berteotti
Copy link
Contributor Author

Agree on this, I just created a market and lost all the context.

We can redirect the user to the created market. What do you think?

  • My questions
  • My LP positions

I think we need a path to see created markets, maybe in the same page you can see created markets and LP'd ones.

Also, how can I create a market? What's the current decision, to omit this for now?

Currently there is no button on the navbar, I think we need to figure out how to organize the navbar to fit all the links. I would hide it for now and we can add it later.

@berteotti
Copy link
Contributor Author

what is templated_id?

template_id is the question template id, which defines how to write and read the question text.

I don't see any relevant docs talking about it, but you can see something here https://reality.eth.limo/app/docs/html/dapp_links.html?highlight=template#specifying-the-question-template

@Diogomartf
Copy link
Contributor

Agree on this, I just created a market and lost all the context.

We can redirect the user to the created market. What do you think?

  • My questions
  • My LP positions

I think we need a path to see created markets, maybe in the same page you can see created markets and LP'd ones.

Also, how can I create a market? What's the current decision, to omit this for now?

Currently there is no button on the navbar, I think we need to figure out how to organize the navbar to fit all the links. I would hide it for now and we can add it later.

I think redirect to the market works.

I'm okay with not having the lists for my LP, and created markets but would be nice to create a task for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants