预充值账户允许您与 KillB 保持余额,以便即时执行交易,而无需等待支付确认。
预充值账户提供最快的交易体验,非常适合高交易量操作。
工作原理
创建预充值账户
POST /api/v2/customers/pre-fund/create
{
"currency": "USDC",
"network": "POLYGON"
}
响应:
{
"id": "prefund-account-id",
"type": "PRE_FUND",
"address": "0xABC...DEF",
"currency": "USDC",
"network": "POLYGON",
"active": true,
"createdAt": "2024-01-15T10:30:00.000Z"
}
支持的预充值方式
加密货币:
PRE_FUND_POLYGON - Polygon 上的 USDC/USDT
PRE_FUND_ERC20 - Ethereum 上的 USDC/USDT
PRE_FUND_SOLANA - Solana 上的 USDC/USDT
PRE_FUND_TRON - Tron 上的 USDC/USDT
PRE_FUND_ARBITRUM - Arbitrum 上的 USDC/USDT
法币:
PRE_FUND - USD, COP, MXN 法币余额
在 Ramps 中使用预充值
在报价中指定预充值方式:
{
"fromCurrency": "USDC",
"toCurrency": "COP",
"amount": 100,
"amountIsToCurrency": false,
"cashInMethod": "PRE_FUND_POLYGON",
"cashOutMethod": "PSE"
}
如果您有足够的预充值余额,ramp 将立即执行。
检查余额
获取您的预充值余额:
GET /api/v2/customers/balances
[
{
"id": "balance-id",
"currency": "USDC",
"amount": "1000.50",
"accountId": "prefund-account-id"
},
{
"id": "balance-id-2",
"currency": "COP",
"amount": "5000000.00",
"accountId": "prefund-fiat-id"
}
]
const getPreFundBalance = async () => {
const response = await fetch(
'https://teste-94u93qnn.uc.gateway.dev/api/v2/customers/balances',
{
headers: {
'Authorization': `Bearer ${token}`
}
}
);
const balances = await response.json();
// 查找 USDC 余额
const usdcBalance = balances.find(b => b.currency === 'USDC');
console.log('USDC Balance:', usdcBalance.amount);
return balances;
};
存入资金
加密货币存款
将 USDC/USDT 发送到预充值账户地址:
// 使用 ethers.js
const depositToPreFund = async (amount) => {
const preFundAccount = await getPreFundAccount('USDC', 'POLYGON');
const usdcContract = new ethers.Contract(USDC_ADDRESS, ERC20_ABI, signer);
// 发送 USDC
const tx = await usdcContract.transfer(
preFundAccount.address,
ethers.utils.parseUnits(amount.toString(), 6) // USDC 有 6 位小数
);
await tx.wait();
console.log('Deposit confirmed:', tx.hash);
};
法币存款
联系支持以通过电汇或 ACH 安排法币预充值。
最佳实践
const checkBeforeRamp = async (requiredAmount) => {
const balances = await getPreFundBalance();
const usdcBalance = parseFloat(balances.find(b => b.currency === 'USDC').amount);
if (usdcBalance < requiredAmount) {
throw new Error(`余额不足。需要 ${requiredAmount},现有 ${usdcBalance}`);
}
};
const balance = await getPreFundBalance();
const threshold = 1000; // 在 $1000 时警报
if (balance.amount < threshold) {
await sendAlert('预充值余额低', balance);
}
- 跟踪所有存款
- 监控所有使用预充值的 ramps
- 计算预期余额
- 与实际余额比较
- 调查差异
下一步