Redeeming price-stable credit

Parameters

Name

Description

Required?

Validation

assetCode

The asset code of price-stable credit that you want to redeem.

Yes

  • Already been setup

  • Correct format (1-7 alphanumeric characters)

issuer

The issuing account of the stable credit to be redeem.

Yes

  • Stellar account format

  • Issuing account of stable credit created in Velo system

amount

The amount of stable credit you which to exchange into VELO token.

Yes

  • Must be a positive number greater than 0 and has less than or equal to 7 decimal places

GO SDK
GO SDK
package main
import (
"context"
"github.com/velo-protocol/DRSv1/libs/client"
"github.com/velo-protocol/DRSv1/libs/txnbuild"
"log"
)
func main() {
// Init Velo SDK From Stellar Account Secret Key
client, err := vclient.NewDefaultTestNetClient("testnet-drsv1-0.velo.org", "<YOUR SECRET KEY OF STELLAR ACCOUNT>")
if err != nil {
log.Println(err)
return
}
defer func() {
_ = client.Close()
}()
// Using Velo SDK Redeem Credit Operation
result, err := client.RedeemCredit(context.Background(), vtxnbuild.RedeemCredit{
AssetCode: "<STABLE CREDIT ASSET CODE>", // Ex: vTHB
Issuer: "<STABLE CREDIT ISSUER ADDRESS>", // Ex: GAXKPU22AE22NO7FXSW7GTNJJ6FGN5NQLXWTJGNBF4VOKLXVJ3RROXTI
Amount: "<STABLE CREDIT REDEEMED AMOUNT>", // Ex: 100 (Amount of vTHB)
})
if err != nil {
log.Println(err)
return
}
log.Println("Transaction Hash:", result.HorizonResult.TransactionSuccessToString())
// Transaction Hash: 4a3365180521e16b478d9f0c9198b97a9434fc9cb07b34f83ecc32fc54d0ca8a
log.Println("Asset Code To Be Redeemed: ", result.VeloNodeResult.AssetCodeToBeRedeemed)
// Asset Code To Be Redeemed: vTHB
log.Println("Asset Issuer To Be Redeemed: ", result.VeloNodeResult.AssetIssuerToBeRedeemed)
// Asset Issuer To Be Redeemed: GAXKPU22AE22NO7FXSW7GTNJJ6FGN5NQLXWTJGNBF4VOKLXVJ3RROXTI
log.Println("Asset Amount To Be Redeemed: ", result.VeloNodeResult.AssetAmountToBeRedeemed)
// Asset Amount To Be Redeemed: 100
log.Println("Collateral Code: ", result.VeloNodeResult.CollateralCode)
// Collateral Code: VELO
log.Println("Collateral Issuer: ", result.VeloNodeResult.CollateralIssuer)
// Collateral Issuer: GDVGQLQQWOYQCYASYWH2BB6Q7YQAZJQWB2JVA3QTJYZOGFO5HBQULPVE
log.Println("Collateral Amount: ", result.VeloNodeResult.CollateralAmount)
// Collateral Amount: 100
}

Error

SDK
SDK

Description

Message

Response code

Cannot parse XDR

The XDR message cannot be decoded

3

Source account not found in user table or does not have permission to perform minting price-stable credit

The signer is not found or does not have sufficient permission to perform mint price-stable credit

7

Signature and source account does not match

The signature and source account does not match

16

Source account is blank

sourceAccount for the transaction must not be blank

3

Source account format is incorrect

invalid sourceAccount format

3

Cannot contact Stellar

internal server error

13

Cannot get price of pegged currency

cannot get price of pegged currency: no valid price in price account ${account}

9

Cannot get account details

fail to get account detail of ${account}

9

Asset code and issuing account does not match

fail to verify asset code: key &{key} not found in the data of account &{value}

3

What's next?

You have now completed the flow of stable credit. Let's take a look at the price stablisation mechanism.