@xochi/widget 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/LICENSE +21 -0
- package/README.md +420 -2
- package/THIRD_PARTY_NOTICES.txt +44 -0
- package/dist/ConfiguratorApp.js +19 -0
- package/dist/EmbedApp.js +57 -0
- package/dist/assets/MonaspaceArgon-Bold-D9kWRRK5.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Light-Dt_6qXbW.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Medium-B1gMZwrU.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Regular-RS-2TGNg.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-SemiBold-PYusZXE_.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Italic-C9u9eioB.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Light-CJkxpyfT.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Medium-DCChELAx.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Regular-BZtV1wRa.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Bold-KacFhGOf.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Medium-Dqqg-cnL.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Regular-BRsdKART.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-SemiBold-DNjPl3uE.woff2 +0 -0
- package/dist/assets/alipay-3tx9-HPp.svg +1 -0
- package/dist/assets/arb-CCfLcB_X.svg +7 -0
- package/dist/assets/arc-Dy98eSCd.svg +10 -0
- package/dist/assets/aztec-DiLp9qTG.svg +4 -0
- package/dist/assets/base-Ch0ino36.svg +4 -0
- package/dist/assets/cashapp-lOg0DIt8.svg +1 -0
- package/dist/assets/chains/arbitrum.svg.js +4 -0
- package/dist/assets/chains/arc.svg.js +4 -0
- package/dist/assets/chains/aztec.svg.js +4 -0
- package/dist/assets/chains/base.svg.js +4 -0
- package/dist/assets/chains/ethereum.svg.js +4 -0
- package/dist/assets/chains/gnosis.png.js +4 -0
- package/dist/assets/chains/index.js +31 -0
- package/dist/assets/chains/optimism.svg.js +4 -0
- package/dist/assets/chains/polygon.svg.js +4 -0
- package/dist/assets/chains/robinhood.svg.js +4 -0
- package/dist/assets/chains/tron.svg.js +4 -0
- package/dist/assets/chains/xochi.svg.js +4 -0
- package/dist/assets/dai-XuyZLceZ.png +0 -0
- package/dist/assets/defillama-BU037Unq.svg +1 -0
- package/dist/assets/defillama.svg.js +4 -0
- package/dist/assets/eth-Dvbng9UB.svg +8 -0
- package/dist/assets/eurc-NI9zNgOQ.png +0 -0
- package/dist/assets/eure-BH9vpwcv.png +0 -0
- package/dist/assets/gnosis-fRzAZQFj.png +0 -0
- package/dist/assets/mercadopago-gjsFb6F7.svg +1 -0
- package/dist/assets/monzo-B9XD4bL5.png +0 -0
- package/dist/assets/monzo-SZnIdUKN.svg +1 -0
- package/dist/assets/monzo-dark-Bwzg90UC.png +0 -0
- package/dist/assets/n26-cANcjY2T.svg +1 -0
- package/dist/assets/op-DF67SbB6.png +0 -0
- package/dist/assets/optimism-B3cTNxEQ.svg +4 -0
- package/dist/assets/paypal-D8xqXEtN.svg +1 -0
- package/dist/assets/pol-uLmSo2O8.svg +3 -0
- package/dist/assets/rails/SOURCES.md +50 -0
- package/dist/assets/rails/alipay.svg.js +4 -0
- package/dist/assets/rails/cashapp.svg.js +4 -0
- package/dist/assets/rails/index.js +59 -0
- package/dist/assets/rails/mercadopago.svg.js +4 -0
- package/dist/assets/rails/monzo-dark.png.js +4 -0
- package/dist/assets/rails/monzo.png.js +4 -0
- package/dist/assets/rails/monzo.svg.js +4 -0
- package/dist/assets/rails/n26.svg.js +4 -0
- package/dist/assets/rails/paypal.svg.js +4 -0
- package/dist/assets/rails/revolut-dark.png.js +4 -0
- package/dist/assets/rails/revolut.png.js +4 -0
- package/dist/assets/rails/revolut.svg.js +4 -0
- package/dist/assets/rails/venmo.svg.js +4 -0
- package/dist/assets/rails/wise-dark.png.js +4 -0
- package/dist/assets/rails/wise.png.js +4 -0
- package/dist/assets/rails/wise.svg.js +4 -0
- package/dist/assets/rails/xmoney.svg.js +4 -0
- package/dist/assets/rails/zelle.svg.js +4 -0
- package/dist/assets/raxol-86FmC34h.png +0 -0
- package/dist/assets/revolut-CiBtyALA.png +0 -0
- package/dist/assets/revolut-D7qr5Vzs.svg +1 -0
- package/dist/assets/revolut-dark-RQdWGM_p.png +0 -0
- package/dist/assets/robinhood-DgdGTQ1I.svg +8 -0
- package/dist/assets/tokens/arb.svg.js +4 -0
- package/dist/assets/tokens/dai.png.js +4 -0
- package/dist/assets/tokens/eth.svg.js +4 -0
- package/dist/assets/tokens/eurc.png.js +4 -0
- package/dist/assets/tokens/eure.png.js +4 -0
- package/dist/assets/tokens/index.js +36 -0
- package/dist/assets/tokens/op.png.js +4 -0
- package/dist/assets/tokens/pol.svg.js +4 -0
- package/dist/assets/tokens/raxol.png.js +4 -0
- package/dist/assets/tokens/usdc.png.js +4 -0
- package/dist/assets/tokens/usdg.png.js +4 -0
- package/dist/assets/tokens/usdt.png.js +4 -0
- package/dist/assets/tokens/wbtc.png.js +4 -0
- package/dist/assets/tokens/wsteth.png.js +4 -0
- package/dist/assets/tokens/zchf.png.js +4 -0
- package/dist/assets/tron-Dtumyzha.svg +4 -0
- package/dist/assets/usdc-UHSd0FoM.png +0 -0
- package/dist/assets/usdg-Cd5nCzbC.png +0 -0
- package/dist/assets/usdt-3G3YdPq8.png +0 -0
- package/dist/assets/venmo-CMHeCn-D.svg +1 -0
- package/dist/assets/wbtc-CV8uE44Q.png +0 -0
- package/dist/assets/wise-BUOflsWL.svg +1 -0
- package/dist/assets/wise-JLpDvCdq.png +0 -0
- package/dist/assets/wise-dark-_Q8pbCom.png +0 -0
- package/dist/assets/wsteth-BamwtTCR.png +0 -0
- package/dist/assets/xmoney-CwY9KVlD.svg +1 -0
- package/dist/assets/xochi-DL2f8G4R.svg +4 -0
- package/dist/assets/zchf-BLBNdTGJ.png +0 -0
- package/dist/assets/zelle-t15cG4SB.svg +1 -0
- package/dist/browser.js +4 -0
- package/dist/components/AccountChip.js +29 -0
- package/dist/components/ActivityFeed.js +710 -0
- package/dist/components/AssetsStrip.js +133 -0
- package/dist/components/AuthorizedAgents.js +197 -0
- package/dist/components/Chevron.js +22 -0
- package/dist/components/ErrorDisplay.js +66 -0
- package/dist/components/InfoButton.js +27 -0
- package/dist/components/IntentTimeline.js +202 -0
- package/dist/components/LinksSignIn.js +26 -0
- package/dist/components/MobileSigningBanner.js +44 -0
- package/dist/components/PrivacyBars.js +44 -0
- package/dist/components/PrivacyPanel.js +99 -0
- package/dist/components/QuoteDetails.js +327 -0
- package/dist/components/ReceiptCommand.js +46 -0
- package/dist/components/SessionReloadBanner.js +19 -0
- package/dist/components/SolverRace.js +62 -0
- package/dist/components/StealthClaims.js +179 -0
- package/dist/components/SwapFlowModal.js +398 -0
- package/dist/components/Toast.js +40 -0
- package/dist/components/TokenIcon.js +21 -0
- package/dist/components/TokenSearchModal.js +331 -0
- package/dist/components/TransactionPreview.js +207 -0
- package/dist/components/WalletProvider.js +41 -0
- package/dist/components/WrapModal.js +192 -0
- package/dist/components/swap-flow/CantonEscrowPanel.js +28 -0
- package/dist/components/swap-flow/CantonEscrowStatus.js +160 -0
- package/dist/components/swap-flow/DepositInstructions.js +156 -0
- package/dist/components/swap-flow/QrCode.js +22 -0
- package/dist/components/swap-flow/SwapResult.js +323 -0
- package/dist/components/swap-flow/depositScreen.js +36 -0
- package/dist/components/widgetTabsContext.js +17 -0
- package/dist/config.js +132 -0
- package/dist/configurator-model.js +71 -0
- package/dist/configurator.js +11 -0
- package/dist/constants.js +53 -0
- package/dist/hooks/applyTheme.js +10 -0
- package/dist/hooks/useAgentRegistry.js +28 -0
- package/dist/hooks/useAgentStream.js +89 -0
- package/dist/hooks/useCantonEscrow.js +89 -0
- package/dist/hooks/useCapabilities.js +86 -0
- package/dist/hooks/useEmbedLook.js +23 -0
- package/dist/hooks/useFocusTrap.js +44 -0
- package/dist/hooks/useIntent.js +435 -0
- package/dist/hooks/useIntentStatusPoll.js +71 -0
- package/dist/hooks/useIntentStream.js +95 -0
- package/dist/hooks/useLocalActivity.js +114 -0
- package/dist/hooks/useLocalSends.js +15 -0
- package/dist/hooks/useLocalStorage.js +26 -0
- package/dist/hooks/useOrderHistory.js +307 -0
- package/dist/hooks/usePermit.js +131 -0
- package/dist/hooks/usePrices.js +49 -0
- package/dist/hooks/usePublicBalances.js +186 -0
- package/dist/hooks/useRampSummaries.js +19 -0
- package/dist/hooks/useRecipientBalance.js +98 -0
- package/dist/hooks/useSettlements.js +33 -0
- package/dist/hooks/useStealth.js +324 -0
- package/dist/hooks/useStealthClaim.js +183 -0
- package/dist/hooks/useStealthScanner.js +259 -0
- package/dist/hooks/useTheme.js +48 -0
- package/dist/hooks/useTierInfo.js +20 -0
- package/dist/hooks/useTrustScore.js +16 -0
- package/dist/hooks/useWalletSession.js +70 -0
- package/dist/hooks/useWrapEth.js +60 -0
- package/dist/index.js +41 -0
- package/dist/integration.js +19 -0
- package/dist/lib/activityValue.js +20 -0
- package/dist/lib/agentConnect.js +11 -0
- package/dist/lib/agentRegistry.js +83 -0
- package/dist/lib/agentStreamVerify.js +47 -0
- package/dist/lib/api.js +67 -0
- package/dist/lib/auth.js +8 -0
- package/dist/lib/authFetch.js +33 -0
- package/dist/lib/aztecTokens.js +13 -0
- package/dist/lib/balances.js +77 -0
- package/dist/lib/capabilities.js +40 -0
- package/dist/lib/claimSubmitPoll.js +63 -0
- package/dist/lib/debug.js +7 -0
- package/dist/lib/declineGuidance.js +31 -0
- package/dist/lib/displayFallbacks.js +25 -0
- package/dist/lib/eip712.js +38 -0
- package/dist/lib/errorCategory.js +200 -0
- package/dist/lib/errorReport.js +19 -0
- package/dist/lib/explorerLinks.js +30 -0
- package/dist/lib/feesLabel.js +19 -0
- package/dist/lib/glyphs.js +58 -0
- package/dist/lib/hostBridge.js +41 -0
- package/dist/lib/hostOrigin.js +52 -0
- package/dist/lib/intentAPI.js +39 -0
- package/dist/lib/linksSignIn.js +9 -0
- package/dist/lib/localActivity.js +247 -0
- package/dist/lib/localSends.js +129 -0
- package/dist/lib/mobileWallet.js +17 -0
- package/dist/lib/pairAvailability.js +29 -0
- package/dist/lib/paymentSummary.js +23 -0
- package/dist/lib/permits.js +27 -0
- package/dist/lib/priceImpact.js +101 -0
- package/dist/lib/providers.js +124 -0
- package/dist/lib/qr.js +20 -0
- package/dist/lib/quoteCost.js +34 -0
- package/dist/lib/quoteCountdown.js +24 -0
- package/dist/lib/rampHostGate.js +24 -0
- package/dist/lib/rampLifecycle.js +63 -0
- package/dist/lib/receiptCost.js +64 -0
- package/dist/lib/recipient/index.js +302 -0
- package/dist/lib/recipient/recent.js +47 -0
- package/dist/lib/recipientReceipt.js +16 -0
- package/dist/lib/reportClient.js +32 -0
- package/dist/lib/sessionExpiry.js +11 -0
- package/dist/lib/settlementAvailability.js +34 -0
- package/dist/lib/stealth.js +110 -0
- package/dist/lib/swapFlowPhase.js +52 -0
- package/dist/lib/swapStatusCopy.js +59 -0
- package/dist/lib/tradeLifecycle.js +40 -0
- package/dist/lib/tronlink.js +71 -0
- package/dist/lib/walletSession.js +87 -0
- package/dist/pages/Configurator.js +390 -0
- package/dist/pages/Trade.js +635 -0
- package/dist/pages/configurator/AllowedAssetsSection.js +98 -0
- package/dist/pages/configurator/AppearanceSection.js +44 -0
- package/dist/pages/configurator/CodeDock.js +140 -0
- package/dist/pages/configurator/DeveloperSection.js +40 -0
- package/dist/pages/configurator/IntegrationSection.js +105 -0
- package/dist/pages/configurator/LayoutSection.js +83 -0
- package/dist/pages/configurator/PolicyNote.js +7 -0
- package/dist/pages/configurator/PreviewStage.js +165 -0
- package/dist/pages/configurator/PrivacySection.js +54 -0
- package/dist/pages/configurator/RouteSection.js +211 -0
- package/dist/pages/configurator/Settings.js +35 -0
- package/dist/pages/configurator/SharedLinkBanner.js +25 -0
- package/dist/pages/configurator/SurfaceSection.js +124 -0
- package/dist/pages/configurator/WhatUsersSee.js +268 -0
- package/dist/pages/configurator/codeShown.js +8 -0
- package/dist/pages/configurator/configuratorUrl.js +33 -0
- package/dist/pages/configurator/paramsDraft.js +82 -0
- package/dist/pages/configurator/previewModel.js +10 -0
- package/dist/pages/configurator/previewQuote.js +109 -0
- package/dist/pages/configurator/routePicks.js +131 -0
- package/dist/pages/configurator/snippets.js +98 -0
- package/dist/pages/configurator/surfaceParams.js +51 -0
- package/dist/pages/configurator/useCodeCheck.js +79 -0
- package/dist/pages/configurator/useConfiguratorUrl.js +24 -0
- package/dist/pages/configurator/useMediaQuery.js +20 -0
- package/dist/pages/configurator/useParamsDraft.js +33 -0
- package/dist/pages/configurator/usePreviewFee.js +100 -0
- package/dist/pages/send/MetaAddressValue.js +28 -0
- package/dist/pages/send/Receive.js +168 -0
- package/dist/pages/send/RecentRecipients.js +23 -0
- package/dist/pages/send/RecipientChip.js +26 -0
- package/dist/pages/send/ScanRecipient.js +85 -0
- package/dist/pages/send/SendForm.js +516 -0
- package/dist/pages/send/SendPanel.js +30 -0
- package/dist/pages/send/ShieldedDisclosure.js +12 -0
- package/dist/pages/send/StealthInvite.js +27 -0
- package/dist/pages/send/addressSend.js +92 -0
- package/dist/pages/send/sendCopy.js +10 -0
- package/dist/pages/send/sendRetry.js +24 -0
- package/dist/pages/send/stealthRecipient.js +65 -0
- package/dist/pages/send/stealthSend.js +15 -0
- package/dist/pages/send/useAddressSend.js +257 -0
- package/dist/pages/send/useSendRecipient.js +61 -0
- package/dist/pages/trade/BuyPanel.js +70 -0
- package/dist/pages/trade/RampRecovery.js +41 -0
- package/dist/pages/trade/RecipientSheet.js +182 -0
- package/dist/pages/trade/Selectors.js +152 -0
- package/dist/pages/trade/SwapPanel.js +971 -0
- package/dist/pages/trade/WidgetTabs.js +109 -0
- package/dist/pages/trade/canton.js +122 -0
- package/dist/pages/trade/config.js +70 -0
- package/dist/pages/trade/embedNarrowing.js +25 -0
- package/dist/pages/trade/embedParams.js +532 -0
- package/dist/pages/trade/embedTheme.js +9 -0
- package/dist/pages/trade/orderMinimum.js +8 -0
- package/dist/pages/trade/resumeSwap.js +55 -0
- package/dist/pages/trade/settlementCopy.js +32 -0
- package/dist/pages/trade/useAmountFit.js +31 -0
- package/dist/pages/trade/useEmbedDefaults.js +18 -0
- package/dist/pages/trade/useSettlementGating.js +289 -0
- package/dist/pages/trade/useSwapAmount.js +191 -0
- package/dist/pages/trade/useSwapFlow.js +511 -0
- package/dist/pages/trade/useSwapPanel.js +475 -0
- package/dist/pages/trade/useSwapRoute.js +634 -0
- package/dist/pages/trade/useTronLinkFill.js +34 -0
- package/dist/pages/trade/zkMoney.js +46 -0
- package/dist/promiseWithResolvers.js +20 -0
- package/dist/ramp/availability/RailTiles.js +156 -0
- package/dist/ramp/availability/RampDisclosure.js +38 -0
- package/dist/ramp/availability/RampRails.js +170 -0
- package/dist/ramp/availability/model.js +207 -0
- package/dist/ramp/availability/useRampDiscovery.js +83 -0
- package/dist/ramp/offramp/CompletedPrerequisite.js +23 -0
- package/dist/ramp/offramp/OfframpActivityList.js +16 -0
- package/dist/ramp/offramp/OfframpRoute.js +222 -0
- package/dist/ramp/offramp/OfframpRouteReview.js +94 -0
- package/dist/ramp/offramp/PaymentAppSend.js +765 -0
- package/dist/ramp/offramp/localOfframps.js +101 -0
- package/dist/ramp/offramp/model.js +154 -0
- package/dist/ramp/offramp/port.js +134 -0
- package/dist/ramp/offramp/prerequisite.js +143 -0
- package/dist/ramp/offramp/useOfframp.js +505 -0
- package/dist/ramp/offramp/useOfframpRails.js +73 -0
- package/dist/ramp/peer/BuyOnramp.js +292 -0
- package/dist/ramp/peer/OnrampSteps.js +148 -0
- package/dist/ramp/peer/buyerDriver.js +461 -0
- package/dist/ramp/peer/discovery.js +231 -0
- package/dist/ramp/peer/environment.js +7 -0
- package/dist/ramp/peer/liveProvider.js +87 -0
- package/dist/ramp/peer/liveReads.js +488 -0
- package/dist/ramp/peer/maker.js +92 -0
- package/dist/ramp/peer/normalization.js +184 -0
- package/dist/ramp/peer/offramp.js +648 -0
- package/dist/ramp/peer/onramp.js +353 -0
- package/dist/ramp/peer/preview.js +52 -0
- package/dist/ramp/peer/protectedMapping.js +67 -0
- package/dist/ramp/peer/runtime.js +55 -0
- package/dist/ramp/peer/sdkMaker.js +107 -0
- package/dist/ramp/recovery/ResumeOnramp.js +153 -0
- package/dist/ramp/recovery/summaries.js +173 -0
- package/dist/ramp/route/OnrampRoute.js +255 -0
- package/dist/ramp/route/RampRouteSteps.js +148 -0
- package/dist/ramp/route/routeActivity.js +12 -0
- package/dist/ramp/route/useXochiRampDriver.js +203 -0
- package/dist/styles.css +17448 -0
- package/dist/styles.js +2 -0
- package/dist/types/ConfiguratorApp.d.ts +6 -0
- package/dist/types/EmbedApp.d.ts +2 -0
- package/dist/types/activity.js +50 -0
- package/dist/types/asset.d.ts +2 -0
- package/dist/types/assets/chains/index.d.ts +3 -0
- package/dist/types/assets/rails/index.d.ts +12 -0
- package/dist/types/assets/tokens/index.d.ts +1 -0
- package/dist/types/browser.d.ts +1 -0
- package/dist/types/components/AccountChip.d.ts +10 -0
- package/dist/types/components/ActivityFeed.d.ts +46 -0
- package/dist/types/components/AssetsStrip.d.ts +14 -0
- package/dist/types/components/AuthorizedAgents.d.ts +15 -0
- package/dist/types/components/Chevron.d.ts +16 -0
- package/dist/types/components/ErrorDisplay.d.ts +44 -0
- package/dist/types/components/InfoButton.d.ts +6 -0
- package/dist/types/components/IntentTimeline.d.ts +41 -0
- package/dist/types/components/LinksSignIn.d.ts +13 -0
- package/dist/types/components/MobileSigningBanner.d.ts +16 -0
- package/dist/types/components/PermitBadge.d.ts +17 -0
- package/dist/types/components/PrivacyBars.d.ts +12 -0
- package/dist/types/components/PrivacyPanel.d.ts +33 -0
- package/dist/types/components/QuoteDetails.d.ts +56 -0
- package/dist/types/components/RampActivityList.d.ts +14 -0
- package/dist/types/components/ReceiptCommand.d.ts +12 -0
- package/dist/types/components/SessionReloadBanner.d.ts +8 -0
- package/dist/types/components/SolverRace.d.ts +35 -0
- package/dist/types/components/StealthClaims.d.ts +51 -0
- package/dist/types/components/SwapFlowModal.d.ts +138 -0
- package/dist/types/components/Toast.d.ts +10 -0
- package/dist/types/components/TokenIcon.d.ts +17 -0
- package/dist/types/components/TokenSearchModal.d.ts +28 -0
- package/dist/types/components/TransactionPreview.d.ts +34 -0
- package/dist/types/components/WalletProvider.d.ts +12 -0
- package/dist/types/components/WrapModal.d.ts +19 -0
- package/dist/types/components/swap-flow/CantonEscrowPanel.d.ts +14 -0
- package/dist/types/components/swap-flow/CantonEscrowStatus.d.ts +30 -0
- package/dist/types/components/swap-flow/DepositInstructions.d.ts +75 -0
- package/dist/types/components/swap-flow/QrCode.d.ts +18 -0
- package/dist/types/components/swap-flow/SwapResult.d.ts +66 -0
- package/dist/types/components/swap-flow/depositScreen.d.ts +67 -0
- package/dist/types/components/widgetTabsContext.d.ts +21 -0
- package/dist/types/config.d.ts +104 -0
- package/dist/types/configurator-model.d.ts +9 -0
- package/dist/types/configurator.d.ts +3 -0
- package/dist/types/constants.d.ts +52 -0
- package/dist/types/hooks/applyTheme.d.ts +7 -0
- package/dist/types/hooks/useAgentRegistry.d.ts +13 -0
- package/dist/types/hooks/useAgentStream.d.ts +15 -0
- package/dist/types/hooks/useCantonEscrow.d.ts +40 -0
- package/dist/types/hooks/useCapabilities.d.ts +83 -0
- package/dist/types/hooks/useEmbedLook.d.ts +4 -0
- package/dist/types/hooks/useFocusTrap.d.ts +7 -0
- package/dist/types/hooks/useIntent.d.ts +156 -0
- package/dist/types/hooks/useIntentStatusPoll.d.ts +107 -0
- package/dist/types/hooks/useIntentStream.d.ts +34 -0
- package/dist/types/hooks/useLocalActivity.d.ts +22 -0
- package/dist/types/hooks/useLocalSends.d.ts +8 -0
- package/dist/types/hooks/useLocalStorage.d.ts +8 -0
- package/dist/types/hooks/useOrderHistory.d.ts +52 -0
- package/dist/types/hooks/usePermit.d.ts +84 -0
- package/dist/types/hooks/usePrices.d.ts +72 -0
- package/dist/types/hooks/usePublicBalances.d.ts +19 -0
- package/dist/types/hooks/useRampSummaries.d.ts +9 -0
- package/dist/types/hooks/useRecipientBalance.d.ts +58 -0
- package/dist/types/hooks/useSettlements.d.ts +14 -0
- package/dist/types/hooks/useStealth.d.ts +72 -0
- package/dist/types/hooks/useStealthClaim.d.ts +96 -0
- package/dist/types/hooks/useStealthScanner.d.ts +44 -0
- package/dist/types/hooks/useTheme.d.ts +29 -0
- package/dist/types/hooks/useTierInfo.d.ts +23 -0
- package/dist/types/hooks/useTrustScore.d.ts +16 -0
- package/dist/types/hooks/useWalletSession.d.ts +21 -0
- package/dist/types/hooks/useWrapEth.d.ts +21 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +8 -0
- package/dist/types/integration.d.ts +9 -0
- package/dist/types/intent.js +85 -0
- package/dist/types/lib/activityValue.d.ts +16 -0
- package/dist/types/lib/agentConnect.d.ts +23 -0
- package/dist/types/lib/agentRegistry.d.ts +47 -0
- package/dist/types/lib/agentStreamVerify.d.ts +29 -0
- package/dist/types/lib/api.d.ts +41 -0
- package/dist/types/lib/auth.d.ts +6 -0
- package/dist/types/lib/authFetch.d.ts +14 -0
- package/dist/types/lib/aztecTokens.d.ts +15 -0
- package/dist/types/lib/balances.d.ts +88 -0
- package/dist/types/lib/capabilities.d.ts +3 -0
- package/dist/types/lib/claimSubmitPoll.d.ts +114 -0
- package/dist/types/lib/debug.d.ts +13 -0
- package/dist/types/lib/declineGuidance.d.ts +55 -0
- package/dist/types/lib/displayFallbacks.d.ts +7 -0
- package/dist/types/lib/eip712.d.ts +61 -0
- package/dist/types/lib/errorCategory.d.ts +48 -0
- package/dist/types/lib/errorReport.d.ts +15 -0
- package/dist/types/lib/explorerLinks.d.ts +67 -0
- package/dist/types/lib/feesLabel.d.ts +20 -0
- package/dist/types/lib/glyphs.d.ts +52 -0
- package/dist/types/lib/hostBridge.d.ts +11 -0
- package/dist/types/lib/hostOrigin.d.ts +30 -0
- package/dist/types/lib/intentAPI.d.ts +15 -0
- package/dist/types/lib/linksSignIn.d.ts +13 -0
- package/dist/types/lib/localActivity.d.ts +135 -0
- package/dist/types/lib/localSends.d.ts +55 -0
- package/dist/types/lib/mobileWallet.d.ts +27 -0
- package/dist/types/lib/pairAvailability.d.ts +106 -0
- package/dist/types/lib/paymentSummary.d.ts +18 -0
- package/dist/types/lib/permits.d.ts +25 -0
- package/dist/types/lib/priceImpact.d.ts +165 -0
- package/dist/types/lib/providers.d.ts +14 -0
- package/dist/types/lib/qr.d.ts +19 -0
- package/dist/types/lib/quoteCost.d.ts +45 -0
- package/dist/types/lib/quoteCountdown.d.ts +34 -0
- package/dist/types/lib/rampHostGate.d.ts +15 -0
- package/dist/types/lib/rampLifecycle.d.ts +20 -0
- package/dist/types/lib/receiptCost.d.ts +64 -0
- package/dist/types/lib/recipient/index.d.ts +33 -0
- package/dist/types/lib/recipient/recent.d.ts +5 -0
- package/dist/types/lib/recipientReceipt.d.ts +25 -0
- package/dist/types/lib/reportClient.d.ts +9 -0
- package/dist/types/lib/sessionExpiry.d.ts +11 -0
- package/dist/types/lib/settlementAvailability.d.ts +61 -0
- package/dist/types/lib/stealth.d.ts +75 -0
- package/dist/types/lib/swapFlowPhase.d.ts +76 -0
- package/dist/types/lib/swapStatusCopy.d.ts +57 -0
- package/dist/types/lib/tierProgressDisplay.d.ts +35 -0
- package/dist/types/lib/tierUnlock.d.ts +25 -0
- package/dist/types/lib/tradeLifecycle.d.ts +32 -0
- package/dist/types/lib/tronlink.d.ts +62 -0
- package/dist/types/lib/walletSession.d.ts +38 -0
- package/dist/types/pages/Configurator.d.ts +25 -0
- package/dist/types/pages/Trade.d.ts +36 -0
- package/dist/types/pages/configurator/AllowedAssetsSection.d.ts +17 -0
- package/dist/types/pages/configurator/AppearanceSection.d.ts +22 -0
- package/dist/types/pages/configurator/CodeDock.d.ts +19 -0
- package/dist/types/pages/configurator/DeveloperSection.d.ts +12 -0
- package/dist/types/pages/configurator/IntegrationSection.d.ts +20 -0
- package/dist/types/pages/configurator/LayoutSection.d.ts +20 -0
- package/dist/types/pages/configurator/PolicyNote.d.ts +6 -0
- package/dist/types/pages/configurator/PreviewStage.d.ts +22 -0
- package/dist/types/pages/configurator/PrivacySection.d.ts +16 -0
- package/dist/types/pages/configurator/RouteSection.d.ts +30 -0
- package/dist/types/pages/configurator/Settings.d.ts +25 -0
- package/dist/types/pages/configurator/SharedLinkBanner.d.ts +16 -0
- package/dist/types/pages/configurator/SurfaceSection.d.ts +5 -0
- package/dist/types/pages/configurator/WhatUsersSee.d.ts +30 -0
- package/dist/types/pages/configurator/codeShown.d.ts +15 -0
- package/dist/types/pages/configurator/configuratorUrl.d.ts +38 -0
- package/dist/types/pages/configurator/paramsDraft.d.ts +32 -0
- package/dist/types/pages/configurator/previewModel.d.ts +20 -0
- package/dist/types/pages/configurator/previewQuote.d.ts +96 -0
- package/dist/types/pages/configurator/routePicks.d.ts +75 -0
- package/dist/types/pages/configurator/snippets.d.ts +23 -0
- package/dist/types/pages/configurator/surfaceParams.d.ts +9 -0
- package/dist/types/pages/configurator/useCodeCheck.d.ts +56 -0
- package/dist/types/pages/configurator/useConfiguratorUrl.d.ts +21 -0
- package/dist/types/pages/configurator/useMediaQuery.d.ts +5 -0
- package/dist/types/pages/configurator/useParamsDraft.d.ts +29 -0
- package/dist/types/pages/configurator/usePreviewFee.d.ts +74 -0
- package/dist/types/pages/send/MetaAddressValue.d.ts +9 -0
- package/dist/types/pages/send/Receive.d.ts +3 -0
- package/dist/types/pages/send/RecentRecipients.d.ts +3 -0
- package/dist/types/pages/send/RecipientChip.d.ts +4 -0
- package/dist/types/pages/send/ScanRecipient.d.ts +3 -0
- package/dist/types/pages/send/SendForm.d.ts +17 -0
- package/dist/types/pages/send/SendPanel.d.ts +19 -0
- package/dist/types/pages/send/ShieldedDisclosure.d.ts +1 -0
- package/dist/types/pages/send/StealthInvite.d.ts +1 -0
- package/dist/types/pages/send/addressSend.d.ts +62 -0
- package/dist/types/pages/send/sendCopy.d.ts +9 -0
- package/dist/types/pages/send/sendRetry.d.ts +10 -0
- package/dist/types/pages/send/stealthRecipient.d.ts +37 -0
- package/dist/types/pages/send/stealthSend.d.ts +18 -0
- package/dist/types/pages/send/useAddressSend.d.ts +61 -0
- package/dist/types/pages/send/useSendRecipient.d.ts +13 -0
- package/dist/types/pages/trade/BuyPanel.d.ts +22 -0
- package/dist/types/pages/trade/RampRecovery.d.ts +22 -0
- package/dist/types/pages/trade/RecipientSheet.d.ts +11 -0
- package/dist/types/pages/trade/Selectors.d.ts +24 -0
- package/dist/types/pages/trade/SwapPanel.d.ts +34 -0
- package/dist/types/pages/trade/WidgetTabs.d.ts +46 -0
- package/dist/types/pages/trade/canton.d.ts +94 -0
- package/dist/types/pages/trade/config.d.ts +185 -0
- package/dist/types/pages/trade/embedNarrowing.d.ts +28 -0
- package/dist/types/pages/trade/embedParams.d.ts +299 -0
- package/dist/types/pages/trade/embedTheme.d.ts +14 -0
- package/dist/types/pages/trade/harness.d.ts +120 -0
- package/dist/types/pages/trade/orderMinimum.d.ts +5 -0
- package/dist/types/pages/trade/resumeSwap.d.ts +139 -0
- package/dist/types/pages/trade/settlementCopy.d.ts +42 -0
- package/dist/types/pages/trade/useAmountFit.d.ts +25 -0
- package/dist/types/pages/trade/useEmbedDefaults.d.ts +28 -0
- package/dist/types/pages/trade/useSettlementGating.d.ts +152 -0
- package/dist/types/pages/trade/useSwapAmount.d.ts +93 -0
- package/dist/types/pages/trade/useSwapFlow.d.ts +152 -0
- package/dist/types/pages/trade/useSwapPanel.d.ts +170 -0
- package/dist/types/pages/trade/useSwapRoute.d.ts +215 -0
- package/dist/types/pages/trade/useTronLinkFill.d.ts +13 -0
- package/dist/types/pages/trade/zkMoney.d.ts +28 -0
- package/dist/types/promiseWithResolvers.d.ts +12 -0
- package/dist/types/ramp/availability/RailTiles.d.ts +26 -0
- package/dist/types/ramp/availability/RampDisclosure.d.ts +9 -0
- package/dist/types/ramp/availability/RampRails.d.ts +27 -0
- package/dist/types/ramp/availability/model.d.ts +51 -0
- package/dist/types/ramp/availability/useRampDiscovery.d.ts +60 -0
- package/dist/types/ramp/offramp/CompletedPrerequisite.d.ts +5 -0
- package/dist/types/ramp/offramp/OfframpActivityList.d.ts +12 -0
- package/dist/types/ramp/offramp/OfframpRoute.d.ts +8 -0
- package/dist/types/ramp/offramp/OfframpRouteReview.d.ts +12 -0
- package/dist/types/ramp/offramp/PaymentAppSend.d.ts +27 -0
- package/dist/types/ramp/offramp/localOfframps.d.ts +58 -0
- package/dist/types/ramp/offramp/model.d.ts +46 -0
- package/dist/types/ramp/offramp/port.d.ts +55 -0
- package/dist/types/ramp/offramp/prerequisite.d.ts +271 -0
- package/dist/types/ramp/offramp/useOfframp.d.ts +87 -0
- package/dist/types/ramp/offramp/useOfframpRails.d.ts +36 -0
- package/dist/types/ramp/peer/BuyOnramp.d.ts +21 -0
- package/dist/types/ramp/peer/OnrampSteps.d.ts +32 -0
- package/dist/types/ramp/peer/buyerDriver.d.ts +48 -0
- package/dist/types/ramp/peer/discovery.d.ts +17 -0
- package/dist/types/ramp/peer/environment.d.ts +2 -0
- package/dist/types/ramp/peer/index.d.ts +14 -0
- package/dist/types/ramp/peer/liveProvider.d.ts +15 -0
- package/dist/types/ramp/peer/liveReads.d.ts +102 -0
- package/dist/types/ramp/peer/maker.d.ts +4 -0
- package/dist/types/ramp/peer/normalization.d.ts +33 -0
- package/dist/types/ramp/peer/offramp.d.ts +130 -0
- package/dist/types/ramp/peer/onramp.d.ts +134 -0
- package/dist/types/ramp/peer/preview.d.ts +14 -0
- package/dist/types/ramp/peer/protectedMapping.d.ts +22 -0
- package/dist/types/ramp/peer/runtime.d.ts +15 -0
- package/dist/types/ramp/peer/sdkMaker.d.ts +67 -0
- package/dist/types/ramp/peer/types.d.ts +64 -0
- package/dist/types/ramp/recovery/ResumeOnramp.d.ts +37 -0
- package/dist/types/ramp/recovery/summaries.d.ts +71 -0
- package/dist/types/ramp/route/OnrampRoute.d.ts +12 -0
- package/dist/types/ramp/route/RampRouteSteps.d.ts +16 -0
- package/dist/types/ramp/route/routeActivity.d.ts +4 -0
- package/dist/types/ramp/route/useXochiRampDriver.d.ts +22 -0
- package/dist/types/result.js +14 -0
- package/dist/types/styles.d.ts +1 -0
- package/dist/types/types/activity.d.ts +184 -0
- package/dist/types/types/index.d.ts +20 -0
- package/dist/types/types/intent.d.ts +85 -0
- package/dist/types/types/result.d.ts +53 -0
- package/dist/types/utils/format.d.ts +88 -0
- package/dist/types/wagmi.d.ts +142 -0
- package/dist/types/widgetLibModule.d.ts +8 -0
- package/dist/utils/format.js +109 -0
- package/dist/wagmi.js +188 -0
- package/dist/widgetLibModule.js +4 -0
- package/licenses/Monaspace-OFL-1.1.txt +93 -0
- package/licenses/assets.json +132 -0
- package/licenses/rainbowkit-MIT.txt +9 -0
- package/licenses/xochi-shared-MIT.txt +21 -0
- package/package.json +115 -4
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a trading pair is or is not selectable.
|
|
3
|
+
*
|
|
4
|
+
* Three states, deliberately not two. "The solver cannot price this" and "your
|
|
5
|
+
* trust score does not reach this yet" are opposite facts: the first is a
|
|
6
|
+
* property of the protocol that no user action changes, the second is a door
|
|
7
|
+
* with a key. Rendering both as one greyed-out row is the failure mode this
|
|
8
|
+
* codebase keeps repeating, where an absent input and a negative result look
|
|
9
|
+
* identical, and it is the one thing the trade-widget kickoff asks to be
|
|
10
|
+
* pedantic about.
|
|
11
|
+
*
|
|
12
|
+
* Today the selector simply DROPS anything the solver does not support, so
|
|
13
|
+
* searching for WETH returns "No tokens found" -- the same empty state as a
|
|
14
|
+
* token that does not exist at all. That is the third state collapsing into
|
|
15
|
+
* nothing.
|
|
16
|
+
*
|
|
17
|
+
* Pure and free of React so it can be tested directly; the modal renders it.
|
|
18
|
+
*/
|
|
19
|
+
export type PairAvailability = {
|
|
20
|
+
state: "available";
|
|
21
|
+
} | {
|
|
22
|
+
state: "trust_locked";
|
|
23
|
+
requiredScore: number;
|
|
24
|
+
requiredTier: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `reason`: why, when the caller knows more than "this leg's coin is not
|
|
28
|
+
* offered" -- the configurator names the pair's own refusal (xochi-widget#46).
|
|
29
|
+
*/
|
|
30
|
+
| {
|
|
31
|
+
state: "unsupported";
|
|
32
|
+
reason?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Minimum trust score a symbol needs, over and above the solver supporting it.
|
|
36
|
+
*
|
|
37
|
+
* EMPTY TODAY, AND THAT IS CORRECT. Every pair the solver can currently price
|
|
38
|
+
* is USD-to-USD and open at Standard, so nothing is trust-gated yet. The table
|
|
39
|
+
* exists so the gate is real code on a real trust score rather than a mock, and
|
|
40
|
+
* so the day an FX asset lands with a tier requirement it is one entry here and
|
|
41
|
+
* no change to the selector, the modal, or the CSS.
|
|
42
|
+
*
|
|
43
|
+
* THIS GATE IS PRESENTATION ONLY. IT ENFORCES NOTHING.
|
|
44
|
+
*
|
|
45
|
+
* The score it is checked against reaches the widget from `localStorage`
|
|
46
|
+
* (`xochi_verify_state`, read in Trade.tsx), so a user can set it to anything.
|
|
47
|
+
* No server-side check refuses a trust-gated pair: the worker resolves tier
|
|
48
|
+
* from D1 for FEE purposes and never looks at pair-level trust at all. The day
|
|
49
|
+
* an asset genuinely must be restricted, the refusal has to live in the quote
|
|
50
|
+
* path; this table only decides what the selector draws.
|
|
51
|
+
*
|
|
52
|
+
* ERC-8262 will resolve attestations to a score, and this is the natural place
|
|
53
|
+
* for the widget to read one. That does NOT make this the enforcement point.
|
|
54
|
+
* Wiring compliance to this file alone would ship a control that has never
|
|
55
|
+
* refused anything, which looks exactly like one that stopped working.
|
|
56
|
+
* Tracked in xochi#433.
|
|
57
|
+
*/
|
|
58
|
+
export declare const SYMBOL_TRUST_REQUIREMENT: Readonly<Record<string, number>>;
|
|
59
|
+
/**
|
|
60
|
+
* Trust score a symbol requires. Unlisted symbols are open to everyone.
|
|
61
|
+
*
|
|
62
|
+
* Takes the table as an argument so the gate can be exercised against a real
|
|
63
|
+
* requirement even while the live one is empty. Without that, the trust-locked
|
|
64
|
+
* branch would be code that has never once executed, which is indistinguishable
|
|
65
|
+
* from code that does not work -- and this repo has shipped that shape before.
|
|
66
|
+
*/
|
|
67
|
+
export declare function requiredScoreFor(symbol: string, requirements?: Readonly<Record<string, number>>): number;
|
|
68
|
+
/**
|
|
69
|
+
* Classify one symbol for one leg of a trade.
|
|
70
|
+
*
|
|
71
|
+
* `supportedSymbols` is the solver's live capability matrix for this leg. An
|
|
72
|
+
* EMPTY or absent list means "no narrowing", matching the existing contract in
|
|
73
|
+
* TokenSearchModal: the fallback matrix is used when the solver is unreachable,
|
|
74
|
+
* and an outage must not repaint every pair as unsupported. Marking everything
|
|
75
|
+
* dead because we failed to ask is exactly the confusion this module exists to
|
|
76
|
+
* prevent.
|
|
77
|
+
*
|
|
78
|
+
* Unsupported outranks trust-locked. If the solver cannot fill a pair, the trust
|
|
79
|
+
* score is beside the point, and telling someone to raise their score for a pair
|
|
80
|
+
* that would still not fill is a false promise.
|
|
81
|
+
*/
|
|
82
|
+
export declare function classifyPairAvailability(params: {
|
|
83
|
+
symbol: string;
|
|
84
|
+
supportedSymbols?: readonly string[];
|
|
85
|
+
trustScore: number;
|
|
86
|
+
/** Defaults to the live table; injectable so the trust branch is testable. */
|
|
87
|
+
requirements?: Readonly<Record<string, number>>;
|
|
88
|
+
}): PairAvailability;
|
|
89
|
+
/** Whether a classified pair can actually be chosen. */
|
|
90
|
+
export declare function isSelectable(availability: PairAvailability): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Short badge text. Null for an available pair: the ordinary case earns no
|
|
93
|
+
* decoration, so the two exceptional states are the only things wearing a
|
|
94
|
+
* badge and cannot be mistaken for the norm.
|
|
95
|
+
*/
|
|
96
|
+
export declare function pairBadgeLabel(availability: PairAvailability): string | null;
|
|
97
|
+
/**
|
|
98
|
+
* One line saying what is true and, where there is one, what to do about it.
|
|
99
|
+
* The trust case names the score to reach, because "locked" without a target is
|
|
100
|
+
* the bare `0/100` problem all over again.
|
|
101
|
+
*
|
|
102
|
+
* "Trade", not "price". Pricing an asset is what a desk does; the person reading
|
|
103
|
+
* this wants to know whether they can swap the thing. Both hints use the same
|
|
104
|
+
* verb so the two states read as answers to one question.
|
|
105
|
+
*/
|
|
106
|
+
export declare function pairAvailabilityHint(availability: PairAvailability, symbol: string): string | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The payment line of the quote panel and the confirm modal: the gas state and
|
|
3
|
+
* what the wallet will be asked to do, in one compact line.
|
|
4
|
+
*
|
|
5
|
+
* The signature count is read off the quote, never the method label: a quote
|
|
6
|
+
* that carries a pull authorization asks for two signatures (the intent, then
|
|
7
|
+
* the pull), the same rule the signing flow counts by (`signingSlot` in
|
|
8
|
+
* @xochi/client). Riddler declares "pimlico" on every stealth quote yet still
|
|
9
|
+
* serves a pull, and a preview quote names erc3009/permit2 with the pull
|
|
10
|
+
* stripped, so a gasless quote without a pull promises no count at all.
|
|
11
|
+
*
|
|
12
|
+
* A gasless method still costs one gasful `approve(Permit2)` when the
|
|
13
|
+
* allowance is short, so "No gas" is claimed only when the allowance is known
|
|
14
|
+
* to cover the amount (`paysNoGas`); an unknown allowance gets a conditional
|
|
15
|
+
* that is true either way.
|
|
16
|
+
*/
|
|
17
|
+
import { type OriginApproval, type PaymentMethod } from "../types/intent.js";
|
|
18
|
+
export declare function paymentSummary(method: PaymentMethod, hasPull: boolean, approval: OriginApproval): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Origin-pull method helpers, read off the solver-served `pull_authorization`.
|
|
3
|
+
*/
|
|
4
|
+
import type { PermitType, Eip712TypedData } from "../types/intent.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the origin-pull method from the solver-served `pull_authorization`.
|
|
7
|
+
* Authoritative: the solver decides how it pulls the origin token, so the
|
|
8
|
+
* approval flow must key on the served authorization's `primaryType`, not a
|
|
9
|
+
* local token-address guess. A local guess that says "permit2" for a token the
|
|
10
|
+
* solver actually pulls via ERC-3009 is what surfaces a gratuitous approval
|
|
11
|
+
* (and, historically, one whose spender looked like the solver EOA). Returns
|
|
12
|
+
* null when there is no authorization or its type is unrecognized, so the caller
|
|
13
|
+
* can fall back to a local heuristic for pre-quote display only.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pullMethodFromAuthorization(pull?: Eip712TypedData): PermitType | null;
|
|
16
|
+
/**
|
|
17
|
+
* The Permit2 contract a served Permit2 pull names in its
|
|
18
|
+
* `domain.verifyingContract` (Riddler #473). usePermit approves only the
|
|
19
|
+
* canonical Permit2 contract (SPEC §2.3 pins it) and refuses a pull whose domain
|
|
20
|
+
* names any other, so the on-chain approval and the signed permit always target
|
|
21
|
+
* the same contract and an approval never points at a server-chosen address.
|
|
22
|
+
* Returns null when there is no permit2 authorization or its domain lacks a
|
|
23
|
+
* usable verifyingContract.
|
|
24
|
+
*/
|
|
25
|
+
export declare function permit2SpenderFromAuthorization(pull?: Eip712TypedData): string | null;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quote pricing helpers shared by the quote display (QuoteDetails) and the
|
|
3
|
+
* pre-execution safety guard (SwapPanel).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* All-in cost of a quote as a percentage below the live market rate. Positive =
|
|
7
|
+
* worse than market, 0 = at-or-better than market.
|
|
8
|
+
*
|
|
9
|
+
* This compares the net output the user actually receives against the market
|
|
10
|
+
* mid-rate, so it folds in every charge: solver spread, venue + routing fees, the
|
|
11
|
+
* fixed network minimum, and market slippage. On small orders the fixed network
|
|
12
|
+
* minimum dominates, which is why a $1 transfer can read as a large cost even
|
|
13
|
+
* with a well-funded solver -- it is total cost, not market slippage alone.
|
|
14
|
+
*
|
|
15
|
+
* Returns 0 when prices or amounts are unavailable, so a missing price never
|
|
16
|
+
* fabricates a cost (or a false guard trip).
|
|
17
|
+
*/
|
|
18
|
+
export declare function calculatePriceImpact(fromAmount: string, toAmount: string, fromDecimals: number, toDecimals: number, fromPrice: number | undefined, toPrice: number | undefined): number;
|
|
19
|
+
/**
|
|
20
|
+
* How far the quote's payout sits below the market-rate payout, as an ABSOLUTE
|
|
21
|
+
* amount in the destination token.
|
|
22
|
+
*
|
|
23
|
+
* A DIFFERENT MEASUREMENT from the served `cost_bps`, which is why the receipt
|
|
24
|
+
* labels the two apart instead of printing them side by side as one figure.
|
|
25
|
+
* This one is a client-side estimate: it needs a DeFi Llama price for both
|
|
26
|
+
* symbols, and it measures the gap against GROSS OUTPUT, where the worker
|
|
27
|
+
* measures its cost against INPUT. On a same-asset bridge the two are
|
|
28
|
+
* indistinguishable; on the FX pairs this widget is being built for they diverge
|
|
29
|
+
* by the exchange rate.
|
|
30
|
+
*
|
|
31
|
+
* Returns null when either price is missing or either amount is unusable, so an
|
|
32
|
+
* unavailable feed renders as nothing rather than as a confident zero. The old
|
|
33
|
+
* inline version defaulted the market payout to 0 and clamped, which produced a
|
|
34
|
+
* "0" that read as "this trade is free".
|
|
35
|
+
*/
|
|
36
|
+
export declare function marketGapAmount(fromAmount: string, toAmount: string, fromDecimals: number, toDecimals: number, fromPrice: number | undefined, toPrice: number | undefined): number | null;
|
|
37
|
+
/**
|
|
38
|
+
* Market rate from the price feed: how many destination tokens one source token
|
|
39
|
+
* buys at spot, before fees. Null when either price is missing or unusable, so a
|
|
40
|
+
* missing feed renders no market row rather than a zero.
|
|
41
|
+
*/
|
|
42
|
+
export declare function marketRate(fromPrice: number | undefined, toPrice: number | undefined): number | null;
|
|
43
|
+
/** "1 USDC \u2248 211.78 RAXOL", or null when there is no usable rate. */
|
|
44
|
+
export declare function formatMarketRate(rate: number | null, fromSymbol: string, toSymbol: string): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* A gap-to-market percentage for primary copy: one decimal, and "<0.1%" for a
|
|
47
|
+
* real gap that would otherwise round to "0.0%".
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatGapPct(pct: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Age of a reference price for the spot-price row: "40s ago", "12m ago". A
|
|
52
|
+
* print timestamped ahead of this device's clock reads "0s ago", never a
|
|
53
|
+
* negative age. Live prints are at most PRICE_MAX_AGE_SECONDS (30 minutes) old,
|
|
54
|
+
* so minutes are the coarsest unit needed (xochi#568).
|
|
55
|
+
*/
|
|
56
|
+
export declare function formatPriceAge(ageSeconds: number): string;
|
|
57
|
+
/**
|
|
58
|
+
* Implied conversion rate of a quote: how many destination tokens one source
|
|
59
|
+
* token buys. Needs no external price feed -- it reads straight off the amounts,
|
|
60
|
+
* so it surfaces a bad rate even for a token the price feed does not carry (USDG).
|
|
61
|
+
* Returns 0 when either amount is unusable.
|
|
62
|
+
*/
|
|
63
|
+
export declare function impliedRate(fromAmount: string, toAmount: string, fromDecimals: number, toDecimals: number): number;
|
|
64
|
+
/**
|
|
65
|
+
* Render an implied rate for the quote receipt.
|
|
66
|
+
*
|
|
67
|
+
* Two shapes, because a rate between two different assets and a rate between
|
|
68
|
+
* the same asset on two chains mean different things (#422). Every pair the
|
|
69
|
+
* solver supports today is USD-to-USD, so the common case is the second one,
|
|
70
|
+
* and unqualified it renders "1 USDC = 0.9879 USDC" -- which reads as a broken
|
|
71
|
+
* swap. It is not broken; it is the honest delivery ratio of a bridge, and
|
|
72
|
+
* naming the two chains is what makes it legible, because the number is about
|
|
73
|
+
* where the money goes rather than what it converts to.
|
|
74
|
+
*
|
|
75
|
+
* The cross-asset form is the one FX will use. It needs no change when non-USD
|
|
76
|
+
* symbols reach `solver-support.ts`.
|
|
77
|
+
*
|
|
78
|
+
* Takes chain NAMES rather than ids so it stays independent of the chain
|
|
79
|
+
* registry. Returns null when the rate is unusable, which the receipt renders
|
|
80
|
+
* as no row at all.
|
|
81
|
+
*/
|
|
82
|
+
export declare function formatImpliedRate(rate: number, fromSymbol: string, toSymbol: string, fromChainName: string, toChainName: string): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* The served cost (fees plus network cost) as a percent ("0.22%"). A real
|
|
85
|
+
* sub-0.01% cost reads "<0.01%" rather than a misleading "0.00%".
|
|
86
|
+
*/
|
|
87
|
+
export declare function formatCostPct(bps: number): string;
|
|
88
|
+
/**
|
|
89
|
+
* How alarming a cost row should look.
|
|
90
|
+
*
|
|
91
|
+
* ONE GRADE PER ROW, each computed from the number that row displays. There is
|
|
92
|
+
* deliberately no combined verdict and no precedence between the two.
|
|
93
|
+
*
|
|
94
|
+
* An earlier version graded everything off the served `cost_bps` whenever the
|
|
95
|
+
* quote carried one, and rendered the market-gap row neutral in that case on the
|
|
96
|
+
* grounds that the served figure "owns the verdict". It does not, because the
|
|
97
|
+
* two do not measure the same risk:
|
|
98
|
+
*
|
|
99
|
+
* - `cost_bps` is `fee_amount_usd / input`, and `fee_amount_usd` is gas plus
|
|
100
|
+
* solver margin. It never observes the exchange rate of the fill.
|
|
101
|
+
* - the market gap is payout against market mid. It is the only thing on the
|
|
102
|
+
* receipt that sees an adverse rate.
|
|
103
|
+
*
|
|
104
|
+
* So a quote with ordinary fees and a badly priced fill graded `normal` and lost
|
|
105
|
+
* its warning. Worse, two unrelated guards intersect to leave one combination
|
|
106
|
+
* with no cover at all: `cost_bps` is computed only for a STABLE origin (the
|
|
107
|
+
* worker's `inputUsd` is NaN otherwise, so the guard does not run), and
|
|
108
|
+
* `stablePairShortfallPct` fires only when BOTH legs are stable. Stable origin
|
|
109
|
+
* to non-stable destination therefore had a served figure suppressing the market
|
|
110
|
+
* gap and no stable-pair check either. That is precisely the cross-asset FX case
|
|
111
|
+
* this widget is being built for.
|
|
112
|
+
*/
|
|
113
|
+
export type CostSeverity = "normal" | "warning" | "severe";
|
|
114
|
+
/**
|
|
115
|
+
* Thresholds for the SERVED cost row, in basis points.
|
|
116
|
+
*
|
|
117
|
+
* The guard caps what can be served: an order costing more than `MAX_COST_RATIO`
|
|
118
|
+
* (0.015 in `cost-guard.ts`, so 150 bps) is refused upstream and never reaches
|
|
119
|
+
* the panel, so every value graded here sits inside 0-150. Reusing the market-gap
|
|
120
|
+
* thresholds unchanged would put "severe" at 300 bps, twice the ceiling, where no
|
|
121
|
+
* served cost could ever reach it.
|
|
122
|
+
*
|
|
123
|
+
* An ordinary filled order costs about 22 bps (the stable fee rate, and the
|
|
124
|
+
* figure the cost-guard docstring uses as typical). 50 bps is over twice that.
|
|
125
|
+
* 100 bps is two thirds of the way to a refusal, and past the point where the
|
|
126
|
+
* fixed network cost rather than the fee is most of what the user is paying.
|
|
127
|
+
*/
|
|
128
|
+
export declare const COST_WARNING_BPS = 50;
|
|
129
|
+
export declare const COST_SEVERE_BPS = 100;
|
|
130
|
+
/**
|
|
131
|
+
* Thresholds for the MARKET GAP row, as a percentage below market mid.
|
|
132
|
+
*
|
|
133
|
+
* A different scale from the served bps above, and deliberately so rather than by
|
|
134
|
+
* oversight. This figure is not bounded by the cost guard (the guard never sees
|
|
135
|
+
* an adverse rate), so it has no 150 bps ceiling to calibrate against. It also
|
|
136
|
+
* carries the fee inside it: an ordinary 22 bps trade shows a gap of about 0.22%,
|
|
137
|
+
* so 1% is already several times a normal fill and 3% is a rate worth stopping on.
|
|
138
|
+
*
|
|
139
|
+
* These are the values this row has always used. They are kept, and now stated to
|
|
140
|
+
* be a market-gap scale rather than borrowed from one.
|
|
141
|
+
*/
|
|
142
|
+
export declare const MARKET_GAP_WARNING_PCT = 1;
|
|
143
|
+
export declare const MARKET_GAP_SEVERE_PCT = 3;
|
|
144
|
+
/**
|
|
145
|
+
* Grade of the served cost (fees plus network cost), or `normal` when there is none to grade.
|
|
146
|
+
*
|
|
147
|
+
* Same usability test as the receipt decoder (`costOf`), so the row can never
|
|
148
|
+
* show a figure it was not graded on, nor be graded on one it refuses to show.
|
|
149
|
+
*/
|
|
150
|
+
export declare function servedCostSeverity(costBps: number | null): CostSeverity;
|
|
151
|
+
/**
|
|
152
|
+
* Grade of the gap to market. Independent of {@link servedCostSeverity}: a
|
|
153
|
+
* well-priced fee schedule does not make a bad rate acceptable, and this row
|
|
154
|
+
* keeps its warning whether or not a served figure sits above it.
|
|
155
|
+
*/
|
|
156
|
+
export declare function marketGapSeverity(priceImpactPct: number): CostSeverity;
|
|
157
|
+
/**
|
|
158
|
+
* For a stablecoin->stablecoin route, how far the implied rate sits below 1:1, as
|
|
159
|
+
* a percent (0 = at par or better, positive = you receive less than you paid).
|
|
160
|
+
* Two $1 tokens should round-trip near 1:1, so any material gap is either a
|
|
161
|
+
* mispriced quote or heavy embedded settlement gas (small L1 stealth orders). It
|
|
162
|
+
* reads off amounts alone, so it works when the price feed lacks the token.
|
|
163
|
+
* Returns null when the pair is not stable/stable (no par expectation to check).
|
|
164
|
+
*/
|
|
165
|
+
export declare function stablePairShortfallPct(fromSymbol: string, toSymbol: string, fromAmount: string, toAmount: string, fromDecimals: number, toDecimals: number): number | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Providers
|
|
3
|
+
*
|
|
4
|
+
* The provider catalogue behind the trust score panel.
|
|
5
|
+
*
|
|
6
|
+
* Provider Categories:
|
|
7
|
+
* - Humanity: Proof of unique human (Humanode, Idena, Human Passport, Worldcoin, BrightID)
|
|
8
|
+
* - Identity: KYC/identity verification (ZKPassport, Privado ID, Coinbase, Civic)
|
|
9
|
+
* - Reputation: On-chain history (ENS, Lens)
|
|
10
|
+
* - Compliance: Regulatory compliance (Chainalysis, Xochi History)
|
|
11
|
+
*/
|
|
12
|
+
import type { Provider, ProviderCategory } from "../types/index.js";
|
|
13
|
+
export declare const PROVIDERS: readonly Provider[];
|
|
14
|
+
export declare const CATEGORIES: readonly ProviderCategory[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface QrSvg {
|
|
2
|
+
/** Total viewBox side length, in modules, including the quiet-zone margin. */
|
|
3
|
+
size: number;
|
|
4
|
+
/**
|
|
5
|
+
* SVG path data covering every dark module as a 1x1 unit square, offset by
|
|
6
|
+
* the quiet-zone `margin`. Render as a single <path> with
|
|
7
|
+
* shape-rendering="crispEdges" for seam-free, resolution-independent output.
|
|
8
|
+
*/
|
|
9
|
+
path: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Build the inline-SVG geometry for a QR code encoding `value`.
|
|
13
|
+
*
|
|
14
|
+
* Error-correction level M (~15% recoverable) with auto-selected version (the
|
|
15
|
+
* smallest that fits). The value is encoded verbatim -- for a Tron deposit this
|
|
16
|
+
* is the base58 address, which wallets read directly on scan. Pure and
|
|
17
|
+
* synchronous so it is trivially unit-testable and needs no effect/canvas.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildQrSvg(value: string, margin?: number): QrSvg;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a quote costs, as the frame's receipt states it.
|
|
3
|
+
*
|
|
4
|
+
* One pure derivation for the two places that show a quote's cost: the frame's
|
|
5
|
+
* QuoteDetails and the configurator's "What users see" panel
|
|
6
|
+
* (xochi-fi/xochi-widget#40). Both read every figure from here, so the panel
|
|
7
|
+
* cannot quote an integrator a cost the widget would not show their users.
|
|
8
|
+
*/
|
|
9
|
+
import { type AssetClass } from "@xochi/client";
|
|
10
|
+
import type { FeeBreakdown, QuoteResponse } from "../types/intent.js";
|
|
11
|
+
export interface QuoteCostInput {
|
|
12
|
+
/** The pay amount in origin base units, as sent with the quote request. */
|
|
13
|
+
fromAmount: string;
|
|
14
|
+
fromSymbol: string;
|
|
15
|
+
fromDecimals: number;
|
|
16
|
+
toSymbol: string;
|
|
17
|
+
toDecimals: number;
|
|
18
|
+
/** Trust score; used to derive the fee anatomy when the quote omits it. */
|
|
19
|
+
trustScore: number;
|
|
20
|
+
/** USD price of the pay token from the price feed; undefined when missing. */
|
|
21
|
+
fromPriceUsd: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
export interface QuoteCost {
|
|
24
|
+
/** Served fees (fee layers plus network cost) in basis points, or null when the guard could not run. */
|
|
25
|
+
servedBps: number | null;
|
|
26
|
+
/** Dollar value of those fees, or null when no honest figure exists. */
|
|
27
|
+
feesUsd: number | null;
|
|
28
|
+
/** "~$2.20 (0.22%)", "0.22%" without a dollar figure, or "Unavailable". */
|
|
29
|
+
feesLabel: string;
|
|
30
|
+
/** The pay amount in whole tokens, or null when unparseable. */
|
|
31
|
+
inputTokens: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* The asset class the served `xochi_fee_rate` matches at this trust score, or
|
|
34
|
+
* null when it matches none: the server then charged a tier other than the
|
|
35
|
+
* local one, and a tier comparison would run the wrong way.
|
|
36
|
+
*/
|
|
37
|
+
rateAssetClass: AssetClass | null;
|
|
38
|
+
/** The asset class the fee was charged at: the server's rate first, then the symbols. */
|
|
39
|
+
assetClass: AssetClass;
|
|
40
|
+
/** The fee layers, served or derived from the shared schedule. */
|
|
41
|
+
fees: FeeBreakdown;
|
|
42
|
+
/** A fee layer amount in the token it is denominated in ("0.2200 USDC"). */
|
|
43
|
+
feeAmount: (raw: string) => string;
|
|
44
|
+
}
|
|
45
|
+
export declare function quoteCost(quote: QuoteResponse, input: QuoteCostInput): QuoteCost;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* quoteCountdown
|
|
3
|
+
*
|
|
4
|
+
* Pure, DOM-free label builders for the market-swap quote countdown that
|
|
5
|
+
* useIntent already computes (quoteExpiresIn). Two contexts, two honest
|
|
6
|
+
* variants:
|
|
7
|
+
*
|
|
8
|
+
* - Panel (quoteRefreshCountdown): the quote auto-reprices bufferSec before it
|
|
9
|
+
* expires, so the compact timer counts down to the refresh instant and reads
|
|
10
|
+
* "(refresh glyph) 23s", spoken "New price in 23 seconds". At the refresh
|
|
11
|
+
* instant it reads "Updating...".
|
|
12
|
+
* - Confirm modal (quoteExpiryLabel): auto-refresh is paused, so the quote
|
|
13
|
+
* counts to hard expiry and reads "Expires in Ns". At 0 it yields no label
|
|
14
|
+
* (null); the modal's existing "Quote expired. Refresh" notice takes over.
|
|
15
|
+
*
|
|
16
|
+
* All clamping and copy logic lives here so it is testable without a DOM.
|
|
17
|
+
*/
|
|
18
|
+
/** The panel timer: what is shown, and what a screen reader says instead. */
|
|
19
|
+
export interface RefreshCountdown {
|
|
20
|
+
text: string;
|
|
21
|
+
spoken: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The panel's refresh timer, or null when idle (no quote held).
|
|
25
|
+
*
|
|
26
|
+
* @param seconds Seconds until hard expiry, as computed by useIntent.
|
|
27
|
+
* @param bufferSec Seconds shaved off to align with the refresh instant.
|
|
28
|
+
*/
|
|
29
|
+
export declare function quoteRefreshCountdown(seconds: number | null | undefined, bufferSec?: number): RefreshCountdown | null;
|
|
30
|
+
/**
|
|
31
|
+
* The confirm modal's expiry label, or null when nothing should render: for
|
|
32
|
+
* null/undefined input and at expiry.
|
|
33
|
+
*/
|
|
34
|
+
export declare function quoteExpiryLabel(seconds: number | null | undefined): string | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HostConnection, HostProtocol } from "@xochi/widget-lib";
|
|
2
|
+
/**
|
|
3
|
+
* Whether this document may start a Peer operation, judged by its host.
|
|
4
|
+
*
|
|
5
|
+
* Outside an iframe there is no bridge and nothing to check. Inside one, a
|
|
6
|
+
* ramp starts only once a host speaking the current widget protocol has
|
|
7
|
+
* pinned the origin: a legacy loader may not drop ramp events safely, and an
|
|
8
|
+
* unanswered handshake proves nothing. Fail closed: `pending` and `legacy`
|
|
9
|
+
* both refuse, and the refusal says why in plain words. Recovery of an
|
|
10
|
+
* operation already submitted never consults this gate.
|
|
11
|
+
*/
|
|
12
|
+
export type RampHostGate = "ready" | Exclude<HostProtocol, "current">;
|
|
13
|
+
export declare function rampHostGate(bridge: Pick<HostConnection, "hostProtocol"> | null): RampHostGate;
|
|
14
|
+
export declare function useRampHostGate(bridge?: Pick<HostConnection, "hostProtocol" | "onHostProtocol"> | null): RampHostGate;
|
|
15
|
+
export declare const RAMP_HOST_GATE_COPY: Record<Exclude<RampHostGate, "ready">, string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type HostConnection, type RampDirection, type RampLegName, type RampLegState } from "@xochi/widget-lib";
|
|
2
|
+
import type { RampSnapshot } from "@xochi/client";
|
|
3
|
+
export interface RampEmitter {
|
|
4
|
+
readonly rampRef: string;
|
|
5
|
+
status(peer: RampLegState, xochi?: RampLegState): void;
|
|
6
|
+
recoveryRequired(leg: RampLegName, code: string): void;
|
|
7
|
+
terminal(peer: RampLegState, xochi?: RampLegState): void;
|
|
8
|
+
}
|
|
9
|
+
/** One Peer operation's public lifecycle. Address and stealth sends must not use this helper. */
|
|
10
|
+
export declare function createRampEmitter(direction: RampDirection, bridge?: Pick<HostConnection, "emit"> | null): RampEmitter;
|
|
11
|
+
/**
|
|
12
|
+
* Continue an operation's lifecycle after a reload or remount, under the
|
|
13
|
+
* reference its `ramp:started` already carried. Never emits `ramp:started`
|
|
14
|
+
* again and never mints a reference: without a stored one (a summary written
|
|
15
|
+
* before references were kept, or a malformed value) it returns null and the
|
|
16
|
+
* resumed view emits nothing rather than announce a second operation.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resumeRampEmitter(rampRef: string | undefined, bridge?: Pick<HostConnection, "emit"> | null): RampEmitter | null;
|
|
19
|
+
/** Tell the host what one S4 snapshot says, through an emitter's deduplication. */
|
|
20
|
+
export declare function emitSnapshot(emitter: RampEmitter | null | undefined, next: RampSnapshot): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare function totalCostUsd(input: {
|
|
2
|
+
/** fee_breakdown.total_usd as served, when the breakdown is present. */
|
|
3
|
+
servedTotalUsd: string | undefined;
|
|
4
|
+
/** Served fees in basis points (fees plus network cost), or null when the guard could not run. */
|
|
5
|
+
costBps: number | null;
|
|
6
|
+
/** The pay amount in whole tokens, or null when unparseable. */
|
|
7
|
+
inputTokens: number | null;
|
|
8
|
+
/** USD price of the pay token from the price feed; undefined when missing. */
|
|
9
|
+
inputPriceUsd: number | undefined;
|
|
10
|
+
}): number | null;
|
|
11
|
+
/**
|
|
12
|
+
* The receipt's one rounding rule for dollar figures: nearest cent with
|
|
13
|
+
* thousands separators ("$2,350.40"), and "<$0.01" for a real amount that would
|
|
14
|
+
* round to zero. Null when there is no honest figure, so the caller renders
|
|
15
|
+
* nothing rather than "$0.00". Callers prefix "~" only when the value does not
|
|
16
|
+
* start with "<".
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatUsd(usd: number | null): string | null;
|
|
19
|
+
/** "~$2.20", or "<$0.01" unchanged: an approximation mark never stacks on "<". */
|
|
20
|
+
export declare function approxUsd(formatted: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Splits the gap to market into the served fees and the remainder, the spread,
|
|
23
|
+
* as drawer figures: "~$0.43 (2.14%)", or the percent alone when there is no
|
|
24
|
+
* honest dollar figure.
|
|
25
|
+
*
|
|
26
|
+
* The gap compares the payout with the market-rate payout, so it is all-in: the
|
|
27
|
+
* fees are taken before the payout is priced, and whatever else the user gives
|
|
28
|
+
* up (the solver's pricing against the feed) is what remains. Spread is
|
|
29
|
+
* therefore DERIVED as gap minus fees, never served.
|
|
30
|
+
*
|
|
31
|
+
* Every figure is computed from the rounded figures shown beside it (whole
|
|
32
|
+
* basis points, whole cents), so Fees + Spread = Total on screen exactly.
|
|
33
|
+
* Spread is null when it cannot be derived honestly: no served fee figure, or
|
|
34
|
+
* fees at or above the gap (the feed and the solver disagree by more than the
|
|
35
|
+
* spread, and a negative or zero "spread" would be a claim about neither).
|
|
36
|
+
* Its dollar figure is dropped when either dollar input is missing or reads
|
|
37
|
+
* under a cent.
|
|
38
|
+
*/
|
|
39
|
+
export declare function decomposeMarketGap(input: {
|
|
40
|
+
/** Gap to market, percent of the market-rate payout (> 0). */
|
|
41
|
+
gapPct: number;
|
|
42
|
+
/** Gap to market in dollars, or null without a price for the payout token. */
|
|
43
|
+
gapUsd: number | null;
|
|
44
|
+
/** Served fees (fees plus network cost) in basis points, or null when absent. */
|
|
45
|
+
feeBps: number | null;
|
|
46
|
+
/** Dollar figure for those fees, or null. */
|
|
47
|
+
feesUsd: number | null;
|
|
48
|
+
}): {
|
|
49
|
+
total: string;
|
|
50
|
+
spread: string | null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Splits a dollar total, as formatUsd shows it, across parts weighted by their
|
|
54
|
+
* base-unit amounts, so the parts always add up to the shown total to the cent.
|
|
55
|
+
* The total's whole cents are allocated in proportion to the weights by the
|
|
56
|
+
* largest-remainder method (ties go to the earlier part). Rounding each part on
|
|
57
|
+
* its own would not reconcile: three parts of $0.036, $0.027 and $0.036 read
|
|
58
|
+
* $0.04 + $0.03 + $0.04 = $0.11 under a $0.10 total.
|
|
59
|
+
*
|
|
60
|
+
* A part that gets no whole cent reads "<$0.01", or "$0.00" when its weight is
|
|
61
|
+
* zero. Null when the total shows no whole cent or a weight is negative or they
|
|
62
|
+
* sum to nothing, so the caller falls back to token amounts for every part.
|
|
63
|
+
*/
|
|
64
|
+
export declare function splitUsd(totalUsd: number | null, weights: readonly bigint[]): string[] | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Address, type PublicClient } from "viem";
|
|
2
|
+
export type RecipientKind = "address" | "ens" | "gns" | "wns" | "zkmoney" | "stealth_meta";
|
|
3
|
+
export interface ResolvedRecipient {
|
|
4
|
+
readonly kind: RecipientKind;
|
|
5
|
+
readonly input: string;
|
|
6
|
+
readonly name?: string;
|
|
7
|
+
readonly address?: Address;
|
|
8
|
+
readonly avatarUrl?: string;
|
|
9
|
+
readonly stealthMetaAddress?: string;
|
|
10
|
+
readonly shieldedAlias?: string;
|
|
11
|
+
}
|
|
12
|
+
export type ResolveResult = {
|
|
13
|
+
readonly status: "resolved";
|
|
14
|
+
readonly recipient: ResolvedRecipient;
|
|
15
|
+
} | {
|
|
16
|
+
readonly status: "not_found" | "invalid" | "unsupported" | "unavailable";
|
|
17
|
+
readonly reason: string;
|
|
18
|
+
};
|
|
19
|
+
export interface RecipientDeps {
|
|
20
|
+
readonly mainnetClient: PublicClient;
|
|
21
|
+
readonly clientFor: (chainId: number) => PublicClient | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function classifyRecipientInput(input: string): RecipientKind | "unknown";
|
|
24
|
+
/** Use readStealthRegistration when absence must be distinguished from a lookup failure. */
|
|
25
|
+
export declare function lookupStealthMetaAddress(address: Address, deps: RecipientDeps, signal?: AbortSignal): Promise<string | undefined>;
|
|
26
|
+
export declare function readStealthRegistration(address: Address, deps: RecipientDeps, signal?: AbortSignal): Promise<"published" | "not_published" | "unknown">;
|
|
27
|
+
/** Build unsigned calldata for a verified deployment. */
|
|
28
|
+
export declare function buildRegisterStealthMetaAddressTx(metaAddress: string, chainId: number): {
|
|
29
|
+
to: Address;
|
|
30
|
+
data: `0x${string}`;
|
|
31
|
+
value: 0n;
|
|
32
|
+
};
|
|
33
|
+
export declare function resolveRecipient(input: string, deps: RecipientDeps, signal?: AbortSignal): Promise<ResolveResult>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ResolvedRecipient } from "./index.js";
|
|
2
|
+
export declare function readRecentRecipientEntries(): ResolvedRecipient[];
|
|
3
|
+
export declare function readRecentRecipients(): string[];
|
|
4
|
+
/** Record a recipient after dispatch. A later selection must resolve the input again. */
|
|
5
|
+
export declare function rememberRecipient(recipient: ResolvedRecipient): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The recipient receipt step of a shielded payout.
|
|
3
|
+
*
|
|
4
|
+
* The Worker holds a shielded order at `settling` with `awaiting_recipient` once
|
|
5
|
+
* the Aztec payout is final; only the recipient's signed receipt, sent by
|
|
6
|
+
* `xochi-recipient receipt <intentId>`, completes it. The status copy and the
|
|
7
|
+
* activity row's command both read `isAwaitingRecipient`, so they cannot
|
|
8
|
+
* disagree about which rows are waiting.
|
|
9
|
+
*/
|
|
10
|
+
import type { IntentStatus } from "../types/intent.js";
|
|
11
|
+
import type { SwapActivityItem } from "../types/activity.js";
|
|
12
|
+
/** The Worker's marker on a `settling` shielded payout whose payout is final. */
|
|
13
|
+
export declare const AWAITING_RECIPIENT_SUBSTATUS = "awaiting_recipient";
|
|
14
|
+
/**
|
|
15
|
+
* Paid on Aztec, waiting for the recipient's receipt. The status decides: the
|
|
16
|
+
* history poll keeps the last known substatus on a completed read that carries
|
|
17
|
+
* none, so the marker alone outlives completion.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isAwaitingRecipient(status: IntentStatus, substatus: string | null | undefined): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The command the recipient runs for this row, or null when the row shows none:
|
|
22
|
+
* receipts not live, the row not waiting, a known non-shielded mode, or an id
|
|
23
|
+
* the CLI would refuse.
|
|
24
|
+
*/
|
|
25
|
+
export declare function receiptCommand(item: SwapActivityItem, live: boolean): string | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report client
|
|
3
|
+
*
|
|
4
|
+
* Fire-and-forget POST of a swap failure to the worker's /api/report endpoint.
|
|
5
|
+
* Best-effort: a failure to report must never disrupt the UI, but it is logged
|
|
6
|
+
* (never silently swallowed).
|
|
7
|
+
*/
|
|
8
|
+
import type { SwapFailureRef } from "./swapFlowPhase.js";
|
|
9
|
+
export declare function reportSwapFailure(ref: SwapFailureRef): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-expiry signal.
|
|
3
|
+
*
|
|
4
|
+
* When an authenticated API call returns 401 with an expired-token body, fire a
|
|
5
|
+
* one-shot `xochi:session-expired` window event. A top-level banner listens and
|
|
6
|
+
* prompts the user to reload -- which pulls a fresh app build and a new login,
|
|
7
|
+
* the common cause of stale-tab 401s during frequent deploys.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SESSION_EXPIRED_EVENT = "xochi:session-expired";
|
|
10
|
+
/** Fire the session-expired event once per page load. */
|
|
11
|
+
export declare function notifySessionExpired(): void;
|