pub fn adapter_invoke<'info>(
    ctx: Context<'_, '_, '_, 'info, AdapterInvoke<'info>>,
    data: Vec<u8>
) -> Result<()>
Expand description

Perform an action by invoking other programs, allowing them to alter the balances of the token accounts belonging to this margin account.

This provides the margin account as a signer to any invoked instruction, and therefore grants the adapter authority over any tokens held by the margin account.

This validates the invoked program by expecting an adapter_metadata account, which must exist for the instruction to be considered valid. The configuration for allowing adapter programs is controlled by protocol governance.

All extra accounts passed in are used as the input accounts when invoking the provided adapter porgram.

Parameters

  • data - The instruction data to pass to the adapter program

Accounts

NameTypeDescription
ownersignerThe authority that owns the margin account.
margin_accountwritableThe margin account to proxy an action for.
adapter_programread_onlyThe program to be invoked.
adapter_metadataread_onlyThe metadata about the proxy program.

Events

Event NameDescription
events::AdapterInvokeBeginMarks the start of the adapter invocation (includes the margin account pubkey and the adapter program pubkey).
events::PositionEvent (Note that each single event represents a different adapter position)The PositionEvent marks the change in position.
events::AdapterInvokeEndMarks the ending of the adapter invocation (includes no data except for the event itself being emitted).