RAY API

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

Getting Started

The RAY API currently points to v1 of the RAY smart contracts. An update for v2 will be released soon.

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.

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 an ERC-721 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 the lending protocols to rebalance between. Ex: ["dydx", "compound"]
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"
}
}

put
Deposit Into Existing RAY Token

https://ray.staked.cloud/api/v1/account/:address/token/:tokenID/deposit
Add funds to an existing RAY token.
Request
Response
Request
Path Parameters
tokenID
required
string
Identifier of the existing RAY token to deposit funds into. You can retrieve this from the reporting methods.
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 deposit
Response
200: OK
Transaction object to sign and submit to Ethereum chain.
// DAI Example
{
"success": true,
"response": {
"from": "",
"to": "0x06a5Bf70BfF314177488864Fe03576ff608e6aec",
"gas": 1000000,
"gasPrice": "1450000000",
"value": "0x1",
"chainId": 1,
"data": "0x1de26e161ccd3266e2864c7e9209fe267cea76cb63056782bb480dfb3fb4a86b5c7ef49b0000000000000000000000000000000000000000000000000000000000000001"
}
}

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
Identifier of existing RAY token to withdraw tokens from. You can retrieve this from the reporting methods.
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 withdraw all funds
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 Portfolio Data

The RAY portfolio endpoints give you information on the yield and allocations of specific portfolios.

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
ID of the portfolio to get details for.
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
ID of the portfolio to get details for.
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

Our RAY Reporting methods allow you to track the holdings of an Ethereum address.

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 a specific RAY token.
Request
Response
Request
Path Parameters
tokenID
required
string
Token ID of RAY token to fetch.
address
required
string
Ethereum address to fetch RAY tokens for.
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",
"tokenAllowance": "6515180014704"
}
}