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 helperscontracts/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
externalAddresspre-call.Invokes
IExternalActionV2(externalAddress).runAction(circomData, deltaAmountChanges)which returnsUTXO[]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 withcalcTokenChangesForProoflessDepositand accumulates amounts (rejects duplicate NFTs).Pulls funds from
msg.senderviahandleTransfersFromProoflessDepositand assertsbalanceAfter - balanceBefore == amountper token.Forms UTXOs one-to-one with user inputs using
handleUtxoCreationEach, settingtimeStamptoblock.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._internalRunExternalActiondelegates tohandleRunExternalActionHinkal.prooflessDepositdelegates tohandleProoflessDeposit
Last updated

