> ## Documentation Index
> Fetch the complete documentation index at: https://partner.tren.ch/llms.txt
> Use this file to discover all available pages before exploring further.

# Partner authority

> Build and sign direct Trench trades with an approved partner key.

A partner authority lets an approved partner build and send Trench trades without using the Partner API.

The same partner authority can sign trades for many user wallets. It is not tied to one user.

## Set up

1. Create a new Solana keypair on your backend.
2. Send only the public key to Trench.
3. Trench adds the public key to the onchain `Config` whitelist.
4. Wait for Trench to confirm that the public key is ready.

Use the active Trench program ID that Trench gives you.

## Build a trade

Use the [Trench IDL](/idls/trench_program.json) to build the existing trade instructions.

| Instruction     | User signer | Partner signer |
| --------------- | ----------- | -------------- |
| `buy`           | `buyer`     | `authority`    |
| `buy_exact_out` | `buyer`     | `authority`    |
| `sell`          | `seller`    | `authority`    |

Set `authority` to your approved partner public key.

Use one address from `Config.fee_addresses` for `protocol_fee_recipient`.

Both the user signer and the `authority` signer must sign the same transaction.

## Referral accounts

Every trade must include the writable `trader_referral` account meta from the IDL. Derive it with the user signer. Use `buyer` for buys and `seller` for sells.

```ts theme={null}
const [traderReferral] = PublicKey.findProgramAddressSync(
  [Buffer.from("trader_referral"), userPublicKey.toBuffer()],
  trenchProgramId,
);
```

Do not initialize this PDA.

Include its address as `trader_referral` and do not add any remaining referral accounts.

## Claim cashback

Build `claim_trader_cashback` from the IDL. Only the `trader` is a signer. This instruction does not use `authority`.
