Skip to content

Commit

Permalink
Merge pull request #57 from marinade-finance/deposit-stake-account-lo…
Browse files Browse the repository at this point in the history
…ckup-time-check

[fix] stake account isLockedUp check to apply current epoch and timestamp
  • Loading branch information
AlexStefan authored Aug 25, 2023
2 parents 3319129 + 602d981 commit 01493fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
## v5.0.4

### Feat:
### Fix:

- Add beta support to (partially) deposit activating stake accounts via `depositActivatingStakeAccount`
- Make `createDirectedStakeVoteIx` public so it can be used in various transactions (like when swapping LSTs via Jup)
- Make it possible to stake locked stake accounts that have the lock period in the past

## v5.0.3

### Feat:

- Add beta support to (partially) deposit activating stake accounts via `depositActivatingStakeAccount`
- Make `createDirectedStakeVoteIx` public so it can be used in various transactions (like when swapping LSTs via Jup)
- Add setup to run integration tests on local validator within the pipeline
- Add beta support to partially deposit stake accounts via `partiallyDepositStakeAccount`
- Add beta support to partially liquidate stake accounts via `partiallyLiquidateStakeAccount`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@marinade.finance/marinade-ts-sdk",
"version": "5.0.3",
"version": "5.0.4",
"description": "Marinade SDK for Typescript",
"main": "dist/src/index.js",
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion src/util/anchor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export async function getParsedStakeAccountInfo(
const stakedLamports = BNOrNull(
parsedData?.info?.stake?.delegation.stake ?? null
)
const { epoch: currentEpoch } = await connection.getEpochInfo()
const currentUnixTimestamp = Date.now() / 1000

return {
address: stakeAccountAddress,
Expand All @@ -134,7 +136,10 @@ export async function getParsedStakeAccountInfo(
deactivationEpoch,
isCoolingDown: deactivationEpoch ? !deactivationEpoch.eq(U64_MAX) : false,
isLockedUp:
lockup?.custodian && lockup?.custodian !== '' && lockup?.epoch > 0,
lockup?.custodian &&
lockup?.custodian !== '' &&
(lockup?.epoch > currentEpoch ||
lockup?.unixTimestamp > currentUnixTimestamp),
balanceLamports,
stakedLamports,
}
Expand Down

0 comments on commit 01493fc

Please sign in to comment.