Skip to content
Merged
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
6 changes: 6 additions & 0 deletions evm/config.testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ FEE_TOKEN = "0xBE97E73126D66188d72fbF99029126D0340a7f18"
CALL_DISPATCHER = "0x2B332088275Bc9E3C26D81B2975de2483320C181"
BANDWIDTH_MANAGER = "0xfE6d81417CFe618ACAA34Df23376C738900290de"
SP1_VERIFIER = "0xe46f1D4A1fC2130C3a3f3f5f78432774D28d249D"
INTENT_GATEWAY_V2 = "0xE13fB34CAe12505ae51BaC8C405AF8EB27AC8058"
SOLVER_ACCOUNT = "0x0b5cfBc16ef60AD6930ba5A90Bb09475B7BF3815"
PRICE_ORACLE = "0x0000000000000000000000000000000000000000"

[97.bool]
is_mainnet = false
Expand Down Expand Up @@ -117,6 +120,9 @@ FEE_TOKEN = "0xBE97E73126D66188d72fbF99029126D0340a7f18"
CALL_DISPATCHER = "0x2B332088275Bc9E3C26D81B2975de2483320C181"
BANDWIDTH_MANAGER = "0xfE6d81417CFe618ACAA34Df23376C738900290de"
SP1_VERIFIER = "0xe46f1D4A1fC2130C3a3f3f5f78432774D28d249D"
INTENT_GATEWAY_V2 = "0xE13fB34CAe12505ae51BaC8C405AF8EB27AC8058"
SOLVER_ACCOUNT = "0x0b5cfBc16ef60AD6930ba5A90Bb09475B7BF3815"
PRICE_ORACLE = "0x0000000000000000000000000000000000000000"

[80002.bool]
is_mainnet = false
Expand Down
87 changes: 50 additions & 37 deletions evm/script/DeployIntentGateway.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,56 @@ contract DeployScript is BaseScript {
address priceOracle = address(0);
// address priceOracle = deployPriceOracle(address(intentGateway));

Deployment[] memory deployments = new Deployment[](9);
deployments[0] = Deployment({
chain: StateMachine.evm(1), // ethereum
gateway: address(intentGateway)
});
deployments[1] = Deployment({
chain: StateMachine.evm(10), // optimism
gateway: address(intentGateway)
});
deployments[2] = Deployment({
chain: StateMachine.evm(42161), // arbitrum
gateway: address(intentGateway)
});
deployments[3] = Deployment({
chain: StateMachine.evm(8453), // base
gateway: address(intentGateway)
});
deployments[4] = Deployment({
chain: StateMachine.evm(56), // bsc
gateway: address(intentGateway)
});
deployments[5] = Deployment({
chain: StateMachine.evm(100), // gnosis
gateway: address(intentGateway)
});
deployments[6] = Deployment({
chain: StateMachine.evm(137), // polygon
gateway: address(intentGateway)
});
deployments[7] = Deployment({
chain: StateMachine.evm(420420419), // polkadot
gateway: address(intentGateway)
});
deployments[8] = Deployment({
chain: StateMachine.evm(1868), // soneium
gateway: address(intentGateway)
});
Deployment[] memory deployments;
if (config.get("is_mainnet").toBool()) {
deployments = new Deployment[](9);
deployments[0] = Deployment({
chain: StateMachine.evm(1), // ethereum
gateway: address(intentGateway)
});
deployments[1] = Deployment({
chain: StateMachine.evm(10), // optimism
gateway: address(intentGateway)
});
deployments[2] = Deployment({
chain: StateMachine.evm(42161), // arbitrum
gateway: address(intentGateway)
});
deployments[3] = Deployment({
chain: StateMachine.evm(8453), // base
gateway: address(intentGateway)
});
deployments[4] = Deployment({
chain: StateMachine.evm(56), // bsc
gateway: address(intentGateway)
});
deployments[5] = Deployment({
chain: StateMachine.evm(100), // gnosis
gateway: address(intentGateway)
});
deployments[6] = Deployment({
chain: StateMachine.evm(137), // polygon
gateway: address(intentGateway)
});
deployments[7] = Deployment({
chain: StateMachine.evm(420420419), // polkadot
gateway: address(intentGateway)
});
deployments[8] = Deployment({
chain: StateMachine.evm(1868), // soneium
gateway: address(intentGateway)
});
} else {
deployments = new Deployment[](2);
deployments[0] = Deployment({
chain: StateMachine.evm(97), // bsc testnet (chapel)
gateway: address(intentGateway)
});
deployments[1] = Deployment({
chain: StateMachine.evm(80002), // polygon amoy
gateway: address(intentGateway)
});
}

intentGateway.init(
Params({
Expand Down
4 changes: 2 additions & 2 deletions sdk/packages/core/contracts/apps/IntentGatewayV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ interface IIntentGatewayV2 {
*/
event OrderPlaced(
bytes32 user,
bytes source,
bytes destination,
string source,
string destination,
uint256 deadline,
uint256 nonce,
uint256 fees,
Expand Down
10 changes: 5 additions & 5 deletions sdk/packages/sdk/src/configs/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const chainConfigs: Record<number, ChainConfigData> = {
USDT: { balanceSlot: 151, allowanceSlot: 152 },
},
addresses: {
IntentGateway: "0xFbF50B2b32768127603cC9eF4b871574b881b8eD",
IntentGateway: "0xE13fB34CAe12505ae51BaC8C405AF8EB27AC8058",
TokenGateway: "0xFcDa26cA021d5535C3059547390E6cCd8De7acA6",
Host: "0xEB944071A9Bf22810757C5BcFf7a2aE9663a311D",
UniswapRouter02: "0x9639379819420704457B07A0C33B678D9E0F8Df0",
Expand All @@ -208,7 +208,7 @@ export const chainConfigs: Record<number, ChainConfigData> = {
UniswapV3Quoter: "0x0000000000000000000000000000000000000000",
UniswapV4Quoter: "0x0000000000000000000000000000000000000000",
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
SolverAccount: "0xCDFcFeD7A14154846808FddC8Ba971A2f8a830a3",
SolverAccount: "0x0b5cfBc16ef60AD6930ba5A90Bb09475B7BF3815",
},
rpcEnvKey: "BSC_CHAPEL",
defaultRpcUrl: "https://bnb-testnet.api.onfinality.io/public",
Expand Down Expand Up @@ -611,7 +611,7 @@ export const chainConfigs: Record<number, ChainConfigData> = {
WETH: "0x360ad4f9a9A8EFe9A8DCB5f461c4Cc1047E1Dcf9", //wmatic, change it to wpol
DAI: "0x0000000000000000000000000000000000000000",
USDC: "0x693b854d6965ffeaae21c74049dea644b56fcacb",
USDT: "0x693b854d6965ffeaae21c74049dea644b56fcacb",
USDT: "0x0000000000000000000000000000000000000000",
},
tokenDecimals: {
USDC: 18,
Expand All @@ -622,13 +622,13 @@ export const chainConfigs: Record<number, ChainConfigData> = {
USDC: { balanceSlot: 1, allowanceSlot: 2 },
},
addresses: {
IntentGateway: "0xFbF50B2b32768127603cC9eF4b871574b881b8eD",
IntentGateway: "0xE13fB34CAe12505ae51BaC8C405AF8EB27AC8058",
TokenGateway: "0x8b536105b6Fae2aE9199f5146D3C57Dfe53b614E",
Host: "0xEB944071A9Bf22810757C5BcFf7a2aE9663a311D",
Calldispatcher: "0x876F1891982E260026630c233A4897160A281Fb8",
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
SolverAccount: "0xCDFcFeD7A14154846808FddC8Ba971A2f8a830a3",
SolverAccount: "0x0b5cfBc16ef60AD6930ba5A90Bb09475B7BF3815",
},
rpcEnvKey: "POLYGON_AMOY",
defaultRpcUrl: "https://rpc-amoy.polygon.technology",
Expand Down
7 changes: 4 additions & 3 deletions sdk/packages/simplex/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperbridge/simplex",
"version": "0.5.3",
"version": "0.5.4",
"license": "Apache-2.0",
"description": "IntentGateway simplex package for hyperbridge",
"main": "dist/index.js",
Expand All @@ -23,9 +23,10 @@
"build": "bash ./scripts/build.sh",
"prepublishOnly": "npm run build",
"test": "pnpm run codegen && vitest --watch=false --maxConcurrency=1",
"test:filler": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/basic.testnet.test.ts src/tests/quorum-public-client.test.ts",
"test:basic": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/basic.testnet.test.ts",
"test:filler": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/fx.testnet.test.ts src/tests/quorum-public-client.test.ts",
"test:basic:testnet": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/basic.testnet.test.ts",
"test:fx": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/fx.mainnet.test.ts",
"test:fx-testnet": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/fx.testnet.test.ts",
"test:mpcvault": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=120000 src/tests/wallet/mpcvault.integration.test.ts",
"test:uniswapV4Price": "pnpm run codegen && vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/funding/uniswapV4Price.test.ts",
"test:watch": "pnpm run codegen && vitest",
Expand Down
18 changes: 17 additions & 1 deletion sdk/packages/simplex/src/core/filler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,23 @@ export class IntentFiller {
)
const result = await this.delegationService.setupDelegationOnChains(chainsWithSolverSelection)
if (!result.success) {
this.logger.warn({ results: result.results }, "Some chains failed EIP-7702 delegation setup")
const failedChains = Object.entries(result.results)
.filter(([, ok]) => !ok)
.map(([chain]) => chain)
const allFailed = failedChains.length === chainsWithSolverSelection.length
if (allFailed) {
this.logger.error(
{ results: result.results },
"EIP-7702 delegation failed on all chains; shutting down",
)
throw new Error(
`EIP-7702 delegation failed on all chains: ${failedChains.join(", ")}. Shutting down for restart.`,
)
}
this.logger.warn(
{ failedChains, results: result.results },
"Some chains failed EIP-7702 delegation setup; continuing on remaining chains",
)
}

// Ensure EntryPoint deposit covers target gas units on chains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,13 @@ export class ContractInteractionService {
outputs: cachedFillerOutputs,
}

// dispatchWithFeeToken pulls relayerFee in fee token; native dispatch pulls none.
const dispatchFeeTokenAmount = fillOptions.nativeDispatchFee > 0n ? 0n : fillOptions.relayerFee
const callData = await this.buildApprovalAndFillCalldata(
order,
cachedFillerOutputs,
fillOptions,
cachedEstimate.totalCostInSourceFeeToken,
cachedEstimate.totalCostInSourceFeeToken + dispatchFeeTokenAmount,
)

const commitment = orderCommitment(order)
Expand Down
12 changes: 5 additions & 7 deletions sdk/packages/simplex/src/services/DelegationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { ENTRYPOINT_ABI } from "@/config/abis/Entrypoint"
/** EIP-7702 delegation indicator prefix */
const DELEGATION_INDICATOR_PREFIX = "0xef0100"

/** Floor for set-code (0x04) txs; L2s like Arbitrum reject viem's default ~94k with "intrinsic gas too low". */
const DELEGATION_TX_GAS_FLOOR = 350_000n
/**
* Fixed gas limit for set-code (0x04) txs.
*/
const DELEGATION_TX_GAS_FLOOR = 650_000n

/**
* Service for managing EIP-7702 delegation of the filler's EOA to the SolverAccount contract.
Expand All @@ -35,11 +37,7 @@ export class DelegationService {
private computeAuthorizationHash(chainId: number, contractAddress: HexString, nonce: number): HexString {
// EIP-7702 requires canonical RLP: integer 0 encodes as empty bytes (0x80), not 0x00.
// viem's `toHex(0)` returns '0x0' which RLP-encodes as the single byte 0x00 — wrong.
const encoded = toRlp([
chainId ? toHex(chainId) : "0x",
contractAddress,
nonce ? toHex(nonce) : "0x",
])
const encoded = toRlp([chainId ? toHex(chainId) : "0x", contractAddress, nonce ? toHex(nonce) : "0x"])
return keccak256(concat(["0x05", encoded])) as HexString
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function createTurnkeySigningAccount(config: TurnkeySignerConfig):
value: 0n,
authorizationList: [args.authorization],
chain: args.walletClient.chain,
gas: args.gasFloor,
})) as HexString,
}
}
Loading
Loading