From d0ef55112eada4df094df12b0fa5e00e03f905ae Mon Sep 17 00:00:00 2001 From: Kan Zhang Date: Fri, 5 Dec 2025 19:01:50 -0800 Subject: [PATCH 1/2] Add new admin tx --- .../admin/schedule_supervisor_recurring.cdc | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 cadence/transactions/flow-yield-vaults/admin/schedule_supervisor_recurring.cdc diff --git a/cadence/transactions/flow-yield-vaults/admin/schedule_supervisor_recurring.cdc b/cadence/transactions/flow-yield-vaults/admin/schedule_supervisor_recurring.cdc new file mode 100644 index 0000000..9c97c4f --- /dev/null +++ b/cadence/transactions/flow-yield-vaults/admin/schedule_supervisor_recurring.cdc @@ -0,0 +1,35 @@ +import "FlowYieldVaultsSchedulerV1" +import "FlowTransactionScheduler" + +/// Admin transaction to kick off scheduled transactions for FlowYieldVaults +/// by calling scheduleNextRecurringExecution on the Supervisor with default parameters. +/// +/// This transaction must be signed by the contract account that owns the Supervisor resource. +/// It uses the default parameters from FlowYieldVaultsSchedulerV1: +/// - recurringInterval: 60.0 seconds +/// - priority: Medium (1) +/// - executionEffort: 800 +/// - scanForStuck: true +/// +transaction { + let supervisorRef: auth(FlowYieldVaultsSchedulerV1.Schedule) &FlowYieldVaultsSchedulerV1.Supervisor + + prepare(signer: auth(BorrowValue) &Account) { + // Borrow the Supervisor resource with Schedule entitlement from the contract account storage + self.supervisorRef = signer.storage.borrow( + from: FlowYieldVaultsSchedulerV1.SupervisorStoragePath + ) ?? panic("Supervisor not found at expected storage path") + } + + execute { + // Call scheduleNextRecurringExecution with default parameters + self.supervisorRef.scheduleNextRecurringExecution( + recurringInterval: FlowYieldVaultsSchedulerV1.DEFAULT_RECURRING_INTERVAL, + priority: FlowTransactionScheduler.Priority.Medium, + priorityRaw: FlowYieldVaultsSchedulerV1.DEFAULT_PRIORITY, + executionEffort: FlowYieldVaultsSchedulerV1.DEFAULT_EXECUTION_EFFORT, + scanForStuck: true + ) + } +} + From bf0ef38d1b115348e5d566194455302f705b200f Mon Sep 17 00:00:00 2001 From: Kan Zhang Date: Mon, 8 Dec 2025 19:56:41 -0800 Subject: [PATCH 2/2] Allow pre-set estimate, to not estimate on each rescheduling call --- .../contracts/FlowYieldVaultsSchedulerV1.cdc | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cadence/contracts/FlowYieldVaultsSchedulerV1.cdc b/cadence/contracts/FlowYieldVaultsSchedulerV1.cdc index 3a375fc..7081b2f 100644 --- a/cadence/contracts/FlowYieldVaultsSchedulerV1.cdc +++ b/cadence/contracts/FlowYieldVaultsSchedulerV1.cdc @@ -47,6 +47,7 @@ access(all) contract FlowYieldVaultsSchedulerV1 { /// Default lookahead seconds for scheduling first execution access(all) let DEFAULT_LOOKAHEAD_SECS: UFix64 + /* --- PATHS --- */ /// Storage path for the Supervisor resource @@ -95,12 +96,14 @@ access(all) contract FlowYieldVaultsSchedulerV1 { /// Capability to withdraw FLOW for Supervisor's own scheduling fees access(self) let feesCap: Capability access(self) var _scheduledTransaction: @FlowTransactionScheduler.ScheduledTransaction? + access(contract) var selfSchedulingFeeEstimate: UFix64 init( feesCap: Capability ) { self.feesCap = feesCap self._scheduledTransaction <- nil + self.selfSchedulingFeeEstimate = FlowYieldVaultsSchedulerV1.MIN_FEE_FALLBACK } /* --- TRANSACTION HANDLER --- */ @@ -193,6 +196,11 @@ access(all) contract FlowYieldVaultsSchedulerV1 { } } + /// Sets the estimated cost of scheduling a transaction at a given timestamp + access(Schedule) fun setSelfSchedulingCostEstimate(estimate: UFix64) { + self.selfSchedulingFeeEstimate = estimate + } + /// Self-reschedules the Supervisor for perpetual operation. /// /// This function handles the scheduling of the next Supervisor execution, @@ -226,13 +234,7 @@ access(all) contract FlowYieldVaultsSchedulerV1 { return } - let est = FlowYieldVaultsSchedulerV1.estimateSchedulingCost( - timestamp: nextTimestamp, - priority: priority, - executionEffort: executionEffort - ) - let baseFee = est.flowFee ?? FlowYieldVaultsSchedulerV1.MIN_FEE_FALLBACK - let required = baseFee * FlowYieldVaultsSchedulerV1.FEE_MARGIN_MULTIPLIER + let required = self.selfSchedulingFeeEstimate * FlowYieldVaultsSchedulerV1.FEE_MARGIN_MULTIPLIER if let vaultRef = self.feesCap.borrow() { if vaultRef.balance >= required { @@ -341,8 +343,8 @@ access(all) contract FlowYieldVaultsSchedulerV1 { init() { // Initialize constants self.DEFAULT_RECURRING_INTERVAL = 60.0 // 60 seconds - self.DEFAULT_PRIORITY = 1 // Medium - self.DEFAULT_EXECUTION_EFFORT = 800 + self.DEFAULT_PRIORITY = FlowTransactionScheduler.Priority.Low.rawValue + self.DEFAULT_EXECUTION_EFFORT = 400 self.MIN_FEE_FALLBACK = 0.00005 self.FEE_MARGIN_MULTIPLIER = 1.2 self.DEFAULT_LOOKAHEAD_SECS = 10.0