Claims & Payouts
Supply your cTokens to the Claims Processor contract to receive the payout in stablecoin tokens.
1
import { ChainId, governance, claimsProcessor, cToken, utils } from '@neptunemutual/sdk'
2
import { info } from './info.js'
3
import { getProvider } from './provider.js'
4
import { ether } from './bn.js'
5
6
const getCToken = async (key) => {
7
const policyDuration = 2 // 2 months
8
const expiryDate = utils.date.getExpiryDate(policyDuration, new Date())
9
const { result } = await cToken.getCTokenByExpiryDate(ChainId.Mumbai, key, expiryDate)
10
11
return result
12
}
13
14
const claim = async () => {
15
try {
16
const { key } = info
17
const provider = getProvider()
18
const amount = ether(50_000)
19
20
const instance = await getCToken(key)
21
22
// Approve the claims processor to spend your cTokens
23
await claimsProcessor.approve(ChainId.Mumbai, instance.address, {}, provider)
24
25
// Get the incident date and submit a claim
26
const incidentDate = (await governance.getIncidentDate(ChainId.Mumbai, key, provider)).result
27
await claimsProcessor.claim(ChainId.Mumbai, instance.address, key, incidentDate, amount, provider)
28
29
console.info('We\'ve sent you the payout')
30
} catch (error) {
31
console.error(error)
32
}
33
}
34
35
claim()
36
37
/*****************************************************************************
38
[info] We've sent you the payout
39
*****************************************************************************/
Copied!
Ensure that you submit a claim only when the resolution occurs or else, you may receive an error message
1
/*****************************************************************************
2
[error] Error: execution reverted: Claim denied
3
at getResult (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:132:21)
4
at processJsonFunc (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:309:22)
5
at /projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:241:46
6
at step (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:33:23)
7
at Object.next (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:14:53)
8
at fulfilled (/projects/@neptunemutual/sdk-test/node_modules/@ethersproject/web/lib/index.js:5:58)
9
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
10
code: 3,
11
data: '0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c436c61696d2064656e6965640000000000000000000000000000000000000000'
12
}
13
*****************************************************************************/
Copied!
Last modified 4mo ago
Copy link