Derivio uses EIP-2535 Diamonds for a modular contract architecture.
zkSync Era
Contract
Address
Interfaces
Staking Diamond (sDLPM)
interface IStakingRewardsToken {structStakingRewardsConfigPrimitives {address assetToken;address rewardToken;uint256 rewardPeriod; }structStakingRewardsStatePrimitives {uint256 rewardPerSecond;uint256 cumulativeRewardPerToken;uint256 lastCumulativeRewardPerTokenUpdate;uint256 rewardPeriodEnd; }structStakingRewardsAccount {uint256 balance;uint256 entryCumulativeRewardPerToken;uint256 claimableReward; }/// @notice Get reward token addressfunctiongetRewardToken() externalviewreturns (address);/// @notice Get config primitivesfunctiongetStakingRewardsConfigPrimitives()externalviewreturns (StakingRewardsConfigPrimitivesmemory);/// @notice Get state primitivesfunctiongetStakingRewardsStatePrimitives()externalviewreturns (StakingRewardsStatePrimitivesmemory);/// @notice Get account infofunctiongetStakingRewardsAccount(address owner ) externalviewreturns (StakingRewardsAccountmemory);/// @notice Get reward amount claimable by ownerfunctionpreviewClaimableReward(address owner ) externalviewreturns (uint256);/// @notice Stake transferred in tokens (assumes token already transferred in)functionstake(address recipient) external;/// @notice Unstake sender's tokens, transfer unstaked tokens to recipient/// @dev Untrusted external callfunctionunstake(uint256 amount,address recipient) external;/// @notice Claim sender's reward, transfer reward to recipient/// @dev Untrusted external callfunctionclaim(address recipient) externalreturns (uint256 rewardAmount);}
Manager Diamond: Orders
Orders are created by the user (TX 1), then executed by keeper bot (TX 2).
To create an order (TX 1), the user needs to transfer tokens to the contract, then immediately call the create order function. WARNING: Transferring the tokens & order creation must be done in the same TX atomically, otherwise the tokens may be taken by someone else.
To do so, use the multi-delegatecall interface included in the manager diamond:
/// @notice Receives and executes a batch of function calls on this contract.functionmulticall(bytes[] calldata data) externalpayablereturns (bytes[] memory results);/// @notice Send ERC20 tokens to the contract. Intended to be used with multicall.functionsendERC20(address token,uint256 amount) externalpayable;
Creating an order requires execution fee in ETH. To get the current minimum execution fee: