withdraw

An entrypoint that withdraws (unstakes) tokens. In time of every withdraw it claims user's rewards if timelock is finished (only for farms with timelock) and transfers user's rewards to an admin if timelock is not finished (only for farms with timelock). In farms without timelock it just claims the rewards. In the case of claiming, rewards are transferred from the contract to the user and to the referrer. Also it takes a commission in staked tokens on withdrawal (withdrawal_fee) if timelock is not finished (only for farms with timelock) and takes this commission from the farm's name. At the end it revotes for a baker if the farm supports QuipuSwap V1 TOK/TEZ LP staked token.

Call parameter

type withdraw_type      is [@layout:comb] record [
  fid                     : fid_type;
  amt                     : nat;
  receiver                : address;
  rewards_receiver        : address;
]
Field
Type
Description

fid

fid_type (nat)

Farm's ID

amt

nat

Amount of tokens to withdraw

receiver

address

Receiver of unstaked tokens

rewards_receiver

address

Receiver of earned tokens

Usage

const tFarmAddress = "KT1...";
const params = {
    fid: 1,
    amt: 100,
    receiver: "tz1.../KT1...",
    rewards_receiver: "tz1.../KT1...",
};
const tFarm = await tezos.contract.at(tFarmAddress);
const operation = await tFarm.methodsObject.withdraw(params).send();

await operation.confirmation();

Errors

  • QSystem/farm-not-set - farming with fid parameter doesn't exist.

  • TFarm/balance-too-low - user's staked balance too low.

Last updated