# Elybroker Investment Accounts Integration Open investment accounts for your own users on Elysium (chain id 99901). Each account is an NFT with its own ERC 6551 wallet that holds stock tokens, funds and HYPE. Whoever holds the NFT controls the wallet. ## Contracts (Elysium 99901) | Contract | Address | | --- | --- | | Elybroker Accounts (NFT) | `0x0ef148BC47B18E5C93314Da76931860175d4bC2E` | | ERC 6551 registry | `0xE272B47AF5d8de38E7D09c048a81480290478193` | | Account implementation | `0xEC570541DeE69540F4D438093Ed4f8f925aeFE35` | | USDC (6 decimals) | `0xb47c4c8f73f009cc0c0d3f92b388d13e293f0b65` | ABIs in this folder: `ElyBrokerAccounts.abi.json`, `InvestAccountWallet.abi.json`. ## Gas The accounts contract has no owner and no fees. Your app or your user calls it directly and pays the network gas. Elybrokers does not sponsor gas for third party accounts. To run your users signature free with sponsored gas from your own prepaid balance, apply at https://elybroker.space/developers/gasless. ## Daily sponsorship limit Approved gasless teams choose how many transactions they sponsor each day, from 1 up to the platform maximum of 500. Read usage with `GET /v1/usage` and change the limit with `POST /v1/settings` and body `{ "dailyOpCap": 200 }`, both with `Authorization: Bearer `. Once the limit is reached, further operations answer 429 until the next UTC day. The same setting is on https://elybroker.space/developers/gasless. ## Account trading limit On elybroker.space the account wallet approves the gasless router for a limit the user picks (Set limit, Use full balance, or Revoke). Gasless orders can never spend more than that limit, and never more than what the user deposited into the account. ## Flow 1. Open an account: `open()` mints to the caller, `openFor(to)` mints to another address. Read the wallet from the `AccountOpened(id, owner, wallet)` event or `walletOf(id)`. 2. Deposit: a plain ERC 20 `transfer` (or HYPE send) to the account wallet. 3. Act from the account: the NFT holder calls `executeCall(to, value, data)` on the account wallet. 4. Withdraw: `executeTokenTransfer(token, to, amount)` on the account wallet. ## Bounded allowances Never approve an unlimited allowance. Approve the swap router for the exact trade amount, or for a limit the user chooses (for example "let gasless orders spend up to 500 USDC"), and skip the approval when the current allowance already covers the trade. Show users what is approved and give them a revoke button (`approve(router, 0)`). A bounded allowance caps what anyone could ever pull, even if a relayer key leaked. ```ts async function ensureAllowance(token, amount, userLimit = 0n) { const current = await pub.readContract({ address: token, abi: erc20Abi, functionName: "allowance", args: [wallet, ROUTER] }); if (current >= amount) return; const target = userLimit > amount ? userLimit : amount; const approve = encodeFunctionData({ abi: erc20Abi, functionName: "approve", args: [ROUTER, target] }); await user.writeContract({ chain, account: me, address: wallet, abi: walletAbi, functionName: "executeCall", args: [token, 0n, approve] }); } ``` ## Buy `ensureAllowance(USDC, amount)`, then `executeCall(ROUTER, 0, swapCalldata)` swapping USDC into the stock token. The stock lands in the account wallet. ## Sell `ensureAllowance(STOCK, amount)`, then `executeCall(ROUTER, 0, swapCalldata)` swapping the stock token into USDC. Proceeds stay in the account wallet until withdrawn. Stock tokens use 18 decimals. ## Notes - Pin chain 99901 on every write and check the connected wallet is on 99901 before signing. - Stock tokens are issued by EQX Assets (Jersey) Limited, which can pause or burn them.