diff --git a/docs/native-dex.md b/docs/native-dex.md index ff5889a..f4ddb11 100644 --- a/docs/native-dex.md +++ b/docs/native-dex.md @@ -41,7 +41,7 @@ There is **no compiler switch** that turns Solidity into Boing VM bytecode. (The - `nativeVm.dexFactory`, `swapRouter`, `ledgerRouterV2` / `V3`, `liquidityLocker`, plus LP vault / share token ids (env or live RPC; zeros when unpublished). - Runtime defaults come from **`fetchNativeDexIntegrationDefaults`** (`@boing-network/boing-sdk`): live `boing_getNetworkInfo.end_user` plus env overrides. Historical SDK-embedded 6913 hexes are **not** treated as live. -The **Swap** tab on 6913 targets the **network default** constant-product pool. **Create Pool** on 6913 deploys a new CP pool, then one Express batch binds token ids, seeds `add_liquidity`, and runs `register_pair` when a factory id is published (two user approvals — deploy cannot join a protocol batch). Amounts are human units (same as Swap). **Pools → Your liquidity** add/remove (Advanced section for a pasted id) works on the canonical pool, a directory venue, or a pasted pool AccountId. Additional factory pairs (including multihop) are surfaced under **Pools** and **Smart route**. +The **Swap** tab on 6913 targets the **network default** constant-product pool. **Create Pool** on 6913 prefers the **create-and-seed** factory when `REACT_APP_BOING_NATIVE_CREATE_AND_SEED_FACTORY` is set: one Express Batch CREATE2s the pool, binds tokens, seeds `add_liquidity`, and `register_pair`s on the directory (one user approval). Without that factory, Create Pool falls back to deploy + one bind/seed/register batch (two approvals — deploy cannot join a protocol batch). Amounts are human units (same as Swap). **Pools → Your liquidity** add/remove (Advanced section for a pasted id) works on the canonical pool, a directory venue, or a pasted pool AccountId. Additional factory pairs (including multihop) are surfaced under **Pools** and **Smart route**. ### “Deploy the Solidity DEX on Boing” actually means diff --git a/frontend/.env.example b/frontend/.env.example index 89122e0..c4dd798 100644 --- a/frontend/.env.example +++ b/frontend/.env.example @@ -56,6 +56,9 @@ REACT_APP_BOING_TESTNET_RPC_URL=https://testnet-rpc.boing.network/ # REACT_APP_BOING_NATIVE_AMM_POOL=0x… # REACT_APP_BOING_NATIVE_VM_DEX_FACTORY=0x… +# Create-and-seed factory (CREATE2 pool + bind + optional register). When set, Create Pool asks +# for one Express approval. Deploy `native_dex_create_and_seed_bytecode` from boing.network first. +# REACT_APP_BOING_NATIVE_CREATE_AND_SEED_FACTORY=0x… # Linked NFT collection ↔ fungible token registry (32-byte AccountId). Required for on-chain # claim/register/unlink on /linked-project; also accepts end_user.canonical_linked_nft_token_registry. # Registry v2 (CREATE2 salt BOING_NFT_TOKEN_LINK_REG_V2, block 1174): an asset is claimed by its creator in its own diff --git a/frontend/scripts/boing-native-boing.test.mjs b/frontend/scripts/boing-native-boing.test.mjs index 63c7f2e..b7e9cc9 100644 --- a/frontend/scripts/boing-native-boing.test.mjs +++ b/frontend/scripts/boing-native-boing.test.mjs @@ -19,10 +19,12 @@ import { } from '../src/services/boingSwapQuote.js'; import { poolCard, pairedAmount } from '../src/services/boingPoolsSimple.js'; import { + buildCreateAndSeedOneShotBatchRequest, buildCreatePoolPostDeployBatchRequest, buildNativeAddLiquidityRequest, buildNativeRemoveLiquidityRequest, } from '../src/services/boingLiquidityTx.js'; +import { boingPoolBytecodeHex } from '@boing-network/boing-sdk'; import { planNativeBoingSwap } from '../src/services/nativeDexCustodySwap.js'; const USDC = '0x6676f971ade3982406efa3e2cdb0477923f8f2a15624c4b6ad3a432817a75e93'; @@ -106,6 +108,33 @@ test('native add / remove liquidity are single batches (wrap with value, unwrap assert.ok(rm.access_list.write.includes(WBOING_HEX)); }); +test('create-and-seed one-shot batch: wrap? + approves + create_and_seed + add_liquidity', () => { + const CAS = `0x${'c5'.repeat(32)}`; + const DIR = `0x${'cd'.repeat(32)}`; + const salt = `0x${'07'.repeat(32)}`; + const { poolHex, request } = buildCreateAndSeedOneShotBatchRequest({ + factoryHex: CAS, + saltHex32: salt, + tokenAHex: WBOING_HEX, + tokenBHex: USDC, + amountA: E18, + amountB: 200n, + senderHex: ME, + directoryHex: DIR, + poolBytecodeHex: boingPoolBytecodeHex(8), + }); + assert.equal(request.type, 'batch'); + assert.match(poolHex, /^0x[0-9a-f]{64}$/); + // deposit + approve wBOING + approve USDC + create_and_seed + add_liquidity + assert.equal(request.calls.length, 5); + assert.equal(request.calls[0].contract, WBOING_HEX); + assert.equal(request.calls[0].value, String(E18)); + assert.equal(request.calls[3].contract, CAS); + assert.equal(request.calls[4].contract, poolHex); + assert.ok(request.access_list.write.includes(CAS)); + assert.ok(request.access_list.write.includes(DIR)); +}); + test('create-pool post-deploy seed is one batch: set_tokens + wrap/approves/add + optional register', () => { const FACTORY = `0x${'cd'.repeat(32)}`; const withReg = buildCreatePoolPostDeployBatchRequest({ diff --git a/frontend/src/components/CreateTokenBoingContent.jsx b/frontend/src/components/CreateTokenBoingContent.jsx index 9a9f0fa..5f1374c 100644 --- a/frontend/src/components/CreateTokenBoingContent.jsx +++ b/frontend/src/components/CreateTokenBoingContent.jsx @@ -272,8 +272,8 @@ export default function CreateTokenBoingContent() {

Boing token v2 — one Express signature creates - the token and puts the whole supply in your account. Nobody can mint more afterwards. Add a pool next to - make it swappable. + the token. Your wallet receives the mint minus the platform fee (fee goes to treasury at deploy). Nobody + can mint more afterwards. Add a pool next to make it swappable.

@@ -296,8 +296,8 @@ export default function CreateTokenBoingContent() {

Standard

- Create one fungible token. Express will ask you to approve the deploy - {feePreview.collectionReady ? ', then a separate fee transfer' : ''}. + Create one fungible token. Express will ask once to approve the deploy + {feePreview.collectionReady ? ' (platform fee is credited to treasury in that same approval)' : ''}.