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

TON Pool Staker #11

Merged
merged 8 commits into from
Dec 3, 2024
Merged

TON Pool Staker #11

merged 8 commits into from
Dec 3, 2024

Conversation

welldan97
Copy link
Collaborator

Add support for Chorus One TON Pool solution, which has 2 pools underneath

Copy link
Contributor

@mkaczanowski mkaczanowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, apart from minor questions it would be nice to post a few CLI invocations and resulting transactions on testnet to prove code works as expected

packages/ton/src/TonPoolStaker.ts Outdated Show resolved Hide resolved
packages/ton/src/TonPoolStaker.ts Outdated Show resolved Hide resolved
@nhallenC1 nhallenC1 marked this pull request as ready for review December 2, 2024 22:20
@nhallenC1
Copy link
Collaborator

TON SDK docs look amazing, great work @mkaczanowski and @welldan97! 🚀

Wanted to raise it here too -- I did notice that the Signing with Fireblocks link appears to be broken.
Upon further review, looks like all the sections that use "Signing with Fireblocks" have that broken link. (For Pool, Single, and Nominator options)

  • E.g. the the section here

Similarly, each section right above that for "What is a Signer?" right above the Fireblocks section in each pool type have the same issue.

However, "What is a Signer?" at the bottom of each of those pages works fine! 👍

@welldan97
Copy link
Collaborator Author

welldan97 commented Dec 3, 2024

@mkaczanowski @nhallenC1, I've addressed the comments. I've also added an architecture overview.
Attaching examples of outputs. We should improve those, though I suggest to do in other PR:

Staking:

https://testnet.tonviewer.com/transaction/c783619915ba10c21e76cb16e804248e1293ac1cd37b579ce9a8163757c1e749

Output
> npm run staking-cli -- ton tx delegate-pool 1.2 -c ./config.json -b -s local
# [0/3] inspect input data
{
  "delegator": "0QDeHoxmpJ6dzzl7KyHDQuOSkwvEnXMcs-8gMCJOSo-IpWcm",
  "validatorAddress": "kQAHBakDk_E7qLlNQZxJDsqj_ruyAFpqarw85tO-c03fK26F",
  "messageType": "delegate-pool",
  "args": [
    "1.2"
  ],
  "broadcast": true
}
Delegating to validator #1: kQAHBakDk_E7qLlNQZxJDsqj_ruyAFpqarw85tO-c03fK26F
# [1/3] prepare unsigned transaction
{
  "validUntil": 1733257844,
  "message": {
    "address": "kQAHBakDk_E7qLlNQZxJDsqj_ruyAFpqarw85tO-c03fK26F",
    "bounceable": true,
    "amount": "1200000000",
    "payload": {
      "_hashes": [
        {
          "type": "Buffer",
          "data": [
            160,
            114,
            199,
            255,
            48,
            63,
            112,
            236,
            149,
            200,
            195,
            90,
            121,
            60,
            84,
            70,
            104,
            166,
            11,
            35,
            21,
            20,
            156,
            253,
            105,
            74,
            133,
            3,
            140,
            236,
            235,
            146
          ]
        },
        {
          "type": "Buffer",
          "data": [
            160,
            114,
            199,
            255,
            48,
            63,
            112,
            236,
            149,
            200,
            195,
            90,
            121,
            60,
            84,
            70,
            104,
            166,
            11,
            35,
            21,
            20,
            156,
            253,
            105,
            74,
            133,
            3,
            140,
            236,
            235,
            146
          ]
        },
        {
          "type": "Buffer",
          "data": [
            160,
            114,
            199,
            255,
            48,
            63,
            112,
            236,
            149,
            200,
            195,
            90,
            121,
            60,
            84,
            70,
            104,
            166,
            11,
            35,
            21,
            20,
            156,
            253,
            105,
            74,
            133,
            3,
            140,
            236,
            235,
            146
          ]
        },
        {
          "type": "Buffer",
          "data": [
            160,
            114,
            199,
            255,
            48,
            63,
            112,
            236,
            149,
            200,
            195,
            90,
            121,
            60,
            84,
            70,
            104,
            166,
            11,
            35,
            21,
            20,
            156,
            253,
            105,
            74,
            133,
            3,
            140,
            236,
            235,
            146
          ]
        }
      ],
      "_depths": [
        0,
        0,
        0,
        0
      ],
      "type": -1,
      "bits": {
        "_length": 156,
        "_data": {
          "type": "Buffer",
          "data": [
            123,
            205,
            31,
            239,
            0,
            0,
            4,
            27,
            214,
            35,
            243,
            227,
            48,
            24,
            106,
            0,
            0,
            0,
            83,
            144,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ]
        },
        "_offset": 0
      },
      "refs": [],
      "mask": {
        "_mask": 0,
        "_hashIndex": 0,
        "_hashCount": 1
      }
    }
  }
}
Do you want to sign the TX? [y/n]: y
signing data from address: 0QDeHoxmpJ6dzzl7KyHDQuOSkwvEnXMcs-8gMCJOSo-IpWcm
* signed transaction received:
{
  tx: x{0100B61BABAD9333BFDA242C578E5FD5F6A6CC11B0E32FD21FEDB33CA3A05F925C92080D7D7D573599C22155D5EB99AE9AEAE6EAC75598ADD359AA11F4E02B0D29A9A317674F6A740000001D0003}
   x{62000382D481C9F89DD45CA6A0CE24876551FF5DD9002D35355E1E7369DF39A6EF95A23C346000000000000000000000000000007BCD1FEF0000041BD623F3E330186A000000539},
  address: '0QDeHoxmpJ6dzzl7KyHDQuOSkwvEnXMcs-8gMCJOSo-IpWcm',
  txHash: 'beb3b11d25931749054619db63e16e056cc9a8c415bc4767b54ec132678b8425',
  stateInit: undefined
}
Do you want to broadcast TX? [y/n]: y
# [3/3] broadcasting the signed transaction

Check TX status here: https://testnet.tonviewer.com/transaction/c783619915ba10c21e76cb16e804248e1293ac1cd37b579ce9a8163757c1e749

Unstaking:

https://testnet.tonviewer.com/transaction/dac72d8231cbc9b6af3d11264d768586fd5066c3825757c984cdd4407a3118fb

Output

> npm run staking-cli -- ton tx unstake-pool 2.5 -c ./config.json -b -s local -I 1
# [0/3] inspect input data
{
  "delegator": "0QDeHoxmpJ6dzzl7KyHDQuOSkwvEnXMcs-8gMCJOSo-IpWcm",
  "validatorAddress": "kQAHBakDk_E7qLlNQZxJDsqj_ruyAFpqarw85tO-c03fK26F",
  "messageType": "unstake-pool",
  "args": [
    "2.5"
  ],
  "broadcast": true
}
Unstaking from validator #1: kQAHBakDk_E7qLlNQZxJDsqj_ruyAFpqarw85tO-c03fK26F
# [1/3] prepare unsigned transaction
{
  "validUntil": 1733253997,
  "message": {
    "address": "kQAHBakDk_E7qLlNQZxJDsqj_ruyAFpqarw85tO-c03fK26F",
    "bounceable": true,
    "amount": "200000000",
    "payload": {
      "_hashes": [
        {
          "type": "Buffer",
          "data": [
            100,
            102,
            106,
            168,
            3,
            54,
            217,
            83,
            84,
            11,
            236,
            63,
            196,
            198,
            154,
            4,
            123,
            60,
            111,
            234,
            143,
            11,
            41,
            156,
            99,
            169,
            9,
            12,
            212,
            24,
            131,
            205
          ]
        },
        {
          "type": "Buffer",
          "data": [
            100,
            102,
            106,
            168,
            3,
            54,
            217,
            83,
            84,
            11,
            236,
            63,
            196,
            198,
            154,
            4,
            123,
            60,
            111,
            234,
            143,
            11,
            41,
            156,
            99,
            169,
            9,
            12,
            212,
            24,
            131,
            205
          ]
        },
        {
          "type": "Buffer",
          "data": [
            100,
            102,
            106,
            168,
            3,
            54,
            217,
            83,
            84,
            11,
            236,
            63,
            196,
            198,
            154,
            4,
            123,
            60,
            111,
            234,
            143,
            11,
            41,
            156,
            99,
            169,
            9,
            12,
            212,
            24,
            131,
            205
          ]
        },
        {
          "type": "Buffer",
          "data": [
            100,
            102,
            106,
            168,
            3,
            54,
            217,
            83,
            84,
            11,
            236,
            63,
            196,
            198,
            154,
            4,
            123,
            60,
            111,
            234,
            143,
            11,
            41,
            156,
            99,
            169,
            9,
            12,
            212,
            24,
            131,
            205
          ]
        }
      ],
      "_depths": [
        0,
        0,
        0,
        0
      ],
      "type": -1,
      "bits": {
        "_length": 160,
        "_data": {
          "type": "Buffer",
          "data": [
            218,
            128,
            62,
            253,
            0,
            6,
            57,
            34,
            21,
            243,
            90,
            225,
            48,
            24,
            106,
            4,
            149,
            2,
            249,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ]
        },
        "_offset": 0
      },
      "refs": [],
      "mask": {
        "_mask": 0,
        "_hashIndex": 0,
        "_hashCount": 1
      }
    }
  }
}
Do you want to sign the TX? [y/n]: y
signing data from address: 0QDeHoxmpJ6dzzl7KyHDQuOSkwvEnXMcs-8gMCJOSo-IpWcm
* signed transaction received:
{
  tx: x{503C1E5F0296BE753C01B8D6D0D5F9D309386B9C9A60A339CAF360BD9AD4097E20756D31E9C7D23D4310C3E3749B49981B48E07F18F88897AEA594A9ECB1290929A9A317674F5B6D0000001A0003}
   x{62000382D481C9F89DD45CA6A0CE24876551FF5DD9002D35355E1E7369DF39A6EF95A05F5E100000000000000000000000000000DA803EFD0006392215F35AE130186A049502F900},
  address: '0QDeHoxmpJ6dzzl7KyHDQuOSkwvEnXMcs-8gMCJOSo-IpWcm',
  txHash: '97701a32770ab98e40f83a15be8cb9921721dbd47eb8b7525c031c4742396438',
  stateInit: undefined
}
Do you want to broadcast TX? [y/n]: y
# [3/3] broadcasting the signed transaction

Check TX status here: https://testnet.tonviewer.com/transaction/dac72d8231cbc9b6af3d11264d768586fd5066c3825757c984cdd4407a3118fb


@welldan97 welldan97 merged commit 523c634 into main Dec 3, 2024
3 checks passed
@welldan97 welldan97 deleted the ton-pool branch December 3, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants