jeduardogruiz commited on
Commit
9200dce
1 Parent(s): 7806acc

Create assetsToMigrate

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