Automatic 5A updates and wash trading detection.
The Transfer Hook program is invoked on every VCoin transfer via Token-2022's transfer hook extension. It automatically updates 5A Activity scores and detects potential wash trading patterns.
Devnet Address: 9K14FcDRrBeHKD9FPNYeVJaEqJQTac2xspJyb1mM6m48
- Auto 5A Activity updates on transfer
- Wash trading detection between related accounts
- Tip recording for ViLink actions
- Engagement trust tracking
- No user action required - runs automatically
- User initiates VCoin transfer
- Token-2022 program calls transfer hook
- Hook executes before transfer completes:
- Updates sender's 5A Activity score
- Checks for wash trading patterns
- Records tip if from ViLink
- Transfer completes (or is blocked)
Creates the hook configuration.
Authority: Admin only
Called automatically on every VCoin transfer.
Authority: Token-2022 program only
Effects:
- Updates sender 5A Activity score
- Checks wash trading patterns
- Records tips for ViLink
- May block suspicious transfers
Setup extra accounts needed for hook execution.
Authority: Admin only
Update hook parameters.
Authority: Protocol authority
Parameters:
block_wash_trading: bool- Enable/disable blockingmin_transfer_for_update: u64- Minimum for 5A updatewash_trading_window: i64- Detection window
pub struct TransferHookConfig {
pub authority: Pubkey,
pub vcoin_mint: Pubkey,
pub five_a_program: Pubkey,
pub block_wash_trading: bool,
pub min_transfer_for_update: u64,
pub wash_trading_window: i64,
pub total_transfers: u64,
pub blocked_transfers: u64,
pub paused: bool,
pub bump: u8,
}
pub struct UserTransferHistory {
pub user: Pubkey,
pub recent_recipients: [Pubkey; 10],
pub recent_timestamps: [i64; 10],
pub recent_index: u8,
pub total_sent: u64,
pub total_received: u64,
pub last_transfer_at: i64,
pub bump: u8,
}The hook detects circular transfer patterns:
- Tracks last 10 transfer recipients per user
- Checks if current recipient recently sent to sender
- If pattern detected within window (default: 1 hour):
- If
block_wash_trading = true: Transfer blocked - If
block_wash_trading = false: 5A update skipped
- If
A → B → A (within 1 hour) = Wash trading detected
- Token-2022 authorization - Only callable by token program
- Wash trading prevention - Configurable blocking
- Rate limiting - Minimum transfer amount for 5A updates
- Pausable - Emergency stop capability
The transfer hook is automatic - no explicit integration needed. When transferring VCoin:
import { ViWoClient, parseVCoin } from "@viwoapp/sdk";
// Normal transfer - hook runs automatically
const transferTx = await client.buildTransferTransaction({
to: recipient,
amount: parseVCoin("100"),
});
await client.sendTransaction(transferTx);
// User's 5A Activity score automatically updated
// Wash trading automatically checkedHook behavior is controlled by the protocol authority:
// Update hook config (admin only)
const updateTx = await client.transferHook.buildUpdateConfigTransaction({
blockWashTrading: true,
minTransferForUpdate: parseVCoin("1"),
washTradingWindow: 3600, // 1 hour
});The hook requires extra accounts for execution:
- Transfer Hook Config
- User Transfer History (sender)
- 5A Protocol Program
- User Score (sender)
These are automatically resolved by Token-2022 using the extra account meta list.