Been trying to add Trigger order instead of swaps. I have had no luck following the examples on the jupiter createOrder & execute
I created this model for the createOrder...
public class PlaceTriggerOrderRequest {
[JsonPropertyName("maker")]
public string? Maker { get; set; }
[JsonPropertyName("payer")]
public string? Payer { get; set; }
[JsonPropertyName("inputMint")]
public string? InputMint { get; set; }
[JsonPropertyName("outputMint")]
public string? OutputMint { get; set; }
[JsonPropertyName("params")]
public Dictionary<string, object>? Params { get; set; }
[JsonPropertyName("computeUnitPrice")]
public string? ComputeUnitPrice { get; set; } = "auto";
[JsonPropertyName("requestId")]
public string? RequestId { get; set; }
}
------------------ createOrder code frag ------------------
// Generate a unique requestId (GUID)
string requestId = Guid.NewGuid().ToString();
// Build the create order request
var createOrderRequest = new PlaceTriggerOrderRequest {
Maker = _Account.PublicKey,
Payer = _Account.PublicKey,
InputMint = _Sell.Address,
OutputMint = _Buy.Address,
RequestId = requestId,
ComputeUnitPrice = "auto",
Params = new Dictionary<string, object> {
["makingAmount"] = makingAmount.ToString(),
["takingAmount"] = takingAmount.ToString()
}
};
if (expiredAt > 0) {
createOrderRequest.Params["expiredAt"] = expiredAt.ToString();
}
string TriggerAPI = "https://lite-api.jup.ag/trigger/v1/"; // NOT the api-key version
// POST to /createOrder endpoint
string createOrderUrl = $"{TriggerAPI}createOrder";
var createOrderResponse = await Http.PostAsync(createOrderUrl, Http.Content(createOrderRequest));
This does return sucessfully, and with a transaction string which I pass into the next routine
tried just using the jupiter Execute version. I get error 500 (internal server error)
If I attempt use sign and send via the solnet rpc....
---- generic sendtransaction routine --------
public static async Task<string?> ExecuteOrderAsync(Account _Account, string _Transaction, int _Retries = 1) {
// Deserialize the base64 transaction to VersionedTransaction
byte[] transactionBytes = Convert.FromBase64String(_Transaction);
VersionedTransaction transaction = VersionedTransaction.Deserialize(transactionBytes);
// Sign the transaction with the wallet's account
transaction.Sign([_Account]);
// Serialize the signed transaction to byte array
var signedTransactionBytes = transaction.Serialize();
// Send the raw transaction to the network
//RequestResult<ResponseValue<SimulationLogs>> signature = await rpcClient.SimulateTransactionAsync(signedTransactionBytes, false);
RequestResult<string> signature = await rpcClient.SendTransactionAsync(signedTransactionBytes, false);
if (!signature.WasSuccessful) {
throw new Exception($"Failed to send transaction {signature.Reason}");
}
return signature.Result;
}
I get an error: invalid transaction: Transaction failed to sanitize accounts offsets correctly
I know you didn't add in trigger orders. but I have been at this for a week now. can you shed any light on this? or a way to verify what I am doing wrong?
Been trying to add Trigger order instead of swaps. I have had no luck following the examples on the jupiter createOrder & execute
I created this model for the createOrder...
------------------ createOrder code frag ------------------
// Generate a unique requestId (GUID)
string requestId = Guid.NewGuid().ToString();
// Build the create order request
var createOrderRequest = new PlaceTriggerOrderRequest {
Maker = _Account.PublicKey,
Payer = _Account.PublicKey,
InputMint = _Sell.Address,
OutputMint = _Buy.Address,
RequestId = requestId,
ComputeUnitPrice = "auto",
Params = new Dictionary<string, object> {
["makingAmount"] = makingAmount.ToString(),
["takingAmount"] = takingAmount.ToString()
}
};
if (expiredAt > 0) {
createOrderRequest.Params["expiredAt"] = expiredAt.ToString();
}
string TriggerAPI = "https://lite-api.jup.ag/trigger/v1/"; // NOT the api-key version
// POST to /createOrder endpoint
string createOrderUrl = $"{TriggerAPI}createOrder";
var createOrderResponse = await Http.PostAsync(createOrderUrl, Http.Content(createOrderRequest));
This does return sucessfully, and with a transaction string which I pass into the next routine
tried just using the jupiter Execute version. I get error 500 (internal server error)
If I attempt use sign and send via the solnet rpc....
---- generic sendtransaction routine --------
public static async Task<string?> ExecuteOrderAsync(Account _Account, string _Transaction, int _Retries = 1) {
// Deserialize the base64 transaction to VersionedTransaction
byte[] transactionBytes = Convert.FromBase64String(_Transaction);
VersionedTransaction transaction = VersionedTransaction.Deserialize(transactionBytes);
I get an error: invalid transaction: Transaction failed to sanitize accounts offsets correctly
I know you didn't add in trigger orders. but I have been at this for a week now. can you shed any light on this? or a way to verify what I am doing wrong?