Skip to content
LogoLogo

Configure Earn Exit-Safe Policy

earn.configureExitSafePolicy

Creates and attaches an admission-only TIP-403 policy to an Earn share token. Existing holders can continue sending shares, while recipients and mint recipients must belong to the same whitelist.

The action submits three or four sequential transactions and is not atomic. Use earn.validateExitSafePolicy to verify the final onchain state before publishing a protected deployment.

Usage

import {  } from './viem.config'
 
const { ,  } = await ..({
  : '0x0000000000000000000000000000000000000002',
  : [
    '0x0000000000000000000000000000000000000003',
    '0x0000000000000000000000000000000000000004',
  ],
  : '0x20c0000000000000000000000000000000000001',
})

Recipes

Protect a Vault Before Launch

Resolve the share token with earn.getVault, then confirm the non-atomic setup with earn.validateExitSafePolicy before announcing the vault.

import {  } from './viem.config'
 
const  = '0x0000000000000000000000000000000000000001'
const  = '0x8ba1f109551bD432803012645Ac136ddd64DBA72'
const  = [, ] as 
 
const {  } = await ..({  })
const {  } = await ..({
  : ..,
  : ,
  ,
})
 
await ..({
  : ..,
  ,
  ,
  ,
})

Include every protocol address that must keep receiving Earn shares, such as the vault and active fee recipients. See Protected Vaults for the complete member checklist, and store the returned policy IDs with the deployment record.

Delegate Eligibility to a Compliance Team

Pass an accessAdministrator other than the caller to hand whitelist control to the team that approves recipients. The action submits a fourth transaction transferring administration.

import {  } from './viem.config'
 
const  = '0x8ba1f109551bD432803012645Ac136ddd64DBA72'
 
const {  } = await ..({
  : ,
  : ['0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb'],
  : '0x20c0000000000000000000000000000000000001',
})
 
.(.?.)
success

After the transfer, only the administrator can update membership with policy.modifyWhitelist.

Return Value

type ReturnValue = {
  policy: {
    transferPolicyId: bigint
    senderPolicyId: bigint
    recipientPolicyId: bigint
    mintRecipientPolicyId: bigint
  }
  receipts: {
    eligibilityPolicy: TransactionReceipt
    compoundPolicy: TransactionReceipt
    tokenPolicy: TransactionReceipt
    policyAdmin?: TransactionReceipt
  }
}

senderPolicyId is the always-allow policy. recipientPolicyId and mintRecipientPolicyId identify the same whitelist.

Parameters

accessAdministrator

  • Type: Address

Address that will administer recipient eligibility. The admin-transfer transaction is skipped when this is the calling account.

initialMembers

  • Type: readonly Address[]

Addresses initially eligible to receive transfers and mints. Duplicate addresses are removed. At least one member is required.

shareToken

  • Type: Address

Earn share token. The calling account must be authorized to change its transfer policy.

account (optional)

  • Type: Account | Address
  • Default: client.account

Account that creates the policies and changes the share token transfer policy.