buyAndLockTokens function, although the contract has additional and currently unused functions for locking tokens.
Locking Tokens
Events
Functions
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.