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

[Liquidity Mining] Reserve packing & unpacking (4) #202

Merged
merged 30 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
49a6c03
Creating data structures for LM
vanitymnm Feb 25, 2025
aa13771
Adding admin IXs for LM reward management
vanitymnm Feb 25, 2025
0abe52c
Document accounts for admin IXs
vanitymnm Feb 25, 2025
4e4694b
Checking that token vault is empty and belogs to the token program
vanitymnm Feb 25, 2025
9d0c84c
Note on running out of IDs
vanitymnm Feb 26, 2025
eff2b19
Removing libssl1.1 dependency as it can no longer be installed on CI
vanitymnm Feb 26, 2025
df22c76
Merge branch 'ci/libssl-fix' into feat/lm-state-intro
vanitymnm Feb 26, 2025
6a51385
Improving clarity of PositionKind unpacking
vanitymnm Feb 26, 2025
fd22173
Describing what LM is
vanitymnm Feb 26, 2025
8ee16b0
Improving documentation and wording
vanitymnm Feb 26, 2025
d184804
Merge branch 'feat/lm-state-intro' into feat/lm-admin-ix-accounts
vanitymnm Feb 26, 2025
7a4b404
Removing duplicate code
vanitymnm Feb 26, 2025
9637228
Adding math for reward accrual
vanitymnm Feb 28, 2025
ef72f92
Improving comments wording
vanitymnm Feb 28, 2025
7833ca2
Fixing error names
vanitymnm Feb 28, 2025
2a28819
Merge branch 'feat/lm-admin-ix-accounts' into feat/lm-reward-accruing
vanitymnm Mar 5, 2025
d8901cc
Merging stash
vanitymnm Mar 5, 2025
b9808d7
Packing and unpacking reward managers
vanitymnm Mar 5, 2025
341a6a9
Adding packing & unpacking tests
vanitymnm Mar 7, 2025
965ca13
Adding an ix to migrate reserve
vanitymnm Mar 7, 2025
34570ed
Realloc succesful
vanitymnm Mar 12, 2025
3faec66
Running test script via anchor tests
vanitymnm Mar 14, 2025
a1bf811
Version bump
vanitymnm Mar 14, 2025
6217267
Merge branch 'feat/liquidity-mining' into feat/lm-state-intro
vanitymnm Mar 14, 2025
95343e6
Merge branch 'feat/lm-state-intro' into feat/lm-admin-ix-accounts
vanitymnm Mar 14, 2025
a4d235b
Merge branch 'feat/liquidity-mining' into feat/lm-admin-ix-accounts
vanitymnm Mar 14, 2025
dc24e8e
Merge branch 'feat/lm-admin-ix-accounts' into feat/lm-reward-accruing
vanitymnm Mar 14, 2025
5c0a70e
Merge branch 'feat/liquidity-mining' into feat/lm-reward-accruing
vanitymnm Mar 14, 2025
52982e4
Merge branch 'feat/lm-reward-accruing' into feat/lm-reserve-migration
vanitymnm Mar 14, 2025
0bf9913
Using latest cache action
vanitymnm Mar 14, 2025
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
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.ts]
indent_size = 2
14 changes: 7 additions & 7 deletions .github/workflows/pull-request-token-lending.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Token Lending Pull Request
on:
pull_request:
paths:
- 'token-lending/**'
- 'token/**'
- "token-lending/**"
- "token/**"
push:
branches: [master]
paths:
- 'token-lending/**'
- 'token/**'
- "token-lending/**"
- "token/**"

jobs:
cargo-test-bpf:
Expand All @@ -30,20 +30,20 @@ jobs:
override: true
profile: minimal

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cache
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Pull Request
on:
pull_request:
paths-ignore:
- 'docs/**'
- "docs/**"
push:
branches: [master, upcoming]
paths-ignore:
- 'docs/**'
- "docs/**"

jobs:
all_github_action_checks:
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
profile: minimal
components: clippy

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -96,21 +96,21 @@ jobs:
override: true
profile: minimal

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
# target # Removed due to build dependency caching conflicts
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cache
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
override: true
profile: minimal

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
Expand Down
1 change: 1 addition & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bail: true
27 changes: 22 additions & 5 deletions Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
anchor_version = "0.13.2"
[toolchain]
package_manager = "yarn"
anchor_version = "0.28.0"

[features]
resolution = true
skip-lint = false

[workspace]
members = [
"token-lending/program",
"token-lending/brick",
]
members = ["token-lending/program", "token-lending/brick"]

[provider]
cluster = "mainnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 token-lending/tests/**/*.ts"

[programs.mainnet]
spl_token_lending = "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo"

[programs.localnet]
solend_program = "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo"

[test.validator]
# we use some mainnet accounts for tests
url = "https://api.mainnet-beta.solana.com"

[[test.validator.clone]]
# Solend Main Pool - (USDC) Reserve State
address = "BgxfHJDzm44T7XG68MYKx7YisTjZu73tVovyZSjJMpmw"
25 changes: 9 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ members = [
"token-lending/cli",
"token-lending/program",
"token-lending/sdk",
"token-lending/brick"
, "token-lending/oracles"]
"token-lending/brick",
"token-lending/oracles",
]

[workspace.package]
version = "2.1.0"

[profile.dev]
split-debuginfo = "unpacked"
Expand Down
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"license": "ISC",
"scripts": {
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
},
"dependencies": {
"@coral-xyz/anchor": "^0.28.0"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^9.0.3",
"ts-mocha": "^10.0.0",
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"typescript": "^5.7.3",
"prettier": "^2.6.2"
}
}
10 changes: 5 additions & 5 deletions token-lending/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "solend-program-cli"
version.workspace = true
authors = ["Solend Maintainers <[email protected]>"]
description = "Solend Program CLI"
edition = "2018"
homepage = "https://solend.fi"
license = "Apache-2.0"
name = "solend-program-cli"
repository = "https://github.com/solendprotocol/solana-program-library"
version = "2.0.2"

[dependencies]
clap = "=2.34.0"
Expand All @@ -16,9 +16,9 @@ solana-client = "1.14.10"
solana-logger = "1.14.10"
solana-sdk = "1.14.10"
solana-program = "1.14.10"
solend-sdk = { path="../sdk" }
solend-program = { path="../program", features = [ "no-entrypoint" ] }
spl-token = { version = "3.3.0", features=["no-entrypoint"] }
solend-sdk = { path = "../sdk" }
solend-program = { path = "../program", features = ["no-entrypoint"] }
spl-token = { version = "3.3.0", features = ["no-entrypoint"] }
spl-associated-token-account = "1.0"
solana-account-decoder = "1.14.10"
reqwest = { version = "0.12.2", features = ["blocking", "json"] }
Expand Down
43 changes: 43 additions & 0 deletions token-lending/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use solend_program::{
instruction::set_lending_market_owner_and_config,
state::{validate_reserve_config, RateLimiterConfig},
};
use solend_sdk::instruction::upgrade_reserve_to_v2_1_0;
use solend_sdk::{
instruction::{
liquidate_obligation_and_redeem_reserve_collateral, redeem_reserve_collateral,
Expand Down Expand Up @@ -768,6 +769,20 @@ fn main() {
.help("Risk authority address"),
)
)
.subcommand(
SubCommand::with_name("upgrade-reserve")
.about("Migrate reserve to version 2.1.0")
.arg(
Arg::with_name("reserve")
.long("reserve")
.validator(is_pubkey)
.value_name("PUBKEY")
.takes_value(true)
.required(true)
.help("Reserve address"),
)

)
.subcommand(
SubCommand::with_name("update-reserve")
.about("Update a reserve config")
Expand Down Expand Up @@ -1324,6 +1339,11 @@ fn main() {
risk_authority_pubkey,
)
}
("upgrade-reserve", Some(arg_matches)) => {
let reserve_pubkey = pubkey_of(arg_matches, "reserve").unwrap();

command_upgrade_reserve_to_v2_1_0(&mut config, reserve_pubkey)
}
("update-reserve", Some(arg_matches)) => {
let reserve_pubkey = pubkey_of(arg_matches, "reserve").unwrap();
let lending_market_owner_keypair =
Expand Down Expand Up @@ -1973,6 +1993,29 @@ fn command_set_lending_market_owner_and_config(
Ok(())
}

fn command_upgrade_reserve_to_v2_1_0(config: &mut Config, reserve_pubkey: Pubkey) -> CommandResult {
let recent_blockhash = config.rpc_client.get_latest_blockhash()?;

let message = Message::new_with_blockhash(
&[
ComputeBudgetInstruction::set_compute_unit_price(30101),
upgrade_reserve_to_v2_1_0(
config.lending_program_id,
reserve_pubkey,
config.fee_payer.pubkey(),
),
],
Some(&config.fee_payer.pubkey()),
&recent_blockhash,
);

let transaction = Transaction::new(&vec![config.fee_payer.as_ref()], message, recent_blockhash);

send_transaction(config, transaction)?;

Ok(())
}

#[allow(clippy::too_many_arguments, clippy::unnecessary_unwrap)]
fn command_update_reserve(
config: &mut Config,
Expand Down
4 changes: 2 additions & 2 deletions token-lending/program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "solend-program"
version = "2.0.2"
version.workspace = true
description = "Solend Program"
authors = ["Solend Maintainers <[email protected]>"]
repository = "https://github.com/solendprotocol/solana-program-library"
Expand All @@ -18,7 +18,7 @@ bytemuck = "1.5.1"
solana-program = "=1.16.20"
solend-sdk = { path = "../sdk" }
oracles = { path = "../oracles" }
spl-token = { version = "3.3.0", features=["no-entrypoint"] }
spl-token = { version = "3.3.0", features = ["no-entrypoint"] }
static_assertions = "1.1.0"

[dev-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ pub fn process_instruction(
accounts,
)
}

// temporary ix for upgrade
LendingInstruction::UpgradeReserveToV2_1_0 => {
msg!("Instruction: Upgrade Reserve to v2.1.0");
liquidity_mining::upgrade_reserve(program_id, accounts)
}
}
}

Expand Down
Loading
Loading