Skip to content

fix(yield_vault): bind initialize to deployer and creation salt (#8) - #27

Open
dongwei-polyred wants to merge 1 commit into
YieldAnchor:mainfrom
dongwei-polyred:fix/initialize-deployer-binding
Open

dongwei-polyred wants to merge 1 commit into
YieldAnchor:mainfrom
dongwei-polyred:fix/initialize-deployer-binding

Conversation

@dongwei-polyred

Copy link
Copy Markdown

Summary

Fixes #8 (option 2 — bind deployer)

initialize previously only required the proposed admin to sign. A front-runner could still name itself as admin on a freshly created vault. This PR binds initialization to the creating account and salt.

Changes

  • initialize(deployer, salt, admin, asset, name, symbol, decimals) re-derives this contract address from deployer+salt; mismatch → VaultError::BadDeployer (17)
  • deployer.require_auth(); if admin != deployer, also admin.require_auth()
  • Front-runner / wrong-salt contract tests; existing init tests updated
  • Contract clients, validation, constants, deploy TS/shell paths pass and persist salt (scripts/.deploy_salt)
  • README + docs/deployment/testnet.md replace the unauthenticated caveat

Verification

cargo test -p yield_vault          # 15 passed
cargo clippy -p yield_vault --all-targets -- -D warnings
pnpm run build:packages && pnpm --filter @yieldanchor/validation test && pnpm --filter @yieldanchor/contract-clients test

BountyHub

https://www.bountyhub.dev/en/bounty/view/7c4339c5-d481-4658-b46c-629023bb05e0
(assignmentType=open — not Exclusive)

Close the front-running window on freshly created vaults (issue YieldAnchor#8 option 2):
initialize now takes deployer + salt, re-derives the contract address, and
requires deployer (and admin when distinct) authorization. Wrong pairs return
BadDeployer. Deploy clients/scripts pass and persist the salt; docs replace
the unauthenticated caveat.

Verified: cargo test -p yield_vault (15), cargo clippy -D warnings,
pnpm validation + contract-clients tests.

Fixes YieldAnchor#8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: initialize is unauthenticated, so a front-runner can capture admin on a fresh vault

1 participant