Marketplace.sol
This document describes the functions, attributes and modifiers in MarketPlace.sol
MarketPlace
Author: Sourabh Marathe, Julian Traversa, Rob Robbins
This contract is in charge of managing the available principals for each loan market.
In addition, this contract routes swap orders between Illuminate PTs and their respective underlying to YieldSpace pools.
State Variables
markets
markets are defined by a tuple that points to a fixed length array of principal token addresses.
pools
pools map markets to their respective YieldSpace pools for the MetaPrincipal token
admin
address that is allowed to create markets, set pools, etc. It is commonly used in the authorized modifier.
redeemer
address of the deployed redeemer contract
lender
address of the deployed lender contract
creator
address of the deployed creator contract
Functions
authorized
ensures that only a certain address can call the function
Parameters
constructor
initializes the MarketPlace contract
Parameters
createMarket
creates a new market for the given underlying token and maturity
Parameters
Returns
setPrincipal
allows the admin to set an individual market
Parameters
Returns
setAdmin
sets the admin address
Parameters
Returns
setPool
sets the address for a pool
Parameters
Returns
sellPrincipalToken
sells the PT for the underlying via the pool
Parameters
Returns
buyPrincipalToken
buys the PT for the underlying via the pool
determines how many underlying to sell by using the preview
Parameters
Returns
sellUnderlying
sells the underlying for the PT via the pool
Parameters
Returns
buyUnderlying
buys the underlying for the PT via the pool
determines how many PTs to sell by using the preview
Parameters
Returns
mint
mint liquidity tokens in exchange for adding underlying and PT
amount of liquidity tokens to mint is calculated from the amount of unaccounted for PT in this contract.
A proportional amount of underlying tokens need to be present in this contract, also unaccounted for.
Parameters
Returns
mintWithUnderlying
Mint liquidity tokens in exchange for adding only underlying
amount of liquidity tokens is calculated from the amount of PT to buy from the pool, plus the amount of unaccounted for PT in this contract.
Parameters
Returns
burn
burn liquidity tokens in exchange for underlying and PT.
Parameters
Returns
burnForUnderlying
burn liquidity tokens in exchange for underlying.
Parameters
Returns
batch
Allows batched call to self (this contract).
Parameters
Events
CreateMarket
emitted upon the creation of a new market
SetPrincipal
emitted upon setting a principal token
Swap
emitted upon swapping with the pool
Mint
emitted upon minting tokens with the pool
Burn
emitted upon burning tokens with the pool
SetAdmin
emitted upon changing the admin
SetPool
emitted upon setting a pool
Enums
Principals
the available principals
the order of this enum is used to select principals from the markets mapping (e.g. Illuminate => 0, Swivel => 1, and so on)
Last updated