Introduction

PowerPool has proposed grant funding to a team that will create automatically executed limit orders on top of Balancer. The limit order comes down creating a Job in PowerAgent network automatically executing swapExactAmountIn method for preliminary selected token_in and token_out based on the current spot price condition.

The product should act as a smart contract factory, allowing users to create a specific job with specific parameters with a single click, deploy it, and add it to the network for further execution.

The successful application would have an existing project who:

General Components

The PowerAgent network consists of a set of independent agent nodes (keepers). A core contract (PowerAgent contract, or Agent) stores the information about all registered keepers and all submitted tasks (or jobs).

A Job is a data structure (stored inside the Agent) which represents the target of execution and conditions for execution.

Jobs may be of three types:

Interval jobs (”execute a function of a given contract once every $T$  seconds).

Predefined Calldata - interval jobs with custom predefined calldata (”execute a function (passing calldata) of a given contract , once every $T$ seconds”).

Resolver jobs - jobs with execution logic defined on-chain. These jobs rely on smart contracts - resolvers, which implement a function which tells whether a job should be executed or not at a given block. The resolver job thus can be formulated as ”execute a function (passing calldata_) of a given contract, when the resolver function returns (true, calldata_)”

Limit Orders as Resolver Jobs

The third type is the most flexible one. Given any information existing on-chain, one may construct a resolver of arbitrary complexity to define any conditions which render the task executable.

This can be especially valuable in relation to the DeFi and operations on decentralized exchanges. An abstract task reading “perform this action if (and only if) these conditions are satisfied”, or, alternatively, “when these conditions are satisfied, then (and only then) perform this action”.

A limit order may be considered as a Task of the following kind:

Buy $A$ amount of token $t$ when the market price $P_\tau$ satisfies the following inequality: $P_\tau ≤ P_{max}$ where $P_{max}$ is the maximal buy price;

Sell $A$ amount of of token $t$ when the market price $P_\tau$ satisfies the following inequality:

$P_\tau \geq P_{min}$, where $P_{min}$ is the minimal sell price;

A general limit order may be described as: