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

Validate Provider Token Max Order Amount Against Bucket Size #399

Open
chibie opened this issue Jan 23, 2025 · 12 comments · May be fixed by #421
Open

Validate Provider Token Max Order Amount Against Bucket Size #399

chibie opened this issue Jan 23, 2025 · 12 comments · May be fixed by #421

Comments

@chibie
Copy link
Contributor

chibie commented Jan 23, 2025

User Story
As a system operator, I want to ensure providers can't set token max order amounts that exceed our largest provision bucket size, to maintain consistent order handling across the platform.

Acceptance Criteria

  1. GIVEN a provider is updating a token's max order amount
    WHEN the amount converted to local currency exceeds the largest bucket size
    THEN the request is rejected with an appropriate error message

  2. GIVEN a provider is updating a token's max order amount
    WHEN the amount converted to local currency is within bucket limits
    THEN the update is successful

  3. GIVEN a provider is setting a token's max order amount
    WHEN their local currency has no provision buckets
    THEN the request is rejected with an appropriate error message

Tech Details

  • Update token validation in UpdateProviderProfile controller to:
    • Query provider's fiat currency and get its market rate
    • Query the largest provision bucket for that currency from the ProvisionBucket schema. e.g storage.Client.ProvisionBucket.Query().Where(provisionbucket.HasCurrencyWith(fiatcurrency.IDEQ(currency.ID))).Order(ent.Desc(provisionbucket.FieldMaxAmount)).First(ctx)
    • Calculate token max amount in local currency: tokenPayload.MaxOrderAmount.Mul(currency.MarketRate)
    • Compare calculated value against bucket max amount
    • Return error if no buckets found or if amount exceeds largest bucket
  • Add appropriate error message format for bucket size violations

Notes/Assumptions

  • Provision buckets are currency-specific
  • Market rate from FiatCurrency is up to date
  • MaxOrderAmount is in crypto amount
  • Bucket amounts are in local currency amount
  • Bucket sizes are pre-configured per currency

Open Questions

  • Should we add a buffer/margin below the max bucket size (e.g. 95% of bucket)?
  • How should we handle market rate fluctuations that might push amounts over bucket size?
@Amizeey
Copy link

Amizeey commented Jan 23, 2025

Could I take over this issue?

@jancris100
Copy link

Hey! I'm Jan.
Member of Dojo Coding. I have contributed before to other projects like:

• Dojo
Can I work on this issue?

@Supa-mega
Copy link

Can I be assigned to this? first time contributor

@caxtonacollins
Copy link

I'd like to take this issue.

@chibie
Copy link
Contributor Author

chibie commented Jan 28, 2025

@caxtonacollins are you working on this ticket?

@wengDavo
Copy link

Can I handle this task?

@Akshola00
Copy link

May I try my hand at this?
i have not contributed to this repo before and I will really love to contribute, please assign this task to me

@OthmanImam
Copy link

Can I handle this task?

@bernardev254
Copy link

’d love to work on this issue to ensure that providers cannot set token max order amounts beyond the largest provision bucket size. I will modify the UpdateProviderProfile controller to fetch the provider’s fiat currency and market rate, retrieve the largest provision bucket, convert the max order amount to local currency, and validate it against the bucket limits. Requests exceeding the limit or missing a provision bucket will return appropriate errors

@Emmy123222
Copy link

May I take this issue on?

@JuViquez
Copy link

JuViquez commented Feb 5, 2025

Can I take this issue?

@Elite-tch
Copy link

Can I jump on this task?

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