-1

I'm reading the source here:

https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/processor.rs

But my Rust is not so fluent right now.

Right around here:

match source_account.delegate {
   COption::Some(ref delegate) if Self::cmp_pubkeys(authority_info.key, delegate) {...} 
   _ => Self::validateOwner(...stuff...&source_account.owner)
}

I see the delegate consulted.

It looks like, if the "authority_info" arg is set to "owner", then even if a "delegate" has been set on the account, the program will run the "owner is signer" assertion rather than the "delegate is signer" assertion. Meaning, that it appears that, the owner is always authorized to transfer tokens in any amount no matter what is delegated.

But, I'm kind of hoping I'm wrong here. In my case, it'd be ideal for the delegate to have exclusive rights over their delegated amount.

As an alternative for my use case, or a fallback to the "Delegate" having "exclusive rights" over the delegated amount, if the delegate were to be mentioned when the total amount on the account drops below the delegate amount, that may suffice.

A follow up "Plan B" question is, if transfer rights are not exclusive, are the delegates cleared when their delegated amount is transferred?

Which I think is technically, no. Because I think what happens is the source account is just depleted of token quantity. The delegate remains set on the account, and so does their delegate amount. There is just less quantity in the account for the delegate to potentially be granted further authority over. Possibly there is zero "amount" on the account, despite the "delegate amount" being greater than zero.

Although actually, if the non delegate (i.e. the owner) is allowed to transfer a quantity over which the delegate has authority ( i.e. transfer in excess of non delegated quantity ), shouldn't that subtract from the delegate's holdings even if the delegate is not the signer?

Or is it possible for the delegate to hold authority over more tokens than what are held by the account?

2
  • can you elaborate on what you mean by "exclusive"? it's not clear from the post
    – trent.sol
    Commented Jul 25, 2022 at 5:10
  • Yes I can. I was hoping that delegated_amount would be subtracted from the amount that the account owner ( if not also the delegate ) could transfer or otherwise manage. Meaning that the delegated_amount would be managed exclusively by the delegate account. Said another way, I had hoped that once an amount was delegated, that amount would be "locked" up, accessible only by the delegate, until the amount was revoked. The answer provided by Arowana states pretty clearly that this is not the case. It seems that we can think of delegated_amount as a "cap" rather than a grant.
    – Ahkilleux
    Commented Jul 26, 2022 at 7:52

1 Answer 1

3

The delegate is a pubkey who can transfer up to delegated_amount tokens by signing a transfer instruction, in some way it is an allowance to spend delegated_amount:

  • The delegated_amount reduces of the transferred amount when the delegate transfer tokens
  • The owner transferring tokens does not alter the delegated amount
  • The owner can revoke the delegate right

"is it possible for the delegate to hold authority over more tokens than what are held by the account" Yes, given that it is an allowance to spend later on, it does not require the delegated_amount to be equal or less than the current amount

https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/processor.rs#L222

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.