PErc20CrossChain

The PErc20CrossChain contract extends the standard PErc20 lending functionality to support cross-chain operations, allowing the authorized PeridotHubHandler to mint and borrow on behalf of users from spoke chains.


🛠️ Key Functions & Parameters

mintFor(address user, uint256 mintAmount)

Mints pTokens for a user on behalf of the hub handler for cross-chain supply operations.

Parameters:

  • user: Address of the user on the hub chain to mint pTokens for

  • mintAmount: Amount of underlying asset being supplied

Process:

  1. Accrues interest to ensure up-to-date calculations

  2. Validates mint is allowed by the Peridottroller

  3. Transfers underlying tokens from hub handler to the pToken contract

  4. Calculates and mints appropriate amount of pTokens for the user

  5. Updates total supply and user's token balance

Access Control: Only callable by the authorized hub handler contract.


borrowFor(address user, uint256 borrowAmount)

Processes borrow requests for users from spoke chains, updating debt and transferring tokens to hub handler.

Parameters:

  • user: Address of the user on the hub chain who is borrowing

  • borrowAmount: Amount of underlying asset to borrow

Process:

  1. Accrues interest to ensure accurate debt calculations

  2. Validates borrow is allowed by the Peridottroller (checks collateral, etc.)

  3. Updates user's borrow balance and total borrows

  4. Transfers borrowed tokens to hub handler for cross-chain delivery

Access Control: Only callable by the authorized hub handler contract.

Last updated