Smart Contract
AgentManager4
A.79f5b5b0f95a160b.AgentManager4
1import FungibleToken from 0xf233dcee88fe0abe
2import FlowToken from 0x1654653399040a61
3import EVM from 0xe467b9dd11fa00df
4
5/// AgentManager4 - Ultra-minimal bridge manager
6/// Strategies are executed via separate transactions, not stored in Agent
7access(all) contract AgentManager4 {
8
9 access(all) let AgentStoragePath: StoragePath
10
11 access(all) event FundsBridgedToEVM(amount: UFix64, evmAddress: String, owner: Address)
12 access(all) event FundsBridgedFromEVM(amount: UFix64, owner: Address)
13
14 access(self) var totalBridgedToEVM: UFix64
15 access(self) var totalBridgedFromEVM: UFix64
16
17 /// Minimal Agent - just tracks that setup is complete
18 access(all) resource Agent {
19 access(all) let ownerAddress: Address
20 access(all) var bridgedToEVM: UFix64
21 access(all) var bridgedFromEVM: UFix64
22
23 init(ownerAddress: Address) {
24 self.ownerAddress = ownerAddress
25 self.bridgedToEVM = 0.0
26 self.bridgedFromEVM = 0.0
27 }
28
29 access(all) fun recordBridgeToEVM(amount: UFix64) {
30 self.bridgedToEVM = self.bridgedToEVM + amount
31 AgentManager4.totalBridgedToEVM = AgentManager4.totalBridgedToEVM + amount
32 }
33
34 access(all) fun recordBridgeFromEVM(amount: UFix64) {
35 self.bridgedFromEVM = self.bridgedFromEVM + amount
36 AgentManager4.totalBridgedFromEVM = AgentManager4.totalBridgedFromEVM + amount
37 }
38
39 access(all) fun getMetrics(): {String: UFix64} {
40 return {
41 "bridgedToEVM": self.bridgedToEVM,
42 "bridgedFromEVM": self.bridgedFromEVM
43 }
44 }
45 }
46
47 access(all) fun createAgent(ownerAddress: Address): @Agent {
48 return <- create Agent(ownerAddress: ownerAddress)
49 }
50
51 access(all) fun getContractMetrics(): {String: UFix64} {
52 return {
53 "totalBridgedToEVM": self.totalBridgedToEVM,
54 "totalBridgedFromEVM": self.totalBridgedFromEVM
55 }
56 }
57
58 init() {
59 self.AgentStoragePath = /storage/AgentManager4
60 self.totalBridgedToEVM = 0.0
61 self.totalBridgedFromEVM = 0.0
62 }
63}