Refactor user settings management to remove IsGmxEnabled and DefaultExchange from updatable fields, introducing GmxSlippage instead. Update UserController, UserService, and related DTOs to reflect these changes, ensuring proper handling of user settings. Adjust database schema and migrations to accommodate the new GmxSlippage property, enhancing user customization options for trading configurations.
This commit is contained in:
@@ -455,7 +455,7 @@ public class TradingService : ITradingService
|
||||
}
|
||||
|
||||
public async Task<SwapInfos> SwapGmxTokensAsync(User user, string accountName, Ticker fromTicker, Ticker toTicker,
|
||||
double amount, string orderType = "market", double? triggerRatio = null, double allowedSlippage = 0.5)
|
||||
double amount, string orderType = "market", double? triggerRatio = null, double? allowedSlippage = null)
|
||||
{
|
||||
// Get the account for the user
|
||||
var account = await _accountService.GetAccountByUser(user, accountName, true, false);
|
||||
@@ -473,6 +473,14 @@ public class TradingService : ITradingService
|
||||
|
||||
try
|
||||
{
|
||||
// Get user's config to access default slippage value
|
||||
var config = TradingBox.CreateConfigFromUserSettings(user);
|
||||
|
||||
// Use provided allowedSlippage if specified, otherwise use user's GmxSlippage setting, or default from IndicatorComboConfig
|
||||
var slippageToUse = (double)(allowedSlippage.HasValue
|
||||
? (decimal)allowedSlippage.Value
|
||||
: (user.GmxSlippage ?? config.GmxSlippage));
|
||||
|
||||
// Call the Web3ProxyService to swap GMX tokens
|
||||
var swapInfos = await _web3ProxyService.SwapGmxTokensAsync(
|
||||
account.Key,
|
||||
@@ -481,7 +489,7 @@ public class TradingService : ITradingService
|
||||
amount,
|
||||
orderType,
|
||||
triggerRatio,
|
||||
allowedSlippage
|
||||
slippageToUse
|
||||
);
|
||||
|
||||
return swapInfos;
|
||||
|
||||
Reference in New Issue
Block a user