Fire insurance example components
This directory contains the set of contracts required for the fire insurance. The fire insurance example is a minimal fully permissioned set of example components that can be used to run a (very simple) fire insurance.
The product is built without a distribution and oracle component.
Contracts
FirePool
import "@etherisc/gif-next/contracts/examples/fire/FirePool.sol";
-
[
constructor(registry, fireProductNftId, componentName, authorization)
] -
[
_intialize(registry, fireProductNftId, componentName, poolInfo, authorization, initialOwner)
] -
[
createBundle(fee, initialAmount, lifetime)
] -
[
approveTokenHandler(token, amount)
] -
[
setLocked(locked)
] -
[
setWallet(newWallet)
]
-
[
_initializeBasicPool(registry, productNftId, name, poolInfo, authorization, initialOwner)
] -
[
stake(bundleNftId, amount)
] -
[
unstake(bundleNftId, amount)
] -
[
extend(bundleNftId, lifetimeExtension)
] -
[
setBundleLocked(bundleNftId, locked)
] -
[
closeBundle(bundleNftId)
] -
[
setBundleFee(bundleNftId, fee)
] -
[
withdrawBundleFees(bundleNftId, amount)
] -
[
setMaxBalanceAmount(maxBalanceAmount)
] -
[
setFees(poolFee, stakingFee, performanceFee)
]
-
[
getContractLocation(name)
] -
[
verifyApplication(applicationNftId, bundleNftId, collateralizationAmount)
] -
[
processConfirmedClaim(policyNftId, claimId, amount)
] -
[
applicationMatchesBundle(applicationNftId, applicationData, bundleNftId, bundleFilter, collateralizationAmount)
] -
[
getInitialPoolInfo()
] -
[
__Pool_init(registry, productNftId, name, poolInfo, authorization, initialOwner)
] -
[
_setPoolFees(poolFee, stakingFee, performanceFee)
] -
[
_setMaxBalanceAmount(maxBalanceAmount)
] -
[
_fundPoolWallet(amount)
] -
[
_defundPoolWallet(amount)
] -
[
_createBundle(bundleOwner, fee, lifetime, filter)
] -
[
_setBundleFee(bundleNftId, fee)
] -
[
_stake(bundleNftId, amount)
] -
[
_unstake(bundleNftId, amount)
] -
[
_extend(bundleNftId, lifetimeExtension)
] -
[
_setBundleLocked(bundleNftId, locked)
] -
[
_closeBundle(bundleNftId)
] -
[
_withdrawBundleFees(bundleNftId, amount)
] -
[
_processFundedClaim(policyNftId, claimId, availableAmount)
]
-
[
getInstance()
] -
[
getAuthorization()
] -
[
withdrawFees(amount)
] -
[
_sendRequest(oracleNftId, requestData, expiryAt, callbackMethod)
] -
[
_cancelRequest(requestId)
] -
[
_resendRequest(requestId)
] -
[
__InstanceLinkedComponent_init(registry, parentNftId, name, componentType, authorization, isInterceptor, initialOwner)
] -
[
_checkAndGetInstanceNftId(registryAddress, parentNftId, componentType)
] -
[
_checkAndGetRegistry(registryAddress, objectNftId, requiredType)
] -
[
_setWallet(newWallet)
] -
[
_getComponentInfo()
] -
[
_getInstanceReader()
] -
[
_withdrawFees(amount)
]
-
[
__Component_init(authority, registry, parentNftId, name, componentType, isInterceptor, initialOwner, registryData)
] -
[
nftTransferFrom(from, to, tokenId, operator)
] -
[
getWallet()
] -
[
getTokenHandler()
] -
[
getToken()
] -
[
getName()
] -
[
getVersion()
] -
[
getComponentInfo()
] -
[
getInitialComponentInfo()
] -
[
isNftInterceptor()
] -
[
isRegistered()
] -
[
_approveTokenHandler(token, amount)
] -
[
_nftTransferFrom(from, to, tokenId, operator)
] -
[
_setLocked(locked)
] -
[
_getServiceAddress(domain)
]
-
[
__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)
] -
[
isActive()
] -
[
getRelease()
] -
[
getInitialInfo()
]
-
[
_checkNftType(nftId, expectedObjectType)
] -
[
__NftOwnable_init(registry, initialOwner)
] -
[
linkToRegisteredNftId()
] -
[
getNftId()
] -
[
getOwner()
] -
[
_linkToNftOwnable(nftOwnableAddress)
]
-
[
__RegistryLinked_init(registry)
] -
[
getRegistry()
]
-
[
__ERC165_init()
] -
[
_initializeERC165()
] -
[
_registerInterface(interfaceId)
] -
[
_registerInterfaceNotInitializing(interfaceId)
] -
[
supportsInterface(interfaceId)
]
-
[
__AccessManaged_init(initialAuthority)
] -
[
__AccessManaged_init_unchained(initialAuthority)
] -
[
authority()
] -
[
setAuthority(newAuthority)
] -
[
isConsumingScheduledOp()
] -
[
_setAuthority(newAuthority)
] -
[
_checkCanCall(caller, data)
]
-
[
__Context_init()
] -
[
__Context_init_unchained()
] -
[
_msgSender()
] -
[
_msgData()
] -
[
_contextSuffixLength()
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
LogPoolVerifiedByPool(pool, applicationNftId, collateralizationAmount)
]
-
[
LogComponentWalletAddressChanged(oldWallet, newWallet)
] -
[
LogComponentWalletTokensTransferred(from, to, amount)
] -
[
LogComponentTokenHandlerApproved(tokenHandler, token, limit, isMaxAmount)
]
-
[
LogNftOwnableNftLinkedToAddress(nftId, owner)
]
-
[
AuthorityUpdated(authority)
]
-
[
Initialized(version)
]
constructor(address registry, NftId fireProductNftId, string componentName, contract IAuthorization authorization)
public
_intialize(address registry, NftId fireProductNftId, string componentName, struct IComponents.PoolInfo poolInfo, contract IAuthorization authorization, address initialOwner)
internal
FirePoolAuthorization
import "@etherisc/gif-next/contracts/examples/fire/FirePoolAuthorization.sol";
-
[
constructor(poolName)
] -
[
_setupTargetAuthorizations()
]
-
[
_setupServiceTargets()
] -
[
_setupTokenHandlerAuthorizations()
]
-
[
getTokenHandlerName()
] -
[
getTokenHandlerTarget()
] -
[
getTarget(targetName)
] -
[
getTargets()
] -
[
targetExists(target)
] -
[
_setupTargets()
] -
[
_setupRoles()
] -
[
_addCustomRole(roleId, adminRoleId, maxMemberCount, name)
] -
[
_addGifTarget(contractName)
] -
[
_addInstanceTarget(contractName)
] -
[
_addTarget(name)
] -
[
_toTargetRoleId(targetDomain)
] -
[
_toTargetRoleName(targetName)
]
-
[
getDomain()
] -
[
getRelease()
] -
[
getCommitHash()
] -
[
getMainTargetName()
] -
[
getMainTarget()
] -
[
getServiceDomains()
] -
[
getServiceDomain(idx)
] -
[
getServiceTarget(serviceDomain)
] -
[
getServiceRole(serviceDomain)
] -
[
getServiceAddress(serviceDomain)
] -
[
getTargetRole(target)
] -
[
roleExists(roleId)
] -
[
getRoles()
] -
[
getRoleInfo(roleId)
] -
[
getRoleName(roleId)
] -
[
getAuthorizedRoles(target)
] -
[
getAuthorizedFunctions(target, roleId)
] -
[
_setupDomains()
] -
[
_setupDomainAuthorizations()
] -
[
_authorizeServiceDomain(serviceDomain, serviceAddress)
] -
[
_addTargetWithRole(targetName, roleId, roleName)
] -
[
_addRole(roleId, info)
] -
[
_authorizeForService(serviceDomain, authorizedDomain)
] -
[
_authorizeForTarget(target, authorizedRoleId)
] -
[
_authorize(functions, selector, name)
]
-
[
__ERC165_init()
] -
[
_initializeERC165()
] -
[
_registerInterface(interfaceId)
] -
[
_registerInterfaceNotInitializing(interfaceId)
] -
[
supportsInterface(interfaceId)
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
Initialized(version)
]
FireProduct
import "@etherisc/gif-next/contracts/examples/fire/FireProduct.sol";
This is the product component for the fire insurance example. It show how to insure a house for a given suminsured in a city. The risk is based on the city. If a fire is reported in the city, the policy holder is able to submit a claim and get a payout.
-
[
constructor(registry, instanceNftid, componentName, authorization)
] -
[
_initialize(registry, instanceNftId, componentName, authorization, initialOwner)
] -
[
cities()
] -
[
city(idx)
] -
[
riskId(cityName)
] -
[
pauseCity(cityName)
] -
[
unpauseCity(cityName)
] -
[
calculatePremium(cityName, sumInsured, lifetime, bundleNftId)
] -
[
calculateNetPremium(sumInsured, , lifetime, )
] -
[
createApplication(cityName, sumInsured, lifetime, bundleNftId)
] -
[
initializeCity(cityName)
] -
[
createPolicy(policyNftId, activateAt)
] -
[
decline(policyNftId)
] -
[
expire(policyNftId, expireAt)
] -
[
close(policyNftId)
] -
[
reportFire(fireId, cityName, damageLevel, reportedAt)
] -
[
fire(fireId)
] -
[
submitClaim(policyNftId, fireId)
] -
[
_checkClaimConditions(policyNftId, policyInfo, fireId)
] -
[
_getClaimAmount(policyNftId, sumInsured, damageLevel)
] -
[
_damageLevelToPayoutPercentage(damageLevel)
] -
[
approveTokenHandler(token, amount)
] -
[
setLocked(locked)
] -
[
setWallet(newWallet)
]
-
[
setFees(productFee, processingFee)
] -
[
_initializeBasicProduct(registry, instanceNftId, name, productInfo, feeInfo, authorization, initialOwner)
]
-
[
registerComponent(component)
] -
[
processFundedClaim(policyNftId, claimId, availableAmount)
] -
[
calculatePremium(sumInsuredAmount, riskId, lifetime, applicationData, bundleNftId, referralId)
] -
[
getInitialProductInfo()
] -
[
getInitialFeeInfo()
] -
[
__Product_init(registry, instanceNftId, name, productInfo, feeInfo, authorization, initialOwner)
] -
[
_setFees(productFee, processingFee)
] -
[
_createRisk(id, data)
] -
[
_updateRisk(id, data)
] -
[
_setRiskLocked(id, locked)
] -
[
_closeRisk(id)
] -
[
_createApplication(applicationOwner, riskId, sumInsuredAmount, premiumAmount, lifetime, bundleNftId, referralId, applicationData)
] -
[
_revoke(applicationNftId)
] -
[
_createPolicy(applicationNftId, activateAt, maxPremiumAmount)
] -
[
_decline(policyNftId)
] -
[
_expire(policyNftId, expireAt)
] -
[
_adjustActivation(policyNftId, activateAt)
] -
[
_collectPremium(policyNftId, activateAt)
] -
[
_activate(policyNftId, activateAt)
] -
[
_close(policyNftId)
] -
[
_submitClaim(policyNftId, claimAmount, claimData)
] -
[
_revokeClaim(policyNftId, claimId)
] -
[
_confirmClaim(policyNftId, claimId, confirmedAmount, data)
] -
[
_declineClaim(policyNftId, claimId, data)
] -
[
_cancelConfirmedClaim(policyNftId, claimId)
] -
[
_createPayout(policyNftId, claimId, amount, data)
] -
[
_createPayoutForBeneficiary(policyNftId, claimId, amount, beneficiary, data)
] -
[
_processPayout(policyNftId, payoutId)
] -
[
_cancelPayout(policyNftId, payoutId)
] -
[
_getProductStorage()
]
-
[
getInstance()
] -
[
getAuthorization()
] -
[
withdrawFees(amount)
] -
[
_sendRequest(oracleNftId, requestData, expiryAt, callbackMethod)
] -
[
_cancelRequest(requestId)
] -
[
_resendRequest(requestId)
] -
[
__InstanceLinkedComponent_init(registry, parentNftId, name, componentType, authorization, isInterceptor, initialOwner)
] -
[
_checkAndGetInstanceNftId(registryAddress, parentNftId, componentType)
] -
[
_checkAndGetRegistry(registryAddress, objectNftId, requiredType)
] -
[
_setWallet(newWallet)
] -
[
_getComponentInfo()
] -
[
_getInstanceReader()
] -
[
_withdrawFees(amount)
]
-
[
__Component_init(authority, registry, parentNftId, name, componentType, isInterceptor, initialOwner, registryData)
] -
[
nftTransferFrom(from, to, tokenId, operator)
] -
[
getWallet()
] -
[
getTokenHandler()
] -
[
getToken()
] -
[
getName()
] -
[
getVersion()
] -
[
getComponentInfo()
] -
[
getInitialComponentInfo()
] -
[
isNftInterceptor()
] -
[
isRegistered()
] -
[
_approveTokenHandler(token, amount)
] -
[
_nftTransferFrom(from, to, tokenId, operator)
] -
[
_setLocked(locked)
] -
[
_getServiceAddress(domain)
]
-
[
__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)
] -
[
isActive()
] -
[
getRelease()
] -
[
getInitialInfo()
]
-
[
_checkNftType(nftId, expectedObjectType)
] -
[
__NftOwnable_init(registry, initialOwner)
] -
[
linkToRegisteredNftId()
] -
[
getNftId()
] -
[
getOwner()
] -
[
_linkToNftOwnable(nftOwnableAddress)
]
-
[
__RegistryLinked_init(registry)
] -
[
getRegistry()
]
-
[
__ERC165_init()
] -
[
_initializeERC165()
] -
[
_registerInterface(interfaceId)
] -
[
_registerInterfaceNotInitializing(interfaceId)
] -
[
supportsInterface(interfaceId)
]
-
[
__AccessManaged_init(initialAuthority)
] -
[
__AccessManaged_init_unchained(initialAuthority)
] -
[
authority()
] -
[
setAuthority(newAuthority)
] -
[
isConsumingScheduledOp()
] -
[
_setAuthority(newAuthority)
] -
[
_checkCanCall(caller, data)
]
-
[
__Context_init()
] -
[
__Context_init_unchained()
] -
[
_msgSender()
] -
[
_msgData()
] -
[
_contextSuffixLength()
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
LogComponentWalletAddressChanged(oldWallet, newWallet)
] -
[
LogComponentWalletTokensTransferred(from, to, amount)
] -
[
LogComponentTokenHandlerApproved(tokenHandler, token, limit, isMaxAmount)
]
-
[
LogNftOwnableNftLinkedToAddress(nftId, owner)
]
-
[
AuthorityUpdated(authority)
]
-
[
Initialized(version)
]
constructor(address registry, NftId instanceNftid, string componentName, contract IAuthorization authorization)
public
_initialize(address registry, NftId instanceNftId, string componentName, contract IAuthorization authorization, address initialOwner)
internal
calculatePremium(string cityName, Amount sumInsured, Seconds lifetime, NftId bundleNftId) → Amount premiumAmount
public
calculateNetPremium(Amount sumInsured, RiskId, Seconds lifetime, bytes) → Amount netPremiumAmount
external
createApplication(string cityName, Amount sumInsured, Seconds lifetime, NftId bundleNftId) → NftId policyNftId
public
createPolicy(NftId policyNftId, Timestamp activateAt)
public
Calling this method will lock the sum insured amount in the pool and activate the policy at the given time. It will also collect the tokens payment for the premium. An approval with the correct amount towards the TokenHandler of the product is therefor required.
FireProductAuthorization
import "@etherisc/gif-next/contracts/examples/fire/FireProductAuthorization.sol";
-
[
constructor(poolName)
] -
[
_setupTargetAuthorizations()
]
-
[
_setupServiceTargets()
] -
[
_setupTokenHandlerAuthorizations()
]
-
[
getTokenHandlerName()
] -
[
getTokenHandlerTarget()
] -
[
getTarget(targetName)
] -
[
getTargets()
] -
[
targetExists(target)
] -
[
_setupTargets()
] -
[
_setupRoles()
] -
[
_addCustomRole(roleId, adminRoleId, maxMemberCount, name)
] -
[
_addGifTarget(contractName)
] -
[
_addInstanceTarget(contractName)
] -
[
_addTarget(name)
] -
[
_toTargetRoleId(targetDomain)
] -
[
_toTargetRoleName(targetName)
]
-
[
getDomain()
] -
[
getRelease()
] -
[
getCommitHash()
] -
[
getMainTargetName()
] -
[
getMainTarget()
] -
[
getServiceDomains()
] -
[
getServiceDomain(idx)
] -
[
getServiceTarget(serviceDomain)
] -
[
getServiceRole(serviceDomain)
] -
[
getServiceAddress(serviceDomain)
] -
[
getTargetRole(target)
] -
[
roleExists(roleId)
] -
[
getRoles()
] -
[
getRoleInfo(roleId)
] -
[
getRoleName(roleId)
] -
[
getAuthorizedRoles(target)
] -
[
getAuthorizedFunctions(target, roleId)
] -
[
_setupDomains()
] -
[
_setupDomainAuthorizations()
] -
[
_authorizeServiceDomain(serviceDomain, serviceAddress)
] -
[
_addTargetWithRole(targetName, roleId, roleName)
] -
[
_addRole(roleId, info)
] -
[
_authorizeForService(serviceDomain, authorizedDomain)
] -
[
_authorizeForTarget(target, authorizedRoleId)
] -
[
_authorize(functions, selector, name)
]
-
[
__ERC165_init()
] -
[
_initializeERC165()
] -
[
_registerInterface(interfaceId)
] -
[
_registerInterfaceNotInitializing(interfaceId)
] -
[
supportsInterface(interfaceId)
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
Initialized(version)
]
FireUSD
import "@etherisc/gif-next/contracts/examples/fire/FireUSD.sol";
FireUSD is a stablecoin with 6 decimals and an initial supply of 1 Billion tokens.
-
[
constructor()
] -
[
decimals()
]
-
[
name()
] -
[
symbol()
] -
[
totalSupply()
] -
[
balanceOf(account)
] -
[
transfer(to, value)
] -
[
allowance(owner, spender)
] -
[
approve(spender, value)
] -
[
transferFrom(from, to, value)
] -
[
_transfer(from, to, value)
] -
[
_update(from, to, value)
] -
[
_mint(account, value)
] -
[
_burn(account, value)
] -
[
_approve(owner, spender, value)
] -
[
_approve(owner, spender, value, emitEvent)
] -
[
_spendAllowance(owner, spender, value)
]
-
[
Transfer(from, to, value)
] -
[
Approval(owner, spender, value)
]
decimals() → uint8
public
Returns the number of decimals used to get its user representation.
For example, if decimals
equals 2
, a balance of 505
tokens should
be displayed to a user as 5.05
(505 / 10 ** 2
).
Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the default value returned by this function, unless it’s overridden.
This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}. |