API for investing from Spot Wallet into Earn wallet

Hi everyone,

I am trying to build the following program using python:

  1. Loop through all my assets on the Spot Wallet
    1.1. For each asset, find out if there is an asset available to activate the Flexible Savings
    1.2. For each asset, find out if there is an asset available to buy a Locked Staking
    1.2.1. If more than one asset is available, buy the one with the longest duration (if assets are enough)

  2. Loop through all my assets on the Spot Wallet, Flexible Savings
    2.1. For each asset, find out if there is an asset available to buy a Locked Staking
    2.1.1. If there is an asset, and I have the minimum amount, move asset from Flexible Savings to Spot Wallet. Go to 1.1

I went through the API but I couldn’t really find the the functions I was expecting.
I was expecting some functions that have the coinnames as input and the available flexible/locked savings status as output.
Same with functions like “give me all assets in Spot wallet” or “give me all assets in flexible savings”.

The loops and general functionality of the program is no problem, but I couldnt find a way to retrieve the information I need and to actually “buy” the stuff I want.

Can someone point me in the right direction or show me some sample code snippets for that?

Sincerely
Joseph

Have a look at the documentation of these endpoints.

Account Information

give me all assets in Spot wallet

Lending account

give me all assets in flexible savings

Get Flexible Product List

find out if there is an asset available to activate the Flexible Savings

Get Fixed and Activity Project List

find out if there is an asset available to buy a Locked Staking

Purchase Flexible Product

buy the one with the longest duration (FLEXIBLE)

Purchase Fixed/Activity Project

buy the one with the longest duration (FIXED)

Redeem Flexible Product

move asset from Flexible Savings to Spot Wallet