@jpool/bond-sdk 0.11.7 → 0.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +799 -1522
- package/dist/index.d.ts +799 -1522
- package/dist/index.js +301 -1263
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +306 -1260
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var anchor = require('@coral-xyz/anchor');
|
|
4
|
-
var splStakePool = require('@solana/spl-stake-pool');
|
|
5
4
|
var splToken = require('@solana/spl-token');
|
|
6
5
|
var web3_js = require('@solana/web3.js');
|
|
7
6
|
|
|
@@ -4569,15 +4568,20 @@ var import_bn = __toESM(require_bn());
|
|
|
4569
4568
|
|
|
4570
4569
|
// src/constants.ts
|
|
4571
4570
|
init_cjs_shims();
|
|
4571
|
+
var GLOBAL_STATE_SEED = "global_state";
|
|
4572
|
+
var BOND_STATE_SEED = "bond_state";
|
|
4573
|
+
var VALIDATOR_BOND_SEED = "validator_bond";
|
|
4574
|
+
var STANDARD_BOND_SEED = "standard";
|
|
4575
|
+
var CROWDFUNDING_BOND_SEED = "crowdfunding";
|
|
4576
|
+
var ENV_PROGRAM_ID = {
|
|
4577
|
+
// [BondClientEnv.DEV]: new PublicKey('...'),
|
|
4578
|
+
};
|
|
4579
|
+
|
|
4580
|
+
// src/history.ts
|
|
4581
|
+
init_cjs_shims();
|
|
4572
4582
|
|
|
4573
4583
|
// src/types/index.ts
|
|
4574
4584
|
init_cjs_shims();
|
|
4575
|
-
var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
|
|
4576
|
-
JBondClientEnv2["DEV"] = "dev";
|
|
4577
|
-
JBondClientEnv2["STAGE"] = "stage";
|
|
4578
|
-
JBondClientEnv2["PROD"] = "prod";
|
|
4579
|
-
return JBondClientEnv2;
|
|
4580
|
-
})(JBondClientEnv || {});
|
|
4581
4585
|
var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
|
|
4582
4586
|
SessionStatus2[SessionStatus2["Live"] = 0] = "Live";
|
|
4583
4587
|
SessionStatus2[SessionStatus2["Finished"] = 1] = "Finished";
|
|
@@ -4589,29 +4593,13 @@ var BondType = /* @__PURE__ */ ((BondType2) => {
|
|
|
4589
4593
|
return BondType2;
|
|
4590
4594
|
})(BondType || {});
|
|
4591
4595
|
var BondTransactionType = /* @__PURE__ */ ((BondTransactionType2) => {
|
|
4592
|
-
BondTransactionType2["Registered"] = "registered";
|
|
4593
4596
|
BondTransactionType2["Deposit"] = "deposit";
|
|
4594
4597
|
BondTransactionType2["Withdrawal"] = "withdrawal";
|
|
4595
4598
|
BondTransactionType2["Compensation"] = "compensation";
|
|
4596
4599
|
return BondTransactionType2;
|
|
4597
4600
|
})(BondTransactionType || {});
|
|
4598
4601
|
|
|
4599
|
-
// src/constants.ts
|
|
4600
|
-
var GLOBAL_STATE_SEED = "global_state";
|
|
4601
|
-
var BOND_STATE_SEED = "bond_state";
|
|
4602
|
-
var VALIDATOR_BOND_SEED = "validator_bond";
|
|
4603
|
-
var STANDARD_BOND_SEED = "standard";
|
|
4604
|
-
var CROWDFUNDING_BOND_SEED = "crowdfunding";
|
|
4605
|
-
var ENV_PROGRAM_ID = {
|
|
4606
|
-
["dev" /* DEV */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
|
|
4607
|
-
["stage" /* STAGE */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
|
|
4608
|
-
["prod" /* PROD */]: "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"
|
|
4609
|
-
};
|
|
4610
|
-
var JSOL_MINT = new web3_js.PublicKey("7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn");
|
|
4611
|
-
var JPOOL_POOL_ADDRESS = new web3_js.PublicKey("CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1");
|
|
4612
|
-
|
|
4613
4602
|
// src/history.ts
|
|
4614
|
-
init_cjs_shims();
|
|
4615
4603
|
var { bs58 } = anchor.utils.bytes;
|
|
4616
4604
|
var HistoryManager = class {
|
|
4617
4605
|
constructor(client) {
|
|
@@ -4633,8 +4621,7 @@ var HistoryManager = class {
|
|
|
4633
4621
|
}
|
|
4634
4622
|
async getHistory(bondType, bondName, vote, opts) {
|
|
4635
4623
|
const [validatorBondAccount] = this.client.pda.validatorBond(bondType, bondName, vote);
|
|
4636
|
-
|
|
4637
|
-
this.debug(`Fetching history for validator bond account: ${validatorBondAccount58}`);
|
|
4624
|
+
this.debug(`Fetching history for validator bond account: ${validatorBondAccount.toBase58()}`);
|
|
4638
4625
|
const signatures = await this.fetchSignaturesForAddress(validatorBondAccount, {
|
|
4639
4626
|
limit: opts?.limit,
|
|
4640
4627
|
before: opts?.before,
|
|
@@ -4675,11 +4662,8 @@ var HistoryManager = class {
|
|
|
4675
4662
|
if (ix.parsed) {
|
|
4676
4663
|
continue;
|
|
4677
4664
|
}
|
|
4678
|
-
if (!this.instructionReferencesBondAccount(ix, validatorBondAccount, validatorBondAccount58)) {
|
|
4679
|
-
continue;
|
|
4680
|
-
}
|
|
4681
4665
|
const { type, amount } = this.decodeInstructionData(ix.data);
|
|
4682
|
-
if (!type || amount <= 0
|
|
4666
|
+
if (!type || amount <= 0) {
|
|
4683
4667
|
continue;
|
|
4684
4668
|
}
|
|
4685
4669
|
history.push({
|
|
@@ -4693,27 +4677,13 @@ var HistoryManager = class {
|
|
|
4693
4677
|
}
|
|
4694
4678
|
return history.sort((a, b) => b.slot - a.slot);
|
|
4695
4679
|
}
|
|
4696
|
-
instructionReferencesBondAccount(ix, validatorBondAccount, validatorBondAccount58) {
|
|
4697
|
-
if (!Array.isArray(ix.accounts) || ix.accounts.length === 0) {
|
|
4698
|
-
return false;
|
|
4699
|
-
}
|
|
4700
|
-
return ix.accounts.some((account) => {
|
|
4701
|
-
if (typeof account === "string") {
|
|
4702
|
-
return account === validatorBondAccount58;
|
|
4703
|
-
}
|
|
4704
|
-
if (account instanceof web3_js.PublicKey) {
|
|
4705
|
-
return account.equals(validatorBondAccount);
|
|
4706
|
-
}
|
|
4707
|
-
const account58 = account?.toBase58?.();
|
|
4708
|
-
return typeof account58 === "string" && account58 === validatorBondAccount58;
|
|
4709
|
-
});
|
|
4710
|
-
}
|
|
4711
4680
|
async fetchSignaturesForAddress(address, options) {
|
|
4712
4681
|
const sigs = await this.connection.getSignaturesForAddress(address, {
|
|
4713
4682
|
limit: options?.limit || 1e3,
|
|
4714
4683
|
before: options?.before,
|
|
4715
4684
|
until: options?.until
|
|
4716
4685
|
}, "confirmed");
|
|
4686
|
+
console.log(sigs);
|
|
4717
4687
|
return sigs.filter((s) => !s.err);
|
|
4718
4688
|
}
|
|
4719
4689
|
async fetchParsedTransactions(sigs, batchSize = 100) {
|
|
@@ -4735,7 +4705,7 @@ var HistoryManager = class {
|
|
|
4735
4705
|
}
|
|
4736
4706
|
const ix = this.program.idl.instructions.find((i) => i.name === name);
|
|
4737
4707
|
if (!ix || !Array.isArray(ix.discriminator)) {
|
|
4738
|
-
|
|
4708
|
+
throw new Error(`Discriminator not found for instruction ${name}`);
|
|
4739
4709
|
}
|
|
4740
4710
|
const disc = new Uint8Array(ix.discriminator);
|
|
4741
4711
|
this.discCache.set(name, disc);
|
|
@@ -4743,45 +4713,47 @@ var HistoryManager = class {
|
|
|
4743
4713
|
}
|
|
4744
4714
|
decodeInstructionData(data) {
|
|
4745
4715
|
if (!data) {
|
|
4746
|
-
return {
|
|
4716
|
+
return {
|
|
4717
|
+
type: null,
|
|
4718
|
+
amount: 0
|
|
4719
|
+
};
|
|
4747
4720
|
}
|
|
4748
4721
|
try {
|
|
4749
4722
|
const buf = bs58.decode(data);
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
const
|
|
4761
|
-
const
|
|
4762
|
-
const
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
}
|
|
4774
|
-
}
|
|
4775
|
-
return { type, amount };
|
|
4776
|
-
} catch
|
|
4777
|
-
console.error("Failed to decode instruction data:", error);
|
|
4723
|
+
if (buf.length < 16) {
|
|
4724
|
+
return {
|
|
4725
|
+
type: null,
|
|
4726
|
+
amount: 0
|
|
4727
|
+
};
|
|
4728
|
+
}
|
|
4729
|
+
const disc = buf.slice(0, 8);
|
|
4730
|
+
const amountBytes = buf.slice(8, 16);
|
|
4731
|
+
const amount = new anchor.BN(amountBytes, "le").toNumber() / web3_js.LAMPORTS_PER_SOL;
|
|
4732
|
+
const perfRegister = this.getInstructionDiscriminator("perfBondRegister");
|
|
4733
|
+
const perfTopUp = this.getInstructionDiscriminator("perfBondTopUp");
|
|
4734
|
+
const perfClaim = this.getInstructionDiscriminator("perfBondClaim");
|
|
4735
|
+
const perfWithdraw = this.getInstructionDiscriminator("perfBondWithdraw");
|
|
4736
|
+
if (Buffer.from(disc).equals(Buffer.from(perfRegister))) {
|
|
4737
|
+
return { type: "deposit" /* Deposit */, amount };
|
|
4738
|
+
}
|
|
4739
|
+
if (Buffer.from(disc).equals(Buffer.from(perfTopUp))) {
|
|
4740
|
+
return { type: "deposit" /* Deposit */, amount };
|
|
4741
|
+
}
|
|
4742
|
+
if (Buffer.from(disc).equals(Buffer.from(perfClaim))) {
|
|
4743
|
+
return { type: "compensation" /* Compensation */, amount };
|
|
4744
|
+
}
|
|
4745
|
+
if (Buffer.from(disc).equals(Buffer.from(perfWithdraw))) {
|
|
4746
|
+
return { type: "withdrawal" /* Withdrawal */, amount };
|
|
4747
|
+
}
|
|
4748
|
+
return { type: null, amount: 0 };
|
|
4749
|
+
} catch {
|
|
4778
4750
|
return { type: null, amount: 0 };
|
|
4779
4751
|
}
|
|
4780
4752
|
}
|
|
4781
4753
|
};
|
|
4782
4754
|
function slotToEpoch(slot, cluster) {
|
|
4783
|
-
const
|
|
4784
|
-
const slotsPerEpoch =
|
|
4755
|
+
const isMainnet = !cluster || cluster === "mainnet-beta";
|
|
4756
|
+
const slotsPerEpoch = isMainnet ? 432e3 : 4e5;
|
|
4785
4757
|
return Math.floor(slot / slotsPerEpoch);
|
|
4786
4758
|
}
|
|
4787
4759
|
|
|
@@ -4790,7 +4762,7 @@ var jbond_default = {
|
|
|
4790
4762
|
address: "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU",
|
|
4791
4763
|
metadata: {
|
|
4792
4764
|
name: "jbond",
|
|
4793
|
-
version: "0.2.
|
|
4765
|
+
version: "0.2.1",
|
|
4794
4766
|
spec: "0.1.0",
|
|
4795
4767
|
description: "Jpool Bond Program"
|
|
4796
4768
|
},
|
|
@@ -4865,10 +4837,7 @@ var jbond_default = {
|
|
|
4865
4837
|
},
|
|
4866
4838
|
{
|
|
4867
4839
|
name: "authority",
|
|
4868
|
-
signer: true
|
|
4869
|
-
relations: [
|
|
4870
|
-
"bond_state"
|
|
4871
|
-
]
|
|
4840
|
+
signer: true
|
|
4872
4841
|
},
|
|
4873
4842
|
{
|
|
4874
4843
|
name: "bond_token_account",
|
|
@@ -5039,84 +5008,6 @@ var jbond_default = {
|
|
|
5039
5008
|
}
|
|
5040
5009
|
]
|
|
5041
5010
|
},
|
|
5042
|
-
{
|
|
5043
|
-
name: "bond_lock_funds",
|
|
5044
|
-
docs: [
|
|
5045
|
-
"Locks funds immediately, making them unavailable for withdrawal.",
|
|
5046
|
-
"The locked amount takes effect immediately in the current epoch.",
|
|
5047
|
-
"",
|
|
5048
|
-
"# Errors",
|
|
5049
|
-
"Fails if the bond type is not lockable, if the amount is zero,",
|
|
5050
|
-
"or if there are insufficient available funds."
|
|
5051
|
-
],
|
|
5052
|
-
discriminator: [
|
|
5053
|
-
117,
|
|
5054
|
-
166,
|
|
5055
|
-
195,
|
|
5056
|
-
99,
|
|
5057
|
-
103,
|
|
5058
|
-
45,
|
|
5059
|
-
195,
|
|
5060
|
-
2
|
|
5061
|
-
],
|
|
5062
|
-
accounts: [
|
|
5063
|
-
{
|
|
5064
|
-
name: "bond_state",
|
|
5065
|
-
writable: true
|
|
5066
|
-
},
|
|
5067
|
-
{
|
|
5068
|
-
name: "validator_bond",
|
|
5069
|
-
writable: true,
|
|
5070
|
-
pda: {
|
|
5071
|
-
seeds: [
|
|
5072
|
-
{
|
|
5073
|
-
kind: "const",
|
|
5074
|
-
value: [
|
|
5075
|
-
118,
|
|
5076
|
-
97,
|
|
5077
|
-
108,
|
|
5078
|
-
105,
|
|
5079
|
-
100,
|
|
5080
|
-
97,
|
|
5081
|
-
116,
|
|
5082
|
-
111,
|
|
5083
|
-
114,
|
|
5084
|
-
95,
|
|
5085
|
-
98,
|
|
5086
|
-
111,
|
|
5087
|
-
110,
|
|
5088
|
-
100
|
|
5089
|
-
]
|
|
5090
|
-
},
|
|
5091
|
-
{
|
|
5092
|
-
kind: "account",
|
|
5093
|
-
path: "bond_state"
|
|
5094
|
-
},
|
|
5095
|
-
{
|
|
5096
|
-
kind: "account",
|
|
5097
|
-
path: "validator_bond.vote_account",
|
|
5098
|
-
account: "ValidatorBond"
|
|
5099
|
-
}
|
|
5100
|
-
]
|
|
5101
|
-
}
|
|
5102
|
-
},
|
|
5103
|
-
{
|
|
5104
|
-
name: "bond_token_account",
|
|
5105
|
-
optional: true
|
|
5106
|
-
},
|
|
5107
|
-
{
|
|
5108
|
-
name: "payer",
|
|
5109
|
-
writable: true,
|
|
5110
|
-
signer: true
|
|
5111
|
-
}
|
|
5112
|
-
],
|
|
5113
|
-
args: [
|
|
5114
|
-
{
|
|
5115
|
-
name: "amount",
|
|
5116
|
-
type: "u64"
|
|
5117
|
-
}
|
|
5118
|
-
]
|
|
5119
|
-
},
|
|
5120
5011
|
{
|
|
5121
5012
|
name: "bond_register",
|
|
5122
5013
|
docs: [
|
|
@@ -5144,34 +5035,7 @@ var jbond_default = {
|
|
|
5144
5035
|
accounts: [
|
|
5145
5036
|
{
|
|
5146
5037
|
name: "bond_state",
|
|
5147
|
-
writable: true
|
|
5148
|
-
pda: {
|
|
5149
|
-
seeds: [
|
|
5150
|
-
{
|
|
5151
|
-
kind: "const",
|
|
5152
|
-
value: [
|
|
5153
|
-
98,
|
|
5154
|
-
111,
|
|
5155
|
-
110,
|
|
5156
|
-
100,
|
|
5157
|
-
95,
|
|
5158
|
-
115,
|
|
5159
|
-
116,
|
|
5160
|
-
97,
|
|
5161
|
-
116,
|
|
5162
|
-
101
|
|
5163
|
-
]
|
|
5164
|
-
},
|
|
5165
|
-
{
|
|
5166
|
-
kind: "arg",
|
|
5167
|
-
path: "bond_type"
|
|
5168
|
-
},
|
|
5169
|
-
{
|
|
5170
|
-
kind: "arg",
|
|
5171
|
-
path: "bond_name"
|
|
5172
|
-
}
|
|
5173
|
-
]
|
|
5174
|
-
}
|
|
5038
|
+
writable: true
|
|
5175
5039
|
},
|
|
5176
5040
|
{
|
|
5177
5041
|
name: "validator_bond",
|
|
@@ -5256,112 +5120,6 @@ var jbond_default = {
|
|
|
5256
5120
|
}
|
|
5257
5121
|
]
|
|
5258
5122
|
},
|
|
5259
|
-
{
|
|
5260
|
-
name: "bond_release_funds",
|
|
5261
|
-
docs: [
|
|
5262
|
-
"Queues funds for unlock in the next epoch.",
|
|
5263
|
-
"The unlock is delayed by one epoch for security - funds remain locked",
|
|
5264
|
-
"in the current epoch but will be available after epoch transition.",
|
|
5265
|
-
"",
|
|
5266
|
-
"# Errors",
|
|
5267
|
-
"Fails if the bond type is not lockable, if the amount is zero,",
|
|
5268
|
-
"or if the amount exceeds currently locked funds."
|
|
5269
|
-
],
|
|
5270
|
-
discriminator: [
|
|
5271
|
-
184,
|
|
5272
|
-
224,
|
|
5273
|
-
14,
|
|
5274
|
-
24,
|
|
5275
|
-
76,
|
|
5276
|
-
14,
|
|
5277
|
-
226,
|
|
5278
|
-
190
|
|
5279
|
-
],
|
|
5280
|
-
accounts: [
|
|
5281
|
-
{
|
|
5282
|
-
name: "bond_state",
|
|
5283
|
-
writable: true
|
|
5284
|
-
},
|
|
5285
|
-
{
|
|
5286
|
-
name: "validator_bond",
|
|
5287
|
-
writable: true,
|
|
5288
|
-
pda: {
|
|
5289
|
-
seeds: [
|
|
5290
|
-
{
|
|
5291
|
-
kind: "const",
|
|
5292
|
-
value: [
|
|
5293
|
-
118,
|
|
5294
|
-
97,
|
|
5295
|
-
108,
|
|
5296
|
-
105,
|
|
5297
|
-
100,
|
|
5298
|
-
97,
|
|
5299
|
-
116,
|
|
5300
|
-
111,
|
|
5301
|
-
114,
|
|
5302
|
-
95,
|
|
5303
|
-
98,
|
|
5304
|
-
111,
|
|
5305
|
-
110,
|
|
5306
|
-
100
|
|
5307
|
-
]
|
|
5308
|
-
},
|
|
5309
|
-
{
|
|
5310
|
-
kind: "account",
|
|
5311
|
-
path: "bond_state"
|
|
5312
|
-
},
|
|
5313
|
-
{
|
|
5314
|
-
kind: "account",
|
|
5315
|
-
path: "validator_bond.vote_account",
|
|
5316
|
-
account: "ValidatorBond"
|
|
5317
|
-
}
|
|
5318
|
-
]
|
|
5319
|
-
}
|
|
5320
|
-
},
|
|
5321
|
-
{
|
|
5322
|
-
name: "payer",
|
|
5323
|
-
writable: true,
|
|
5324
|
-
signer: true
|
|
5325
|
-
}
|
|
5326
|
-
],
|
|
5327
|
-
args: [
|
|
5328
|
-
{
|
|
5329
|
-
name: "amount",
|
|
5330
|
-
type: "u64"
|
|
5331
|
-
}
|
|
5332
|
-
]
|
|
5333
|
-
},
|
|
5334
|
-
{
|
|
5335
|
-
name: "bond_remove",
|
|
5336
|
-
docs: [
|
|
5337
|
-
"Removes bond state"
|
|
5338
|
-
],
|
|
5339
|
-
discriminator: [
|
|
5340
|
-
121,
|
|
5341
|
-
112,
|
|
5342
|
-
246,
|
|
5343
|
-
177,
|
|
5344
|
-
181,
|
|
5345
|
-
8,
|
|
5346
|
-
18,
|
|
5347
|
-
220
|
|
5348
|
-
],
|
|
5349
|
-
accounts: [
|
|
5350
|
-
{
|
|
5351
|
-
name: "bond_state",
|
|
5352
|
-
writable: true
|
|
5353
|
-
},
|
|
5354
|
-
{
|
|
5355
|
-
name: "authority",
|
|
5356
|
-
writable: true,
|
|
5357
|
-
signer: true,
|
|
5358
|
-
relations: [
|
|
5359
|
-
"bond_state"
|
|
5360
|
-
]
|
|
5361
|
-
}
|
|
5362
|
-
],
|
|
5363
|
-
args: []
|
|
5364
|
-
},
|
|
5365
5123
|
{
|
|
5366
5124
|
name: "bond_set_withdraw_authority",
|
|
5367
5125
|
docs: [
|
|
@@ -5652,113 +5410,16 @@ var jbond_default = {
|
|
|
5652
5410
|
]
|
|
5653
5411
|
},
|
|
5654
5412
|
{
|
|
5655
|
-
name: "
|
|
5656
|
-
docs: [
|
|
5657
|
-
"Closes a validator bond account and transfers remaining balance to the rent receiver.",
|
|
5658
|
-
"",
|
|
5659
|
-
"# Security",
|
|
5660
|
-
"- Only the validator identity or withdrawal authority can close the bond",
|
|
5661
|
-
"- All funds must be unlocked (locked == 0 and pending_unlock == 0)",
|
|
5662
|
-
"- For token collateral, closes the associated token account as well",
|
|
5663
|
-
"- Decrements the bond state's total_members counter",
|
|
5664
|
-
"",
|
|
5665
|
-
"# Errors",
|
|
5666
|
-
"Fails if the signer is not authorized, if funds are still locked,",
|
|
5667
|
-
"or if the rent receiver is not the identity or withdrawal authority."
|
|
5668
|
-
],
|
|
5413
|
+
name: "global_configure",
|
|
5669
5414
|
discriminator: [
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
],
|
|
5679
|
-
accounts: [
|
|
5680
|
-
{
|
|
5681
|
-
name: "bond_state",
|
|
5682
|
-
writable: true
|
|
5683
|
-
},
|
|
5684
|
-
{
|
|
5685
|
-
name: "validator_bond",
|
|
5686
|
-
writable: true,
|
|
5687
|
-
pda: {
|
|
5688
|
-
seeds: [
|
|
5689
|
-
{
|
|
5690
|
-
kind: "const",
|
|
5691
|
-
value: [
|
|
5692
|
-
118,
|
|
5693
|
-
97,
|
|
5694
|
-
108,
|
|
5695
|
-
105,
|
|
5696
|
-
100,
|
|
5697
|
-
97,
|
|
5698
|
-
116,
|
|
5699
|
-
111,
|
|
5700
|
-
114,
|
|
5701
|
-
95,
|
|
5702
|
-
98,
|
|
5703
|
-
111,
|
|
5704
|
-
110,
|
|
5705
|
-
100
|
|
5706
|
-
]
|
|
5707
|
-
},
|
|
5708
|
-
{
|
|
5709
|
-
kind: "account",
|
|
5710
|
-
path: "bond_state"
|
|
5711
|
-
},
|
|
5712
|
-
{
|
|
5713
|
-
kind: "account",
|
|
5714
|
-
path: "validator_bond.vote_account",
|
|
5715
|
-
account: "ValidatorBond"
|
|
5716
|
-
}
|
|
5717
|
-
]
|
|
5718
|
-
}
|
|
5719
|
-
},
|
|
5720
|
-
{
|
|
5721
|
-
name: "authority",
|
|
5722
|
-
writable: true,
|
|
5723
|
-
signer: true
|
|
5724
|
-
},
|
|
5725
|
-
{
|
|
5726
|
-
name: "rent_receiver",
|
|
5727
|
-
writable: true
|
|
5728
|
-
},
|
|
5729
|
-
{
|
|
5730
|
-
name: "bond_token_account",
|
|
5731
|
-
writable: true,
|
|
5732
|
-
optional: true
|
|
5733
|
-
},
|
|
5734
|
-
{
|
|
5735
|
-
name: "destination_token_account",
|
|
5736
|
-
writable: true,
|
|
5737
|
-
optional: true
|
|
5738
|
-
},
|
|
5739
|
-
{
|
|
5740
|
-
name: "system_program",
|
|
5741
|
-
address: "11111111111111111111111111111111"
|
|
5742
|
-
},
|
|
5743
|
-
{
|
|
5744
|
-
name: "token_program",
|
|
5745
|
-
optional: true,
|
|
5746
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
5747
|
-
}
|
|
5748
|
-
],
|
|
5749
|
-
args: []
|
|
5750
|
-
},
|
|
5751
|
-
{
|
|
5752
|
-
name: "global_configure",
|
|
5753
|
-
discriminator: [
|
|
5754
|
-
67,
|
|
5755
|
-
142,
|
|
5756
|
-
164,
|
|
5757
|
-
250,
|
|
5758
|
-
90,
|
|
5759
|
-
233,
|
|
5760
|
-
144,
|
|
5761
|
-
187
|
|
5415
|
+
67,
|
|
5416
|
+
142,
|
|
5417
|
+
164,
|
|
5418
|
+
250,
|
|
5419
|
+
90,
|
|
5420
|
+
233,
|
|
5421
|
+
144,
|
|
5422
|
+
187
|
|
5762
5423
|
],
|
|
5763
5424
|
accounts: [
|
|
5764
5425
|
{
|
|
@@ -5855,6 +5516,80 @@ var jbond_default = {
|
|
|
5855
5516
|
],
|
|
5856
5517
|
args: []
|
|
5857
5518
|
},
|
|
5519
|
+
{
|
|
5520
|
+
name: "migrate_bond",
|
|
5521
|
+
docs: [
|
|
5522
|
+
"Migrates validator bond data from legacy structure to new structure."
|
|
5523
|
+
],
|
|
5524
|
+
discriminator: [
|
|
5525
|
+
107,
|
|
5526
|
+
119,
|
|
5527
|
+
59,
|
|
5528
|
+
110,
|
|
5529
|
+
76,
|
|
5530
|
+
18,
|
|
5531
|
+
37,
|
|
5532
|
+
163
|
|
5533
|
+
],
|
|
5534
|
+
accounts: [
|
|
5535
|
+
{
|
|
5536
|
+
name: "bond_state",
|
|
5537
|
+
writable: true
|
|
5538
|
+
},
|
|
5539
|
+
{
|
|
5540
|
+
name: "legacy_validator_bond",
|
|
5541
|
+
writable: true
|
|
5542
|
+
},
|
|
5543
|
+
{
|
|
5544
|
+
name: "legacy_vote_account"
|
|
5545
|
+
},
|
|
5546
|
+
{
|
|
5547
|
+
name: "validator_bond",
|
|
5548
|
+
writable: true,
|
|
5549
|
+
pda: {
|
|
5550
|
+
seeds: [
|
|
5551
|
+
{
|
|
5552
|
+
kind: "const",
|
|
5553
|
+
value: [
|
|
5554
|
+
118,
|
|
5555
|
+
97,
|
|
5556
|
+
108,
|
|
5557
|
+
105,
|
|
5558
|
+
100,
|
|
5559
|
+
97,
|
|
5560
|
+
116,
|
|
5561
|
+
111,
|
|
5562
|
+
114,
|
|
5563
|
+
95,
|
|
5564
|
+
98,
|
|
5565
|
+
111,
|
|
5566
|
+
110,
|
|
5567
|
+
100
|
|
5568
|
+
]
|
|
5569
|
+
},
|
|
5570
|
+
{
|
|
5571
|
+
kind: "account",
|
|
5572
|
+
path: "bond_state"
|
|
5573
|
+
},
|
|
5574
|
+
{
|
|
5575
|
+
kind: "account",
|
|
5576
|
+
path: "legacy_vote_account"
|
|
5577
|
+
}
|
|
5578
|
+
]
|
|
5579
|
+
}
|
|
5580
|
+
},
|
|
5581
|
+
{
|
|
5582
|
+
name: "creator",
|
|
5583
|
+
writable: true,
|
|
5584
|
+
signer: true
|
|
5585
|
+
},
|
|
5586
|
+
{
|
|
5587
|
+
name: "system_program",
|
|
5588
|
+
address: "11111111111111111111111111111111"
|
|
5589
|
+
}
|
|
5590
|
+
],
|
|
5591
|
+
args: []
|
|
5592
|
+
},
|
|
5858
5593
|
{
|
|
5859
5594
|
name: "session_finish",
|
|
5860
5595
|
docs: [
|
|
@@ -5965,19 +5700,6 @@ var jbond_default = {
|
|
|
5965
5700
|
}
|
|
5966
5701
|
],
|
|
5967
5702
|
events: [
|
|
5968
|
-
{
|
|
5969
|
-
name: "BondConfigured",
|
|
5970
|
-
discriminator: [
|
|
5971
|
-
141,
|
|
5972
|
-
252,
|
|
5973
|
-
43,
|
|
5974
|
-
54,
|
|
5975
|
-
45,
|
|
5976
|
-
157,
|
|
5977
|
-
81,
|
|
5978
|
-
14
|
|
5979
|
-
]
|
|
5980
|
-
},
|
|
5981
5703
|
{
|
|
5982
5704
|
name: "BondFinished",
|
|
5983
5705
|
discriminator: [
|
|
@@ -5991,32 +5713,6 @@ var jbond_default = {
|
|
|
5991
5713
|
191
|
|
5992
5714
|
]
|
|
5993
5715
|
},
|
|
5994
|
-
{
|
|
5995
|
-
name: "BondInitialized",
|
|
5996
|
-
discriminator: [
|
|
5997
|
-
73,
|
|
5998
|
-
68,
|
|
5999
|
-
161,
|
|
6000
|
-
2,
|
|
6001
|
-
214,
|
|
6002
|
-
12,
|
|
6003
|
-
169,
|
|
6004
|
-
53
|
|
6005
|
-
]
|
|
6006
|
-
},
|
|
6007
|
-
{
|
|
6008
|
-
name: "BondRemoved",
|
|
6009
|
-
discriminator: [
|
|
6010
|
-
177,
|
|
6011
|
-
200,
|
|
6012
|
-
116,
|
|
6013
|
-
123,
|
|
6014
|
-
1,
|
|
6015
|
-
244,
|
|
6016
|
-
161,
|
|
6017
|
-
240
|
|
6018
|
-
]
|
|
6019
|
-
},
|
|
6020
5716
|
{
|
|
6021
5717
|
name: "BondStarted",
|
|
6022
5718
|
discriminator: [
|
|
@@ -6031,16 +5727,16 @@ var jbond_default = {
|
|
|
6031
5727
|
]
|
|
6032
5728
|
},
|
|
6033
5729
|
{
|
|
6034
|
-
name: "
|
|
5730
|
+
name: "CollateralToppedUp",
|
|
6035
5731
|
discriminator: [
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
5732
|
+
189,
|
|
5733
|
+
137,
|
|
5734
|
+
204,
|
|
5735
|
+
58,
|
|
6040
5736
|
135,
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
5737
|
+
182,
|
|
5738
|
+
19,
|
|
5739
|
+
176
|
|
6044
5740
|
]
|
|
6045
5741
|
},
|
|
6046
5742
|
{
|
|
@@ -6056,19 +5752,6 @@ var jbond_default = {
|
|
|
6056
5752
|
82
|
|
6057
5753
|
]
|
|
6058
5754
|
},
|
|
6059
|
-
{
|
|
6060
|
-
name: "CompensationBurned",
|
|
6061
|
-
discriminator: [
|
|
6062
|
-
177,
|
|
6063
|
-
198,
|
|
6064
|
-
90,
|
|
6065
|
-
188,
|
|
6066
|
-
47,
|
|
6067
|
-
95,
|
|
6068
|
-
20,
|
|
6069
|
-
174
|
|
6070
|
-
]
|
|
6071
|
-
},
|
|
6072
5755
|
{
|
|
6073
5756
|
name: "CompensationClaimed",
|
|
6074
5757
|
discriminator: [
|
|
@@ -6082,45 +5765,6 @@ var jbond_default = {
|
|
|
6082
5765
|
32
|
|
6083
5766
|
]
|
|
6084
5767
|
},
|
|
6085
|
-
{
|
|
6086
|
-
name: "FundsLocked",
|
|
6087
|
-
discriminator: [
|
|
6088
|
-
227,
|
|
6089
|
-
93,
|
|
6090
|
-
162,
|
|
6091
|
-
69,
|
|
6092
|
-
181,
|
|
6093
|
-
4,
|
|
6094
|
-
71,
|
|
6095
|
-
157
|
|
6096
|
-
]
|
|
6097
|
-
},
|
|
6098
|
-
{
|
|
6099
|
-
name: "FundsUnlocked",
|
|
6100
|
-
discriminator: [
|
|
6101
|
-
11,
|
|
6102
|
-
240,
|
|
6103
|
-
184,
|
|
6104
|
-
107,
|
|
6105
|
-
86,
|
|
6106
|
-
187,
|
|
6107
|
-
196,
|
|
6108
|
-
128
|
|
6109
|
-
]
|
|
6110
|
-
},
|
|
6111
|
-
{
|
|
6112
|
-
name: "ValidatorBondClosed",
|
|
6113
|
-
discriminator: [
|
|
6114
|
-
71,
|
|
6115
|
-
54,
|
|
6116
|
-
59,
|
|
6117
|
-
241,
|
|
6118
|
-
91,
|
|
6119
|
-
35,
|
|
6120
|
-
123,
|
|
6121
|
-
123
|
|
6122
|
-
]
|
|
6123
|
-
},
|
|
6124
5768
|
{
|
|
6125
5769
|
name: "ValidatorRegistered",
|
|
6126
5770
|
discriminator: [
|
|
@@ -6133,46 +5777,33 @@ var jbond_default = {
|
|
|
6133
5777
|
95,
|
|
6134
5778
|
72
|
|
6135
5779
|
]
|
|
6136
|
-
},
|
|
6137
|
-
{
|
|
6138
|
-
name: "WithdrawAuthorityChanged",
|
|
6139
|
-
discriminator: [
|
|
6140
|
-
91,
|
|
6141
|
-
149,
|
|
6142
|
-
224,
|
|
6143
|
-
49,
|
|
6144
|
-
187,
|
|
6145
|
-
48,
|
|
6146
|
-
190,
|
|
6147
|
-
100
|
|
6148
|
-
]
|
|
6149
5780
|
}
|
|
6150
5781
|
],
|
|
6151
5782
|
errors: [
|
|
6152
5783
|
{
|
|
6153
5784
|
code: 6e3,
|
|
6154
|
-
name: "
|
|
6155
|
-
msg: "
|
|
5785
|
+
name: "InvalidVoteAccount",
|
|
5786
|
+
msg: "Invalid vote account"
|
|
6156
5787
|
},
|
|
6157
5788
|
{
|
|
6158
5789
|
code: 6001,
|
|
6159
|
-
name: "
|
|
6160
|
-
msg: "
|
|
5790
|
+
name: "IdentityMismatch",
|
|
5791
|
+
msg: "Identity does not match vote account"
|
|
6161
5792
|
},
|
|
6162
5793
|
{
|
|
6163
5794
|
code: 6002,
|
|
6164
|
-
name: "
|
|
6165
|
-
msg: "
|
|
5795
|
+
name: "InsufficientCollateral",
|
|
5796
|
+
msg: "Insufficient collateral amount"
|
|
6166
5797
|
},
|
|
6167
5798
|
{
|
|
6168
5799
|
code: 6003,
|
|
6169
|
-
name: "
|
|
6170
|
-
msg: "
|
|
5800
|
+
name: "TargetAprTooLow",
|
|
5801
|
+
msg: "Target APR is below minimum threshold"
|
|
6171
5802
|
},
|
|
6172
5803
|
{
|
|
6173
5804
|
code: 6004,
|
|
6174
|
-
name: "
|
|
6175
|
-
msg: "
|
|
5805
|
+
name: "MathOverflow",
|
|
5806
|
+
msg: "Math overflow"
|
|
6176
5807
|
},
|
|
6177
5808
|
{
|
|
6178
5809
|
code: 6005,
|
|
@@ -6181,53 +5812,93 @@ var jbond_default = {
|
|
|
6181
5812
|
},
|
|
6182
5813
|
{
|
|
6183
5814
|
code: 6006,
|
|
6184
|
-
name: "
|
|
6185
|
-
msg: "
|
|
5815
|
+
name: "ValidatorNotActive",
|
|
5816
|
+
msg: "Validator bond account is not active"
|
|
6186
5817
|
},
|
|
6187
5818
|
{
|
|
6188
5819
|
code: 6007,
|
|
6189
|
-
name: "
|
|
6190
|
-
msg: "
|
|
5820
|
+
name: "ValidatorAlreadyRegistered",
|
|
5821
|
+
msg: "Validator already registered"
|
|
6191
5822
|
},
|
|
6192
5823
|
{
|
|
6193
5824
|
code: 6008,
|
|
6194
|
-
name: "
|
|
6195
|
-
msg: "
|
|
5825
|
+
name: "Unauthorized",
|
|
5826
|
+
msg: "Unauthorized"
|
|
6196
5827
|
},
|
|
6197
5828
|
{
|
|
6198
5829
|
code: 6009,
|
|
6199
|
-
name: "
|
|
6200
|
-
msg: "
|
|
5830
|
+
name: "WithdrawalLockedNearEpochEnd",
|
|
5831
|
+
msg: "Withdrawals are locked near the end of the epoch."
|
|
6201
5832
|
},
|
|
6202
5833
|
{
|
|
6203
5834
|
code: 6010,
|
|
6204
|
-
name: "
|
|
6205
|
-
msg: "
|
|
5835
|
+
name: "MissingTokenAccounts",
|
|
5836
|
+
msg: "Missing token accounts for token collateral type"
|
|
6206
5837
|
},
|
|
6207
5838
|
{
|
|
6208
5839
|
code: 6011,
|
|
6209
|
-
name: "
|
|
6210
|
-
msg: "
|
|
5840
|
+
name: "MissingTokenProgram",
|
|
5841
|
+
msg: "Token program is required for token collateral type"
|
|
6211
5842
|
},
|
|
6212
5843
|
{
|
|
6213
5844
|
code: 6012,
|
|
6214
|
-
name: "
|
|
6215
|
-
msg: "
|
|
5845
|
+
name: "InvalidMint",
|
|
5846
|
+
msg: "Invalid mint for token collateral type"
|
|
6216
5847
|
},
|
|
6217
5848
|
{
|
|
6218
5849
|
code: 6013,
|
|
6219
5850
|
name: "MissingStakeAccount",
|
|
6220
|
-
msg: "
|
|
5851
|
+
msg: "Stake account is required for stake account collateral type"
|
|
6221
5852
|
},
|
|
6222
5853
|
{
|
|
6223
5854
|
code: 6014,
|
|
6224
5855
|
name: "MissingStakeProgram",
|
|
6225
|
-
msg: "
|
|
5856
|
+
msg: "Stake program is required for stake account collateral type"
|
|
6226
5857
|
},
|
|
6227
5858
|
{
|
|
6228
5859
|
code: 6015,
|
|
5860
|
+
name: "BondFinished",
|
|
5861
|
+
msg: "Bond is finished (deposits/withdrawals disabled)"
|
|
5862
|
+
},
|
|
5863
|
+
{
|
|
5864
|
+
code: 6016,
|
|
5865
|
+
name: "BondNotFinished",
|
|
5866
|
+
msg: "Bond is not finished"
|
|
5867
|
+
},
|
|
5868
|
+
{
|
|
5869
|
+
code: 6017,
|
|
6229
5870
|
name: "UnsupportedCollateralType",
|
|
6230
5871
|
msg: "Unsupported collateral type"
|
|
5872
|
+
},
|
|
5873
|
+
{
|
|
5874
|
+
code: 6018,
|
|
5875
|
+
name: "Overflow",
|
|
5876
|
+
msg: "Math operation overflowed"
|
|
5877
|
+
},
|
|
5878
|
+
{
|
|
5879
|
+
code: 6019,
|
|
5880
|
+
name: "IncorrectBondType",
|
|
5881
|
+
msg: "Incorrect bond type for this operation"
|
|
5882
|
+
},
|
|
5883
|
+
{
|
|
5884
|
+
code: 6020,
|
|
5885
|
+
name: "BondNotFinishable",
|
|
5886
|
+
msg: "This bond type can't be finished"
|
|
5887
|
+
},
|
|
5888
|
+
{
|
|
5889
|
+
code: 6021,
|
|
5890
|
+
name: "InvalidArgument",
|
|
5891
|
+
msg: "Invalid argument provided"
|
|
5892
|
+
},
|
|
5893
|
+
{
|
|
5894
|
+
code: 6022,
|
|
5895
|
+
name: "BondNotDisabled",
|
|
5896
|
+
msg: "Bond is not disabled"
|
|
5897
|
+
},
|
|
5898
|
+
{
|
|
5899
|
+
code: 6023,
|
|
5900
|
+
name: "BondNotEnabled",
|
|
5901
|
+
msg: "Bond is not enabled"
|
|
6231
5902
|
}
|
|
6232
5903
|
],
|
|
6233
5904
|
types: [
|
|
@@ -6261,26 +5932,6 @@ var jbond_default = {
|
|
|
6261
5932
|
]
|
|
6262
5933
|
}
|
|
6263
5934
|
},
|
|
6264
|
-
{
|
|
6265
|
-
name: "BondConfigured",
|
|
6266
|
-
type: {
|
|
6267
|
-
kind: "struct",
|
|
6268
|
-
fields: [
|
|
6269
|
-
{
|
|
6270
|
-
name: "bond",
|
|
6271
|
-
type: "pubkey"
|
|
6272
|
-
},
|
|
6273
|
-
{
|
|
6274
|
-
name: "authority",
|
|
6275
|
-
type: "pubkey"
|
|
6276
|
-
},
|
|
6277
|
-
{
|
|
6278
|
-
name: "timestamp",
|
|
6279
|
-
type: "i64"
|
|
6280
|
-
}
|
|
6281
|
-
]
|
|
6282
|
-
}
|
|
6283
|
-
},
|
|
6284
5935
|
{
|
|
6285
5936
|
name: "BondFinished",
|
|
6286
5937
|
type: {
|
|
@@ -6336,46 +5987,6 @@ var jbond_default = {
|
|
|
6336
5987
|
]
|
|
6337
5988
|
}
|
|
6338
5989
|
},
|
|
6339
|
-
{
|
|
6340
|
-
name: "BondInitialized",
|
|
6341
|
-
type: {
|
|
6342
|
-
kind: "struct",
|
|
6343
|
-
fields: [
|
|
6344
|
-
{
|
|
6345
|
-
name: "bond",
|
|
6346
|
-
type: "pubkey"
|
|
6347
|
-
},
|
|
6348
|
-
{
|
|
6349
|
-
name: "authority",
|
|
6350
|
-
type: "pubkey"
|
|
6351
|
-
},
|
|
6352
|
-
{
|
|
6353
|
-
name: "timestamp",
|
|
6354
|
-
type: "i64"
|
|
6355
|
-
}
|
|
6356
|
-
]
|
|
6357
|
-
}
|
|
6358
|
-
},
|
|
6359
|
-
{
|
|
6360
|
-
name: "BondRemoved",
|
|
6361
|
-
type: {
|
|
6362
|
-
kind: "struct",
|
|
6363
|
-
fields: [
|
|
6364
|
-
{
|
|
6365
|
-
name: "bond",
|
|
6366
|
-
type: "pubkey"
|
|
6367
|
-
},
|
|
6368
|
-
{
|
|
6369
|
-
name: "authority",
|
|
6370
|
-
type: "pubkey"
|
|
6371
|
-
},
|
|
6372
|
-
{
|
|
6373
|
-
name: "timestamp",
|
|
6374
|
-
type: "i64"
|
|
6375
|
-
}
|
|
6376
|
-
]
|
|
6377
|
-
}
|
|
6378
|
-
},
|
|
6379
5990
|
{
|
|
6380
5991
|
name: "BondStarted",
|
|
6381
5992
|
type: {
|
|
@@ -6529,7 +6140,7 @@ var jbond_default = {
|
|
|
6529
6140
|
}
|
|
6530
6141
|
},
|
|
6531
6142
|
{
|
|
6532
|
-
name: "
|
|
6143
|
+
name: "CollateralToppedUp",
|
|
6533
6144
|
type: {
|
|
6534
6145
|
kind: "struct",
|
|
6535
6146
|
fields: [
|
|
@@ -6599,34 +6210,6 @@ var jbond_default = {
|
|
|
6599
6210
|
]
|
|
6600
6211
|
}
|
|
6601
6212
|
},
|
|
6602
|
-
{
|
|
6603
|
-
name: "CompensationBurned",
|
|
6604
|
-
type: {
|
|
6605
|
-
kind: "struct",
|
|
6606
|
-
fields: [
|
|
6607
|
-
{
|
|
6608
|
-
name: "validator",
|
|
6609
|
-
type: "pubkey"
|
|
6610
|
-
},
|
|
6611
|
-
{
|
|
6612
|
-
name: "amount",
|
|
6613
|
-
type: "u64"
|
|
6614
|
-
},
|
|
6615
|
-
{
|
|
6616
|
-
name: "post_balance",
|
|
6617
|
-
type: "u64"
|
|
6618
|
-
},
|
|
6619
|
-
{
|
|
6620
|
-
name: "epoch",
|
|
6621
|
-
type: "u64"
|
|
6622
|
-
},
|
|
6623
|
-
{
|
|
6624
|
-
name: "timestamp",
|
|
6625
|
-
type: "i64"
|
|
6626
|
-
}
|
|
6627
|
-
]
|
|
6628
|
-
}
|
|
6629
|
-
},
|
|
6630
6213
|
{
|
|
6631
6214
|
name: "CompensationClaimed",
|
|
6632
6215
|
type: {
|
|
@@ -6655,54 +6238,6 @@ var jbond_default = {
|
|
|
6655
6238
|
]
|
|
6656
6239
|
}
|
|
6657
6240
|
},
|
|
6658
|
-
{
|
|
6659
|
-
name: "FundsLocked",
|
|
6660
|
-
type: {
|
|
6661
|
-
kind: "struct",
|
|
6662
|
-
fields: [
|
|
6663
|
-
{
|
|
6664
|
-
name: "validator",
|
|
6665
|
-
type: "pubkey"
|
|
6666
|
-
},
|
|
6667
|
-
{
|
|
6668
|
-
name: "amount",
|
|
6669
|
-
type: "u64"
|
|
6670
|
-
},
|
|
6671
|
-
{
|
|
6672
|
-
name: "total_locked",
|
|
6673
|
-
type: "u64"
|
|
6674
|
-
},
|
|
6675
|
-
{
|
|
6676
|
-
name: "epoch",
|
|
6677
|
-
type: "u64"
|
|
6678
|
-
}
|
|
6679
|
-
]
|
|
6680
|
-
}
|
|
6681
|
-
},
|
|
6682
|
-
{
|
|
6683
|
-
name: "FundsUnlocked",
|
|
6684
|
-
type: {
|
|
6685
|
-
kind: "struct",
|
|
6686
|
-
fields: [
|
|
6687
|
-
{
|
|
6688
|
-
name: "validator",
|
|
6689
|
-
type: "pubkey"
|
|
6690
|
-
},
|
|
6691
|
-
{
|
|
6692
|
-
name: "amount",
|
|
6693
|
-
type: "u64"
|
|
6694
|
-
},
|
|
6695
|
-
{
|
|
6696
|
-
name: "pending_unlock",
|
|
6697
|
-
type: "u64"
|
|
6698
|
-
},
|
|
6699
|
-
{
|
|
6700
|
-
name: "epoch",
|
|
6701
|
-
type: "u64"
|
|
6702
|
-
}
|
|
6703
|
-
]
|
|
6704
|
-
}
|
|
6705
|
-
},
|
|
6706
6241
|
{
|
|
6707
6242
|
name: "GlobalConfigureData",
|
|
6708
6243
|
type: {
|
|
@@ -6725,69 +6260,9 @@ var jbond_default = {
|
|
|
6725
6260
|
{
|
|
6726
6261
|
name: "authority",
|
|
6727
6262
|
docs: [
|
|
6728
|
-
"The authority allowed to manage the program"
|
|
6729
|
-
],
|
|
6730
|
-
type: "pubkey"
|
|
6731
|
-
},
|
|
6732
|
-
{
|
|
6733
|
-
name: "bump",
|
|
6734
|
-
docs: [
|
|
6735
|
-
"Bump for the PDA"
|
|
6736
|
-
],
|
|
6737
|
-
type: "u8"
|
|
6738
|
-
}
|
|
6739
|
-
]
|
|
6740
|
-
}
|
|
6741
|
-
},
|
|
6742
|
-
{
|
|
6743
|
-
name: "ValidatorBond",
|
|
6744
|
-
type: {
|
|
6745
|
-
kind: "struct",
|
|
6746
|
-
fields: [
|
|
6747
|
-
{
|
|
6748
|
-
name: "state",
|
|
6749
|
-
docs: [
|
|
6750
|
-
"The bond state address"
|
|
6751
|
-
],
|
|
6752
|
-
type: "pubkey"
|
|
6753
|
-
},
|
|
6754
|
-
{
|
|
6755
|
-
name: "identity",
|
|
6756
|
-
docs: [
|
|
6757
|
-
"Validator identity pubkey"
|
|
6758
|
-
],
|
|
6759
|
-
type: "pubkey"
|
|
6760
|
-
},
|
|
6761
|
-
{
|
|
6762
|
-
name: "vote_account",
|
|
6763
|
-
docs: [
|
|
6764
|
-
"Validator vote account pubkey"
|
|
6765
|
-
],
|
|
6766
|
-
type: "pubkey"
|
|
6767
|
-
},
|
|
6768
|
-
{
|
|
6769
|
-
name: "creator",
|
|
6770
|
-
docs: [
|
|
6771
|
-
"The bond creator pubkey"
|
|
6772
|
-
],
|
|
6773
|
-
type: "pubkey"
|
|
6774
|
-
},
|
|
6775
|
-
{
|
|
6776
|
-
name: "withdrawal_authority",
|
|
6777
|
-
docs: [
|
|
6778
|
-
"Optional withdrawal authority pubkey (if set, can withdraw on behalf of the validator,",
|
|
6779
|
-
"otherwise only identity can withdraw)"
|
|
6780
|
-
],
|
|
6781
|
-
type: {
|
|
6782
|
-
option: "pubkey"
|
|
6783
|
-
}
|
|
6784
|
-
},
|
|
6785
|
-
{
|
|
6786
|
-
name: "created_at",
|
|
6787
|
-
docs: [
|
|
6788
|
-
"Bond creation timestamp"
|
|
6263
|
+
"The authority allowed to manage the program"
|
|
6789
6264
|
],
|
|
6790
|
-
type: "
|
|
6265
|
+
type: "pubkey"
|
|
6791
6266
|
},
|
|
6792
6267
|
{
|
|
6793
6268
|
name: "bump",
|
|
@@ -6795,38 +6270,21 @@ var jbond_default = {
|
|
|
6795
6270
|
"Bump for the PDA"
|
|
6796
6271
|
],
|
|
6797
6272
|
type: "u8"
|
|
6798
|
-
},
|
|
6799
|
-
{
|
|
6800
|
-
name: "locked",
|
|
6801
|
-
docs: [
|
|
6802
|
-
"Amount of collateral currently locked (unavailable for withdrawal)"
|
|
6803
|
-
],
|
|
6804
|
-
type: "u64"
|
|
6805
|
-
},
|
|
6806
|
-
{
|
|
6807
|
-
name: "pending_unlock",
|
|
6808
|
-
docs: [
|
|
6809
|
-
"Pending unlock amount (will reduce `locked` next epoch)"
|
|
6810
|
-
],
|
|
6811
|
-
type: "u64"
|
|
6812
|
-
},
|
|
6813
|
-
{
|
|
6814
|
-
name: "pending_unlock_epoch",
|
|
6815
|
-
docs: [
|
|
6816
|
-
"Epoch when pending_unlock was queued"
|
|
6817
|
-
],
|
|
6818
|
-
type: "u64"
|
|
6819
6273
|
}
|
|
6820
6274
|
]
|
|
6821
6275
|
}
|
|
6822
6276
|
},
|
|
6823
6277
|
{
|
|
6824
|
-
name: "
|
|
6278
|
+
name: "ValidatorBond",
|
|
6825
6279
|
type: {
|
|
6826
6280
|
kind: "struct",
|
|
6827
6281
|
fields: [
|
|
6828
6282
|
{
|
|
6829
|
-
name: "
|
|
6283
|
+
name: "state",
|
|
6284
|
+
type: "pubkey"
|
|
6285
|
+
},
|
|
6286
|
+
{
|
|
6287
|
+
name: "identity",
|
|
6830
6288
|
type: "pubkey"
|
|
6831
6289
|
},
|
|
6832
6290
|
{
|
|
@@ -6834,16 +6292,22 @@ var jbond_default = {
|
|
|
6834
6292
|
type: "pubkey"
|
|
6835
6293
|
},
|
|
6836
6294
|
{
|
|
6837
|
-
name: "
|
|
6295
|
+
name: "creator",
|
|
6838
6296
|
type: "pubkey"
|
|
6839
6297
|
},
|
|
6840
6298
|
{
|
|
6841
|
-
name: "
|
|
6842
|
-
type:
|
|
6299
|
+
name: "withdrawal_authority",
|
|
6300
|
+
type: {
|
|
6301
|
+
option: "pubkey"
|
|
6302
|
+
}
|
|
6843
6303
|
},
|
|
6844
6304
|
{
|
|
6845
|
-
name: "
|
|
6305
|
+
name: "created_at",
|
|
6846
6306
|
type: "i64"
|
|
6307
|
+
},
|
|
6308
|
+
{
|
|
6309
|
+
name: "bump",
|
|
6310
|
+
type: "u8"
|
|
6847
6311
|
}
|
|
6848
6312
|
]
|
|
6849
6313
|
}
|
|
@@ -6854,7 +6318,7 @@ var jbond_default = {
|
|
|
6854
6318
|
kind: "struct",
|
|
6855
6319
|
fields: [
|
|
6856
6320
|
{
|
|
6857
|
-
name: "
|
|
6321
|
+
name: "identity",
|
|
6858
6322
|
type: "pubkey"
|
|
6859
6323
|
},
|
|
6860
6324
|
{
|
|
@@ -6867,30 +6331,6 @@ var jbond_default = {
|
|
|
6867
6331
|
}
|
|
6868
6332
|
]
|
|
6869
6333
|
}
|
|
6870
|
-
},
|
|
6871
|
-
{
|
|
6872
|
-
name: "WithdrawAuthorityChanged",
|
|
6873
|
-
type: {
|
|
6874
|
-
kind: "struct",
|
|
6875
|
-
fields: [
|
|
6876
|
-
{
|
|
6877
|
-
name: "validator",
|
|
6878
|
-
type: "pubkey"
|
|
6879
|
-
},
|
|
6880
|
-
{
|
|
6881
|
-
name: "old_authority",
|
|
6882
|
-
type: {
|
|
6883
|
-
option: "pubkey"
|
|
6884
|
-
}
|
|
6885
|
-
},
|
|
6886
|
-
{
|
|
6887
|
-
name: "new_authority",
|
|
6888
|
-
type: {
|
|
6889
|
-
option: "pubkey"
|
|
6890
|
-
}
|
|
6891
|
-
}
|
|
6892
|
-
]
|
|
6893
|
-
}
|
|
6894
6334
|
}
|
|
6895
6335
|
],
|
|
6896
6336
|
constants: [
|
|
@@ -6954,25 +6394,6 @@ function anchorToBondType(variant) {
|
|
|
6954
6394
|
return fromAnchor(variant);
|
|
6955
6395
|
}
|
|
6956
6396
|
|
|
6957
|
-
// src/utils/stake-pool.ts
|
|
6958
|
-
init_cjs_shims();
|
|
6959
|
-
async function getStakePoolAccountData(connection, stakePoolAddress) {
|
|
6960
|
-
const stakePoolAccount = await splStakePool.getStakePoolAccount(connection, stakePoolAddress);
|
|
6961
|
-
if (!stakePoolAccount) {
|
|
6962
|
-
throw new Error(`Stake pool account not found: ${stakePoolAddress.toBase58()}`);
|
|
6963
|
-
}
|
|
6964
|
-
return stakePoolAccount.account.data;
|
|
6965
|
-
}
|
|
6966
|
-
function lamportsToPoolTokenLamports(lamports, stakePool) {
|
|
6967
|
-
if (stakePool.totalLamports.isZero()) {
|
|
6968
|
-
throw new Error("Stake pool has zero total lamports");
|
|
6969
|
-
}
|
|
6970
|
-
if (stakePool.poolTokenSupply.isZero()) {
|
|
6971
|
-
throw new Error("Stake pool has zero pool token supply");
|
|
6972
|
-
}
|
|
6973
|
-
return lamports.mul(stakePool.poolTokenSupply).div(stakePool.totalLamports);
|
|
6974
|
-
}
|
|
6975
|
-
|
|
6976
6397
|
// src/utils/wallet.ts
|
|
6977
6398
|
init_cjs_shims();
|
|
6978
6399
|
function isVersionedTransaction(tx) {
|
|
@@ -7008,20 +6429,6 @@ var NodeWallet = class {
|
|
|
7008
6429
|
// src/utils/web3.ts
|
|
7009
6430
|
init_cjs_shims();
|
|
7010
6431
|
var SOL_DECIMALS = Math.log10(web3_js.LAMPORTS_PER_SOL);
|
|
7011
|
-
function lamportsToSol(lamports) {
|
|
7012
|
-
if (typeof lamports === "number") {
|
|
7013
|
-
return Math.abs(lamports) / web3_js.LAMPORTS_PER_SOL;
|
|
7014
|
-
}
|
|
7015
|
-
let signMultiplier = 1;
|
|
7016
|
-
if (lamports.isNeg()) {
|
|
7017
|
-
signMultiplier = -1;
|
|
7018
|
-
}
|
|
7019
|
-
const absLamports = lamports.abs();
|
|
7020
|
-
const lamportsString = absLamports.toString(10).padStart(10, "0");
|
|
7021
|
-
const splitIndex = lamportsString.length - SOL_DECIMALS;
|
|
7022
|
-
const solString = `${lamportsString.slice(0, splitIndex)}.${lamportsString.slice(splitIndex)}`;
|
|
7023
|
-
return signMultiplier * Number.parseFloat(solString);
|
|
7024
|
-
}
|
|
7025
6432
|
function solToLamports(amount) {
|
|
7026
6433
|
if (Number.isNaN(amount)) {
|
|
7027
6434
|
return new anchor.BN(0);
|
|
@@ -7042,13 +6449,20 @@ function getBondTypeSeed(type) {
|
|
|
7042
6449
|
}
|
|
7043
6450
|
|
|
7044
6451
|
// src/client.ts
|
|
6452
|
+
var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
|
|
6453
|
+
JBondClientEnv2["DEV"] = "dev";
|
|
6454
|
+
JBondClientEnv2["STAGE"] = "stage";
|
|
6455
|
+
JBondClientEnv2["PROD"] = "prod";
|
|
6456
|
+
return JBondClientEnv2;
|
|
6457
|
+
})(JBondClientEnv || {});
|
|
7045
6458
|
var JBondClient = class _JBondClient {
|
|
7046
6459
|
constructor(provider, options) {
|
|
7047
6460
|
this.provider = provider;
|
|
7048
6461
|
this.options = options ?? {};
|
|
6462
|
+
this.program = new anchor.Program(jbond_default, this.provider);
|
|
7049
6463
|
}
|
|
7050
6464
|
options;
|
|
7051
|
-
|
|
6465
|
+
program;
|
|
7052
6466
|
get history() {
|
|
7053
6467
|
return new HistoryManager(this);
|
|
7054
6468
|
}
|
|
@@ -7077,24 +6491,11 @@ var JBondClient = class _JBondClient {
|
|
|
7077
6491
|
static fromKeypair(connection, keypair, options) {
|
|
7078
6492
|
return _JBondClient.fromWallet(connection, new NodeWallet(keypair), options);
|
|
7079
6493
|
}
|
|
7080
|
-
/**
|
|
7081
|
-
* Get or create the program instance
|
|
7082
|
-
*/
|
|
7083
|
-
get program() {
|
|
7084
|
-
if (!this._program) {
|
|
7085
|
-
jbond_default.address = this.programId.toBase58();
|
|
7086
|
-
this._program = new anchor.Program(jbond_default, this.provider);
|
|
7087
|
-
}
|
|
7088
|
-
return this._program;
|
|
7089
|
-
}
|
|
7090
6494
|
/**
|
|
7091
6495
|
* Get the current program ID.
|
|
7092
6496
|
*/
|
|
7093
6497
|
get programId() {
|
|
7094
|
-
|
|
7095
|
-
return this.options.programId;
|
|
7096
|
-
}
|
|
7097
|
-
return new web3_js.PublicKey(ENV_PROGRAM_ID["prod" /* PROD */]);
|
|
6498
|
+
return this.options.programId ?? this.program.programId;
|
|
7098
6499
|
}
|
|
7099
6500
|
/**
|
|
7100
6501
|
* Get the current connection.
|
|
@@ -7106,22 +6507,13 @@ var JBondClient = class _JBondClient {
|
|
|
7106
6507
|
* Set the environment.
|
|
7107
6508
|
*/
|
|
7108
6509
|
env(env) {
|
|
7109
|
-
|
|
7110
|
-
if (!envProgramId) {
|
|
7111
|
-
throw new Error(`Invalid environment: ${env}`);
|
|
7112
|
-
}
|
|
7113
|
-
this._program = null;
|
|
7114
|
-
this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
|
|
7115
|
-
return this.configure("programId", new web3_js.PublicKey(envProgramId));
|
|
6510
|
+
return this.configure("programId", ENV_PROGRAM_ID[env]);
|
|
7116
6511
|
}
|
|
7117
6512
|
/**
|
|
7118
6513
|
* Configure a specific option.
|
|
7119
6514
|
*/
|
|
7120
6515
|
configure(key, val) {
|
|
7121
6516
|
this.options[key] = val;
|
|
7122
|
-
if (key === "programId") {
|
|
7123
|
-
this._program = null;
|
|
7124
|
-
}
|
|
7125
6517
|
return this;
|
|
7126
6518
|
}
|
|
7127
6519
|
/**
|
|
@@ -7180,8 +6572,8 @@ var JBondClient = class _JBondClient {
|
|
|
7180
6572
|
* Top up collateral
|
|
7181
6573
|
*/
|
|
7182
6574
|
async topUpCollateral(props) {
|
|
7183
|
-
const
|
|
7184
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(...
|
|
6575
|
+
const ixs = await this.getTopUpIxs(props);
|
|
6576
|
+
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(...ixs));
|
|
7185
6577
|
}
|
|
7186
6578
|
/**
|
|
7187
6579
|
* Withdraw collateral
|
|
@@ -7191,14 +6583,7 @@ var JBondClient = class _JBondClient {
|
|
|
7191
6583
|
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
7192
6584
|
}
|
|
7193
6585
|
/**
|
|
7194
|
-
*
|
|
7195
|
-
*/
|
|
7196
|
-
async migrateBond(props) {
|
|
7197
|
-
const { instructions, signers } = await this.getMigrateBondIx(props);
|
|
7198
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(...instructions), signers);
|
|
7199
|
-
}
|
|
7200
|
-
/**
|
|
7201
|
-
* Claim compensation for a validator
|
|
6586
|
+
* Claim compensation
|
|
7202
6587
|
*/
|
|
7203
6588
|
async claimCompensation(props) {
|
|
7204
6589
|
const ix = await this.getClaimIx(props);
|
|
@@ -7239,14 +6624,6 @@ var JBondClient = class _JBondClient {
|
|
|
7239
6624
|
const ix = await this.getBondSessionFinishIx(props);
|
|
7240
6625
|
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
7241
6626
|
}
|
|
7242
|
-
async bondRemove(props) {
|
|
7243
|
-
const ix = await this.getBondRemoveIx(props);
|
|
7244
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
7245
|
-
}
|
|
7246
|
-
async closeValidatorBond(props) {
|
|
7247
|
-
const ix = await this.getCloseValidatorBondIx(props);
|
|
7248
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
7249
|
-
}
|
|
7250
6627
|
/**
|
|
7251
6628
|
* Build global state initialize instruction
|
|
7252
6629
|
*/
|
|
@@ -7357,9 +6734,6 @@ var JBondClient = class _JBondClient {
|
|
|
7357
6734
|
collateralType = bondState2.collateralType;
|
|
7358
6735
|
}
|
|
7359
6736
|
const instructions = [];
|
|
7360
|
-
const signers = [];
|
|
7361
|
-
const amountLamports = solToLamports(amount);
|
|
7362
|
-
let topUpAmount = amountLamports;
|
|
7363
6737
|
try {
|
|
7364
6738
|
await this.getValidatorBond(props.bondType, props.name, props.voteAccount);
|
|
7365
6739
|
} catch {
|
|
@@ -7391,33 +6765,10 @@ var JBondClient = class _JBondClient {
|
|
|
7391
6765
|
accounts.bondTokenAccount = splToken.getAssociatedTokenAddressSync(mint, validatorBond, true);
|
|
7392
6766
|
}
|
|
7393
6767
|
});
|
|
7394
|
-
if (props.solUsage) {
|
|
7395
|
-
let usesJsolCollateral = false;
|
|
7396
|
-
matchVariant(collateralType, {
|
|
7397
|
-
token: (mint) => {
|
|
7398
|
-
usesJsolCollateral = mint.equals(JSOL_MINT);
|
|
7399
|
-
}
|
|
7400
|
-
});
|
|
7401
|
-
if (usesJsolCollateral) {
|
|
7402
|
-
const stakePool = await getStakePoolAccountData(this.connection, JPOOL_POOL_ADDRESS);
|
|
7403
|
-
const deposit = await splStakePool.depositSol(
|
|
7404
|
-
this.connection,
|
|
7405
|
-
JPOOL_POOL_ADDRESS,
|
|
7406
|
-
payer,
|
|
7407
|
-
amountLamports.toNumber(),
|
|
7408
|
-
void 0,
|
|
7409
|
-
void 0,
|
|
7410
|
-
void 0
|
|
7411
|
-
);
|
|
7412
|
-
instructions.push(...deposit.instructions);
|
|
7413
|
-
signers.push(...deposit.signers);
|
|
7414
|
-
topUpAmount = lamportsToPoolTokenLamports(amountLamports, stakePool);
|
|
7415
|
-
}
|
|
7416
|
-
}
|
|
7417
6768
|
instructions.push(
|
|
7418
|
-
await this.program.methods.bondTopUp(
|
|
6769
|
+
await this.program.methods.bondTopUp(solToLamports(amount)).accountsPartial(accounts).instruction()
|
|
7419
6770
|
);
|
|
7420
|
-
return
|
|
6771
|
+
return instructions;
|
|
7421
6772
|
}
|
|
7422
6773
|
/**
|
|
7423
6774
|
* Build withdraw collateral instruction
|
|
@@ -7456,139 +6807,6 @@ var JBondClient = class _JBondClient {
|
|
|
7456
6807
|
});
|
|
7457
6808
|
return this.program.methods.bondWithdraw(solToLamports(amount)).accountsPartial(accounts).instruction();
|
|
7458
6809
|
}
|
|
7459
|
-
/**
|
|
7460
|
-
* Build instructions for migrating SOL bond collateral into JSOL bond collateral in a single transaction
|
|
7461
|
-
*/
|
|
7462
|
-
async getMigrateBondIx(props) {
|
|
7463
|
-
const {
|
|
7464
|
-
bondType,
|
|
7465
|
-
voteAccount,
|
|
7466
|
-
identity,
|
|
7467
|
-
withdrawName = "performance",
|
|
7468
|
-
topUpName = "perf",
|
|
7469
|
-
stakePoolAddress = JPOOL_POOL_ADDRESS
|
|
7470
|
-
} = props;
|
|
7471
|
-
const payer = props.payer ?? this.provider.wallet?.publicKey;
|
|
7472
|
-
const destination = props.destination ?? payer;
|
|
7473
|
-
if (!payer || !destination) {
|
|
7474
|
-
throw new Error("Missing payer/destination");
|
|
7475
|
-
}
|
|
7476
|
-
const withdrawBondState = await this.getBondState(bondType, withdrawName);
|
|
7477
|
-
await matchVariant(withdrawBondState.collateralType, {
|
|
7478
|
-
native: () => {
|
|
7479
|
-
},
|
|
7480
|
-
token: () => {
|
|
7481
|
-
throw new Error("Withdraw bond collateral type must be native SOL for migration");
|
|
7482
|
-
}
|
|
7483
|
-
});
|
|
7484
|
-
const availableLamports = await this.getAvailableCollateral(bondType, withdrawName, voteAccount);
|
|
7485
|
-
if (!availableLamports || availableLamports <= 0) {
|
|
7486
|
-
throw new Error("No available balance to migrate");
|
|
7487
|
-
}
|
|
7488
|
-
const amount = lamportsToSol(availableLamports);
|
|
7489
|
-
const amountLamports = solToLamports(amount);
|
|
7490
|
-
const withdrawIx = await this.getWithdrawIx({
|
|
7491
|
-
bondType,
|
|
7492
|
-
name: withdrawName,
|
|
7493
|
-
amount,
|
|
7494
|
-
voteAccount,
|
|
7495
|
-
destination,
|
|
7496
|
-
withdrawalAuthority: props.withdrawalAuthority
|
|
7497
|
-
});
|
|
7498
|
-
const deposit = await this.getDepositSolIxsWithoutBalanceCheck(
|
|
7499
|
-
stakePoolAddress,
|
|
7500
|
-
payer,
|
|
7501
|
-
amountLamports.toNumber()
|
|
7502
|
-
);
|
|
7503
|
-
const topUpBondState = await this.getBondState(bondType, topUpName);
|
|
7504
|
-
const topUpCollateralType = topUpBondState.collateralType;
|
|
7505
|
-
const instructions = [withdrawIx, ...deposit.instructions];
|
|
7506
|
-
const signers = [...deposit.signers];
|
|
7507
|
-
try {
|
|
7508
|
-
await this.getValidatorBond(bondType, topUpName, voteAccount);
|
|
7509
|
-
} catch {
|
|
7510
|
-
instructions.push(
|
|
7511
|
-
await this.getRegisterValidatorIx({
|
|
7512
|
-
bondType,
|
|
7513
|
-
name: topUpName,
|
|
7514
|
-
voteAccount,
|
|
7515
|
-
identity,
|
|
7516
|
-
creator: payer,
|
|
7517
|
-
collateralType: topUpCollateralType
|
|
7518
|
-
})
|
|
7519
|
-
);
|
|
7520
|
-
}
|
|
7521
|
-
const [topUpBondStateAddress] = this.pda.bondState(bondType, topUpName);
|
|
7522
|
-
const [topUpValidatorBond] = this.pda.validatorBond(bondType, topUpName, voteAccount);
|
|
7523
|
-
await matchVariant(topUpCollateralType, {
|
|
7524
|
-
native: () => {
|
|
7525
|
-
throw new Error("Top up bond collateral type must be token for migration");
|
|
7526
|
-
},
|
|
7527
|
-
token: async (mint) => {
|
|
7528
|
-
const stakePool = await getStakePoolAccountData(this.connection, stakePoolAddress);
|
|
7529
|
-
const topUpAmount = lamportsToPoolTokenLamports(amountLamports, stakePool);
|
|
7530
|
-
const topUpIx = await this.program.methods.bondTopUp(topUpAmount).accountsPartial({
|
|
7531
|
-
bondState: topUpBondStateAddress,
|
|
7532
|
-
validatorBond: topUpValidatorBond,
|
|
7533
|
-
payer,
|
|
7534
|
-
payerTokenAccount: splToken.getAssociatedTokenAddressSync(mint, payer),
|
|
7535
|
-
bondTokenAccount: splToken.getAssociatedTokenAddressSync(mint, topUpValidatorBond, true),
|
|
7536
|
-
stakeAccount: null,
|
|
7537
|
-
stakeProgram: null
|
|
7538
|
-
}).instruction();
|
|
7539
|
-
instructions.push(topUpIx);
|
|
7540
|
-
}
|
|
7541
|
-
});
|
|
7542
|
-
return { instructions, signers };
|
|
7543
|
-
}
|
|
7544
|
-
/**
|
|
7545
|
-
* Build stake-pool SOL deposit instructions without pre-checking payer balance.
|
|
7546
|
-
* This allows composing withdraw->deposit in a single transaction where SOL is obtained by the prior instruction.
|
|
7547
|
-
*/
|
|
7548
|
-
async getDepositSolIxsWithoutBalanceCheck(stakePoolAddress, payer, lamports, destinationTokenAccount, referrerTokenAccount, depositAuthority) {
|
|
7549
|
-
const stakePool = await getStakePoolAccountData(this.connection, stakePoolAddress);
|
|
7550
|
-
const transferSigner = new web3_js.Keypair();
|
|
7551
|
-
const signers = [transferSigner];
|
|
7552
|
-
const instructions = [
|
|
7553
|
-
web3_js.SystemProgram.transfer({
|
|
7554
|
-
fromPubkey: payer,
|
|
7555
|
-
toPubkey: transferSigner.publicKey,
|
|
7556
|
-
lamports
|
|
7557
|
-
})
|
|
7558
|
-
];
|
|
7559
|
-
let destinationPoolAccount = destinationTokenAccount;
|
|
7560
|
-
if (!destinationPoolAccount) {
|
|
7561
|
-
const associatedAddress = splToken.getAssociatedTokenAddressSync(stakePool.poolMint, payer);
|
|
7562
|
-
instructions.push(
|
|
7563
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(
|
|
7564
|
-
payer,
|
|
7565
|
-
associatedAddress,
|
|
7566
|
-
payer,
|
|
7567
|
-
stakePool.poolMint
|
|
7568
|
-
)
|
|
7569
|
-
);
|
|
7570
|
-
destinationPoolAccount = associatedAddress;
|
|
7571
|
-
}
|
|
7572
|
-
const [withdrawAuthority] = web3_js.PublicKey.findProgramAddressSync(
|
|
7573
|
-
[stakePoolAddress.toBuffer(), Buffer.from("withdraw")],
|
|
7574
|
-
splStakePool.STAKE_POOL_PROGRAM_ID
|
|
7575
|
-
);
|
|
7576
|
-
instructions.push(
|
|
7577
|
-
splStakePool.StakePoolInstruction.depositSol({
|
|
7578
|
-
stakePool: stakePoolAddress,
|
|
7579
|
-
reserveStake: stakePool.reserveStake,
|
|
7580
|
-
fundingAccount: transferSigner.publicKey,
|
|
7581
|
-
destinationPoolAccount,
|
|
7582
|
-
managerFeeAccount: stakePool.managerFeeAccount,
|
|
7583
|
-
referralPoolAccount: referrerTokenAccount ?? destinationPoolAccount,
|
|
7584
|
-
poolMint: stakePool.poolMint,
|
|
7585
|
-
lamports,
|
|
7586
|
-
withdrawAuthority,
|
|
7587
|
-
depositAuthority
|
|
7588
|
-
})
|
|
7589
|
-
);
|
|
7590
|
-
return { instructions, signers };
|
|
7591
|
-
}
|
|
7592
6810
|
/**
|
|
7593
6811
|
* Build claim instruction
|
|
7594
6812
|
*/
|
|
@@ -7619,47 +6837,13 @@ var JBondClient = class _JBondClient {
|
|
|
7619
6837
|
native: () => {
|
|
7620
6838
|
},
|
|
7621
6839
|
token: (mint) => {
|
|
6840
|
+
accounts.destinationTokenAccount = splToken.getAssociatedTokenAddressSync(mint, reserve, true);
|
|
7622
6841
|
accounts.bondTokenAccount = splToken.getAssociatedTokenAddressSync(mint, validatorBond, true);
|
|
7623
|
-
|
|
7624
|
-
accounts.reserveTokenAccount = null;
|
|
7625
|
-
accounts.destinationTokenAccount = null;
|
|
7626
|
-
} else {
|
|
7627
|
-
accounts.destinationTokenAccount = splToken.getAssociatedTokenAddressSync(mint, reserve, true);
|
|
7628
|
-
accounts.reserveTokenAccount = splToken.getAssociatedTokenAddressSync(mint, reserve, true);
|
|
7629
|
-
}
|
|
6842
|
+
accounts.reserveTokenAccount = splToken.getAssociatedTokenAddressSync(mint, reserve, true);
|
|
7630
6843
|
}
|
|
7631
6844
|
});
|
|
7632
6845
|
return this.program.methods.bondClaim(solToLamports(amount)).accountsPartial(accounts).instruction();
|
|
7633
6846
|
}
|
|
7634
|
-
/**
|
|
7635
|
-
* Build claim all compensations instructions
|
|
7636
|
-
*/
|
|
7637
|
-
async getClaimAllCompensationsIxs(props) {
|
|
7638
|
-
const ixs = [];
|
|
7639
|
-
const validatorBondBalances = await this.getBondStateValidatorBondBalances(
|
|
7640
|
-
props.bondType,
|
|
7641
|
-
props.name
|
|
7642
|
-
);
|
|
7643
|
-
for (const bond_balance of validatorBondBalances) {
|
|
7644
|
-
const amountToClaim = lamportsToSol(bond_balance.balance);
|
|
7645
|
-
if (amountToClaim <= 0) {
|
|
7646
|
-
this.debug("No balance to claim for validator:", bond_balance.voteAccount.toBase58());
|
|
7647
|
-
continue;
|
|
7648
|
-
}
|
|
7649
|
-
this.debug("Amount to claim:", amountToClaim);
|
|
7650
|
-
const ix = await this.getClaimIx({
|
|
7651
|
-
bondType: props.bondType,
|
|
7652
|
-
name: props.name,
|
|
7653
|
-
amount: amountToClaim,
|
|
7654
|
-
collateralType: props.collateralType,
|
|
7655
|
-
reserve: props.reserve,
|
|
7656
|
-
authority: props.authority,
|
|
7657
|
-
voteAccount: bond_balance.voteAccount
|
|
7658
|
-
});
|
|
7659
|
-
ixs.push(ix);
|
|
7660
|
-
}
|
|
7661
|
-
return ixs;
|
|
7662
|
-
}
|
|
7663
6847
|
/**
|
|
7664
6848
|
* Build set withdraw authority instruction
|
|
7665
6849
|
*/
|
|
@@ -7688,150 +6872,23 @@ var JBondClient = class _JBondClient {
|
|
|
7688
6872
|
const authority = this.provider.wallet?.publicKey;
|
|
7689
6873
|
return this.program.methods.sessionStart(new import_bn.BN(props.duration)).accountsPartial({ bondState, authority }).instruction();
|
|
7690
6874
|
}
|
|
7691
|
-
async lockFunds(props) {
|
|
7692
|
-
const ix = await this.getLockFundsIx(props);
|
|
7693
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
7694
|
-
}
|
|
7695
|
-
async releaseFunds(props) {
|
|
7696
|
-
const ix = await this.getReleaseFundsIx(props);
|
|
7697
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
7698
|
-
}
|
|
7699
|
-
/**
|
|
7700
|
-
* Build bond remove instruction
|
|
7701
|
-
*/
|
|
7702
|
-
async getBondRemoveIx(props) {
|
|
7703
|
-
const { bondType, name } = props;
|
|
7704
|
-
const [bondState] = this.pda.bondState(bondType, name);
|
|
7705
|
-
const authority = props.authority ?? this.provider.wallet?.publicKey;
|
|
7706
|
-
return this.program.methods.bondRemove().accountsPartial({ bondState, authority }).instruction();
|
|
7707
|
-
}
|
|
7708
|
-
/**
|
|
7709
|
-
* Build close validator bond instruction
|
|
7710
|
-
*/
|
|
7711
|
-
async getCloseValidatorBondIx(props) {
|
|
7712
|
-
const { bondType, name, voteAccount } = props;
|
|
7713
|
-
const [bondState] = this.pda.bondState(bondType, name);
|
|
7714
|
-
const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
|
|
7715
|
-
const authority = props.authority ?? this.provider.wallet?.publicKey;
|
|
7716
|
-
const rentReceiver = props.rentReceiver ?? authority;
|
|
7717
|
-
if (!authority || !rentReceiver) {
|
|
7718
|
-
throw new Error("Missing authority or rentReceiver");
|
|
7719
|
-
}
|
|
7720
|
-
let collateralType = props.collateralType;
|
|
7721
|
-
if (!collateralType) {
|
|
7722
|
-
const state = await this.getBondState(bondType, name);
|
|
7723
|
-
collateralType = state.collateralType;
|
|
7724
|
-
}
|
|
7725
|
-
const accounts = {
|
|
7726
|
-
bondState,
|
|
7727
|
-
validatorBond,
|
|
7728
|
-
authority,
|
|
7729
|
-
rentReceiver,
|
|
7730
|
-
bondTokenAccount: null,
|
|
7731
|
-
destinationTokenAccount: null
|
|
7732
|
-
};
|
|
7733
|
-
matchVariant(collateralType, {
|
|
7734
|
-
native: () => {
|
|
7735
|
-
},
|
|
7736
|
-
token: (mint) => {
|
|
7737
|
-
accounts.bondTokenAccount = splToken.getAssociatedTokenAddressSync(mint, validatorBond, true);
|
|
7738
|
-
accounts.destinationTokenAccount = splToken.getAssociatedTokenAddressSync(mint, rentReceiver, true);
|
|
7739
|
-
}
|
|
7740
|
-
});
|
|
7741
|
-
return this.program.methods.closeValidatorBond().accountsPartial(accounts).instruction();
|
|
7742
|
-
}
|
|
7743
|
-
/**
|
|
7744
|
-
* Build test set last update epoch instruction
|
|
7745
|
-
* NOTE!: This instruction is for testing purposes only.
|
|
7746
|
-
* It allows direct manipulation of the validator bond's last epoch update.
|
|
7747
|
-
* This should not be used in production environments.
|
|
7748
|
-
*/
|
|
7749
|
-
// async getTestSetLastUpdateEpochIx(props: { bondType: BondType, bondName: string, voteAccount: PublicKeyInitData, payer: PublicKey, epoch: number }) {
|
|
7750
|
-
// const { bondType, bondName, voteAccount, payer, epoch } = props
|
|
7751
|
-
// const [validatorBond, _] = this.pda.validatorBond(bondType, bondName, voteAccount)
|
|
7752
|
-
// return this.program.methods
|
|
7753
|
-
// .testSetLastUpdateEpoch(new BN(epoch))
|
|
7754
|
-
// .accountsPartial({ validatorBond, payer })
|
|
7755
|
-
// .instruction()
|
|
7756
|
-
// }
|
|
7757
|
-
/**
|
|
7758
|
-
* Build lock funds instruction
|
|
7759
|
-
*/
|
|
7760
|
-
async getLockFundsIx(props) {
|
|
7761
|
-
const { bondType, name, voteAccount, amount, withdrawAuthority } = props;
|
|
7762
|
-
const [bondState] = this.pda.bondState(bondType, name);
|
|
7763
|
-
let collateralType = props.collateralType;
|
|
7764
|
-
if (!collateralType) {
|
|
7765
|
-
const bondState2 = await this.getBondState(bondType, name);
|
|
7766
|
-
collateralType = bondState2.collateralType;
|
|
7767
|
-
}
|
|
7768
|
-
const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
|
|
7769
|
-
const accounts = {
|
|
7770
|
-
bondState,
|
|
7771
|
-
validatorBond,
|
|
7772
|
-
payer: withdrawAuthority,
|
|
7773
|
-
bondTokenAccount: null
|
|
7774
|
-
};
|
|
7775
|
-
matchVariant(collateralType, {
|
|
7776
|
-
native: () => {
|
|
7777
|
-
},
|
|
7778
|
-
token: (mint) => {
|
|
7779
|
-
const bondTokenAccount = splToken.getAssociatedTokenAddressSync(mint, validatorBond, true);
|
|
7780
|
-
accounts.bondTokenAccount = bondTokenAccount;
|
|
7781
|
-
}
|
|
7782
|
-
});
|
|
7783
|
-
return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
|
|
7784
|
-
}
|
|
7785
|
-
/**
|
|
7786
|
-
* Build release funds instruction
|
|
7787
|
-
*/
|
|
7788
|
-
async getReleaseFundsIx(props) {
|
|
7789
|
-
const { bondType, name, voteAccount, amount, withdrawAuthority } = props;
|
|
7790
|
-
const [bondState] = this.pda.bondState(bondType, name);
|
|
7791
|
-
const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
|
|
7792
|
-
const accounts = {
|
|
7793
|
-
bondState,
|
|
7794
|
-
validatorBond,
|
|
7795
|
-
payer: withdrawAuthority
|
|
7796
|
-
};
|
|
7797
|
-
return this.program.methods.bondReleaseFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
|
|
7798
|
-
}
|
|
7799
|
-
/**
|
|
7800
|
-
* Get available collateral for withdrawal (taking into account locked funds)
|
|
7801
|
-
*/
|
|
7802
|
-
async getAvailableCollateral(bondType, bondName, voteAccount) {
|
|
7803
|
-
const validatorBond = await this.getValidatorBond(bondType, bondName, voteAccount);
|
|
7804
|
-
return await this.getValidatorBondBalance(bondType, bondName, voteAccount) - validatorBond.locked.toNumber();
|
|
7805
|
-
}
|
|
7806
6875
|
/**
|
|
7807
6876
|
* Get all bond states with total collected collateral
|
|
7808
6877
|
*/
|
|
7809
|
-
async getAllBondStates(bondType, sessionStatus
|
|
7810
|
-
const
|
|
7811
|
-
const targetBondType = bondTypeToAnchor(bondType);
|
|
6878
|
+
async getAllBondStates(bondType, sessionStatus) {
|
|
6879
|
+
const result = [];
|
|
7812
6880
|
const accounts = await this.program.account.bondState.all();
|
|
7813
|
-
const
|
|
7814
|
-
if (!sameVariant(account.bondType,
|
|
7815
|
-
|
|
6881
|
+
for (const { publicKey, account } of accounts) {
|
|
6882
|
+
if (!sameVariant(account.bondType, bondTypeToAnchor(bondType))) {
|
|
6883
|
+
continue;
|
|
7816
6884
|
}
|
|
7817
6885
|
if (sessionStatus !== void 0 && this.getBondStateSessionStatus(account) !== sessionStatus) {
|
|
7818
|
-
|
|
6886
|
+
continue;
|
|
7819
6887
|
}
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
if (!includeStats) {
|
|
7823
|
-
return filteredAccounts.map(({ publicKey, account }) => ({
|
|
7824
|
-
publicKey,
|
|
7825
|
-
bondState: account,
|
|
7826
|
-
stateStats: null
|
|
7827
|
-
}));
|
|
6888
|
+
const stateStats = await this.getBondStateStats(account);
|
|
6889
|
+
result.push({ publicKey, bondState: account, stateStats });
|
|
7828
6890
|
}
|
|
7829
|
-
return
|
|
7830
|
-
filteredAccounts.map(async ({ publicKey, account }) => {
|
|
7831
|
-
const stateStats = await this.getBondStateStats(account);
|
|
7832
|
-
return { publicKey, bondState: account, stateStats };
|
|
7833
|
-
})
|
|
7834
|
-
);
|
|
6891
|
+
return result;
|
|
7835
6892
|
}
|
|
7836
6893
|
/**
|
|
7837
6894
|
* Fetch global state or throw if not found
|
|
@@ -7852,28 +6909,16 @@ var JBondClient = class _JBondClient {
|
|
|
7852
6909
|
return { publicKey, ...data };
|
|
7853
6910
|
}
|
|
7854
6911
|
/**
|
|
7855
|
-
* Fetch validator bond data or
|
|
6912
|
+
* Fetch validator bond data or null if not found
|
|
7856
6913
|
*/
|
|
7857
6914
|
async getValidatorBond(bondType, bondName, vote) {
|
|
7858
6915
|
const [publicKey] = this.pda.validatorBond(bondType, bondName, new web3_js.PublicKey(vote));
|
|
7859
|
-
this.debug(`Fetching validator bond ${publicKey}...`);
|
|
7860
6916
|
const data = await this.program.account.validatorBond.fetch(publicKey);
|
|
7861
6917
|
return { publicKey, ...data };
|
|
7862
6918
|
}
|
|
7863
6919
|
/**
|
|
7864
|
-
*
|
|
7865
|
-
|
|
7866
|
-
async getValidatorBondNullable(bondType, bondName, vote) {
|
|
7867
|
-
const [publicKey] = this.pda.validatorBond(bondType, bondName, new web3_js.PublicKey(vote));
|
|
7868
|
-
this.debug(`Fetching validator bond ${publicKey}...`);
|
|
7869
|
-
const data = await this.program.account.validatorBond.fetchNullable(publicKey);
|
|
7870
|
-
if (!data) {
|
|
7871
|
-
return null;
|
|
7872
|
-
}
|
|
7873
|
-
return { publicKey, ...data };
|
|
7874
|
-
}
|
|
7875
|
-
/**
|
|
7876
|
-
* Get validator bond account balance (in SOL)
|
|
6920
|
+
* Get validator bond account balance, in the collateral's base units
|
|
6921
|
+
* (lamports for native bonds, token base units for token bonds).
|
|
7877
6922
|
*/
|
|
7878
6923
|
async getValidatorBondBalance(bondType, bondName, vote) {
|
|
7879
6924
|
const [address] = this.pda.validatorBond(bondType, bondName, new web3_js.PublicKey(vote));
|
|
@@ -7885,8 +6930,8 @@ var JBondClient = class _JBondClient {
|
|
|
7885
6930
|
if (!accountInfo) {
|
|
7886
6931
|
return 0;
|
|
7887
6932
|
}
|
|
7888
|
-
const { lamports } = accountInfo;
|
|
7889
|
-
const rentExempt = await this.
|
|
6933
|
+
const { data, lamports } = accountInfo;
|
|
6934
|
+
const rentExempt = await this.connection.getMinimumBalanceForRentExemption(data.length);
|
|
7890
6935
|
return Math.max(0, lamports - rentExempt);
|
|
7891
6936
|
},
|
|
7892
6937
|
token: async (mint) => {
|
|
@@ -7900,13 +6945,12 @@ var JBondClient = class _JBondClient {
|
|
|
7900
6945
|
}
|
|
7901
6946
|
});
|
|
7902
6947
|
}
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
}
|
|
6948
|
+
/**
|
|
6949
|
+
* Get total collected collateral for a bond state
|
|
6950
|
+
*/
|
|
6951
|
+
async getBondStateTotalCollected(bondType, bondName, votes) {
|
|
6952
|
+
const bondState = await this.getBondState(bondType, bondName);
|
|
6953
|
+
const collateralType = bondState.collateralType;
|
|
7910
6954
|
const chunk = (arr, n = 100) => {
|
|
7911
6955
|
const res = [];
|
|
7912
6956
|
for (let i = 0; i < arr.length; i += n) {
|
|
@@ -7916,79 +6960,76 @@ var JBondClient = class _JBondClient {
|
|
|
7916
6960
|
};
|
|
7917
6961
|
return await matchVariant(collateralType, {
|
|
7918
6962
|
native: async () => {
|
|
7919
|
-
const addresses =
|
|
6963
|
+
const addresses = votes.map((vote) => {
|
|
6964
|
+
const [address] = this.pda.validatorBond(bondType, bondName, new web3_js.PublicKey(vote));
|
|
6965
|
+
return address;
|
|
6966
|
+
});
|
|
7920
6967
|
const accountInfos = await this.connection.getMultipleAccountsInfo(addresses);
|
|
7921
|
-
const
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
6968
|
+
const balances = await Promise.all(
|
|
6969
|
+
accountInfos.map(async (accountInfo) => {
|
|
6970
|
+
if (!accountInfo) {
|
|
6971
|
+
return 0;
|
|
6972
|
+
}
|
|
6973
|
+
const { lamports } = accountInfo;
|
|
6974
|
+
return lamports;
|
|
6975
|
+
})
|
|
6976
|
+
);
|
|
6977
|
+
return balances.reduce((sum, v) => sum + v, 0);
|
|
7926
6978
|
},
|
|
7927
6979
|
token: async (mint) => {
|
|
7928
|
-
const
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
})
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
6980
|
+
const tokenAccounts = votes.map((vote) => {
|
|
6981
|
+
const [validatorBondAddress] = this.pda.validatorBond(bondType, bondName, new web3_js.PublicKey(vote));
|
|
6982
|
+
return splToken.getAssociatedTokenAddressSync(mint, validatorBondAddress, true);
|
|
6983
|
+
});
|
|
6984
|
+
if (tokenAccounts.length === 0) {
|
|
6985
|
+
return 0;
|
|
6986
|
+
}
|
|
6987
|
+
let total = 0n;
|
|
6988
|
+
for (const part of chunk(tokenAccounts, 100)) {
|
|
6989
|
+
const infos = await this.connection.getMultipleAccountsInfo(part).catch(() => []);
|
|
6990
|
+
for (let i = 0; i < infos.length; i++) {
|
|
7936
6991
|
const info = infos[i];
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
6992
|
+
if (!info) {
|
|
6993
|
+
continue;
|
|
6994
|
+
}
|
|
6995
|
+
if (info.data.length !== splToken.ACCOUNT_SIZE) {
|
|
7940
6996
|
continue;
|
|
7941
6997
|
}
|
|
7942
6998
|
try {
|
|
7943
6999
|
const acc = splToken.AccountLayout.decode(info.data);
|
|
7944
7000
|
const raw = BigInt(acc.amount.toString());
|
|
7945
|
-
|
|
7946
|
-
balances.push({
|
|
7947
|
-
voteAccount,
|
|
7948
|
-
balance: Number.isFinite(asNumber) ? asNumber : Number.MAX_SAFE_INTEGER
|
|
7949
|
-
});
|
|
7001
|
+
total += raw;
|
|
7950
7002
|
} catch {
|
|
7951
|
-
balances.push({ voteAccount, balance: 0 });
|
|
7952
7003
|
}
|
|
7953
7004
|
}
|
|
7954
7005
|
}
|
|
7955
|
-
|
|
7006
|
+
const asNumber = Number(total);
|
|
7007
|
+
return Number.isFinite(asNumber) ? asNumber : Number.MAX_SAFE_INTEGER;
|
|
7956
7008
|
}
|
|
7957
7009
|
});
|
|
7958
7010
|
}
|
|
7959
|
-
/**
|
|
7960
|
-
* Get total collected collateral for a bond state
|
|
7961
|
-
*/
|
|
7962
|
-
async getBondStateTotalCollected(bondType, bondName, bondState) {
|
|
7963
|
-
const allBalances = await this.getBondStateValidatorBondBalances(bondType, bondName, bondState);
|
|
7964
|
-
return allBalances.reduce((sum, vb) => sum + vb.balance, 0);
|
|
7965
|
-
}
|
|
7966
7011
|
/**
|
|
7967
7012
|
* Get bond state stats
|
|
7968
7013
|
* @param state
|
|
7014
|
+
* @private
|
|
7969
7015
|
*/
|
|
7970
7016
|
async getBondStateStats(state) {
|
|
7971
7017
|
const bondType = anchorToBondType(state.bondType);
|
|
7018
|
+
const validatorBonds = await this.getBondValidatorStates(bondType, state.name);
|
|
7972
7019
|
const totalCollected = await this.getBondStateTotalCollected(
|
|
7973
7020
|
bondType,
|
|
7974
7021
|
state.name,
|
|
7975
|
-
|
|
7022
|
+
validatorBonds.map((vb) => vb.voteAccount)
|
|
7976
7023
|
);
|
|
7977
7024
|
return {
|
|
7978
7025
|
totalCollected,
|
|
7979
7026
|
status: this.getBondStateSessionStatus(state)
|
|
7980
7027
|
};
|
|
7981
7028
|
}
|
|
7982
|
-
/**
|
|
7983
|
-
* Get validator bond rent exempt amount
|
|
7984
|
-
*/
|
|
7985
|
-
validatorBondRentExempt = async () => {
|
|
7986
|
-
return this.connection.getMinimumBalanceForRentExemption(this.program.account.validatorBond.size);
|
|
7987
|
-
};
|
|
7988
7029
|
/**
|
|
7989
7030
|
* Get all validator bonds for a given bond state
|
|
7990
7031
|
*/
|
|
7991
|
-
async
|
|
7032
|
+
async getBondValidatorStates(bondType, bondName) {
|
|
7992
7033
|
const [bondState] = this.pda.bondState(bondType, bondName);
|
|
7993
7034
|
const accounts = await this.program.account.validatorBond.all([
|
|
7994
7035
|
{
|
|
@@ -8039,12 +7080,9 @@ exports.ENV_PROGRAM_ID = ENV_PROGRAM_ID;
|
|
|
8039
7080
|
exports.GLOBAL_STATE_SEED = GLOBAL_STATE_SEED;
|
|
8040
7081
|
exports.JBondClient = JBondClient;
|
|
8041
7082
|
exports.JBondClientEnv = JBondClientEnv;
|
|
8042
|
-
exports.JPOOL_POOL_ADDRESS = JPOOL_POOL_ADDRESS;
|
|
8043
|
-
exports.JSOL_MINT = JSOL_MINT;
|
|
8044
7083
|
exports.NodeWallet = NodeWallet;
|
|
8045
7084
|
exports.STANDARD_BOND_SEED = STANDARD_BOND_SEED;
|
|
8046
7085
|
exports.SessionStatus = SessionStatus;
|
|
8047
7086
|
exports.VALIDATOR_BOND_SEED = VALIDATOR_BOND_SEED;
|
|
8048
|
-
exports.lamportsToSol = lamportsToSol;
|
|
8049
7087
|
//# sourceMappingURL=index.js.map
|
|
8050
7088
|
//# sourceMappingURL=index.js.map
|