totalAmount of one token in iterations equal orders, one every frequency seconds, buying another token. Olympex creates each order as the strategy runs and executes it from the maker’s wallet. This guide spends 100 USDC on WETH on Polygon in 10 daily orders of 10 USDC, follows the orders, then cancels the strategy and lowers the allowance.
You need API credentials and the signing helper from Sign requests, and a wallet on Polygon that holds USDC and POL for gas. Order signatures and allowances explains what the wallet’s signature and allowance let Olympex do: read it before you run this with real funds.
Prerequisites
OLYMPEX_API_KEY_ID,OLYMPEX_SECRET_KEYandOLYMPEX_PASSPHRASEin your server’s environment, andsign-request.tssaved next to your code.- Node.js 22.18 or later, which runs
.tsfiles directly, in an ES module project (npm pkg set type=module), and ethers v6 (npm install ethers). - An RPC URL for Polygon, as
POLYGON_RPC_URL. - A wallet that is an externally owned account (EOA), with its private key in
WALLET_PRIVATE_KEY. It holds the USDC to spend and POL for its approval transactions. Smart-contract wallets (Safe, ERC-4337) can’t sign orders: only 65-byte ECDSA signatures are accepted.
Steps
1
Set up and check the chain
The snippets in these steps form one script, On Polygon the order contract is
run-dca-strategy.ts. Run it with node run-dca-strategy.ts.GET /chains returns the IDs of the chains Olympex has enabled, as integers. Check your chain there instead of hard-coding the list. Limit orders and DCA execute only on the chains in ORDER_CONTRACTS, where the Olympex order contract is deployed.0x50186B03dc7315271FB58da0d3b9f2c65A51dA76. It’s not the contractToApprove that POST /swap returns, which is for swaps.2
Resolve the tokens with GET /tokens
GET /tokens returns every token Olympex lists on a chain, with its address, symbol, name and decimals. Match tokens by address, never by symbol, and compare addresses case-insensitively: their casing varies.symbol(), for example with a suffix such as STRK_1 that tells tokens with the same symbol apart, so findToken trims it and drops a trailing _<number>.The token you spend must be an ERC-20. To spend a chain’s native token, wrap it first: WETH (0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) on Ethereum, WBNB (0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c) on BNB Chain or WPOL (0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270) on Polygon. ERC-20 tokens whose transfer and approve don’t return a boolean can’t be spent either: USDT isn’t supported as the token you sell in limit orders or DCA on Ethereum. Neither are fee-on-transfer tokens.3
Approve the order contract for totalAmount
Each order pulls its amount from the maker through the Olympex order contract. Olympex takes the execution gas out of the token bought, so the allowance covers Nothing moves when you approve or create the strategy. The allowance is the on-chain limit on what Olympex can move from the wallet: approve only what your open orders and strategies need, and never an unlimited amount.
totalAmount of the token you spend, with nothing on top.Read the wallet’s current allowance for the order contract, then approve that value plus totalAmount. The allowance is shared: every open limit order and active DCA strategy that sells the same token on the same chain draws on it. approve replaces the allowance instead of adding to it, so approving only this strategy’s amount would take it away from the others.4
Sign the token pair
The maker signs the pair once: Then sign USDC for WETH:Olympex doesn’t check the signature when you create the strategy: a wrong one makes execution fail later, which the self-check in
keccak256(abi.encodePacked(maker, maker, tokenIn, tokenOut)), signed with personal_sign over its 32 raw bytes. Save this helper as sign-order-pair.ts, the same file Place a limit order uses:sign-order-pair.ts
signOrderPair prevents.The signature lets the Olympex order contract swap USDC for WETH from this wallet. It doesn’t bind an amount, price, expiry, chain or order: Olympex enforces those when it executes. It stays valid after you cancel, and it’s the same signature a limit order that sells USDC for WETH uses.5
Create the strategy with POST /dca-order/strategies
POST /dca-order/strategies stores the strategy. It starts active immediately.Olympex checks the types, the required fields and that each address is a valid EVM address. It doesn’t check the other rules in this table or the pair signature: a strategy that breaks one is created, and its orders can’t execute. Check them before you send the request. Other fields in the schema are set by Olympex; don’t send them.
Response
id you send. If the call times out or fails with a 5xx, don’t send it again: the strategy may exist. GET /dca-order/strategies lists your strategies newest first, so look there first:accountTo and status only. It ignores any other query parameter, such as chainId, so a misspelt filter returns every strategy. Send each parameter once: a parameter sent twice returns an empty array.6
Follow the orders
Olympex places the orders one A response from the orders endpoint, after the first order ran:Route these
frequency apart. A new strategy has no orders until its first order is scheduled. Olympex doesn’t notify you when an order changes, so check on your own schedule:GET /dca-order/strategies/{id}returns the strategy’sstatus, without its orders.finishedmeans every order ran.GET /dca-order/strategies/{id}/ordersreturns the orders Olympex has created so far, oldest first.
Treat any other value as not final.
Response
GET requests through your retry wrapper: GET is safe to repeat.7
Cancel the strategy
Send Sending the same
{"status":"cancelled"} to PATCH /dca-order/strategies/{id}. Cancelling stops new orders and can’t be undone. Orders that Olympex already created are read-only: the next step lowers the allowance so they can’t spend what you release.PATCH again is safe.8
Lower the allowance
Cancelling doesn’t touch your allowance, and the pair signature stays valid. Lower the allowance by the part of If an order that was
totalAmount the strategy won’t spend, and keep what your other open orders need:executing ends in error, lower the allowance by its amount too. When a strategy finishes, its orders have used their share of the allowance. To stop everything that spends USDC on Polygon at once, set the allowance to 0: that also stops every limit order that sells USDC there.Verify
Run these at the end of the script:- The strategy is
cancelled. - It appears in the strategy list filtered by the checksummed maker and
status=cancelled. With the maker in lowercase, the list is empty:accountTomatches case-sensitively. - Once no order is
executing, the allowance is back to its value before step 3: executed orders used their part, and you released the rest.
Common pitfalls
What’s next
DCA
Strategies, orders, price bounds and statuses.
Order signatures and allowances
What the signature and the allowance let Olympex do.
Place a limit order
Sell a token when the market reaches your price.
Create a DCA strategy
Every field of
POST /dca-order/strategies.