Update SDK (#35)

* Update SDK for swap

* Fix web3proxy build

* Update types

* Fix swap

* Send token test and BASE transfer

* fix cache and hook

* Fix send

* Update health check with uiFeereceiver

* Fix sdk

* Fix get positions

* Fix timeoutloop

* Fix open position

* Fix closes positions

* Review
This commit is contained in:
Oda
2025-09-17 14:28:56 +07:00
committed by GitHub
parent 271dd70ad7
commit cee3902a4d
91 changed files with 21375 additions and 2831 deletions

View File

@@ -232,7 +232,7 @@ public class CandleStoreGrain : Grain, ICandleStoreGrain, IAsyncObserver<Candle>
}
}
public Task<Candle> GetLastCandle()
public Task<List<Candle>> GetLastCandle(int count = 1)
{
try
{
@@ -240,15 +240,33 @@ public class CandleStoreGrain : Grain, ICandleStoreGrain, IAsyncObserver<Candle>
if (_state.State.Candles == null || _state.State.Candles.Count == 0)
{
_logger.LogDebug("No candles available for grain {GrainKey}", this.GetPrimaryKeyString());
return Task.FromResult<Candle>(null);
return Task.FromResult(new List<Candle>());
}
return Task.FromResult(_state.State.Candles.LastOrDefault());
// Validate count parameter
if (count <= 0)
{
_logger.LogWarning("Invalid count parameter {Count} for grain {GrainKey}, using default value 1",
count, this.GetPrimaryKeyString());
count = 1;
}
// Get the last X candles, ordered by date
var lastCandles = _state.State.Candles
.OrderBy(c => c.Date)
.TakeLast(count)
.ToList();
_logger.LogDebug("Retrieved {Count} latest candles for grain {GrainKey}",
lastCandles.Count, this.GetPrimaryKeyString());
return Task.FromResult(lastCandles);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error retrieving last candle for grain {GrainKey}", this.GetPrimaryKeyString());
return Task.FromResult<Candle>(null);
_logger.LogError(ex, "Error retrieving last {Count} candles for grain {GrainKey}",
count, this.GetPrimaryKeyString());
return Task.FromResult(new List<Candle>());
}
}
}