Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cadence_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
restore-keys: |
${{ runner.os }}-flow-emulator-fork-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/incrementfi_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
token: ${{ secrets.GH_PAT }}
submodules: recursive
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/punchswap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
cache-dependency-path: |
**/go.sum
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled_rebalance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
19 changes: 16 additions & 3 deletions cadence/tests/transactions/set_erc4626_vault_price.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ import "FlowEVMBridgeUtils"
access(all) fun computeMappingSlot(_ values: [AnyStruct]): String {
let encoded = EVM.encodeABI(values)
let hashBytes = HashAlgorithm.KECCAK_256.hash(encoded)
return String.encodeHex(hashBytes)
return "0x\(String.encodeHex(hashBytes))"
}

// Helper: Convert UInt256 to zero-padded 64-char hex string (32 bytes) with 0x prefix
access(all) fun slotHex(_ value: UInt256): String {
let raw = value.toBigEndianBytes()
var padded: [UInt8] = []
var padCount = 32 - raw.length
while padCount > 0 {
padded.append(0)
padCount = padCount - 1
}
padded = padded.concat(raw)
return "0x\(String.encodeHex(padded))"
}

// Helper: Compute ERC20 balanceOf storage slot
Expand Down Expand Up @@ -84,7 +97,7 @@ transaction(
let finalTargetSupply = targetAssets * supplyMultiplier

let supplyValue = String.encodeHex(finalTargetSupply.toBigEndianBytes())
EVM.store(target: vault, slot: String.encodeHex(totalSupplySlot.toBigEndianBytes()), value: supplyValue)
EVM.store(target: vault, slot: slotHex(totalSupplySlot), value: supplyValue)

// Update asset.balanceOf(vault) to finalTargetAssets
let vaultBalanceSlot = computeBalanceOfSlot(holderAddress: vaultAddress, balanceSlot: assetBalanceSlot)
Expand Down Expand Up @@ -120,6 +133,6 @@ transaction(
assert(newSlotBytes.length == 32, message: "Vault storage slot must be exactly 32 bytes, got \(newSlotBytes.length) (lastUpdate: \(lastUpdateBytes.length), maxRate: \(maxRateBytes.length), assets: \(paddedAssets.length))")

let newSlotValue = String.encodeHex(newSlotBytes)
EVM.store(target: vault, slot: String.encodeHex(vaultTotalAssetsSlot.toBigEndianBytes()), value: newSlotValue)
EVM.store(target: vault, slot: slotHex(vaultTotalAssetsSlot), value: newSlotValue)
}
}
26 changes: 15 additions & 11 deletions cadence/tests/transactions/set_uniswap_v3_pool_price.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import EVM from "MockEVM"
access(all) fun computeMappingSlot(_ values: [AnyStruct]): String {
let encoded = EVM.encodeABI(values)
let hashBytes = HashAlgorithm.KECCAK_256.hash(encoded)
return String.encodeHex(hashBytes)
return "0x\(String.encodeHex(hashBytes))"
}

// Helper: Compute ERC20 balanceOf storage slot
Expand Down Expand Up @@ -33,12 +33,16 @@ access(all) fun toHex32(_ value: UInt256): String {

// Helper: Convert a slot number (UInt256) to its padded hex string for EVM.store/load
access(all) fun slotHex(_ slotNum: UInt256): String {
return toHex32(slotNum)
return "0x\(toHex32(slotNum))"
}

// Helper: Parse a hex slot string back to UInt256
access(all) fun slotToNum(_ slotHex: String): UInt256 {
let bytes = slotHex.decodeHex()
access(all) fun slotToNum(_ slot: String): UInt256 {
var hex = slot
if hex.length > 2 && hex.slice(from: 0, upTo: 2) == "0x" {
hex = hex.slice(from: 2, upTo: hex.length)
}
let bytes = hex.decodeHex()
var num = 0 as UInt256
for byte in bytes {
num = num * 256 + UInt256(byte)
Expand Down Expand Up @@ -201,22 +205,22 @@ transaction(
assert(slot0Value.length == 64, message: "slot0 must be 64 hex chars")

// --- Slot 0: slot0 (packed) ---
EVM.store(target: poolAddr, slot: "0", value: slot0Value)
EVM.store(target: poolAddr, slot: slotHex(0), value: slot0Value)

// Verify round-trip
let readBack = EVM.load(target: poolAddr, slot: "0")
let readBack = EVM.load(target: poolAddr, slot: slotHex(0))
let readBackHex = String.encodeHex(readBack)
assert(readBackHex == slot0Value, message: "slot0 read-back mismatch - storage corruption!")

// --- Slots 1-3: feeGrowthGlobal0X128, feeGrowthGlobal1X128, protocolFees = 0 ---
let zero32 = "0000000000000000000000000000000000000000000000000000000000000000"
EVM.store(target: poolAddr, slot: "1", value: zero32)
EVM.store(target: poolAddr, slot: "2", value: zero32)
EVM.store(target: poolAddr, slot: "3", value: zero32)
EVM.store(target: poolAddr, slot: slotHex(1), value: zero32)
EVM.store(target: poolAddr, slot: slotHex(2), value: zero32)
EVM.store(target: poolAddr, slot: slotHex(3), value: zero32)

// --- Slot 4: liquidity = uint128 max ---
let liquidityAmount: UInt256 = 340282366920938463463374607431768211455 // 2^128 - 1
EVM.store(target: poolAddr, slot: "4", value: toHex32(liquidityAmount))
EVM.store(target: poolAddr, slot: slotHex(4), value: toHex32(liquidityAmount))

// --- Initialize boundary ticks ---
// Tick storage layout per tick (4 consecutive slots):
Expand Down Expand Up @@ -293,7 +297,7 @@ transaction(

assert(obs0Bytes.length == 32, message: "observations[0] must be exactly 32 bytes")

EVM.store(target: poolAddr, slot: "8", value: String.encodeHex(obs0Bytes))
EVM.store(target: poolAddr, slot: slotHex(8), value: String.encodeHex(obs0Bytes))

// --- Fund pool with token balances ---
// Calculate 1 billion tokens in each token's decimal format
Expand Down
Loading