DYDX - How to bridge your rewards
How to bridge your rewards using Kiln Connect, regardless of your custody solution.
Bridge to Ethereum
import { Kiln } from "@kilnfi/sdk";
import axios from 'axios';
const f = async () => {
const k = new Kiln({
baseUrl: 'https://api.kiln.fi',
apiToken: 'YOUR_KILN_API_TOKEN',
});
/**
* Send dydx-usdc rewards to noble
*/
// Craft IBC transfer transaction
const transferTx = await k.client.POST(
'/v1/dydx/transaction/noble-ibc-transfer',
{
body: {
pubkey: '02d92b48d3e9ef34f2016eac7857a02768c88e30aea7a2366bc5ba032a22eceb8b',
amount_uusdc: '1000000',
}
}
);
// Sign the transaction with Fireblocks or your custody solution
const signResponse = await k.fireblocks.signDydxTx(vault, tx.data.data);
// Broadcast the transaction on DYDX
const broadcastedTx = await k.client.POST("/v1/dydx/transaction/broadcast", {
body: {
tx_serialized: signResponse.signed_tx.data.tx_serialized,
}
});
/**
* Burn the usdc on noble for eth address recipient
*/
// Craft burn transaction
const txburn = await k.client.POST(
'/v1/noble/transaction/burn-usdc',
{
body: {
pubkey: '02d92b48d3e9ef34f2016eac7857a02768c88e30aea7a2366bc5ba032a22eceb8b',
amount_usdc: '1000000',
recipient: '0xBC86717BaD3F8CcF86d2882a6bC351C94580A994',
}
}
);
// Sign the transaction with Fireblocks or your custody solution
const signResponseBurn = await k.fireblocks.signDydxTx(vault, txburn.data.data);
// Broadcast the transaction on Noble
const broadcastedTxBurn = await k.client.POST("/v1/noble/transaction/broadcast", {
body: {
tx_serialized: signResponseBurn.signed_tx.data.tx_serialized,
}
});
/**
* 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 } = await axios.get(`https://iris-api-sandbox.circle.com/v1/messages/4/${burnTxHash}`);
// Craft the Ethereum mint transaction
// todo: Kiln to add this part to the sdk
const mintTx;
// Sign and broadcast the transaction with Fireblocks on Ethereum
const txHash = await k.fireblocks.signAndBroadcastEthTx(vault, mintTx);
};
f();
Bridge to Osmosis
Last updated
Was this helpful?

