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

Update wlth-bid-ask-ma-spread.rain #35

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

Conversation

TobyMeller
Copy link
Contributor

fix on inverted math

was sub/add in wrong direction

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs

stablerevertcondition stablerevert-amount
if(tokenrevertcondition tokenrevert-amount
if(stablecondition stable-amount
if(tokencondition token-amount max-value())
)
)
),

price:if(
Copy link
Contributor

Choose a reason for hiding this comment

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

Try replacing the price with the following segment:

mul1: mul(current-price 0.995),
mul2: mul(current-price 1.005),

price: conditions(
  stablerevertcondition mul1
  tokenrevertcondition mul2
  stablecondition mul2
  tokencondition mul1
  "default" max-value()
); 
  • The above should solve the problem of too many elements on stack, but probably will get that error if more elements were to be present on the stack. Perhaps try introducing more sources that do some of the calcs.
  • Also I'm not sure of the price calculation above is correct because current-price is only in one direction and hence mul1 and mul2 are also in the same direction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added and pushed. That gets past the truncation error.

I have put the "string" in at the end of the conditions. if I put Max Value and the direction is stable outgoing that could still go through? however if token outgoing it wont?

is there an issue there?

Copy link
Contributor

@Siddharth2207 Siddharth2207 Jul 23, 2024

Choose a reason for hiding this comment

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

No, if you put max-value as the default value if all conditions are false, it won't go through in either case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why is that? it still provides a price?

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.

2 participants