Trade between KALE and some other, related vegetable.
customer - The address of a customer making the trade.vegetable - The SAC address of the vegetable which should be traded
against KALE.amount - The amount of tokens (in stroops) which should be exchanged
between the customer and the trading post.buy_kale - Whether or not the customer should receive KALE or the
other vegetable.KALE
balance to send to the customer (if buying KALE).fn trade(
env: soroban_sdk::Env,
customer: soroban_sdk::Address,
vegetable: soroban_sdk::Address,
amount: i128,
buy_kale: bool,
)
Initializes the trading post and sets things up to begin further configuration.
owner - The address which will be the owner and administrator of the
trading post.kale - The address of the KALE asset contract.vegetables - (optional) A vector of assets that will be available
for trading.max_vegetables - (optional) The maximum number of vegetables that
should be available to trade. Defaults to 4.fn __constructor(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
kale: soroban_sdk::Address,
vegetables: Option>,
max_vegetables: Option,
)
Upgrade the contract's Wasm bytecode. The trading post must be closed before invoking this function.
new_wasm_hash - Hash identifier for the bytecode that should be
henceforth used by this contract. The bytecode must already be
installed and present on-chain.fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Add more vegetables which will be available to trade for using KALE
tokens.
vegetables_to_add - A vector of vegetable asset contract addresses.fn add_vegetables(
env: soroban_sdk::Env,
vegetables_to_add: soroban_sdk::Vec,
)
Remove vegetables so they will no longer be available to trade for using
KALE tokens.
vegetables_to_remove - A vector of vegetable asset contract
addresses.fn remove_vegetables(
env: soroban_sdk::Env,
vegetables_to_remove: soroban_sdk::Vec,
)
Increase the maximum number of vegetables available for trade.
new_max_vegetables - The new maximum number of vegetables that can
be available to trade.fn grow_shelf_space(env: soroban_sdk::Env, new_max_vegetables: u32)
Decrease the maximum number of vegetables available for trade.
new_max_vegetables - The new maximum number of vegetables that can
be available to trade.fn shrink_shelf_space(env: soroban_sdk::Env, new_max_vegetables: u32)
Open the trading post for business. The trading post is closed by default, so this function will need to be invoked before trading can begin.
fn open(env: soroban_sdk::Env)
Close the trading post.
fn close(env: soroban_sdk::Env)
The airdrop changed from 500x to 501x, which left the trading post with a small surplus of KALE. Let's burn it to balance out the sKALEs.
fn burn_the_extra_kale(env: soroban_sdk::Env)