Skip to content

feat/mm quote reserve sizing - #9

Merged
goheesheng merged 6 commits into
mainfrom
feat/mm-quote-reserve-sizing
Jul 7, 2026
Merged

goheesheng merged 6 commits into
mainfrom
feat/mm-quote-reserve-sizing

Conversation

@goheesheng

Copy link
Copy Markdown
Collaborator
  • feat: add transfer_position action (0.2.2)
  • fix: value-import EvmWalletProvider so AgentKit injects the wallet (0.2.3)
  • fix: BigInt-safe serialization in get_market_prices (0.2.4)
  • feat: optional RFQ referrer for fee sharing (THETANUTS_REFERRER)
  • fix: depend on published thetanuts-client@^0.3.0, not file:../thetanuts-sdk
  • feat: get_mm_quote action — size RFQ reserves off the MM's real quote

Adds an 11th action so an agent can hand a settled option position to
another address — unblocks ACP-provider flows where the agent settles on
its own wallet and must transfer the minted position to the client.

- transfer_position: encodes BaseOption.transfer(bool,address), broadcasts
  via the wallet provider; gated by SafetyPolicy (new transferPosition type,
  amount 0n, recipient surfaced to onWriteAction for allowlisting).
- get_user_positions now returns optionAddress.
- TransferPositionSchema/Args exported; tests + CHANGELOG + version bump.
….2.3)

Action methods are annotated `wallet: EvmWalletProvider`, but it was imported
as `type EvmWalletProvider` (type-only). With emitDecoratorMetadata, a type-only
annotation degrades the recorded design:paramtypes to `Function` instead of the
class — so AgentKit's validateActionMethodArguments sees isWalletProvider=false
and NEVER injects the wallet as arg[0]. The action then receives the schema args
as arg[0] and calls buildClient(args) → 'wallet.getNetwork is not a function',
failing every on-chain action (approve/request_rfq/settle/transfer_position).

Fix: import EvmWalletProvider as a VALUE. design:paramtypes now records
[EvmWalletProvider, void 0]; AgentKit injects the wallet correctly.

Surfaced during a live Base-mainnet trade with a CDP smart-account wallet.
24 tests + typecheck green; metadata verified in the built dist.
get_market_prices threw 'Do not know how to serialize a BigInt' — API response
has BigInt fields. Added a replacer coercing bigint→string.
buildClient now reads THETANUTS_REFERRER and, when it's a valid EVM address,
constructs the ThetanutsClient with referrer set so RFQ referral fees can accrue
to that wallet. Inert/no-op when unset or invalid (never throws — an invalid
referrer must not break trade execution). Also export buildClient from the
package index so the provider's referral/claim script can build a client.
Typecheck green, dist rebuilt.
…ts-sdk

CI failed building the agentkit: 'Cannot find module @thetanuts-finance/
thetanuts-client'. Root cause: the devDependency was file:../thetanuts-sdk — a
THIRD private sibling repo that isn't checked out in CI (only agentkit + provider
are). Locally it resolved because thetanuts-sdk exists on disk, masking it.

Fix: use the PUBLISHED @thetanuts-finance/thetanuts-client@^0.3.0 (public on npm,
identical 0.3.0 to what the file: link provided, and it already satisfies the
peerDependency range). Lockfile regenerated to resolve from registry.npmjs.org.
Agentkit builds green; the provider (which consumes this via file: link)
typechecks + 55 tests pass against it.
  Adds getMmQuoteForStructure + get_mm_quote action that price a structure via the
  MM's actual (non-whitelisted) quote, so a BUY reserve can be sized to clear.
  Fixes a 48x strike-order mispricing (PUT_SPREAD needs [hi,lo]). Regression tests
  included. Root cause: reserves were sized off the public feed, which under-prices
  the MM's real RFQ quote → RFQs expired unfilled (RFQ 87).
@goheesheng
goheesheng merged commit 0de7be9 into main Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant