AleoSwap is a decentralized exchange (DEX) built on the Aleo blockchain, utilizing the Uniswap mechanism. It leverages the unique features of the Aleo blockchain to offer enhanced privacy and new functionalities to both the DEX and its users.
We are currently undergoing rapid iteration. Some of the optimizations and new features may require Aleo(snarkVM, aleo lang) to provide additional features and support before they can be implemented.
Learn more about the project:
- AleoSwap Program
- TOC
- Deployment
- Functions
- create_token
- transfer
- approve
- transfer_from
- transfer_to_private
- transfer_to_public
- transfer_privately
- join
- create_pair
- create_pair_privately
- add_liquidity
- add_liquidity_privately
- remove_liquidity
- remove_liquidity_privately
- wrap_private_credits
- wrap_public_credits
- unwrap
- handle_unwrap_to_private
- handle_unwrap_to_public
- swap_exact_tokens_for_tokens
- swap_exact_private_for_public
- swap_exact_private_for_private
- swap_exact_public_for_private
- swap_tokens_for_exact_tokens
- swap_private_for_exact_public
- swap_private_for_exact_private
- swap_public_for_exact_private
- token_faucet
- set_token_faucet
- change_token_admin
- Public States
create_token
is used to create a new token.
Function:
create_token(public info: TokenInfo)
Params:
-
info: TokenInfo
: a struct including token name, symbol, decimals and total_supplystruct TokenInfo { name: field, symbol: field, decimals: u8, total_supply: u128, admin: address, }
-
We need to convert
name
andsymbol
string directly to bytes array and then to field (integer) type. e.g.USDT -> 1431520340field
. -
The admin can perform some special operations on the token, like
set_token_faucet
.
Command:
# Create a new token: name=USDT, symbol=USDT, decimals=6, total_supply=1e8*1e6, admin=$admin_addr
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id create_token "{name: 1431520340field, symbol: 1431520340field, decimals: 6u8, total_supply: 100000000000000u128, admin: $admin_addr}"
transfer
is used to transfer public tokens.
- It is similar to the ERC20 transfer, but with an additional
token_id
parameter.
Function:
transfer(public token_id: field, public to: address, public amount: u128)
Params:
token_id: field
: the token id to be transferredto: address
: the receiver addressamount: u128
: amount of tokens to be transferred
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id transfer 1field $to_address 100000000u128
approve
is used to authorize other accounts to spend tokens.
- It is similar to the ERC20 approve, but with an additional
token_id
parameter.
Function:
approve(public token_id: field, public spender: address, public amount: u128)
Params:
token_id: field
: the token id to be approvedspender: address
: the spender addressamount: u128
: the maximum amount that the spender can spend
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id approve 1field $spender 10000000000u128
transfer_from
is used to transfer public tokens from other accounts.
- It is similar to the ERC20 transfer_from, but with an additional
token_id
parameter.
Function:
transfer_from(public token_id: field, public from: address, public to: address, public amount: u128)
Params:
token_id: field
: the token id to be transferredfrom: address
: the address of the account from which the token is transferredto: address
: the receiver addressamount: u128
: amount of tokens to be transferred
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id transfer_from 1field $from_addr $to_addr 100000000u128
transfer_to_private
is used to transfer and convert public tokens to a new private token record (PrivateToken).
Function:
transfer_to_private(public token_id: field, private to: address, public amount: u128) -> PrivateToken
Params:
-
token_id: field
: the token id to be transferred -
to: address
: the receiver address -
amount: u128
: amount of tokens to be transferred and converted -
Output 1 PrivateToken record: a new PrivateToken record with the following structure:
record PrivateToken { // The token owner owner: address, // The token id token: field, // The token amount amount: u128, }
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id transfer_to_private 1field $to_addr 100000000u128
transfer_to_public
is used to transfer and convert a private token record (PrivateToken
) to public tokens.
Function:
transfer_to_public(private pt_in: PrivateToken, public to: address, public amount: u128) -> PrivateToken
Params:
pt_in: PrivateToken
: the PrivateToken record to be spentto: address
: the receiver addressamount: u128
: amount of tokens to be transferred and converted- Output 1 PrivateToken record: it is a new PrivateToken record (owned by the caller) with an amount of
pt_in.amount - amount
.
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id transfer_to_public $private_token_record $to_addr 10000000u128
transfer_privately
is used to transfer private tokens (PrivateToken
records).
Function:
transfer_privately(private pt_in: PrivateToken, private to: address, private amount: u128) -> (PrivateToken, PrivateToken)
Params:
pt_in: PrivateToken
: the PrivateToken record to be spentto: address
: the receiver addressamount: u128
: amount of tokens to be transferred- Output 2 PrivateToken records: the first belongs to the receiver(
to
), the second is a change belonging to the caller
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id transfer_privately $private_token_record $to_addr 50000000u128
join
is used to merge two PrivateToken
records into a new PrivateToken
record.
- The two records being joined must have the same owner and the token id.
Function:
join(private pt1: PrivateToken, private pt2: PrivateToken) -> PrivateToken
Params:
pt1: PrivateToken
: the PrivateToken record to be spentpt2: PrivateToken
: the PrivateToken record to be spent- Output 1 PrivateToken record: the new record with an amount of
pt1.amount + pt2.amount
.
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id join $private_token_record_1 $private_token_record_2
create_pair
is used to create a new pair and add initial liquidity.
- A pair must be created through this function (or
create_pair_privately
) before subsequent liquidity and swap operations can be performed. - Each pair is also a standard token (called liquidity pool token or LP token) created automatically when the pair is created,
and its token_id is the same as pair_id:
lp_token_id = pair_id = bhp256_hash({token_a: field, token_b: field})
. - This function can only be used to add initial liquidity, further liquidity additions require calling the
add_liquidity
function. - The caller's token_a and token_b will be transferred to the program, and LP tokens will be minted to the
to
address.
Function:
create_pair(
public token_a: field,
public token_b: field,
public amount_a: u128,
public amount_b: u128,
public to: address
)
Params:
token_a: field
: the token with the smaller token idtoken_b: field
: the token with the larger token idamount_a: u128
: the amount oftoken_a
to be added as the initial liquidityamount_b: u128
: the amount oftoken_b
to be added as the initial liquidityto: address
: the address to receive the LP tokens
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id create_pair 1field 2field 100000000u128 10000000000u128 $to_addr
create_pair_privately
is used to create a new pair and add initial liquidity privately.
Function:
transition create_pair_privately(
private pt_a: PrivateToken,
private pt_b: PrivateToken,
public amount_a: u128,
public amount_b: u128,
private to: address,
public liquidity: u128,
) -> (PrivateToken, PrivateToken, PrivateToken)
Params:
pt_a: PrivateToken
: the PrivateToken record oftoken_a
to be spentpt_b: PrivateToken
: the PrivateToken record oftoken_b
to be spent, requirept_a.token < pt_b.token
amount_a: u128
: the amount oftoken_a
to be added as the initial liquidityamount_b: u128
: the amount oftoken_b
to be added as the initial liquidityto: address
: the address to receive the private LP tokensliquidity: u128
: the amount of LP token to add initially- Output 3
PrivateToken
records:- the output LP token owned by
to
- the change of
pt_a
owned by caller - the change of
pt_b
owned by caller
- the output LP token owned by
add_liquidity
is used to add liquidity to a pair.
- The caller's
token_a
andtoken_b
will be transferred to the program, and LP tokens will be minted to theto
address.
Function:
add_liquidity(
public token_a: field,
public token_b: field,
public amount_a: u128,
public amount_b: u128,
public min_a: u128,
public min_b: u128,
public to: address
)
Params:
token_a: field
: the token with the smaller token idtoken_b: field
: the token with the larger token id, requiretoken_a < token_b
amount_a: u128
: the max amount oftoken_a
to be addedamount_b: u128
: the max amount oftoken_b
to be addedmin_a: u128
: the min amount oftoken_a
to be addedmin_b: u128
: the min amount oftoken_b
to be addedto: address
: the address to receive the LP tokens
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id add_liquidity 1field 2field 100000000u128 10000000000u128 0u128 0u128 $to_addr
add_liquidity_privately
is used to add liquidity to a pair privately.
Function:
transition add_liquidity_privately(
private pt_a: PrivateToken,
private pt_b: PrivateToken,
public amount_a: u128,
public amount_b: u128,
public min_a: u128,
public min_b: u128,
public min_liquidity: u128,
private to: address,
public refund_to: address,
) -> (PrivateToken, PrivateToken, PrivateToken)
Params:
-
pt_a: PrivateToken
: the PrivateToken record oftoken_a
to be spent -
pt_b: PrivateToken
: the PrivateToken record oftoken_b
to be spent, requirept_a.token < pt_b.token
-
amount_a: u128
: the max amount oftoken_a
to be added -
amount_b: u128
: the max amount oftoken_b
to be added -
min_a: u128
: the min amount oftoken_a
to be added -
min_b: u128
: the min amount oftoken_b
to be added -
min_liquidity: u128
: the min amount of LP token to receive -
refund_to: address
: the address to receive the refunded LP token publicly -
Output 3
PrivateToken
records:- the output LP token owned by
to
- the change of
pt_a
owned by caller - the change of
pt_b
owned by caller
- the output LP token owned by
remove_liquidity
is used to remove liquidity from a pair.
- The caller's LP tokens will be burned,
token_a
andtoken_b
will be transferred to theto
address.
Function:
remove_liquidity(
public token_a: field,
public token_b: field,
public liquidity: u128,
public min_a: u128,
public min_b: u128,
public to: address,
)
Params:
token_a: field
: the token with the smaller token idtoken_b: field
: the token with the larger token idliquidity: u128
: the amount of lP token to removemin_a: u128
: the min amount oftoken_a
to be removedmin_b: u128
: the min amount oftoken_b
to be removedto: address
: the address to receive thetoken_a
andtoken_b
tokens
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id remove_liquidity 1field 2field 1000000000u128 0u128 0u128 $to_addr
remove_liquidity
is used to remove liquidity from a pair privately.
Function:
transition remove_liquidity_privately(
public token_a: field,
public token_b: field,
private pt_lp: PrivateToken,
public liquidity: u128,
public min_a: u128,
public min_b: u128,
private to: address,
public refund_to: address,
) -> (PrivateToken, PrivateToken, PrivateToken)
Params:
token_a: field
: the token with the smaller token idtoken_b: field
: the token with the larger token idpt_lp: PrivateToken
: the PrivateToken record of LP token to be spentliquidity: u128
: the amount of LP token to removemin_a: u128
: the min amount oftoken_a
to be removedmin_b: u128
: the min amount oftoken_b
to be removedto: address
: the address to receive thetoken_a
andtoken_b
tokensrefund_to: address
: the address to receive the remainingtoken_a
andtoken_b
publicly- Output 3
PrivateToken
records:- the output
token_a
record owned byto
- the output
token_b
record owned byto
- the change of
pt_lp
owned by caller
- the output
wrap_private_credits
is used to wrap private aleo credits into WALEO tokens (the token-0).
- The wrapper function performs a
1:1
exchange between Aleo micro-credits and WALEO token. - In this way, we can introduce aleo credits into our DeFi world. The user can always convert WALEO tokens back into aleo credits by unwrapping.
Function:
wrap_private_credits(
private input: credits.leo/credits,
public to: address,
public amount: field,
public holder: address
) -> (credits.leo/credits)
Params:
input: credits
: the aleo credits record to be wrappedto: address
: the address to receive the WALEO tokensamount: field
: amount of micro-credits to be wrappedholder: address
: the address to hold the wrapped aleo credits. It must be the admin of WALEO token (token-0) for safety.- Output 1 credits record: it is the change for the caller
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id wrap_private_credits $input_record $to_addr 10000000field $holder_addr
wrap_private_credits
is used to wrap public aleo credits into WALEO tokens (the token-0).
- It is similar to the
wrap_private_credits
, except the wrapped aleo credits is public.
Function:
transition wrap_public_credits(
public to: address,
public amount: field,
public holder: address
)
Params:
to: address
: the address to receive the WALEO tokensamount: field
: amount of micro-credits to be wrappedholder: address
: the address to hold the wrapped aleo credits. It must be the admin of WALEO token (token-0) for safety.
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id wrap_public_credits $to_addr 10000000field $holder_addr
unwrap
is used to unwrap WALEO tokens into aleo credits.
- The unwrapped WALEO tokens will be burned, and a pending
UnwrapItem
will be created.
Function:
unwrap(public to: address, public amount: field, public into_private: bool)
Params:
to: address
: the address to receive aleo creditsamount: field
: amount of micro-credits to be unwrappedinto_private: bool
: unwrap into private or public aleo credits
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id unwrap $to_addr 10000000field true
handle_unwrap_to_private
is used to handle a pending unwrap item, transferring private credits to the user.
Function:
handle_unwrap_to_private(public index: u64, public to: address, public amount: field) -> credits.leo/credits
Params:
index: u64
: the index of theUnwrapItem
to: address
: the address to receive aleo creditsamount: field
: amount of micro-credits to be transferred
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id handle_unwrap_to_private 0u64 $to_addr 10000000field
handle_unwrap_to_public
is used to handle a pending unwrap item, transferring public credits to the user.
Function:
handle_unwrap_to_public(public index: u64, public to: address, public amount: field)
Params:
index: u64
: the index of theUnwrapItem
to: address
: the address to receive aleo creditsamount: field
: amount of micro-credits to be transferred
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id handle_unwrap_to_public 1u64 $to_addr 10000000field
swap_exact_tokens_for_tokens
is used to exchange a fixed amount of input tokens for a variable amount of output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_exact_tokens_for_tokens(
public token_in: field,
public token_out: field,
public amount_in: u128,
public amount_out_min: u128,
public to: address,
)
Params:
token_in: field
: the input token idtoken_out: field
: the output token idamount_in: u128
: the fixed amount of input tokenamount_out_min: u128
: the minimum amount of output token expected to receiveto: address
: the address to receive the output tokens
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id swap_exact_tokens_for_tokens 1field 2field 1000000u128 98000000u128 $to_addr
swap_exact_private_for_public
is used to exchange a fixed amount of private input tokens for a variable amount of public output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_exact_private_for_public(
private pt_in: PrivateToken,
public token_out: field,
public amount_in: u128,
public amount_out_min: u128,
public to: address,
) -> (PrivateToken)
Params:
pt_in: PrivateToken
: the PrivateToken record to be spenttoken_out: field
: the output token idamount_in: u128
: the fixed amount of input tokenamount_out_min: u128
: the minimum amount of output token expected to receiveto: address
: the address to receive the output tokens- Output 1
PrivateToken
record: it is a new PrivateToken record (owned by the caller) with an amount ofpt_in.amount - amount_in
.
swap_exact_private_for_private
is used to exchange a fixed amount of private input tokens for a variable amount of private output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_exact_private_for_private(
private pt_in: PrivateToken,
public token_out: field,
public amount_in: u128,
public amount_out_min: u128,
private to_pri: address,
public to_pub: address,
) -> (PrivateToken, PrivateToken)
Params:
pt_in: PrivateToken
: the PrivateToken record to be spenttoken_out: field
: the output token idamount_in: u128
: the fixed amount of input tokenamount_out_min: u128
: the minimum amount of output token expected to receiveto_pri: address
: the address to receiveamount_out_min
of output tokens privatelyto_pub: address
: the address to receive the remaining output tokens publicly- Output 2
PrivateToken
records: the first belongs to the receiver(to_pri
), the second is a change and belongs to the caller
swap_exact_public_for_private
is used to exchange a fixed amount of public input tokens for a variable amount of private output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_exact_public_for_private(
public token_in: field,
public token_out: field,
public amount_in: u128,
public amount_out_min: u128,
private to_pri: address,
public to_pub: address,
) -> (PrivateToken) {
Params:
token_in: field
: the input token idtoken_out: field
: the output token idamount_in: u128
: the fixed amount of input tokenamount_out_min: u128
: the minimum amount of output token expected to receiveto_pri: address
: the address to receiveamount_out_min
of output tokens privatelyto_pub: address
: the address to receive the remaining output tokens publicly- Output 1
PrivateToken
records: it is a new PrivateToken record (owned byto_pri
) with an amount ofamount_out_min
.
swap_tokens_for_exact_tokens
is used to exchange a variable amounts of input token for a fixed amount of output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_tokens_for_exact_tokens(
public token_in: field,
public token_out: field,
public amount_in_max: u128,
public amount_out: u128,
public to: address,
)
Params:
token_in: field
: the input token idtoken_out: field
: the output token idamount_in_max: u128
: the maximum amount of input token originally intended to be spentamount_out: u128
: the fixed amount of output tokento: address
: the address to receive the output tokens
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id swap_tokens_for_exact_tokens 2field 1field 50000000u128 500000u128 $to_addr
swap_private_for_exact_public
is used to exchange a variable amount of private input tokens for a fixed amount of public output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_private_for_exact_public(
private pt_in: PrivateToken,
public token_out: field,
public amount_in_max: u128,
public amount_out: u128,
public to: address,
public refund_to: address,
) -> (PrivateToken)
Params:
pt_in: PrivateToken
: the PrivateToken record to be spent, with an amount greater than or equal toamount_in_max
token_out: field
: the output token idamount_in_max: u128
: the maximum amount of input token originally intended to be spentamount_out: u128
: the fixed amount of output tokento: address
: the address to receive the public output tokensrefund_to: address
: the address to receive the refunded input token publicly- Output 1
PrivateToken
records: it is a new PrivateToken record (owned by the caller) with an amount ofpt_in.amount - amount_in_max
.
swap_private_for_exact_private
is used to exchange a variable amount of private input tokens for a fixed amount of private output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_private_for_exact_private(
private pt_in: PrivateToken,
public token_out: field,
public amount_in_max: u128,
public amount_out: u128,
private to_pri: address,
public refund_to: address,
) -> (PrivateToken, PrivateToken)
Params:
pt_in: PrivateToken
: the PrivateToken record to be spent, with an amount greater than or equal toamount_in_max
token_out: field
: the output token idamount_in_max: u128
: the maximum amount of input token originally intended to be spentamount_out: u128
: the fixed amount of output tokento_pri: address
: the address to receive the private output tokensrefund_to: address
: the address to receive the refunded input token publicly- Output 2
PrivateToken
records: the first belongs to the receiver(to_pri
), the second is a change and belongs to the caller
swap_public_for_exact_private
is used to exchange a variable amount of public input tokens for a fixed amount of private output tokens.
- Slippage can be adjusted through the parameters.
- Each swap call will charge a fee of
0.3%
.
Function:
swap_public_for_exact_private(
public token_in: field,
public token_out: field,
public amount_in_max: u128,
public amount_out: u128,
private to_pri: address,
) -> (PrivateToken){
Params:
token_out: field
: the input token idtoken_out: field
: the output token idamount_in_max: u128
: the maximum amount of input token originally intended to be spentamount_out: u128
: the fixed amount of output tokento_pri: address
: the address to receive the private output tokens- Output 1
PrivateToken
records: the first belongs to the receiver(to_pri
), the second is a change and belongs to the caller - Output 1
PrivateToken
records: it is a new PrivateToken record (owned byto_pri
) with an amount ofamount_out
.
token_faucet
is used to obtain some tokens from the token's faucet for free.
- The faucet is used to facilitate users to get test tokens, it only exists in the test network.
Function:
token_faucet(public token_id: field, public to: address)
Params:
token_id: field
: the id of the tokento: address
: the receiver address
Command:
snarkos developer execute -q $rpc_url -b $broadcast_url -p $private_key -r $fee_record \
$program_id token_faucet 1field $to_addr
set_token_faucet
is used to configure the faucet amount of the token.
- Only the token's admin can successfully perform this operation.
- The faucet is used to facilitate users to get test tokens, it only exists in the test network.
Function:
set_token_faucet(public token_id: field, public amount: u128)
Params:
token_id: field
: the id of the tokenamount: u128
: the amount of tokens the user can receive each time callingtoken_faucet
. Set to 0 to turn off faucet.
change_token_admin
is used to change the token's admin address.
- Only the token's admin can successfully perform this operation.
Function:
change_token_admin(public token_id: field, public admin: address)
Params:
token_id: field
: the id of the tokenadmin: address
: the new admin address. It can be set to a special address to renounce administrator permissions.
balances
stores the balances of all tokens and all accounts.
- mapping:
key: field => balance: u128
- key:
key = bhp256_hash({token: field, user: address})
- the token id of an LP token is the same as its pair id
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/balances/$key
allowance
stores authorization data (approve
) of all tokens and all accounts.
- mapping:
key: field => amount: u128
- key:
key = bhp256_hash({token: field, payer: address, spender: address})
- the token id of an LP token is the same as its pair id
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/allowance/$key
tokens
stores meta info (TokenInfo
) of all tokens.
-
mapping:
token_id: field => info: TokenInfo
-
the token id of an LP token is the same as its pair id
-
TokenInfo
is a structure as follows:struct TokenInfo { name: field, symbol: field, decimals: u8, total_supply: u128, admin: address, }
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/tokens/$token_id
faucets
stores faucet configs of all tokens.
- mapping:
token_id: field => faucet_amount: u128
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/faucets/$token_id
pairs
stores the info of all pairs.
-
mapping:
pair_id: field => pair: Pair
-
pair_id
is a hash:pair_id = bhp256_hash({token_a: field, token_b: field})
,token_a
andtoken_b
are the token ids of the two tokens that make up the pair, requiringtoken_a < token_b
. -
Pair
is a structure as follows:struct Pair { reserve_a: u128, reserve_b: u128, }
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/pairs/$pair_id
global_state
stores the global state.
-
mapping:
true: bool => state: GlobalState
-
GlobalState
is a structure as follows:struct GlobalState { next_token_id: field, admin: address, }
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/global_state/true
wrap_state
stores the state of WALEO (Wrapped Aleo) functions.
-
mapping:
true: bool => state: WrapState
-
WrapState
is a structure as follows:struct WrapState { // total count of unwraps unwrap_count: u64, // total amount of pending unwraps total_pending_amount: u128, // max operation fee for each unwrap unwrap_fee: u128, }
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/wrap_state/true
unwraps
stores all the WALEO unwrapping history (pending or handled).
-
mapping:
index: u64 => item: UnwrapItem
-
UnwrapItem
is a structure as follows:struct UnwrapItem { // receiver address to: address, // amount of aleo micro-credits amount: u128, // fee to the operator for handling the unwrapping fee: u128, // to private or public credits is_private: bool, // pending or handled is_pending: bool, }
Query command:
curl $aleoRpc/testnet3/program/swap.aleo/mapping/unwraps/$index
xborys_