|
| 1 | +--- |
| 2 | +title: "EVMAdapter Reference" |
| 3 | +sidebar_label: "Adapter" |
| 4 | +sidebar_position: 2 |
| 5 | +--- |
| 6 | + |
| 7 | +# EVMAdapter Reference |
| 8 | + |
| 9 | +The `EVMAdapter` is a stateless struct that implements all required shared interfaces for the EVM chain family. |
| 10 | + |
| 11 | +**Source:** [v1_6_0/sequences/adapter.go](../v1_6_0/sequences/adapter.go) |
| 12 | + |
| 13 | +For the interfaces it implements, see [Interfaces Reference](../../../../deployment/docs/interfaces.md). |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Struct Definition |
| 18 | + |
| 19 | +```go |
| 20 | +type EVMAdapter struct{} |
| 21 | +``` |
| 22 | + |
| 23 | +The EVM adapter is intentionally stateless -- all state is resolved from the DataStore and environment at execution time. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Registration |
| 28 | + |
| 29 | +### Main Adapter (`sequences/adapter.go`) |
| 30 | + |
| 31 | +**Source:** [v1_6_0/sequences/adapter.go](../v1_6_0/sequences/adapter.go) |
| 32 | + |
| 33 | +```go |
| 34 | +func init() { |
| 35 | + v, _ := semver.NewVersion("1.6.0") |
| 36 | + |
| 37 | + laneapi.GetLaneAdapterRegistry().RegisterLaneAdapter(chain_selectors.FamilyEVM, v, &EVMAdapter{}) |
| 38 | + deployapi.GetRegistry().RegisterDeployer(chain_selectors.FamilyEVM, v, &EVMAdapter{}) |
| 39 | + deployapi.GetTransferOwnershipRegistry().RegisterAdapter(chain_selectors.FamilyEVM, v, &EVMAdapter{}) |
| 40 | + mcmsreaderapi.GetRegistry().RegisterMCMSReader(chain_selectors.FamilyEVM, &EVMAdapter{}) |
| 41 | + tokensapi.GetTokenAdapterRegistry().RegisterTokenAdapter(chain_selectors.FamilyEVM, v, &EVMAdapter{}) |
| 42 | + lanes.GetPingPongAdapterRegistry().RegisterPingPongAdapter(chain_selectors.FamilyEVM, v, &EVMAdapter{}) |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +### Separate Adapters (`adapters/init.go`) |
| 47 | + |
| 48 | +**Source:** [v1_6_0/adapters/init.go](../v1_6_0/adapters/init.go) |
| 49 | + |
| 50 | +```go |
| 51 | +func init() { |
| 52 | + // Curse adapter |
| 53 | + fastcurse.GetCurseRegistry().RegisterNewCurse(fastcurse.CurseRegistryInput{ |
| 54 | + CursingFamily: chain_selectors.FamilyEVM, |
| 55 | + CursingVersion: semver.MustParse("1.6.0"), |
| 56 | + CurseAdapter: NewCurseAdapter(), |
| 57 | + CurseSubjectAdapter: NewCurseAdapter(), |
| 58 | + }) |
| 59 | + |
| 60 | + // Lane migration adapters |
| 61 | + deploy.GetLaneMigratorRegistry().RegisterRampUpdater(chain_selectors.FamilyEVM, semver.MustParse("1.6.0"), &LaneMigrater{}) |
| 62 | + deploy.GetLaneMigratorRegistry().RegisterRouterUpdater(chain_selectors.FamilyEVM, semver.MustParse("1.2.0"), &RouterUpdater{}) |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Interface Implementations |
| 69 | + |
| 70 | +### Deployer |
| 71 | + |
| 72 | +| Method | Delegates To | |
| 73 | +|--------|-------------| |
| 74 | +| `DeployChainContracts()` | `DeployChainContracts` sequence | |
| 75 | +| `DeployMCMS()` | v1.0.0 MCMS deployer | |
| 76 | +| `FinalizeDeployMCMS()` | v1.0.0 MCMS finalize (no-op for EVM) | |
| 77 | +| `SetOCR3Config()` | OCR3 configuration sequence | |
| 78 | +| `GrantAdminRoleToTimelock()` | Timelock admin role sequence | |
| 79 | + |
| 80 | +EVM delegates MCMS deployment to the v1.0.0 implementation since MCMS contracts are version-agnostic on EVM. |
| 81 | + |
| 82 | +### LaneAdapter |
| 83 | + |
| 84 | +| Method | Behavior | |
| 85 | +|--------|----------| |
| 86 | +| `GetOnRampAddress()` | Looks up OnRamp v1.6.0 from DataStore | |
| 87 | +| `GetOffRampAddress()` | Looks up OffRamp v1.6.0 from DataStore | |
| 88 | +| `GetRouterAddress()` | Looks up Router from DataStore | |
| 89 | +| `GetFQAddress()` | Looks up latest FeeQuoter (v1.6.0 -- v1.7.0 range) | |
| 90 | +| `ConfigureLaneLegAsSource()` | OnRamp dest config + FeeQuoter dest config + price updates | |
| 91 | +| `ConfigureLaneLegAsDest()` | OffRamp source config + Router ramp updates | |
| 92 | + |
| 93 | +All `Get*Address` methods return 20-byte EVM addresses. |
| 94 | + |
| 95 | +### TokenAdapter |
| 96 | + |
| 97 | +| Method | Behavior | |
| 98 | +|--------|----------| |
| 99 | +| `AddressRefToBytes()` | Hex-decodes the address string to bytes | |
| 100 | +| `DeriveTokenAddress()` | Reads token address from the pool contract on-chain | |
| 101 | +| `DeriveTokenDecimals()` | Reads decimals from the token contract on-chain | |
| 102 | +| `DeriveTokenPoolCounterpart()` | Returns tokenPool unchanged (no PDA derivation needed on EVM) | |
| 103 | +| `ConfigureTokenForTransfersSequence()` | Registers token + sets remote chain configs | |
| 104 | +| `ManualRegistration()` | Registers customer token via proposeAdministrator | |
| 105 | +| `SetTokenPoolRateLimits()` | Sets inbound/outbound rate limits | |
| 106 | +| `DeployToken()` | Deploys ERC20 BurnMint token | |
| 107 | +| `DeployTokenPoolForToken()` | Deploys token pool for existing token | |
| 108 | +| `UpdateAuthorities()` | Transfers token/pool ownership to timelock | |
| 109 | + |
| 110 | +### TokenPriceProvider (Optional) |
| 111 | + |
| 112 | +```go |
| 113 | +func (e *EVMAdapter) GetDefaultTokenPrices() map[datastore.ContractType]*big.Int |
| 114 | +``` |
| 115 | + |
| 116 | +Returns a default price of $20 per token (18 decimals) for WETH and LINK. |
| 117 | + |
| 118 | +### TransferOwnershipAdapter |
| 119 | + |
| 120 | +| Method | Behavior | |
| 121 | +|--------|----------| |
| 122 | +| `InitializeTimelockAddress()` | No-op on EVM (timelock resolved at execution time) | |
| 123 | +| `SequenceTransferOwnershipViaMCMS()` | Calls `transferOwnership()` on each contract | |
| 124 | +| `SequenceAcceptOwnership()` | Calls `acceptOwnership()` on each contract | |
| 125 | +| `ShouldAcceptOwnershipWithTransferOwnership()` | Returns `false` (two-step ownership on EVM) | |
| 126 | + |
| 127 | +### MCMSReader |
| 128 | + |
| 129 | +| Method | Behavior | |
| 130 | +|--------|----------| |
| 131 | +| `GetChainMetadata()` | Reads MCM starting op count from on-chain | |
| 132 | +| `GetTimelockRef()` | Resolves RBACTimelock AddressRef from DataStore | |
| 133 | +| `GetMCMSRef()` | Resolves ProposerManyChainMultiSig AddressRef | |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## Specialized Adapters |
| 138 | + |
| 139 | +### CurseAdapter (`adapters/fastcurse.go`) |
| 140 | + |
| 141 | +Implements `CurseAdapter` and `CurseSubjectAdapter` for EVM RMN operations. |
| 142 | + |
| 143 | +- `Initialize()` -- loads RMNRemote contract address |
| 144 | +- `IsSubjectCursedOnChain()` -- calls `isCursed(subject)` on RMNRemote |
| 145 | +- `Curse()` / `Uncurse()` -- returns sequences that call `curse()`/`uncurse()` on RMNRemote |
| 146 | +- `SelectorToSubject()` -- converts chain selector to 16-byte curse subject |
| 147 | +- `SubjectToSelector()` -- reverses the conversion |
| 148 | + |
| 149 | +### FeeAdapter (`adapters/fees.go`) |
| 150 | + |
| 151 | +Implements `FeeAdapter` for EVM fee configuration. |
| 152 | + |
| 153 | +- `SetTokenTransferFee()` -- returns sequence that calls `applyTokenTransferFeeConfigUpdates` on FeeQuoter |
| 154 | +- `GetOnchainTokenTransferFeeConfig()` -- reads current fee config from FeeQuoter |
| 155 | +- `GetDefaultTokenTransferFeeConfig()` -- returns sensible defaults |
| 156 | + |
| 157 | +### ConfigImporter (`adapters/configimport.go`) |
| 158 | + |
| 159 | +Implements `ConfigImporter` for importing existing on-chain state into the DataStore. |
| 160 | + |
| 161 | +### LaneMigrater (`adapters/lanemigrator.go`) |
| 162 | + |
| 163 | +Implements `RampUpdateInRouter` and `RouterUpdateInRamp` for lane migration scenarios. |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## EVM Utilities |
| 168 | + |
| 169 | +### Address Conversion (`utils/datastore/datastore.go`) |
| 170 | + |
| 171 | +```go |
| 172 | +func ToByteArray(ref datastore.AddressRef) ([]byte, error) // Hex string -> bytes |
| 173 | +func ToEVMAddress(ref datastore.AddressRef) (common.Address, error) // Hex string -> common.Address |
| 174 | +func ToPaddedEVMAddress(ref datastore.AddressRef) ([]byte, error) // 32-byte left-padded |
| 175 | +``` |
| 176 | + |
| 177 | +### Contract Introspection (`utils/common.go`) |
| 178 | + |
| 179 | +```go |
| 180 | +func TypeAndVersion(addr common.Address, client bind.ContractBackend) (string, *semver.Version, error) |
| 181 | +func ValidateEVMAddress(addr string, fieldName string) error |
| 182 | +``` |
0 commit comments