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

Add a special 'Self' destination variant #62

Merged
merged 7 commits into from
Mar 6, 2024
Merged

Conversation

Quantumplation
Copy link
Member

We want to allow recurring automated strategies that can execute in multiple stages.

The idea behind this was to allow setting the destination back to the order script with a "strategy" order details.

However, this overlooks the fact that this would require setting a destination datum hash. This means that our order executions would have a finite depth.

So, this commit adds a new variant to the Destination, which enforces that the results of the swap are paid back to the same address, with the same datum.

Thus, we could construct the order datum:

OrderDatum {
  pool_ident: ...,
  owner: ...,
  max_protocol_fee: ...,
  destination: Self,
  details: Strategy { ... },
  extension: ...
}

and the output order datum will be... the same thing.

Some notes:

  • We make sure it's the second variant, which should mean that it doesn't change the offchain code
  • This doesn't make a whole lot of sense for any other variant; should we only allow it for strategies? Unless the auditors come up with a problem, I don't see a reason to restrict it.

We want to allow recurring automated strategies that can execute in
multiple stages.

The idea behind this was to allow setting the destination back to the
order script with a "strategy" order details.

However, this overlooks the fact that this would require setting a
destination datum hash. This means that our order executions would have
a finite depth.

So, this commit adds a new variant to the Destination, which enforces
that the results of the swap are paid back to the *same address, with
the same datum*.

Thus, we could construct the order datum:
```
OrderDatum {
  pool_ident: ...,
  owner: ...,
  max_protocol_fee: ...,
  destination: Self,
  details: Strategy { ... },
  extension: ...
}
```

and the output order datum will be... the same thing.

Some notes:
 - We make sure it's the *second* variant, which should mean that it
   doesn't change the offchain code
 - This doesn't make a whole lot of sense for any other variant; should
   we only allow it for strategies? Unless the auditors come up with a
   problem, I don't see a reason to restrict it.
@Quantumplation Quantumplation changed the base branch from pi/script-strategies to main March 5, 2024 22:12
lib/calculation/donation.ak Show resolved Hide resolved
lib/calculation/process.ak Outdated Show resolved Hide resolved
@Quantumplation Quantumplation merged commit 618f457 into main Mar 6, 2024
1 check passed
@Quantumplation Quantumplation deleted the pi/self-destination branch March 6, 2024 01:03
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