Skip to content
LogoLogo

IWeirollComponent

Git Source

Functions

weirollVm

Address of the Weiroll VM.

function weirollVm() external view returns (address);

Returns

NameTypeDescription
<none>address

allowedInstrRoot

Root of the Merkle tree containing allowed instructions.

function allowedInstrRoot() external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32

accountingCurrency

Currency used to value positions.

If set to address(0), the reference currency of the OracleRegistry is used.

function accountingCurrency() external view returns (address);

Returns

NameTypeDescription
<none>address

maxPositionIncreaseLossBps

Max allowed value loss (in basis points) when increasing a position while in WALLED mode.

function maxPositionIncreaseLossBps() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256

maxPositionDecreaseLossBps

Max allowed value loss (in basis points) when decreasing a position while in WALLED mode.

function maxPositionDecreaseLossBps() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256

instrCooldownDuration

Cooldown duration for instruction executions in seconds.

function instrCooldownDuration() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256

accountForPosition

Prices a position.

function accountForPosition(Instruction calldata instruction) external returns (uint256 value);

Parameters

NameTypeDescription
instructionInstructionThe accounting instruction.

Returns

NameTypeDescription
valueuint256The new position value.

accountForPositionBatch

Prices a batch of positions.

function accountForPositionBatch(Instruction[] calldata instructions, uint256[] calldata groupIds)
        external
        returns (uint256[] memory values);

Parameters

NameTypeDescription
instructionsInstruction[]The array of accounting instructions.
groupIdsuint256[]Ignored parameter kept to preserve interface compatibility with Makina Core.

Returns

NameTypeDescription
valuesuint256[]The new position values.

managePosition

Manages a position's state through paired management and accounting instructions.

If acctInstruction is provided, it is executed before and after the management instruction to compute the new position value and its signed delta.

In WALLED mode, acctInstruction must be provided and value preservation checks are applied using a validation matrix to prevent economic inconsistencies between position changes and token flows.

The WALLED mode matrix evaluates three factors to determine required validations:

  • Affected Tokens flow - Sign of the change in the Safe's aggregate value of mgmtInstruction.affectedTokens
  • Debt Position - Whether position represents protocol liability (true) vs asset (false)
  • Position Δ direction - Direction of position value change (increase/decrease/null)

┌──────────────────────┬───────────────┬──────────────────────┬───────────────────────────┐ │ Affected Tokens flow │ Debt Position │ Position Δ direction │ Action │ ├──────────────────────┼───────────────┼──────────────────────┼───────────────────────────┤ │ Outflow │ No │ Decrease │ Revert: Invalid direction │ │ Outflow │ Yes │ Increase │ Revert: Invalid direction │ │ Outflow │ No │ Increase / Null │ Minimum Δ Check │ │ Outflow │ Yes │ Decrease / Null │ Minimum Δ Check │ │ Inflow / Null │ No │ Decrease │ Maximum Δ Check │ │ Inflow / Null │ Yes │ Increase │ Maximum Δ Check │ │ Inflow / Null │ No │ Increase / Null │ No check (favorable move) │ │ Inflow / Null │ Yes │ Decrease / Null │ No check (favorable move) │ └──────────────────────┴───────────────┴──────────────────────┴───────────────────────────┘

function managePosition(Instruction calldata mgmtInstruction, Instruction calldata acctInstruction)
        external
        returns (uint256 value, int256 change);

Parameters

NameTypeDescription
mgmtInstructionInstructionThe management instruction.
acctInstructionInstructionThe accounting instruction.

Returns

NameTypeDescription
valueuint256The new position value, or 0 if acctInstruction was not provided.
changeint256The signed position value delta, or 0 if acctInstruction was not provided.

managePositionBatch

Manages a batch of positions.

Convenience function to manage multiple positions in a single transaction.

function managePositionBatch(Instruction[] calldata mgmtInstructions, Instruction[] calldata acctInstructions)
        external
        returns (uint256[] memory values, int256[] memory changes);

Parameters

NameTypeDescription
mgmtInstructionsInstruction[]The array of management instructions.
acctInstructionsInstruction[]The array of accounting instructions.

Returns

NameTypeDescription
valuesuint256[]The new position values.
changesint256[]The changes in the position values.

manageFlashLoan

Manages flash loan funds.

function manageFlashLoan(Instruction calldata instruction, address token, uint256 amount) external;

Parameters

NameTypeDescription
instructionInstructionThe flash loan management instruction.
tokenaddressThe loan token.
amountuint256The loan amount.

harvest

Harvests one or multiple positions.

function harvest(Instruction calldata instruction, ISwapComponent.SwapOrder[] calldata swapOrders) external;

Parameters

NameTypeDescription
instructionInstructionThe harvest instruction.
swapOrdersISwapComponent.SwapOrder[]The array of swap orders to be executed after the harvest.

setAllowedInstrRoot

Sets the root of the Merkle tree containing allowed instructions.

function setAllowedInstrRoot(bytes32 newAllowedInstrRoot) external;

Parameters

NameTypeDescription
newAllowedInstrRootbytes32The new Merkle root.

setAccountingCurrency

Sets the currency used to value positions.

function setAccountingCurrency(address newAccountingCurrency) external;

Parameters

NameTypeDescription
newAccountingCurrencyaddressThe new currency.

setMaxPositionIncreaseLossBps

Sets the maximum allowed relative value loss for position increases while in WALLED mode.

function setMaxPositionIncreaseLossBps(uint256 newMaxPositionIncreaseLossBps) external;

Parameters

NameTypeDescription
newMaxPositionIncreaseLossBpsuint256The new maximum value loss in basis points.

setMaxPositionDecreaseLossBps

Sets the maximum allowed relative value loss for position decreases while in WALLED mode.

function setMaxPositionDecreaseLossBps(uint256 newMaxPositionDecreaseLossBps) external;

Parameters

NameTypeDescription
newMaxPositionDecreaseLossBpsuint256The new maximum value loss in basis points.

setInstrCooldownDuration

Sets the cooldown duration for instruction executions while in WALLED mode.

function setInstrCooldownDuration(uint256 newInstrCooldownDuration) external;

Parameters

NameTypeDescription
newInstrCooldownDurationuint256The new cooldown duration in seconds.

Events

AllowedInstrRootChanged

event AllowedInstrRootChanged(bytes32 indexed oldRoot, bytes32 indexed newRoot);

Parameters

NameTypeDescription
oldRootbytes32
newRootbytes32

AccountingCurrencyChanged

event AccountingCurrencyChanged(address indexed oldAccountingCurrency, address indexed newAccountingCurrency);

Parameters

NameTypeDescription
oldAccountingCurrencyaddress
newAccountingCurrencyaddress

InstrCooldownDurationChanged

event InstrCooldownDurationChanged(uint256 oldInstrCooldownDuration, uint256 newInstrCooldownDuration);

Parameters

NameTypeDescription
oldInstrCooldownDurationuint256
newInstrCooldownDurationuint256

MaxPositionIncreaseLossBpsChanged

event MaxPositionIncreaseLossBpsChanged(
        uint256 oldMaxPositionIncreaseLossBps, uint256 newMaxPositionIncreaseLossBps
    );

Parameters

NameTypeDescription
oldMaxPositionIncreaseLossBpsuint256
newMaxPositionIncreaseLossBpsuint256

MaxPositionDecreaseLossBpsChanged

event MaxPositionDecreaseLossBpsChanged(
        uint256 oldMaxPositionDecreaseLossBps, uint256 newMaxPositionDecreaseLossBps
    );

Parameters

NameTypeDescription
oldMaxPositionDecreaseLossBpsuint256
newMaxPositionDecreaseLossBpsuint256

PositionManaged

event PositionManaged(bool indexed withValuation, bool indexed guarded, uint256 indexed positionId, uint256 value);

Parameters

NameTypeDescription
withValuationbool
guardedbool
positionIduint256
valueuint256

Structs

Instruction

Instruction parameters.

struct Instruction {
        uint256 positionId;
        bool isDebt;
        uint256 groupId;
        InstructionType instructionType;
        address[] affectedTokens;
        address[] positionTokens;
        bytes32[] commands;
        bytes[] state;
        uint128 stateBitmap;
        bytes32[] merkleProof;
    }

Properties

NameTypeDescription
positionIduint256The ID of the involved position.
isDebtboolWhether the position is a debt.
groupIduint256The ID of the position accounting group.
Set to 0 if the instruction is not of type ACCOUNTING, or if the involved position is ungrouped.
instructionTypeInstructionTypeThe type of the instruction.
affectedTokensaddress[]The array of affected tokens.
positionTokensaddress[]The array of position tokens.
commandsbytes32[]The array of commands.
statebytes[]The array of state.
stateBitmapuint128The state bitmap.
merkleProofbytes32[]The array of Merkle proof elements.

Enums

InstructionType

enum InstructionType {
        MANAGEMENT,
        ACCOUNTING,
        HARVEST,
        FLASHLOAN_MANAGEMENT
    }

Variants

NameDescription
MANAGEMENT
ACCOUNTING
HARVEST
FLASHLOAN_MANAGEMENT