Services

This document is better viewed at https://docs.etherisc.com/contracts/api/services

Contracts

ComponentOwnerService

import "@etherisc/gif-contracts/contracts/services/ComponentOwnerService.sol";
Events
Initializable

onlyOwnerWithRoleFromComponent(contract IComponent component) modifier

onlyOwnerWithRole(uint256 id) modifier

_afterInitialize() internal

This function is called after the contract is initialized and can only be called once. It sets the component controller contract address.

propose(contract IComponent component) external

Propose a new component to be added to the system.

stake(uint256 id) external

Stake function allows the owner to stake a specific id.

withdraw(uint256 id) external

Allows the owner to withdraw a specific asset by its ID.

pause(uint256 id) external

Pauses a specific component with the given ID.

unpause(uint256 id) external

Unpauses a component with the specified ID.

archive(uint256 id) external

Archives a component with the given ID from the component owner’s inventory.

InstanceOperatorService

import "@etherisc/gif-contracts/contracts/services/InstanceOperatorService.sol";

onlyInstanceOperatorAddress() modifier

_afterInitialize() internal

Performs the necessary setup after contract initialization. - Sets the component, pool, and treasury contracts. - Transfers ownership to the message sender. - Links the bundle module to the bundle token. - Sets the default admin role.

prepareRelease(bytes32 _newRelease) external

Prepares a new release by calling the prepareRelease function from the Registry contract.

register(bytes32 _contractName, address _contractAddress) external

Registers a contract in the registry.

deregister(bytes32 _contractName) external

Deregisters a contract from the registry.

registerInRelease(bytes32 _release, bytes32 _contractName, address _contractAddress) external

Registers a contract in a specific release.

deregisterInRelease(bytes32 _release, bytes32 _contractName) external

Deregisters a contract from a specific release in the registry.

createRole(bytes32 _role) external

Adds a new role to the access control contract.

invalidateRole(bytes32 _role) external

Invalidates a role.

grantRole(bytes32 role, address principal) external

Grants a role to a principal.

revokeRole(bytes32 role, address principal) external

Revokes a role from a principal.

approve(uint256 id) external

Approves a component with the given ID and sets its corresponding riskpool ID in the pool contract.

decline(uint256 id) external

Declines a component with the specified ID.

suspend(uint256 id) external

Suspends the component with the given ID.

resume(uint256 id) external

Resumes the execution of a paused component instance.

archive(uint256 id) external

Archives a component with the given ID from the instance operator’s address.

setDefaultStaking(uint16 componentType, bytes data) external

Sets the default staking for a specific component type.

adjustStakingRequirements(uint256 id, bytes data) external

Adjusts the staking requirements for a specific instance operator by providing the operator ID and the new staking requirements.

suspendTreasury() external

Suspends the treasury functionality.

resumeTreasury() external

Resumes the treasury contract.

setInstanceWallet(address walletAddress) external

Sets the wallet address of the instance operator.

setRiskpoolWallet(uint256 riskpoolId, address riskpoolWalletAddress) external

Sets the wallet address for a specific risk pool.

setProductToken(uint256 productId, address erc20Address) external

Sets the ERC20 token address for a given product ID.

createFeeSpecification(uint256 componentId, uint256 fixedFee, uint256 fractionalFee, bytes feeCalculationData) → struct ITreasury.FeeSpecification external

Returns a FeeSpecification object created with the given parameters.

setPremiumFees(struct ITreasury.FeeSpecification feeSpec) external

Sets the premium fees for the treasury.

setCapitalFees(struct ITreasury.FeeSpecification feeSpec) external

Sets the fee specification for capital fees in the treasury contract.

InstanceService

import "@etherisc/gif-contracts/contracts/services/InstanceService.sol";
Events
Initializable

_afterInitialize() internal

Internal function that is called after initialization is complete. It sets the bundle, component, policy, pool, and treasury controllers by retrieving their contract addresses. It also sets the chain names.

_setChainNames() internal

Sets the names for several blockchain networks by assigning them to their respective chain IDs.

Sets the names for the Ethereum Mainnet/ETH, Goerli/ETH, Ganache, Gnosis/xDai, Sokol/SPOA, Polygon Mainnet/MATIC, Mumbai/MATIC, Avalanche C-Chain/AVAX and Avalanche Fuji Testnet/AVAX blockchain networks by assigning them to their respective chain IDs.

getChainId() → uint256 chainId public

Returns the chain ID of the current blockchain.

getChainName() → string chainName public

Returns the name of the chain based on its ID.

getInstanceId() → bytes32 instanceId public

Returns the instance ID of the contract, which is a hash of the chain ID and the registry address.

getInstanceOperator() → address external

Returns the address of the current instance operator.

getComponentOwnerService() → contract IComponentOwnerService service external

Returns the address of the Component Owner Service contract.

getInstanceOperatorService() → contract IInstanceOperatorService service external

Returns the instance operator service contract address.

getOracleService() → contract IOracleService service external

Returns the Oracle Service contract instance.

getProductService() → contract IProductService service external

Returns the address of the Product Service contract.

getRiskpoolService() → contract IRiskpoolService service external

Returns the IRiskpoolService contract instance.

getRegistry() → contract IRegistry service external

Returns the current instance of the IRegistry contract.

contracts() → uint256 numberOfContracts external

Returns the number of contracts registered in the registry.

contractName(uint256 idx) → bytes32 name external

Returns the name of the contract at the specified index in the registry.

getDefaultAdminRole() → bytes32 external

Returns the default admin role for the AccessControl contract.

getProductOwnerRole() → bytes32 external

Returns the role identifier of the product owner role.

getOracleProviderRole() → bytes32 external

Returns the role identifier for the oracle provider role.

getRiskpoolKeeperRole() → bytes32 external

Returns the role identifier for the Riskpool Keeper role.

hasRole(bytes32 role, address principal) → bool external

Checks if an address has a specific role.

products() → uint256 external

Returns the number of products in the component contract.

oracles() → uint256 external

Returns the number of oracles registered in the component.

riskpools() → uint256 external

Returns the number of risk pools in the component.

getComponentId(address componentAddress) → uint256 componentId external

Returns the component ID of a given component address.

getComponentType(uint256 componentId) → enum IComponent.ComponentType componentType external

Returns the type of a component given its ID.

getComponentState(uint256 componentId) → enum IComponent.ComponentState componentState external

Returns the current state of a specific component.

getComponent(uint256 id) → contract IComponent external

Returns the component with the specified ID.

getOracleId(uint256 idx) → uint256 oracleId public

Returns the oracle ID at the specified index.

getRiskpoolId(uint256 idx) → uint256 riskpoolId public

Returns the riskpool ID for the given index.

getProductId(uint256 idx) → uint256 productId public

Returns the product ID of the component at the given index.

getStakingRequirements(uint256 id) → bytes data external

Returns the staking requirements for a specific ID.

getStakedAssets(uint256 id) → bytes data external

Returns the staked assets for a given ID.

processIds() → uint256 numberOfProcessIds external

Returns the number of process IDs in the policy contract.

getMetadata(bytes32 bpKey) → struct IPolicy.Metadata metadata external

Returns the metadata associated with a given business process key.

getApplication(bytes32 processId) → struct IPolicy.Application application external

Returns the application data associated with the given process ID.

getPolicy(bytes32 processId) → struct IPolicy.Policy policy external

Returns the policy associated with the given process ID.

claims(bytes32 processId) → uint256 numberOfClaims external

Returns the number of claims associated with a given process ID.

payouts(bytes32 processId) → uint256 numberOfPayouts external

Returns the number of payouts for a given processId.

getClaim(bytes32 processId, uint256 claimId) → struct IPolicy.Claim claim external

Returns the claim with the given claimId for the specified processId.

getPayout(bytes32 processId, uint256 payoutId) → struct IPolicy.Payout payout external

Returns the information of a specific payout.

getRiskpool(uint256 riskpoolId) → struct IPool.Pool riskPool external

Returns the risk pool with the given ID.

getFullCollateralizationLevel() → uint256 external

Returns the full collateralization level of the pool.

getCapital(uint256 riskpoolId) → uint256 capitalAmount external

Returns the capital amount of a given risk pool.

getTotalValueLocked(uint256 riskpoolId) → uint256 totalValueLockedAmount external

Returns the total value locked in a specific risk pool.

getCapacity(uint256 riskpoolId) → uint256 capacityAmount external

Returns the available capacity of a risk pool.

getBalance(uint256 riskpoolId) → uint256 balanceAmount external

Returns the balance amount of a specific risk pool.

activeBundles(uint256 riskpoolId) → uint256 numberOfActiveBundles external

Returns the number of active bundles for a given risk pool.

getActiveBundleId(uint256 riskpoolId, uint256 bundleIdx) → uint256 bundleId external

Returns the active bundle ID for a given risk pool and bundle index.

getMaximumNumberOfActiveBundles(uint256 riskpoolId) → uint256 maximumNumberOfActiveBundles external

Returns the maximum number of active bundles for a given risk pool ID.

getBundleToken() → contract IBundleToken token external

Returns the bundle token contract address.

getBundle(uint256 bundleId) → struct IBundle.Bundle bundle external

Returns the bundle with the given ID.

bundles() → uint256 external

Returns the number of bundles in the _bundle contract.

unburntBundles(uint256 riskpoolId) → uint256 numberOfUnburntBundles external

Returns the number of unburnt bundles for a given risk pool ID.

getTreasuryAddress() → address external

Returns the address of the treasury contract.

getInstanceWallet() → address external

Returns the address of the instance wallet associated with the treasury.

getRiskpoolWallet(uint256 riskpoolId) → address external

Returns the wallet address of the specified riskpool.

getComponentToken(uint256 componentId) → contract IERC20 external

Returns the IERC20 token associated with the given component ID.

getFeeFractionFullUnit() → uint256 external

Returns the fraction of the treasury fee expressed in full units.

OracleService

import "@etherisc/gif-contracts/contracts/services/OracleService.sol";
Events
Initializable

_afterInitialize() internal

Sets the _query variable to an instance of the IQuery contract.

respond(uint256 _requestId, bytes _data) external

Allows a registered oracle to respond to a data request.

ProductService

import "@etherisc/gif-contracts/contracts/services/ProductService.sol";

constructor(address _registry) public

Constructor function that initializes the contract with a registry address.

fallback() external

Fallback function that ensures the caller is a registered product and authorized to execute the delegated policy flow.

_delegate(address implementation) internal

Delegates the current call to implementation.

_license() → contract ILicense internal

Returns the instance of the License contract.

RiskpoolService

import "@etherisc/gif-contracts/contracts/services/RiskpoolService.sol";
Events
Initializable

onlyProposedRiskpool() modifier

onlyActiveRiskpool() modifier

onlyOwningRiskpool(uint256 bundleId, bool mustBeActive) modifier

onlyOwningRiskpoolId(uint256 riskpoolId, bool mustBeActive) modifier

_afterInitialize() internal

Sets the addresses of the BundleController, ComponentController, PoolController, and TreasuryModule contracts.

registerRiskpool(address wallet, address erc20Token, uint256 collateralizationLevel, uint256 sumOfSumInsuredCap) external

Registers a new risk pool with the given parameters.

createBundle(address owner, bytes filter, uint256 initialCapital) → uint256 bundleId external

Creates a new bundle with the given parameters and adds it to the active set of the riskpool.

fundBundle(uint256 bundleId, uint256 amount) → uint256 netAmount external

This function allows a user to fund a bundle with a specified amount.

defundBundle(uint256 bundleId, uint256 amount) → uint256 netAmount external

Defunds a bundle by withdrawing a specified amount of tokens from it.

lockBundle(uint256 bundleId) external

Locks a bundle, preventing it from being traded or redeemed.

unlockBundle(uint256 bundleId) external

Unlocks a bundle for trading by adding its ID to the active set of a risk pool and unlocking the bundle.

closeBundle(uint256 bundleId) external

Closes a bundle and removes it from the active set of the owning riskpool.

burnBundle(uint256 bundleId) external

Burns a closed bundle, withdrawing its remaining balance and defunding it from the riskpool and the pool.

collateralizePolicy(uint256 bundleId, bytes32 processId, uint256 collateralAmount) external

Collateralizes a policy by locking a specified amount of collateral for a given bundle and process ID.

processPremium(uint256 bundleId, bytes32 processId, uint256 amount) external

Processes a premium payment for a specific bundle.

processPayout(uint256 bundleId, bytes32 processId, uint256 amount) external

Processes a payout for a specific bundle.

releasePolicy(uint256 bundleId, bytes32 processId) → uint256 collateralAmount external

Releases a policy for a given bundle and process ID.

setMaximumNumberOfActiveBundles(uint256 riskpoolId, uint256 maxNumberOfActiveBundles) external

Sets the maximum number of active bundles for a given riskpool.