Claim Protocol

How It Works

LegacyVault utilizes a Permissionless Claim mechanism for the designated beneficiary. Once the Dead Man's Switch timer has expired, the "ownership" of the funds effectively shifts. There is no need for probate courts, lawyers, or manual approval.

The Mechanism

A. The Claim Process

When the Beneficiary calls claim_token(), the smart contract executes a three-step validation before releasing funds:

1

Identity Check

Only the address stored in beneficiary can call this function.

2

Time Check

The contract calculates if block.timestamp has passed the deadline.

3

Asset Routing

The contract intelligently checks where the funds are (Wallet vs Lending Pool) and retrieves them.

B. Intelligent Withdrawal Logic

The code handles two scenarios automatically:

  • Idle Assets: If tokens are sitting in the Vault, they are transferred directly.

  • Invested Assets: If tokens (USDC) are in the Lending Pool, the contract triggers a withdrawal from the pool directly to the beneficiary, ensuring they get the Principal + Interest.

BE/vault-logic/src/lib.rs
// Actual logic from BE/vault-logic/src/lib.rs

pub fn claim_token(&mut self, token_address: Address) -> Result<(), Vec<u8>> {
    // ... Identity checks ...

    // 1. Time Validation
    let deadline = self.last_ping.get() + self.duration.get();
    if U256::from(block::timestamp()) < deadline { 
        return Err(b"Owner masih aktif".to_vec()); 
    }

    // 2. Lending Pool Integration (Principal + Interest)
    if is_usdc {
        // ... Check pool balance ...
        if pool_balance > U256::ZERO {
            // Withdraw directly to beneficiary
            let _ = pool.withdraw(config_withdraw, beneficiary)?;
            return Ok(());
        }
    }

    // 3. Fallback: Transfer local vault balance
    let _ = token.transfer(config_transfer, beneficiary, bal)?;
    Ok(())
}