register
- update
- ramp
sequence. Since any ramp requires different information to be sent by the user during the update
stage, the SDK implements an easy-to-use interface which is generic for any ramp, as well as the corresponding typing.
rampProcess
and a list of unsignedTransactions
.
unsignedTransactions
array contains objects that your application must process. Each object has a standard structure:phase
: A string identifying the purpose of the transaction (e.g., squidRouterApprove
).txData
: An object containing the raw transaction details.to
: The destination EVM address (e.g., a contract address).data
: The encoded calldata for the transaction.updateRamp
. This step requires you to pass the resulting transaction hashes from the previous step.
wagmi
package for signing transactions. This example demonstrates the process of acquiring the necessary data and handling the signing:import { useSendTransaction } from 'wagmi';
import { VortexSdk } from '@vortexfi/sdk';
// Assumes 'sdk', 'quote', and 'brlOfframpData' are already defined.
// 1. Get the transactions to sign.
const { rampProcess, unsignedTransactions } = await sdk.registerRamp(quote, rampData);
const address = '0xasdf...' // This is the address of your wallet account that you want to use for submitting the transactions
const { sendTransactionAsync } = useSendTransaction();
const transactionHashes: { [key: string]: string } = {};
// 2. Sign and send user transactions.
for (const tx of unsignedTransactions) {
const hash = await sendTransactionAsync({
to: tx.txData.to,
data: tx.txData.data,
});
// Wait for transaction confirmation here.
transactionHashes[`${tx.phase}`] = hash;
}
// 3. Create additionalData object with relevant hashes. The required fields are depending on the ramp type.
const additionalData = {
squidRouterApproveHash: transactionHashes['squidRouterApprove'],
squidRouterSwapHash: transactionHashes['squidRouterSwap']
}
await sdk.updateRamp(quote, rampProcess.id, additionalData);
await sdk.startRamp(rampProcess.id);
BRL
onramp:import { VortexSdk } from "@vortexfi/sdk";
import { FiatToken, EvmToken, Networks} from "@vortexfi/sdk";
import type { VortexSdkConfig } from "@vortexfi/sdk";
const config: VortexSdkConfig = {
apiBaseUrl: "http://localhost:3000",
};
const sdk = new VortexSdk(config);
const quoteRequest = {
from: "pix" as const,
inputAmount: "150000",
inputCurrency: FiatToken.BRL,
outputCurrency: EvmToken.USDC,
rampType: RampDirection.BUY,
to: Networks.Polygon,
};
const quote = await sdk.createQuote(quoteRequest);
const brlOnrampData = {
destinationAddress: "0x1234567890123456789012345678901234567890",
taxId: "123.456.789-00"
};
cconst { rampProcess } = await = await sdk.registerRamp(quote, brlOnrampData);
// Make the FIAT payment.
// The sdk will provide the information to make the payment.
const { depositQrCode } = registeredRamp
console.log("Please do the pix transfer using the following code: ", brCode)
//Once the payment is done, start the ramp.
const startedRamp = await sdk.startRamp(quote, registeredRamp.id);
registerRamp
, the returned unsignedTransactions
array will contain data for a token approval and swap. You must sign and broadcast these transactions, then provide their resulting hashes to updateRamp
to confirm the sale and trigger your ramp process.