ILockedWethSecondaryMarket

Git Source

This contract manages LockedWeth tokens sell orders

Functions

WETH

Returns the WETH contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

POOL_MANAGER_FACTORY

Returns the pool manager factory contract

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

sellOrders

Returns a sell order

function sellOrders(uint256 _orderId)
    external
    view
    returns (ILockManager _lockedWethToken, uint256 _id, uint256 _amount, address _owner, uint16 _discount);

Parameters

NameTypeDescription
_orderIduint256The order id

sellOrdersCount

Returns the sell orders count

function sellOrdersCount() external view returns (uint256 _sellOrdersCount);

Returns

NameTypeDescription
_sellOrdersCountuint256The sell orders count

postOrder

Posts a LockedWeth sell limit order

The amount is represented in WETH tokens The LockedWeth tokens remain in the poster account The discount value must be less than the discount precision

function postOrder(ILockManager _lockedWethToken, uint256 _amount, uint16 _discount) external;

Parameters

NameTypeDescription
_lockedWethTokenILockManagerThe locked WETH
_amountuint256The amount of LockedWeth tokens to be sold
_discountuint16The discount value

buyOrder

Buys a sell order

The sell order is bought with WETH tokens and cannot be purchased partially

function buyOrder(uint256 _orderId) external;

Parameters

NameTypeDescription
_orderIduint256The id of the sell order to be bought

cancelOrder

Cancels a sell order

The caller must be the order owner

function cancelOrder(uint256 _orderId) external;

Parameters

NameTypeDescription
_orderIduint256The id of the order to be canceled

getSellOrders

Returns pagination of the orders posted

Minimum _startFrom is 1; ids start from 1

function getSellOrders(uint256 _startFrom, uint256 _amount) external returns (SellOrder[] memory _sellOrders);

Parameters

NameTypeDescription
_startFromuint256The index from where to start the pagination
_amountuint256The maximum amount of orders to retrieve

Returns

NameTypeDescription
_sellOrdersSellOrder[]The paginated orders posted

Events

SellOrderPosted

Emitted when a new LockedWeth sell order is posted

event SellOrderPosted(SellOrder _order);

SellOrderBought

Emitted when a sell order is bought

event SellOrderBought(SellOrder _order, address _buyer);

SellOrderCancelled

Emitted when a sell order is canceled

event SellOrderCancelled(SellOrder _order);

Errors

LockedWethSecondaryMarket_InvalidPoolManager

Thrown when the pool manager is invalid

error LockedWethSecondaryMarket_InvalidPoolManager(IPoolManager _poolManager);

LockedWethSecondaryMarket_InvalidLockManager

Thrown when the lock manager is invalid

error LockedWethSecondaryMarket_InvalidLockManager(ILockManager _lockManager);

LockedWethSecondaryMarket_ZeroAmount

Thrown when the order amount is zero

error LockedWethSecondaryMarket_ZeroAmount();

LockedWethSecondaryMarket_MaxDiscountExceeded

Thrown when the discount value exceeds the max discount

error LockedWethSecondaryMarket_MaxDiscountExceeded(uint16 _discount, uint16 _maxDiscount);

LockedWethSecondaryMarket_NotOrderOwner

Thrown when trying to delete an order and the caller is not the owner

error LockedWethSecondaryMarket_NotOrderOwner(uint256 _orderId);

LockedWethSecondaryMarket_OrderNotAvailable

Thrown when trying to buy a sell order whose amount is zero

The order could not be available because it was already sold or canceled

error LockedWethSecondaryMarket_OrderNotAvailable(uint256 _orderId);

Structs

SellOrder

The sell order

struct SellOrder {
    ILockManager lockedWethToken;
    uint256 id;
    uint256 amount;
    address owner;
    uint16 discount;
}