Skip to content

Commit

Permalink
Merge branch 'v55'
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Oct 20, 2024
2 parents 4ea5fed + 4b89128 commit 74cc455
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 19 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Set squid version to prod
on:
push:
tags:
- 'prod'

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install squid CLI
run: npm i -g @subsquid/cli

- name: npm install
run: npm i

- name: Authenticate to squid
env:
API_TOKEN: ${{ secrets.SQUID_API_TOKEN }}
run: sqd auth -k $API_TOKEN

- name: update squid.yml
run: |
# Get the branch name from GitHub
BRANCH_NAME=${{ github.ref_name }}
# Update prod tag
sqd tags add prod --name origin-squid -s $BRANCH_NAME --allow-tag-reassign
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Release squid

name: Release squid version
on:
push:
tags:
- 'v*'
branches:
- 'v[0-9]+'

jobs:
build_and_publish:
Expand All @@ -25,22 +24,22 @@ jobs:

- name: update squid.yml
run: |
# Get the tag from GitHub
TAG=$(echo ${{ github.ref }} | sed 's/refs\/tags\///')
# Extract the numeric part of the tag
VERSION=$(echo $TAG | sed 's/v//')
# Get the branch name from GitHub
BRANCH_NAME=${{ github.ref_name }}
# Extract the version from the branch name (assuming format 'vXX')
VERSION=$(echo $BRANCH_NAME | sed 's/^v//')
# Update the version in squid.yaml
sed -i "s/^version: .*/version: $VERSION/" squid.yaml
# Optional: Print the updated version for verification
echo "Updated squid.yaml version to: $VERSION"
- name: Authenticate to squid
env:
env:
API_TOKEN: ${{ secrets.SQUID_API_TOKEN }}
run: sqd auth -k $API_TOKEN

- name: Build and deploy squid
run: sqd build && sqd deploy . -o origin --no-stream-logs
run: sqd build && sqd deploy . -o origin --no-stream-logs --allow-update
21 changes: 16 additions & 5 deletions src/templates/origin-arm/origin-arm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const createOriginARMProcessors = ({
topic0: [originLidoArmAbi.events.RedeemRequested.topic],
range: { from },
})
const feeCollectedFilter = logFilter({
address: [armAddress],
topic0: [originLidoArmAbi.events.FeeCollected.topic],
range: { from },
})
const tracker = blockFrequencyTracker({ from })
let armEntity: Arm
let initialized = false
Expand Down Expand Up @@ -86,6 +91,7 @@ export const createOriginARMProcessors = ({
p.addLog(redeemClaimedFilter.value)
p.addLog(depositFilter.value)
p.addLog(withdrawalFilter.value)
p.addLog(feeCollectedFilter.value)
},
initialize,
process: async (ctx: Context) => {
Expand All @@ -106,7 +112,7 @@ export const createOriginARMProcessors = ({
}))
)
}
const getCurrentState = async (block: Block, extra?: { deposit: bigint; withdrawal: bigint }) => {
const getCurrentState = async (block: Block) => {
const stateId = getStateId(block)
if (states[states.length - 1]?.id === stateId) {
return states[states.length - 1]
Expand Down Expand Up @@ -147,9 +153,9 @@ export const createOriginARMProcessors = ({
totalAssetsCap,
totalSupply,
assetsPerShare,
totalDeposits: (previousState?.totalDeposits ?? 0n) + (extra?.deposit ?? 0n),
totalWithdrawals: (previousState?.totalWithdrawals ?? 0n) + (extra?.withdrawal ?? 0n),
totalFees: feesAccrued,
totalDeposits: previousState?.totalDeposits ?? 0n,
totalWithdrawals: previousState?.totalWithdrawals ?? 0n,
totalFees: previousState?.totalFees ?? 0n,
totalYield: 0n,
})
armStateEntity.totalYield = calculateTotalYield(armStateEntity)
Expand All @@ -159,7 +165,6 @@ export const createOriginARMProcessors = ({
const calculateTotalYield = (state: ArmState) =>
state.totalAssets - state.totalDeposits + state.totalWithdrawals

// ArmWithdrawalRequest
for (const block of ctx.blocks) {
if (tracker(ctx, block)) {
// ArmState
Expand Down Expand Up @@ -204,6 +209,7 @@ export const createOriginARMProcessors = ({
dailyStatsMap.set(currentDayId, armDailyStatEntity)
}
for (const log of block.logs) {
// ArmWithdrawalRequest
if (redeemRequestedFilter.matches(log)) {
const event = originLidoArmAbi.events.RedeemRequested.decode(log)
const eventId = `${ctx.chain.id}:${armAddress}:${event.requestId}`
Expand Down Expand Up @@ -243,6 +249,11 @@ export const createOriginARMProcessors = ({
state.totalWithdrawals += event.assets
state.totalYield = calculateTotalYield(state)
}
if (feeCollectedFilter.matches(log)) {
const event = originLidoArmAbi.events.FeeCollected.decode(log)
const state = await getCurrentState(block)
state.totalFees += event.fee
}
}
}
await ctx.store.insert(states)
Expand Down

0 comments on commit 74cc455

Please sign in to comment.