Skip to main content

LighterCodec

Builds Lighter commands that move no money to a chosen receiver. It holds nothing and has no permission. Deposits and the collection of finished withdrawals are not here: the vault builds them itself with its own address as the receiver. It runs behind a UUPS proxy.

Deployer​

initialize​

function initialize() external;

Once, through the proxy, in the transaction that deploys it.

Read​

market​

function market() external view returns (IGedhoMarket);

Market whose orders it builds.

ReturnsType
-IGedhoMarket

target​

function target() external view returns (address);

Contract that receives the commands.

ReturnsType
-address

closeShort​

function closeShort(
uint48 accountIndex,
uint256 size,
uint256 maxPrice
) external view returns (bytes memory);

Market order that can only reduce the short. Lighter refuses it when size times price is above the quote limit of the market.

ParameterTypeDescription
accountIndexuint48
sizeuint256In the decimals of the asset, a multiple of the lot. Zero means the whole short.
maxPriceuint256Worst price with 8 decimals, rounded up to the Lighter price step.
ReturnsType
-bytes

cancelAllOrders​

function cancelAllOrders(
uint48 accountIndex
) external view returns (bytes memory);
ParameterType
accountIndexuint48
ReturnsType
-bytes

withdraw​

function withdraw(
uint48 accountIndex,
uint256 amount
) external view returns (bytes memory);

Withdrawal to the owner of the account, which is the vault.

ParameterTypeDescription
accountIndexuint48
amountuint256USDG with 6 decimals.
ReturnsType
-bytes

setApiKey​

function setApiKey(
uint48 accountIndex,
uint8 slot,
bytes calldata publicKey
) external view returns (bytes memory);

Installs an API key.

ParameterType
accountIndexuint48
slotuint8
publicKeybytes
ReturnsType
-bytes

removeApiKey​

function removeApiKey(
uint48 accountIndex,
uint8 slot
) external view returns (bytes memory);

Replaces an API key by a key that nobody owns.

ParameterType
accountIndexuint48
slotuint8
ReturnsType
-bytes

Errors​

ValueOutOfRange​

error ValueOutOfRange();

The size, price or key does not fit the Lighter format.