DeploySEALED

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

Transaction ID

Timestamp

Oct 09, 2025, 05:32:07 AM UTC
4mo ago

Block Height

128,856,514

Computation

0

Execution Fee

0.00000924 FLOW

Transaction Summary

Deploy

Contract deployment

Contract deployment

Script Arguments

0nameString
AgentManager
1codeString
import FungibleToken from 0xf233dcee88fe0abe import FlowToken from 0x1654653399040a61 import stFlowToken from 0xd6f80565193ad727 import VaultCore from 0x79f5b5b0f95a160b import IncrementStakingStrategy from 0x79f5b5b0f95a160b import IncrementLoopingStrategy from 0x79f5b5b0f95a160b import IncrementFarmingStrategy from 0x79f5b5b0f95a160b import SwapStrategy from 0x79f5b5b0f95a160b access(all) contract AgentManager { access(all) let AgentStoragePath: StoragePath access(all) let AgentPrivatePath: PrivatePath access(all) event AgentInitialized(agent: Address) access(all) event StrategyExecuted(strategyType: String, assetType: String, amount: UFix64, result: UFix64) access(all) event YieldHarvested(strategyType: String, amount: UFix64) access(all) event HealthCheckPerformed(healthy: Bool, details: {String: UFix64}) access(self) var authorizedAgent: Address? access(self) var totalStrategyExecutions: UInt64 access(self) var totalYieldHarvested: UFix64 access(self) var lastHealthCheck: UFix64 access(all) enum StrategyType: UInt8 { access(all) case incrementStaking access(all) case incrementLooping access(all) case incrementFarming access(all) case swap } access(all) resource AgentCapability { access(self) let vaultCap: Capability<&VaultCore.Vault> access(self) let stakingStrategy: @IncrementStakingStrategy.Strategy access(self) let loopingStrategy: @IncrementLoopingStrategy.Strategy access(self) let farmingStrategy: @IncrementFarmingStrategy.Strategy access(self) let swapStrategy: @SwapStrategy.Strategy init(vaultCap: Capability<&VaultCore.Vault>) { self.vaultCap = vaultCap self.stakingStrategy <- IncrementStakingStrategy.createStrategy() self.loopingStrategy <- IncrementLoopingStrategy.createStrategy() self.farmingStrategy <- IncrementFarmingStrategy.createStrategy() self.swapStrategy <- SwapStrategy.createStrategy() } access(all) fun executeIncrementStaking(amount: UFix64): UFix64 { pre { amount > 0.0: "Amount must be positive" } let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") let flowVault <- vault.withdrawForStrategy(assetType: VaultCore.AssetType.flow, amount: amount) as! @FlowToken.Vault let stFlowVault <- self.stakingStrategy.executeStrategy(from: <-flowVault) let stFlowReceived = stFlowVault.balance vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-stFlowVault) AgentManager.totalStrategyExecutions = AgentManager.totalStrategyExecutions + 1 emit StrategyExecuted(strategyType: "IncrementStaking", assetType: "FLOW", amount: amount, result: stFlowReceived) return stFlowReceived } access(all) fun executeIncrementLooping(amount: UFix64, numLoops: UInt8): UFix64 { pre { amount > 0.0: "Amount must be positive" numLoops >= 1 && numLoops <= 3: "Loops must be 1-3" } let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") let flowVault <- vault.withdrawForStrategy(assetType: VaultCore.AssetType.flow, amount: amount) as! @FlowToken.Vault let stFlowVault <- self.loopingStrategy.executeStrategy(from: <-flowVault, numLoops: numLoops) let stFlowReceived = stFlowVault.balance vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-stFlowVault) AgentManager.totalStrategyExecutions = AgentManager.totalStrategyExecutions + 1 emit StrategyExecuted(strategyType: "IncrementLooping", assetType: "FLOW", amount: amount, result: stFlowReceived) return stFlowReceived } access(all) fun executeIncrementFarming(poolId: UInt64, amount: UFix64, assetType: VaultCore.AssetType): Bool { pre { amount > 0.0: "Amount must be positive" } let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") let assetVault <- vault.withdrawForStrategy(assetType: assetType, amount: amount) let success = self.farmingStrategy.executeStrategy(poolId: poolId, from: <-assetVault) AgentManager.totalStrategyExecutions = AgentManager.totalStrategyExecutions + 1 emit StrategyExecuted(strategyType: "IncrementFarming", assetType: assetType == VaultCore.AssetType.flow ? "FLOW" : "stFLOW", amount: amount, result: success ? 1.0 : 0.0) return success } access(all) fun executeSwap(fromAsset: VaultCore.AssetType, toAsset: VaultCore.AssetType, amount: UFix64): UFix64 { pre { amount > 0.0: "Amount must be positive" fromAsset != toAsset: "Cannot swap same asset" } let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") var resultAmount = 0.0 let sourceVault <- vault.withdrawForStrategy(assetType: fromAsset, amount: amount) if fromAsset == VaultCore.AssetType.flow && toAsset == VaultCore.AssetType.stflow { let flowVault <- sourceVault as! @FlowToken.Vault let stFlowVault <- self.swapStrategy.swapFlowToStFlow(from: <-flowVault) resultAmount = stFlowVault.balance vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-stFlowVault) } else if fromAsset == VaultCore.AssetType.stflow && toAsset == VaultCore.AssetType.flow { let stFlowVault <- sourceVault as! @stFlowToken.Vault let flowVault <- self.swapStrategy.swapStFlowToFlow(from: <-stFlowVault) resultAmount = flowVault.balance vault.depositFromStrategy(assetType: VaultCore.AssetType.flow, from: <-flowVault) } else { destroy sourceVault panic("Unsupported swap direction") } AgentManager.totalStrategyExecutions = AgentManager.totalStrategyExecutions + 1 emit StrategyExecuted(strategyType: "Swap", assetType: fromAsset == VaultCore.AssetType.flow ? "FLOW" : "stFLOW", amount: amount, result: resultAmount) return resultAmount } access(all) fun harvestStaking(): UFix64 { let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") let harvestedVault <- self.stakingStrategy.harvest() let harvestedAmount = harvestedVault.balance if harvestedAmount > 0.0 { vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-harvestedVault) vault.recordYieldHarvest(assetType: VaultCore.AssetType.stflow, amount: harvestedAmount) AgentManager.totalYieldHarvested = AgentManager.totalYieldHarvested + harvestedAmount emit YieldHarvested(strategyType: "IncrementStaking", amount: harvestedAmount) } else { destroy harvestedVault } return harvestedAmount } access(all) fun harvestFarming(poolId: UInt64): UFix64 { let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") let harvestedVaults <- self.farmingStrategy.harvestPool(poolId: poolId) var totalHarvested: UFix64 = 0.0 // Process each reward token type for tokenKey in harvestedVaults.keys { let rewardVault <- harvestedVaults.remove(key: tokenKey)! let amount = rewardVault.balance totalHarvested = totalHarvested + amount // Deposit based on token type if tokenKey.contains("FlowToken") { vault.depositFromStrategy(assetType: VaultCore.AssetType.flow, from: <-rewardVault) vault.recordYieldHarvest(assetType: VaultCore.AssetType.flow, amount: amount) } else if tokenKey.contains("stFlowToken") { vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-rewardVault) vault.recordYieldHarvest(assetType: VaultCore.AssetType.stflow, amount: amount) } else { // For other tokens, just destroy for now destroy rewardVault } } destroy harvestedVaults if totalHarvested > 0.0 { AgentManager.totalYieldHarvested = AgentManager.totalYieldHarvested + totalHarvested emit YieldHarvested(strategyType: "IncrementFarming", amount: totalHarvested) } return totalHarvested } access(all) fun harvestAllFarms(): UFix64 { let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") let harvestedVaults <- self.farmingStrategy.harvestAll() var totalHarvested: UFix64 = 0.0 // Process each reward token type for tokenKey in harvestedVaults.keys { let rewardVault <- harvestedVaults.remove(key: tokenKey)! let amount = rewardVault.balance totalHarvested = totalHarvested + amount // Deposit based on token type if tokenKey.contains("FlowToken") { vault.depositFromStrategy(assetType: VaultCore.AssetType.flow, from: <-rewardVault) vault.recordYieldHarvest(assetType: VaultCore.AssetType.flow, amount: amount) } else if tokenKey.contains("stFlowToken") { vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-rewardVault) vault.recordYieldHarvest(assetType: VaultCore.AssetType.stflow, amount: amount) } else { // For other tokens, just destroy for now destroy rewardVault } } destroy harvestedVaults if totalHarvested > 0.0 { AgentManager.totalYieldHarvested = AgentManager.totalYieldHarvested + totalHarvested emit YieldHarvested(strategyType: "IncrementFarmingAll", amount: totalHarvested) } return totalHarvested } access(all) fun checkLoopingHealth(): {String: UFix64} { let metrics = self.loopingStrategy.getHealthMetrics() let healthFactor = metrics["healthFactor"]! let isHealthy = healthFactor > 1.5 AgentManager.lastHealthCheck = getCurrentBlock().timestamp emit HealthCheckPerformed(healthy: isHealthy, details: metrics) return metrics } access(all) fun getFarmingPositions(): {UInt64: {String: UFix64}} { return self.farmingStrategy.getPositions() } access(all) fun getStrategyBalances(): {String: {String: UFix64}} { return { "staking": self.stakingStrategy.getBalances(), "looping": self.loopingStrategy.getBalances(), "farming": self.farmingStrategy.getBalances(), "swap": self.swapStrategy.getBalances() } } access(all) fun getSwapQuote(fromAsset: VaultCore.AssetType, toAsset: VaultCore.AssetType, amount: UFix64): SwapStrategy.RouteQuote { if fromAsset == VaultCore.AssetType.flow && toAsset == VaultCore.AssetType.stflow { return SwapStrategy.getQuoteFlowToStFlow(amount: amount) } else if fromAsset == VaultCore.AssetType.stflow && toAsset == VaultCore.AssetType.flow { return SwapStrategy.getQuoteStFlowToFlow(amount: amount) } else { panic("Unsupported swap direction") } } access(all) fun withdrawForEVMBridge(amount: UFix64): @FlowToken.Vault { pre { amount > 0.0: "Amount must be positive" } let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") let flowVault <- vault.withdrawForEVMBridge(assetType: VaultCore.AssetType.flow, amount: amount) as! @FlowToken.Vault return <- flowVault } access(all) fun depositFromEVMBridge(from: @FlowToken.Vault) { let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") vault.depositFromEVMBridge(from: <-from) } access(all) fun emergencyExitAll() { let vault = self.vaultCap.borrow() ?? panic("Cannot borrow vault") // Exit staking strategy let stakingExit <- self.stakingStrategy.emergencyExit() if stakingExit.balance > 0.0 { vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-stakingExit) } else { destroy stakingExit } // Exit looping strategy let loopingExit <- self.loopingStrategy.emergencyExit() destroy loopingExit // Exit farming strategy - returns dictionary of vaults let farmingExit <- self.farmingStrategy.emergencyExit() for tokenKey in farmingExit.keys { let exitVault <- farmingExit.remove(key: tokenKey)! let amount = exitVault.balance if amount > 0.0 { // Deposit based on token type if tokenKey.contains("FlowToken") { vault.depositFromStrategy(assetType: VaultCore.AssetType.flow, from: <-exitVault) } else if tokenKey.contains("stFlowToken") { vault.depositFromStrategy(assetType: VaultCore.AssetType.stflow, from: <-exitVault) } else { destroy exitVault } } else { destroy exitVault } } destroy farmingExit // Exit swap strategy let swapExit <- self.swapStrategy.emergencyExit() if swapExit.balance > 0.0 { vault.depositFromStrategy(assetType: VaultCore.AssetType.flow, from: <-swapExit) } else { destroy swapExit } } } access(all) fun createAgentCapability(vaultCap: Capability<&VaultCore.Vault>): @AgentCapability { return <- create AgentCapability(vaultCap: vaultCap) } access(all) fun setAuthorizedAgent(agent: Address) { self.authorizedAgent = agent emit AgentInitialized(agent: agent) } access(all) fun getMetrics(): {String: AnyStruct} { return { "authorizedAgent": self.authorizedAgent, "totalStrategyExecutions": self.totalStrategyExecutions, "totalYieldHarvested": self.totalYieldHarvested, "lastHealthCheck": self.lastHealthCheck, "stakingMetrics": IncrementStakingStrategy.getMetrics(), "loopingMetrics": IncrementLoopingStrategy.getMetrics(), "farmingMetrics": IncrementFarmingStrategy.getMetrics(), "swapMetrics": SwapStrategy.getMetrics() } } init() { self.AgentStoragePath = /storage/AgentCapability self.AgentPrivatePath = /private/AgentCapability self.authorizedAgent = nil self.totalStrategyExecutions = 0 self.totalYieldHarvested = 0.0 self.lastHealthCheck = getCurrentBlock().timestamp } }

Cadence Script

1transaction(name: String, code: String ) {
2		prepare(signer: auth(AddContract) &Account) {
3			signer.contracts.add(name: name, code: code.utf8 )
4		}
5	}