# Purchase a Policy

The policy fee denoted $P_F$ is given by the equation

${P_F = C_A. { 3 \over {1\over F} + {{t - c + N_M + (A_M . A_W)} \over {{c \over t} + (C_D . C_A)}} + {1\over C}}}$

where $F$and $C$are constants, $c$ is the cover commitment amount, $t$ is the total balance of the pool, $C_D$ is the policy duration desired, $C_A$ is the desired cover amount, $N_M$ is NEP provision amount for the cover pool , $A_M$ is assurance token amount for the cover pool, and$A_W$ is the assurance token liquidity weight.

For simplicity, this equation can be broken down further to the following subtopics:

## Utilization Ratio

The utilization ratio simply tells us how much liquidity in a given cover pool has already been used. It is denoted as the ratio between cover ommitment and total balance, given the pool has a positive balance.

$u = {c \over t}$

where $c$ is the cover commitment and $t$ is the total balance of the pool.

## Available Liquidity

The available liquidity is always greater than or equal to the total balance of a cover pool. A cover pool may have additional liquidity available through Assurance Tokens and NEP Provision. The weight of assurance token is a constant.

$l = {t - c + N_M + (A_M . A_W)}$

where $t$ is the total balance of the pool, $c$ is the cover commitment, $N_M$ is NEP provision amount for the cover pool , $A_M$ is assurance token amount for the cover pool, $A_W$ is the assurance token liquidity weight.

## Impact Ratio

The impact ratio signifies the effect of the desired cover amount and duration on the liquidity pool.

$i = {u + (C_D . C_A) \over l}$

where $u$ is the current utilization ratio, $C_D$ is the policy duration desired, $C_A$ is the desired cover amount, and $l$ is the available liquidity.

## Policy Fee

Finally, the policy fee ($P_F$) equation can be now derived from a simple harmonic mean of three values: namely floor, impact ratio, and ceiling, denoted as

${P_F = C_A. { 3 \over {1\over F} + {1 \over i} + {1\over C}}}$

where $F$ and $C$ are constants, $C_A$ is the desired cover amount, and i is the impact. Check the following sheet which contains this equation.

## Get Fees

import { ChainId, policy } from '@neptunemutual/sdk'import { info } from './info.js'import { getProvider } from './provider.js'import { weiAsPercent, weiAsDollars, ether } from './bn.js'​const get = async () => {  const { key } = info  const provider = getProvider()  const args = {    duration: 2,    amount: ether(100_000)  }​  console.info('Getting %s cover for %d months', weiAsDollars(args.amount), args.duration)  console.info('--------------------------------------')​  const response = await policy.getCoverFee(ChainId.Mumbai, key, args, provider)  const {    fee,    utilizationRatio,    totalAvailableLiquidity,    coverRatio,    rate  } = response.result​  console.info('Rate: %s', weiAsPercent(rate))  console.info('Fee: %s', weiAsDollars(fee, 'xYZ'))  console.info('--------------------------------------')  console.info('Utilization Ratio: %s', weiAsPercent(utilizationRatio))  console.info('Total Available Liquidity: %s', weiAsDollars(totalAvailableLiquidity))  console.info('Cover Ratio: %s', weiAsPercent(coverRatio))}​get()​/*****************************************************************************[info] Getting $100,000.00 cover for 2 months[info] --------------------------------------[info] Rate: 16.66%[info] Fee:$2,776.78[info] --------------------------------------[info] Utilization Ratio: 0.00%[info] Total Available Liquidity: \$299,700.00[info] Cover Ratio: 66.73%*****************************************************************************/

Result Type

 Property Type Description fee number The amount required in DAI to purchase the policy for the specified amount. utilizationRatio number Utilization Ratio = Total Commitment / Total Liquidity totalAvailableLiquidity number Total Available Liquidity = Total Liquidity - Total Commitment + Amount in NEP Provision + Weighted Amount in Assurance Pool coverRatio number Cover Ratio = Utilization Ratio + Cover Duration * (Amount to Cover / Total Liquidity) floor number The base policy floor rate ceiling number The base policy ceiling rate rate number The annualized percentage required to purchase this policy for the specified amount

## Purchase Policy

import { ChainId, policy } from '@neptunemutual/sdk'import { info } from './info.js'import { getProvider } from './provider.js'import { ether } from './bn.js'​const purcahse = async () => {  const { key } = info  const provider = getProvider()​  const args = {    duration: 2,    amount: ether(10_000) // <-- Amount to Cover (In DAI)  }​  // First approve the Policy contract to spend your DAI, USDC, or BUSD  await policy.approve(ChainId.Mumbai, {}, provider)​  const response = await policy.purchaseCover(ChainId.Mumbai, key, args, provider)  console.info(response)}​purcahse()​/*****************************************************************************[info] {  status: 'Success',  result: {    nonce: 1,    gasPrice: BigNumber { _hex: '0x06fc23ac00', _isBigNumber: true },    gasLimit: BigNumber { _hex: '0x2f788c', _isBigNumber: true },    to: '0x50443BED0C90987D3A3715f0A90e60503BB548dD',    value: BigNumber { _hex: '0x00', _isBigNumber: true },    data: '0x02bbd6e570726f746f3a636f6e7472616374733a636f7665723a6366633a303100000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000021e19e0c9bab2400000',    chainId: 80001,    v: 160038,    r: '0xc6539f52dfb2fc026bdef71082dccdcfd886fa6cef06c1d507ba18d1bbe6ed33',    s: '0x2b2ca2256d0a9513bc503e5f8496f54def3b2fb2ef9e2a988a0f21167a3c7cbe',    from: '0x076F91C0A411197e6Fce476F37c6385CCeacd26D',    hash: '0x1e6d351385c19d13e7e08fb372d23100d8000ef916909b18fabeb40252f9eb47',    type: null,    wait: [Function (anonymous)]  }}*****************************************************************************/