The example position hook is an easy way to get started.A user’s Divvi wallet invokes position hooks when determining the types, quantity, and value of assets a user owns. If a position hook detects a user owns one or more positions, it provides information about the positions for the app to show to the user.
https://github.com/divvi-xyz/hooks/tree/main/src/apps/ubeswap
.
Position pricing hooks must implement the PositionsHook
TypeScript interface.
MyApp
, you will need to create a new folder with the name my-app
in src/apps
and add a positions.ts
file. The file should export an object with the following properties:
getPositionDefinitions
getPositionDefinitions
function is called by Divvi apps to get the positions owned by a user.
It receives the following arguments:
network
: the network for which the positions should be returned.address
: the address of the user for which the positions should be returned.PositionDefinition
objects.
The PositionDefinition
is either an AppTokenPositionDefinition
or a ContractPositionDefinition
, representing an app token or a contract position respectively.
getPositionDefinitions
implementation for representing locked CELO owned by a user.
Please take a look at the full implementation for more details.
type
: the type of position definition. In this case, it’s a contract-position-definition
.network
: the network of the position definition.address
: the address of the contract for the position definition.tokens
: the base tokens that the position definition represents. In this case, it’s just CELO.label
: a human-readable label for the position definition.balances
: a function that returns the balances of the base tokens represented by the position definition.getPositions
script via the command line.
LOG_LEVEL
environment variable to debug
.