Stakes can be taggued using the Solana memo feature to enable Kiln to distinguish your stakes on-chain.
Solana memo instruction
A Solana transaction is composed of multiple instructions, executed one after the other. Here is an example of instructions you can define with the standard Solana @solana/web3.js package.
constmemoProgram='MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';constmemo='hello, world!';constinstructions= [// 1 - add memo to transactionnewTransactionInstruction({ keys: [ { pubkey: staker, isSigner:true, isWritable:true, }, ], programId:newPublicKey(memoProgram), data:Buffer.from(memo), }),// 2 - create stake accountSystemProgram.createAccount({/** The account that will transfer lamports to the created account */ fromPubkey: publicKey,/** Public key of the created account. Must be pre-calculated with PublicKey.createWithSeed() */ newAccountPubkey:stakeKey.publicKey,/** Amount of lamports to transfer to the created account */ lamports:solToLamports(parsedStakeAmount),/** Amount of space in bytes to allocate to the created account */ space:200,/** Public key of the program to assign as the owner of the created account */ programId, }),// 3 - init stake accountStakeProgram.initialize({ stakePubkey:stakeKey.publicKey, authorized: {/** stake authority */ staker: publicKey,/** withdraw authority */ withdrawer: publicKey, }, lockup: {/** Unix timestamp of lockup expiration */ unixTimestamp:0,/** Epoch of lockup expiration */ epoch:0,/** Lockup custodian authority */ custodian:newPublicKey('11111111111111111111111111111111'), }, }),// 4 - delegate stake accountStakeProgram.delegate({ stakePubkey:stakeKey.publicKey, authorizedPubkey: publicKey, votePubkey:newPublicKey(SOL_VOTE_ACCOUNT_ADDRESS), }),];tx.add(...instructions);
This transaction will be taggued with the hello, world! memo and will create, initialize and delegate a stake account.
What value should we use for the memo?
Kiln gives to each partner a fix value to include as memo in all the transactions they craft with the following format: kiln_{uuidv4}.
DYDX - How to bridge your rewards
How to bridge your rewards using Kiln Connect, regardless of your custody solution.
Rewards earned on DYDX are DYDX-USDC. In this tutorial we will present how to bridge these rewards to Ethereum or to Osmosis using the Kiln SDK. These flows can be done directly from Kiln Dashboard if you are using Fireblocks.
Bridge to Ethereum
The goal of this bridge is to bring your dYdX rewards in USDC on your ETH address so that you can use them for other purposes like depositing them on a centralized exchange to get some dYdX back.
To convert your DYDX-USDC to USDC on Ethereum, we will use the Noble bridge developed by Circle, which is the recommended on-chain approach.
There is 3 steps to this flow:
1) Transfer the USDC from DYDX to the Noble chain
2) Burn the USDC on Noble
3) Mint the USDC on Ethereum
Here is a TypeScript code snippet that you can use:
import { Kiln } from"@kilnfi/sdk";import axios from'axios';constf=async () => {constk=newKiln({ apiToken:'YOUR_KILN_API_TOKEN', });/** * Send dydx-usdc rewards to noble */// Craft IBC transfer transactionconsttransferTx=awaitk.dydx.craftNobleIbcTransfer('YOUR_WALLET_PUBKEY',1);// Sign the transaction with your custody solutionconstsignature='...';// Add signature to the transactionconst { data: data1 } =awaitaxios.post("https://api.kiln.fi/v1/dydx/transaction/prepare", { pubkey:transferTx.data.pubkey, tx_body:transferTx.data.tx_body, tx_auth_info:transferTx.data.tx_auth_info, signature: signature, });// Broadcast the transactionconsttransferTxHash=awaitk.dydx.broadcast(data1.data);/** * Burn the usdc on noble for eth address recipient */// Craft burn transactionconstburnTx=awaitk.noble.craftBurnUsdc('YOUR_WALLET_PUBKEY','ETH_RECIPIENT',1);// Sign the transaction with your custody solutionconstsignature2='...';// Add signature to the transactionconst { data: data2 } =awaitaxios.post("https://api.kiln.fi/v1/noble/transaction/prepare", { pubkey:burnTx.data.pubkey, tx_body:burnTx.data.tx_body, tx_auth_info:burnTx.data.tx_auth_info, signature: signature, });// Broadcast the transactionconstburnTxHash=awaitk.noble.broadcast(data2.data);/** * Mint the USDC on Ethereum to the recipient */// Fetch the attestation from circle's API (https://developers.circle.com/stablecoins/reference/getattestation)const { data: attestation } =awaitaxios.get(`https://iris-api-sandbox.circle.com/v1/messages/4/${burnTxHash}`);// Craft the ethereum mint transaction// todo: Kiln to add this part to the sdkconstmintTx;// Sign the transaction with your custody solutionconstsignature3='...';// Add signature to the transactionconst { data: data3 } =awaitaxios.post("https://api.kiln.fi/v1/eth/transaction/prepare", { pubkey:mintTx.data.pubkey, tx_body:mintTx.data.tx_body, tx_auth_info:mintTx.data.tx_auth_info, signature: signature, });// Broadcast the transactionconstmintTxHash=awaitk.eth.broadcast(data3.data);};f();
Bridge to Osmosis
The goal of this bridge is to bring your dYdX rewards in USDC on another cosmos address here on Osmosis so that you can use them for other purposes like depositing them on a centralized exchange or a Swap on Osmosis to get some dYdX back.
This flow follows two steps:
1) Transfer the DYDX-USDC to the Noble chain
2) Transfer the USDC on Noble to Osmosis
Here is a TypeScript code snippet that you can use:
import { Kiln } from"@kilnfi/sdk";import axios from'axios';constf=async () => {constk=newKiln({ apiToken:'YOUR_KILN_API_TOKEN', });/** * Send dydx-usdc rewards to noble */// Craft IBC transfer transactionconsttransferTx=awaitk.dydx.craftNobleIbcTransfer('YOUR_WALLET_PUBKEY',1);// Sign the transaction with your custody solutionconstsignature='...';// Add signature to the transactionconst { data: data1 } =awaitaxios.post("https://api.kiln.fi/v1/dydx/transaction/prepare", { pubkey:transferTx.data.pubkey, tx_body:transferTx.data.tx_body, tx_auth_info:transferTx.data.tx_auth_info, signature: signature, });// Broadcast the transactionconsttransferTxHash=awaitk.dydx.broadcast(data1.data);/** * Send usdc from noble to osmosis */// Craft IBC transfer transactionconsttransferTx2=awaitk.noble.craftOsmoIbcTransfer('YOUR_WALLET_PUBKEY','OSMO_RECIPIENT_ADDRESS',1);// Sign the transaction with your custody solutionconstsignature2='...';// Add signature to the transactionconst { data: data2 } =awaitaxios.post("https://api.kiln.fi/v1/noble/transaction/prepare", { pubkey:transferTx2.data.pubkey, tx_body:transferTx2.data.tx_body, tx_auth_info:transferTx2.data.tx_auth_info, signature: signature2, });// Broadcast the transactionconsttransferTxHash2=awaitk.noble.broadcast(data2.data);};f();