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 supply

  • msg.value: Native gas payment for cross-chain execution

Process:

  1. Transfers tokens from user to the spoke contract

  2. Pays gas for cross-chain execution via Axelar Gas Service

  3. Sends tokens and user data to hub via Axelar Gateway

  4. 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 from

  • borrowAmount: Amount of underlying asset to borrow

  • msg.value: Native gas payment for cross-chain execution

Process:

  1. Pays gas for cross-chain message execution

  2. Sends borrow request to hub handler

  3. 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 name

  • sourceAddress: Should match the configured hub contract address

  • payload: Contains the user address who should receive the tokens

  • tokenSymbol: Symbol of the borrowed token

  • amount: Amount of tokens being received

Process:

  1. Validates message comes from the authorized hub contract

  2. Transfers received tokens to the specified user

  3. Emits event for monitoring

Last updated