A Solana program for migrating tokens from one mint to another using configurable migration strategies.
This Anchor program enables users to migrate their tokens from an old token mint to a new token mint based on predefined migration strategies. The program supports two migration strategies:
- ProRata: Calculates withdrawal amounts based on proportional supply of both tokens
- Fixed: Scales the deposited amount up or down by 10^e for decimal redenomination
- Node.js and Yarn
- Rust and Cargo
- Solana CLI tools
- Anchor CLI
# Install dependencies
yarn install
# Build the program
anchor build
# Run tests
anchor test
# Deploy to localnet
anchor deploy
# Deploy to devnet/mainnet
anchor deploy --provider.cluster devnet
The admin can initialize a new token migration strategy:
await program.methods.initialize(
mintFrom, // Source token mint
mintTo, // Destination token mint
{ fixed: { e: 0 } } // Migration strategy
)
Users can migrate their tokens using the configured strategy:
await program.methods.migrate(
new BN(amount) // Amount to migrate
)
Proportionally distributes new tokens based on supply ratios:
withdraw_amount = (supply_to * deposit_amount) / supply_from
Scales amounts by powers of 10:
Fixed(1)
: Multiply by 10 (e.g., 100 → 1000)Fixed(-1)
: Divide by 10 (e.g., 100 → 10)Fixed(0)
: 1:1 ratio (e.g., 100 → 100)
MIT