Increase Stacked Position
This guide explains how to increase your stacked STX position. The process depends on your role:
Solo Stackers use the
stack-increasefunction.Delegators must first revoke their current delegation using
revoke-delegate-stxand then re-delegate with a higher amount to the same pool operator usingdelegate-stx.Pool Operators increase their delegators' locked amount by calling
delegate-stack-increaseand then stacking the increased amount with eitherstack-aggregation-commit-indexed(if not already committed) orstack-aggregation-increase(if the commit has already been made).
Solo Stackers
Solo stackers can add more STX to their active stacking position by calling the stack-increase function. The new amount takes effect from the next stacking cycle.
The stack-increase function locks an additional amount of STX from your account. Your account must be actively stacking and not delegating, and you must have enough unlocked STX to cover the increase.
Function source code
;; Increase the number of STX locked.
;; *New in Stacks 2.1*
;; This method locks up an additional amount of STX from `tx-sender`'s, indicated
;; by `increase-by`. The `tx-sender` must already be Stacking & must not be
;; straddling more than one signer-key for the cycles effected.
;; Refer to `verify-signer-key-sig` for more information on the authorization parameters
;; included here.
(define-public (stack-increase
(increase-by uint)
(signer-sig (optional (buff 65)))
(signer-key (buff 33))
(max-amount uint)
(auth-id uint))
(let ((stacker-info (stx-account tx-sender))
(amount-stacked (get locked stacker-info))
(amount-unlocked (get unlocked stacker-info))
(unlock-height (get unlock-height stacker-info))
(cur-cycle (current-pox-reward-cycle))
(first-increased-cycle (+ cur-cycle u1))
(stacker-state (unwrap! (map-get? stacking-state
{ stacker: tx-sender })
(err ERR_STACK_INCREASE_NOT_LOCKED)))
(cur-pox-addr (get pox-addr stacker-state))
(cur-period (get lock-period stacker-state)))
;; tx-sender must be currently locked
(asserts! (> amount-stacked u0)
(err ERR_STACK_INCREASE_NOT_LOCKED))
;; must be called with positive `increase-by`
(asserts! (>= increase-by u1)
(err ERR_STACKING_INVALID_AMOUNT))
;; stacker must have enough stx to lock
(asserts! (>= amount-unlocked increase-by)
(err ERR_STACKING_INSUFFICIENT_FUNDS))
;; must be called directly by the tx-sender or by an allowed contract-caller
(asserts! (check-caller-allowed)
(err ERR_STACKING_PERMISSION_DENIED))
;; stacker must be directly stacking
(asserts! (> (len (get reward-set-indexes stacker-state)) u0)
(err ERR_STACKING_IS_DELEGATED))
;; stacker must not be delegating
(asserts! (is-none (get delegated-to stacker-state))
(err ERR_STACKING_IS_DELEGATED))
;; Validate that amount is less than or equal to `max-amount`
(asserts! (>= max-amount (+ increase-by amount-stacked)) (err ERR_SIGNER_AUTH_AMOUNT_TOO_HIGH))
;; Verify signature from delegate that allows this sender for this cycle
(try! (consume-signer-key-authorization cur-pox-addr cur-cycle "stack-increase" cur-period signer-sig signer-key increase-by max-amount auth-id))
;; update reward cycle amounts
(asserts! (is-some (fold increase-reward-cycle-entry
(get reward-set-indexes stacker-state)
(some { first-cycle: first-increased-cycle,
reward-cycle: (get first-reward-cycle stacker-state),
stacker: tx-sender,
add-amount: increase-by,
signer-key: signer-key })))
(err ERR_INVALID_INCREASE))
;; NOTE: stacking-state map is unchanged: it does not track amount-stacked in PoX-4
(ok { stacker: tx-sender, total-locked: (+ amount-stacked increase-by)})))Arguments:
Increase by: the amount of uSTX to add to your lock amount.
Signer public key: the public key used for signing. This can stay the same, or you can use a new key.
Signer signature: a signature proving control of your signing key.
Max Amount: used to validate the signer signature provided. It represents the maximum number of uSTX (1 STX = 1,000,000 uSTX) that can be stacked in this transaction.
Auth Id: used to validate the signer signature provided. It is a random integer that prevents re-use of this particular signer signature.
Delegators
Delegators have to increase their delegated amount in two steps.
Delegate with a Higher Amount
After revoking, call the delegate-stx function with your new, higher amount. This function does not directly delegate the STX, but rather allows the pool operator to issue the stacking lock on behalf of the user calling this function.
Arguments:
Amount: Denoted in uSTX (1 STX = 1,000,000 uSTX).
Delegate to: the STX address of the pool operator they're delegating to.
Until burn height: optional BTC block height when the delegation expires.
Pox Address: optional BTC address that, if specified, the signer must use to accept this delegation.
Make sure the revocation is successful before initiating a new delegation. Otherwise, the delegate-stx transaction will fail.
Pool Operators
Pool operators can increase the total stacking amount through a two-step process. First, update the delegation's locked amount with delegate-stack-increase. Then, stack the increased amount by committing it in a future cycle, or increasing an already committed position.
Increase the Locked Amount
The delegate-stack-increase function allows a pool operator to add more STX to the existing locked position for a given delegator. It performs necessary checks and updates the delegation state with the increased amount.
Arguments:
Stacker: the STX address of the delegator.
Pox Address: the BTC address of the pool operator where they will receive the BTC rewards. If the delegator has set his own BTC address in the
delegate-stxcall, this address will have to be the same one.Increase by: the amount of uSTX to add to the delegator's locked amount.
Stack the Increased Amount
Once the locked amount is updated, the operator must commit the change. There are two functions that can be used to stack the increased amount:
If the Commit Has Not Yet Been Made: stack-aggregation-commit-indexed
This function stacks the total locked amount for an upcoming reward cycle. Note that the stack-aggregation-commit-indexed function wraps the inner-stack-aggregation-commit function. The wrapped inner function is included here.
Arguments:
Pox Address: the BTC address to receive rewards.
Reward-cycle: a reward cycle in the future.
Signer public key: the public key of your signer.
Signer signature: a signature proving control of your signing key.
Max Amount: used to validate the signer signature provided.
Auth Id: used to validate the signer signature provided.
If the Commit Has Already Been Made: stack-aggregation-increase
If you have previously committed an amount, you can further increase the stacked position by calling stack-aggregation-increase. This function adds an additional amount of STX to the already committed delegation.
Arguments:
Pox Address: the BTC address to receive rewards.
Reward Cycle: a reward cycle in the future.
Reward Cycle Index: the index returned by
stack-aggregation-commit-indexed.Signer signature: a signature proving control of your signing key.
Signer public key: the public key of your signer.
Max Amount: used to validate the signer signature provided.
Auth Id: used to validate the signer signature provided.
Sequential Process: First call
delegate-stack-increaseto update the locked amount of a delegation. Then, commit the change:Use
stack-aggregation-commit-indexedif this is the first commit in the given cycle.Use
stack-aggregation-increaseif you have already committed in the cycle you want to increase.
Failing to commit (or properly increase after a commit) will result in the increased delegation not taking effect in upcoming stacking cycles.
Was this helpful?