Comments (6)
Delegation on Stake Pool is a two step process. We need to account for that in our DelegateDeposit function and the bot.
Link to conversation on Slack about this : https://chorusone.slack.com/archives/C01TPS807D2/p1619433904001700
from solido.
Given that the Stake Pool program only accepts activated stake accounts, this needs to be broken into two functions.
A rough sketch below. Feel free to add notes @naomijub @enriquefynn @joncinque
DelegateDeposits
attempts to create an activating stake account that will delegate x
amount to validator v
.
It will fail if there exists an activating or activated-but-not-merged stake account for this validator v
.
Note : For each validator in the Stake Pool Program, we will only maintain atmost one (Activating or Activated-But-Not-Merged) Stake Account in the Lido Program.
1. DelegateDeposits(x: amount, v: validator)
1.1 Compute Stake Account Address = f(Program ID, Validator)
- If it already exists, then it was created earlier by another DelegateDeposits call
- And so it is either in `Activating Stake` or `Activated But Not Merged State`
- A possibility is that at this point : we fail this transaction
- So we are effectively pausing delegating to this validator until the last delegation
we did for this validator has been activated and merged with the Stake Pool
- This also discourages repeated delegations to the same validator.
1.2 If you reached here, that means the stake account doesn't exist
1.3 Create Stake Account with x SOL in it
- (taking the x SOL from the Lido Deposit Pool, of course x < amount in Deposit Pool)
1.4 Delegate it to the validator v
1.5 <Check : What should we set the withdraw and stake authorities to - at this point
- so it's not stolen>
1.6 Stake Account is now activating : nothing to do in this function
As mentioned above, for each validator in the Stake Pool Program, the Lido Program maintains atmost one stake account in the Lido Program.
SubmitStakeAccount(v)
- checks if the Lido Program has a stake account that corresponds to this validator. If it exists and is activated and is the credits observed match (i.e. the stake account is mergeable) - it will submit this stake account to the Stake Pool program (in lieu of Stake Pool tokens)
2. SubmitStakeAccount(v: validator)
2.1 Compute Stake Account Address = f(Program ID, Validator)
2.2 If this stake account doesn't exist - fail
2.3 If this stake account is still activating - fail
2.4 If this stake account is activated
a) check - do credits_observed of your stake pool stake account and the deposited stake account match
- If no, fail.
- If yes, proceed to next step
b) set authorities to Stake Pool Deposit Authority
c) call Stake Pool deposit for the above stake account (in the same transaction)
2.5 Note : If 2.4 succeeds, then this Stake Account Address would be destroyed.
from solido.
Regarding
1.5 <Check : What should we set the withdraw and stake authorities to - at this point - so it's not stolen>
You can do something very simple, and set the stake / withdraw authority directly to the deposit authority of the stake pool program, and that way you won't ever need to do 2.4.b
from solido.
Nice. I thought that at first, but something you wrote on Slack got me confused. I will clarify it in our call! :) Cheers.
from solido.
I think 2.2, 2.3 are covered when we call deposit
to the stake pool, as it will try to merge the two stake accounts.
If both are activating is also fine (good for the tests) as @joncinque pointed out
from solido.
So the transaction will fail in these cases - when stake_merge
is called in the Stake Pool program. Got it.
from solido.
Related Issues (20)
- Add a service that can return historical APY HOT 1
- Backfilling historical stSOL price information HOT 3
- Limit queries to select `epoch + offset`
- Test deploying Anker program with a pre-existing mint
- [APY daemon] Make /metrics internal
- Add Expires header to APY responses HOT 1
- Add fuzzer for APY daemon HOT 1
- Cannot install Solido JS SDK by npm HOT 2
- Can not confirm tx when i use a keypair instance which import by secret key.
- Arbitrage our own `try_sell_anker_rewards` call HOT 5
- Cli: solido deposit doesn't work HOT 1
- wrong minimum_balance in get_reserve_available_balance() HOT 2
- open api for rates HOT 2
- Can't build hello world example using solido repo as external repo HOT 2
- `process_withdraw` duplicates `check_mint` check. HOT 1
- Update Solana to a more recent version
- Updating the Anker deployment
- cargo build fail HOT 1
- Why are the structs different in the rust program vs js package? HOT 4
- Deactivating stake is not exposed properly in Prometheus metrics HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solido.