Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

ITTUnlockerSafeDispatcherTrait

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait

Part of the group: dispatchers

pub trait ITTUnlockerSafeDispatcherTrait<T>

Trait functions

create_preset

Creates an unlocking schedule Preset.

Arguments

  • preset_id: Refer to Preset.
  • linear_start_timestamps_relative: Refer to Preset.
  • linear_start_timestamps_relative: Refer to Preset.
  • linear_bips: Refer to Preset.
  • num_of_unlocks_for_each_linear: Refer to Preset.
  • stream: Refer to Preset.
  • recipient_id: Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.

Panics

  • INVALID_PRESET_FORMAT: If the preset is not formatted correctly (e.g. linear_bips fails to add up to BIPS_PRECISION)
  • PRESET_EXISTS: If the input preset_id has already been created.
  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • PresetCreated

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::create_preset

fn create_preset(
    self: T,
    preset_id: felt252,
    linear_start_timestamps_relative: Span<u64>,
    linear_end_timestamp_relative: u64,
    linear_bips: Span<u64>,
    num_of_unlocks_for_each_linear: Span<u64>,
    stream: bool,
    recipient_id: u64,
    extraData: felt252,
) -> Result<(), Array<felt252>>

create_actual

Creates an unlocking schedule Actual.

Arguments

  • recipient: The initial recipient of the unlocked tokens.
  • preset_id: The unlocking schedule preset that this Actual builds on top of.
  • start_timestamp_absolute: Refer to Actual.
  • amount_skipped: Refer to Actual.
  • total_amount: Refer to Actual.
  • unsafe_mint: Use mint(...) instead of safe_mint(...).
  • recipient_id: Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.
  • batch_id: Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.

Panics

  • PRESET_DOES_NOT_EXIST: If preset_id does not exist.
  • INVALID_SKIP_AMOUNT: If the amount of tokens skipped is greater than or equal to the total unlocked amount.
  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • ActualCreated

Returns

  • u256: The created actual_id, aka the unlocking schedule ID.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::create_actual

fn create_actual(
    self: T,
    recipient: ContractAddress,
    preset_id: felt252,
    start_timestamp_absolute: u64,
    amount_skipped: u256,
    total_amount: u256,
    unsafe_mint: bool,
    recipient_id: u64,
    batch_id: u64,
    extraData: felt252,
) -> Result<u256, Array<felt252>>

withdraw_deposit

Withdraws any unclaimed deposit held by the Unlocker.

Arguments

  • amount: The amount of tokens to withdraw.

Panics

  • NOT_PERMISSIONED: If withdrawing has been disabled.
  • GENERIC_ERC20_TRANSFER_ERROR: If for any reason the token transfer returns false.
  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • TokensWithdrawn

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::withdraw_deposit

fn withdraw_deposit(self: T, amount: u256, extraData: felt252) -> Result<(), Array<felt252>>

claim

Claims your unlocked tokens as a recipient. Any fees charged are not taken from the claimed amount.

Arguments

  • actual_id: The schedule ID assigned to you.
  • claim_to: The destination address for the claimed tokens. Use Zeroable::zero() to claim to your current address.
  • recipient_id: Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.

Panics

  • NOT_PERMISSIONED: If the caller isn’t the recipient of said actual_id.
  • GENERIC_ERC20_TRANSFER_ERROR: If for any reason the token transfer returns false.
  • ReentrancyGuardComponent::Errors::REENTRANT_CALL: If a reentrant call is detected.

Events

  • TokensClaimed

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::claim

fn claim(
    self: T, actual_id: u256, claim_to: ContractAddress, recipient_id: u64, extraData: felt252,
) -> Result<(), Array<felt252>>

delegate_claim

Claims someone else’s unlocked tokens as an authorized claiming delegate.

Arguments

  • actual_id: The schedule ID assigned to you.
  • recipient_id: Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.

Panics

  • NOT_PERMISSIONED: If the caller isn’t an authorized claiming delegate.
  • GENERIC_ERC20_TRANSFER_ERROR: If for any reason the token transfer returns false.
  • ReentrancyGuardComponent::Errors::REENTRANT_CALL: If a reentrant call is detected.

Events

  • TokensClaimed

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::delegate_claim

fn delegate_claim(
    self: T, actual_id: u256, recipient_id: u64, extraData: felt252,
) -> Result<(), Array<felt252>>

cancel

Cancels an existing schedule.

Arguments

  • actual_id: The schedule ID to cancel.
  • wipe_claimable_balance: Normally when canceling a schedule, calculation is performed to ensure the recipient will receive unlocked tokens until the moment of cancellation. This option prevents such calculation.
  • recipient_id: Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.

Panics

  • NOT_PERMISSIONED: If cancellation is disabled.
  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • ActualCancelled

Returns

  • u256: The amount claimable by the recipient from the cancelled schedule.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::cancel

fn cancel(
    self: T, actual_id: u256, wipe_claimable_balance: bool, recipient_id: u64, extraData: felt252,
) -> Result<u256, Array<felt252>>

set_hook

Sets the external hook contract.

Arguments

  • hook: The address of an external contract that implements ITTHook.

Panics

  • NOT_PERMISSIONED: If hooking is disabled.
  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::set_hook

fn set_hook(self: T, hook: ContractAddress) -> Result<(), Array<felt252>>

set_claiming_delegate

Sets the claiming delegate, who can trigger claim on behalf of recipients.

Arguments

  • delegate: The address of the claiming delegate.

Panics

  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::set_claiming_delegate

fn set_claiming_delegate(self: T, delegate: ContractAddress) -> Result<(), Array<felt252>>

disable_cancel

Permanently disables the ability for the owner to cancel schedules.

Panics

  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • CancelDisabled

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::disable_cancel

fn disable_cancel(self: T) -> Result<(), Array<felt252>>

disable_hook

Permanently disables the ability for the owner to set external hooks. Also clears the current hook.

Panics

  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • HookDisabled

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::disable_hook

fn disable_hook(self: T) -> Result<(), Array<felt252>>

disable_withdraw

Permanently disables the ability for the owner to withdraw deposit.

Panics

  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • WithdrawDisabled

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::disable_withdraw

fn disable_withdraw(self: T) -> Result<(), Array<felt252>>

disable_create

Permanently disables the ability for the owner to create new schedules.

Panics

  • OwnableComponent::Errors::NOT_OWNER: If the caller is not the owner.

Events

  • CreateDisabled

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::disable_create

fn disable_create(self: T) -> Result<(), Array<felt252>>

deployer

Returns the address of the TokenTable Deployer.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::deployer

fn deployer(self: T) -> Result<ContractAddress, Array<felt252>>

futuretoken

Returns the address of the FutureToken NFT created alongside this Unlocker instance.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::futuretoken

fn futuretoken(self: T) -> Result<ContractAddress, Array<felt252>>

hook

Returns the address of the external hook set by the owner.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::hook

fn hook(self: T) -> Result<ContractAddress, Array<felt252>>

claiming_delegate

Returns the address of the claiming delegate set by the owner.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::claiming_delegate

fn claiming_delegate(self: T) -> Result<ContractAddress, Array<felt252>>

is_cancelable

Returns if schedules are cancelable.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::is_cancelable

fn is_cancelable(self: T) -> Result<bool, Array<felt252>>

is_hookable

Returns if external hooks are allowed to be set.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::is_hookable

fn is_hookable(self: T) -> Result<bool, Array<felt252>>

is_withdrawable

Returns if the owner can withdraw deposited tokens.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::is_withdrawable

fn is_withdrawable(self: T) -> Result<bool, Array<felt252>>

is_createable

Returns if the owner can create new schedules.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::is_createable

fn is_createable(self: T) -> Result<bool, Array<felt252>>

get_project_token

Returns the project token that’s being unlocked.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::get_project_token

fn get_project_token(self: T) -> Result<ContractAddress, Array<felt252>>

get_preset

Returns the requested Preset struct.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::get_preset

fn get_preset(self: T, preset_id: felt252) -> Result<Preset, Array<felt252>>

get_actual

Returns the requested Actual struct.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::get_actual

fn get_actual(self: T, actual_id: u256) -> Result<Actual, Array<felt252>>

get_cancelled_amount_claimable

Returns the amount of claimable tokens for a cancelled schedule.

Arguments

  • actual_id: The cancenlled schedule ID that we are querying.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::get_cancelled_amount_claimable

fn get_cancelled_amount_claimable(self: T, actual_id: u256) -> Result<u256, Array<felt252>>

calculate_amount_claimable

Calculates the amount of claimable tokens for an ongoing schedule. Internally calls simulate_amount_claimable().

Arguments

  • actual_id: The ongoing schedule ID that we are querying.

Returns

  • u256: The claimable amount of tokens this time.
  • u256: The updated total amount of tokens claimed after this claim action.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::calculate_amount_claimable

fn calculate_amount_claimable(self: T, actual_id: u256) -> Result<(u256, u256), Array<felt252>>

simulate_amount_claimable

Simulates the amount of claimable tokens for an ongoing schedule. This function exposes more parameters to make testing the calculation logic easier.

Arguments

  • actual_start_timestamp_absolute: Refer to Actual.start_timestamp_absolute.
  • preset_linear_end_timestamp_relative: Refer to Preset.linear_end_timestamp_relative.
  • preset_linear_start_timestamps_relative: Refer to Preset.linear_start_timestamps_relative.
  • claim_timestamp_absolute: The timestamp of when claim() is called. Must be in the future.
  • preset_linear_bips: Refer to Preset.linear_bips.
  • preset_num_of_unlocks_for_each_linear: Refer to Preset.num_of_unlocks_for_each_linear.
  • preset_stream: Refer to Preset.stream.
  • preset_bips_precision: The decimal precision of calculation. Hardcoded to 10000.
  • actual_total_amount: Refer to Actual.total_amount.

Returns

  • u256: The claimable amount of tokens this time.

Fully qualified path: tokentable_v2::components::interfaces::unlocker::ITTUnlockerSafeDispatcherTrait::simulate_amount_claimable

fn simulate_amount_claimable(
    self: T,
    actual_start_timestamp_absolute: u64,
    preset_linear_end_timestamp_relative: u64,
    preset_linear_start_timestamps_relative: Span<u64>,
    claim_timestamp_absolute: u64,
    preset_linear_bips: Span<u64>,
    preset_num_of_unlocks_for_each_linear: Span<u64>,
    preset_stream: bool,
    preset_bips_precision: u64,
    actual_total_amount: u256,
) -> Result<u256, Array<felt252>>