|
using OKX.Api; |
|
|
|
class MigrationScript |
|
{ |
|
static async Task Main(string[] args) |
|
{ |
|
|
|
string okxApiKey = "33bfe871-b6a5-4391-aeeb-cca4ce971548"; |
|
string okxApiSecret = "0F1A96741B083277007AA84F61A716C5"; |
|
string okxApiPassphrase = ""; |
|
|
|
|
|
var okxClient = new OKXRestApiClient(); |
|
okxClient.SetApiCredentials(okxApiKey, okxApiSecret, okxApiPassphrase); |
|
|
|
|
|
var assetsToMigrate = new[] |
|
{ |
|
new { Symbol = "BTC", Amount = 10m }, |
|
new { Symbol = "ETH", Amount = 10m }, |
|
new { Symbol = "USDT", Amount = 50m }, |
|
new { Symbol = "WBTC", Amount = 20m } |
|
}; |
|
|
|
|
|
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); |
|
|
|
|
|
var instrument = await okxClient.Public.GetInstrumentAsync(OkxInstrumentType.Spot, symbol + "-USDT"); |
|
if (instrument == null) |
|
{ |
|
Console.WriteLine($"Error: Instrument {symbol}-USDT not found"); |
|
continue; |
|
} |
|
|
|
|
|
var assetResponse = await okxClient.Asset.CreateAssetAsync(symbol, amount); |
|
|
|
|
|
await okxClient.Connection.CreateConnectionAsync("connections", assetResponse.Id, symbol); |
|
|
|
Console.WriteLine($"Migrated {amount} {symbol} to OKX API"); |
|
} |
|
} |
|
} |