Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic to add expiration to delegation #768

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/account-postgres-sink-service/vote_service_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
"schema": "public"
}
]
},
{
"programId": "hdaoVTCqhfHHo75XdAMxBKdUqvq1i5bF23sisBqVgGR",
"accounts": [
{ "type": "SubDaoV0", "table": "sub_daos", "schema": "public" },
{ "type": "DaoV0", "table": "daos", "schema": "public" },
{
"type": "DelegatedPositionV0",
"table": "delegated_positions",
"schema": "public"
}
]
}
],
"indexConfigs": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export async function run(args: any = process.argv) {
const delegations = await hsdProgram.account.delegatedPositionV0.all()
const needsMigration = delegations.filter(d => d.account.expirationTs.isZero());
const positionKeys = needsMigration.map(d => d.account.position);
const coder = hsdProgram.coder.accounts
const coder = vsrProgram.coder.accounts
const positionAccs = (await getMultipleAccounts({
connection: provider.connection,
keys: positionKeys,
})).map(a => coder.decode("positionV0", a.data));
})).map(a => coder.decode("PositionV0", a.data));

const currTs = await getSolanaUnixTimestamp(provider);
const currTsBN = new anchor.BN(currTs.toString());
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function run(args: any = process.argv) {
)[0],
genesisEndSubDaoEpochInfo: subDaoEpochInfoKey(
subDao,
position.genesisEnd
position.genesisEnd.isZero() ? min(position.lockup.endTs, proxyEndTs!) : position.genesisEnd
)[0],
proxyConfig: registrar.proxyConfig,
systemProgram: SystemProgram.programId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ pub struct CloseDelegationV0<'info> {
// no need to pass an extra account here. Just pass the closing time sdei and
// do not change it.
if position.genesis_end <= registrar.clock_unix_timestamp() {
position.lockup.end_ts
min(
position.lockup.end_ts,
if delegated_position.expiration_ts == 0 {
position.lockup.end_ts
} else {
min(position.lockup.end_ts, delegated_position.expiration_ts)
}
)
} else {
position.genesis_end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub struct DelegateV0<'info> {
// Avoid passing an extra account if the end is 0 (no genesis on this position).
// Pass instead closing time epoch info, txn account deduplication will reduce the overall tx size
if position.genesis_end <= registrar.clock_unix_timestamp() {
position.lockup.end_ts
min(position.lockup.end_ts, proxy_config.get_current_season(registrar.clock_unix_timestamp()).unwrap().end)
} else {
position.genesis_end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ pub struct ExtendExpirationTsV0<'info> {
// no need to pass an extra account here. Just pass the closing time sdei and
// do not change it.
if position.genesis_end <= registrar.clock_unix_timestamp() {
position.lockup.end_ts
if delegated_position.expiration_ts == 0 {
position.lockup.end_ts
} else {
min(position.lockup.end_ts, delegated_position.expiration_ts)
}
} else {
position.genesis_end
}
Expand Down
Loading