ScheduledSEALED

$#?╱▓●^%^▫◇▫^■●█░▫◇$^#□◇%■●◇*□○■●▫■?▫◇░●◇▪▓█■█▫■▓▒▪□○◆&~○╱?╲~◇▓*

Transaction ID

Timestamp

Dec 11, 2025, 03:34:36 AM UTC
2mo ago

Block Height

135,618,591

Computation

0

Execution Fee

0.0001 FLOW

Execution Error

Error Code: 1101

mismatched types

Error ContextLine 38
33
34        // Fund COA with FLOW for EVM operations
35        let coa = signer.storage.borrow<auth(EVM.Owner) &EVM.CadenceOwnedAccount>(from: coaPath)!
36        let flowVaultForCOA = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)!
37        let coaFunding <- flowVaultForCOA.withdraw(amount: 1.0)
38        coa.deposit(from: <-coaFunding)
39
40        // 2. Setup controller if not exists
41        if signer.storage.borrow<&DCAControllerUnified.Controller>(from: DCAControllerUnified.ControllerStoragePath) == nil {
42            let controller <- DCAControllerUnified.createController()
43            signer.storage.save(<-controller, to: DCAControllerUnified.ControllerStoragePath)
Call Stack
Raw Error

[Error Code: 1101] error caused by: 1 error occurred: * transaction preprocess failed: [Error Code: 1101] cadence runtime error: Execution failed: error: mismatched types --> 195c14abe81e06385f4685d2b2d1a32471377c475e9dbedb1881258b5df8eae8:38:26 | 38 | coa.deposit(from: <-coaFunding) | ^^^^^^^^^^^^ expected `FlowToken.Vault`, got `{FungibleToken.Vault}`; check the expression's type or convert it to the expected type See documentation at: https://cadence-lang.org/docs/language/values-and-types Was this error unhelpful? Consider suggesting an improvement here: https://github.com/onflow/cadence/issues.

Transaction Summary

Scheduled

Called FlowTransactionScheduler, FlowTransactionSchedulerUtils, DCAPlanUnified +6 more

Script Arguments

0amountPerIntervalUFix64
0.10000000
1intervalSecondsUInt64
60
2maxSlippageBpsUInt64
500
3maxExecutionsUInt64
2
4delaySecondsUInt64
30
5priorityUInt8
0
6executionEffortUInt64
5000

Cadence Script

1import FlowTransactionScheduler from 0xe467b9dd11fa00df
2import FlowTransactionSchedulerUtils from 0xe467b9dd11fa00df
3import DCAPlanUnified from 0xca7ee55e4fc3251a
4import DCAControllerUnified from 0xca7ee55e4fc3251a
5import DCATransactionHandlerUnified from 0xca7ee55e4fc3251a
6import FungibleToken from 0xf233dcee88fe0abe
7import FlowToken from 0x1654653399040a61
8import EVM from 0xe467b9dd11fa00df
9import EVMVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed from 0x1e4aa0b87d10b141
10
11/// Test unified handler with FLOW → USDF (EVM/UniswapV3 path)
12/// All-in-one: Setup controller with COA, create plan, init handler, schedule first execution
13transaction(
14    amountPerInterval: UFix64,
15    intervalSeconds: UInt64,
16    maxSlippageBps: UInt64,
17    maxExecutions: UInt64,
18    delaySeconds: UInt64,
19    priority: UInt8,
20    executionEffort: UInt64
21) {
22    let signerAddress: Address
23
24    prepare(signer: auth(Storage, Capabilities) &Account) {
25        self.signerAddress = signer.address
26
27        // 1. Setup COA if not exists (required for EVM swaps)
28        let coaPath = /storage/evm
29        if signer.storage.borrow<&EVM.CadenceOwnedAccount>(from: coaPath) == nil {
30            let coa <- EVM.createCadenceOwnedAccount()
31            signer.storage.save(<-coa, to: coaPath)
32        }
33
34        // Fund COA with FLOW for EVM operations
35        let coa = signer.storage.borrow<auth(EVM.Owner) &EVM.CadenceOwnedAccount>(from: coaPath)!
36        let flowVaultForCOA = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)!
37        let coaFunding <- flowVaultForCOA.withdraw(amount: 1.0)
38        coa.deposit(from: <-coaFunding)
39
40        // 2. Setup controller if not exists
41        if signer.storage.borrow<&DCAControllerUnified.Controller>(from: DCAControllerUnified.ControllerStoragePath) == nil {
42            let controller <- DCAControllerUnified.createController()
43            signer.storage.save(<-controller, to: DCAControllerUnified.ControllerStoragePath)
44        }
45
46        let controller = signer.storage.borrow<&DCAControllerUnified.Controller>(from: DCAControllerUnified.ControllerStoragePath)!
47
48        // 3. Setup USDF vault if not exists (target token for EVM swap)
49        let usdfVaultPath = /storage/evmVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed
50        let usdfReceiverPath = /public/evmVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed_receiver
51        if signer.storage.borrow<&EVMVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed.Vault>(from: usdfVaultPath) == nil {
52            signer.storage.save(<-EVMVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed.createEmptyVault(vaultType: Type<@EVMVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed.Vault>()), to: usdfVaultPath)
53            let cap = signer.capabilities.storage.issue<&{FungibleToken.Receiver}>(usdfVaultPath)
54            signer.capabilities.publish(cap, at: usdfReceiverPath)
55        }
56
57        // 4. Configure vault capabilities on controller
58        // Source vault = FLOW (for FLOW → USDF)
59        let flowVaultCap = signer.capabilities.storage.issue<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>(/storage/flowTokenVault)
60        controller.setSourceVaultCapability(cap: flowVaultCap)
61
62        // Target vault = USDF
63        let usdfVaultCap = signer.capabilities.storage.issue<&{FungibleToken.Receiver}>(usdfVaultPath)
64        controller.setTargetVaultCapability(cap: usdfVaultCap)
65
66        // Fee vault = FLOW
67        let feeVaultCap = signer.capabilities.storage.issue<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>(/storage/flowTokenVault)
68        controller.setFeeVaultCapability(cap: feeVaultCap)
69
70        // COA capability (required for EVM swaps)
71        let coaCap = signer.capabilities.storage.issue<auth(EVM.Owner) &EVM.CadenceOwnedAccount>(coaPath)
72        controller.setCOACapability(cap: coaCap)
73
74        // 5. Create plan (FLOW → USDF - requires EVM)
75        let firstExecutionTime = getCurrentBlock().timestamp + UFix64(delaySeconds)
76        let plan <- DCAPlanUnified.createPlan(
77            sourceTokenType: Type<@FlowToken.Vault>(),
78            targetTokenType: Type<@EVMVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed.Vault>(),
79            amountPerInterval: amountPerInterval,
80            intervalSeconds: intervalSeconds,
81            maxSlippageBps: maxSlippageBps,
82            maxExecutions: maxExecutions,
83            firstExecutionTime: firstExecutionTime
84        )
85        let planId = plan.id
86        controller.addPlan(plan: <-plan)
87
88        // 6. Setup handler if not exists
89        let handlerPath = /storage/DCATransactionHandlerUnified
90        if signer.storage.borrow<&DCATransactionHandlerUnified.Handler>(from: handlerPath) == nil {
91            let controllerCap = signer.capabilities.storage.issue<auth(DCAControllerUnified.Owner) &DCAControllerUnified.Controller>(DCAControllerUnified.ControllerStoragePath)
92            let handler <- DCATransactionHandlerUnified.createHandler(controllerCap: controllerCap)
93            signer.storage.save(<-handler, to: handlerPath)
94        }
95
96        // 7. Get handler capability
97        let controllers = signer.capabilities.storage.getControllers(forPath: handlerPath)
98        var handlerCap: Capability<auth(FlowTransactionScheduler.Execute) &{FlowTransactionScheduler.TransactionHandler}>? = nil
99
100        for c in controllers {
101            if let cap = signer.capabilities.storage.getController(byCapabilityID: c.capabilityID)?.capability as? Capability<auth(FlowTransactionScheduler.Execute) &{FlowTransactionScheduler.TransactionHandler}> {
102                if cap.check() {
103                    handlerCap = cap
104                    break
105                }
106            }
107        }
108
109        if handlerCap == nil {
110            let cap = signer.capabilities.storage.issue<auth(FlowTransactionScheduler.Execute) &{FlowTransactionScheduler.TransactionHandler}>(handlerPath)
111            handlerCap = cap
112        }
113
114        // 8. Setup scheduler manager if not exists
115        let managerPath = /storage/FlowTransactionSchedulerManager
116        if signer.storage.borrow<&{FlowTransactionSchedulerUtils.Manager}>(from: managerPath) == nil {
117            let manager <- FlowTransactionSchedulerUtils.createManager()
118            signer.storage.save(<-manager, to: managerPath)
119        }
120
121        // Get manager capability
122        let managerControllers = signer.capabilities.storage.getControllers(forPath: managerPath)
123        var schedulerManagerCap: Capability<auth(FlowTransactionSchedulerUtils.Owner) &{FlowTransactionSchedulerUtils.Manager}>? = nil
124
125        for c in managerControllers {
126            if let cap = signer.capabilities.storage.getController(byCapabilityID: c.capabilityID)?.capability as? Capability<auth(FlowTransactionSchedulerUtils.Owner) &{FlowTransactionSchedulerUtils.Manager}> {
127                if cap.check() {
128                    schedulerManagerCap = cap
129                    break
130                }
131            }
132        }
133
134        if schedulerManagerCap == nil {
135            let cap = signer.capabilities.storage.issue<auth(FlowTransactionSchedulerUtils.Owner) &{FlowTransactionSchedulerUtils.Manager}>(managerPath)
136            schedulerManagerCap = cap
137        }
138
139        // 9. Get fee provider capability
140        let feeProviderCap = signer.capabilities.storage.issue<auth(FungibleToken.Withdraw) &FlowToken.Vault>(/storage/flowTokenVault)
141
142        // 10. Create LoopConfig
143        let schedulePriority = priority == 0 ? FlowTransactionScheduler.Priority.High : (priority == 1 ? FlowTransactionScheduler.Priority.Medium : FlowTransactionScheduler.Priority.Low)
144
145        let loopConfig = DCATransactionHandlerUnified.createLoopConfig(
146            planId: planId,
147            intervalSeconds: UFix64(intervalSeconds),
148            schedulerManagerCap: schedulerManagerCap!,
149            feeProviderCap: feeProviderCap,
150            priority: schedulePriority,
151            executionEffort: executionEffort
152        )
153
154        // 11. Estimate fees and schedule
155        let estimate = FlowTransactionScheduler.estimate(
156            data: loopConfig,
157            timestamp: firstExecutionTime,
158            priority: schedulePriority,
159            executionEffort: executionEffort
160        )
161
162        let flowVault = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)!
163        let fees <- flowVault.withdraw(amount: estimate.flowFee ?? 0.0)
164
165        let manager = schedulerManagerCap!.borrow()!
166
167        let scheduleId = manager.schedule(
168            handlerCap: handlerCap!,
169            data: loopConfig,
170            timestamp: firstExecutionTime,
171            priority: schedulePriority,
172            executionEffort: executionEffort,
173            fees: <-fees as! @FlowToken.Vault
174        )
175
176        log("Plan created: ".concat(planId.toString()))
177        log("Schedule ID: ".concat(scheduleId.toString()))
178        log("First execution at: ".concat(firstExecutionTime.toString()))
179        log("Plan requiresEVM: true (FLOW → USDF)")
180    }
181}