Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
70d557b
added Aztec.
erkostandyan Sep 8, 2025
072f3d4
Add environment variable for aztec stores.
Sep 9, 2025
37794cf
Fix get swaps pagination
PurpleTheBest Sep 18, 2025
48962c8
Add repository dtos for create and update
PurpleTheBest Sep 18, 2025
2d77a32
Remove swap id from transaction request
PurpleTheBest Sep 18, 2025
0ce4676
Get rid of calldata asset
PurpleTheBest Sep 18, 2025
4ff59af
Bring Aztec changes to dev.
erkostandyan Oct 2, 2025
c5c952c
Merge pull request #135 from TrainProtocol/dev-add-aztec
erkostandyan Oct 2, 2025
d61a5f5
added treasury generate for testing.
erkostandyan Oct 3, 2025
df7140c
.
erkostandyan Oct 6, 2025
40336a4
fixed treasury dockerfile build error
erkostandyan Oct 6, 2025
f6fdc3b
changed dockerIgnore and dockerFile files
erkostandyan Oct 7, 2025
f652d7c
Merge pull request #136 from TrainProtocol/dev-fix-dockerfile
erkostandyan Oct 7, 2025
27a066a
Changed vault set async function for private salt variable.
erkostandyan Oct 8, 2025
db9f889
erkostandyan Oct 9, 2025
c498500
Changed valut getAsync function.
erkostandyan Oct 9, 2025
6c852f8
Fix vault set changes to accept private_salt values
erkostandyan Oct 9, 2025
ad2d633
added new method in vault service.
erkostandyan Oct 9, 2025
3fbfb9e
remove comment.
erkostandyan Oct 9, 2025
24627c2
Merge pull request #137 from TrainProtocol/dev-vault-fix
erkostandyan Oct 9, 2025
ac722b4
changed gnerate method for testing.
erkostandyan Oct 10, 2025
bd7a297
changed treasury client timeout for aztec.
erkostandyan Oct 10, 2025
2f6732e
Changed treasury client factory to 10min.
erkostandyan Oct 10, 2025
aabf73e
minor changes for aztec test.
erkostandyan Oct 12, 2025
2b08f22
added missing aztec worker in js.
erkostandyan Oct 13, 2025
fdefd01
added aztec github action.
erkostandyan Oct 13, 2025
3509140
Try to update docker.
Oct 15, 2025
2f89b31
Fix docker.
Oct 15, 2025
ea67f32
Revert "Fix docker."
Oct 15, 2025
c7fa55e
Reapply "Fix docker."
Oct 15, 2025
e67dd71
Revert "Reapply "Fix docker.""
Oct 15, 2025
9bd34c1
Fix.
Oct 15, 2025
9f281ff
Make block range shorter.
erkostandyan Oct 15, 2025
a4f9b91
Merge branch 'dev' of https://github.com/TrainProtocol/solver into dev
erkostandyan Oct 15, 2025
cb1f196
Back starknet solver. (#134)
Mandzikyan Nov 12, 2025
424036a
Fix starknet signature.
Nov 12, 2025
7dcf0bb
Fix private key.
Nov 12, 2025
65ca76f
Make starknet to return bigints in starknet specific way.
Nov 12, 2025
36edb13
fix.
Nov 13, 2025
7d8004c
Fix.
Nov 13, 2025
0042332
Remove v3 detaisl.
Nov 13, 2025
92bf26e
Some starknet fixes.
Nov 13, 2025
01400af
Reaad port from env variable
arkoc Nov 13, 2025
f745782
Add back 8080 port
arkoc Nov 13, 2025
bc5bb8b
Fixes.
Nov 13, 2025
4c0f490
Merge branch 'dev' of https://github.com/TrainProtocol/solver into dev
Nov 13, 2025
49c53c6
revert ts config.
Nov 13, 2025
cfe03d3
Dev solana remove revert (#138)
Mandzikyan Nov 14, 2025
172dc65
get back aztec
erkostandyan Nov 14, 2025
ade9ce6
Some fixes.
Nov 14, 2025
949c799
Fix minors.
Nov 14, 2025
72e6e74
Remove some repositorys using from solana.
Nov 14, 2025
404187c
Fix solana yml.
Nov 14, 2025
e639fbb
Dummy commit.
Nov 14, 2025
73057fd
yml Fixes.
Nov 14, 2025
f831efb
Dommy commitV2.
Nov 14, 2025
ca16198
Dummy commitV3.
Nov 14, 2025
18f730d
Fix repo name.
Nov 14, 2025
bf4ce2c
Fix majors. (#139)
Mandzikyan Nov 14, 2025
3b090f7
Dev solana major fixes (#140)
Mandzikyan Nov 14, 2025
d34e1e9
Update starknet lib.
Nov 15, 2025
cebfbbd
Some starknet fixes.
Nov 15, 2025
2462348
.
erkostandyan Nov 15, 2025
3417f5c
Bring back Aztec.
erkostandyan Nov 16, 2025
fb8a81c
Added Aztec worker.
erkostandyan Nov 16, 2025
aef2fcd
Revert "Added Aztec worker."
erkostandyan Nov 16, 2025
50f34ce
Fix aztec treasury.
erkostandyan Nov 16, 2025
59f70dc
Added env gitignore.
erkostandyan Nov 16, 2025
29d9200
Update docker file.
erkostandyan Nov 16, 2025
f77e483
Changed node version.
erkostandyan Nov 16, 2025
d4a6c45
Fixed js docker.
erkostandyan Nov 16, 2025
50d1950
Add dummy change.
erkostandyan Nov 16, 2025
0ab1fa3
Fix starknet event decoder.
Nov 17, 2025
89caa49
Fixed treasury setDict method.
erkostandyan Nov 17, 2025
c08fa3a
Fix correct event parsing.
Nov 17, 2025
1eaa470
Increased treasury timeout.
erkostandyan Nov 18, 2025
99cce31
Merge branch 'dev' of https://github.com/TrainProtocol/solver into dev
erkostandyan Nov 18, 2025
d40a61d
Increased timeout
erkostandyan Nov 18, 2025
0dc3919
Mapping solver source and destination addreses in SwapDto.cs.
Martin9204 Nov 18, 2025
0dabe18
Returning detailed swap dto instead of swap dto
Martin9204 Nov 18, 2025
c78f57d
Merge pull request #142 from TrainProtocol/dev-solver-address
PurpleTheBest Nov 18, 2025
2371966
Create htlc lock for solana native contract. (#143)
Mandzikyan Nov 18, 2025
dc0107a
Initial commit.
erkostandyan Nov 18, 2025
c7996cb
Added aztec config service.
erkostandyan Nov 18, 2025
e27a95d
Removed comments.
erkostandyan Nov 18, 2025
a204cbd
Merge pull request #144 from TrainProtocol/dev-moveAztecTreasury
erkostandyan Nov 18, 2025
9b4c7c2
Dev solana native program (#145)
Mandzikyan Nov 18, 2025
78e062a
Back merge.
Nov 18, 2025
3027c78
Fixes.
Nov 18, 2025
b0bee42
Merge remote-tracking branch 'origin/main' into dev
PurpleTheBest Nov 19, 2025
11587c8
Fix refund address.
Nov 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions csharp/src/API/Endpoints/SolverV1Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static RouteGroupBuilder MapV1Endpoints(this RouteGroupBuilder group)
.Produces<ApiResponse<QuoteWithSolverDto>>();

group.MapGet("/swaps/{commitId}", GetSwapAsync)
.Produces<ApiResponse<SwapDto>>();
.Produces<ApiResponse<DetailedSwapDto>>();

group.MapPost("/transactions/build", BuildTransactionAsync)
.Produces<ApiResponse<PrepareTransactionDto>>();
Expand Down Expand Up @@ -121,7 +121,7 @@ private static async Task<IResult> GetSwapAsync(
});
}

return Results.Ok(new ApiResponse<SwapDto> { Data = swap.ToDto() });
return Results.Ok(new ApiResponse<DetailedSwapDto> { Data = swap.ToDetailedDto() });
}
private static async Task<IResult> GetRoutesAsync(
HttpContext httpContext,
Expand Down
25 changes: 17 additions & 8 deletions csharp/src/Workflow.Solana/Helpers/EventDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
using System.Numerics;
using Train.Solver.Blockchain.Solana.Extensions;
using Train.Solver.Blockchain.Solana.Models;
using Train.Solver.Blockchain.Solana.Programs.HTLCProgram;
using Train.Solver.Infrastructure.Abstractions.Models;
using Train.Solver.Workflow.Abstractions.Models;
using Train.Solver.Workflow.Solana.Programs.HTLCProgram;
using Train.Solver.Workflow.Solana.Programs.HtlcSolProgram;

namespace Train.Solver.Blockchain.Solana.Helpers;

Expand All @@ -34,9 +35,11 @@ public static async Task<HTLCBlockEventResponse> GetBlockEventsAsync(
{
var htlcTokenContractAddress = network.HTLCTokenContractAddress;

var htlcNativeContractAddress = network.HTLCNativeContractAddress;

var trackedBlockEvents = blockResponseResult.Result.Transactions
.Where(transaction => transaction.Transaction.Message.Instructions
.Any(instruction => instruction.ProgramId == htlcTokenContractAddress))
.Any(instruction => instruction.ProgramId == htlcTokenContractAddress || instruction.ProgramId == htlcNativeContractAddress))
.ToList();

foreach (var transaction in trackedBlockEvents)
Expand All @@ -47,11 +50,15 @@ public static async Task<HTLCBlockEventResponse> GetBlockEventsAsync(
var isLockEvent = transaction.Meta.LogMessages
.Any(x => x.Contains(SolanaConstants.HtlcConstants.addLockEventPrefixPattern));

var contractAddress = transaction.Transaction.Message.Instructions.Any(x => x.ProgramId == htlcTokenContractAddress) ?
htlcTokenContractAddress :
htlcNativeContractAddress;

var accountForSimulation = solverAccounts.First();

if (isCommitEvent)
{
var prefixPattern = "Program return: " + htlcTokenContractAddress + " ";
var prefixPattern = "Program return: " + contractAddress + " ";

var logResult = transaction.Meta.LogMessages.Where(s => s.StartsWith(prefixPattern))
.Select(s => s.Substring(prefixPattern.Length))
Expand All @@ -63,6 +70,7 @@ public static async Task<HTLCBlockEventResponse> GetBlockEventsAsync(
var commitEvent = await DeserializeCommitEventDataAsync(
rpcClient,
network,
contractAddress,
id,
accountForSimulation);

Expand Down Expand Up @@ -106,7 +114,7 @@ public static async Task<HTLCBlockEventResponse> GetBlockEventsAsync(

if (isLockEvent)
{
var prefixPattern = "Program return: " + htlcTokenContractAddress + " ";
var prefixPattern = "Program return: " + contractAddress + " ";

var logResult = transaction.Meta.LogMessages.Where(s => s.StartsWith(prefixPattern))
.Select(s => s.Substring(prefixPattern.Length))
Expand All @@ -118,6 +126,7 @@ public static async Task<HTLCBlockEventResponse> GetBlockEventsAsync(
var addLockMessageResult = await DeserializeAddLockEventDataAsync(
rpcClient,
network,
contractAddress,
id,
accountForSimulation);

Expand All @@ -139,6 +148,7 @@ public static async Task<HTLCBlockEventResponse> GetBlockEventsAsync(
private static async Task<SolanaHTLCCommitEventModel> DeserializeCommitEventDataAsync(
IRpcClient rpcClient,
DetailedNetworkDto network,
string contractAddress,
string commitId,
string solverAccount)
{
Expand All @@ -152,7 +162,7 @@ private static async Task<SolanaHTLCCommitEventModel> DeserializeCommitEventData
.SetFeePayer(new PublicKey(solverAccount));

builder.SetGetDetailsInstruction(
new PublicKey(network.HTLCTokenContractAddress),
new PublicKey(contractAddress),
commitId.HexToByteArray());

var latestBlockHashResponse = await rpcClient.GetLatestBlockHashAsync();
Expand Down Expand Up @@ -191,6 +201,7 @@ private static async Task<SolanaHTLCCommitEventModel> DeserializeCommitEventData
private static async Task<HTLCLockEventMessage?> DeserializeAddLockEventDataAsync(
IRpcClient rpcClient,
DetailedNetworkDto network,
string contractAddress,
string commitId,
string solverAccount)
{
Expand All @@ -205,10 +216,8 @@ private static async Task<SolanaHTLCCommitEventModel> DeserializeCommitEventData
var builder = new TransactionBuilder()
.SetFeePayer(new PublicKey(solverAccount));

var htlcContractAddress = network.HTLCTokenContractAddress;

builder.SetGetDetailsInstruction(
new PublicKey(htlcContractAddress),
new PublicKey(contractAddress),
commitId.HexToByteArray());

var latestBlockHashResponse = await rpcClient.GetLatestBlockHashAsync();
Expand Down
186 changes: 121 additions & 65 deletions csharp/src/Workflow.Solana/Helpers/SolanaTransactionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
using Solnet.Rpc.Builders;
using Solnet.Wallet;
using System.Numerics;
using Train.Solver.Blockchain.Solana.Programs.HTLCProgram;
using Train.Solver.Blockchain.Solana.Programs.HTLCProgram.Models;
using Train.Solver.Common.Extensions;
using Train.Solver.Data.Abstractions.Entities;
using Train.Solver.Infrastructure.Abstractions.Models;
using Train.Solver.Workflow.Abstractions.Models;
using Train.Solver.Workflow.Solana.Programs.HTLCProgram;
using Train.Solver.Workflow.Solana.Programs.HTLCProgram.Models;
using Train.Solver.Workflow.Solana.Programs.HtlcSolProgram;
using Train.Solver.Workflow.Solana.Programs.HtlcSolProgram.Models;
using Train.Solver.Workflow.Solana.Programs.HtlcSplProgram.Models;

namespace Train.Solver.Workflow.Solana.Helpers;

Expand Down Expand Up @@ -59,37 +62,60 @@ public static async Task<PrepareTransactionDto> BuildHTLCLockTransactionAsync(
var builder = new TransactionBuilder()
.SetFeePayer(new PublicKey(solverAccount));

await GetOrCreateAssociatedTokenAccount(
rpcClient,
builder,
currency,
new PublicKey(solverAccount),
new PublicKey(solverAccount));
if (isNative)
{
builder.SetSolLockTransactionInstruction(
new PublicKey(htlcContractAddress),
new HTLCSolLockRequest
{
Id = request.CommitId.HexToByteArray(),
Hashlock = request.Hashlock.HexToByteArray(),
Timelock = new BigInteger(request.Timelock),
Amount = request.Amount,
DestinationNetwork = request.DestinationNetwork,
DestinationAsset = request.DestinationAsset,
SourceAsset = currency.Symbol,
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.Receiver),
DestinationAddress = request.DestinationAddress,
Reward = request.Reward,
RewardTimelock = new BigInteger(request.RewardTimelock),
});
}
else
{
await GetOrCreateAssociatedTokenAccount(
rpcClient,
builder,
currency,
new PublicKey(solverAccount),
new PublicKey(solverAccount));

builder.SetLockTransactionInstruction(
new PublicKey(htlcContractAddress),
new HTLCLockRequest
{
Hashlock = request.Hashlock.HexToByteArray(),
Id = request.CommitId.HexToByteArray(),
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.Receiver),
Amount = request.Amount,
Timelock = new BigInteger(request.Timelock),
SourceAsset = currency.Symbol,
DestinationNetwork = request.DestinationNetwork,
SourceAddress = request.DestinationAddress,
DestinationAsset = request.DestinationAsset,
SourceTokenPublicKey = new PublicKey(currency.Contract),
Reward = request.Reward,
RewardTimelock = new BigInteger(request.RewardTimelock),
});
builder.SetSplLockTransactionInstruction(
new PublicKey(htlcContractAddress),
new HTLCSplLockRequest
{
Id = request.CommitId.HexToByteArray(),
Hashlock = request.Hashlock.HexToByteArray(),
Timelock = new BigInteger(request.Timelock),
Amount = request.Amount,
DestinationNetwork = request.DestinationNetwork,
DestinationAsset = request.DestinationAsset,
SourceAsset = currency.Symbol,
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.Receiver),
DestinationAddress = request.DestinationAddress,
SourceTokenPublicKey = new PublicKey(currency.Contract),
Reward = request.Reward,
RewardTimelock = new BigInteger(request.RewardTimelock),
});
}

var latestBlockResult = await rpcClient.GetLatestBlockHashAsync();

if (!latestBlockResult.WasSuccessful)
{
throw new ($"Failed to get last valid block");
throw new($"Failed to get last valid block");
}

builder.SetRecentBlockHash(latestBlockResult.Result.Value.Blockhash);
Expand Down Expand Up @@ -133,7 +159,7 @@ public static async Task<PrepareTransactionDto> BuildHTLCRedeemTransactionAsync(
{
throw new ArgumentNullException(nameof(request.SenderAddress), "Sender address is required");
}

var currency = network.Tokens.SingleOrDefault(x => x.Symbol.ToUpper() == request.Asset.ToUpper());

if (currency is null)
Expand All @@ -160,27 +186,43 @@ public static async Task<PrepareTransactionDto> BuildHTLCRedeemTransactionAsync(
var builder = new TransactionBuilder()
.SetFeePayer(new PublicKey(solverAccount));

await GetOrCreateAssociatedTokenAccount(
rpcClient,
builder,
currency,
new PublicKey(solverAccount),
new PublicKey(solverAccount));
if (isNative)
{
builder.SetSolRedeemTransactionInstruction(
new PublicKey(htlcContractAddress),
new HTLCSolRedeemRequest
{
Id = request.CommitId.HexToByteArray(),
Secret = BigInteger.Parse(request.Secret).ToHexBigInteger().HexValue.HexToByteArray(),
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.DestinationAddress),
SenderPublicKey = new PublicKey(request.SenderAddress),
});
}
else
{
await GetOrCreateAssociatedTokenAccount(
rpcClient,
builder,
currency,
new PublicKey(solverAccount),
new PublicKey(solverAccount));

builder.SetRedeemTransactionInstruction(
new PublicKey(htlcContractAddress),
new HTLCRedeemRequest
{
Id = request.CommitId.HexToByteArray(),
Secret = BigInteger.Parse(request.Secret).ToHexBigInteger().HexValue.HexToByteArray(),
SourceTokenPublicKey = new PublicKey(currency.Contract),
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.DestinationAddress),
SenderPublicKey = new PublicKey(request.SenderAddress),
RewardPublicKey = request.DestinationAddress == solverAccount?
new PublicKey(request.DestinationAddress) :
new PublicKey(request.SenderAddress),
});
builder.SetSplRedeemTransactionInstruction(
new PublicKey(htlcContractAddress),
new HTLCSplRedeemRequest
{
Id = request.CommitId.HexToByteArray(),
Secret = BigInteger.Parse(request.Secret).ToHexBigInteger().HexValue.HexToByteArray(),
SourceTokenPublicKey = new PublicKey(currency.Contract),
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.DestinationAddress),
SenderPublicKey = new PublicKey(request.SenderAddress),
RewardPublicKey = request.DestinationAddress == solverAccount ?
new PublicKey(request.DestinationAddress) :
new PublicKey(request.SenderAddress),
});
}

var latestBlockResult = await rpcClient.GetLatestBlockHashAsync();

Expand Down Expand Up @@ -245,22 +287,36 @@ public static async Task<PrepareTransactionDto> BuildHTLCRefundTransactionAsync(
var builder = new TransactionBuilder()
.SetFeePayer(new PublicKey(solverAccount));

await GetOrCreateAssociatedTokenAccount(
rpcClient,
builder,
currency,
new PublicKey(request.DestinationAddress),
new PublicKey(solverAccount));
if (isNative)
{
builder.SetSolRefundTransactionInstruction(
new PublicKey(htlcContractAddress),
new HtlcSolRefundRequest
{
Id = request.CommitId.HexToByteArray(),
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.DestinationAddress)
});
}
else
{
await GetOrCreateAssociatedTokenAccount(
rpcClient,
builder,
currency,
new PublicKey(request.DestinationAddress),
new PublicKey(solverAccount));

builder.SetRefundTransactionInstruction(
new PublicKey(htlcContractAddress),
new HTLCRefundRequest
{
Id = request.CommitId.HexToByteArray(),
SourceTokenPublicKey = new PublicKey(currency.Contract),
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.DestinationAddress)
});
builder.SetSplRefundTransactionInstruction(
new PublicKey(htlcContractAddress),
new HtlcSplRefundRequest
{
Id = request.CommitId.HexToByteArray(),
SourceTokenPublicKey = new PublicKey(currency.Contract),
SignerPublicKey = new PublicKey(solverAccount),
ReceiverPublicKey = new PublicKey(request.DestinationAddress)
});
}

var latestBlockHashResponse = await rpcClient.GetLatestBlockHashAsync();

Expand Down Expand Up @@ -399,7 +455,7 @@ public static async Task<PrepareTransactionDto> BuildHTLCAddlockSigTransactionAs

builder.SetAddLockSigInstruction(
new PublicKey(htlcContractAddress),
new HTLCAddlocksigRequest
new HtlcAddlocksigRequest
{
AddLockSigMessageRequest = new()
{
Expand Down Expand Up @@ -535,5 +591,5 @@ private static async Task GetOrCreateAssociatedTokenAccount(
{
throw new Exception("Failed to load token wallet", ex);
}
}
}
}
Loading