My company launched cross-chain farming in 2021. Cross-chain farming is 100% decentralized! We had yet to see anything like this in the DeFi industry, and I am glad, we were the first ones to pull it off.
In a nutshell, users can deposit ETH on the Ethereum mainnet. The deposited ETH will then be used to generate LP tokens on PolyDEX which is on Polygon network. Users will be enrolled in the farm of choice with a single click.
It relies on two types of Polygon - Ethereum bridges:
POS Token Bridge
State Sync mechanism and FxPortals as a Data bridge
POS Token bridge
POS bridge is basically a set of contracts that help in moving assets from the root chain to the child chain. ( From Ethereum to Polygon ) Token contracts on root and child need to be mapped in order to use the POS bridge.
Read more here: https://docs.matic.network/docs/develop/ethereum-matic/pos/getting-started
State Sync Mechanism and FxPortals
This is the mechanism to read the data from the Ethereum on Polygon chain. This bridge also requires mapping of the root and child contracts.
How does it work?
So now that we have got our basics sorted, lets look into exactly how cross chain farming works:
User deposits ETH on the Ethereum main-net in a contract by specifying the details of the farm that user wants to enrol into.
Smart contract processes the provided information and prepares the cross chain farming metadata.
Triggers the POS token bridge to port ETH over to Polygon to be received on CrossChainFarming Intermediator contract.
Triggers FxPortals to move the metadata from Ethereum to Polygon, again to be received on CrossChainFarming Intermediator contract.
After the State Sync event has been processed by the Polygon validators, ETH and metadata both are transferred from Ethereum and received on Polygon.
Intermediator contract decodes the metadata, triggers another smart contract on Polygon which converts ETH to tokens required to add liquidity in corresponding pair and get LP tokens.
After the LP tokens are received, triggers PolyDEX’s core farming contract to deposit LP tokens for the user.
High-level Architecture for Cross chain farming
On PolyDEX Farms, the farm will reflect the non zero stake for users immediately once this process is completed and users will start earning farming rewards.
Do follow the blog for more such interesting and technical concepts in Web3.