Contract 3d3f79e97dbe76b1f8fbe2095ddcd03738ff9988ec74ec9d9fb47bf8c661694f

← Back to Index 📥 Download WASM

Meta

binver 0.1.0
cliver 25.1.0#
rssdkver 23.4.1#e671b396f8bacf1370925f722df158b31c0baae5
rsver 1.92.0

Interface

fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
    operator: soroban_sdk::Address,
)

Updates the default fee rate applied to campaign creation

Arguments

  • caller - Address calling the function (must be governor or guardian)
  • default_fees - New default fee rate in base 10^9

Notes

  • Only callable by governor or guardian
  • Fee rate must be less than BASE_9 (100%)
fn set_fees(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    default_fees: i128,
) -> Result<(), soroban_sdk::Error>

Returns the terms and conditions message

Returns

  • Option<String> - The message, or None if not set
fn get_message(env: soroban_sdk::Env) -> Option

Updates the terms and conditions that users must accept before creating campaigns

Arguments

  • caller - Address calling the function (must be governor or guardian)
  • message - New terms and conditions message text

Notes

  • Only callable by governor or guardian
  • Automatically computes and stores the keccak256 hash
  • The message may be a link to the full terms hosted offchain
fn set_message(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    message: soroban_sdk::String,
) -> Result<(), soroban_sdk::Error>

Returns the original parameters of a campaign

Arguments

  • campaign_id - ID of the campaign to retrieve

Returns

  • CampaignParameters - Campaign parameters as originally created

Notes

  • Returns original parameters even if the campaign has been overridden
fn get_campaign(
    env: soroban_sdk::Env,
    campaign_id: soroban_sdk::BytesN<32>,
) -> Result

Withdraws accumulated protocol fees to a specified address

Arguments

  • caller - Address calling the function (must be governor)
  • tokens - Array of token addresses to withdraw fees from
  • to - Address that will receive the withdrawn fees

Notes

  • Only callable by governor
  • Transfers the entire balance of each token held by the contract
fn recover_fees(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    tokens: soroban_sdk::Vec,
    to: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Initializes the contract with access control, distributor, and default fees

Arguments

  • access_control_manager - Address of the access control manager contract
  • distributor - Address of the Distributor contract
  • default_fees - Default fee rate in base 10^9 (must be less than BASE_9)
fn __constructor(
    env: soroban_sdk::Env,
    access_control_manager: soroban_sdk::Address,
    distributor: soroban_sdk::Address,
    default_fees: i128,
) -> Result<(), soroban_sdk::Error>

Returns the fee rebate for a specific user

Arguments

  • user - The user address to query

Returns

  • i128 - The fee rebate percentage for the user in base 10^9
fn get_fee_rebate(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128

Returns the array index of a campaign in the campaign list

Arguments

  • campaign_id - ID of the campaign to look up

Returns

  • u32 - Zero-based index of the campaign in the campaignList array

Notes

  • Reverts if the campaign does not exist
fn campaign_lookup(
    env: soroban_sdk::Env,
    campaign_id: soroban_sdk::BytesN<32>,
) -> Result

Creates a new reward distribution campaign

Arguments

  • caller - Address creating the campaign
  • new_campaign - Parameters defining the campaign structure and rewards

Returns

  • BytesN<32> - Unique identifier for the newly created campaign

Notes

  • Campaigns with invalid formatting may not be processed by the reward engine, potentially losing rewards
  • Reward tokens must be whitelisted and amounts must exceed the token-specific minimum threshold
  • Reverts if the sender has not accepted the terms and conditions via accept_conditions()
fn create_campaign(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_campaign: CampaignParameters,
) -> Result, soroban_sdk::Error>

Returns the Distributor contract address

Returns

  • Address - The Distributor contract address
fn get_distributor(env: soroban_sdk::Env) -> soroban_sdk::Address

Creates multiple reward distribution campaigns in a single transaction

Arguments

  • caller - Address creating the campaigns
  • campaigns - Array of campaign parameters to create

Returns

  • Vec<BytesN<32>> - Array of campaign IDs for all newly created campaigns
fn create_campaigns(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    campaigns: soroban_sdk::Vec,
) -> Result>, soroban_sdk::Error>

Returns the default fee rate

Returns

  • i128 - The default fee rate in base 10^9
fn get_default_fees(env: soroban_sdk::Env) -> i128

Returns the hash of the terms and conditions

Returns

  • Option<BytesN<32>> - The message hash, or None if not set
fn get_message_hash(env: soroban_sdk::Env) -> Option>

Allows a user to accept Merkl's terms and conditions to enable campaign creation

Arguments

  • caller - User accepting the conditions

Notes

  • If the conditions change (through set_message), users must accept again the new terms
  • If the messageHash is not set, it means that there are no conditions to accept
fn accept_conditions(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Returns a campaign from the campaign list by its array index

Arguments

  • array_index - The zero-based index in the campaign list

Returns

  • CampaignParameters - The campaign at the specified index

Notes

  • Returns the original campaign parameters even if overridden
fn get_campaign_list(
    env: soroban_sdk::Env,
    array_index: u32,
) -> Result

Returns the fee recipient address

Returns

  • Option<Address> - The fee recipient address, or None if not set
fn get_fee_recipient(env: soroban_sdk::Env) -> Option

Returns the complete list of all reward tokens (including those no longer whitelisted)

Returns

  • Vec<Address> - Array of all reward token addresses
fn get_reward_tokens(env: soroban_sdk::Env) -> soroban_sdk::Vec

Updates parameters of an existing campaign while preserving core immutable fields

Arguments

  • caller - Address requesting the override (must be creator or authorized operator)
  • campaign_id - ID of the campaign to override
  • new_campaign - New campaign parameters (some fields will be ignored or validated)

Notes

  • Cannot change rewardToken, amount, or creator address
  • Can only update startTimestamp if the campaign has not yet started
  • New end time (startTimestamp + duration) must be in the future
  • The Merkl engine validates override correctness; invalid overrides are ignored
  • In the case of an invalid override, the campaign may not be processed and fees may still be taken by the Merkl engine
fn override_campaign(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    campaign_id: soroban_sdk::BytesN<32>,
    new_campaign: CampaignParameters,
) -> Result<(), soroban_sdk::Error>

Sets campaign-type-specific fee rates that override the default fee

Arguments

  • caller - Address calling the function (must be governor or guardian)
  • campaign_type - Type identifier for the campaign
  • fees - Fee rate for this campaign type in base 10^9

Notes

  • Only callable by governor or guardian
  • Set fee to 1 to effectively waive fees for a campaign type
  • Fee rate must be less than BASE_9 (100%)
fn set_campaign_fees(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    campaign_type: u32,
    fees: i128,
) -> Result<(), soroban_sdk::Error>

Updates the address that receives protocol fees from campaign creation

Arguments

  • caller - Address calling the function (must be governor)
  • fee_recipient - New fee recipient address

Notes

  • Only callable by governor
fn set_fee_recipient(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    fee_recipient: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Returns the total number of campaigns in the campaign list

Returns

  • u32 - The total count of campaigns
fn get_campaign_count(env: soroban_sdk::Env) -> u32

Returns the hash of the conditions a user has accepted

Arguments

  • user - The user address to query

Returns

  • Option<BytesN<32>> - The hash of accepted conditions, or None if user hasn't signed
fn get_user_signature(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> Option>

Computes the unique campaign ID for a given set of campaign parameters

Arguments

  • campaign - Campaign parameters to hash

Returns

  • BytesN<32> - Unique campaign ID derived from hashing key parameters

Notes

  • Campaign ID is computed as keccak256 of the campaign parameters
fn compute_campaign_id(
    env: soroban_sdk::Env,
    campaign: CampaignParameters,
) -> soroban_sdk::BytesN<32>

Extends the TTL of the contract instance, code, and key persistent entries

Notes

  • Callable by anyone — keeping the contract alive is a public good
  • Extends instance storage (which includes all Instance entries and the contract code)
  • Extends global persistent entries (RewardTokenCount, CampaignCount) that are shared across all users
  • Individual Campaign(i) and RewardToken(i) entries are extended when accessed
  • For bulk TTL extension of campaign entries, use extend_campaign_ttl_batch()
fn extend_contract_ttl(env: soroban_sdk::Env)

Returns the predeposited balance for a creator and reward token

Arguments

  • creator - The creator address to query
  • token - The reward token address to query

Returns

  • i128 - The predeposited balance amount
fn get_creator_balance(
    env: soroban_sdk::Env,
    creator: soroban_sdk::Address,
    token: soroban_sdk::Address,
) -> i128

Updates the Distributor contract address that receives and distributes rewards

Arguments

  • caller - Address calling the function (must be governor)
  • distributor - New Distributor contract address

Notes

  • Only callable by governor
fn set_new_distributor(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    distributor: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Sets a fee rebate for a specific user

Arguments

  • caller - Address calling the function (must be governor or guardian)
  • user - User address receiving the fee rebate
  • user_fee_rebate - Rebate amount in base 10^9

Notes

  • Only callable by governor or guardian
fn set_user_fee_rebate(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    user_fee_rebate: i128,
) -> Result<(), soroban_sdk::Error>

Returns whether an operator is authorized to create campaigns on behalf of a user

Arguments

  • user - The user address to query
  • operator - The operator address to query

Returns

  • bool - True if operator is authorized, false otherwise
fn get_campaign_operator(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    operator: soroban_sdk::Address,
) -> bool

Returns the override parameters for a campaign

Arguments

  • campaign_id - The campaign ID to query

Returns

  • Option<CampaignParameters> - The override parameters, or None if no override exists
fn get_campaign_override(
    env: soroban_sdk::Env,
    campaign_id: soroban_sdk::BytesN<32>,
) -> Option

Returns the allowance for an operator to spend a creator's predeposited tokens

Arguments

  • creator - The creator address to query
  • operator - The operator address to query
  • token - The reward token address to query

Returns

  • i128 - The allowance amount
fn get_creator_allowance(
    env: soroban_sdk::Env,
    creator: soroban_sdk::Address,
    operator: soroban_sdk::Address,
    token: soroban_sdk::Address,
) -> i128

Permanently disables contract upgradeability

fn revoke_upgradeability(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Decreases a user's predeposited token balance and transfers tokens out

Arguments

  • caller - Address requesting the withdrawal (must be user or governor)
  • user - Address whose balance will be decreased
  • reward_token - Token to withdraw
  • to - Address that will receive the withdrawn tokens
  • amount - Amount to withdraw

Notes

  • Only callable by the user themselves or a governor
fn decrease_token_balance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    reward_token: soroban_sdk::Address,
    to: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>

Increases a user's predeposited token balance for campaign funding

Arguments

  • caller - Address initiating the deposit
  • user - Address whose balance will be increased
  • reward_token - Token to deposit
  • amount - Amount to deposit

Notes

  • When called by a governor, the user must have sent tokens to the contract beforehand
  • Can be used to deposit on behalf of another user
  • WARNING: Do not use with any non strictly standard tokens (like rebasing tokens) as they will cause accounting issues
fn increase_token_balance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    reward_token: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>

Returns all whitelisted reward tokens and their minimum required amounts

Returns

  • Vec<RewardTokenAmount> - Array of reward tokens with their minimum amounts per epoch

Notes

  • Not optimized for onchain queries; intended for off-chain/API use
fn get_valid_reward_tokens(
    env: soroban_sdk::Env,
) -> Result, soroban_sdk::Error>

Decreases an operator's allowance to spend a user's predeposited tokens

Arguments

  • caller - Address reducing the allowance (must be user or governor)
  • user - User reducing the allowance
  • operator - Operator whose allowance is being reduced
  • reward_token - Token for which allowance is reduced
  • amount - Amount to decrease the allowance by

Notes

  • Only callable by the user themselves or a governor
fn decrease_token_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    operator: soroban_sdk::Address,
    reward_token: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>

Increases an operator's allowance to spend a user's predeposited tokens

Arguments

  • caller - Address granting the allowance (must be user or governor)
  • user - User granting the allowance
  • operator - Operator receiving spending permission
  • reward_token - Token for which allowance is granted
  • amount - Amount to increase the allowance by

Notes

  • Only callable by the user themselves or a governor
fn increase_token_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    operator: soroban_sdk::Address,
    reward_token: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>

Toggles an operator's authorization to create and manage campaigns on behalf of a user

Arguments

  • caller - Address toggling the authorization (must be user or governor)
  • user - User granting or revoking operator access
  • operator - Operator whose authorization is being toggled

Notes

  • Only callable by the user themselves or a governor
  • Toggles between authorized (1) and unauthorized (0)
fn toggle_campaign_operator(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    operator: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Toggles whether a user must sign the terms message before creating campaigns

Arguments

  • caller - Address calling the function (must be governor or guardian)
  • user - User address whose whitelist status is being toggled

Notes

  • Only callable by governor or guardian
  • Whitelisted users (status = 1) can create campaigns without accepting Merkl terms
fn toggle_signing_whitelist(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Extends TTL for a batch of campaign entries

Arguments

  • start - Start index (inclusive)
  • end - End index (exclusive)

Notes

  • Callable by anyone — keeping campaign data alive is a public good
  • With 100k campaigns, extending all TTLs requires multiple transactions due to the read limit per tx (~20 campaigns per batch)
fn extend_campaign_ttl_batch(env: soroban_sdk::Env, start: u32, end: u32)

Returns the reallocation target for a specific address within a campaign

Arguments

  • campaign_id - The campaign ID to query
  • from - The address whose rewards were reallocated

Returns

  • Option<Address> - The target address receiving the reallocated rewards, or None if no reallocation exists
fn get_campaign_reallocation(
    env: soroban_sdk::Env,
    campaign_id: soroban_sdk::BytesN<32>,
    from: soroban_sdk::Address,
) -> Option

Returns the AccessControlManager contract address

Returns

  • Address - The AccessControlManager contract address
fn get_access_control_manager(env: soroban_sdk::Env) -> soroban_sdk::Address

Returns the specific fee rate for a campaign type

Arguments

  • campaign_type - The campaign type identifier

Returns

  • Option<i128> - The fee rate for this campaign type, or None if using default fees
fn get_campaign_specific_fees(
    env: soroban_sdk::Env,
    campaign_type: u32,
) -> Option

Returns the minimum required amount for a reward token

Arguments

  • token - The reward token address to query

Returns

  • i128 - The minimum amount required per epoch, or 0 if token is not whitelisted
fn get_reward_token_min_amount(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
) -> i128

Reallocates unclaimed rewards from specific addresses to a new recipient after campaign ends

Arguments

  • caller - Address requesting the reallocation (must be creator or authorized operator)
  • campaign_id - ID of the completed campaign to reallocate from
  • froms - Array of addresses whose unclaimed rewards should be reallocated
  • to - Address that will receive the reallocated rewards

Notes

  • Can only be called after the campaign has ended (startTimestamp + duration has passed)
  • Reallocation validity is determined by the Merkl engine; invalid reallocations are ignored
fn reallocate_campaign_rewards(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    campaign_id: soroban_sdk::BytesN<32>,
    froms: soroban_sdk::Vec,
    to: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Returns whether a user is whitelisted from signature requirements

Arguments

  • user - The user address to query

Returns

  • bool - True if user is whitelisted, false otherwise
fn get_user_signature_whitelist(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> bool

Configures minimum reward amounts per epoch for whitelisted tokens

Arguments

  • caller - Address calling the function (must be governor or guardian)
  • tokens - Array of reward token addresses
  • amounts - Array of minimum amounts (0 = remove from whitelist, >0 = add/update)

Notes

  • Only callable by governor or guardian
  • Setting amount to 0 effectively removes the token from the whitelist
  • Prevents duplicate entries when adding previously removed tokens
fn set_reward_token_min_amounts(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    tokens: soroban_sdk::Vec,
    amounts: soroban_sdk::Vec,
) -> Result<(), soroban_sdk::Error>

Returns a paginated list of whitelisted reward tokens

Arguments

  • skip - Number of tokens to skip
  • first - Maximum number of tokens to return

Returns

  • Vec<RewardTokenAmount> - Array of reward tokens and their minimum amounts

Notes

  • Not optimized for onchain queries; intended for off-chain/API use
fn get_valid_reward_tokens_paged(
    env: soroban_sdk::Env,
    skip: u32,
    first: u32,
) -> Result, soroban_sdk::Error>

Returns all addresses from which rewards were reallocated for a campaign

Arguments

  • campaign_id - ID of the campaign

Returns

  • Vec<Address> - Array of addresses that had rewards reallocated away from them
fn get_campaign_list_reallocation(
    env: soroban_sdk::Env,
    campaign_id: soroban_sdk::BytesN<32>,
) -> Result, soroban_sdk::Error>

Returns whether upgradeability is deactivated

Returns

  • bool - True if upgradeability is deactivated, false otherwise
fn get_upgradeability_deactivated(env: soroban_sdk::Env) -> bool

Returns all timestamps when a campaign was overridden

Arguments

  • campaign_id - ID of the campaign

Returns

  • Vec<u64> - Array of block timestamps when overrides occurred
fn get_campaign_overrides_timestamp(
    env: soroban_sdk::Env,
    campaign_id: soroban_sdk::BytesN<32>,
) -> Result, soroban_sdk::Error>

Imports

WebAssembly Text (WAT) ▶