Bitcoin modular insurance mechanism

In the insurance module design of Yala Finance, we have opted for the Takaful insurance model [@feng2022unified]. The Takaful insurance model is a cooperative insurance system, aiming to provide insurance protection to participants through the mutual sharing of risks and assistance.

Actor model

In this system, key roles are played by policyholders, insurers (operators), and shareholders.

Insurers, acting as operators, are tasked with:

  • Managing the Takaful insurance fund. Their responsibilities include collecting premiums, overseeing investments, and handling claims, ensuring the fund's stability and operational integrity to meet participants' insurance demands.

  • Setting initial parameters. Operators are responsible for establishing key parameters such as profit-sharing ratios, risk-sharing rules, and premium rates.

  • Crafting insurance contracts. They create Takaful insurance contracts that define the rights and duties of participants, developing and implementing script contracts based on predetermined parameters and managing the insurance module.

  • Supervision and governance. Operators implement supervision and governance mechanisms to ensure Takaful insurance activities' compliance and resilience. This includes managing fund use, protecting participant rights, and preventing fraud. For larger policies, they may need to draft additional insurance contracts, analyze policyholders' on-chain behaviors, and conduct KYC procedures as needed.

Shareholders contribute to the qard hasan (benevolent loan) fund, engaging in long-term profit-sharing and decision-making for the insurance fund. They may also serve as operators or simply invest in the fund and participate in its governance.


Takaful operates by pooling contributions from members into a fund, with premiums financing mutual assistance for losses. This fund, along with all related activities such as investments and profit distribution, is managed by an operator. In cases where the Takaful Insurance Fund falls short of covering claims, operators use qard hasan (a benevolent loan) from company shareholders to fill the gap. Though not required, any future surpluses are first allocated to repay these loans, benefiting the shareholders.

Surpluses remaining after claims and expenses are reimbursed to participants, with the operational cycle and calculations outlined by the operator in a scripted contract. The fund employs a detailed mechanism for rebates, with thresholds designed to regulate fund withdrawals and maintain stability. Commonly, five thresholds are established: three for the Takaful fund to manage its levels and two for qard hasan to guide loans and repayments. Loans are made to elevate the fund to a safe level during deficits, and as the fund grows, reaching certain triggers allows for investments, distribution of excess to participants and the operator, and reserve setting for the future. Surplus in the qard hasan beyond a defined point triggers dividends to participants, ensuring equitable benefit distribution.

Assume that all n participants pay a premium of d to the Takaful insurance fund. The $R_t$ denotes the reserve after all payments have been made in the period starting at time t. The net return is the total income minus the total expenses for a given time period. The total amount of benefits withdrawn from the Takaful Insurance Fund is S. The net benefit is the total revenue minus the total expenses for a given time period, i.e., $nd - S$. h is the surplus trigger point, and any amount exceeding the surplus trigger point at the point in the calculation cycle is the surplus of the fund, which should be distributed to the participants, the Takaful operator, and the shareholders. Takaful fund reserves satisfy the recurrence relation Rt=h(Rt1+ndS)+R_t = h \land (R_{t - 1} + nd - S)_+

Insurance model in Yala

Yala's insurance model merges the profit-sharing and agent models, drawing inspiration from Takaful. In the profit-sharing approach, the operator allocates the Takaful fund's surplus proceeds once they surpass a predetermined surplus trigger. Conversely, in the agent model, the operator earns proceeds for fund management, creating a balanced structure that rewards both fund stewardship and communal surplus.

In the Yala insurance model, insurers oversee the Takaful Module and Qard Hasan Module. The Takaful Module, central to the system, manages the insurance pool and the lending script contract. Here, policyholders, termed Participants, choose their insurance module and initiate a script contract linked to the Takaful Module. This setup, pre-approved by Insurers, automatically entitles Participants to payouts, triggering a process where, upon permission, the indexer consensus transitions the module from Black to White, enabling Insurers to access the funds for claims.

The Insurance Pool's resources are allocated for claims and Insurers' fees, embodying shared risk among Participants. Once the pool's funds surpass the investment threshold, Insurers can invest to generate additional revenue. This excess income, beyond a set surplus trigger, is shared between Participants and Insurers, with any leftover reserves earmarked for future insurance periods.

The Qard Hasan Module is triggered when a deficiency occurs and the Insurance Pool reaches the Minimum funding level. the funds in the Qard Hasan Pool are used to cover the Insurance Pool's losses until its funding is restored to the Loan Maximum Point. That is, when (Rt1+nd)(1ρw)<S(R_{t-1} +nd)(1-\rho^w )<S, the Qard Hasan loan Q=S(Rt1+nd)(1ρw)Q=S - (R_{t-1} +nd)(1-\rho^w ) will be offered, where ρw\rho^w is the agency fee rate and ρm\rho^m is the profit sharing rate. If the body of Insurance Pool funds exceeds the surplus trigger at stage t stage, the reserve satisfies

Rt=h[((Rt1+nd)(1ρw)S)(1ρm)]+.(13)R_t = h \land \left[ \left( (R_{t-1} + nd)(1 - \rho^w ) - S \right)(1 - \rho^m ) \right]_+. (13)

Each participant receives benefits

Gt=[((Rt1n+d)(1ρw)Sn)(1ρm)hn]+.14G_t = \left[ \left(\left( \frac{R_{t-1}}{n} + d \right)(1 - \rho^w ) - \frac{S}{n} \right)(1 - \rho^m ) - \frac{h}{n} \right]_+ .(14)

If we set the profit threshold point h=0h=0, the earnings for each participant in the model simplify to: xx

Gt=[(Rt1n+d)(1ρw)Sn](1ρm).(15)G_t = \left[ \left( \frac{R_{t-1}}{n} + d \right)(1 - \rho^w ) - \frac{S}{n} \right](1 - \rho^m ). (15)

If the body of Insurance Pool funds does not reach the surplus trigger at stage t, no profit sharing will be calculated for the Insurers, at which point the reserve satisfies

Rt=[(Rt1+nd1ρwS)]+.(16)R_t = \left[ \left( \frac{R_{t-1} + nd}{1 - \rho^w } - S \right) \right]_+ . (16)

Since Yala Finance is a high-risk trading scenario, there could be a large demand for short-term insurance, Insurers could reasonably increase insurance rates for short-term traders, contract parameters would need to be changed at any time in conjunction with the market price provided by the prognosticator, and Insurers would have the right to reject high-risk trades.The Yala insurance model could also become a Defi The Yala insurance model could also be a standalone derivative in the BTC ecosystem, where policyholders and shareholders could provide capital for long-term gains.

Key external actors


Keepers, often automated and independent entities, are motivated by arbitrage to enhance liquidity in decentralized systems. In Yala Finance, they help stabilize $YU's price by selling it when above the target and buying when below. During liquidations in Yala's Vault module, Keepers engage in auctions for surplus, debt, and collateral, contributing to the protocol's market efficiency.


Yala Finance requires real-time information about the market prices of collateral assets in the Yala Finance Vault to determine when to trigger liquidation. Oracles provide data services for USD prices, collateral prices, and $YU prices to both the Yala Foundation, insurers, and the liquidation module [@al2020trustworthy; @caldarelli2022overview].

The Yala Foundation oversees the Oracle and OSM Modules, which source price inputs from the BTC Layer 2 Oracle node. This node fetches off-chain data, reformats it, and supplies it to the Oracle Module. To safeguard against attackers controlling prophecy machines, the OSM (Office of the Secretary) intermediates, receiving prices indirectly to enhance security. It introduces a 30-minute delay before releasing prices to the protocol, allowing time for emergency actions if needed. The Yala Foundation decides on this delay and emergency protocols.

Given the limited collateral types in early Yala Finance, the Oracle system doesn't require extensive price data. It operates on a publish-subscribe model, with the Oracle Module collecting and broadcasting price data at set intervals after OSM processing. Each node in the system runs a daemon to keep its price data current.


Given the high volatility unique to Yala Finance, collateralized borrowers require insurance services. However, to preserve $YU stability, the Yala Foundation doesn't directly provide these services or assume borrower risks. Instead, when starting a Loan Module, borrowers can also activate an Insure Module tailored to that specific module.

  "p": "BRC-20-module",
  "op": "deploy",
  "name": "Yala_Insure",    
  "source": "at_code_address",         
  "init": {   
    "module": "at_loan_module_address"

Insurers are insurance operators responsible for maintaining the qard hasan fund pool, setting various parameters for insurance contracts, and publishing them on the insurance platform. Before initiating the Insure Module, borrowers need to select an insurance contract on the insurance platform and then direct the source to the script code segment to complete the publication of the Insure Module.

Last updated