Architecture
Deposit flow
User initiates a deposit by interacting with the Pike protocol on a Spoke chain.
Spoke chain contract creates the required data to send to Hub chain. In parallel mint pToken accordingly to the user’s wallet.
The Gateway contract on the Spoke chain receives the deposit request and forwards it to the HubState contract on the Hub chain via the Wormhole relayer.
HubState verifies the deposit request, ensuring that the user meets the required criteria and that the deposited assets are supported.
Once the deposit is approved, HubState updates the user's collateral balance and reserves the deposited assets for borrowing purposes.
The user's collateral can now be utilized for borrowing on the Spoke chain.
Borrow flow
User submits a borrowing request through the contract on the relevant Spoke chain.
Spoke chain contract creates the required data to send to Hub chain.
The Gateway contract on the Spoke chain receives the borrow request and forwards it to the Hub chain via the Wormhole relayer.
HubState validates the request, checking the user's collateral, borrowing limit, and other parameters.
If the request is valid, the Hub chain sends back a message to Spoke chain via the Wormhole relayer to confirm the borrow.
Spoke chain receives the message to confirm the borrow and sends the asset to the user’s wallet.
The user can now access and utilize the borrowed assets for their intended purposes.
Repay flow
User initiates a loan repayment by interacting with the contract on the Spoke chain.
Spoke chain contract creates the required data to send to Hub chain.
The Gateway contract on the Spoke chain receives the repayment request data and forwards it to the Hub chain via the Wormhole relayer.
The HubState verifies the repayment request, ensuring that the user has sufficient funds and the repayment amount is valid.
Once the repayment is confirmed, the HubState updates the user's borrowing balance, adjusting interest accruals and calculating any remaining outstanding loan amounts.
The user's repayment reduces their borrowing balance and improves their overall loan status.
Withdraw flow
User submits a withdrawal request through the contract on the relevant Spoke chain.
Spoke chain contract creates the required data to send to Hub chain.
The Gateway contract on the Spoke chain receives the withdraw request data and forwards it to the Hub chain via the Wormhole relayer.
HubState validates the request, checking the user's collateral, borrowing limit, and other parameters.
If the request is valid, the Hub chain sends back a message to Spoke chain via the Wormhole relayer to confirm the withdrawal.
Spoke chain receives the message to confirm the withdrawal, sends the asset to the user’s wallet, and burns pToken accordingly.
The user can now access and utilize the assets for their intended purposes.
Liquidation flow
In the case of a borrower's default or failure to meet loan obligations, the liquidation bot can trigger the liquidation from the contract on the relevant Spoke chain.
Spoke contract creates and encodes the message payload for sending to Hub chain.
Gateway contract on the Spoke chain receives the liquidation request and forwards it to the Hub chain via the Wormhole relayer.
Hub contract validates the request, performs needed checks, calculates the reward amount for a liquidator and updates the global state.
Hub contract creates, encodes and sends back the confirmation message to Spoke chain.
Spoke chain receives the message, performs needed checks and sends the liquidation reward to the wallet address which had initiated the liquidation.
Last updated