PeridotSpoke
The PeridotSpoke contract enables users on spoke chains to interact with the Peridot protocol on the hub chain, handling cross-chain supply and borrow operations through Axelar GMP.
🛠️ Key Functions & Parameters
✅ supplyToPeridot(string calldata assetSymbol, uint256 amount) payable
Allows users to supply assets to the hub chain lending pools from a spoke chain.
Parameters:
assetSymbol
: Symbol of the asset to supply (e.g., "USDC", "WETH")amount
: Amount of the asset to supplymsg.value
: Native gas payment for cross-chain execution
Process:
Transfers tokens from user to the spoke contract
Pays gas for cross-chain execution via Axelar Gas Service
Sends tokens and user data to hub via Axelar Gateway
Hub mints pTokens for the user on the hub chain
✅ borrowFromPeridot(address pTokenAddress, uint256 borrowAmount) payable
Enables users to borrow assets from hub chain pools, receiving them on the spoke chain.
Parameters:
pTokenAddress
: Address of the pToken contract on the hub chain to borrow fromborrowAmount
: Amount of underlying asset to borrowmsg.value
: Native gas payment for cross-chain execution
Process:
Pays gas for cross-chain message execution
Sends borrow request to hub handler
Hub processes borrow and sends tokens back to user on spoke chain
✅ _executeWithToken(bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes calldata payload, string calldata tokenSymbol, uint256 amount)
Receives borrowed tokens sent back from the hub chain.
Parameters:
sourceChain
: Should match the configured hub chain namesourceAddress
: Should match the configured hub contract addresspayload
: Contains the user address who should receive the tokenstokenSymbol
: Symbol of the borrowed tokenamount
: Amount of tokens being received
Process:
Validates message comes from the authorized hub contract
Transfers received tokens to the specified user
Emits event for monitoring
Last updated