Skip to content

Commit 1b2e59b

Browse files
v14.1.5 (#36)
1 parent 28f26a9 commit 1b2e59b

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

.coverage

0 Bytes
Binary file not shown.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ By default, Jupiter Ultra provides gasless swaps when the user has < 0.01 SOL an
104104

105105
This plugin enables Solana Agent to swap tokens using DFlow's Swap API with a Solana keypair. DFlow offers faster swaps compared to Jupiter Ultra with competitive rates.
106106

107-
**Note:** Platform fees are not supported with DFlow. Use Solana Ultra (Jupiter) if you need to collect fees on swaps.
108-
109107
```python
110108
config = {
111109
"tools": {
112110
"solana_dflow_swap": {
113111
"private_key": "my-private-key", # Required - base58 string
114112
"payer_private_key": "payer-private-key", # Optional - for gasless/sponsored transactions
115113
"rpc_url": "https://api.mainnet-beta.solana.com", # Optional - RPC URL (defaults to mainnet)
114+
"platform_fee_bps": 50, # Optional - fee in basis points (50 = 0.5%)
115+
"referral_account": "your-wallet-pubkey", # Optional - wallet to receive fees (DFlow creates ATAs automatically)
116116
},
117117
},
118118
}
@@ -121,6 +121,7 @@ config = {
121121
**Features:**
122122
- **Fast Swaps**: DFlow typically executes faster than Jupiter Ultra
123123
- **Gasless Transactions**: Optionally sponsor gas fees for users via `payer_private_key`
124+
- **Platform Fees**: Collect fees on swaps via `referral_account` - DFlow auto-creates token accounts
124125

125126
### Jupiter Trigger
126127

@@ -374,6 +375,8 @@ config = {
374375
"signing_key": "wallet-auth:your-signing-key", # Required - your Privy wallet authorization signing key
375376
"rpc_url": "https://mainnet.helius-rpc.com/?api-key=YOUR_KEY", # Required - Helius recommended for priority fees
376377
"payer_private_key": "payer-private-key", # Optional - for gasless/sponsored transactions
378+
"platform_fee_bps": 50, # Optional - fee in basis points (50 = 0.5%)
379+
"referral_account": "your-wallet-pubkey", # Optional - wallet to receive fees (DFlow creates ATAs automatically)
377380
},
378381
},
379382
}
@@ -384,6 +387,7 @@ config = {
384387
- **Privy Delegated Wallets**: Seamless user experience with embedded wallets
385388
- **Helius Priority Fees**: Uses Helius priority fee estimation for reliable transaction landing
386389
- **Gasless Transactions**: Optionally sponsor gas fees for users via `payer_private_key`
390+
- **Platform Fees**: Collect fees on swaps via `referral_account` - DFlow auto-creates token accounts
387391

388392
**RPC URL (Required):**
389393
Helius RPC is strongly recommended (`https://mainnet.helius-rpc.com/?api-key=YOUR_KEY`). Helius provides priority fee estimation and better blockhash handling, which significantly improves transaction success rates. Get a free API key at [helius.dev](https://helius.dev).

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.1.4"
3+
version = "14.1.5"
44
description = "Solana Agent Kit"
55
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
66
license = "MIT"

sakit/privy_dflow_swap.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
Transactions are signed via Privy's signTransaction and sent via Helius RPC
99
for priority fees and reliable blockhash handling.
1010
11-
Note: Platform fees are not supported. Use Jupiter Ultra (privy_ultra) if you
12-
need to collect fees on swaps.
11+
Supports platform fee collection via referralAccount - DFlow auto-creates the
12+
required token accounts to receive fees in the output token.
1313
"""
1414

1515
import base64
@@ -210,6 +210,8 @@ def __init__(self, registry: Optional[ToolRegistry] = None):
210210
self._signing_key: Optional[str] = None
211211
self._payer_private_key: Optional[str] = None
212212
self._rpc_url: Optional[str] = None
213+
self._platform_fee_bps: Optional[int] = None
214+
self._referral_account: Optional[str] = None
213215

214216
def get_schema(self) -> Dict[str, Any]:
215217
return {
@@ -250,6 +252,9 @@ def configure(self, config: Dict[str, Any]) -> None:
250252
self._payer_private_key = tool_cfg.get("payer_private_key")
251253
# RPC URL for sending transactions (Helius recommended for priority fees)
252254
self._rpc_url = tool_cfg.get("rpc_url")
255+
# Platform fee configuration (uses referralAccount for auto ATA creation)
256+
self._platform_fee_bps = tool_cfg.get("platform_fee_bps")
257+
self._referral_account = tool_cfg.get("referral_account")
253258

254259
async def execute( # pragma: no cover
255260
self,
@@ -302,6 +307,8 @@ async def execute( # pragma: no cover
302307
user_public_key=public_key,
303308
slippage_bps=slippage_bps if slippage_bps > 0 else None,
304309
sponsor=sponsor,
310+
platform_fee_bps=self._platform_fee_bps,
311+
referral_account=self._referral_account,
305312
)
306313

307314
if not order_result.success:

sakit/solana_dflow_swap.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Enables fast token swaps using DFlow's Swap API with a Solana keypair.
44
DFlow offers faster swaps compared to Jupiter Ultra with similar liquidity.
55
6-
Note: Platform fees are not supported. Use Jupiter Ultra (solana_ultra) if you
7-
need to collect fees on swaps.
6+
Supports platform fee collection via referralAccount - DFlow auto-creates the
7+
required token accounts to receive fees in the output token.
88
"""
99

1010
import base64
@@ -80,6 +80,8 @@ def __init__(self, registry: Optional[ToolRegistry] = None):
8080
self._private_key: Optional[str] = None
8181
self._payer_private_key: Optional[str] = None
8282
self._rpc_url: Optional[str] = None
83+
self._platform_fee_bps: Optional[int] = None
84+
self._referral_account: Optional[str] = None
8385

8486
def get_schema(self) -> Dict[str, Any]:
8587
return {
@@ -113,6 +115,9 @@ def configure(self, config: Dict[str, Any]) -> None:
113115
self._private_key = tool_cfg.get("private_key")
114116
self._payer_private_key = tool_cfg.get("payer_private_key")
115117
self._rpc_url = tool_cfg.get("rpc_url") or DEFAULT_RPC_URL
118+
# Platform fee configuration (uses referralAccount for auto ATA creation)
119+
self._platform_fee_bps = tool_cfg.get("platform_fee_bps")
120+
self._referral_account = tool_cfg.get("referral_account")
116121

117122
async def execute(
118123
self,
@@ -146,6 +151,8 @@ async def execute(
146151
user_public_key=user_pubkey,
147152
slippage_bps=slippage_bps if slippage_bps > 0 else None,
148153
sponsor=sponsor,
154+
platform_fee_bps=self._platform_fee_bps,
155+
referral_account=self._referral_account,
149156
)
150157

151158
if not order_result.success:

tests/test_privy_dflow_swap_tool.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def test_configure_sets_credentials(self):
6767
"signing_key": "test_signing_key",
6868
"payer_private_key": "payer_key",
6969
"rpc_url": "https://custom-rpc.com",
70+
"platform_fee_bps": 50,
71+
"referral_account": "RefAcct123",
7072
}
7173
}
7274
}
@@ -78,6 +80,8 @@ def test_configure_sets_credentials(self):
7880
assert tool._signing_key == "test_signing_key"
7981
assert tool._payer_private_key == "payer_key"
8082
assert tool._rpc_url == "https://custom-rpc.com"
83+
assert tool._platform_fee_bps == 50
84+
assert tool._referral_account == "RefAcct123"
8185

8286

8387
class TestPrivyDFlowSwapToolExecute:

tests/test_solana_dflow_swap_tool.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ def test_configure_sets_credentials(self):
7171
"private_key": "test_private_key",
7272
"payer_private_key": "payer_key",
7373
"rpc_url": "https://custom-rpc.com",
74+
"platform_fee_bps": 50,
75+
"referral_account": "RefAcct123",
7476
}
7577
}
7678
}
@@ -80,6 +82,8 @@ def test_configure_sets_credentials(self):
8082
assert tool._private_key == "test_private_key"
8183
assert tool._payer_private_key == "payer_key"
8284
assert tool._rpc_url == "https://custom-rpc.com"
85+
assert tool._platform_fee_bps == 50
86+
assert tool._referral_account == "RefAcct123"
8387

8488
def test_configure_uses_default_rpc_url(self):
8589
"""Should use default RPC URL when not provided."""

0 commit comments

Comments
 (0)