redeemPolicy

The process starts when the user requests the off-chain service for a redeem quote value. Most of the time, the redeem value will be less than the insurance premium fee that the user paid the first time they bought the policy, since some fees and some coverage duration have already been paid for. After the user gets the redemption value along with the merkle proofs, they use the "Redeem Policy" operation of the smart contract to call the "Policy Manager" contract with the associated data as parameters. After that, the "Policy Manager" contract will verify with the "Pricing Manager" contract's redeem value by using merkle proofs as a verification process.

If the redemption value check is successful, the "Policy Manager" contract will trigger the "RiskCarrier Manager." The "RiskCarrier Manager" then interacts to the external service provider to refund the fund. The token will then be sent from external service provider to the "Policy Manager" in the ratio set by the redemption value parameter for the risk carrier role.

The "Policy Manager" contract will stamp that the policy has been canceled. The user can finally receive their money back in an amount corresponding with the token's redemption value according to the accepted token standard.

redeemPolicy

function redeemPolicy(RedeemPolicyParams _redeemData_) external returns (bool)

The function redeemPolicy allows a user to redeem an insurance policy. The function takes a single parameter:

  • RedeemPolicyParams: A struct that contains information about the policy being redeemed. This includes the policy ID, redeem rate, risk carrier ratio, and signature valid until date. It also includes the v, r, and s values that are used in Ethereum transactions.

The function returns a boolean value indicating whether the policy redemption was successful or not. It also emits a PolicyRedeemed event, which includes information about the policy that was redeemed, such as the policyholder's address, policy ID, redeem amount, and risk carrier ratio. The risk carrier ratio appears to be the percentage of the redeem amount that is being transferred back to the policyholder.

Requirements:

  • nonReentrant The function must not be reentrant.

  • whenNotPaused The function must not be paused.

Events:

  • PolicyRedeemed - Emitted when the policy is redeemed successfully.

Parameters

NameTypeDescription

redeemData

The parameters of the policy to be redeemed.

Return Values

NameTypeDescription

[0]

bool

true if the policy is redeemed successfully.

RedeemPolicyParams

struct RedeemPolicyParams {
        string policyId;
        uint8 redeemRate;
        uint8 riskCarrierRatio;
        uint40 signatureValidUntil;
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

The RedeemPolicyParams struct is a data structure used to pass a set of parameters to the redeemPolicy() function. The struct consists of the following fields:

  • policyId: The ID of the policy being redeemed.

  • redeemRate: The rate at which the policy is being redeemed. This is typically a percentage of the total policy value.

  • riskCarrierRatio: The ratio of the policy's risk being transferred back to the policyholder. This is typically a percentage of the policy's redeem amount.

  • signatureValidUntil: The date until which the verifier's signature is valid.

  • v: The v value from the signed message that is used for signature verification.

  • r: The r value from the signed message that is used for signature verification.

  • s: The s value from the signed message that is used for signature verification.

The RedeemPolicyParams struct is used to pass all of the necessary information about redeeming a policy to the redeemPolicy() function. The function will use this information to calculate the redeem amount and transfer the appropriate amount back to the policyholder.

PolicyRedeemed

event PolicyRedeemed(
        address policyholder,
        string policyId,
        uint256 redeemAmount,
        uint8 redeemRate,
        uint8 riskCarrierRatio
    )

This PolicyRedeemed event is emitted when a policy is redeemed. The event includes the following parameters:

  • policyholder: the address of the policyholder who is redeeming the policy.

  • policyId: the unique identifier for the policy being redeemed.

  • redeemAmount: the amount being redeemed from the policy.

  • redeemRate: the rate at which the policy is being redeemed.

  • riskCarrierRatio: the percentage of the redeem amount that the risk carrier is required to transfer back to the policyholder.

Last updated