Skip to main content

IShAgent Interface

Agent Functions

Agent functions allow policy agents to manage or move tokens on behalf of users, subject to the constraints of the policy. These functions are designed to offer guarantees to agents operating under the constraints of asynchronous execution.


hold

function hold(
uint64 policyID,
address account,
uint256 amount
) external;

Places a "hold" on amount of a user’s bonded tokens under a specific policy, preventing them from being moved or unbonded until released.

note

Holds are meant to be issued and expire inside of the same transaction, and are typically used to proactively prevent double-spending.

release

function release(
uint64 policyID,
address account,
uint256 amount
) external;

Releases a previously placed "hold" on amount of a user’s bonded tokens, making those tokens freely available to move or unbond again.


batchHold

function batchHold(
uint64 policyID,
address[] calldata accounts,
uint256[] memory amounts
) external;

Performs multiple hold operations in one transaction, holding tokens for multiple accounts.

batchRelease

function batchRelease(
uint64 policyID,
address[] calldata accounts,
uint256[] calldata amounts
) external;

Performs multiple release operations in one transaction, releasing tokens for multiple accounts.


agentTransferFromBonded

function agentTransferFromBonded(
uint64 policyID,
address from,
address to,
uint256 amount,
uint256 fromReleaseAmount
) external;

Transfers amount of bonded tokens from from to to, optionally releasing fromReleaseAmount from a hold first. Does not change the total supply of bonded tokens.


agentWithdrawFromBonded

function agentWithdrawFromBonded(
uint64 policyID,
address from,
address to,
uint256 amount,
uint256 fromReleaseAmount
) external;

Transfers amount of underlying assets from a bonded position directly to the to address by first converting the appropriate number of shares. Optionally releases fromReleaseAmount from a hold first.


agentExecuteWithSponsor

function agentExecuteWithSponsor(
uint64 policyID,
address payor,
address recipient,
uint256 msgValue,
uint256 gasLimit,
address callTarget,
bytes calldata callData
) external payable
returns (
uint128 actualPayorCost,
bool success,
bytes memory returnData
);

Executes a call to callTarget with callData, sponsored by the payor’s bonded balance in a particular policy. The recipient receives the cost charged to the payor’s bonded balance. Returns the actual cost paid, whether the call succeeded, and any returned data.

Parameters

NameTypeDescription
policyIDuint64Policy under which the payor's bonded balance is debited
payoraddressAddress whose bonded balance will sponsor the gas cost
recipientaddressAddress receiving the sponsored cost
msgValueuint256Amount of Ether (or native token) passed along to the inner call, combined with any additional funds from msg.value
gasLimituint256Gas limit to be used for the inner call
callTargetaddressAddress of the contract to call
callDatabytesCalldata to pass to callTarget

Returns

NameTypeDescription
actualPayorCostuint128Final amount of bonded tokens spent by the payor
successboolIndicates whether the inner call succeeded
returnDatabytesData returned by the inner call