ComplexOpcodes

You should add to this file opcodes for some complex structures. These may be arrays, structs and others

opLoadRemoteAny

function opLoadRemoteAny(address _ctxProgram, address _ctxDSL) public

opLoadRemoteUint256

function opLoadRemoteUint256(address _ctxProgram, address) public

opLoadRemoteBytes32

function opLoadRemoteBytes32(address _ctxProgram, address) public

opLoadRemoteBool

function opLoadRemoteBool(address _ctxProgram, address) public

opLoadRemoteAddress

function opLoadRemoteAddress(address _ctxProgram, address) public

opDeclare

function opDeclare(address _ctxProgram, address) public

Declares an empty array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
address

opPush

function opPush(address _ctxProgram, address) public

Inserts an item to array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
address

opGet

function opGet(address _ctxProgram, address) public

Gets an element by its index in the array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
address

opLengthOf

function opLengthOf(address _ctxProgram, address) public

Get length of an array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
address

opSumOf

function opSumOf(address _ctxProgram, address _ctxDSL) public

Sums uin256 elements from the array (array name should be provided)

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_ctxDSL address DSLContext contract instance address

opSumThroughStructs

function opSumThroughStructs(address _ctxProgram, address _ctxDSL) public

Sums struct variables values from the struct type array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_ctxDSL address DSLContext contract instance address

opVotersBalance

function opVotersBalance(address _ctxProgram, address) public

Finds a sum of all tokens of users in the array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
address

opStruct

function opStruct(address _ctxProgram, address) public

Inserts items to DSL structures using mixed variable name (ex. BOB.account). Struct variable names already contain a name of a DSL structure, . dot symbol, the name of variable. endStruct word (0xcb398fe1) is used as an indicator for the ending loop for the structs parameters

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
address

opCompound

function opCompound(address _ctxProgram, address _ctxDSL) public

Master opcode to interact with Compound V2. Needs sub-commands to be executed

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_ctxDSL address DSLContext contract address

opCompoundDeposit

function opCompoundDeposit(address _ctxProgram) public

Sub-command of Compound V2. Makes a deposit of funds to Compound V2

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address

opCompoundWithdraw

function opCompoundWithdraw(address _ctxProgram) public

Sub-command of Compound V2. Makes a withdrawal of funds to Compound V2

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address

_sumOfStructVars

function _sumOfStructVars(address _ctxProgram, bytes32 _arrNameB32, bytes4 _varName, bytes32 _length) internal returns (uint256 total)

Sums struct variables values from the struct type array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_arrNameB32 bytes32 Array's name in bytecode
_varName bytes4 Struct's name in bytecode
_length bytes32 Array's length in bytecode

Return Values

Name Type Description
total uint256 Total sum of each element in the struct type of array

_opLoadRemote

function _opLoadRemote(address _ctxProgram, string _funcSignature) internal

Loads a variable value from another smart contract

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_funcSignature string Signature of the "read" function

_mustDelegateCall

function _mustDelegateCall(address _ctxProgram, address _ctxDSL, string _opcode) internal

Makes a delegate call and ensures it is successful

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_ctxDSL address DSLContext contract address
_opcode string Opcode string

_getArrLength

function _getArrLength(address _ctxProgram, bytes32 _arrNameB32) internal returns (bytes32 result)

Returns array's length

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_arrNameB32 bytes32 Array's name in bytecode

Return Values

Name Type Description
result bytes32 Array's length in bytecode

_getItem

function _getItem(address _ctxProgram, uint256 _index, bytes32 _arrNameB32) internal returns (bytes item)

Returns the element from the array

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_index uint256 Array's index
_arrNameB32 bytes32 Array's name in bytecode

Return Values

Name Type Description
item bytes Item from the array by its index

_sumOfVars

function _sumOfVars(address _ctxProgram, bytes32 _arrNameB32, bytes32 _length) internal returns (uint256 total)

Sums uin256 elements from the array (array name should be provided)

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_arrNameB32 bytes32 Array's name in bytecode
_length bytes32 Array's length in bytecode

Return Values

Name Type Description
total uint256 Total sum of each element in the uint256 type of array

_checkArrType

function _checkArrType(address _ctxDSL, address _ctxProgram, bytes32 _arrNameB32, string _typeName) internal

Checks the type for array

Parameters

Name Type Description
_ctxDSL address DSLContext contract address
_ctxProgram address ProgramContext contract address
_arrNameB32 bytes32 Array's name in bytecode
_typeName string Type of the array, ex. uint256, address, struct