LDGR/Docs
DocsBridges & automationScheduled AMM repricing

Reprice a pool when swaps move it off target.

An AMM reprice schedule is a bounded, pre-funded contract. Its optional after-swap hook can run one deterministic reprice immediately after a direct or routed swap touches the pool.

Start with a few settings

Select a pool and target, fund at least one pool asset, then enter a native fee reserve and a spending cap for each asset. Either escrow amount can stay blank for zero funding on that side. The schedule cannot spend assets it has not received.

Leave the interval blank for hourly repricing. Under Advanced timing, the start, end, and run count are optional: the default starts five minutes after form submission, allows ten successful reprices, and ends one interval per allowed run after the start. Custom windows must fit within one year. The resolved terms are shown in wallet confirmation.

Use Manage existing schedule for cancellation, resume, time-window changes, auto-renew, a higher execution limit, and after-swap settings.

Keep repricing with auto-renew

Enable Auto-renew when opening a schedule, or change the setting for an existing active schedule in Utilities. It is off by default and requires the owner's wallet confirmation.

Code example
await ammRepriceScheduleUpdate({
  contractId,
  autoRenew: true, // use false to stop renewing
});

When enabled, an expired window renews at the next regular alarm or after-swap trigger; reaching the successful-run limit also starts another cycle with the same duration and run allowance. Both alarm and after-swap executions use the remaining prepaid funds. Missed intervals do not accumulate catch-up executions. Turning renewal off lets the current cycle end normally; cancel to stop and recover the remaining funds immediately.

Auto-renew cannot top up escrow or fees. Insufficient funds, input limits, unavailable prices, and ownership changes still pause the schedule. Existing schedules keep renewal disabled until their owner enables it; completed and cancelled schedules cannot be reopened.

Increase the executions per cycle

Under Manage existing schedule, enter the contract ID and a New execution limit per cycle, then choose Increase execution limit and approve in the owning wallet. The limit must be higher than the current one, up to 10,000.

The higher allowance applies to the current and future cycles. Already used executions still count. It keeps the same contract, cycle duration, interval, and prepaid funds; safety pauses remain. Open or paused schedules can be updated, while completed and cancelled schedules cannot.

Code example
await ammRepriceScheduleUpdate({
  contractId,
  maxExecutions: 100, // must exceed the current per-cycle limit
});

Enable it on an existing schedule

The hook is a separate setting and is disabled by default, including on schedules opened before the hook existed. The original schedule owner can toggle it at any time while the schedule is open or paused; changing the setting does not move escrow or change the schedule's target, caps, interval, or execution budget.

Code example
await ammRepriceScheduleSetHook({
  contractId,
  swapTrigger: "after_swap", // use "disabled" to turn it off
});

In Utilities, open the AMM swap tool, select the schedule controls, expand Manage existing schedule, enter its contract ID, and choose After swap or Disabled. The change still requires the owner's normal wallet confirmation.

What happens after a swap

01Swap

A direct or routed swap executes against the pool with its normal slippage protection and swap fee.

02Trigger

If the pool has an enabled hook, the ledger evaluates its linked reprice schedule immediately after the swap.

03Reprice

At most one bounded zero-swap-fee reprice runs toward the schedule's fixed ratio or supported USD target.

04Commit

The swap and the linked execution commit atomically in the same ledger transaction, while history shows the reprice as a separate linked execution event.

The hook is not a webhook

It does not call a website, wait for a wallet, or debit the owner later. Every execution uses only the schedule's existing asset escrow, native fee reserve, per-direction input caps, and remaining execution allowance for the current cycle. Auto-renew can repeat that window and allowance, but cannot replenish funds. If the prepaid resources or a required target quote are unavailable, the schedule pauses or does not spend.

Alarm scheduling still works

The hook adds a swap-triggered execution; it does not replace the schedule's regular time-based alarm. A schedule may therefore run after an affected swap and also at its next eligible interval, with the same escrow and execution limits applying to both paths.