manifoldfinance / fold-staking

Captive Staking Insurance Protocol
https://manifoldfinance.github.io/fold-staking/
1 stars 0 forks source link

Outline `claimInsurance` process and workflow #9

Open sambacha opened 1 month ago

sambacha commented 1 month ago

Currently, claimInsurance does not have the logic necessary to 'validate' a claim. This is because the management of captive insurance claims is handled by us, which is why it is called Captive Insurance.

Until the L2 Construct is implemented for v2 supporting multiple relays, this is fine. However, we should outline and document how exactly a claim is substantiated. Typically, the insured party must provide notice to their insurance carrier for potential claims. Therefore, it is up to the underlying LST/Validator/Node Operator to initiate this process, it is not up to us to initialize the process for paying out a claim.

sandybradley commented 1 month ago

How about a flow more like ...

struct Claim {
    address claimant;
    uint128 liquidityClaimed;
    uint256 timestamp;
    bool approved;
}

mapping(uint256 => Claim) public claims;
uint256 public claimCounter;

function submitClaim(uint128 liquidity) external {
    require(liquidity <= balances[msg.sender].amount, "Insufficient liquidity");
    claimCounter++;
    claims[claimCounter] = Claim(msg.sender, liquidity, block.timestamp, false);
    emit ClaimSubmitted(msg.sender, liquidity, block.timestamp);
}

function approveClaim(uint256 claimId) external onlyOwner {
    Claim storage claim = claims[claimId];
    require(!claim.approved, "Claim already approved");
    claim.approved = true;
    _processClaim(claim);
}

function _processClaim(Claim memory claim) internal {
    // Logic to withdraw liquidity and transfer funds to claimant
}

event ClaimSubmitted(address indexed claimant, uint128 liquidity, uint256 timestamp);