All the entrypoints can be broken down into three categories:
- User entrypoints. With their help funds are invested into deposits and farms.
- Admin entrypoints. They are used for managing contracts and can only be called by the Admin.
- Supplementary entrypoints. Utilized during internal operations. In most cases, these entrypoints can only be called by the contract itself.
depositLending – used for filling the deposit up with funds. For xtz-contract this sum is determined by the number of xtz transferred upon the callback. For BTC-contracts there is a special parameter for determining this number - shares. Thus, you need to first summon approve for the same number of tokens.
redeemLending – employed for withdrawing funds from a deposit. The amount of withdrawn funds is determined by the parameters amount ( for xtz-contracts) or shares (for BTC-contracts). In case there is an attempt to withdraw more funds than there are available on an account an error message 'too much amount' is displayed.
investLB – invests in lb-Farm, while almost always summoning additional funds from deposits, and 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 with himself 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.
redeemLB – unwinds lb-Farm, and returns all the proceeds (minus the borrowed amount) to the Farmer. A farm can only be unwound completely. To control for slippage one may specify the minTokensWithdrawn parameter. For ВTC-contract you additionally need to specify xtz_to_token_amount , to ensure that the debt gets repaid in full.
updateIndexes – initiates the computation process for all three indices. Necessary for ensuring the regularity of this process by allowing any interested party to initiate 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. Value of the Farm is in this case deteremined by the oracle. Partial buyout is also possible.
In the event of being called by a user without admin rights will display error message ‘Forbidden.'
liquidateOnchainLB – a mechanism for forced Farm closure in cases when the collateral value starts approaching the borrowed amount at a dangerously close level. Farm value is determined through the complete sale of its lb-tokens. A part of collateral premium over the borrowed amount goes to Admin while the remaining difference gets assigned to Lender accounts proportionally to their deposit sizes.
disableOnchainLiquidation – disables liquidation mechanism (liquidateOnchainLB). Once terminated, it cannot be reactivated.
setIsWorkingStatus – used for powering on and off the contract. The powered-off contract differs from the “pluged-in” one: all of the interest from Farms goes to Admin and none gets assigned to the Lenders. Admin can always power up a “shutdown” contract again.
setUpfrontCommission – sets the upfront-fee size. It should be less than 2%.
setDelegate (xtz-contract only) – delegates the xtz remains from the contract to the liquiditiy baker. Baker rewards are shared among Lenders proportionally to their deposit sizes.
withdrawCommission – sends all of the accumulated commission since the last time this entry was called to the Admin.
setRateParams – sets parameters for calculation of base interest rate using utilization rate.
setLeverageParams – sets parameters for investing in Farms and liquidating them. Such as, for example, maximum allowed leverage or liquidation commission for both types of liquidations.
These entries can only be initiated during scenarios described in the contracts.
default – entry required to obtain xtz from dex-contract. In xtz-contract it is also responsible for obtaining token rewards for liquidity baking.
investLBFinalize – ends an investLB call.
redeemLBFinalize – ends a redeemLBcall.
liquidateLBFinalize – ends a liquidateLB call.
liquidateOnchainLBFinalize – terminates liquidateOnchainLB call.
sendBalance (BTC-contract only) – sends all xtz on contract’s balance to a chosen address.
sellXtz (BTC-contract only) – exchanges all xtz on the contract’s balance for tzBTC.
These 4 callback entries are for refreshing the storage values and one – for selling funds:
updateTzBTCCallback (BTC-contract only) – refreshes tzBTC_shares value in storage.
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 – updates local_params.tzbtc_pool value in storage.
updateLqtTotalCallback – updates local_params.lqt_total value in storage.