PrimaryLendingPlatformWrappedTokenGatewayCore

Overview

License: MIT

abstract contract PrimaryLendingPlatformWrappedTokenGatewayCore is Initializable, AccessControlUpgradeable, ReentrancyGuardUpgradeable

Core contract for the Primary Lending Platform Wrapped Token Gateway Core

Abstract contract that defines the core functionality of the primary lending platform wrapped token gateway.

Events info

SetPrimaryLendingPlatform

event SetPrimaryLendingPlatform(address newPrimaryLendingPlatform)

Emitted when the PrimaryLendingPlatform contract address is updated.

Parameters:

NameTypeDescription

newPrimaryLendingPlatform

address

The new address of the PrimaryLendingPlatform contract.

SetPITLiquidation

event SetPITLiquidation(address newPITLiquidation)

Emitted when the PIT liquidation address is set.

SetPITLeverage

event SetPITLeverage(address newPITLeverage)

Emitted when the PIT (Pool Interest Token) leverage is set to a new address.

Parameters:

NameTypeDescription

newPITLeverage

address

The address of the new PIT leverage contract.

Constants info

MODERATOR_ROLE (0x797669c9)

bytes32 constant MODERATOR_ROLE = keccak256("MODERATOR_ROLE")

State variables info

primaryLendingPlatform (0x92641a7c)

contract IPrimaryLendingPlatform primaryLendingPlatform

WETH (0xad5c4648)

contract IWETH WETH

pitLiquidation (0xf8514cae)

contract IPrimaryLendingPlatformLiquidation pitLiquidation

pitLeverage (0x22c7ddee)

contract IPrimaryLendingPlatformLeverage pitLeverage

Modifiers info

onlyAdmin

modifier onlyAdmin()

Modifier that allows only the admin to execute the function.

onlyModerator

modifier onlyModerator()

Modifier that allows only the moderator to execute the function.

isProjectTokenListed

modifier isProjectTokenListed(address projectToken)

Modifier that checks if the project token is listed.

Parameters:

NameTypeDescription

projectToken

address

Address of the project token.

isLendingTokenListed

modifier isLendingTokenListed(address lendingToken)

Modifier that checks if the lending token is listed.

Parameters:

NameTypeDescription

lendingToken

address

Address of the lending token.

Functions info

initialize (0xf8c8765e)

function initialize(
    address pit,
    address weth,
    address pitLiquidationAddress,
    address pitLeverageAddress
) public initializer

Initializes the PrimaryLendingPlatformWrappedTokenGateway contract.

Parameters:

NameTypeDescription

pit

address

Address of the primary index token contract.

weth

address

Address of the wrapped Ether (WETH) token contract.

pitLiquidationAddress

address

Address of the primary index token liquidation contract.

pitLeverageAddress

address

Address of the primary index token leverage contract.

setPrimaryLendingPlatform (0xe801734a)

function setPrimaryLendingPlatform(address newPit) external onlyModerator

Sets the address of the primary lending platform contract.

Requirements:

  • newPit cannot be the zero address.

  • Caller must be a moderator.

Parameters:

NameTypeDescription

newPit

address

The address of the new primary lending platform contract.

setPITLiquidation (0x6ccf9e23)

function setPITLiquidation(address newLiquidation) external onlyModerator

Only the moderator can call this function.

Sets the address of the PrimaryLendingPlatformLiquidation contract for PIT liquidation.

Requirements:

  • newLiquidation cannot be the zero address.

  • Caller must be a moderator.

Parameters:

NameTypeDescription

newLiquidation

address

The address of the new PrimaryLendingPlatformLiquidation contract.

setPITLeverage (0x1a58ed4a)

function setPITLeverage(address newLeverage) external onlyModerator

Sets the Primary Lending Platform Leverage contract address.

Requirements:

  • newLeverage cannot be the zero address.

  • Caller must be a moderator.

Parameters:

NameTypeDescription

newLeverage

address

The address of the new Primary Lending Platform Leverage contract.

getTotalOutstanding (0x75efd575)

function getTotalOutstanding(
    address user,
    address projectToken
) public view returns (uint256 outstanding)

Returns the total outstanding balance of a user for a specific project token.

Parameters:

NameTypeDescription

user

address

The address of the user.

projectToken

address

The address of the project token.

Return values:

NameTypeDescription

outstanding

uint256

The total outstanding balance of the user.

deposit (0xd0e30db0)

function deposit() external payable nonReentrant

Deposits Ether into the PrimaryLendingPlatformWrappedTokenGatewayCore contract and wraps it into WETH.

supply (0x047fc9aa)

function supply() external payable nonReentrant

Allows users to supply ETH to the PrimaryLendingPlatformWrappedTokenGatewayCore contract. The ETH is converted to WETH and then transferred to the user's address. The supplyFromRelatedContract function of the PrimaryLendingPlatform contract is called to supply the WETH to the user.

redeem (0xdb006a75)

function redeem(uint256 bLendingTokenAmount) external nonReentrant

Redeems the specified amount of bLendingToken for the underlying asset (WETH) and transfers it to the caller.

Parameters:

NameTypeDescription

bLendingTokenAmount

uint256

The amount of bLendingToken to redeem. If set to type(uint256).max, redeems all the bLendingToken balance of the caller.

redeemUnderlying (0x852a12e3)

function redeemUnderlying(uint256 lendingTokenAmount) external nonReentrant

Redeems the underlying asset from the Primary Lending Platform and transfers it to the caller.

Parameters:

NameTypeDescription

lendingTokenAmount

uint256

The amount of the lending token to redeem.

repay (0x22867d78)

function repay(
    address projectToken,
    uint256 lendingTokenAmount
) external payable nonReentrant

Repays the specified amount of the project token's Ether outstanding debt using the lending token.

Parameters:

NameTypeDescription

projectToken

address

The address of the project token.

lendingTokenAmount

uint256

The amount of the lending token to be used for repayment.

receive

receive() external payable

Only WETH contract is allowed to transfer ETH here. Prevent other addresses to send Ether to this contract.

fallback

fallback() external payable

Reverts any fallback calls to the contract.

Last updated