Introduction
The function allows LPs to provide liquidity to the pool. They receive pool tokens in exchange, based on the amount the transfer interactions hold. The process sends back the tokens in case the LP did not provide an equivalent value of tokens, unless the reserves are empty (in this case the LP sets the initial price)
Action
: "Provide"
The process function the action is calling
Handlers.add(
"provide",
Handlers.utils.hasMatchingTag("Action", "Provide"),
provide.provide
)
Transfer-A
: txID
Token A transfer interaction to the AMM process
-- transfer iteraction A
local transferAID = message.Tags["Transfer-A"]
Transfer-B
: txID
Token B transfer interaction to the AMM process
-- transfer interaction B
local transferBID = message.Tags["Transfer-B"]
This function lets users swap between two tokens.
Action
: "Swap"
The process function the action is calling
Handlers.add(
"swap",
Handlers.utils.hasMatchingTag("Action", "Swap"),
swap.swap
)
Transfer
: txID
The transfer interaction to the AMM process
Expected-Output
: integer
The expected quantity of tokens to swap for
-- expected output for slippage
local expectedOutput = tonumber(message.Tags["Expected-Output"])
Slippage-Tolerance
: float
(percentage)
The tolerated price difference between the expected output and the actual output. If the difference is larger, the swap fails.
-- slippage tolerance in %
local slippageTolerance = tonumber(message.Tags["Slippage-Tolerance"])
Pool
: address
ID of the AMM pool (must be the id of the AMM process)