Contract 67891eb9f8845b16106e807f8d63330e8e92bbee4839517c022ae32bc2907c4f

← Back to Index 📥 Download WASM

Meta

desc Exchange your hard-earned KALE tokens for other, related vegetables.
rssdkver 22.0.7#211569aa49c8d896877dfca1f2eb4fe9071121c8
rsver 1.81.0
title KaleFail Trading Post
ver 1.1.0

Interface

Trade between KALE and some other, related vegetable.

Arguments

  • 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.

Panics

  • If the trading post is not open for business.
  • If the desired vegetable token is not in the list of available vegetables.
  • If the trading post contract does not have a high enough 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.

Arguments

  • 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.

Arguments

  • 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.

Panics

  • If the trading post is still open.
  • If the Wasm bytecode is not already installed 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.

Arguments

  • vegetables_to_add - A vector of vegetable asset contract addresses.

Panics

  • If a vegetable to be added is already available for trade.
  • If the trading post is open for trading, but the SAC admin of a provided vegetable contract is not the trading post contract address.
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.

Arguments

  • vegetables_to_remove - A vector of vegetable asset contract addresses.

Panics

  • If a vegetable to be removed is not already available for trade.
fn remove_vegetables(
    env: soroban_sdk::Env,
    vegetables_to_remove: soroban_sdk::Vec,
)

Increase the maximum number of vegetables available for trade.

Arguments

  • new_max_vegetables - The new maximum number of vegetables that can be available to trade.

Panics

  • If the existing maximum is greater than the provided new maximum.
  • If the existing maximum is equal to the provided new maximum. Why even bother then?
fn grow_shelf_space(env: soroban_sdk::Env, new_max_vegetables: u32)

Decrease the maximum number of vegetables available for trade.

Arguments

  • new_max_vegetables - The new maximum number of vegetables that can be available to trade.

Panics

  • If the existing maximum is less than the provided new maximum.
  • If the existing maximum is equal to the provided new maximum. Why even bother then?
  • If the number of available vegetables would be bigger than the new maximum.
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.

Panics

  • If there are no vegetable assets available for trade.
  • If one or more of the available vegetable assets does not have a SAC admin set to this trading post contract's address.
fn open(env: soroban_sdk::Env)

Close the trading post.

fn close(env: soroban_sdk::Env)

Donate a portion of the trading post's holdings to the LP effort

fn donate(env: soroban_sdk::Env)

Imports

WebAssembly Text (WAT) ▶