RAY API

Use our RAY API for convenient access to the RAY smart contracts.

Getting Started

You'll need an API Key to get started.

RAY Interactions

For each of the endpoints in this section, you will submit a POST request and receive a transaction object in return. Sign the transaction object and submit it to Ethereum to complete the desired action.

Transaction Object Schema

Field

Description

Type

from

Address signing the transaction

String

to

Target contract address

String

gas

Estimated upper-bound of gas consumption

Number

gasPrice

Estimated gas price in GWei

String (HEX formatted)

value

Ether to send with transaction in Wei

String (HEX formatted)

post
Grant ERC-20 Allowance

https://ray.staked.cloud/api/v1/account/:address/allowance
Allow RAY to access your token balance by approving our smart contracts.
Request
Response
Request
Path Parameters
address
required
string
Ethereum address with token balance.
Query Parameters
api_key
required
string
Your API key
Body Parameters
amount
required
string
Amount in Wei, pass -1 for max. allowance
coin
required
string
Ticker of coin being granted allowance for. ETH, DAI, or USDC
Response
200: OK
Transaction object to sign and submit to the Ethereum chain.
// USDC Example
{
"success": true,
"response": {
"from": "",
"to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"gas": 100000,
"gasPrice": "1550000000",
"value": 0,
"chainId": 1,
"data": "0x095ea7b300000000000000000000000006a5bf70bff314177488864fe03576ff608e6aec0000000000000000000000000000000000000000000000000000000000000064"
}
}

post
Mint a RAY Token

https://ray.staked.cloud/api/v1/account/:address/purchase
Minting transfers assets into the system whose ownership is represented by a RAY token.
Request
Response
Request
Path Parameters
address
required
string
Ethereum address to establish a RAY token position.
Query Parameters
api_key
required
string
Your API key
Body Parameters
portfolio
required
array
Array of strings of that indicate the opportunities to rebalance between. See below for details
coin
required
string
Ticker of coin to deposit. ETH, DAI, or USDC
amount
required
string
Amount in Wei
Response
200: OK
Transaction object to sign and submit to the Ethereum chain.
// DAI Example
{
"success": true,
"response": {
"from": "",
"to": "0x06a5Bf70BfF314177488864Fe03576ff608e6aec",
"gas": 1000000,
"gasPrice": "1450000000",
"value": "0x0",
"chainId": 1,
"data": "0x7ed9db59d33be800bb630e1ae95562a75be01b1b77a96386f99b3faa97a828b28c92dbb90000000000000000000000001af0f13e5d1b593d4eec276b7cce4c375dbd9af50000000000000000000000000000000000000000000000000000000000000001"
}
}

RAY does not support all possible combinations of opportunities with rebalancing calls and oracle monitoring. Selecting opportunities associated with the RAY V2 tokens is recommended.

RAY Token

Underlying Deposit Token

Portfolio Opportunities

RAY ETH

ETH

["compound", "dydx", "aave", "bzx"]

RAY DAI

DAI

["compound", "dydx", "aave", "dsr", "bzx"]

RAY USDC

USDC

["compound", "dydx", "aave", "bzx"]

bzx is disabled

put
Redeem Funds

https://ray.staked.cloud/api/v1/account/:address/token/:tokenID/withdraw
Redeem funds from an existing RAY token.
Request
Response
Request
Path Parameters
tokenID
required
string
RAY token contract address.
address
required
string
Ethereum address which owns existing RAY token
Query Parameters
api_key
required
string
Your API key
Body Parameters
amount
required
string
Amount in Wei to withdraw, pass -1 to max withdraw
Response
200: OK
Transaction object to sign and submit to the Ethereum chain.
// DAI Example
{
"success": true,
"response": {
"from": "",
"to": "0x06a5Bf70BfF314177488864Fe03576ff608e6aec",
"gas": 3000000,
"gasPrice": "12000000000",
"value": 0,
"chainId": 1,
"data": "0x112ad90b1ccd3266e2864c7e9209fe267cea76cb63056782bb480dfb3fb4a86b5c7ef49b0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000d9fd8ae74d33dfc6883c01d2f5fb0dcb82384854"
}
}

RAY Portfolios

Each RAY token is associated with a portfolio. These portfolios define the opportunities between which a RAY token rebalances between.

RAY Token

Portfolio Identifier

RAY ETH

0xda7bfa5022265a9af7a95bf987e0ab3676a73bf83db817cd7c7793569054fff4

RAY DAI

0xf718ab6dc6da441acdc78107a8d317bc03e73837f54f725bd6f6ddd204ddd170

RAY USDC

0xaf145a0288e9599b7c20a388e502db1bec31609e0e8e125a89be848ce2858fa2

get
Get Portfolio Details

https://ray.staked.cloud/api/v1/portfolio/:portfolioID
Get the details of a specific portfolio, including its yield, current allocation, and allocation history.
Request
Response
Request
Path Parameters
portfolioID
required
string
Identifier of the portfolio
Query Parameters
api_key
required
string
Your API key
Response
200: OK
Example response for a DAI portfolio
{
"success": true,
"response": {
"apr": 0.07547270655447004,
"apy": 0.07839379283431946,
"br": 0.07371,
"alpha": "0",
"currentAllocation": [
{
"opportunity": "bzx",
"supplied": "0"
},
{
"opportunity": "dydx",
"supplied": "291457543064985917336007"
},
{
"opportunity": "compound",
"supplied": "80962172777046182"
}
],
"historicalAllocation": [
{
"timestamp": 1568131266,
"allocation": [
{
"opportunity": "compound",
"balance": "0"
},
{
"opportunity": "bzx",
"balance": "0"
},
{
"opportunity": "dydx",
"balance": "0"
}
]
},
...
],
"opportunities": [
{
"opportunity": "bzx",
"apr": 0.07327350192778904
},
{
"opportunity": "compound",
"apr": 0.0737150535097632
},
{
"opportunity": "dydx",
"apr": 0.07547270704271752
}
]
}
}

get
Get Portfolio Allocation

https://ray.staked.cloud/api/v1/portfolio/:portfolioID/allocation
Get the current allocation of a specific portfolio.
Request
Response
Request
Path Parameters
portfolioID
required
string
Identifier of the portfolio
Query Parameters
api_key
required
string
Your API key
Response
200: OK
Example for a DAI portfolio.
{
"success": true,
"response": {
"allocation": [
{
"opportunity": "bzx",
"supplied": "0"
},
{
"opportunity": "dydx",
"supplied": "291457543064985917336007"
},
{
"opportunity": "compound",
"supplied": "80962172777046182"
}
],
"totalSupplied": "2.91457624027158694382189e+23",
"oppsArr": [
{
"uuid": "0xe785c07d1af961a43565f21ea1241b8ef0a4517d58e02edba14d331f602d3300",
"protocol": "compound",
"principalType": "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359",
"principalSymbol": "DAI",
"principalAmount": "-1",
"collateralType": "-1",
"collateralSymbol": "-1",
"collateralAmount": -1,
"startTime": 0,
"termLength": 0,
"withdrawalTime": 0,
"interestRate": 0.0737183872202688,
"details": "N/A",
"exists": 1,
"type": "0x87e3990b15e1e64e3a17b0e4ebfcc4c03cc5ec64a33b442ae01ef15d9dadb575"
},
{
"uuid": "0x614df4ef2be00a4aba5275ce620953d072a8fdc0d3b9e119db84ffc491900650",
"protocol": "bzx",
"principalType": "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359",
"principalSymbol": "DAI",
"principalAmount": "-1",
"collateralType": "-1",
"collateralSymbol": "-1",
"collateralAmount": -1,
"startTime": 0,
"termLength": 0,
"withdrawalTime": 0,
"interestRate": 0.07323099722520827,
"details": "N/A",
"exists": 1,
"type": "0x87e3990b15e1e64e3a17b0e4ebfcc4c03cc5ec64a33b442ae01ef15d9dadb575"
},
{
"uuid": "0x7c2e891cac5d0f53d36b49385a3f997174e5a30a6505488d89010999675cf701",
"protocol": "dydx",
"principalType": "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359",
"principalSymbol": "DAI",
"principalAmount": "-1",
"collateralType": "-1",
"collateralSymbol": "-1",
"collateralAmount": 1.15,
"startTime": 0,
"termLength": 0,
"withdrawalTime": 0,
"interestRate": 0.07547250346247361,
"details": "N/A",
"exists": 1,
"type": "0x87e3990b15e1e64e3a17b0e4ebfcc4c03cc5ec64a33b442ae01ef15d9dadb575"
}
]
}
}

RAY Reporting

RAY Reporting methods detail the holdings of an Ethereum address. Each response contains high-level information along with the RAY tokens owned by the address.

RAY Token (v2) Object Schema

Field

Description

Type

uuid

RAY token contract address

String

capital

Deposit amount (in decimals of underlying token)

Number

type

Portfolio identifier of the RAY token

String

principal

Deposit token name

String

purchaseTime

Unix timestamp of deposit

Number

valueFlow

Array of objects that describe interactions with the RAY token

Array

interestEarnt

Total amount of interest earned by depositor

String

tokenValue

Amount of underlying redeemable by depositor

String

get
Get Tokens Associated with Address

https://ray.staked.cloud/api/v1/account/:address
Get the RAY tokens and account details associated with an Ethereum address.
Request
Response
Request
Path Parameters
address
required
string
Ethereum address to fetch RAY tokens for.
Query Parameters
api_key
required
string
Your API key
Response
200: OK
Account details successfully retrieved.
{
"success": true,
"response": {
"uuid": "Wallet address",
"eth": "amount of ETH",
"dai": "amount of DAI",
"usdc": "amount of USDC",
"tokens": [
...
{
"uuid": "RAY Token ID",
"capital": 0,
"expiryTime": 0,
"termLength": 0,
"type": "Portfolio ID",
"principal": "Asset Name (ETH,DAI,USDC)",
"purchaseTime": 1568082355,
"valueFlow": [
{
"deposit": true,
"amount": "100000000000000000",
"timestamp": 1568082355,
"tokenValue": "0"
}
],
"interestEarnt": "30151599",
"tokenValue": "618384483737",
"tokenAllowance": "6515179647075"
}
...
],
"burntTokens": [
...
{
"uuid": "RAY Token ID",
"capital": 0,
"expiryTime": 0,
"termLength": 0,
"type": "Portfolio ID",
"principal": "USDC",
"purchaseTime": 1568479611,
"valueFlow": [
{
"deposit": true,
"amount": "100000",
"timestamp": 1568479611,
"tokenValue": "0"
},
{
"deposit": false,
"amount": "100017",
"timestamp": 1568579882,
"tokenValue": "100017"
}
],
"interestEarnt": "17",
"tokenValue": "100017",
"tokenAllowance": "14"
}
...
]
}
}

get
Get Details of a Specific RAY Token

https://ray.staked.cloud/api/v1/account/:address/token/:tokenID
Get the details of an Ethereum address with regards to a specific RAY token.
Request
Response
Request
Path Parameters
tokenID
required
string
RAY token contract address
address
required
string
Target Ethereum address
Query Parameters
api_key
required
string
Your API key
Response
200: OK
{
"success": true,
"response": {
"uuid": "Wallet address",
"capital": 0,
"expiryTime": 0,
"termLength": 0,
"type": "Portfolio ID",
"principal": "ETH",
"purchaseTime": 1568082355,
"valueFlow": [
{
"deposit": true,
"amount": "100000000000000000",
"timestamp": 1568082355,
"tokenValue": "0"
},
{
"deposit": false,
"amount": "100000000000000007",
"timestamp": 1568302631,
"tokenValue": "100000618358155789"
}
],
"interestEarnt": "31014805",
"tokenValue": "618385346943",
"annualizedRate": "0.15"
"tokenAllowance": "6515180014704"
}
}