-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[duration]: add ExitRequests, finalized logic
- Loading branch information
Showing
7 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query ExitRequests($user: String!, $vault: String!) { | ||
exitRequests(user: $user, vault: $vault) { | ||
duration | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/methods/vault/requests/getExitQueuePositions/fetchExitRequestDuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import graphql from '../../../../graphql' | ||
import { apiUrls } from '../../../../utils' | ||
|
||
|
||
export type FetchExitQueuePositionsInput = { | ||
options: StakeWise.Options | ||
vaultAddress: string | ||
userAddress: string | ||
} | ||
|
||
const fetchExitRequestDuration = (values: FetchExitQueuePositionsInput) => { | ||
const { options, vaultAddress, userAddress } = values | ||
|
||
return graphql.backend.vault.fetchExitRequestsQuery({ | ||
url: apiUrls.getSubgraphqlUrl(options), | ||
variables: { | ||
vault: vaultAddress.toLowerCase(), | ||
user: userAddress.toLowerCase(), | ||
}, | ||
modifyResult: (data) => { | ||
if (!data || !data.exitRequests || !data.exitRequests.length) { | ||
return 0 | ||
} | ||
|
||
const durations = data.exitRequests.map(request => request.duration) | ||
|
||
return Math.max(...durations) | ||
}, | ||
}) | ||
} | ||
|
||
|
||
export default fetchExitRequestDuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters