Mixtral_ether / assetsToMigrate
jeduardogruiz's picture
Create assetsToMigrate
9200dce verified
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");
}
}
}