Robo-Advisor for Yield (RAY) is a decentralized investment tool that re-balances funds to the highest yielding opportunities.
Users deposit funds into the RAY smart contract, customize which Opportunities should be considered, and an off-chain oracle monitors rates on eligible protocols. RAY automatically moves funds to the highest-yielding at option at any time. Users receive an ERC-721 token representing the value of positions they own.
This subgraph tracks all opportunities, users and RAY tokens and all the activities of users such as minting, depositing, withdrawing. and burning to Ray Contract. Subgraph is deployed here https://thegraph.com/explorer/subgraph/nanspro/ray, you can run queries there and also use the apis in your dapp. There is one demo dapp which can be found here: http://nanspro.github.io/
yarn install
yarn codegen
yarn deploy
The subgraph can be queried using graphQL queries and the endpoint for that is https://api.thegraph.com/subgraphs/name/nanspro/ray, you can read more about ray protocol's working and their smart contract functionality here https://staked.gitbook.io/staked/ray/smart-contract-integration
The following entities are present in this subgraph, below are few example queries that can be made on them
User
You can query our subgraph to obtain list of all users who have postions on ray protocol.
{
users {
id
address
portfolioId
tokenValue
}
}
id
: Ray Token id of that useraddress
: Ethereum address of the owner of ray token with idportfolioId
: The corresponding id for the basket of opportunities to associate with this RAY tokentokenValue
: The value of this RAY tokentokenAddr
: Address of token which is deposited by userisERC20
: Whether user has deposited a ERC20 token or not(deposited ETH)
RayToken
You can query our subgraph to obtain list of all ray tokens present on ray protocol.
{
rayTokens {
id
owner {
id
# can specify any or all user's attributes shown above
}
}
}
id
: Ray Token idowner
: User entity which tells us about the user who owns this ray token
Opportunity
You can query our subgraph to obtain list of all opportunities created on ray protocol.
{
opportunities{
id
opportunityTokenId
portfolioId
}
}
id
: Unique identifierportfolioId
: The corresponding id for the basket of opportunities associated with this RAY tokenopportunityTokenId
: It is generated when portfolio lends to a opportunityId
Mint
When user mints a new ray token by creating a postion on ray smart contract.
{
rayMints{
id
value
rayTokenId
owner
portfolioId
}
}
id
: Unique identifiervalue
: The amount in the smallest units of the asset that were credited to the minted RAY tokenThe amount in the smallest units of the asset that were credited to the minted RAY tokenrayTokenId
: The token id of newly generated ERC721 ray tokenowner
: User who crated this mint(owner of this new minted ray token)
Deposit
Users can add additional value to an existing RAY token through the deposit function.
{
rayDeposits{
id
value
rayTokenId
previousValue
}
}
id
: Unique identifiervalue
: The amount in the smallest units of the asset that were credited to the minted RAY tokenrayTokenId
: The id of the RAY token the deposit was forpreviousValue
: The token value before the deposit
Withdraw
Withdrawing allows a user to partially or fully withdraw the underlying value from their RAY token.
{
rayWithdraws{
id
valueAfterFee
rayTokenId
totalValue
}
}
id
: Unique identifiervalueAfterFee
: The amount in the smallest units of the asset that was withdrawn from the RAY tokenrayTokenId
: The id of the RAY token the withdrawal was fortotalValue
: The token value before the withdraw
Burn
Burning allows a user to trade in their full RAY token for all the underlying value.
{
rayBurns{
id
value
rayTokenId
owner
worth
}
}
id
: Unique identifiervalue
: The amount transferred to owner after feesrayTokenId
: The id of the RAY token which was burnedworth
: The worth of the ray token which was burned