Skip to main content
Vault allows users of context.markets to lock tokens until resolution so that Context might reward them as part of its rewards program. There is no onchain guarantee that interacting with the Vault will earn rewards. Vault is designed to be interacted with via the Context interface. Rewards are distributed in a separate contract at Context’s discretion according to the rules of its rewards program. This page documents the latest version of the Vault contract. The current Context interface only supports locking via the buyAndLockTokens function, although the contract has additional and currently unused functions for locking tokens.

Locking Tokens

Events

event LockUpdated(
    bytes32 indexed marketId, address indexed locker, uint256[] newAmounts, uint256[] totalAmounts, uint256 nonce
);
event TokensPurchasedAndLocked(
    bytes32 indexed marketId,
    address indexed user,
    uint256[] sharesPurchased,
    uint256 cost,
    uint256[] totalLocked,
    uint256 nonce
);
event Unlocked(bytes32 indexed marketId, address indexed locker, uint256[] amounts);

Functions

function buyAndLockTokens(
    bytes32 marketId,
    uint256[] memory amounts,
    uint256 maxCost,
    uint256 deadline,
    uint256 nonce
);
function unlock(bytes32 marketId);
The current Context UI uses buyAndLockTokens to accomplish both actions in a single call, rather than our currently unused addLock (tokens must already be purchased) or sponsoredLock (like buyAndLockTokens but with an admin-signed USDC subsidy) functions which can be seen on github or basescan. A lock for a market can be added to multiple times while a market is not yet resolved to increase the locked position. While outcome tokens for a market are locked, the Vault holds those tokens. unlock can be called one time per user per market, and it returns all of their locked tokens only after a market is resolved. This means that one should only lock tokens if they are comfortable holding until resolution. See this note for more information on oracles and trust in the protocol. One should not buy let alone lock outcome tokens for a market with an oracle that they do not trust to act reliably and correctly. buyAndLockTokens takes the USDC necessary to purchase amounts tokens (can buy multiple outcome tokens in one call) from the user, purchases those tokens as long as the trade is under maxCost and before deadline, and locks them in the Vault until resolution. The function emits both TokensPurchasedAndLocked and LockUpdated events. A nonce can only be used once per buyer.

Still have questions?

Ask in Discord.