-
Notifications
You must be signed in to change notification settings - Fork 15
Developers
Please join our Telegram for the Staked community here. Our team looks forward to answering any questions you may have. Feel free to make suggestions for greater clarity or better functionality.
For a prettier interface please visit here
Table of Contents:
-
PortfolioManager
: User entry-point to interact with the product (deposit or withdraw). Deposits are held here before theOracle
lends them. -
NAVCalculator
: Contains functions around calculating the Net Asset Value of RAY portfolios and opportunities, and the value of unique RAY Tokens.
Governance
-
Admin
: Contract that has permissioned access to change settings in the system - currently only able to be accessed by a wallet controlled by Staked.
Token Contracts
-
RAY Token
: Token that represents user positions in RAY. -
Opportunity Token
: Tokenize positions in Opportunities, currently only used internally.
Opportunity Contracts
-
BzxOpportunity
: Proxy to interact with Fulcrum (bZx) -
CompoundOpportunity
: Proxy to interact with Compound V2 -
DydxOpportunity
: Proxy to interact with dYdX V2
The RAY interface smart contract contains all relevant functions.
Location:
Reference this call to the deployed PortfolioManager.sol
Definition:
The mint
function allows users to transfer assets to the RAY system and create a new position.
Function Signature:
function mint(bytes32 portfolioId, address beneficiary, uint value) external payable returns(bytes32)
Parameters:
-
msg.sender
: The account that will supply the asset -
portfolioId
: The corresponding id for the basket of opportunities to associate with this RAY token -
beneficiary
: The account that will own the RAY token -
value
: The amount in the smallest units of the asset, to deposit
Returns:
The unique identifier of the newly minted RAY token
Note:
For ERC20 tokens, the funder (msg.sender
) must first approve PortfolioManager
to access their assets for the specified value.
Events:
LogMintRAYT(bytes32 indexed tokenId, bytes32 indexed portfolioId, address indexed beneficiary, uint value);
Location:
Reference this call to the deployed PortfolioManager.sol
Definition:
The deposit
function allows a user to transfer assets to the RAY system to increase an existing position's value (adding the value to an existing RAY token).
Function Signature:
function deposit(bytes32 tokenId, uint value) external payable
Parameters:
-
msg.sender
: The account that will supply the asset -
tokenId
: The unique identifier of the RAY token to deposit value into -
value
: The amount in the smallest units of the asset, to deposit
Note:
For ERC20 tokens, the funder (msg.sender
) must first approve PortfolioManager
to access their assets for the specified value.
Events:
LogDepositToRAYT(bytes32 indexed tokenId, uint value, uint tokenValue);
Location:
Reference this call to the deployed PortfolioManager.sol
Definition:
The redeem
function allows a user to trade in their RAY token for the underlying value.
Function Signature:
function redeem(bytes32 tokenId, uint valueToWithdraw, address originalCaller) external returns(uint)
Parameters:
-
msg.sender
: The account that owns the RAY token -
tokenId
: The unique identifier of the RAY token to withdraw value from -
valueToWithdraw
: The amount in the smallest units of the asset, to withdraw -
originalCaller
: Themsg.sender
. (This parameter can be set to anything, only relevant if themsg.sender
is ourGasFunder.sol
smart contract which enables paying gas on user transactions)
Returns:
The value withdrawn after system fees have been taken
Events:
LogWithdrawFromRAYT(bytes32 indexed tokenId, uint value, uint tokenValue);
Location:
Reference this call to the deployed NAVCalculator.sol
Definition:
The getTokenValue
function allows a user to get the current value of their RAY token.
Function Signature:
function getTokenValue(bytes32 portfolioId, bytes32 tokenId) public view returns(uint, uint)
Parameters:
-
portfolioId
: The corresponding id for the basket of opportunities associated with this RAY token -
tokenId
: The unique identifier of the RAY token to get the value of
Returns:
A two index object.
The first index contains the token's current value in-kind. Ex. If the token's principal type is DAI, the value is represented in DAI.
The second index contains the portfolio's current price per share.
These are used for RAY direct contract integration. To dynamically generate these, the template used is as follows:
keccak256({Coin Type Ticker in CamelCase}{Opportunities in Alphabetical Order in CamelCase})
Example: The id of the portfolio that lends ETH to bZx, Compound and dYdX is equal to keccak256(EthBzxCompoundDydx)
or 0xbe72e724d4b9326428f7faca782d2dcc9e3e10824e8cf48a6499f23d695fd018
Note: '0x' needs to be pre-pended, some keccak256
generators don't automatically add that.
Valid Values for Opportunities:
- Bzx
- Compound
- Dydx
Valid Values for Coins:
- Eth
- Dai
- Usdc
Below you'll find the actual values for every portfolio (not added yet)
Coin: ETH
portfolioId
: 0xbe72e724d4b9326428f7faca782d2dcc9e3e10824e8cf48a6499f23d695fd018
Coin: DAI
portfolioId
: 0x87e3990b15e1e64e3a17b0e4ebfcc4c03cc5ec64a33b442ae01ef15d9dadb575
Coin: USDC
portfolioId
: 0x7c80b0e3ce0d2cabe1a3dfc888fca469bab09beccc3496f88cba8613d159a65b
--
Coin: ETH
portfolioId
: 0x89bdc287eca0056552bd2979865efb44e5f19fdc962accefb49f7eefc0e55ea9
Coin: DAI
portfolioId
: 0xe51a4786828f3cbbdd643cd0d415c0f45bdbf7ec739dbdb2e64d6ac97bf103f1
Coin: USDC
portfolioId
: 0x1e868d302424cfebaf2b757c06fdd1a32411fd445ebb51ffc433cc15bacfe3e3
--
Coin: ETH
portfolioId
: 0xe1d9f3a90e5d350eec05cd47282029fcf71c7c09c29c032f198eeffc936975b6
Coin: DAI
portfolioId
: 0xae52c5b4d809b421d746d3a7bde807ea6ec242ae13ae1b2bc6434493acf26d8b
Coin: USDC
portfolioId
: 0x978274153eec4f3c072b45a6268ae86c0e61033c7a817328b407954972369b1d
--
Coin: ETH
portfolioId
: 0xf26c69dbf25f9fb2bf793e4847f7c619cbc3323cb4ff988fb0ce4c5ea45affa1
Coin: DAI
portfolioId
: 0xd33be800bb630e1ae95562a75be01b1b77a96386f99b3faa97a828b28c92dbb9
Coin: USDC
portfolioId
: 0xf904b00f34beab1e77301f192a7fe866c4936fb9ea30e65543df5dc2d9176c69
--
Coin: ETH
portfolioId
: 0x21590982edcc6d2c9b986dd8174fda53c28d1a919c8bf9b58ead7d441b306439
Coin: DAI
portfolioId
: 0x165de3655459c6088f957bdb2877779c94aa17af570340349630726914a826fa
Coin: USDC
portfolioId
: 0xb6cb9e19cd1b048a65dffcccc3a071c8d2d89ad070a0dca6f7efdf4ee7ab9e51
--
Coin: ETH
portfolioId
: 0x5870955881b5219ec3d880e8ad25206c312127210a5695618971c47541982994
Coin: DAI
portfolioId
: 0xcd93cf275bcc8c600887dc587ea0a16e8f0a87fa7f99560f72186069c8d3b3df
Coin: USDC
portfolioId
: 0x839de554365a548fbb6bf9b32952a781e00390bb8454a2bb8f4f3bbed40bc92c
--
Coin: ETH
portfolioId
: 0xa49d129cd260862e8226f232c7d2ab0dd7302e2bcb49847810392625b7dbf3f6
Coin: DAI
portfolioId
: 0xf21acfdd065ab7839f3b0c66c441c6366b2240db1c3fa7c7da134c9be316fcd0
Coin: USDC
portfolioId
: 0x4672ce0a5532a592a953596e6c19fc1cb1bd89cdaf2f6d6b4c71d5f8b6f7f58a