Purchase Contract
Overview
The Purchase Contract provides an automated system for handling token purchases with stablecoin payments. It integrates directly with the RestrictedLockupToken and InterestPayment contracts to provide atomic purchase transactions that include originator payments, admin fees, interest prefunding, and token minting.
Key Features
- Atomic Purchase Transactions: All operations (payments, fees, minting) occur in a single transaction
- Multi-Party Payment Distribution: Supports originator payments, admin fees, and interest prefunding
- AML/KYC Integration: Validates both payer and recipient compliance status
- Purchase ID Tracking: Prevents duplicate transactions with unique purchase identifiers
- Automation-Ready: Designed for automated execution by external systems
- Flexible Configuration: Configurable wallet addresses for different payment recipients
Usage
Architecture Overview
Purchase Execution Flow
1. Purchase Parameters
Each purchase requires a structured set of parameters:
// For purchases with interest prefunding
struct PurchaseParamsWithInterest {
string purchaseId; // Unique identifier
address payerAddress; // Who pays USDC
address tokenRecipientAddress; // Who receives tokens
uint256 mintAmount; // Number of tokens to mint
uint256 originatorPurchaseAmount; // Payment to originator
uint256 prefundedInterestAmount; // Interest prefunding
uint256 adminFeeExcludingPrefundedInterestAmount; // Admin fees
uint256 totalAmount; // Total USDC required
}
// For basic purchases without interest
struct PurchaseParams {
string purchaseId; // Unique identifier
address payerAddress; // Who pays USDC
address tokenRecipientAddress; // Who receives tokens
uint256 originatorPurchaseAmount; // Payment to originator
uint256 mintAmount; // Number of tokens to mint
uint256 adminFeeAmount; // Admin fees
uint256 totalAmount; // Total USDC required
}