feat: add transfer_position action (0.2.2)#8
Open
goheesheng wants to merge 5 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an 11th action,
transfer_position, so an agent can hand a settled option position to another address. This unblocks flows where the agent settles an RFQ on its own wallet (the signer owns the minted position) and must then transfer it to an end user or counterparty — e.g. an ACP provider fulfilling a job for a client.Changes
transfer_positionaction — encodesBaseOption.transfer(bool isBuyer, address target)and broadcasts via the wallet provider (the SDK client still holds no signer).isBuyerselects the long/short leg;optionAddressis resolved fromget_user_positions.TransferPositionSchema/TransferPositionArgs— exported from the package entry.get_user_positionsnow returnsoptionAddress(needed to address a transfer).transferPositionaction type, gated bySafetyPolicy. No ERC20 amount (amount: 0n, so the notional cap is N/A); the collateral allowlist is skipped; the recipient is passed toonWriteActionasspenderso hosts can allowlist the target.Testing
npm run typecheckclean.npm test— 24/24, including 5 newtransferPositionsafety cases (fail-closed, zero-amount passes the cap, allowlist skipped, host hook receives the recipient and can reject/allow).Version
Bumps to 0.2.2. Additive only — no breaking changes to existing actions.