Skip to main content

Configuration

The widget is configured with attributes on the <treasures-swap> element. All of them are optional. An unknown or invalid value is ignored, never an error: the widget falls back to its default for that option.

Attributes​

AttributeValueWhat it does
integratorintg_…Your integrator ID. It credits trades to your organisation and charges your widget fee if you set one. Left out, the widget still works, credited to no one. See Integrator ID and Fees
stockA ticker, such as AAPLThe stock the widget opens on
sidebuy (default) or sellThe side the widget opens on
amountA number, such as 100An amount to start with: dollars on a buy, shares on a sell. An amount under 0.00001 is ignored
stocksTickers, comma-separated, such as AAPL,TSLA,NVDAOffer only these stocks. A stock outside the list opens on the list's first
lockAny of stock, side, amount, comma-separatedWhat the user can't change. See Locks
chainsAny of sol, eth, base, arbitrum, robinhood, bnb, comma-separatedTrade only on these chains
connectevm or solanaThe only wallet type your users can connect. See Connecting Wallets. Left out, users can connect both
wallethostUse the wallets your page already connected instead of the widget's own connect. See Use your page's wallet
themelight or darkThe widget's theme. Left out, it follows the user's system. See Customization
paletteJSONYour colours, corners, font and shadow. See Customization
heightPixels, such as 700A fixed height: the box stays that size and scrolls inside when its content is taller. At least 510. Left out, the box grows to fit its content

Locks​

lock takes away the controls for what you have already decided, so you can build a focused box such as "Buy Tesla":

LockEffectNeeds
stockNo stock pickerstock set
sideNo Buy/Sell switchNothing: without side it holds the box on buy
amountThe amount is fixedamount set. It holds the side too, since the amount is dollars on a buy and shares on a sell

A lock whose option is not set is ignored. A locked stock that can't be traded right now says so, instead of offering another stock.

<!-- A "Buy Tesla" box: $100 to start, stock and side fixed. -->
<treasures-swap stock="TSLA" side="buy" amount="100" lock="stock,side"></treasures-swap>

Changing options at runtime​

Change an attribute and the widget follows. Most options change in place; a few reload the widget.

OptionsWhen you change one
stock, side, amount, stocks, lockApplied in place, keeping what the user typed. A new side clears the amount, since dollars become shares. A change made while the user is reviewing a trade waits until they close the review
theme, paletteApplied in place, at once
heightApplied at once
integrator, wallet, chains, connectThe widget reloads, because they shape quotes and the wallet connection

Setting the same values again does nothing, so re-rendering the element from React or Vue is safe.

// Your page's own stock list drives the widget, keeping what the user typed:
document.querySelector('treasures-swap').setAttribute('stock', 'NVDA');