File size: 1,927 Bytes
9200dce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
using OKX.Api;
class MigrationScript
{
static async Task Main(string[] args)
{
// Set API credentials
string okxApiKey = "33bfe871-b6a5-4391-aeeb-cca4ce971548";
string okxApiSecret = "0F1A96741B083277007AA84F61A716C5";
string okxApiPassphrase = ""; // Set your API passphrase
// Create OKX API client
var okxClient = new OKXRestApiClient();
okxClient.SetApiCredentials(okxApiKey, okxApiSecret, okxApiPassphrase);
// Define assets to migrate in bulk
var assetsToMigrate = new[]
{
new { Symbol = "BTC", Amount = 10m },
new { Symbol = "ETH", Amount = 10m },
new { Symbol = "USDT", Amount = 50m },
new { Symbol = "WBTC", Amount = 20m }
};
// Migrate assets in bulk
await MigrateAssetsInBulk(okxClient, assetsToMigrate);
}
static async Task MigrateAssetsInBulk(OKXRestApiClient okxClient, IEnumerable<object> assetsToMigrate)
{
foreach (var asset in assetsToMigrate)
{
string symbol = (string)asset.GetType().GetProperty("Symbol").GetValue(asset);
decimal amount = (decimal)asset.GetType().GetProperty("Amount").GetValue(asset);
// Get asset details
var instrument = await okxClient.Public.GetInstrumentAsync(OkxInstrumentType.Spot, symbol + "-USDT");
if (instrument == null)
{
Console.WriteLine($"Error: Instrument {symbol}-USDT not found");
continue;
}
// Create asset on OKX API
var assetResponse = await okxClient.Asset.CreateAssetAsync(symbol, amount);
// Create connection on OKX API
await okxClient.Connection.CreateConnectionAsync("connections", assetResponse.Id, symbol);
Console.WriteLine($"Migrated {amount} {symbol} to OKX API");
}
}
} |