Quipuswap
  • introduction
    • What is QuipuSwap?
    • Participants
    • QuipuSwap subprojects
      • QuipuSwap Farms
      • Quipuswap Stable DEX
      • Token to Token Swaps
      • Governance (text-only)
  • Get Started
    • Install Wallet
    • How to get TEZ
    • How to find my tokens
    • Connect wallet
    • FAQ
  • Dex Guides
    • Overview
    • Types of the exchange (Token/TEZ, Token/Token)
    • How to use the DEX
      • Trade
      • How to add liquidity to an existing liquidity pool
      • How to create a new liquidity pool
      • How to remove liquidity
      • How to vote for a baker
      • How to ban/veto a baker
  • Tezos Tokens
    • What is a Token?
    • What is the difference between FA1.2 and FA2 standards?
    • QUIPU Tokenomics
  • Smart Contracts
    • Dex token edition
      • Overview
      • Dex
      • Exceptions
    • QuipuSwap stable swap DEX
      • 🛠️Developer module
        • 📄Storage & action types
        • 🔵Developer setter entrypoints
          • set_dev_address
          • set_dev_fee
      • 🏠Standalone DEX
        • 📄Storage and types overview
        • 🟡Initialization
          • set_admin_function
          • set_dev_function
          • set_dex_function
          • set_token_function
        • 🟠Add new dex
          • add_pool
        • 🔵DEX methods
          • invest
          • swap
          • 📤Divesting
            • divest
            • divest_imbalanced
            • divest_one_coin
          • 🤑DEX rewards
            • claim_referral
            • stake
        • 🛠️Developer methods
          • claim_developer
          • Dev module entrypoints
        • 🛑Admin methods
          • add_rem_managers
          • ramp_A
          • set_admin
          • set_fees
          • stop_ramp_A
      • 🏭Factory
        • 📄Storage and types overview
        • 🟡Initial setup
          • set_init_function
          • set_dev_function
          • DEX compiled codebase setup
            • set_admin_function
            • set_dex_function
            • set_token_function
        • 🟠Initialize new DEX flow
          • add_pool
          • start_dex
        • 💱Deployed from factory DEX
          • 📄Storage and types overview
          • 🟡Initialization
            • copy_dex_function
            • freeze
          • 🔵DEX methods
          • 🛠️Claim developer rewards
          • 🛑Admin methods
        • 🛑Developer methods
          • claim_rewards
          • 🧑‍💻Factory management
            • 🟢Factory params
              • set_burn_rate
              • set_price
              • set_whitelist
            • 🔵Dev module entrypoints
    • Dex 2.0
      • ⁉️Errors overview
      • 🥐BakerRegistry contract
        • Storage and types overview
        • Entrypoints overview
          • validate
          • register
      • ⚙️FlashSwapsProxy contract
        • Storage and types overview
        • Entrypoints overview
          • default
      • 🧺Bucket contract
        • Storage and types overview
        • Entrypoints overview
          • fill
          • pour_out
          • pour_over
          • withdraw_rewards
          • ban_baker
          • vote
          • default
        • On-chain views overview
          • is_banned_baker
          • get_tez_balance
          • get_user_candidate
      • ⚖️Auction contract
        • Storage and types overview
        • Entrypoints overview
          • Auction entrypoints
            • receive_fee
            • launch_auction
            • place_bid
            • claim
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_baker
            • set_fees
            • set_auction_duration
            • set_min_bid
            • update_whitelist
            • withdraw_dev_fee
            • withdraw_public_fee
            • burn_bid_fee
      • 🏦DexCore contract
        • Storage and types overview
        • Entrypoints overview
          • DEX entrypoints
            • launch_exchange
            • invest_liquidity
            • divest_liquidity
            • swap
            • withdraw_profit
            • claim_interface_fee
            • claim_interface_tez_fee
            • withdraw_auction_fee
            • vote
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_flash_swaps_proxy
            • set_auction
            • add_managers
            • set_fees
            • set_collecting_period
            • update_token_metadata
            • ban
          • Permits' entrypoints
            • permit
            • set_expiry
          • FA2 entrypoints
            • transfer
            • update_operators
            • balance_of
          • Callbacks
            • launch_callback
            • flash_swap_callback
            • close
        • On-chain views overview
          • check_is_banned_baker
          • get_reserves
          • get_total_supply
          • get_swap_min_res
          • get_toks_per_share
          • get_cumulative_prices
          • get_collecting_period
    • Trusted contracts
    • Farming
      • Referral system overview
      • Fees overview
      • Rewards precision overview
      • BakerRegistry contract
        • Storage and types overview
        • Entrypoints overview
          • validate
          • register
      • Burner contract
        • Storage and types overview
        • Entrypoints overview
          • default
          • burn_callback
      • ProxyMinter contract
        • Storage and types overview
        • Entrypoints overview
          • Admin entrypoints
            • add_minter
            • withdraw_tokens
            • set_admin
            • confirm_admin
          • Minter entrypoint
            • mint_tokens
      • QFarm contract
        • Storage and types overview
        • Entrypoints overview
          • Farming entrypoints
            • deposit
            • withdraw
            • harvest
          • FA2 entrypoints
            • transfer
            • update_operators
            • balance_of
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_fees
            • set_reward_per_second
            • set_burner
            • set_proxy_minter
            • set_baker_registry
            • set_is_v1_lp
            • ban_bakers
            • add_new_farm
            • pause_farms
            • burn_tez_rewards
            • withdraw_farm_depo
            • update_token_metadata
          • Other entrypoints
            • burn_farm_rewards
            • default
      • TFarm contract
        • Storage and types overview
        • Entrypoints overview
          • Farming entrypoints
            • deposit
            • withdraw
            • harvest
          • FA2 entrypoints
            • transfer
            • update_operators
            • balance_of
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_fees
            • set_reward_per_second
            • set_burner
            • set_baker_registry
            • set_is_v1_lp
            • ban_bakers
            • add_new_farm
            • pause_farms
            • burn_tez_rewards
            • claim_farm_rewards
            • withdraw_farm_depo
            • update_token_metadata
          • Other entrypoints
            • default
  • Brand and Logos
Powered by GitBook
On this page
  • Call parameters
  • Usage
  • Errors
  1. Smart Contracts
  2. Farming
  3. TFarm contract
  4. Entrypoints overview
  5. Admin entrypoints

add_new_farm

An entrypoint that adds a new farm with the specified parameters. Also setups share token default metadata. Required amount of reward token will be transferred from an admin to the contract (allowance is required).

Call parameters

type fa12_type          is address

type fa2_type           is [@layout:comb] record [
  token                   : address;
  id                      : token_id_type;
]

type token_type         is
  FA12                    of fa12_type
| FA2                     of fa2_type

type fees_type          is [@layout:comb] record [
  harvest_fee             : nat;
  withdrawal_fee          : nat;
]

type stake_params_type  is [@layout:comb] record [
  staked_token            : token_type;
  is_v1_lp                : bool;
]

type add_new_farm_type  is [@layout:comb] record [
  fees                    : fees_type;
  stake_params            : stake_params_type;
  token_info              : map(string, bytes);
  reward_token            : token_type;
  paused                  : bool;
  timelock                : nat;
  start_time              : timestamp;
  end_time                : timestamp;
  reward_per_second       : nat;
]

fees_type

Field
Type
Hint
Description

harvest_fee

nat

Float value multiplied by 1e+16

Fee that applies in time of rewards claiming

withdrawal_fee

nat

Float value multiplied by 1e+16

Fee that applies in time of withdrawing (unstaking) tokens only in farms with timelock

stake_params_type

Field
Type
Description

staked_token

token_type

FA1.2/FA2 staked token

is_v1_lp

bool

Flag that indicates: QuipuSwap V1 LP token staked or not

add_new_farm_type

Field
Type
Description

fees

Fees that applies to the farming

stake_params

Staking parameters

token_info

map(string, bytes)

Mapping of token's keys to token's info

reward_token

token_type

FA1.2/FA2 reward token

paused

bool

Flag that indicates: farm is paused or not

timelock

nat

Timelock in seconds (0 for farms without timelock)

start_time

timestamp

Farm's start time

end_time

timestamp

Farm's end time

reward_per_second

nat

Reward per second

Usage

import { MichelsonMap } from "@taquito/michelson-encoder";

const tFarmAddress = "KT1...";
const lifetime = 10510000; // ~4 months
const params = {
    fees: {
        harvest_fee: 0.05 * 10 ** 16, // 0.05%
        withdrawal_fee: 0.25 * 10 ** 16, // 0.25%
    },
    stake_params: {
        staked_token: {
            fA2: {
                token: "KT1...",
                id: 0,
            },
        },
        is_v1_lp: true, // or false
    },
    token_info: MichelsonMap.fromLiteral({
        name: Buffer.from("wWBTC/TEZ FA2 Staking Share").toString("hex"),
        symbol: Buffer.from("QSHR").toString("hex"),
        decimals: Buffer.from("6").toString("hex"),
    }),
    reward_token: {
      fA12: "KT1...",
    },
    paused: false, // or true
    timelock: 0, // or positive number
    start_time: String(Math.ceil(Date.now() / 1000)),
    end_time: String(Math.floor(Date.now() / 1000) + lifetime + 1),
    reward_per_second: 1169098400000000,
};
const tFarm = await tezos.contract.at(tFarmAddress);
const operation = await tFarm.methodsObject.add_new_farm(params).send();

await operation.confirmation();

Errors

  • Not-admin - sender of the transaction is not current administrator.

  • TFarm/wrong-end-time - end time of a farming is less that or equal to start time.

  • TFarm/wrong-timelock - timelock is greater than farming's lifetime.

Previousban_bakersNextpause_farms

Last updated 3 years ago

fees_type
stake_params_type