Token account delegation is expensive, requiring three steps and two accounts. #63
Description
Token delegation is one way that an account owner can give authority to a program to issue transfer instructions.
Token account delegation requires three steps
- Allocate a new account via 'System' program
- Issue
TokenInstruction::NewAccount
to create the delegate token account - issue 'TokenInstruction::Approve' to approve the delegate
Using a delegate requires both the delegate and the original source account to be present when performing a transfer. This gets especially painful for programs like token-swap that perform transfers from multiple accounts
Delegation accounts also have a typically short lifespan and there is not defund instruction to reclaim any lamports held in them. If they are included in the rent exemption enforcement being proposed there should probably be a defund instruction, though that adds another step to the delegation process.
Delegation could be reduced to a simple step and single account if the token account itself held one delegation public key and amount. If all of the amount is transferred delegation ends or if a new delegation instruction is issued it would replace any existing delegation. Canceling delegation could also occur by specifying the primary owner in a delegate instruction.
Single-step delegation would also be more conducive to transactions performing an atomic delegation and operation transaction.
Activity