Settlement Mechanics

Receiver System Overview

Receiver Contract

function getReceiver(
    address controller,
    bytes memory key
) public returns (address receiverAddress)

Process:

  1. Generate unique key for operation

  2. Deploy or retrieve receiver contract

  3. Configure permissions

  4. Track receivers per controller

Key Generation

// Single vault operation
bytes memory key = abi.encode(superformId);

// Multi vault operation
bytes memory key = abi.encode(superformIds);

Settlement Process

Cross-Chain Asset Reception

Settlement Types

1. Liquidation Settlement

function settleLiquidation(
    address controller,
    uint256[] calldata superformIds
) external onlyRoles(RELAYER_ROLE)

Used for:

  • Cross-chain withdrawals

  • Emergency liquidations

  • Forced exits

Process:

  1. Get receiver contract

  2. Check settled assets

  3. Pull assets from receiver

  4. Transfer to vault

  5. Fulfill settled request

2. Divest Settlement

function settleDivest(
    uint256[] calldata superformIds
) external onlyRoles(RELAYER_ROLE)

Used for:

  • Normal cross-chain withdrawals

  • Strategy exits

  • Rebalancing operations

Process:

  1. Generate/retrieve receiver

  2. Pull settled assets

  3. Update pending divests

  4. Notify vault

  5. Update total idle

State Updates

Pre-Settlement State

mapping(address => mapping(bytes => uint256)) public requestedAssets;
uint256 public totalPendingXChainDivests;

Post-Settlement State

mapping(address => ERC7540_FilledRequest) private _claimableRedeemRequest;
uint128 internal _totalIdle;

Receiver Contract Lifecycle

1. Deployment

receiverAddress = LibClone.clone(
    receiverImplementation,
    abi.encodeWithSignature(
        "initialize(address)",
        controller,
        key
    )
);

2. Usage

// Track receiver
receivers[controller][key] = receiverAddress;

// Pull assets
ERC20Receiver(receiverAddress).pull(settledAssets);

3. State Management

  • Tracks balances per operation

  • Maintains operation keys

  • Handles permissions

Security Considerations

Asset Safety

  • Only gateway can pull assets

  • Controller-specific receivers

  • Key-based segregation

State Consistency

  • Atomic updates

  • Balance verification

  • Settlement confirmation

Recovery Mechanisms

// Handle failed settlements
function handleFailedSettlement(
    address receiver,
    bytes memory key
) external onlyRole(EMERGENCY_ADMIN_ROLE)
  • See Core Operations for withdrawal process

  • See State Management for request states

  • See Asset Management for accounting

Last updated