Skip to content

Commit

Permalink
Merge pull request #2 from agoltzman/main
Browse files Browse the repository at this point in the history
fix: removed controller references
  • Loading branch information
SlavaSereb authored Aug 8, 2023
2 parents 21f3c06 + 595d6a5 commit 756182a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

This script allows to stake KSM via the Fireblocks system using the RAW signing API feature.

## :warning: Breaking Change in 2.0.0 :warning:
Version 2.0.0 introduces a breaking change; as per [this forum post](https://forum.polkadot.network/t/staking-controller-deprecation-plan-staking-ui-leads-comms/2748) on Polkadot - the controller is being deprecated.<br>
As a result the following breaking changes were introduced:
* The function `setController` will no longer work and will results in an error
* The function `bond` no longer accepts 4 arguments, instead only 3 arguments - `vaultAccountId: string, amount?: number, rewardDestination?: string` (the `controller` argument was removed)

**Prerequisites:**

1. Run `npm i` from the project's directory to install all needed dependencies.

2. Create the following vault accounts with KSM wallet within each:

a. Stash Account - holds the amount to stake

b. Controller Account - has the permissions to run nominations (should have balance of 25 KSM)
2. Create a vault account with KSM wallet which will act as a stash and controller account

3. Enable RAW signing feature by contacting Fireblocks's support team

Expand All @@ -28,30 +30,28 @@ This script allows to stake KSM via the Fireblocks system using the RAW signing

**How to stake KSM**

1. addProxy(<controller_account_vault_account_id>, <proxy_ksm_address>);
1. addProxy(<stake_account_vault_account_id>, <proxy_ksm_address>);

2. bond(<stash_account_vault_account_id>, <amount_to_stake>, <controller_account_address>, **optional** - <reward_destination>);
2. bond(<stash_account_vault_account_id>, <amount_to_stake>, **optional** - <reward_destination>);

reward_destination - Can be one of the following:

1. Stash (Default)

2. Staked - the rewards are sent back to the Stash and automatically bonded

3. Controller - the rewards are sent back to the Controller account

**How to stake extra KSM**
1. bondExtra(<stash_account_vault_account_id>, <amount_to_bond>)

**How to stop staking**

1. chill(<controller_account_vault_account_id>);
1. chill(<stake_account_vault_account_id>);

2. unbond(<controller_account_vault_account_id>, <amount_to_unbond>);
2. unbond(<stake_account_vault_account_id>, <amount_to_unbond>);

3. **7 days after** unbond() - withdrawUnbonded(<controller_account_vault_account_id>);
3. **7 days after** unbond() - withdrawUnbonded(<stake_account_vault_account_id>);

4. **Optional** - removeProxy(<controller_account_vault_account_id>, <proxy_ksm_address>);
4. **Optional** - removeProxy(<stake_account_vault_account_id>, <proxy_ksm_address>);

**How to change controller**

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ksm_staking",
"version": "1.0.0",
"version": "2.0.0",
"description": "FB KSM Staking",
"main": "index.js",
"scripts": {
Expand All @@ -9,7 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@polkadot/api": "6.3.1",
"@polkadot/api": "^10.9.1",
"fireblocks-sdk": ">=1.7.1",
"fs": "0.0.1-security",
"path": "^0.12.7",
Expand Down
11 changes: 5 additions & 6 deletions src/ksm-staker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,22 @@ export class KSMStaker {
* Bond an amount of KSM from the stash to the controller
* @param vaultAccountId - Stash vault account ID
* @param amount - the amount to bond
* @param controllerAddress - the controller's address
* @param rewardDestination - rewards destination (Stash, Staked or Controller)
*/

async bond(vaultAccountId, amount?: number, controllerAddress?: string, rewardDestination?: string) {
async bond(vaultAccountId, amount?: number, rewardDestination?: string) {
if(!amount) {
const availableBalance = (await this.apiClient.getVaultAccountAsset(vaultAccountId, this.getAssetId())).available;
amount = Number.parseFloat(availableBalance);
}

const txNote = controllerAddress ? `Bond ${amount} KSM to ${controllerAddress}` : `Bond ${amount} KSM`;
const txNote = `Bond ${amount} KSM`;
console.log(txNote);

await this.sendTransaction({
vaultAccountId,
params: [
'staking.bond', controllerAddress || await this.getPermanentAddress(vaultAccountId),
'staking.bond',
(amount * 1000000000000).toString(),
rewardDestination? rewardDestination: 'Stash'
],
Expand Down Expand Up @@ -120,8 +119,8 @@ export class KSMStaker {
* @param controllerAddress - new controller address
*/

async setController(vaultAccountId, controllerAddress){
await this.sendTransaction({params: ['staking.setController', controllerAddress], vaultAccountId, txNote: `Setting ${controllerAddress} as controller`})
async setController(vaultAccountId){
throw new Error("setController is no longer supported in DOT / KSM / WND, for more information see README.md")
}
}

0 comments on commit 756182a

Please sign in to comment.