pub enum ContractAction {
Deploy {
code: Vec<u8>,
gas_limit: u64,
},
Call {
contract: Hash32,
input: Vec<u8>,
value: u64,
gas_limit: u64,
},
PoolCreate {
token: Hash32,
block_amt: u64,
token_amt: u64,
gas_limit: u64,
},
PoolAdd {
token: Hash32,
block_amt: u64,
token_max: u64,
gas_limit: u64,
},
PoolRemove {
token: Hash32,
shares: u64,
gas_limit: u64,
},
PoolSwapBuy {
token: Hash32,
block_in: u64,
min_token_out: u64,
gas_limit: u64,
},
PoolSwapSell {
token: Hash32,
token_in: u64,
min_block_out: u64,
gas_limit: u64,
},
}Expand description
A Blockle VM action carried by a transaction. Gas is prepaid: consensus
requires fee >= gas_limit * gas_price, whether or not execution
succeeds or uses less.
Variants§
Deploy
Store code as a new contract. The contract id is derived from the
deploying txid.
Call
Execute a deployed contract. value moves from this transaction’s
inputs into the contract’s balance before execution (refunded to the
sender if the call fails).
PoolCreate
Native AMM — create a BLOCK/token pool seeded with block_amt BLOCK
(from inputs) and token_amt of the BLOCK-20 token (from the sender’s
token balance). LP shares lock for one week.
PoolAdd
Add liquidity at the current ratio: block_amt BLOCK plus up to
token_max of the token. Re-locks the position for one week.
PoolRemove
Withdraw shares of LP (BLOCK paid out, token credited). Fails if the
position is still within its one-week lock.
PoolSwapBuy
Swap block_in BLOCK (from inputs) for the token; reverts (refund) if
the output would be below min_token_out.
PoolSwapSell
Swap token_in of the token for BLOCK (paid out); no-op if the output
would be below min_block_out.