Thanks to visit codestin.com
Credit goes to github.com

Skip to content

speedrun-hq/contracts-core

Repository files navigation

Speedrun EVM Contracts

codecov

This repository holds all the smart contracts for the Speedrun protocol deployed on EVM chains - including ZetaChain.

Intent Contract Interface

Initiate Intent

function initiate(
  address asset,
  uint256 amount,
  uint256 targetChain,
  bytes calldata receiver,
  uint256 tip,
  uint256 salt
) external

Creates a new intent for cross-chain transfer:

  • asset: Address of the token to transfer
  • amount: Amount of tokens to transfer
  • targetChain: Chain ID of the destination chain
  • receiver: Address of the receiver on the target chain (in bytes format)
  • tip: Amount of tokens to pay as fee for the cross-chain transfer
  • salt: Random value to ensure uniqueness of the intent ID

Fulfill Intent

function fulfill(
  bytes32 intentId,
  uint256 amount,
  address asset,
  address receiver
) external

Fulfills an existing intent:

  • intentId: Identifier of the intent to fulfill
  • amount: Actual amount of tokens being transferred (may differ from intent's amount)
  • asset: Address of the token being transferred
  • receiver: Address of the recipient on the target chain

Architecture

Learn more about the contract architecture

Mainnet Contract Addresses

Intent Contract Addresses

These are the main user facing contracts, to initiate and fulfil intents on connected chains

base:       0x999fce149FD078DCFaa2C681e060e00F528552f4
arbitrum:   0xD6B0E2a8D115cCA2823c5F80F8416644F3970dD2
eth:        0x951AB2A5417a51eB5810aC44BC1fC716995C1CAB
bnb:        0x68282fa70a32E52711d437b6c5984B714Eec3ED0
polygon:    0x4017717c550E4B6E61048D412a718D6A8078d264
avalanche:  0x9a22A7d337aF1801BEEcDBE7f4f04BbD09F9E5bb

Explorer Links

Development

Prerequisites

  • Foundry
  • Solidity 0.8.26
  • Node.js (for dependencies)

Setup

  1. Install dependencies:
npm install
  1. Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryup

Build

forge build

Test

forge test

Deployment

Deploy the smart contracts

Administration

The Speedrun protocol uses role-based access control for administrative functions. Both the Intent and Router contracts implement OpenZeppelin's AccessControlUpgradeable for permission management.

Common Roles

  • DEFAULT_ADMIN_ROLE: Main administrator role that can grant/revoke other roles and perform critical operations
  • PAUSER_ROLE: Role responsible for pausing contract functions in emergency situations

Intent Contract Administration

Role Function Description
DEFAULT_ADMIN_ROLE upgradeToAndCall Upgrade implementation contract (UUPS pattern)
DEFAULT_ADMIN_ROLE unpause Unpauses the contract operations
DEFAULT_ADMIN_ROLE updateGateway Updates the gateway contract address
DEFAULT_ADMIN_ROLE updateRouter Updates the router contract address on ZetaChain
PAUSER_ROLE pause Pauses initiate and fulfill functions. Note: onCall remains active even when paused to ensure settlements from ZetaChain are processed

Router Contract Administration

Role Function Description
DEFAULT_ADMIN_ROLE upgradeToAndCall Upgrade implementation contract (UUPS pattern)
DEFAULT_ADMIN_ROLE unpause Unpauses the contract operations
DEFAULT_ADMIN_ROLE updateGateway Updates the gateway contract address
DEFAULT_ADMIN_ROLE updateSwapModule Updates the swap module address
DEFAULT_ADMIN_ROLE setIntentContract Sets the Intent contract address for a specific chain
DEFAULT_ADMIN_ROLE addToken Adds a new supported token to the system
DEFAULT_ADMIN_ROLE addTokenAssociation Associates a token with its addresses on different chains
DEFAULT_ADMIN_ROLE updateTokenAssociation Updates an existing token association
DEFAULT_ADMIN_ROLE removeTokenAssociation Removes a token association for a specific chain
DEFAULT_ADMIN_ROLE setWithdrawGasLimit Updates the gas limit for withdraw operations
PAUSER_ROLE pause Pauses the onCall function which prevents processing new cross-chain transactions

License

MIT

About

Speedrun router and EVM smart contract implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •