IWeirollComponent
Functions
weirollVm
Address of the Weiroll VM.
function weirollVm() external view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
allowedInstrRoot
Root of the Merkle tree containing allowed instructions.
function allowedInstrRoot() external view returns (bytes32);Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
instrCooldownDuration
Cooldown duration for instruction executions in seconds.
function instrCooldownDuration() external view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
accountForPosition
Prices a position.
function accountForPosition(Instruction calldata instruction) external returns (uint256 value);Parameters
| Name | Type | Description |
|---|---|---|
| instruction | Instruction | The accounting instruction. |
Returns
| Name | Type | Description |
|---|---|---|
| value | uint256 | The new position value. |
accountForPositionBatch
Prices a batch of positions.
function accountForPositionBatch(Instruction[] calldata instructions, uint256[] calldata groupIds)
external
returns (uint256[] memory values);Parameters
| Name | Type | Description |
|---|---|---|
| instructions | Instruction[] | The array of accounting instructions. |
| groupIds | uint256[] | Ignored parameter kept to preserve interface compatibility with Makina Core. |
Returns
| Name | Type | Description |
|---|---|---|
| values | uint256[] | 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
| Name | Type | Description |
|---|---|---|
| mgmtInstruction | Instruction | The management instruction. |
| acctInstruction | Instruction | The accounting instruction. |
Returns
| Name | Type | Description |
|---|---|---|
| value | uint256 | The new position value, or 0 if acctInstruction was not provided. |
| change | int256 | The 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
| Name | Type | Description |
|---|---|---|
| mgmtInstructions | Instruction[] | The array of management instructions. |
| acctInstructions | Instruction[] | The array of accounting instructions. |
Returns
| Name | Type | Description |
|---|---|---|
| values | uint256[] | The new position values. |
| changes | int256[] | The changes in the position values. |
manageFlashLoan
Manages flash loan funds.
function manageFlashLoan(Instruction calldata instruction, address token, uint256 amount) external;Parameters
| Name | Type | Description |
|---|---|---|
| instruction | Instruction | The flash loan management instruction. |
| token | address | The loan token. |
| amount | uint256 | The loan amount. |
harvest
Harvests one or multiple positions.
function harvest(Instruction calldata instruction, ISwapComponent.SwapOrder[] calldata swapOrders) external;Parameters
| Name | Type | Description |
|---|---|---|
| instruction | Instruction | The harvest instruction. |
| swapOrders | ISwapComponent.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
| Name | Type | Description |
|---|---|---|
| newAllowedInstrRoot | bytes32 | The new Merkle root. |
setAccountingCurrency
Sets the currency used to value positions.
function setAccountingCurrency(address newAccountingCurrency) external;Parameters
| Name | Type | Description |
|---|---|---|
| newAccountingCurrency | address | The new currency. |
setMaxPositionIncreaseLossBps
Sets the maximum allowed relative value loss for position increases while in WALLED mode.
function setMaxPositionIncreaseLossBps(uint256 newMaxPositionIncreaseLossBps) external;Parameters
| Name | Type | Description |
|---|---|---|
| newMaxPositionIncreaseLossBps | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| newMaxPositionDecreaseLossBps | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| newInstrCooldownDuration | uint256 | The new cooldown duration in seconds. |
Events
AllowedInstrRootChanged
event AllowedInstrRootChanged(bytes32 indexed oldRoot, bytes32 indexed newRoot);Parameters
| Name | Type | Description |
|---|---|---|
| oldRoot | bytes32 | |
| newRoot | bytes32 |
AccountingCurrencyChanged
event AccountingCurrencyChanged(address indexed oldAccountingCurrency, address indexed newAccountingCurrency);Parameters
| Name | Type | Description |
|---|---|---|
| oldAccountingCurrency | address | |
| newAccountingCurrency | address |
InstrCooldownDurationChanged
event InstrCooldownDurationChanged(uint256 oldInstrCooldownDuration, uint256 newInstrCooldownDuration);Parameters
| Name | Type | Description |
|---|---|---|
| oldInstrCooldownDuration | uint256 | |
| newInstrCooldownDuration | uint256 |
MaxPositionIncreaseLossBpsChanged
event MaxPositionIncreaseLossBpsChanged(
uint256 oldMaxPositionIncreaseLossBps, uint256 newMaxPositionIncreaseLossBps
);Parameters
| Name | Type | Description |
|---|---|---|
| oldMaxPositionIncreaseLossBps | uint256 | |
| newMaxPositionIncreaseLossBps | uint256 |
MaxPositionDecreaseLossBpsChanged
event MaxPositionDecreaseLossBpsChanged(
uint256 oldMaxPositionDecreaseLossBps, uint256 newMaxPositionDecreaseLossBps
);Parameters
| Name | Type | Description |
|---|---|---|
| oldMaxPositionDecreaseLossBps | uint256 | |
| newMaxPositionDecreaseLossBps | uint256 |
PositionManaged
event PositionManaged(bool indexed withValuation, bool indexed guarded, uint256 indexed positionId, uint256 value);Parameters
| Name | Type | Description |
|---|---|---|
| withValuation | bool | |
| guarded | bool | |
| positionId | uint256 | |
| value | uint256 |
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
| Name | Type | Description |
|---|---|---|
| positionId | uint256 | The ID of the involved position. |
| isDebt | bool | Whether the position is a debt. |
| groupId | uint256 | The ID of the position accounting group. Set to 0 if the instruction is not of type ACCOUNTING, or if the involved position is ungrouped. |
| instructionType | InstructionType | The type of the instruction. |
| affectedTokens | address[] | The array of affected tokens. |
| positionTokens | address[] | The array of position tokens. |
| commands | bytes32[] | The array of commands. |
| state | bytes[] | The array of state. |
| stateBitmap | uint128 | The state bitmap. |
| merkleProof | bytes32[] | The array of Merkle proof elements. |
Enums
InstructionType
enum InstructionType {
MANAGEMENT,
ACCOUNTING,
HARVEST,
FLASHLOAN_MANAGEMENT
}Variants
| Name | Description |
|---|---|
| MANAGEMENT | |
| ACCOUNTING | |
| HARVEST | |
| FLASHLOAN_MANAGEMENT |