Skip to content

Commit 9564dc3

Browse files
v14.0.2 (#28)
1 parent 693d01e commit 9564dc3

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sakit"
3-
version = "14.0.1"
3+
version = "14.0.2"
44
description = "Solana Agent Kit"
55
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
66
license = "MIT"

sakit/utils/recurring.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,50 @@ async def create_order(
9797
order_count: Total number of orders to execute
9898
frequency: Time between each order in seconds (as string, e.g., "3600" for hourly)
9999
payer: Optional payer wallet address for gasless (defaults to user)
100-
min_out_amount: Optional minimum output amount per order
101-
max_out_amount: Optional maximum output amount per order
100+
min_out_amount: Optional minimum output amount per order (as price, not amount)
101+
max_out_amount: Optional maximum output amount per order (as price, not amount)
102102
start_at: Optional start time in unix seconds (as string)
103103
104104
Returns:
105105
RecurringOrderResponse with transaction to sign
106106
"""
107+
# Build the time-based order params per Jupiter API spec
108+
time_params: Dict[str, Any] = {
109+
"inAmount": int(in_amount),
110+
"numberOfOrders": int(order_count),
111+
"interval": int(frequency),
112+
"minPrice": None,
113+
"maxPrice": None,
114+
"startAt": None,
115+
}
116+
117+
# Handle optional price bounds
118+
if min_out_amount:
119+
try:
120+
time_params["minPrice"] = float(min_out_amount)
121+
except (ValueError, TypeError):
122+
pass
123+
if max_out_amount:
124+
try:
125+
time_params["maxPrice"] = float(max_out_amount)
126+
except (ValueError, TypeError):
127+
pass
128+
if start_at:
129+
try:
130+
time_params["startAt"] = int(start_at)
131+
except (ValueError, TypeError):
132+
pass
133+
107134
body = {
108135
"user": user,
109136
"payer": payer or user,
110137
"inputMint": input_mint,
111138
"outputMint": output_mint,
112139
"params": {
113-
"depositAmount": in_amount,
114-
"orderCount": order_count,
115-
"frequency": frequency,
140+
"time": time_params,
116141
},
117142
}
118143

119-
if min_out_amount:
120-
body["params"]["minOutAmount"] = min_out_amount
121-
if max_out_amount:
122-
body["params"]["maxOutAmount"] = max_out_amount
123-
if start_at:
124-
body["params"]["startAt"] = start_at
125-
126144
try:
127145
async with httpx.AsyncClient(timeout=30.0) as client:
128146
response = await client.post(

tests/test_recurring_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async def test_create_order_with_payer(self, recurring_client):
112112

113113
@pytest.mark.asyncio
114114
async def test_create_order_with_min_max_amounts(self, recurring_client):
115-
"""Should include minOutAmount and maxOutAmount when provided."""
115+
"""Should include minPrice and maxPrice when provided."""
116116
mock_response = {
117117
"order": "dcaorder123",
118118
"transaction": "base64encodedtx==",
@@ -140,9 +140,10 @@ async def test_create_order_with_min_max_amounts(self, recurring_client):
140140

141141
call_args = mock_instance.post.call_args
142142
payload = call_args.kwargs.get("json") or call_args[1].get("json")
143-
# min/max amounts are in nested params object
144-
assert payload.get("params", {}).get("minOutAmount") == "90000"
145-
assert payload.get("params", {}).get("maxOutAmount") == "110000"
143+
# minPrice/maxPrice are in nested params.time object (converted to float)
144+
time_params = payload.get("params", {}).get("time", {})
145+
assert time_params.get("minPrice") == 90000.0
146+
assert time_params.get("maxPrice") == 110000.0
146147

147148
@pytest.mark.asyncio
148149
async def test_create_order_api_error(self, recurring_client):

0 commit comments

Comments
 (0)