Automated Market Taker Protocol ๐ค
Onchain yield harvesting and strategy trade protocol. ๐
- Automated Onchain Trading: Implements a fully automated trading strategy based on mathematical and market-driven rules by one button "GRIND". ๐
- Capital Optimization: Maximizes efficiency of liquidity by dynamically adjusting liquidity. ๐ฐ
Architecture:
- PoolsNFT ๐ด - Enumerates all strategy pools. The gateway to the standardized interaction with strategy pools.
- PoolsNFTLens ๐ - Lens contract that retrieves data from PoolsNFT and Strategies.
- URUS โ๏ธ - Implements all URUS algorithm logic. Core of liquidity micromanagement
- Registry ๐ - Storage of quote tokens, base tokens, and oracles, grAI crosschain info.
- GRETH ๐ช - ERC20 token that stands as incentivization for
grindand implements the index of collected profit. - Strategy ๐ - Logic that utilizes URUS + interaction with onchain protocols like AAVE and Uniswap.
- StrategyFactory ๐ญ - Factory that deploys ERC1967Proxy of Strategy as isolated smart contract with liquidity.
- GRAI ๐ช - ERC20 token that tokenizes grinds on intent.
- GrinderAI ๐ค - Gateway for AI agent to interact with PoolsNFT and GRAI.
PoolsNFT is a gateway that facilitates the creation of strategy pools and links represented by NFTs. It supports royalty mechanisms upon strategy profits, deposits, withdrawals, and strategy grinding.
- Pool Ownership: Each NFT represents ownership of a strategy pool. ๐ฆ
- Royalties: Configurable royalty system with shares for pool owners, grinders, and reserve funds on grETH token. ๐
- Deposits & Withdrawals: Supports token deposits and withdrawals while enforcing caps and minimum limits to trusted actors. ๐ณ
- Profit Sharing: Distributes profits between participants of the strategy pool. ๐ค๐ฅ
- Rebalancing: Enables efficient pool balancing across different strategies. โ๏ธ
- Royalty Trading: Allows users to buy royalty on strategy profits. ๐
- Minting: Deploys a strategy pool and mints its NFT representation. ๐จ๏ธ
- Grind Mechanism: Rewards users with grETH for maintaining pool strategies. ๐
- Management: Flexible configuration of deposits, royalty shares, and pool limits. ๐ง
The owner has the highest level of authority in the contract and is responsible for administrative operations and configuration. ๐ ๏ธ
The agent acts as a delegate for the pool owner, authorized to perform configuration of strategy parameters in URUS and rebalancing strategy pools owned by ownerOf. ๐
royaltyPriceInitNumerator: Determines the initial royalty price as a percentage of the deposited quote token. ๐royaltyPriceCompensationShareNumerator: Share of the royalty price allocated as compensation to the previous owner. ๐ฐroyaltyPriceReserveShareNumerator: Share allocated to the reserve. ๐ฆroyaltyPricePoolOwnerShareNumerator: Share allocated to the pool owner. ๐royaltyPriceGrinderShareNumerator: Share allocated to the last grinder. ๐
grethGrinderShareNumerator: Share of the grinder reward allocated to the grinder (e.g., 80%). ๐grethReserveShareNumerator: Share allocated to the reserve (e.g., 10%). ๐ฆgrethPoolOwnerShareNumerator: Share allocated to the pool owner (e.g., 5%). ๐grethRoyaltyReceiverShareNumerator: Share allocated to the royalty receiver (e.g., 5%). ๐
royaltyNumerator: Total royalty share of the profits (e.g., 20%). ๐poolOwnerShareNumerator: Share of profits allocated to the pool owner (e.g., 80%). ๐royaltyReceiverShareNumerator: Share of the royalty allocated to the royalty receiver (e.g., 10%). ๐royaltyReserveShareNumerator: Share allocated to the reserve on GRETH (e.g., 5%). ๐ฆroyaltyOwnerShareNumerator: Share allocated to the owner of the protocol (e.g., 5%). ๐
setPoolsNFTLens(address _poolsNFTLens)๐ผ๏ธ: Set the PoolsNFTLens address.setRoyaltyPriceInitNumerator(uint16 _royaltyPriceInitNumerator)๐: Set the royalty price initial numerator.setRoyaltyPriceShares(...)๐: Adjust royalty price shares.setGRETHShares(...)๐ช: Adjust GRETH share distributions.setRoyaltyShares(...)๐: Adjust royalty distribution shares.transferOwnership(address payable newOwner)๐: Transfer ownership tonewOwner. RequiresnewOwnerto call this function with the same parameter.setStrategyFactory(address _strategyFactory)๐ญ: Set the strategy factory. Internally instantiatesstrategyFactoryId.setStrategyStopped(uint16 strategyId, bool _isStrategyStopped)โ: Stop or resume the deployment of a strategy.execute(address target, uint256 value, bytes memory data)๐: Execute any transaction.
- Use
mintormintToto create a new isolated strategy pool:- Specify
strategyId,quoteToken,baseToken, and the initial amount ofquoteToken. ๐ช - Call the
StrategyFactory, which deploys an ERC1967Proxy with the implementation ofStrategy. ๐๏ธ - Mint the corresponding NFT bound to the deployed ERC1967Proxy. ๐ด
- Transfer
quoteTokenfrommsg.sendertoPoolsNFT. ๐ณ - Call
depositonStrategyas a gateway. ๐
- Specify
- Deposit
quoteTokento a strategy pool withpoolId:- Check that
msg.senderis the depositor ofpoolId. ๐ก๏ธ - Ensure that
quoteTokenAmountis within the bounds ofminDeposit < quoteTokenAmount < maxDeposit. ๐ - Transfer
quoteTokenfrommsg.sendertoPoolsNFT. ๐ฐ - Call
depositonStrategyas a gateway. ๐
- Check that
- Deposits
baseTokenwith specifiedbaseTokenPriceto strategy pool withpoolId๐ฆ- Checks that
msg.senderis agent ofpoolIdโ baseTokentransfers frommsg.sendertoPoolsNFT๐- Call
deposit2onStrategyas gateway ๐
- Checks that
- Withdraw
quoteTokenfrom strategy pool withpoolId๐ต- Checks that
msg.senderis agent ofpoolIdโ - Call
withdrawonStrategyas gateway ๐
- Checks that
- Withdraw all liquidity of
quoteTokenandbaseTokenfrom strategy pool withpoolId๐ธ- Checks that
msg.senderis agent ofpoolIdโ - Call
exitonStrategyas gateway ๐
- Checks that
- Sets agent of
poolId๐ ๏ธ
- Rebalance funds of two different strategy pools
poolId0andpoolId1with portionsrebalance0+rebalance1๐- Checks that owners of
poolId0andpoolId1are equal โ - Checks that
msg.senderis agent ofpoolId0andpoolId1. Owner of pool can be agent ๐ค - Call
beforeRebalanceon pools withpoolId0andpoolId1๐ง PoolsNFTreceivesbaseTokenfrompoolId0andpoolId1๐ฅ- Rebalance funds โ๏ธ
PoolsNFTapproves transfer ofbaseTokenโ- Call
afterRebalanceon pools withpoolId0andpoolId1๐ง
- Checks that owners of
- Grind strategy with
poolId:- โ
Checks that
poolIdhas sufficient balance ofquoteToken+baseToken. - ๐ Call
grindonStrategy. - ๐
If the call is successful, the grinder earns
grETH, equal to the spent transaction fee.
- โ
Checks that
- Buy royalty of
poolId:- ๐ Calculate royalty shares.
- ๐ฐ
msg.senderpays for the royalty. - ๐ค
PoolsNFTdistributes shares. - ๐
msg.senderbecomes the royalty receiver ofpoolId.
URUS is the core logic of the URUS trading algorithm. It is designed to handle automated trading, hedging, and rebalancing liqudity from quoteToken to baseToken and vise versa.
- Position Management: Supports long and hedge positions with configurable parameters. ๐๐
- Profits Accountability: Tracks and distributes yield and trade profits for
quoteTokenandbaseToken. ๐ต - Investment & Rebalancing: Handles liquidity management, token swaps, and holding through lending/liquidity protocols. ๐
The HelperData struct contains metadata and dynamic parameters essential for the functionality of the URUS algorithm:
- Token Decimals: Stores decimals for
baseToken,quoteToken, andfeeToken. ๐ข - Oracle Decimals: Stores decimals and multipliers for price oracles. ๐
- Coefficient Multipliers: Constants for fee and percentage calculations. โ๏ธ
The feeToken is a utility token used to pay transaction fees during URUS operations. For most EVM chains, the fee token equals WETH (wrapped ETH). ๐
The quoteToken is the primary unit of account and settlement for trades. It is used to:
- Define the value of other tokens. ๐
- Record liquidity and calculate profitability in terms of
quoteToken. ๐ฐ
The baseToken is the asset being traded within the URUS strategy. For example, in an ETH/USDT trading pair:
baseToken: ETH ๐ ๏ธquoteToken: USDT ๐ต
The FeeConfig structure in the URUS contract defines parameters for calculating fees applied during trading operations. Unlike a fixed percentage, the fee coefficients (feeCoef) are multipliers applied to the sum of transaction fees, allowing dynamic scaling of fees for different operations. ๐
Definition:
struct FeeConfig {
uint256 longSellFeeCoef; // Fee coeficient for selling in a long position.
uint256 hedgeSellFeeCoef; // Fee coeficient for selling in a hedge position.
uint256 hedgeRebuyFeeCoef; // Fee coeficient for rebuying during a hedge operation.
}- Description: Coefficient used to calculate the fee for a
long_selloperation. ๐ - Purpose: Covers additional protocol fees for selling a long position. ๐ฆ
- How It Works:
- Multiplies the base transaction fee (
feeQty) bylongSellFeeCoef. ๐
- Multiplies the base transaction fee (
- Example:
- If
feeQty = 50(in feeToken) andlongSellFeeCoef = 1_50: [ \text{Total Fee} = \frac{50 \times 1.50}{100} = 75 , \text{feeToken}. ] ๐งฎ
- If
- Description: Coefficient used to calculate the fee for a
hedge_selloperation. ๐ง - Purpose: Ensures coverage of costs and rewards for selling during a hedge position. ๐ก๏ธ
- How It Works:
- Multiplies the base transaction fee (
feeQty) byhedgeSellFeeCoef. ๐
- Multiplies the base transaction fee (
- Example:
- If
feeQty = 30(in feeToken) andhedgeSellFeeCoef = 2_00: [ \text{Total Fee} = \frac{30 \times 2.00}{100} = 60 , \text{feeToken}. ] ๐งฎ
- If
- Description: Coefficient used to calculate the fee for a
hedge_rebuyoperation. ๐ต - Purpose: Covers costs associated with rebuying assets during a hedge position. ๐ ๏ธ
- How It Works:
- Multiplies the base transaction fee (
feeQty) byhedgeRebuyFeeCoef. ๐
- Multiplies the base transaction fee (
- Example:
- If
feeQty = 40(in feeToken) andhedgeRebuyFeeCoef = 1_75: [ \text{Total Fee} = \frac{40 \times 1.75}{100} = 70 , \text{feeToken}. ] ๐งฎ
- If
Fees are calculated as follows:
- Determine the transaction fee (
feeQty) infeeToken. This can include:- Gas costs in
feeToken. โฝ - Additional operational expenses. โ๏ธ
- Gas costs in
- Apply the corresponding fee coefficient (
feeCoef): ๐ข [ \text{Total Fee} = \frac{\text{feeQty} \times \text{feeCoef}}{\text{helper.coefMultiplier}} ] ๐งฎ
The Config structure in the URUS contract defines critical parameters for the operation of the URUS algorithm. These parameters control the behavior of positions, thresholds, and profit margins during trading. Adjusting these values allows authorized roles to optimize the strategy for specific market conditions. ๐
The Config structure contains the following parameters:
- Description: The maximum number of buys that can be executed. ๐
- Purpose: Limits the exposure to long positions, ensuring controlled investment levels. ๐ก๏ธ
- Example:
- If
longNumberMax = 4, a maximum of 4 sequential buys can be executed. ๐ - Scenario: Assume the following conditions:
- Initial investment: 100 USDT ๐ต
extraCoef = 2_00(x2.00) ๐ง- Long Number Max: 4 ๐ข
- The investments would be:
- Buy amount on iteration 1: 100 USDT ๐ฐ
Total investment: 100 USDT ๐ต - Buy amount on iteration 2: 100 * 2.00 = 200 USDT ๐ฐ
Total investment: 100 + 200 = 300 USDT ๐ต - Buy amount on iteration 3: 300 * 2.00 = 600 USDT ๐ฐ
Total investment: 300 + 600 = 900 USDT ๐ต - Buy amount on iteration 4: 900 * 2.00 = 1800 USDT ๐ฐ
Total investment: 900 + 1800 = 2700 USDT ๐ต
- Buy amount on iteration 1: 100 USDT ๐ฐ
- If
- Description: The maximum number of hedge level grids. ๐
- Purpose: Defines the depth level of hedging during adverse market movements. โ๏ธ
- Example:
- If
hedgeNumberMax = 3, the hedge process will stop after 3 iterations. โ - Scenario:
- Total
baseTokenholdings: 16 units ๐ช - Hedge process splits positions:
- Hedge 1: 4 units ๐
Total sold: 4 units ๐ค - Hedge 2: 4 units ๐
Total sold: 4 + 4 = 8 units ๐ค - Hedge 3: 8 units ๐
Total sold: 8 + 8 = 16 units ๐ค
- Hedge 1: 4 units ๐
- No further hedging will occur after 3 steps. The position is closed. ๐ช
- Total
- If
- Description: Multiplier used to calculate the additional liquidity required for subsequent long positions. ๐
- Purpose: Ensures exponential growth of investments in long positions while maintaining proportional risk. โ๏ธ
- Description: The allowed price volatility percentage for position thresholds. ๐๐
- Purpose: Helps define the acceptable range of price movements before triggering operations. ๐ฏ
- Example:
- If
priceVolatilityPercent = 1_00(1%): ๐- Long position threshold: If price drops by 1%, a buy order is triggered. ๐
- Scenario:
baseTokenprice: 1000quoteToken/baseToken๐ต- Volatility: 1% ๐ช๏ธ
- Trigger price: 990
quoteToken/baseToken๐
- If
- Description: The required return percentage to execute a profitable
long_sell. ๐ - Purpose: Ensures that long positions are sold only when a certain profit margin is achieved. ๐ฆ
- Example:
- If
returnPercentLongSell = 100_50(100.5%): ๐- A
long_sellwill only execute if the return is 0.5% or more above the initial investment. ๐๏ธ - Scenario:
- Initial investment: $1,000 ๐ต
- Required return: $1,005 (0.5% profit) ๐
- A
- If
- Description: The required return percentage to execute a profitable
hedge_sell. ๐ - Purpose: Protects hedge positions by ensuring a minimum profit margin before selling. โ๏ธ
- Example:
- If
returnPercentHedgeSell = 100_50(100.5%): ๐- A
hedge_sellwill only execute if the return is 0.5% or more above the investment. ๐
- A
- If
- Description: The required return percentage to execute a profitable
hedge_rebuy. ๐ต - Purpose: Ensures that hedge positions are repurchased only when a certain profit margin is achievable. ๐ฆ
- Example:
- If
returnPercentHedgeRebuy = 100_50(100.5%): ๐- A
hedge_rebuywill only execute if the return is 0.5% or more. ๐๏ธ
- A
- If
Changes to the Config structure can only be made by authorized roles, defined in Strategy:
setConfig(Config memory conf)๐ ๏ธ: Sets the entire configuration.setLongNumberMax(uint8 longNumberMax)๐ข: Sets the maximum number of long positions.setHedgeNumberMax(uint8 hedgeNumberMax)๐ก๏ธ: Sets the maximum number of levels of hedge positions.setExtraCoef(uint256 extraCoef)๐: Sets the multiplier for liquidity calculations.setPriceVolatilityPercent(uint256 priceVolatilityPercent)๐: Sets the allowed price volatility.setOpReturnPercent(uint8 op, uint256 returnPercent)๐: Sets the return percentage for specific operations.
The long position tracks data related to buying and holding baseToken:
number๐ข: Current long buys count.numberMax๐: Maximum allowed long buys.priceMin๐: Minimum allowable threshold price forbaseTokenpurchases.liquidity๐ฐ: Quote token liquidity in the position.qty๐ช: Quantity ofbaseTokenheld.priceโ๏ธ: Weighted average cost price.feeQty๐ต: Total fee quantity accrued infeeToken.feePrice๐: Fee price in terms ofquoteToken.
The hedge position tracks data for hedging against price declines:
number๐ข: Current hedge position count.numberMax๐: Maximum allowed hedge positions.priceMin๐: Minimum price at which the hedge was initialized.liquidity๐ฐ: Quote token liquidity used in the hedge.qty๐ช: Quantity ofbaseTokenhedged.priceโ๏ธ: Hedge price.feeQty๐ต: Total fee quantity accrued infeeToken.feePrice๐: Fee price in terms ofquoteToken.
- Action: Deposit
quoteTokeninto the strategy pool. - Steps:
- ๐ Instantiate start timestamp.
- ๐ฐ
quoteTokenis transferred from the gateway. - ๐ Make an investment (calculate
initialLiquidity). - ๐ฆ Put
quoteTokeninto the lending protocol.
- Action: Deposit
baseTokenwith specifiedbaseTokenPriceinto the strategy pool. - Steps:
- โ Check that the long position is not bought or has used all liquidity.
- โ Check that liquidity is not hedged.
- ๐ฐ
baseTokenis transferred from the gateway. - ๐ฆ Put
baseTokeninto the lending protocol. - ๐ Recalculate all position-related parameters.
- Action: Deposit
quoteTokeninto the strategy pool. ๐ฆ - Steps:
- โ Check that the long position used all liquidity.
- ๐ก๏ธ Check that liquidity is not hedged.
- ๐ฐ
quoteTokenis transferred from the gateway. - ๐ Swap
quoteTokentobaseToken. - ๐๏ธ Make an investment (recalculate
initialLiquidity). - ๐ฆ Put
baseTokeninto the lending protocol. - ๐ Recalculate all position-related parameters.
- Action: Withdraw
quoteTokenfrom the pool. ๐ต - Steps:
- โ Check that no liquidity is used.
- ๐ฐ Take
quoteTokenAmount. - ๐ค Transfer
quoteTokenAmountto the withdrawer.
- Action: Exit all positions and withdraw all assets. ๐ธ
- Steps:
- ๐ฆ Fetch all
baseTokenandquoteTokenfrom lending protocols or fund storage. - ๐ค Transfer tokens to the owner's address.
- ๐ Reset
longandhedgepositions to their initial state.
- Action: Executes a buy operation for
baseTokenin a long position. ๐ - Steps:
- ๐งฎ Calculate the amount of
quoteTokenrequired. - ๐ฐ Fetch
quoteTokenfrom lending protocols. - ๐ Swap
quoteTokenforbaseTokenon a DEX. - ๐ Update the long position with the new
baseTokenquantity and average price.
- Action: Sells all
baseTokenfrom a long position. ๐ - Steps:
- ๐ฆ Fetch all
baseTokenfrom lending protocols. - ๐ Swap
baseTokenforquoteToken. - โ Verify profitability based on thresholds.
- ๐ต Distribute profits and reset the long position.
- Action: Sells
baseTokento hedge against price declines. ๐ - Steps:
- ๐งฎ Calculates the
baseTokenquantity to sell. - ๐ฆ Fetches
baseTokenfrom lending protocols. - ๐ Swaps
baseTokenforquoteTokenon a DEX. - ๐ Updates the hedge position and adjusts the long position.
- ๐งฎ Calculates the
- Action: Rebuys
baseTokenduring a hedge position. ๐ - Steps:
- ๐ฐ Uses
quoteTokenliquidity from the hedge position. - ๐ Swaps
quoteTokenforbaseTokenon a DEX. - ๐ Updates the long position with the re-bought quantity.
- ๐ ๏ธ Resets the hedge position.
- ๐ฐ Uses
- Action: Executes the appropriate trading operation based on the current state. โ๏ธ
- Steps:
- ๐ Calls
long_buyif no positions exist. - ๐ Calls
long_sellorlong_buyif a long position is active. - ๐ก๏ธ Calls
hedge_sellorhedge_rebuyif hedging is active.
- ๐ Calls
- Action: Prepares the strategy for rebalancing. ๐ ๏ธ
- Steps:
- ๐ฆ Fetches all
baseTokenfrom lending protocols. - ๐ Transfers tokens to the rebalancing contract (gateway).
- ๐ Adjusts the long position accordingly.
- ๐ฆ Fetches all
- Action: Updates the strategy after rebalancing. ๐ง
- Steps:
- ๐ฆ Fetches rebalanced
baseTokenfrom the rebalancing contract. - ๐ Updates the long position with the new price and quantity.
- ๐ฆ Fetches rebalanced
grETH is the yield index token, representing profits accumulated in strategy pools.
- The
sharefunction calculates the proportional value of a specified amount of grETH in terms of a chosen asset (native or ERC-20 token). ๐ - Formula:
(Liquidity * grETH Amount) / Total grETH Supply๐งฎ
All ETH transfers to grETH are converted to WETH. ๐
The Registry contract is the metadata and configuration hub for the GrindURUS protocol. It maintains mappings between quote/base tokens, price oracles, strategy factories, and GRAI token configurations across chains. It also tracks token coherence for analytical and routing purposes.
- Stores oracle connections between token pairs.
- Tracks all available quote and base tokens.
- Registers strategies and LayerZero endpoint information for GRAI tokens.
- Computes token coherence (used for assessing oracle coverage).
- Delegates ownership rights dynamically to the
PoolsNFTcontract's owner.
owner()โ Returns the current protocol owner viaPoolsNFT._onlyOwner()โ Reverts if caller is not owner.
-
setPoolsNFT(address _poolsNFT)
Set the reference address for thePoolsNFTcontract. -
setOracle(address quoteToken, address baseToken, address oracle)
Set an oracle for a token pair and automatically deploy the inverse oracle. -
unsetOracle(address quoteToken, address baseToken, address oracle)
Remove an existing oracle mapping and clean up coherence tracking. -
setStrategyInfo(uint16 strategyId, address factory, string description)
Register a strategy with its factory and metadata. -
setGRAIInfo(uint32 endpointId, address grai, string description)
Register a GRAI token for a specific LayerZero endpoint.
Token Coherence is a metric used in the Registry contract to quantify how well-connected a token is within the oracle graph of the GrindURUS protocol.
Each token is either a quote token or base token in an oracle pair. A token's coherence is defined as:
coherence(token) = number of oracle connections (excluding self-pairs)
For example, if token A has oracles with B, C, and D, then:
coherence(A) = 3 (assuming A โ B, C, D)
-
getOracle(address quoteToken, address baseToken)
Get oracle for a given token pair. ReturnsPriceOracleSelfifquote == base. -
hasOracle(address quoteToken, address baseToken)
Returnstrueif oracle exists between the given pair.
-
getQuoteTokens()
Returns the list of all known quote tokens. -
getBaseTokens()
Returns the list of all known base tokens. -
getQuoteTokensBy(uint256[] quoteTokenIds)
Returns selected quote tokens by index. -
getBaseTokensBy(uint256[] baseTokenIds)
Returns selected base tokens by index.
-
getStrategyInfosBy(uint16[] strategyIds)
Batch query forStrategyInfoby IDs. -
getGRAIInfosBy(uint32[] endpointIds)
Batch query forGRAIInfoby endpoint IDs.
GRAI is the utility token of the GrindURUS protocol, burned when a grind is executed via GrinderAI. It is implemented as an Omnichain Fungible Token (OFT) using LayerZero and supports cross-chain usage.
setMultiplierNumerator(uint256)โ Sets the multiplier for LayerZero fee estimation.setNativeBridgeFee(uint256)โ Sets additional LayerZero bridge fee percentage.setPeer(uint32, bytes32)โ Registers peer endpoint for cross-chain messaging.mint(address, uint256)โ Mints GRAI tokens when grinds are purchased.
GRAI uses LayerZero infrastructure for bridging. ๐
- Earn Estimation of Fee ๐งฎ
function getTotalFeesForBridgeTo(uint32 dstChainId, bytes32 toAddress, uint256 amount) external view returns (uint256 nativeFee, uint256 nativeBridgeFee, uint256 totalNativeFee);- This function calculates the total fees required for bridging, including native fees and bridge fees. ๐ต
- Call
bridgeToFunction ๐ Use thebridgeTofunction with the valuetotalNativeFeeobtained in step 1:
function bridgeTo(uint32 dstChainId, bytes32 toAddress, uint256 amount) external payable;Parameters:
dstChainId: Defined ingraiInfoson theRegistry. ๐toAddress: Encoded as abytes32address of the receiver. The peer is stored as abytes32to support non-EVM chains. ๐ฌamount: The amount of GRAI to bridge. ๐ช
GrinderAI is the autonomous agent contract for the GrindURUS protocol. It enables gas-efficient, transparent automation of grind operations on strategy pools using the grAI utility token. It supports minting, payment processing, GRAI token management, and simulation of operations on pools.
setRatePerGRAI(token, rate)โ Set price pergrAIfor a token.
setLzReceivOptions(endpointId, gasLimit, value)โ Set LayerZero options.setMultiplierNumerator(n)โ Adjust gas multiplier for fees.setArtificialFeeNumerator(endpointId, n)โ Set additional bridge fee.setPeer(eid, peer)โ Set remote peer for OFT sync.
mint(token, amount)โ MintgrAIto sender.mintTo(token, to, amount)โ MintgrAIto another user.- ETH or tokens are accepted depending on
ratePerGRAI.
grind(poolId)โ Executes macro+micro grind on a pool.grindOp(poolId, op)โ Executes a specific operation (buy,sell, etc).batchGrind(poolIds[])โ Batch of grind pools.batchGrindOp(poolIds[], ops[])โ Batch of granular grind ops.microOp(poolId, op)/macroOp(poolId, op)โ Simulate operations.
calcPayment(token, amount)โ Get payment needed to mintgrAI.getIntentOf(account)โ Return how many grinds the user has and pool ownership.isPaymentToken(token)โ Check if token is valid for payment.owner()โ Get dynamic owner (forwarded fromPoolsNFT).
When ETH is received: all ETH go to owner
Initialize firstly .env
$ cp .env.example .env$ forge build --sizes$ forge testThe deployment is implemented in scripts and handled by foundry framework.
$ forge script script/DeployArbitrum.s.sol:DeployArbitrumScriptApply .env
$ source .env$ forge script script/DeployArbitrum.s.sol:DeployArbitrumScript --slow --broadcast --verify --verifier-url "https://api.arbiscan.io/api" --etherscan-api-key $ARBITRUMSCAN_API_KEY