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

restaking-v2: added restaking program with tests #346

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
02f4aef
added restaking program with tests
dhruvja Jun 15, 2024
be2e588
added restaking-v2 program to config
dhruvja Jun 16, 2024
6f16a24
added restaking-v2 program to config
dhruvja Jun 16, 2024
c5fd07c
add fee payer account for initializing accounts
dhruvja Jun 18, 2024
1abae32
fmt
dhruvja Jun 18, 2024
b7b1a5d
set remainder to the first validator
dhruvja Jun 19, 2024
142110b
use extend instead of append
dhruvja Jun 19, 2024
a1edae5
add docs
dhruvja Jul 2, 2024
59c57e5
add support for oracles
dhruvja Jul 8, 2024
c0fc9ef
deref instead of clone
dhruvja Jul 8, 2024
a2d2c3c
fix clippy
dhruvja Jul 8, 2024
7077206
fmt
dhruvja Jul 8, 2024
b263140
fix clippy
dhruvja Jul 8, 2024
1f951b3
use into iter
dhruvja Jul 10, 2024
b894ff2
not use ref in find
dhruvja Jul 10, 2024
8ad8b62
throw err without if else branching
dhruvja Jul 10, 2024
66d22df
use decimals in the eq instead of calculating before
dhruvja Jul 10, 2024
ccfc142
fmt
dhruvja Jul 10, 2024
33101f9
fmt
dhruvja Jul 15, 2024
48483d7
use lazy evaluation
dhruvja Jul 15, 2024
f11a065
store price with exponent
dhruvja Jul 15, 2024
f200f48
fmt
dhruvja Jul 16, 2024
b1969e4
revert change to restaking.ts file
dhruvja Jul 16, 2024
dd164a0
fix clippy
dhruvja Jul 16, 2024
eb3b581
update delegations during deposit/withdraw
dhruvja Jul 23, 2024
20547b9
check for duplicates in the ix payload
dhruvja Jul 23, 2024
cfbd6e8
proper calculation when updating the stake
dhruvja Jul 23, 2024
9a6a233
use proper conversions when calculating the amount from the price
dhruvja Jul 23, 2024
0c9ebeb
remove unused update_frequency attr
dhruvja Jul 23, 2024
83cf557
ignore the remainder
dhruvja Jul 23, 2024
6ee16e3
fix clippy
dhruvja Jul 23, 2024
6318686
add fee payer to send transfer method
dhruvja Jul 29, 2024
89ea265
Merge branch 'master' of https://github.com/ComposableFi/emulated-lig…
dhruvja Aug 6, 2024
a0deea5
remove guest chain program id
dhruvja Aug 15, 2024
f0e4ca4
remove remainder from amount when depositing
dhruvja Aug 15, 2024
7a49524
add pause flag for tokens
dhruvja Aug 15, 2024
5b52f9b
remove fee payer
dhruvja Aug 21, 2024
1044781
increase maximum age for oracle
dhruvja Sep 2, 2024
f190512
add a method to reallocate common state
dhruvja Sep 4, 2024
025a490
make decimals as 6
dhruvja Sep 12, 2024
360e64e
fix multiplication overflow
dhruvja Oct 10, 2024
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
6 changes: 6 additions & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ rpc_port = 8899

[[test.validator.clone]]
address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"

[[test.validator.clone]]
address = "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"

[[test.validator.clone]]
address = "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
59 changes: 59 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pretty_assertions = "1.4.0"
primitive-types = "0.12.2"
prost = { version = "0.12.3", default-features = false }
prost-build = { version = "0.12.3", default-features = false }
pyth-solana-receiver-sdk ="0.1.0"
rand = { version = "0.8.5" }
reqwest = "0.12.3"
serde = "1"
Expand Down
5 changes: 5 additions & 0 deletions solana/restaking-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ These are changes which were introduced in the new version.
- If one of the validator gets slashed, the amount is slashed equally among the validators.
- A fungible receipt token is issued instead of a non fungible one.
- There is no unbonding period since all the validators get slashed equally.
- Allow deposits of tokens other than LSTs with the use of oracles.

This program can only be called by the bridge contract. If people just want to restake directly and dont want to bridge, they can do it via restaking-v1 program.

## Oracles

For tokens others than LSTs which have a different value than SOL, we need to use oracle to get their current price and then update the stake. But since the stake is recorded in lamports in the guest chain, everytime the price changes we would need to update the stake. To do this, we store the delegations of the particular token locally and get the price on every interval set during initialization. Every time the price is updated, we calculate the difference and update the price on the guest chain. This would make sure that the stake on guest chain is always up to date. Whenever new deposits are made, it would use the stored price rather than from the oracle. But if the price is stale then the deposit would be rejected. This is a better way of updating the stake using oracle where we need to update it once for all the deposits for a particular token during an interval.
1 change: 1 addition & 0 deletions solana/restaking-v2/programs/restaking-v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ anchor-spl = { workspace = true, features = ["metadata"] }
solana-ibc = { workspace = true, features = ["cpi"] }
solana-program.workspace = true
solana-signature-verifier.workspace = true
pyth-solana-receiver-sdk.workspace = true

[dev-dependencies]
anchor-client.workspace = true
Expand Down
Loading
Loading