Marketplace.sol
This document describes the functions, attributes and modifiers in MarketPlace.sol
Last updated
This document describes the functions, attributes and modifiers in MarketPlace.sol
Last updated
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.
markets are defined by a tuple that points to a fixed length array of principal token addresses.
pools map markets to their respective YieldSpace pools for the MetaPrincipal token
address that is allowed to create markets, set pools, etc. It is commonly used in the authorized modifier.
address of the deployed redeemer contract
address of the deployed lender contract
address of the deployed creator contract
ensures that only a certain address can call the function
Parameters
a
address
address that msg.sender must be to be authorized
initializes the MarketPlace contract
Parameters
r
address
address of the deployed redeemer contract
l
address
address of the deployed lender contract
c
address
address of the deployed creator contract
creates a new market for the given underlying token and maturity
Parameters
u
address
address of an underlying asset
m
uint256
maturity (timestamp) of the market
t
address[8]
principal token addresses for this market
n
string
name for the Illuminate token
s
string
symbol for the Illuminate token
a
address
address of the APWine router that corresponds to this market
e
address
address of the Element vault that corresponds to this market
h
address
address of a helper contract, used for Sense approvals if active in the market
sensePeriphery
address
address of the Sense periphery contract that must be approved by the lender
Returns
<none>
bool
bool true if successful
allows the admin to set an individual market
Parameters
p
uint8
principal value according to the MarketPlace's Principals Enum
u
address
address of an underlying asset
m
uint256
maturity (timestamp) of the market
a
address
address of the new principal token
h
address
a supplementary address (apwine needs a router, element needs a vault, sense needs interest bearing asset)
sensePeriphery
address
address of the Sense periphery contract that must be approved by the lender
Returns
<none>
bool
bool true if the principal set, false otherwise
sets the admin address
Parameters
a
address
Address of a new admin
Returns
<none>
bool
bool true if the admin set, false otherwise
sets the address for a pool
Parameters
u
address
address of an underlying asset
m
uint256
maturity (timestamp) of the market
a
address
address of the pool
Returns
<none>
bool
bool true if the pool set, false otherwise
sells the PT for the underlying via the pool
Parameters
u
address
address of an underlying asset
m
uint256
maturity (timestamp) of the market
a
uint128
amount of PTs to sell
s
uint128
slippage cap, minimum amount of underlying that must be received
Returns
<none>
uint128
uint128 amount of underlying bought
buys the PT for the underlying via the pool
determines how many underlying to sell by using the preview
Parameters
u
address
address of an underlying asset
m
uint256
maturity (timestamp) of the market
a
uint128
amount of PTs to be purchased
s
uint128
slippage cap, maximum number of underlying that can be sold
Returns
<none>
uint128
uint128 amount of underlying sold
sells the underlying for the PT via the pool
Parameters
u
address
address of an underlying asset
m
uint256
maturity (timestamp) of the market
a
uint128
amount of underlying to sell
s
uint128
slippage cap, minimum number of PTs that must be received
Returns
<none>
uint128
uint128 amount of PT purchased
buys the underlying for the PT via the pool
determines how many PTs to sell by using the preview
Parameters
u
address
address of an underlying asset
m
uint256
maturity (timestamp) of the market
a
uint128
amount of underlying to be purchased
s
uint128
slippage cap, maximum number of PTs that can be sold
Returns
<none>
uint128
uint128 amount of PTs sold
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
u
address
the address of the underlying token
m
uint256
the maturity of the principal token
b
uint256
number of base tokens
p
uint256
the principal token amount being sent
minRatio
uint256
minimum ratio of LP tokens to PT in the pool.
maxRatio
uint256
maximum ratio of LP tokens to PT in the pool.
Returns
<none>
uint256
uint256 number of base tokens passed to the method
<none>
uint256
uint256 number of yield tokens passed to the method
<none>
uint256
uint256 the amount of tokens minted.
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
u
address
the address of the underlying token
m
uint256
the maturity of the principal token
a
uint256
the underlying amount being sent
p
uint256
amount of PT
being bought in the Pool, from this we calculate how much underlying it will be taken in.
minRatio
uint256
minimum ratio of LP tokens to PT in the pool.
maxRatio
uint256
maximum ratio of LP tokens to PT in the pool.
Returns
<none>
uint256
uint256 number of base tokens passed to the method
<none>
uint256
uint256 number of yield tokens passed to the method
<none>
uint256
uint256 the amount of tokens minted.
burn liquidity tokens in exchange for underlying and PT.
Parameters
u
address
the address of the underlying token
m
uint256
the maturity of the principal token
a
uint256
the amount of liquidity tokens to burn
minRatio
uint256
minimum ratio of LP tokens to PT in the pool
maxRatio
uint256
maximum ratio of LP tokens to PT in the pool
Returns
<none>
uint256
uint256 amount of LP tokens burned
<none>
uint256
uint256 amount of base tokens received
<none>
uint256
uint256 amount of fyTokens received
burn liquidity tokens in exchange for underlying.
Parameters
u
address
the address of the underlying token
m
uint256
the maturity of the principal token
a
uint256
the amount of liquidity tokens to burn
minRatio
uint256
minimum ratio of LP tokens to PT in the pool.
maxRatio
uint256
minimum ratio of LP tokens to PT in the pool.
Returns
<none>
uint256
uint256 amount of PT tokens sent to the pool
<none>
uint256
uint256 amount of underlying tokens returned
Allows batched call to self (this contract).
Parameters
c
bytes[]
An array of inputs for each call.
emitted upon the creation of a new market
emitted upon setting a principal token
emitted upon swapping with the pool
emitted upon minting tokens with the pool
emitted upon burning tokens with the pool
emitted upon changing the admin
emitted upon setting a pool
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)