diff --git a/src/transactions/amm.ts b/src/transactions/amm.ts index 4f5c67b..49d125e 100644 --- a/src/transactions/amm.ts +++ b/src/transactions/amm.ts @@ -254,13 +254,24 @@ export async function authorizeDerivedKeyAMM( SellingDAOCoinCreatorPublicKey: string; QuoteCurrencyPublicKey: string; numSubOrders: number; + /** + * When buying or selling raw DESO (i.e. QuoteCurrencyPublicKey === 'DESO'), + * set this to the total DESO amount (in nanos) that will be spent/received + * across all sub-orders so the derived key limit covers the full trade. + * Falls back to a hardcoded default when not provided. + */ + GlobalDESOLimitNanos?: number; } ) { const jwt = await identity.jwt(); const deriveResponse = await identity.derive( { GlobalDESOLimit: - payload.QuoteCurrencyPublicKey === 'DESO' ? 100000 * 1e9 : 1e9, + payload.GlobalDESOLimitNanos !== undefined + ? payload.GlobalDESOLimitNanos + : payload.QuoteCurrencyPublicKey === 'DESO' + ? 100000 * 1e9 + : 1e9, TransactionCountLimitMap: { AUTHORIZE_DERIVED_KEY: 1, // CREATE_USER_ASSOCIATION: payload.numSubOrders,