Technical documentation

Entrypoints

8min

Entrypoint description

All the entrypoints can be broken down into four categories:

  1. User entrypoints. With their help, funds are invested into deposits and farms.
  2. Admin entrypoints. Used for managing contracts and can only be called by the Admin.
  3. Supplementary entrypoints. Utilized during internal operations. Usually, these entrypoints can only be called by the contract itself.
  4. f12. Exterior entrypoints, description: f12ο»Ώ

User Entries

  • depositLending – used for filling the deposit up with funds, where sp.amount (is the amount of xtz that is supposed to be deposited) orshares (the amount of tzBTC tokens that are supposed to be deposited. In this case, to invest, you must first call approve for the required number of tokens.)
    • minDepositShares The minimum expected amount of tokens to be received.
    • deadline The time limit for sending transactions, equal to now + one second.
  • redeemLending – used to withdraw funds from a deposit. Errors display as codes.
    • shares (only in BTC contract) The amount of tzBTC tokens that are supposed to be withdrawn from the deposit.
    • amount (xtz contract only) The amount of xtz to be withdrawn from the deposit.
    • deadline The timestamp until which the transaction remains valid, equal to now + one second.
  • investLB – invests in LB-Farm, while almost always summoning additional funds from deposits, thus borrowing funds from lenders. While the currency of the contract may differ (xtz in xzt-contract and tzBTC in BTC-contract), the user always brings only xtz. The leverage one can obtain this way is limited from above. This is the most computationally complex parameter, and it was designed this way to save on gas.
    • amount2tzBTC The amount of xtz to be exchanged for tzBTC.
    • mintzBTCTokensBought The minimum number of learned tzBTC tokens. It is needed to control slippage.
    • tzBTC2xtz (only in BTC contract) The number of tzBTC tokens to be exchanged for xtz.
    • minXtzBought (only in BTC contract) The minimum amount of xtz learned. It was needed to control slippage.
    • amount2Lqt The amount of xtz invested in the LB farm.
    • minLqtMinted is the minimum number of learned LB tokens. It is needed to control slippage.
    • tzBTCShares (xtz contract only) investor's tzBTC tokens. Not taken into account when calculating collateral.
    • sp.amount The investor's xtz. It should take into account the upfront commission.
    • maxTzBTCShares The maximum tzBTC shares added to liquidity
    • deadline The timestamp until which the transaction remains valid, equal to now + one second.
  • investBalancedLB - (xtz contract only) creates a farm in about 200% of the collateral, where tzBTC is taken from the client, and xtz is borrowed from the contract. Thus, the client doesn't need a double exchange of tzBTC, unlike investLB. Using the method, you can create a farm with a large coverage (cratio<200%) by transferring additional funds in the entry point, but the commission will be taken for a farm of 200%.
    • amount2Lqt The xtz amount converted to LB tokens
    • minLqtMinted The minimum LB tokens to mint
    • maxTzBTCShares The maximum number of tzBTC shares provided by the client.
    • deadline The timestamp until which the transaction remains valid, equal to now + one second.
  • redeemLB – closes LB-Farm, and returns all the proceeds (minus the borrowed amount) to the Farmer. A farm can be unwound wholly and partly. The debt is written off in proportion to the burnt SIRS tokens.
    • minTokensWithdrawn The minimum amount of tzBTC to be received when selling a farm. Needed to control slippage.
    • xtz_to_token_amount (BTC contract only) The amount of xtz to be sold. The amount of tzBTC received from the operation and tzBTC received from the sale of LB tokens should cover the debt.
    • lqtBurned LB shares to burn
    • minXtzWithdrawn (only in the xtz contract) The minimum xtz to get after burning LB tokens.
    • minTokensBought (BTC contract only) The minimum tzBTC to buy in the second trade.
    • sell_remaining_tzbtc The flag that determines whether or not to sell remaining tzBTC shares.
    • minXtzBought (only in the xtz contract) The minimum xtz to buy in the second trade.
    • send_tzbtc (only in the xtz contract) The tzBTC shares to send directly to the client.
    • deadline The timestamp until which the transaction remains valid, equal to now + one second.
  • updateIndexes – initiates the computation process for all three indices. Necessary to ensure the regularity of this process by allowing any interested party to start this process with minimal transaction costs.
  • liquidateLB - starts a forced buyout of a Farm, for which the collateral value gets dangerously close to the borrowed amount. The value of the Farm is, in this case, determined by the oracle. A partial buyout is also possible.
    • address The address of the contract to be liquidated.
    • payment_shares (only in the BTC contract) The number of tzBTC tokens for which the farm's LB tokens are supposed to be redeemed. In this case, to invest, you must first call approve for the required number of tokens.
    • sp.amount (only in the xtz contract) The amount of xtz for which the farm's LB tokens are supposed to be redeemed.
    • deadline The timestamp until which the transaction remains valid, equal to now + one second.
    • min_expected_sirs Minimal amount of sirs the user expects to receive.
  • returnDebt - allows a direct return of loan for a given farm.
    • address The address of the farm, to which the debt user wants to return
    • shares (BTC contract only) The amount of tzBTC shares that need to be returned. (in the xtz contract, this value is set via sp.amount)
    • minReturnedGrossCredit - min amount of debt to be redeemed
    • deadline The time limit for sending transactions, equal to now + one second.

Flashloan

Entrypoints related to flash loan functionality. Flash Loans allow you to borrow any available amount of xtz or tzBTC without collateral as long as the liquidity is returned to the protocol within one block transaction.

  • flashloan - lends funds (tezos in the xtz contract and tzBTC in the BTC contract).
    • callback and amount (xtz) or shares (BTC) Calls this callback and transfers the amount or shares of funds to the account
  • flashloanFinalize - if the client did not return the funds taken in flashloan, along with interest, it falls.
    • callback (mutez - for xtz contract, nat - for BTC) The amount of funds to be returned.
  • flashloanReturn (only in the xtz contract) - returns a debt.

Admin Entries

In the event of being called by a user without admin rights will display the error message "Forbidden"

  • setAdminCandidate - adding a candidate to become an admin, and it can only be interacted by an admin.
    • admin_candidate - address of a candidate.
  • approveAdminCandidate - approving candidate. It can only be interacted with by a candidate (from the admin_candidate address). After the interaction, the candidate becomes the Admin:
    • the admin address in the administrator storage becomes admin_candidate;
    • admin_candidate remains the same.
  • liquidateOnchainLB - a mechanism of forced close a close-to-debt farm. Farm value is determined through the complete sale of its lb-tokens. A part of the collateral premium over the borrowed amount goes to Admin, while the remaining difference gets assigned to Lender's accounts proportionally to their deposit sizes.
    • deadline The time limit for sending transactions; is equal to now + one second.
    • address The address to liquidate
    • minXtzWithdrawn The minimum xtz to get after burning LB tokens
    • minTokensWithdrawn The minimum tzBTC to get after burning LB tokens
    • minTokensBought (BTC contract only) The minimum tzBTC to buy in secondary trade
    • minXtzBought (xtz contract only) The minimum xtz to buy in secondary trade
  • disableOnchainLiquidation - disables the liquidateOnchainLB liquidation mechanism. It can be turned off only once.
  • setDexContract - sets the dex-contract (LB contract by default) for exchanging xtz for tzBTC and vice versa.
  • setFlashloanParams Sets flashloan parameters.
    • flashloan_admin_commission Admin commission.
    • flashloan_deposit_commission Commission for depositors.
    • flashloan_available Sets if flashloan is enabled or not.
  • setDelegate (xtz-contract only) - delegates the xtz remains from the contract to the liquidity baker. Baker rewards are shared among Lenders proportionally to their deposit sizes.
  • setIsWorkingStatus – used for powering on and off the contract. When the contract is powered-off, all of the interest from Farms goes to Admin, and none gets assigned to the Lenders; entrypointsdepositLending and investLB cannot interact; funds withdrawal is available only. investBalancedLB(in xtz contract) is also disabled. Admin can always power up a β€œshutdown” contract again.
  • setLbPriceChangeRate - changes the value of lb_price_change_rate, which is used in oracle's clamp function.
  • setLeverageParams – sets parameters for investing in Farms and liquidation β€” for example, the maximum allowed leverage or liquidation commission for both types of liquidations.
  • setOracleToCfmmMaxDiff - sets the value of oracle_to_cfmm_max_diff in storage in units of 10^-5. The value is used to check the exchanging cfmm price with the oracle price for xtz and tzBTC during investing in a farm. Prices must not differ by more than (1 + oracle_to_cfmm_max_diff) times.
  • setPause - pauses the contract.
  • setRateParams - sets parameters for calculating the base interest rate using the utilization rate.
  • setUpfrontCommission - sets the upfront-fee size. It should be less than 2%.
  • withdrawCommission - sends the Admin all of the accumulated commission since the last time this entry interacted.
  • addOrRemoveUpfrontFree - add or remove an address from a unique set of clients who don't pay upfront fees when investing in a farm.
    • address The address of some client: if it is in this set, then it is removed from it, and if not, then it is added.

Supplementary entries

These entries can only be initiated during scenarios described in the contracts.

  • default – entry required to obtain xtz from dex-contract. In the xtz-contract, it is also responsible for obtaining token rewards for liquidity baking. The baking reward is divided evenly among all depositors.
  • investLBFinalize – ends an investLB and investBalancedLB (in xtz contract) call.
  • redeemLBFinalize – ends a redeemLB call.
  • liquidateLBFinalize – ends a liquidateLB call.
  • liquidateOnchainLBFinalize – terminates liquidateOnchainLB call.
  • sendBalance (BTC-contract only) – sends all xtz on the contract’s balance to a chosen address.
  • sellXtz (BTC-contract only) – exchanges all xtz on the contract’s balance for tzBTC.
  • calculateLbPrice - calculates the current price of a SIRS token (SIRS LB) based on the clamp function

These three callback entries are for refreshing the storage values and one – for selling funds:

  • sellTzBTC (xtz-contract only) – exchanges all tzBTC tokens for xtz. This entry is also a callback one.
  • updateLBCallback – updates lb_shares value in storage.
  • updateTzbtcPoolCallback(BTC contract only) – updates local_params.tzbtc_pool and tzBTC_shares value in storage.
  • updateLqtTotalCallback – updates local_params.lqt_total value in storage.

fa12

The description can be found on a web page:

Standard fa12 entrypoints

  • approve
  • getAllowance
  • getBalance
  • getTotalSupply
  • transfer

Non-standard fa12 entrypoints

  • getAdministrator - Returns admin's address.
  • update_metadata - Updates metadata.

ο»Ώ

Updated 25 Mar 2024
Doc contributor
Doc contributor
Doc contributor
Did this page help you?