Skip to content

Commit 389a7d8

Browse files
authored
[Liquidity Mining] Reserve packing & unpacking (4) (#202)
1 parent 2587270 commit 389a7d8

File tree

20 files changed

+1988
-178
lines changed

20 files changed

+1988
-178
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.ts]
8+
indent_size = 2

.github/workflows/pull-request-token-lending.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name: Token Lending Pull Request
33
on:
44
pull_request:
55
paths:
6-
- 'token-lending/**'
7-
- 'token/**'
6+
- "token-lending/**"
7+
- "token/**"
88
push:
99
branches: [master]
1010
paths:
11-
- 'token-lending/**'
12-
- 'token/**'
11+
- "token-lending/**"
12+
- "token/**"
1313

1414
jobs:
1515
cargo-test-bpf:
@@ -30,20 +30,20 @@ jobs:
3030
override: true
3131
profile: minimal
3232

33-
- uses: actions/cache@v2
33+
- uses: actions/cache@v4
3434
with:
3535
path: |
3636
~/.cargo/registry
3737
~/.cargo/git
3838
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
3939

40-
- uses: actions/cache@v2
40+
- uses: actions/cache@v4
4141
with:
4242
path: |
4343
~/.cargo/bin/rustfilt
4444
key: cargo-bpf-bins-${{ runner.os }}
4545

46-
- uses: actions/cache@v2
46+
- uses: actions/cache@v4
4747
with:
4848
path: |
4949
~/.cache

.github/workflows/pull-request.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name: Pull Request
33
on:
44
pull_request:
55
paths-ignore:
6-
- 'docs/**'
6+
- "docs/**"
77
push:
88
branches: [master, upcoming]
99
paths-ignore:
10-
- 'docs/**'
10+
- "docs/**"
1111

1212
jobs:
1313
all_github_action_checks:
@@ -59,7 +59,7 @@ jobs:
5959
profile: minimal
6060
components: clippy
6161

62-
- uses: actions/cache@v2
62+
- uses: actions/cache@v4
6363
with:
6464
path: |
6565
~/.cargo/registry
@@ -96,21 +96,21 @@ jobs:
9696
override: true
9797
profile: minimal
9898

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

107-
- uses: actions/cache@v2
107+
- uses: actions/cache@v4
108108
with:
109109
path: |
110110
~/.cargo/bin/rustfilt
111111
key: cargo-bpf-bins-${{ runner.os }}
112112

113-
- uses: actions/cache@v2
113+
- uses: actions/cache@v4
114114
with:
115115
path: |
116116
~/.cache
@@ -143,7 +143,7 @@ jobs:
143143
override: true
144144
profile: minimal
145145

146-
- uses: actions/cache@v2
146+
- uses: actions/cache@v4
147147
with:
148148
path: |
149149
~/.cargo/registry

.mocharc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bail: true

Anchor.toml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1-
anchor_version = "0.13.2"
1+
[toolchain]
2+
package_manager = "yarn"
3+
anchor_version = "0.28.0"
4+
5+
[features]
6+
resolution = true
7+
skip-lint = false
28

39
[workspace]
4-
members = [
5-
"token-lending/program",
6-
"token-lending/brick",
7-
]
10+
members = ["token-lending/program", "token-lending/brick"]
811

912
[provider]
1013
cluster = "mainnet"
1114
wallet = "~/.config/solana/id.json"
1215

16+
[scripts]
17+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 token-lending/tests/**/*.ts"
18+
1319
[programs.mainnet]
1420
spl_token_lending = "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo"
21+
22+
[programs.localnet]
23+
solend_program = "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo"
24+
25+
[test.validator]
26+
# we use some mainnet accounts for tests
27+
url = "https://api.mainnet-beta.solana.com"
28+
29+
[[test.validator.clone]]
30+
# Solend Main Pool - (USDC) Reserve State
31+
address = "BgxfHJDzm44T7XG68MYKx7YisTjZu73tVovyZSjJMpmw"

Cargo.lock

Lines changed: 9 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ members = [
33
"token-lending/cli",
44
"token-lending/program",
55
"token-lending/sdk",
6-
"token-lending/brick"
7-
, "token-lending/oracles"]
6+
"token-lending/brick",
7+
"token-lending/oracles",
8+
]
9+
10+
[workspace.package]
11+
version = "2.1.0"
812

913
[profile.dev]
1014
split-debuginfo = "unpacked"

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"license": "ISC",
3+
"scripts": {
4+
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
5+
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
6+
},
7+
"dependencies": {
8+
"@coral-xyz/anchor": "^0.28.0"
9+
},
10+
"devDependencies": {
11+
"chai": "^4.3.4",
12+
"mocha": "^9.0.3",
13+
"ts-mocha": "^10.0.0",
14+
"@types/bn.js": "^5.1.0",
15+
"@types/chai": "^4.3.0",
16+
"@types/mocha": "^9.0.0",
17+
"typescript": "^5.7.3",
18+
"prettier": "^2.6.2"
19+
}
20+
}

token-lending/cli/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
2+
name = "solend-program-cli"
3+
version.workspace = true
24
authors = ["Solend Maintainers <[email protected]>"]
35
description = "Solend Program CLI"
46
edition = "2018"
57
homepage = "https://solend.fi"
68
license = "Apache-2.0"
7-
name = "solend-program-cli"
89
repository = "https://github.com/solendprotocol/solana-program-library"
9-
version = "2.0.2"
1010

1111
[dependencies]
1212
clap = "=2.34.0"
@@ -16,9 +16,9 @@ solana-client = "1.14.10"
1616
solana-logger = "1.14.10"
1717
solana-sdk = "1.14.10"
1818
solana-program = "1.14.10"
19-
solend-sdk = { path="../sdk" }
20-
solend-program = { path="../program", features = [ "no-entrypoint" ] }
21-
spl-token = { version = "3.3.0", features=["no-entrypoint"] }
19+
solend-sdk = { path = "../sdk" }
20+
solend-program = { path = "../program", features = ["no-entrypoint"] }
21+
spl-token = { version = "3.3.0", features = ["no-entrypoint"] }
2222
spl-associated-token-account = "1.0"
2323
solana-account-decoder = "1.14.10"
2424
reqwest = { version = "0.12.2", features = ["blocking", "json"] }

token-lending/cli/src/main.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use solend_program::{
1111
instruction::set_lending_market_owner_and_config,
1212
state::{validate_reserve_config, RateLimiterConfig},
1313
};
14+
use solend_sdk::instruction::upgrade_reserve_to_v2_1_0;
1415
use solend_sdk::{
1516
instruction::{
1617
liquidate_obligation_and_redeem_reserve_collateral, redeem_reserve_collateral,
@@ -768,6 +769,20 @@ fn main() {
768769
.help("Risk authority address"),
769770
)
770771
)
772+
.subcommand(
773+
SubCommand::with_name("upgrade-reserve")
774+
.about("Migrate reserve to version 2.1.0")
775+
.arg(
776+
Arg::with_name("reserve")
777+
.long("reserve")
778+
.validator(is_pubkey)
779+
.value_name("PUBKEY")
780+
.takes_value(true)
781+
.required(true)
782+
.help("Reserve address"),
783+
)
784+
785+
)
771786
.subcommand(
772787
SubCommand::with_name("update-reserve")
773788
.about("Update a reserve config")
@@ -1324,6 +1339,11 @@ fn main() {
13241339
risk_authority_pubkey,
13251340
)
13261341
}
1342+
("upgrade-reserve", Some(arg_matches)) => {
1343+
let reserve_pubkey = pubkey_of(arg_matches, "reserve").unwrap();
1344+
1345+
command_upgrade_reserve_to_v2_1_0(&mut config, reserve_pubkey)
1346+
}
13271347
("update-reserve", Some(arg_matches)) => {
13281348
let reserve_pubkey = pubkey_of(arg_matches, "reserve").unwrap();
13291349
let lending_market_owner_keypair =
@@ -1973,6 +1993,29 @@ fn command_set_lending_market_owner_and_config(
19731993
Ok(())
19741994
}
19751995

1996+
fn command_upgrade_reserve_to_v2_1_0(config: &mut Config, reserve_pubkey: Pubkey) -> CommandResult {
1997+
let recent_blockhash = config.rpc_client.get_latest_blockhash()?;
1998+
1999+
let message = Message::new_with_blockhash(
2000+
&[
2001+
ComputeBudgetInstruction::set_compute_unit_price(30101),
2002+
upgrade_reserve_to_v2_1_0(
2003+
config.lending_program_id,
2004+
reserve_pubkey,
2005+
config.fee_payer.pubkey(),
2006+
),
2007+
],
2008+
Some(&config.fee_payer.pubkey()),
2009+
&recent_blockhash,
2010+
);
2011+
2012+
let transaction = Transaction::new(&vec![config.fee_payer.as_ref()], message, recent_blockhash);
2013+
2014+
send_transaction(config, transaction)?;
2015+
2016+
Ok(())
2017+
}
2018+
19762019
#[allow(clippy::too_many_arguments, clippy::unnecessary_unwrap)]
19772020
fn command_update_reserve(
19782021
config: &mut Config,

0 commit comments

Comments
 (0)