Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cadence/contracts/interfaces/DeFiActions.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,10 @@ access(all) contract DeFiActions {
}
}

/// Callback invoked every time an AutoBalancer executes (runs rebalance).
/// Callback invoked after AutoBalancer.executeTransaction runs rebalance.
///
access(all) resource interface AutoBalancerExecutionCallback {
/// Called at the end of each rebalance run.
/// Called at the end of each executeTransaction-triggered rebalance run.
/// @param balancerUUID: The AutoBalancer's UUID
access(all) fun onExecuted(balancerUUID: UInt64)
}
Expand Down Expand Up @@ -949,8 +949,9 @@ access(all) contract DeFiActions {
}
self._rebalanceRange = range
}
/// Sets the optional callback invoked every time this AutoBalancer runs rebalance.
/// Sets the optional callback invoked after executeTransaction runs rebalance.
/// Pass nil to clear the callback.
/// NOTE: callback execution occurs in the same transaction context; callback panics will revert execution.
access(Set) fun setExecutionCallback(_ cap: Capability<&{AutoBalancerExecutionCallback}>?) {
self._executionCallback = cap
}
Expand Down Expand Up @@ -1076,7 +1077,7 @@ access(all) contract DeFiActions {
}
if let cap = self._executionCallback {
if cap.check() {
cap.borrow()!.onExecuted(balancerUUID: self.uniqueID?.id ?? 0)
cap.borrow()!.onExecuted(balancerUUID: self.uuid)
}
}
// clean up internally-managed historical scheduled transactions
Expand Down
2 changes: 1 addition & 1 deletion cadence/tests/AutoBalancer_test.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ access(all) fun test_ExecutionCallbackRuns() {
let createdEvts = Test.eventsOfType(Type<DeFiActions.CreatedAutoBalancer>())
Test.assertEqual(1, createdEvts.length)
let createdEvt = createdEvts[0] as! DeFiActions.CreatedAutoBalancer
let balancerUUID = createdEvt.uniqueID ?? 0
let balancerUUID = createdEvt.uuid
Copy link
Copy Markdown
Member

@holyfuchs holyfuchs Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FlowYieldVaults is currently using uniqueID.id, to store and refer to the YieldVaults and their AutoBalancers.
Since FlowYieldVaults is using this callback it would require more changes in that repo, or alternatively a mapping in the FlowYieldVaultsSchedulerRegistry, which would complicate things unnecessarily.


let interval: UInt64 = 10
let executionEffort: UInt64 = 1_000
Expand Down