Skip to content

Commit

Permalink
[for-new-stake] change exit queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Cast0001 committed Sep 12, 2024
1 parent 193187b commit d7e09fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/graphql/subgraph/exitQueue/exitQueueQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query exitQueue($receiver: Bytes, $vault: String!) {
}) {
withdrawalTimestamp
positionTicket
isV2Position
totalShares
totalAssets
timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import vaultMulticall from '../../../../contracts/multicall/vaultMulticall'
type ExitRequest = {
withdrawalTimestamp: string | null
positionTicket: string
isV2Position: boolean
totalShares: string
totalAssets: string
timestamp: string
Expand All @@ -21,7 +22,7 @@ export type ParseExitRequestsInput = {
type Position = {
exitQueueIndex: bigint
positionTicket: string
isV1Position: boolean
isV2Position: boolean
timestamp: string
}

Expand Down Expand Up @@ -115,7 +116,7 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise<ParseE
queuedAssets = 0n

for (let i = 0; i < indexes.length; i++) {
const { positionTicket, timestamp, totalShares, totalAssets } = exitRequests[i]
const { positionTicket, timestamp, totalShares, totalAssets, isV2Position } = exitRequests[i]

queuedShares += BigInt(totalShares || 0)
queuedAssets += BigInt(totalAssets || 0)
Expand All @@ -133,8 +134,7 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise<ParseE
const is24HoursPassed = await _checkTimestamp(timestamp, provider)

if (is24HoursPassed) {
const isV1Position = BigInt(totalShares) > 0
const item = { exitQueueIndex, positionTicket, timestamp, isV1Position }
const item = { exitQueueIndex, positionTicket, timestamp, isV2Position }

claims.push(item)
}
Expand Down Expand Up @@ -180,14 +180,14 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise<ParseE
let withdrawableAssets = 0n

exitedAssetsResponse.forEach(({ exitedTickets, exitedAssets }, i) => {
const { isV1Position } = claims[i]
const { isV2Position } = claims[i]

if (isV1Position) {
// in V1 exit queue exit tickets are shares
queuedShares -= BigInt(exitedTickets || 0)
if (isV2Position) {
// in V2 vaults exit queue exit tickets are assets, for v1 and v3+ will be shares
queuedAssets -= BigInt(exitedAssets || 0)
}
else {
queuedAssets -= BigInt(exitedAssets || 0)
queuedShares -= BigInt(exitedTickets || 0)
}

withdrawableAssets += BigInt(exitedAssets || 0)
Expand Down

0 comments on commit d7e09fe

Please sign in to comment.