Get exchange rate between price-stable credit and VELO

Parameters

You don't need to be a trusted partner to check exchange rates.

Name

Description

Required?

Validation

assetCode

The asset code of price-stable credit that you want to get exchange rate for.

Yes

  • Already been setup

  • Correct format (1-7 alphanumeric characters)

issuer

The issuing account of the asset code that you want to get exchange rate.

Yes

  • Stellar public address format

GO SDK
GO SDK
package main
import (
"context"
spec "github.com/velo-protocol/DRSv1/grpc"
"github.com/velo-protocol/DRSv1/libs/client"
"log"
)
func main() {
// Init Velo SDK From Stellar Account Secret Key
client, err := vclient.NewDefaultTestNetClient("testnet-drsv1-0.velo.org", "<YOUR SECRET KEY>")
if err != nil {
log.Println(err)
return
}
defer func() {
_ = client.Close()
}()
// Using Velo SDK Get Exchange Rate Operation
exchangeRate, err := client.GetExchangeRate(context.Background(), &spec.GetExchangeRateRequest{
AssetCode: "<STABLE CREDIT ASSET CODE>", // Ex: vTHB
Issuer: "<STABLE CREDIT ISSUER ADDRESS>", // Ex: GAXKPU22AE22NO7FXSW7GTNJJ6FGN5NQLXWTJGNBF4VOKLXVJ3RROXTI
})
if err != nil {
log.Println(err)
return
}
log.Println("Asset Code: ", exchangeRate.AssetCode)
// Asset Code: vTHB
log.Println("Asset Issuer: ", exchangeRate.Issuer)
// Asset Issuer: GAXKPU22AE22NO7FXSW7GTNJJ6FGN5NQLXWTJGNBF4VOKLXVJ3RROXTI
log.Println("Redeemable Collateral: ", exchangeRate.RedeemableCollateral)
// Redeemable Collateral: VELO
log.Println("Redeemable Price Per Unit: ", exchangeRate.RedeemablePricePerUnit)
// Redeemable Price Per Unit: 1
}

Error

SDK
SDK

Description

Message

Response code

Cannot connect to Stellar

Internal server error

13

Asset code and issuer does not match

Mismatched assetCode and issuer

3

Invalid issuing account

invalid issuing account

9

What's next?

When you know the exchange rate, you will also know how much the stable credit you have is worth. Next let's try exchanging the stable credit back to VELO token.