DO NOTE: The standards for tokens can change, which we should account for.

A token is an ao process that has a table representing the balances of Arweave wallets.

-- user balances
-- it is a good practice to keep the balances table as a global variable (hence the capital initial)
Balances = {
	--[[
	an address is a string consisting of exactly 43 characters. these can 
	be numbers, letters (case-sensitive!), as well as "-" and "_"
	the user balance is an integer/whole number
	(tokens can support fractional balances with their own mechanisms)
	]]--
	["ljvCPN31XCLPkBo9FUeB7vAK0VC6-eY52-CS-6Iho8U"] = 1000,
	["psh5nUh3VF22Pr8LeoV1K2blRNOOnoVH0BbZ85yRick"] = 23345
}

Optionally a token can have any other fields in its state. Most commonly the following are used:

-- token symbol/ticker (balances are usually represented with the ticker next to them)
Ticker = "ARDRIVE"

-- token name
Name = "ArDrive"

-- token description
Description = ""

-- token fractions
Denomination = 10 ^ 12

-- token logo
Logo = "txID"

-- Making these values global is not a requirement, but it's also good practice

The AMM front-end/user interface might display these values for ease of use, but they should not be required to remain minimalist.

Standard functions

Apart from the fields above, a token should support some core functionalities, which will be referred as standards. These functions are imperative and the AMM is not usable without them.

The transfer function allows the AMM front-end to initiate token allocations for the users from their own balances. This lets the AMM receive tokens for order-making by moving the required quantity from the user’s balance to the AMM’s.

The credit notice message is sent by a token after a successful transfer to the recipient. This is important because it signals the AMM process about the incoming transfer, so it store it for later use (swap/liquidity provide).

-- Send Credit-Notice to the Recipient
    ao.send({
      Target = target,
      Action = "Credit-Notice",
      Sender = message.From,
      Quantity = tostring(quantity)
    })

Implementation in the AMM

The AMM process can also be considered a token and as such, it implements the standards for tokens defined above. We utilize token functionalities to allow LPs to receive fees for swaps (paid out in pool tokens).