primitivefinance / portfolio

Portfolio is an automated market making protocol for implementing custom strategies at the lowest cost possible.

Home Page:https://www.primitive.xyz/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Explore opcode for conditional checks

Alexangelj opened this issue · comments

Description

The contracts support calls directly via msg.sender. This is a problem for allocate because there is no parameter to enforce a lower bound on received liquidity. An opcode and internal function can be appended at the end to enforce these arbitrary checks and revert the entire jump instruction set if conditions like liquidity >= minLiquidity are not met.

There is some level of protection against sandwiches via the JIT defense mechanics, preventing atomic liquidity sandwiches.

That is one example - but there's many more conditional checks that are possible. For example, placing conditional checks around a swap could let you sandwich your own trade with logic.

An opcode could accept arbitrary values and store them in predefined state that can be used conditionally in the execution of the FVM instructions.

For example:

struct TransientState {
   address beneficiary;
}

The opcode could set an address for beneficiary. This variable could be used transiently in allocate to send position liquidity to a target address.