@jpool/bond-sdk 0.11.0-next.7 → 0.11.0-next.9
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 +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7047,11 +7047,19 @@ var JBondClient = class _JBondClient {
|
|
|
7047
7047
|
const authority = this.provider.wallet?.publicKey;
|
|
7048
7048
|
return this.program.methods.sessionStart(new import_bn.BN(props.duration)).accountsPartial({ bondState, authority }).instruction();
|
|
7049
7049
|
}
|
|
7050
|
+
async lockFunds(props) {
|
|
7051
|
+
const ix = await this.getLockFundsIx(props);
|
|
7052
|
+
return this.provider.sendAndConfirm?.(new Transaction().add(ix));
|
|
7053
|
+
}
|
|
7054
|
+
async releaseFunds(props) {
|
|
7055
|
+
const ix = await this.getReleaseFundsIx(props);
|
|
7056
|
+
return this.provider.sendAndConfirm?.(new Transaction().add(ix));
|
|
7057
|
+
}
|
|
7050
7058
|
/**
|
|
7051
7059
|
* Build lock funds instruction
|
|
7052
7060
|
*/
|
|
7053
7061
|
async getLockFundsIx(props) {
|
|
7054
|
-
const { bondType, name, voteAccount, amount } = props;
|
|
7062
|
+
const { bondType, name, voteAccount, amount, withdrawAuthority } = props;
|
|
7055
7063
|
const [bondState] = this.pda.bondState(bondType, name);
|
|
7056
7064
|
let collateralType = props.collateralType;
|
|
7057
7065
|
if (!collateralType) {
|
|
@@ -7059,11 +7067,10 @@ var JBondClient = class _JBondClient {
|
|
|
7059
7067
|
collateralType = bondState2.collateralType;
|
|
7060
7068
|
}
|
|
7061
7069
|
const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
|
|
7062
|
-
const authority = this.provider.wallet?.publicKey;
|
|
7063
7070
|
const accounts = {
|
|
7064
7071
|
bondState,
|
|
7065
7072
|
validatorBond,
|
|
7066
|
-
payer:
|
|
7073
|
+
payer: withdrawAuthority,
|
|
7067
7074
|
bondTokenAccount: null
|
|
7068
7075
|
};
|
|
7069
7076
|
matchVariant(collateralType, {
|
|
@@ -7080,15 +7087,21 @@ var JBondClient = class _JBondClient {
|
|
|
7080
7087
|
* Build release funds instruction
|
|
7081
7088
|
*/
|
|
7082
7089
|
async getReleaseFundsIx(props) {
|
|
7083
|
-
const { bondType, name, voteAccount, amount } = props;
|
|
7090
|
+
const { bondType, name, voteAccount, amount, withdrawAuthority } = props;
|
|
7084
7091
|
const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
|
|
7085
|
-
const authority = this.provider.wallet?.publicKey;
|
|
7086
7092
|
const accounts = {
|
|
7087
7093
|
validatorBond,
|
|
7088
|
-
payer:
|
|
7094
|
+
payer: withdrawAuthority
|
|
7089
7095
|
};
|
|
7090
7096
|
return this.program.methods.bondReleaseFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
|
|
7091
7097
|
}
|
|
7098
|
+
/**
|
|
7099
|
+
* Get available collateral for withdrawal (taking into account locked funds)
|
|
7100
|
+
*/
|
|
7101
|
+
async getAvailableCollateral(bondType, bondName, voteAccount) {
|
|
7102
|
+
const validatorBond = await this.getValidatorBond(bondType, bondName, voteAccount);
|
|
7103
|
+
return await this.getValidatorBondBalance(bondType, bondName, voteAccount) - validatorBond.currentEpochLocked.toNumber();
|
|
7104
|
+
}
|
|
7092
7105
|
/**
|
|
7093
7106
|
* Get all bond states with total collected collateral
|
|
7094
7107
|
*/
|