CURRENTLY IN TESTNET — Should be updated when in mainnet
The burn interaction consists of various processes. Let’s take a closer inspection at the processes within burn.lua
which is responsible for swapping.
Quantity Validation
We validate the quantity of tokens to be burned is a valid token quantity based on assigned burn quantity:
-- burn quantity
local quantity = tonumber(message.Tags.Quantity)
-- validate quantity
arweave.TokenQuantity:assert(quantity)
Balance Check
The user initiating the burn needs to have a balance greater than or equal to the quantity of tokens they intend to burn:
-- validate if the user has enough tokens
assert(Balances[message.From] ~= nil, "No balance for this user")
assert(Balances[message.From] >= quantity, "Not enought tokens to burn")
Pool Liquidity Check
We need to make sure that the specific quantity of tokens assigned to burn will not drain the entire liquidity pool:
-- make sure the LP does not burn the total supply,
-- as this action would drain the pool
local totalSupply = balances.totalSupply()
assert(quantity < totalSupply, "This action would drain the pool")
Burn Ratio Calculation
The ratio of tokens to be burned relative to the total supply in the liquidity pool:
$burnRatio = \\frac{quantity}{totalSupply}$
local burnRatio = quantity / totalSupply