-
Notifications
You must be signed in to change notification settings - Fork 1
PROTO-178: Single extension program with compile flags (ScaledUI + No Yield) #11
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
Merged
Merged
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
eb2948f
feat: use feature flags to add "no yield" option
Oighty 362b554
chore: rename program
Oighty 38e8c1f
fix: state serialization
Oighty fe25de0
chore: makefile and test fixes
Oighty 43454c3
chore: remove unused imports and cleanup compile warnings
Oighty 5f79a5f
chore: update CI
Oighty b238990
chore: remove unnecessary idl-build flag
Oighty 855e3d1
fix: compiler warning on no-yield variant
Oighty ac44e44
chore: comment clean-up
Oighty 0ab5828
fix: no yield multiplier return value
Oighty 0207359
test: no yield ext tests
Oighty 7118905
chore: move test runner to makefile
Oighty b106d64
chore: add default feature to play nicer with anchor plugin
Oighty dd56955
test: new test harness and initial test conversion to new format
Oighty 6d67f3d
feat: check that ext mint has freeze authority on initialization
Oighty 585872b
refactor: cfg_if imports
Oighty 678114c
fix: remove unused signer from sync
Oighty 763d7af
test: finish refactored admin tests
Oighty 2f1f58b
test: wrap/unwrap test refactor
Oighty 75eb1ca
test: refactor sync unit tests
Oighty a4948d7
test: remove old test files and update makefile
Oighty 1478743
test: add test case for ext mint not having freeze authority
Oighty d9e5c96
test: refactor multiplier calculation and add tests
Oighty 5094a71
tests: update multiplier checks to account for floating point precisi…
Oighty 3965c93
chore: clarify comment on test
Oighty de68b3b
chore: update solana-m dep to `develop` branch
Oighty 8d3ba81
feat: use last claim index for scaledui syncs instead of m global
Oighty 62ebb68
test: update existing tests for index change
Oighty 2ff3f0c
test: add'l ext tests with solvency checks
Oighty 43a4827
chore: update README
Oighty e6e0f45
Update README.md
Oighty f71a84e
chore: kurtis review clean-up
Oighty 89ab8f6
fix
SC4RECOIN edc0759
test: fix tests to accompany fix
Oighty 5487dd7
Merge pull request #15 from m0-foundation/kurtis/unwrap-exploit
Oighty abaf31c
PROTO-179: swap router (#12)
SC4RECOIN 8a98536
fix: make "no-yield" the default option to fix CPI build
Oighty 1de0096
chore: rename program_authority -> wrap_authority
Oighty 07ee511
test: fix existing tests with tokenAuthority/wrapAuthority split
Oighty d6faa3d
test: wrap/unwrap with wrap authority tests
Oighty 6e8c7bb
feat: dynamically sized wrap auth list (#17)
Oighty 4a94237
Allow wrap authority co-signing on swaps (#16)
SC4RECOIN b7754ad
test: fix tests after merge
Oighty 34ec02c
chore: readme updates
Oighty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,34 @@ | ||
| build-programs: | ||
| anchor build -p ext_swap | ||
| anchor build -p m_ext -- --features scaled-ui --no-default-features | ||
| @mv target/deploy/m_ext.so target/deploy/scaled_ui.so | ||
| @mv target/idl/m_ext.json target/idl/scaled_ui.json | ||
| @mv target/types/m_ext.ts target/types/scaled_ui.ts | ||
| anchor build -p m_ext -- --features no-yield --no-default-features | ||
| @cp target/deploy/m_ext.so target/deploy/no_yield.so | ||
| @cp target/idl/m_ext.json target/idl/no_yield.json | ||
| @cp target/types/m_ext.ts target/types/no_yield.ts | ||
|
|
||
| test-programs: | ||
| @yarn run jest --preset ts-jest --verbose tests/unit/**.test.ts | ||
| @cargo test | ||
|
|
||
| define update-program-id | ||
| @sed -i '' 's/declare_id!("[^"]*")/declare_id!("$(1)")/' programs/m_ext/src/lib.rs | ||
| endef | ||
|
|
||
| build-test-programs: | ||
| $(call update-program-id,3joDhmLtHLrSBGfeAe1xQiv3gjikes3x8S4N3o6Ld8zB) | ||
| anchor build -p m_ext | ||
| @mv target/deploy/m_ext.so tests/programs/ext_a.so | ||
| $(call update-program-id,HSMnbWEkB7sEQAGSzBPeACNUCXC9FgNeeESLnHtKfoy3) | ||
| anchor build -p m_ext | ||
| @mv target/deploy/m_ext.so tests/programs/ext_b.so | ||
| $(call update-program-id,81gYpXqg8ZT9gdkFSe35eqiitqBWqVfYwDwVfXuk8Xfw) | ||
| sed -i '' '/pub ext_token_program: Program<'\''info, Token2022>,/a\'$$'\n''\ pub dummy_account: Program<'\''info, Token2022>,' programs/m_ext/src/instructions/wrap.rs | ||
| cargo fmt | ||
| anchor build -p m_ext --skip-lint | ||
| @mv target/deploy/m_ext.so tests/programs/ext_c.so | ||
| sed -i '' '/pub dummy_account: Program<'\''info, Token2022>,/d' programs/m_ext/src/instructions/wrap.rs | ||
| $(call update-program-id,3C865D264L4NkAm78zfnDzQJJvXuU3fMjRUvRxyPi5da) | ||
| anchor build -p m_ext |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,29 +1,29 @@ | ||
| { | ||
| "scripts": { | ||
| "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", | ||
| "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", | ||
| "test": "yarn run jest --preset ts-jest --verbose", | ||
| "build": "anchor build" | ||
| }, | ||
| "dependencies": { | ||
| "@coral-xyz/anchor": "^0.31.1", | ||
| "@m0-foundation/solana-m-sdk": "https://gitpkg.vercel.app/m0-foundation/solana-m/sdk?0991eb829a52f6ba5969fd47d3100ef6871f0a6d&scripts.postinstall=yarn%20build", | ||
| "@solana-developers/helpers": "^2.7.0", | ||
| "@solana/spl-token": "^0.4.13", | ||
| "@solana/web3.js": "^1.98", | ||
| "anchor-litesvm": "0.1.2", | ||
| "bn.js": "^5.2.1", | ||
| "litesvm": "0.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/bn.js": "^5.1.0", | ||
| "@types/jest": "^29.0.3", | ||
| "@types/node": "^22.13.13", | ||
| "jest": "^29.0.3", | ||
| "nock": "^14.0.2", | ||
| "prettier": "^2.6.2", | ||
| "ts-jest": "^29.0.2", | ||
| "ts-node": "^10.9.2", | ||
| "typescript": "5" | ||
| } | ||
| "scripts": { | ||
| "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", | ||
| "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", | ||
| "test": "make test-programs", | ||
| "build": "make build-programs" | ||
| }, | ||
| "dependencies": { | ||
| "@coral-xyz/anchor": "^0.31.1", | ||
| "@m0-foundation/solana-m-sdk": "https://gitpkg.vercel.app/m0-foundation/solana-m/sdk?0991eb829a52f6ba5969fd47d3100ef6871f0a6d&scripts.postinstall=yarn%20build", | ||
| "@solana-developers/helpers": "^2.7.0", | ||
| "@solana/spl-token": "^0.4.13", | ||
| "@solana/web3.js": "^1.98", | ||
| "anchor-litesvm": "0.1.2", | ||
| "bn.js": "^5.2.1", | ||
| "litesvm": "0.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/bn.js": "^5.1.0", | ||
| "@types/jest": "^29.0.3", | ||
| "@types/node": "^22.13.13", | ||
| "jest": "^29.0.3", | ||
| "nock": "^14.0.2", | ||
| "prettier": "^2.6.2", | ||
| "ts-jest": "^29.0.2", | ||
| "ts-node": "^10.9.2", | ||
| "typescript": "5" | ||
| } | ||
| } | ||
15 changes: 7 additions & 8 deletions
15
programs/scaled_ui_ext/Cargo.toml → programs/ext_swap/Cargo.toml
This file contains hidden or 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 |
|---|---|---|
| @@ -1,26 +1,25 @@ | ||
| [package] | ||
| name = "scaled_ui_ext" | ||
| name = "ext_swap" | ||
| version = "0.1.0" | ||
| description = "Created with Anchor" | ||
| edition = "2021" | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib", "lib"] | ||
| name = "scaled_ui_ext" | ||
| name = "ext_swap" | ||
|
|
||
| [features] | ||
| default = [] | ||
| cpi = ["no-entrypoint"] | ||
| no-entrypoint = [] | ||
| no-idl = [] | ||
| no-log-ix-name = [] | ||
| cpi = ["no-entrypoint"] | ||
| default = [] | ||
| idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"] | ||
|
|
||
|
|
||
| [dependencies] | ||
| anchor-lang.workspace = true | ||
| anchor-spl.workspace = true | ||
| spl-token-2022.workspace = true | ||
| cfg-if.workspace = true | ||
| solana-security-txt.workspace = true | ||
| solana-program.workspace = true | ||
| earn.workspace = true | ||
| solana-security-txt.workspace = true | ||
| m_ext = {path = "../m_ext", features = ["cpi"]} |
File renamed without changes.
This file contains hidden or 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,13 @@ | ||
| use anchor_lang::prelude::*; | ||
|
|
||
| #[error_code] | ||
| pub enum SwapError { | ||
| #[msg("Extension is not whitelisted")] | ||
| InvalidExtension, | ||
| #[msg("Extension is already whitelisted")] | ||
| AlreadyWhitelisted, | ||
| #[msg("Index invalid for length of the array")] | ||
| InvalidIndex, | ||
| #[msg("Signer is not whitelisted")] | ||
| UnauthorizedUnwrapper, | ||
| } |
This file contains hidden or 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,34 @@ | ||
| use anchor_lang::prelude::*; | ||
|
|
||
| use crate::state::{SwapGlobal, GLOBAL_SEED}; | ||
|
|
||
| #[derive(Accounts)] | ||
| pub struct InitializeGlobal<'info> { | ||
| #[account(mut)] | ||
| pub admin: Signer<'info>, | ||
|
|
||
| #[account( | ||
| init, | ||
| payer = admin, | ||
| space = SwapGlobal::size(0,0), | ||
| seeds = [GLOBAL_SEED], | ||
| bump, | ||
| )] | ||
| pub swap_global: Account<'info, SwapGlobal>, | ||
|
|
||
| pub system_program: Program<'info, System>, | ||
| } | ||
|
|
||
| impl InitializeGlobal<'_> { | ||
| pub fn handler(ctx: Context<Self>, m_mint: Pubkey) -> Result<()> { | ||
| ctx.accounts.swap_global.set_inner(SwapGlobal { | ||
| bump: ctx.bumps.swap_global, | ||
| admin: ctx.accounts.admin.key(), | ||
| m_mint: m_mint, | ||
| whitelisted_unwrappers: vec![], | ||
| whitelisted_extensions: vec![], | ||
| }); | ||
|
|
||
| Ok(()) | ||
| } | ||
| } |
This file contains hidden or 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,11 @@ | ||
| pub mod initialize; | ||
| pub mod swap; | ||
| pub mod unwrap; | ||
| pub mod whitelist; | ||
| pub mod wrap; | ||
|
|
||
| pub use initialize::*; | ||
| pub use swap::*; | ||
| pub use unwrap::*; | ||
| pub use whitelist::*; | ||
| pub use wrap::*; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.