https://github.com/glottologist/liquid-dapp
Simple liquid staking dapp to demonstrate event emission in Tezos
https://github.com/glottologist/liquid-dapp
Last synced: 3 months ago
JSON representation
Simple liquid staking dapp to demonstrate event emission in Tezos
- Host: GitHub
- URL: https://github.com/glottologist/liquid-dapp
- Owner: glottologist
- Created: 2022-04-12T09:41:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-03T16:17:06.000Z (about 3 years ago)
- Last Synced: 2024-12-27T05:23:19.616Z (5 months ago)
- Language: LigoLANG
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# liquid-dapp
Simple liquid staking dapp to demonstrate event emission in Tezos## Building
The easiest way to build is to use `nix`. With nix installed you can spin up a development shell in the project root using:
```nix
nix develop
```Once in the shell, use `build` to compile the ligo liquid contract.
## Patching the Michelson code
Ligo doesn't currently support event emission so that compiled Michelson code needs to be adjusted to emit the events correctly. In the resulting compiled code for the liquid contract `liquid.tz` there is a string marker to help narrow down the place that needs to be amended. In the code one can look for a string "This is the emission function". The surrounding code should be of the following format:
```Michelson
APPLY ;
LAMBDA
(pair nat nat)
unit
{ CDR ;
INT ;
ISNAT ;
IF_NONE
{ PUSH string "This is the emission function" ; FAILWITH }
{ DROP ; UNIT } } ;
```The `(pair nat nat)` is the liquid exchange rate that needs to be emited. This can be accomplished with the following:
```Michelson
PUSH nat ???; PUSH string "xrate"; EMIT
```This needs to be patched in between the first `APPLY;` and the callsite of the lambda `LAMBDA` so the patched code should look like the following:
```Michelson
APPLY ;
PUSH nat ???; PUSH string "xrate"; EMIT
LAMBDA
(pair nat nat)
unit
{ CDR ;
INT ;
ISNAT ;
IF_NONE
{ PUSH string "This is the emission function" ; FAILWITH }
{ DROP ; UNIT } } ;
```Once the compiled code has been patched it can then be deployed.
## Deploy