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

Feature Request: Adding if-else Condition Support for Job Creations #72

Open
0x7183 opened this issue Oct 14, 2023 · 9 comments
Open

Feature Request: Adding if-else Condition Support for Job Creations #72

0x7183 opened this issue Oct 14, 2023 · 9 comments

Comments

@0x7183
Copy link

0x7183 commented Oct 14, 2023

BIG Labs is interested in contributing to Warp Contracts by adding the ability to use if-else conditions when creating jobs.
We would like to discuss the technical aspects and implementation details with the Warp Contracts development team.

@dev8723
Copy link
Contributor

dev8723 commented Oct 14, 2023

@0x7183 can you give a job example of using if else?

@0x7183
Copy link
Author

0x7183 commented Oct 14, 2023

@llllllluc following some examples:

  1. A Grid bot using warp
  2. Most of the trading strategies
  3. Handling of errors in sub messages

@dev8723
Copy link
Contributor

dev8723 commented Oct 14, 2023

@llllllluc following some examples:

  1. A Grid bot using warp
  2. Most of the trading strategies
  3. Handling of errors in sub messages

sorry i mean job example where the condition needs if else, can you write some sudo code to help me better understand? the more detail the better maybe use grid bot as example

@0x7183
Copy link
Author

0x7183 commented Oct 14, 2023

With a grid bot we need to buy or sell an asset based on the price.

Right now there isn't a way to implement it using only warp.

We'll require a job for the buy message with the buy condition and a job with for the sell message with the sell condition.
Also when a job is triggered we have to delete the other one and create a new buy and sell message updating the parameters based on the last message.

What we need is something like that in pseudo code:

If buy:
buy msg
else if sell:
sell msg
else:
pass

Sorry for the formatting, but I'm from phone and is pretty late here.

If this isn't enough I'll provide more details tomorrow!

@dev8723
Copy link
Contributor

dev8723 commented Oct 15, 2023

I see, this is a nice feature we should support, it's like having 2 condition field and 2 msgs fields, if cond 1 resolves to true, then execute msgs 1, if cond 2 resolves to true, then execute msgs 2, if both resolves to false, then do nothing, but what if both resolve to true? I'm trying to think of an elegant way to implement this. Maybe you can bring this up in warp telegram, and let @vladjdk and @simke9445 chime in.

@dev8723
Copy link
Contributor

dev8723 commented Oct 15, 2023

when a job is triggered we have to delete the other one and create a new buy and sell message updating the parameters based on the last message.

I think this is already supported by the recurring job, where you can update var every time it executes (recurring job is after you execute, it will create a new one)

@0x7183
Copy link
Author

0x7183 commented Oct 15, 2023

@vladjdk told us to open an issue on Github and discuss there the implementation details, if you're ok with it we can start working at it and make a PR at the end.

Just what is the main branch?

@dev8723
Copy link
Contributor

dev8723 commented Oct 15, 2023

awesome! the pre release branch is in #67, looking forward to the PR!

@simke9445
Copy link
Contributor

Cool idea, me and @vladjdk were discussing this on several occasions, and its great that you guys took a hand of it.

Ideally this would work very similar to a switch statement.

Job would look like this:

  • cA && tA
  • cB && tB
  • cC && tC
    • c - condition
    • t - set of transactions

in your case:

  • cA = buy condition
  • tA = buy tx
  • cB = sell condition
  • tB = sell tx
  • cA and cB can be simple static var conditions, aka "state" == "buy" | "sell", where state var is kept in job's memory.

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

No branches or pull requests

3 participants