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

Permissioned pools #83

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

Conversation

Luivatra
Copy link

@Luivatra Luivatra commented Nov 7, 2024

This PR introduces the concept of "condition pools".

A condition pool allows for the pool creator to define a condition that needs to be fulfilled for any action to be taken on the pool. To avoid assets becoming stuck liquidity withdrawals are always allowed. A simple example would be a pool that only allows trades to happen between 9 am to 5 pm.

Validators

Pool

The same as the current pool validator, but with added condition logic. The process_orders logic is extended to also keep track of whether all orders are withdrawals or not. If a condition is defined in the pool datum and not all orders are withdrawals we check for the presence of the condition script in the transaction withdrawal scripts.

Conditions

Condition validators are located in the validators/conditions folder.

Trading Hours

Simple condition that requires the transactions validity range to be within a certain window (defined in the pool's condition_datum).

Permissioned

The pool will have a list of supported compliance oracles and using this verifies that each order has a valid compliance token in their datum. This compliance token consists of unique data for this order, including order details and owner and a signature provided by the compliance oracle.

Types

Pool Datum

Has been extended with:

  • condition: Some
  • condition_datum: Some

Condition refers to the withdrawal validator that needs to be present. The condtion_datum holds variables required for the functionality in the condition script.

TradingHoursDatum

Holds the open and close time where trading is allowed.

PermissionedDatum

List of Public key hashes for the compliance oracles supported by this pool

TokenData

  • The users DID Identifier
  • The users public key
  • The destination address
  • Blake2b-256 hash of the cbor serialized details from the order
  • A valid range
  • The public key of the oracle

ComplianceToken

  • TokenData instance

  • A signature from the compliance oracle for serialised token data

  • Tests to cover negative cases and withdrawal only

  • Check condition manage logic (is it in scope?)

Copy link
Contributor

@rrruko rrruko left a comment

Choose a reason for hiding this comment

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

Looks good, just a few minor observations

validators/conditions/permissioned.ak Outdated Show resolved Hide resolved
lib/types/conditions/permissioned.ak Outdated Show resolved Hide resolved
validators/pool.ak Outdated Show resolved Hide resolved
lib/calculation/process.ak Show resolved Hide resolved
@Luivatra Luivatra marked this pull request as ready for review December 12, 2024 10:23
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