2:I[91610,["538","static/chunks/app/docs/integration/page-087236117f0b6feb.js"],"CodeBlock"] 4:I[75001,[],""] 5:I[9596,[],""] 6:I[83453,["575","static/chunks/575-5a246ccadcf411fa.js","418","static/chunks/418-f3b6d2f154485d8f.js","998","static/chunks/app/docs/layout-c4230139aed5d08b.js"],"default",1] 7:I[5520,["575","static/chunks/575-5a246ccadcf411fa.js","913","static/chunks/913-95a4bf8751887fd7.js","319","static/chunks/319-a605e396582267ab.js","114","static/chunks/114-54f34015d309a9f8.js","654","static/chunks/654-8e46d05deaba89c2.js","395","static/chunks/395-2e55d845c3f0b2f3.js","185","static/chunks/app/layout-0fe9fc7be6bfdac9.js"],"Providers"] 3:T418,const [account] = await wallet.getAddresses(); // 1 — Approve spender (allowance of 1,500 USDG) await wallet.writeContract({ account, address: USDG, abi: erc20Abi, functionName: "approve", args: [EXECUTOR, parseUnits("1500", 6)], }); // 2 — Place limit buy with dynamic slippage await wallet.writeContract({ account, address: EXECUTOR, abi: executorAbi, functionName: "placeOrder", args: [ USDG, TSLA, TSLA_FEED, parseUnits("1500", 6), // amountIn minAmountOut, // slippage guard 262_00000000n, // trigger: ≤ $262 (Chainlink decimals 8) 0, // triggerDir: 0 = BELOW 0, // orderType: 0 = LIMIT 0n, 1, 0n, // interval, runs, expiry 0n, 0n, // windowStart, windowEnd — set both to the // next NYSE open (+30 min) for an at-open order 0, 0, // gapMode NONE — or (1, -100) to fire // at a ≥1% pool discount vs the feed ], });0:["oSNFCr-VaZMgs1L9AoMiI",[[["",{"children":["docs",{"children":["integration",{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],["",{"children":["docs",{"children":["integration",{"children":["__PAGE__",{},[["$L1",[["$","h1",null,{"className":"mb-3 font-display text-3xl font-bold tracking-tight text-cream","children":"Integration Guide"}],["$","p",null,{"className":"mb-8 text-base leading-relaxed text-muted","children":"Place a limit order or DCA plan from your own dApp in minutes. Approve, calculate slippage, submit order, and watch execution events."}],["$","h2",null,{"className":"mb-3 mt-10 font-display text-xl font-semibold text-cream","children":"1 · Clients Setup (Viem vs Ethers.js)"}],["$","div",null,{"className":"mb-5 rounded-xl border p-4 text-sm leading-relaxed border-neon/30 bg-neon/5 text-cream/90","children":"Use the client library that best fits your stack. Below is client initialization code for both Viem and Ethers.js:"}],["$","$L2",null,{"code":"import { createPublicClient, createWalletClient, custom, http, parseAbi, parseUnits } from \"viem\";\n\nexport const robinhoodChain = {\n id: 4663,\n name: \"Robinhood Chain\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: { default: { http: [\"https://rpc.mainnet.chain.robinhood.com\"] } },\n};\n\nconst publicClient = createPublicClient({ chain: robinhoodChain, transport: http() });\nconst wallet = createWalletClient({ chain: robinhoodChain, transport: custom(window.ethereum) });\n\nconst EXECUTOR = \"0x…\"; // your deployment\nconst USDG = \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\"; // 6 decimals!\nconst TSLA = \"0x322F0929c4625eD5bAd873c95208D54E1c003b2d\";\nconst TSLA_FEED = \"0x…\"; // from docs.chain.link","title":"setup-viem.ts"}],["$","div",null,{"className":"mt-4"}],["$","$L2",null,{"code":"import { ethers } from \"ethers\";\n\nconst provider = new ethers.providers.Web3Provider(window.ethereum);\nconst signer = provider.getSigner();\n\nconst EXECUTOR_ADDRESS = \"0x...\";\nconst USDG_ADDRESS = \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\";\n\nconst EXECUTOR_ABI = [\n \"function placeOrder(address tokenIn, address tokenOut, address priceFeed, uint256 amountIn, uint256 minAmountOut, int256 triggerPrice, uint8 triggerDir, uint8 orderType, uint64 interval, uint32 runs, uint64 expiry, uint64 windowStart, uint64 windowEnd, uint8 gapMode, int32 triggerGapBps) external returns (uint256 id)\",\n \"function cancelOrder(uint256 id) external\",\n];\nconst ERC20_ABI = [\"function approve(address spender, uint256 value) returns (bool)\"];\n\nconst executorContract = new ethers.Contract(EXECUTOR_ADDRESS, EXECUTOR_ABI, signer);\nconst usdgContract = new ethers.Contract(USDG_ADDRESS, ERC20_ABI, signer);","title":"setup-ethers.js"}],["$","h2",null,{"className":"mb-3 mt-10 font-display text-xl font-semibold text-cream","children":"2 · Calculating Slippage Out Off-chain"}],["$","p",null,{"className":"mb-4 text-sm leading-relaxed text-muted","children":["Instead of passing ",["$","code",null,{"className":"rounded bg-white/10 px-1.5 py-0.5 text-[13px] text-cream","children":"0"}]," as the slippage protection (which exposes user swaps to frontrunning or high pool price impact), query the Uniswap V2 Router and deduct a toll (e.g. 0.5% or 1% slippage):"]}],["$","$L2",null,{"code":"// Query Uniswap V2 Router to estimate stock output and apply 0.5% slippage tolerance\nconst routerAbi = parseAbi([\n \"function getAmountsOut(uint256 amountIn, address[] calldata path) view returns (uint256[] memory amounts)\",\n]);\nconst UNISWAP_V2_ROUTER = \"0x89e5db8b5aa49aa85ac63f691524311aeb649eba\";\n\nconst expectedAmounts = await publicClient.readContract({\n address: UNISWAP_V2_ROUTER,\n abi: routerAbi,\n functionName: \"getAmountsOut\",\n args: [parseUnits(\"1500\", 6), [USDG, TSLA]],\n});\n\nconst expectedTslaOut = expectedAmounts[1];\n// Compute minAmountOut (expectedTslaOut * 99.5% = expectedTslaOut * 995 / 1000)\nconst minAmountOut = (expectedTslaOut * 995n) / 1000n;","language":"javascript","title":"calculate-slippage.ts"}],["$","h2",null,{"className":"mb-3 mt-10 font-display text-xl font-semibold text-cream","children":"3 · Approve + Place Order"}],["$","p",null,{"className":"mb-4 text-sm leading-relaxed text-muted","children":"Call approve first, then submit the order parameter struct to the contract executor:"}],["$","$L2",null,{"code":"$3","title":"place-order-viem.ts"}],["$","div",null,{"className":"mt-4"}],["$","$L2",null,{"code":"// 1 — Approve USDG spend (1,500 USDG)\nconst approveTx = await usdgContract.approve(EXECUTOR_ADDRESS, ethers.utils.parseUnits(\"1500\", 6));\nawait approveTx.wait();\n\n// 2 — Place limit order\nconst placeTx = await executorContract.placeOrder(\n USDG_ADDRESS, TSLA, TSLA_FEED,\n ethers.utils.parseUnits(\"1500\", 6), // amountIn (USDG decimals 6)\n minAmountOutEthers, // minAmountOut (slippage-adjusted stock token)\n 26200000000, // triggerPrice: $262.00 (8 decimals)\n 0, // triggerDir: BELOW\n 0, // orderType: LIMIT\n 0, 1, 0, // interval, runs, expiry\n 0, 0, // windowStart, windowEnd (0 = anytime)\n 0, 0 // gapMode, triggerGapBps (0 = no gap trigger)\n);\nawait placeTx.wait();","title":"place-order-ethers.js"}],["$","div",null,{"className":"mb-5 rounded-xl border p-4 text-sm leading-relaxed border-gold/40 bg-gold/10 text-gold","children":[["$","strong",null,{"children":"USDG is 6 decimals"}]," while stock tokens are 18. Ensure you use ",["$","code",null,{"className":"rounded bg-white/10 px-1.5 py-0.5 text-[13px] text-cream","children":"parseUnits(val, 6)"}]," when setting amountIn for USDG tokens and 18 decimals for stock outputs."]}],["$","h2",null,{"className":"mb-3 mt-10 font-display text-xl font-semibold text-cream","children":"4 · Cancelling Orders"}],["$","p",null,{"className":"mb-4 text-sm leading-relaxed text-muted","children":"Only the order's owner can cancel it. Cancelling releases no funds (as funds stay in the owner's wallet) but immediately invalidates the order's active execution eligibility:"}],["$","$L2",null,{"code":"// Cancel order #42 using viem\nawait wallet.writeContract({\n account,\n address: EXECUTOR,\n abi: executorAbi,\n functionName: \"cancelOrder\",\n args: [42n],\n});","title":"cancel-order.ts"}],["$","h2",null,{"className":"mb-3 mt-10 font-display text-xl font-semibold text-cream","children":"5 · Listen for Execution"}],["$","$L2",null,{"code":"// Listen to execution logs\npublicClient.watchContractEvent({\n address: EXECUTOR,\n abi: executorAbi,\n eventName: \"OrderExecuted\",\n onLogs: (logs) => {\n for (const log of logs) {\n console.log(`order #${log.args.id} filled: ${log.args.amountOut} out`);\n }\n },\n});","title":"watch-fills.ts"}],["$","h2",null,{"className":"mb-3 mt-10 font-display text-xl font-semibold text-cream","children":"Reading Prices & Balances Correctly"}],["$","$L2",null,{"code":"const feedAbi = parseAbi([\n \"function latestRoundData() view returns (uint80, int256, uint256, uint256, uint80)\",\n]);\nconst stockAbi = parseAbi([\n \"function balanceOf(address) view returns (uint256)\",\n \"function uiMultiplier() view returns (uint256)\",\n]);\n\n// Chainlink price — 8 decimals, ALREADY multiplier-adjusted (total return)\nconst [, answer] = await publicClient.readContract({\n address: TSLA_FEED, abi: feedAbi, functionName: \"latestRoundData\",\n});\nconst priceUsd = Number(answer) / 1e8;\n\n// share-equivalent balance (ERC-8056)\nconst [raw, multiplier] = await Promise.all([\n publicClient.readContract({ address: TSLA, abi: stockAbi, functionName: \"balanceOf\", args: [account] }),\n publicClient.readContract({ address: TSLA, abi: stockAbi, functionName: \"uiMultiplier\" }),\n]);\nconst shares = (raw * multiplier) / 10n ** 18n;","title":"reads.ts"}],["$","div",null,{"className":"mb-5 rounded-xl border p-4 text-sm leading-relaxed border-neon/30 bg-neon/5 text-cream/90","children":[["$","strong",null,{"children":"The multiplier rule:"}]," Chainlink stock feeds on Robinhood Chain are total-return (dividends reinvested via"," ",["$","code",null,{"className":"rounded bg-white/10 px-1.5 py-0.5 text-[13px] text-cream","children":"uiMultiplier"}],"). Apply the multiplier to"," ",["$","em",null,{"children":"balances"}]," (",["$","code",null,{"className":"rounded bg-white/10 px-1.5 py-0.5 text-[13px] text-cream","children":"balanceOf × uiMultiplier / 1e18"}],"), never to the feed price. Applying it twice overstates values."]}]],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","docs","children","integration","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[null,["$","$L6",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","docs","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}],"params":{}}]],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/f55723d0ee21179d.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","className":"__variable_f367f3 __variable_dd5b2f","children":["$","body",null,{"className":"font-sans","children":["$","$L7",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]}]],null],null],["$L8",null]]]] 8:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"Longbow Docs — Integration Guide"}],["$","meta","3",{"name":"description","content":"Wall Street closes, the chain doesn't. Longbow tracks the gap between on-chain stock prices and real quotes on Robinhood Chain — non-custodial limit orders & DCA, keeper-executed through Uniswap V2. Nock. Draw. Loose."}],["$","meta","4",{"property":"og:title","content":"Longbow — Wall Street closes. The chain doesn't."}],["$","meta","5",{"property":"og:description","content":"The gap terminal for tokenized stocks: on-chain price vs real quote, live — with non-custodial limit & DCA orders keepers execute through Uniswap V2."}],["$","meta","6",{"property":"og:image","content":"https://longbowtrade.xyz/brand/og.png"}],["$","meta","7",{"property":"og:image:width","content":"1200"}],["$","meta","8",{"property":"og:image:height","content":"630"}],["$","meta","9",{"property":"og:image:alt","content":"Longbow"}],["$","meta","10",{"name":"twitter:card","content":"summary_large_image"}],["$","meta","11",{"name":"twitter:site","content":"@longbowtrade"}],["$","meta","12",{"name":"twitter:title","content":"Longbow — Wall Street closes. The chain doesn't."}],["$","meta","13",{"name":"twitter:description","content":"The gap terminal for tokenized stocks: on-chain price vs real quote, live — with non-custodial limit & DCA orders keepers execute through Uniswap V2."}],["$","meta","14",{"name":"twitter:image","content":"https://longbowtrade.xyz/brand/og.png"}],["$","link","15",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"48x48"}],["$","link","16",{"rel":"icon","href":"/brand/favicon.svg","type":"image/svg+xml"}],["$","link","17",{"rel":"icon","href":"/brand/favicon-32.png","sizes":"32x32","type":"image/png"}],["$","link","18",{"rel":"icon","href":"/brand/icon-192.png","sizes":"192x192","type":"image/png"}],["$","link","19",{"rel":"apple-touch-icon","href":"/brand/apple-touch-icon.png"}]] 1:null