This project uses deno. So install deno first
-
Then to install dependencies run:
deno install
-
Update
.env
using the.env.example
and update the dna token from apibara -
Update the
REDIS_URL
in the.env
file -
For generating the prisma client and tables run:
deno run -A npm:prisma generate && deno run -A npm:prisma db push
chmod u+x ./start-indexers.sh && ./start-indexers.sh
deno run dev
Events are emitted during each function in this particular order
- Depositing
Transfer
with from address = 0x0Deposit
- Depositing with a referral
Transfer
with from address = 0x0Deposit
Referral
- Withdrawal of xstrk
Approval
(not always, only when caller != owner) // while spending allowance of strkTransfer
with to address = 0x0Withdraw
- Transfering tokens
Transfer
To run the testcases
cp .env.sample .env
There are 2 entry points for Depositing fn deposit()
and fn mint()
and 2 for
withdraing fn withdraw()
and fn redeem()
but have verfied the above event
flow remains the same regardless of the function chosen as entry point
- To not double count any transaction by listening events
- Not double counting deposits and deposit with referral
- to not double count transfer in mint/burn(deposit/withdrawl)
- There could be muticall in a single transaction too emitting multple of the above together
- To listen only events that emitted from the lst contract
- Ignore the
Transfer
events that have either thefrom
as 0x0 orto
0x0 - Not listen for explicitly
Referral
event but onlyDeposit
to check for the Referral by following- To check the transaction reciepts of each transaction which has all the evnets emitted in that transaction
- Filter out the events that emitted from the lst contract
- For each deposit check that exactly after
Deposit
eventReferral
is present or not - if yes thats referral txn otherwise not, then store referal code in the deposits table
- if not consider it as normal deposit event