TrustfulRiskModule

This is an implementation of the RiskModule that relays fully on trusted accounts to price and resolve the policies.

Roles

The specific functions of the contract are as follows:

RoleGlobal*DescriptionMethods Accessible

PRICER_ROLE

Creates new policies.

  • newPolicy: Creates a new policy.

  • newPolicyFull: Creates a new policy with all its details and returns the created policy data.

RESOLVER_ROLE

Resolves policies.

  • resolvePolicy: Resolves a policy by executing the necessary actions within the contract.

  • resolvePolicyFullPayout: Resolves a policy with full payout.

( * ) Global means that the role can be delegated to a user at the protocol level (for all components) or only for a specific component. Non-global roles can only be granted for a specific component.

External Methods

newPolicy

function newPolicy(uint256 payout, uint256 premium, uint256 lossProb, uint40 expiration, address onBehalfOf, uint96 internalId) external returns (uint256)

Creates a new Policy

Requirements:

  • The caller has been granted componentRole(PRICER_ROLE)

Emits:

  • {PolicyPool.NewPolicy}

NameTypeDescription

payout

uint256

The exposure (maximum payout) of the policy

premium

uint256

The premium that will be paid by the policyHolder

lossProb

uint256

The probability of having to pay the maximum payout (wad)

expiration

uint40

The expiration of the policy (timestamp)

onBehalfOf

address

The policy holder

internalId

uint96

An id that's unique within this module and it will be used to identify the policy

NameTypeDescription

[0]

uint256

Returns the id of the created policy

resolvePolicy

function resolvePolicy(struct Policy.PolicyData policy, uint256 payout) external

Resolves a policy, if payout > 0, it pays to the policy holder.

Requirements:

  • The caller has been granted componentRole(RESOLVER_ROLE)

  • payout <= policy.payout

  • block.timestamp >= policy.expiration

Emits:

  • {PolicyPool.PolicyResolved}

NameTypeDescription

policy

struct Policy.PolicyData

The policy previously created (from {NewPolicy} event)

payout

uint256

The payout to transfer to the policy holder

resolvePolicyFullPayout

function resolvePolicyFullPayout(struct Policy.PolicyData policy, bool customerWon) external

Resolves a policy with full payout (policy.payout) if customerWon == true

Requirements:

  • The caller has been granted componentRole(RESOLVER_ROLE)

  • block.timestamp >= policy.expiration

Emits:

  • {PolicyPool.PolicyResolved}

NameTypeDescription

policy

struct Policy.PolicyData

The policy previously created (from {NewPolicy} event)

customerWon

bool

If true, policy.payout is transferred to the policy holder. If false, the policy is resolved without payout and can't be longer claimed.

Last updated