Skip to content

Submit Proportional Join

POST /intents/submit (type: "joinProportional")

Submit a signed proportional join intent. The user deposits all pool tokens in the correct ratio -- no swap fees apply.

Full Example (viem)

javascript
import { parseUnits } from 'viem';

const MULTIHOP_ROUTER = '0x662F15226f5b6Bf8aA10512374Af3115412C04bA';
const RELAYER_URL = 'https://mainnet.relayer.ryze.pro/api/v1';

// 1. Get a proportional join quote
const quoteRes = await fetch('https://mainnet.router.ryze.pro/join-quote', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    poolAddress: '0x7B41aA91947398CD9244AD4e314C253D9B1B5206',
    tokensIn: [
      { token: '0x4200000000000000000000000000000000000006', amount: parseUnits('0.0625', 18).toString() },
      { token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', amount: parseUnits('100', 6).toString() },
    ],
  }),
});
const quote = await quoteRes.json();

// 2. Read nonce
const nonce = await publicClient.readContract({
  address: MULTIHOP_ROUTER,
  abi: [{ name: 'joinProportionalNonces', type: 'function', inputs: [{ type: 'address' }], outputs: [{ type: 'uint256' }], stateMutability: 'view' }],
  functionName: 'joinProportionalNonces',
  args: [account.address],
});

// 3. Build intent
const deadline = BigInt(Math.floor(Date.now() / 1000) + 1800);
const tokensIn = quote.tokensIn.map(t => t.token);
const amountsIn = quote.tokensIn.map(t => BigInt(t.amount));
const minSharesOut = BigInt(quote.sharesOut) * 995n / 1000n;

const intent = {
  user: account.address,
  pool: '0x7B41aA91947398CD9244AD4e314C253D9B1B5206',
  tokensIn,
  amountsIn,
  minSharesOut,
  recipient: account.address,
  deadline,
  nonce,
};

// 4. Sign EIP-712
const signature = await walletClient.signTypedData({
  domain: {
    name: 'MultiHopRouter',
    version: '1',
    chainId: 8453,
    verifyingContract: MULTIHOP_ROUTER,
  },
  types: {
    JoinProportionalIntent: [
      { name: 'user', type: 'address' },
      { name: 'pool', type: 'address' },
      { name: 'tokensIn', type: 'address[]' },
      { name: 'amountsIn', type: 'uint256[]' },
      { name: 'minSharesOut', type: 'uint256' },
      { name: 'recipient', type: 'address' },
      { name: 'deadline', type: 'uint256' },
      { name: 'nonce', type: 'uint256' },
    ],
  },
  primaryType: 'JoinProportionalIntent',
  message: intent,
});

// 5. Split signature and submit
const r = signature.slice(0, 66);
const s = '0x' + signature.slice(66, 130);
const v = parseInt(signature.slice(130, 132), 16);

const res = await fetch(`${RELAYER_URL}/intents/submit`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    type: 'joinProportional',
    user: intent.user,
    pool: intent.pool,
    tokensIn: intent.tokensIn,
    amountsIn: intent.amountsIn.map(a => a.toString()),
    minSharesOut: intent.minSharesOut.toString(),
    recipient: intent.recipient,
    deadline: Number(intent.deadline),
    nonce: Number(intent.nonce),
    signature: { v, r, s },
  }),
});
const result = await res.json();
console.log('Intent ID:', result.intentId);

Request Body

json
{
  "type": "joinProportional",
  "user": "0xYourAddress",
  "pool": "0x7B41aA91947398CD9244AD4e314C253D9B1B5206",
  "tokensIn": [
    "0x4200000000000000000000000000000000000006",
    "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  ],
  "amountsIn": [
    "62500000000000000",
    "100000000"
  ],
  "minSharesOut": "199000000000000000000",
  "recipient": "0xYourAddress",
  "deadline": 1713200000,
  "nonce": 0,
  "signature": { "v": 27, "r": "0x...", "s": "0x..." }
}

Fields

FieldTypeDescription
typestringMust be "joinProportional"
useraddressSender (must match signature)
pooladdressPool to join
tokensInaddress[]Token addresses (min 2, no duplicates)
amountsInstring[]Amounts per token (same order as tokensIn)
minSharesOutstringMinimum LP shares to receive
recipientaddressAddress to receive LP shares
deadlinenumberUnix timestamp expiry
noncenumberFrom joinProportionalNonces(user) on contract
signatureobjectEIP-712 signature {v, r, s}

WARNING

Both users tokens must be approved for the MultiHopRouter before submitting a proportional join.

EIP-712 Types

typescript
const types = {
  JoinProportionalIntent: [
    { name: 'user', type: 'address' },
    { name: 'pool', type: 'address' },
    { name: 'tokensIn', type: 'address[]' },
    { name: 'amountsIn', type: 'uint256[]' },
    { name: 'minSharesOut', type: 'uint256' },
    { name: 'recipient', type: 'address' },
    { name: 'deadline', type: 'uint256' },
    { name: 'nonce', type: 'uint256' },
  ],
};