Claims & Payouts

Supply your cTokens to the Claims Processor contract to receive the payout in stablecoin tokens.

import { ChainId, governance, claimsProcessor, cToken, utils } from '@neptunemutual/sdk'
import { info } from './info.js'
import { getProvider } from './provider.js'
import { ether } from './bn.js'
const getCToken = async (key) => {
const policyDuration = 2 // 2 months
const expiryDate = utils.date.getExpiryDate(policyDuration, new Date())
const { result } = await cToken.getCTokenByExpiryDate(ChainId.Mumbai, key, expiryDate)
return result
}
const claim = async () => {
try {
const { key } = info
const provider = getProvider()
const amount = ether(50_000)
const instance = await getCToken(key)
// Approve the claims processor to spend your cTokens
await claimsProcessor.approve(ChainId.Mumbai, instance.address, {}, provider)
// Get the incident date and submit a claim
const incidentDate = (await governance.getIncidentDate(ChainId.Mumbai, key, provider)).result
await claimsProcessor.claim(ChainId.Mumbai, instance.address, key, incidentDate, amount, provider)
console.info('We\'ve sent you the payout')
} catch (error) {
console.error(error)
}
}
claim()
/*****************************************************************************
[info] We've sent you the payout
*****************************************************************************/

Ensure that you submit a claim only when the resolution occurs or else, you may receive an error message

/*****************************************************************************
[error] Error: execution reverted: Claim denied
at getResult (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:132:21)
at processJsonFunc (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:309:22)
at /projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:241:46
at step (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
code: 3,
data: '0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c436c61696d2064656e6965640000000000000000000000000000000000000000'
}
*****************************************************************************/