PrimaryLendingPlatformLeverageZksync
Overview
License: MIT
The PrimaryLendingPlatformLeverageZksync contract is the contract that allows users to open leveraged positions for zksync network.
Contract that allows users to open leveraged positions using the OpenOcean exchange aggregator. Inherit from PrimaryLendingPlatformLeverageCore.
Functions info
leveragedBorrow (0x40b5aa8d)
The function to be called when a user wants to leverage their position.
Executes a leveraged borrow for the borrower on the specified projectToken using the given lendingToken and update related token's prices.
Requirements:
The project token is listed on the platform.
The lending token is listed on the platform.
Notional exposure must be greater than 0.
The lending token must be the same as the current lending token or the current lending token must be address(0).
The user must have a valid position for the given project token and lending token.
Effects:
Update price of related tokens.
Calculates the required
lendingTokenCount
based onnotionalExposure
.Performs a naked borrow using
_nakedBorrow
function.Approves the transfer of
lendingToken
to the system.Buys tokens on an exchange aggregator using
_buyOnExchangeAggregator
function.Collateralizes the loan with the received tokens using
_collateralizeLoan
function.Defers liquidity check using
_deferLiquidityCheck
function.Sets the leveraged position flag and type for the borrower.
Parameters:
leveragedBorrowFromRelatedContract (0xb21cacd5)
Allows a related contract to borrow funds on behalf of a user to enter a leveraged position and update related token's prices.
Requirements:
Caller must be a related contract.
The project token is listed on the platform.
The lending token is listed on the platform.
Notional exposure must be greater than 0.
The lending token must be the same as the current lending token or the current lending token must be address(0).
The user must have a valid position for the given project token and lending token.
Effects:
Update price of related tokens.
Calculates the required
lendingTokenCount
based onnotionalExposure
.Performs a naked borrow using
_nakedBorrow
function.Approves the transfer of
lendingToken
to the system.Buys tokens on an exchange aggregator using
_buyOnExchangeAggregator
function.Collateralizes the loan with the received tokens using
_collateralizeLoan
function.Defers liquidity check using
_deferLiquidityCheck
function.Sets the leveraged position flag and type for the borrower.
Parameters:
calculateLendingTokenCountWithUpdatePrices (0xff7e86fa)
Calculates the lending token count for a given notional value after updating related token's prices.
Parameters:
Return values:
Last updated