For the complete documentation index, see llms.txt. This page is also available as Markdown.

HinkalInLogic

Overview

HinkalInLogic and HinkalInLogicBase implement the execution-layer logic that Hinkal.sol delegates to. They manage:

  • External protocol execution with precise allowance/balance accounting

  • Proofless deposit flow (token/NFT collection and UTXO formation)

Files

  • contracts/HinkalInLogicBase.sol - core logic and helpers

  • contracts/HinkalInLogic.sol - concrete implementation (external actions, proofless deposit)


External Actions (HinkalInLogic.sol)

function handleRunExternalAction(CircomData circomData, int256[] approvalChangesPerToken)
    external returns (UTXO[])
  • Computes deltaAmountChanges[i] = calculateDeltaAmount(...) per token.

  • For negative deltas, transfers tokens/NFTs to externalAddress pre-call.

  • Invokes IExternalActionV2(externalAddress).runAction(circomData, deltaAmountChanges) which returns UTXO[] created during the action.

This path is used by Hinkal._internalRunExternalAction to integrate with DeFi targets in a privacy-preserving, atomic way.


Proofless Deposit (HinkalInLogic.sol)

function handleProoflessDeposit(address[] erc20Addresses, uint256[] amounts, uint256[] tokenIds, StealthAddressStructure[] stealthAddressStructures)
    public payable returns (UTXO[] utxoArray)
  • Groups identical (token, tokenId) pairs with calcTokenChangesForProoflessDeposit and accumulates amounts (rejects duplicate NFTs).

  • Pulls funds from msg.sender via handleTransfersFromProoflessDeposit and asserts balanceAfter - balanceBefore == amount per token.

  • Forms UTXOs one-to-one with user inputs using handleUtxoCreationEach, setting timeStamp to block.timestamp.

Used by Hinkal.prooflessDeposit to create on-chain commitments without a ZK proof.


Safety and Helpers

  • erc20SafetyCheck: blacklist of ERC20 methods (approve/mint/transferFrom, etc.) disallowed in external calls via metadata selector checks.

  • isERC20: coarse detection to apply safety checks only when necessary.

  • calculateBalances/calculateAllowances: snapshot helpers.

  • approveMore: adjusts aggregate ERC20 allowances to match individual approval changes exactly.


Reverts and Invariants

  • Proofless deposit: length checks, duplicate NFT protection, and exact transfer assertions


Integration Surface with Hinkal.sol

  • Hinkal._internalRunExternalAction delegates to handleRunExternalAction

  • Hinkal.prooflessDeposit delegates to handleProoflessDeposit

Last updated