Skip to content
Open
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 config.env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ contracts:
balancerArbAddress: $BALANCER_ARB_ADDRESS_V5
stabullArbAddress: $STABULL_ARB_ADDRESS_V5
dispair: $DISPAIR_V5
v6:
sushiArbAddress: $ARB_ADDRESS_V6
genericArbAddress: $GENERIC_ARB_ADDRESS_V6
balancerArbAddress: $BALANCER_ARB_ADDRESS_V6
stabullArbAddress: $STABULL_ARB_ADDRESS_V6
dispair: $DISPAIR_V6
liquidityProviders: $LIQUIDITY_PROVIDERS
route: $ROUTE
sleep: $SLEEP
Expand Down
14 changes: 14 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ writeRpc:

# List of subgraph urls, required
# for specifying more than 1 subgraph URL in the env, separate them by a comma
# NOTE: for v6 orderbook subgraph, prepend the URL with "v6=" because the v5 and v6
# subgraph schemas are identical and this prefix is needed to identify the version
subgraph:
- https://subgraph-url1.com
- https://subgraph-url2.com
- v6=https://v6-subgraph.com

# Contract addresses for different versions requireed for operating and solving trades
# at least one version should be partially or fully specified
Expand All @@ -61,6 +64,17 @@ contracts:
stabullArbAddress: "0x1234...5678"
# Dispair v5 contract address
dispair: "0x1234...5678"
v6:
# Sushi RP arb v6 contract address
sushiArbAddress: "0x1234...5678"
# Generic arb v6 contract address
genericArbAddress: "0x1234...5678"
# Balancer arb v6 contract address
balancerArbAddress: "0x1234...5678"
# Stabull arb v6 contract address
stabullArbAddress: "0x1234...5678"
# Dispair v6 contract address
dispair: "0x1234...5678"

# list of liquidity providers
# if provided through an env var, they should be separated by a comma
Expand Down
11 changes: 11 additions & 0 deletions src/common/abis/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@ const _deployer = [
`function eval4(${_EvalV4} calldata eval) external view returns (${_StackItem}[] calldata stack, bytes32[] calldata writes)`,
] as const;

const _deployerV6 = [
"function parse2(bytes memory data) external view returns (bytes memory bytecode)",
"function I_STORE() external view returns (address)",
"function I_INTERPRETER() external view returns (address)",
"function I_PARSER() external view returns (address)",
`function eval4(${_EvalV4} calldata eval) external view returns (${_StackItem}[] calldata stack, bytes32[] calldata writes)`,
] as const;

/** Keeps ExpressionDeployer related ABIs */
export namespace DeployerAbi {
/** ExpressionDeployerNPE2 contract primary parsed ABI */
export namespace Primary {
/** ExpressionDeployerNPE2 contract primary parsed ABI */
export const Deployer = parseAbi(_deployer);

/** ExpressionDeployerNPE2 contract primary parsed ABI */
export const DeployerV6 = parseAbi(_deployerV6);
}

/** Deployer signature ABI */
Expand Down
99 changes: 99 additions & 0 deletions src/common/abis/orderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,59 @@ export namespace _v5 {
] as const;
}

export namespace _v6 {
// structs
export const Float = "bytes32" as const;
export const IOV2 = `(address token, bytes32 vaultId)` as const;
export const EvaluableV4 = `(address interpreter, address store, bytes bytecode)` as const;
export const SignedContextV1 = "(address signer, bytes32[] context, bytes signature)" as const;
export const TaskV2 = `(${EvaluableV4} evaluable, ${SignedContextV1}[] signedContext)` as const;
export const ClearStateChangeV2 =
`(${Float} aliceOutput, ${Float} bobOutput, ${Float} aliceInput, ${Float} bobInput)` as const;
export const OrderV4 =
`(address owner, ${EvaluableV4} evaluable, ${IOV2}[] validInputs, ${IOV2}[] validOutputs, bytes32 nonce)` as const;
export const TakeOrderConfigV4 =
`(${OrderV4} order, uint256 inputIOIndex, uint256 outputIOIndex, ${SignedContextV1}[] signedContext)` as const;
export const QuoteV2 =
`(${OrderV4} order, uint256 inputIOIndex, uint256 outputIOIndex, ${SignedContextV1}[] signedContext)` as const;
export const TakeOrdersConfigV5 =
`(${Float} minimumIO, ${Float} maximumIO, ${Float} maximumIORatio, bool IOIsInput, ${TakeOrderConfigV4}[] orders, bytes data)` as const;
export const OrderConfigV4 =
`(${EvaluableV4} evaluable, ${IOV2}[] validInputs, ${IOV2}[] validOutputs, bytes32 nonce, bytes32 secret, bytes meta)` as const;
export const ClearConfigV2 =
"(uint256 aliceInputIOIndex, uint256 aliceOutputIOIndex, uint256 bobInputIOIndex, uint256 bobOutputIOIndex, bytes32 aliceBountyVaultId, bytes32 bobBountyVaultId)" as const;

// signatures
export const Orderbook = [
`event OrderNotFound(address sender, address owner, bytes32 orderHash)` as const,
`event AddOrderV3(address sender, bytes32 orderHash, ${OrderV4} order)` as const,
`event OrderZeroAmount(address sender, address owner, bytes32 orderHash)` as const,
`event RemoveOrderV3(address sender, bytes32 orderHash, ${OrderV4} order)` as const,
`event AfterClearV2(address sender, ${ClearStateChangeV2} clearStateChange)` as const,
`event OrderExceedsMaxRatio(address sender, address owner, bytes32 orderHash)` as const,
`event DepositV2(address sender, address token, bytes32 vaultId, uint256 depositAmountUint256)` as const,
`event ClearV3(address sender, ${OrderV4} alice, ${OrderV4} bob, ${ClearConfigV2} clearConfig)` as const,
`event TakeOrderV3(address sender, ${TakeOrderConfigV4} config, ${Float} input, ${Float} output)` as const,
`event WithdrawV2(address sender, address token, bytes32 vaultId, ${Float} targetAmount, ${Float} withdrawAmount, uint256 withdrawAmountUint256)` as const,
`function entask2(${TaskV2}[] calldata tasks) external` as const,
`function orderExists(bytes32 orderHash) external view returns (bool exists)` as const,
`function vaultBalance2(address owner, address token, bytes32 vaultId) external view returns (${Float} balance)` as const,
`function deposit4(address token, bytes32 vaultId, ${Float} depositAmount, ${TaskV2}[] calldata tasks) external` as const,
`function withdraw4(address token, bytes32 vaultId, ${Float} targetAmount, ${TaskV2}[] calldata tasks) external` as const,
`function removeOrder3(${OrderV4} calldata order, ${TaskV2}[] calldata tasks) external returns (bool stateChanged)` as const,
`function addOrder4(${OrderConfigV4} calldata config, ${TaskV2}[] calldata tasks) external returns (bool stateChanged)` as const,
`function quote2(${QuoteV2} calldata quoteConfig) external view returns (bool exists, ${Float} outputMax, ${Float} ioRatio)` as const,
`function takeOrders4(${TakeOrdersConfigV5} calldata config) external returns (${Float} totalTakerInput, ${Float} totalTakerOutput)` as const,
`function clear3(${OrderV4} memory alice, ${OrderV4} memory bob, ${ClearConfigV2} calldata clearConfig, ${SignedContextV1}[] memory aliceSignedContext, ${SignedContextV1}[] memory bobSignedContext) external` as const,
"function multicall(bytes[] calldata data) external returns (bytes[] memory results)",
] as const;
export const Arb = [
"function iRouteProcessor() external view returns (address)",
`function arb5(address orderBook, ${TakeOrdersConfigV5} calldata takeOrders, ${TaskV2} calldata task) external payable`,
// `function arb4(address orderBook, ${TakeOrdersConfigV5} calldata startTakeOrders, ${TakeOrdersConfigV5} calldata endTakeOrders, bytes calldata exchangeData, ${TaskV2} calldata task) external payable`,
] as const;
}

/** Keeps Orderbook v4 and v5 related ABIs */
export namespace OrderbookAbi {
export namespace V4 {
Expand Down Expand Up @@ -192,4 +245,50 @@ export namespace OrderbookAbi {
bytecode: "0x",
} as const;
}

export namespace V6 {
/** Orderbook and Arb contracts primary parsed ABIs */
export namespace Primary {
/** Arb contract ABI */
export const Arb = parseAbi(_v6.Arb);

/** Orderbook v6 contract ABI */
export const Orderbook = parseAbi(_v6.Orderbook);

/** Order v4 (for orderbook v6) struct ABI */
export const OrderStructAbi = parseAbiParameters(_v6.OrderV4);
}

/** Orderbook v4 structs */
export namespace Structs {
export const Float = _v6.Float;
export const IO = _v6.IOV2;
export const Evaluable = _v6.EvaluableV4;
export const SignedContext = _v6.SignedContextV1;
export const Task = _v6.TaskV2;
export const ClearStateChange = _v6.ClearStateChangeV2;
export const Order = _v6.OrderV4;
export const TakeOrderConfig = _v6.TakeOrderConfigV4;
export const OrderConfig = _v6.OrderConfigV4;
export const TakeOrdersConfig = _v6.TakeOrdersConfigV5;
export const ClearConfig = _v6.ClearConfigV2;
export const Quote = _v6.QuoteV2;
}

/** Signature ABI for Orderbook v4 and Arb contracts */
export namespace Signatures {
/** Signature ABI for Orderbook contract only including vaultBalance() function */
export const Orderbook = _v6.Orderbook;

/** Signature ABI for Arb contract */
export const Arb = _v6.Arb;
}

// an empty evaluable mainly used as default evaluable for arb contracts
export const DefaultArbEvaluable = {
interpreter: "0x" + "0".repeat(40),
store: "0x" + "0".repeat(40),
bytecode: "0x",
} as const;
}
}
36 changes: 36 additions & 0 deletions src/config/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,27 @@ export namespace Validator {
"stabullArbAddress v5",
true,
);
const dispairV6 = resolveAddress(input?.contracts?.v6?.dispair, "dispair v6", true);
const sushiArbAddressV6 = resolveAddress(
input?.contracts?.v6?.sushiArbAddress,
"sushiArbAddress v6",
true,
);
const genericArbAddressV6 = resolveAddress(
input?.contracts?.v6?.genericArbAddress,
"genericArbAddress v6",
true,
);
const balancerArbAddressV6 = resolveAddress(
input?.contracts?.v6?.balancerArbAddress,
"balancerArbAddress v6",
true,
);
const stabullArbAddressV6 = resolveAddress(
input?.contracts?.v6?.stabullArbAddress,
"stabullArbAddress v6",
true,
);
const contracts: AppOptionsContracts = {};
if (
dispairV4 ||
Expand Down Expand Up @@ -543,6 +564,21 @@ export namespace Validator {
stabullArb: stabullArbAddressV5 as `0x${string}` | undefined,
};
}
if (
dispairV6 ||
sushiArbAddressV6 ||
genericArbAddressV6 ||
balancerArbAddressV6 ||
stabullArbAddressV6
) {
contracts.v6 = {
sushiArb: sushiArbAddressV6 as `0x${string}` | undefined,
dispair: dispairV6 as `0x${string}` | undefined,
genericArb: genericArbAddressV6 as `0x${string}` | undefined,
balancerArb: balancerArbAddressV6 as `0x${string}` | undefined,
stabullArb: stabullArbAddressV6 as `0x${string}` | undefined,
};
}
return contracts;
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/config/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export type AppOptionsContracts = {
balancerArb?: `0x${string}`;
stabullArb?: `0x${string}`;
};
v6?: {
sushiArb?: `0x${string}`;
dispair?: `0x${string}`;
genericArb?: `0x${string}`;
balancerArb?: `0x${string}`;
stabullArb?: `0x${string}`;
};
};

/** Rain Solver app yaml configurations */
Expand Down
Loading
Loading