@wireio/stake 2.2.1 → 2.3.0
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/README.md +185 -243
- package/lib/stake.browser.js +343 -202
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +104 -23
- package/lib/stake.js +511 -331
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +343 -202
- package/lib/stake.m.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -2
- package/src/networks/ethereum/clients/receipt.client.ts +54 -69
- package/src/networks/ethereum/clients/validator.client.ts +61 -0
- package/src/networks/ethereum/ethereum.ts +21 -1
- package/src/networks/ethereum/types.ts +21 -17
- package/src/networks/solana/clients/convert.client.ts +339 -0
- package/src/networks/solana/solana.ts +35 -6
- package/src/networks/solana/types.ts +22 -0
- package/src/networks/solana/utils.ts +8 -1
- package/src/types.ts +40 -2
- package/src/networks/solana/clients/deposit.client.ts +0 -291
package/lib/stake.js
CHANGED
|
@@ -9,213 +9,24 @@ var bs58 = require('bs58');
|
|
|
9
9
|
var ethers = require('ethers');
|
|
10
10
|
|
|
11
11
|
function _interopNamespaceDefault(e) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
}
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
22
20
|
});
|
|
23
|
-
}
|
|
24
|
-
n.default = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var multisig__namespace = /*#__PURE__*/_interopNamespaceDefault(multisig);
|
|
29
|
-
|
|
30
|
-
var __pow = Math.pow;
|
|
31
|
-
var __async$g = (__this, __arguments, generator) => {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
var fulfilled = (value) => {
|
|
34
|
-
try {
|
|
35
|
-
step(generator.next(value));
|
|
36
|
-
} catch (e) {
|
|
37
|
-
reject(e);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var rejected = (value) => {
|
|
41
|
-
try {
|
|
42
|
-
step(generator.throw(value));
|
|
43
|
-
} catch (e) {
|
|
44
|
-
reject(e);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
48
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
class DepositClient {
|
|
52
|
-
constructor(provider, pgs) {
|
|
53
|
-
this.provider = provider;
|
|
54
|
-
this.pgs = pgs;
|
|
55
|
-
this.program = pgs.getProgram("liqsolCore");
|
|
56
|
-
}
|
|
57
|
-
get connection() {
|
|
58
|
-
return this.provider.connection;
|
|
59
|
-
}
|
|
60
|
-
get wallet() {
|
|
61
|
-
return this.provider.wallet;
|
|
62
|
-
}
|
|
63
|
-
buildDepositTx(_0) {
|
|
64
|
-
return __async$g(this, arguments, function* (amount, user = this.wallet.publicKey) {
|
|
65
|
-
if (!user) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
"DepositClient.buildDepositTx: wallet not connected"
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
if (!amount || amount <= BigInt(0)) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
"DepositClient.buildDepositTx: amount must be greater than zero."
|
|
73
|
-
);
|
|
74
21
|
}
|
|
75
|
-
const depositAuthority = this.pgs.deriveDepositAuthorityPda();
|
|
76
|
-
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
77
|
-
const liqsolMintAuthority = this.pgs.deriveLiqsolMintAuthorityPda();
|
|
78
|
-
const reservePool = this.pgs.deriveReservePoolPda();
|
|
79
|
-
const vault = this.pgs.deriveVaultPda();
|
|
80
|
-
const controllerState = this.pgs.deriveStakeControllerStatePda();
|
|
81
|
-
const payoutState = this.pgs.derivePayoutStatePda();
|
|
82
|
-
const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
|
|
83
|
-
const payRateHistory = this.pgs.derivePayRateHistoryPda();
|
|
84
|
-
const globalConfig = this.pgs.deriveGlobalConfigPda();
|
|
85
|
-
const userAta = splToken.getAssociatedTokenAddressSync(
|
|
86
|
-
liqsolMint,
|
|
87
|
-
user,
|
|
88
|
-
true,
|
|
89
|
-
splToken.TOKEN_2022_PROGRAM_ID
|
|
90
|
-
);
|
|
91
|
-
const distributionState = this.pgs.deriveDistributionStatePda();
|
|
92
|
-
const userRecord = this.pgs.deriveUserRecordPda(userAta);
|
|
93
|
-
const bucketTokenAccount = splToken.getAssociatedTokenAddressSync(
|
|
94
|
-
liqsolMint,
|
|
95
|
-
bucketAuthority,
|
|
96
|
-
true,
|
|
97
|
-
splToken.TOKEN_2022_PROGRAM_ID
|
|
98
|
-
);
|
|
99
|
-
const seed = Math.floor(Math.random() * __pow(2, 32));
|
|
100
|
-
const ephemeralStake = yield this.pgs.deriveEphemeralStakeAddress(user, seed);
|
|
101
|
-
return yield this.program.methods.deposit(new anchor.BN(amount.toString()), seed).accounts({
|
|
102
|
-
user,
|
|
103
|
-
depositAuthority,
|
|
104
|
-
systemProgram: web3_js.SystemProgram.programId,
|
|
105
|
-
tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
|
|
106
|
-
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
107
|
-
liqsolProgram: this.pgs.PROGRAM_IDS.LIQSOL_TOKEN,
|
|
108
|
-
stakeProgram: web3_js.StakeProgram.programId,
|
|
109
|
-
liqsolMint,
|
|
110
|
-
userAta,
|
|
111
|
-
liqsolMintAuthority,
|
|
112
|
-
reservePool,
|
|
113
|
-
vault,
|
|
114
|
-
ephemeralStake,
|
|
115
|
-
controllerState,
|
|
116
|
-
payoutState,
|
|
117
|
-
bucketAuthority,
|
|
118
|
-
bucketTokenAccount,
|
|
119
|
-
userRecord,
|
|
120
|
-
distributionState,
|
|
121
|
-
payRateHistory,
|
|
122
|
-
instructionsSysvar: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
123
|
-
clock: web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
124
|
-
stakeHistory: web3_js.SYSVAR_STAKE_HISTORY_PUBKEY,
|
|
125
|
-
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
126
|
-
globalConfig
|
|
127
|
-
}).instruction();
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
buildWithdrawTx(_0) {
|
|
131
|
-
return __async$g(this, arguments, function* (amount, user = this.wallet.publicKey) {
|
|
132
|
-
if (!user) {
|
|
133
|
-
throw new Error(
|
|
134
|
-
"DepositClient.buildWithdrawTx: wallet not connected"
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
if (!amount || amount <= BigInt(0)) {
|
|
138
|
-
throw new Error(
|
|
139
|
-
"DepositClient.buildWithdrawTx: amount must be greater than zero."
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
143
|
-
const userAta = splToken.getAssociatedTokenAddressSync(
|
|
144
|
-
liqsolMint,
|
|
145
|
-
user,
|
|
146
|
-
true,
|
|
147
|
-
splToken.TOKEN_2022_PROGRAM_ID
|
|
148
|
-
);
|
|
149
|
-
const userRecord = this.pgs.deriveUserRecordPda(userAta);
|
|
150
|
-
const distributionState = this.pgs.deriveDistributionStatePda();
|
|
151
|
-
const global = this.pgs.deriveWithdrawGlobalPda();
|
|
152
|
-
const reservePool = this.pgs.deriveReservePoolPda();
|
|
153
|
-
const stakeAllocationState = this.pgs.deriveStakeAllocationStatePda();
|
|
154
|
-
const stakeMetrics = this.pgs.deriveStakeMetricsPda();
|
|
155
|
-
const maintenanceLedger = this.pgs.deriveMaintenanceLedgerPda();
|
|
156
|
-
const globalConfig = this.pgs.deriveGlobalConfigPda();
|
|
157
|
-
const globalAcct = yield this.program.account.global.fetch(global);
|
|
158
|
-
const rawId = globalAcct.nextReceiptId;
|
|
159
|
-
let receiptId;
|
|
160
|
-
if (typeof rawId === "bigint") {
|
|
161
|
-
receiptId = rawId;
|
|
162
|
-
} else if (rawId != null && typeof rawId === "object" && "toString" in rawId) {
|
|
163
|
-
receiptId = BigInt(rawId.toString());
|
|
164
|
-
} else if (typeof rawId === "number") {
|
|
165
|
-
receiptId = BigInt(rawId);
|
|
166
|
-
} else {
|
|
167
|
-
throw new Error(
|
|
168
|
-
`DepositClient.buildWithdrawTx: unexpected nextReceiptId type (${typeof rawId})`
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
const mintAuthority = this.pgs.deriveWithdrawMintAuthorityPda();
|
|
172
|
-
const metadata = this.pgs.deriveWithdrawMintMetadataPda();
|
|
173
|
-
const nftMint = this.pgs.deriveWithdrawNftMintPda(receiptId);
|
|
174
|
-
const receiptData = this.pgs.deriveLiqReceiptDataPda(nftMint);
|
|
175
|
-
const owner = user;
|
|
176
|
-
const nftAta = splToken.getAssociatedTokenAddressSync(
|
|
177
|
-
nftMint,
|
|
178
|
-
owner,
|
|
179
|
-
true,
|
|
180
|
-
splToken.TOKEN_2022_PROGRAM_ID
|
|
181
|
-
);
|
|
182
|
-
const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
|
|
183
|
-
const bucketTokenAccount = splToken.getAssociatedTokenAddressSync(
|
|
184
|
-
liqsolMint,
|
|
185
|
-
bucketAuthority,
|
|
186
|
-
true,
|
|
187
|
-
splToken.TOKEN_2022_PROGRAM_ID
|
|
188
|
-
);
|
|
189
|
-
return yield this.program.methods.requestWithdraw(new anchor.BN(amount.toString())).accounts({
|
|
190
|
-
user,
|
|
191
|
-
owner,
|
|
192
|
-
global,
|
|
193
|
-
liqsolMint,
|
|
194
|
-
userAta,
|
|
195
|
-
userRecord,
|
|
196
|
-
reservePool,
|
|
197
|
-
stakeAllocationState,
|
|
198
|
-
stakeMetrics,
|
|
199
|
-
maintenanceLedger,
|
|
200
|
-
clock: web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
201
|
-
mintAuthority,
|
|
202
|
-
receiptData,
|
|
203
|
-
metadata,
|
|
204
|
-
nftMint,
|
|
205
|
-
nftAta,
|
|
206
|
-
distributionState,
|
|
207
|
-
bucketTokenAccount,
|
|
208
|
-
tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
|
|
209
|
-
tokenInterface: splToken.TOKEN_2022_PROGRAM_ID,
|
|
210
|
-
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
211
|
-
systemProgram: web3_js.SystemProgram.programId,
|
|
212
|
-
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
213
|
-
globalConfig
|
|
214
|
-
}).instruction();
|
|
215
22
|
});
|
|
216
23
|
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
217
26
|
}
|
|
218
27
|
|
|
28
|
+
var multisig__namespace = /*#__PURE__*/_interopNamespaceDefault(multisig);
|
|
29
|
+
|
|
219
30
|
var address$7 = "5nBtmutQLrRKBUxNfHJPDjiW5u8id6QM9Hhjg1D1g1XH";
|
|
220
31
|
var metadata$7 = {
|
|
221
32
|
name: "liqsol_core",
|
|
@@ -14638,7 +14449,7 @@ var devnetTransferHookIDL = {
|
|
|
14638
14449
|
types: types$2
|
|
14639
14450
|
};
|
|
14640
14451
|
|
|
14641
|
-
var __async$
|
|
14452
|
+
var __async$h = (__this, __arguments, generator) => {
|
|
14642
14453
|
return new Promise((resolve, reject) => {
|
|
14643
14454
|
var fulfilled = (value) => {
|
|
14644
14455
|
try {
|
|
@@ -14716,7 +14527,7 @@ const PDA_SEEDS = {
|
|
|
14716
14527
|
LIQ_RECEIPT_DATA: "liq_receipt_data",
|
|
14717
14528
|
WITHDRAW_MINT: "mint"
|
|
14718
14529
|
};
|
|
14719
|
-
const deriveEphemeralStakeAddress = (user, seed) => __async$
|
|
14530
|
+
const deriveEphemeralStakeAddress = (user, seed) => __async$h(null, null, function* () {
|
|
14720
14531
|
const seedStr = `ephemeral_${seed}`;
|
|
14721
14532
|
return web3_js.PublicKey.createWithSeed(user, seedStr, web3_js.StakeProgram.programId);
|
|
14722
14533
|
});
|
|
@@ -14735,7 +14546,7 @@ const INDEX_SCALE$1 = BigInt(1e12);
|
|
|
14735
14546
|
const lamportsToSol = (lamports) => Number(lamports) / LAMPORTS_PER_SOL;
|
|
14736
14547
|
const solToLamports = (sol) => BigInt(Math.round(sol * LAMPORTS_PER_SOL));
|
|
14737
14548
|
|
|
14738
|
-
var __async$
|
|
14549
|
+
var __async$g = (__this, __arguments, generator) => {
|
|
14739
14550
|
return new Promise((resolve, reject) => {
|
|
14740
14551
|
var fulfilled = (value) => {
|
|
14741
14552
|
try {
|
|
@@ -14889,7 +14700,7 @@ function buildSolanaTrancheSnapshot(options) {
|
|
|
14889
14700
|
};
|
|
14890
14701
|
}
|
|
14891
14702
|
function buildOutpostAccounts(connection, user, pgs) {
|
|
14892
|
-
return __async$
|
|
14703
|
+
return __async$g(this, null, function* () {
|
|
14893
14704
|
const globalState = pgs.deriveOutpostGlobalStatePda();
|
|
14894
14705
|
const poolAuthority = pgs.deriveOutpostPoolAuthorityPda();
|
|
14895
14706
|
const liqsolMint = pgs.deriveLiqsolMintPda();
|
|
@@ -14954,7 +14765,7 @@ function buildOutpostAccounts(connection, user, pgs) {
|
|
|
14954
14765
|
});
|
|
14955
14766
|
}
|
|
14956
14767
|
function getEpochSnapshot(connection) {
|
|
14957
|
-
return __async$
|
|
14768
|
+
return __async$g(this, null, function* () {
|
|
14958
14769
|
var _a;
|
|
14959
14770
|
const info = yield connection.getEpochInfo();
|
|
14960
14771
|
let slotTimeMs = Number((_a = process.env.SLOT_TIME_MS_FALLBACK) != null ? _a : 400);
|
|
@@ -14985,7 +14796,7 @@ function msToEpochEnd(snapshot) {
|
|
|
14985
14796
|
return remainingSlots * snapshot.slotMs;
|
|
14986
14797
|
}
|
|
14987
14798
|
function scheduledInstruction(connection, config, instruction) {
|
|
14988
|
-
return __async$
|
|
14799
|
+
return __async$g(this, null, function* () {
|
|
14989
14800
|
var _a, _b;
|
|
14990
14801
|
const early = (_a = config.early) != null ? _a : 0.1;
|
|
14991
14802
|
const late = (_b = config.late) != null ? _b : 0.9;
|
|
@@ -15032,14 +14843,14 @@ function generateTestKeypair() {
|
|
|
15032
14843
|
return web3_js.Keypair.generate();
|
|
15033
14844
|
}
|
|
15034
14845
|
function airdropSol(connection, publicKey, amountSol) {
|
|
15035
|
-
return __async$
|
|
14846
|
+
return __async$g(this, null, function* () {
|
|
15036
14847
|
const lamports = solToLamports(amountSol);
|
|
15037
14848
|
const sig = yield connection.requestAirdrop(publicKey, Number(lamports));
|
|
15038
14849
|
yield connection.confirmTransaction(sig, "confirmed");
|
|
15039
14850
|
});
|
|
15040
14851
|
}
|
|
15041
14852
|
function waitForConfirmation(connection, signature) {
|
|
15042
|
-
return __async$
|
|
14853
|
+
return __async$g(this, null, function* () {
|
|
15043
14854
|
yield connection.confirmTransaction(signature, "confirmed");
|
|
15044
14855
|
});
|
|
15045
14856
|
}
|
|
@@ -15047,8 +14858,8 @@ function sleep(ms) {
|
|
|
15047
14858
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15048
14859
|
}
|
|
15049
14860
|
function waitUntilSafeToExecuteFunction(_0) {
|
|
15050
|
-
return __async$
|
|
15051
|
-
yield scheduledInstruction(connection, config, () => __async$
|
|
14861
|
+
return __async$g(this, arguments, function* (connection, config = {}) {
|
|
14862
|
+
yield scheduledInstruction(connection, config, () => __async$g(null, null, function* () {
|
|
15052
14863
|
return;
|
|
15053
14864
|
}));
|
|
15054
14865
|
});
|
|
@@ -15059,8 +14870,285 @@ function ceilDiv(n, d) {
|
|
|
15059
14870
|
}
|
|
15060
14871
|
return n.add(d.subn(1)).div(d);
|
|
15061
14872
|
}
|
|
14873
|
+
function normalizeToBigInt(x) {
|
|
14874
|
+
if (typeof x === "bigint") return x;
|
|
14875
|
+
if (x != null && typeof x === "object" && "toString" in x) return BigInt(x.toString());
|
|
14876
|
+
if (typeof x === "number") return BigInt(x);
|
|
14877
|
+
throw new Error(`normalizeToBigInt: unsupported type ${typeof x}`);
|
|
14878
|
+
}
|
|
15062
14879
|
|
|
15063
|
-
var
|
|
14880
|
+
var __pow = Math.pow;
|
|
14881
|
+
var __async$f = (__this, __arguments, generator) => {
|
|
14882
|
+
return new Promise((resolve, reject) => {
|
|
14883
|
+
var fulfilled = (value) => {
|
|
14884
|
+
try {
|
|
14885
|
+
step(generator.next(value));
|
|
14886
|
+
} catch (e) {
|
|
14887
|
+
reject(e);
|
|
14888
|
+
}
|
|
14889
|
+
};
|
|
14890
|
+
var rejected = (value) => {
|
|
14891
|
+
try {
|
|
14892
|
+
step(generator.throw(value));
|
|
14893
|
+
} catch (e) {
|
|
14894
|
+
reject(e);
|
|
14895
|
+
}
|
|
14896
|
+
};
|
|
14897
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
14898
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
14899
|
+
});
|
|
14900
|
+
};
|
|
14901
|
+
let ConvertClient$1 = class ConvertClient {
|
|
14902
|
+
constructor(provider, pgs) {
|
|
14903
|
+
this.provider = provider;
|
|
14904
|
+
this.pgs = pgs;
|
|
14905
|
+
this.program = pgs.getProgram("liqsolCore");
|
|
14906
|
+
}
|
|
14907
|
+
get connection() {
|
|
14908
|
+
return this.provider.connection;
|
|
14909
|
+
}
|
|
14910
|
+
get wallet() {
|
|
14911
|
+
return this.provider.wallet;
|
|
14912
|
+
}
|
|
14913
|
+
buildDepositTx(_0) {
|
|
14914
|
+
return __async$f(this, arguments, function* (amount, user = this.wallet.publicKey) {
|
|
14915
|
+
if (!user) throw new Error("ConvertClient.buildDepositTx: wallet not connected");
|
|
14916
|
+
if (!amount || amount <= BigInt(0))
|
|
14917
|
+
throw new Error("ConvertClient.buildDepositTx: amount must be greater than zero.");
|
|
14918
|
+
const depositAuthority = this.pgs.deriveDepositAuthorityPda();
|
|
14919
|
+
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
14920
|
+
const liqsolMintAuthority = this.pgs.deriveLiqsolMintAuthorityPda();
|
|
14921
|
+
const reservePool = this.pgs.deriveReservePoolPda();
|
|
14922
|
+
const vault = this.pgs.deriveVaultPda();
|
|
14923
|
+
const controllerState = this.pgs.deriveStakeControllerStatePda();
|
|
14924
|
+
const payoutState = this.pgs.derivePayoutStatePda();
|
|
14925
|
+
const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
|
|
14926
|
+
const payRateHistory = this.pgs.derivePayRateHistoryPda();
|
|
14927
|
+
const globalConfig = this.pgs.deriveGlobalConfigPda();
|
|
14928
|
+
const userAta = splToken.getAssociatedTokenAddressSync(liqsolMint, user, true, splToken.TOKEN_2022_PROGRAM_ID);
|
|
14929
|
+
const distributionState = this.pgs.deriveDistributionStatePda();
|
|
14930
|
+
const userRecord = this.pgs.deriveUserRecordPda(userAta);
|
|
14931
|
+
const bucketTokenAccount = splToken.getAssociatedTokenAddressSync(
|
|
14932
|
+
liqsolMint,
|
|
14933
|
+
bucketAuthority,
|
|
14934
|
+
true,
|
|
14935
|
+
splToken.TOKEN_2022_PROGRAM_ID
|
|
14936
|
+
);
|
|
14937
|
+
const seed = Math.floor(Math.random() * __pow(2, 32));
|
|
14938
|
+
const ephemeralStake = yield this.pgs.deriveEphemeralStakeAddress(user, seed);
|
|
14939
|
+
return yield this.program.methods.deposit(new anchor.BN(amount.toString()), seed).accounts({
|
|
14940
|
+
user,
|
|
14941
|
+
depositAuthority,
|
|
14942
|
+
systemProgram: web3_js.SystemProgram.programId,
|
|
14943
|
+
tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
|
|
14944
|
+
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
14945
|
+
liqsolProgram: this.pgs.PROGRAM_IDS.LIQSOL_TOKEN,
|
|
14946
|
+
stakeProgram: web3_js.StakeProgram.programId,
|
|
14947
|
+
liqsolMint,
|
|
14948
|
+
userAta,
|
|
14949
|
+
liqsolMintAuthority,
|
|
14950
|
+
reservePool,
|
|
14951
|
+
vault,
|
|
14952
|
+
ephemeralStake,
|
|
14953
|
+
controllerState,
|
|
14954
|
+
payoutState,
|
|
14955
|
+
bucketAuthority,
|
|
14956
|
+
bucketTokenAccount,
|
|
14957
|
+
userRecord,
|
|
14958
|
+
distributionState,
|
|
14959
|
+
payRateHistory,
|
|
14960
|
+
instructionsSysvar: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
14961
|
+
clock: web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
14962
|
+
stakeHistory: web3_js.SYSVAR_STAKE_HISTORY_PUBKEY,
|
|
14963
|
+
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
14964
|
+
globalConfig
|
|
14965
|
+
}).instruction();
|
|
14966
|
+
});
|
|
14967
|
+
}
|
|
14968
|
+
buildWithdrawTx(_0) {
|
|
14969
|
+
return __async$f(this, arguments, function* (amount, user = this.wallet.publicKey) {
|
|
14970
|
+
if (!user) throw new Error("ConvertClient.buildWithdrawTx: wallet not connected");
|
|
14971
|
+
if (!amount || amount <= BigInt(0))
|
|
14972
|
+
throw new Error("ConvertClient.buildWithdrawTx: amount must be greater than zero.");
|
|
14973
|
+
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
14974
|
+
const userAta = splToken.getAssociatedTokenAddressSync(liqsolMint, user, true, splToken.TOKEN_2022_PROGRAM_ID);
|
|
14975
|
+
const userRecord = this.pgs.deriveUserRecordPda(userAta);
|
|
14976
|
+
const distributionState = this.pgs.deriveDistributionStatePda();
|
|
14977
|
+
const global = this.pgs.deriveWithdrawGlobalPda();
|
|
14978
|
+
const reservePool = this.pgs.deriveReservePoolPda();
|
|
14979
|
+
const stakeAllocationState = this.pgs.deriveStakeAllocationStatePda();
|
|
14980
|
+
const stakeMetrics = this.pgs.deriveStakeMetricsPda();
|
|
14981
|
+
const maintenanceLedger = this.pgs.deriveMaintenanceLedgerPda();
|
|
14982
|
+
const globalConfig = this.pgs.deriveGlobalConfigPda();
|
|
14983
|
+
const globalAcct = yield this.program.account.global.fetch(global);
|
|
14984
|
+
const rawId = globalAcct.nextReceiptId;
|
|
14985
|
+
const receiptId = normalizeToBigInt(rawId);
|
|
14986
|
+
const mintAuthority = this.pgs.deriveWithdrawMintAuthorityPda();
|
|
14987
|
+
const metadata = this.pgs.deriveWithdrawMintMetadataPda();
|
|
14988
|
+
const nftMint = this.pgs.deriveWithdrawNftMintPda(receiptId);
|
|
14989
|
+
const receiptData = this.pgs.deriveLiqReceiptDataPda(nftMint);
|
|
14990
|
+
const owner = user;
|
|
14991
|
+
const nftAta = splToken.getAssociatedTokenAddressSync(nftMint, owner, true, splToken.TOKEN_2022_PROGRAM_ID);
|
|
14992
|
+
const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
|
|
14993
|
+
const bucketTokenAccount = splToken.getAssociatedTokenAddressSync(
|
|
14994
|
+
liqsolMint,
|
|
14995
|
+
bucketAuthority,
|
|
14996
|
+
true,
|
|
14997
|
+
splToken.TOKEN_2022_PROGRAM_ID
|
|
14998
|
+
);
|
|
14999
|
+
return yield this.program.methods.requestWithdraw(new anchor.BN(amount.toString())).accounts({
|
|
15000
|
+
user,
|
|
15001
|
+
owner,
|
|
15002
|
+
global,
|
|
15003
|
+
liqsolMint,
|
|
15004
|
+
userAta,
|
|
15005
|
+
userRecord,
|
|
15006
|
+
reservePool,
|
|
15007
|
+
stakeAllocationState,
|
|
15008
|
+
stakeMetrics,
|
|
15009
|
+
maintenanceLedger,
|
|
15010
|
+
clock: web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
15011
|
+
mintAuthority,
|
|
15012
|
+
receiptData,
|
|
15013
|
+
metadata,
|
|
15014
|
+
nftMint,
|
|
15015
|
+
nftAta,
|
|
15016
|
+
distributionState,
|
|
15017
|
+
bucketTokenAccount,
|
|
15018
|
+
tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
|
|
15019
|
+
tokenInterface: splToken.TOKEN_2022_PROGRAM_ID,
|
|
15020
|
+
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15021
|
+
systemProgram: web3_js.SystemProgram.programId,
|
|
15022
|
+
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
15023
|
+
globalConfig
|
|
15024
|
+
}).instruction();
|
|
15025
|
+
});
|
|
15026
|
+
}
|
|
15027
|
+
fetchWithdrawReceipts(owner) {
|
|
15028
|
+
return __async$f(this, null, function* () {
|
|
15029
|
+
var _a, _b, _c, _d;
|
|
15030
|
+
const globalPda = this.pgs.deriveWithdrawGlobalPda();
|
|
15031
|
+
const globalAcct = yield this.program.account.global.fetch(globalPda);
|
|
15032
|
+
const nextId = normalizeToBigInt(globalAcct.nextReceiptId);
|
|
15033
|
+
const mintToId = new Map();
|
|
15034
|
+
for (let i = BigInt(0); i < nextId; i++) {
|
|
15035
|
+
const mint = this.pgs.deriveWithdrawNftMintPda(i);
|
|
15036
|
+
mintToId.set(mint.toBase58(), i);
|
|
15037
|
+
}
|
|
15038
|
+
const tokenAccounts = yield this.connection.getParsedTokenAccountsByOwner(owner, {
|
|
15039
|
+
programId: splToken.TOKEN_2022_PROGRAM_ID
|
|
15040
|
+
});
|
|
15041
|
+
const receipts = [];
|
|
15042
|
+
for (const { pubkey, account } of tokenAccounts.value) {
|
|
15043
|
+
const info = (_b = (_a = account.data) == null ? void 0 : _a["parsed"]) == null ? void 0 : _b.info;
|
|
15044
|
+
if (!info) continue;
|
|
15045
|
+
const amount = info.tokenAmount;
|
|
15046
|
+
const decimals = Number((_c = amount == null ? void 0 : amount.decimals) != null ? _c : 0);
|
|
15047
|
+
const uiAmount = Number((_d = amount == null ? void 0 : amount.uiAmount) != null ? _d : 0);
|
|
15048
|
+
if (decimals !== 0 || uiAmount !== 1) continue;
|
|
15049
|
+
const mintStr = info.mint;
|
|
15050
|
+
if (!mintStr) continue;
|
|
15051
|
+
const receiptId = mintToId.get(mintStr);
|
|
15052
|
+
if (receiptId === void 0) continue;
|
|
15053
|
+
const mintKey = new web3_js.PublicKey(mintStr);
|
|
15054
|
+
const receiptDataPda = this.pgs.deriveLiqReceiptDataPda(mintKey);
|
|
15055
|
+
let receiptData;
|
|
15056
|
+
try {
|
|
15057
|
+
const raw = yield this.program.account.liqReceiptData.fetch(receiptDataPda);
|
|
15058
|
+
receiptData = {
|
|
15059
|
+
receiptId: normalizeToBigInt(raw.receiptId),
|
|
15060
|
+
liqports: normalizeToBigInt(raw.liqports),
|
|
15061
|
+
epoch: normalizeToBigInt(raw.epoch),
|
|
15062
|
+
fulfilled: Boolean(raw.fulfilled)
|
|
15063
|
+
};
|
|
15064
|
+
} catch (err) {
|
|
15065
|
+
console.warn(`ConvertClient: failed to fetch receipt data for mint ${mintStr}`, err);
|
|
15066
|
+
continue;
|
|
15067
|
+
}
|
|
15068
|
+
const { etaMs, readyAtMs } = yield this.estimateEpochEta(receiptData.epoch);
|
|
15069
|
+
const status = receiptData.fulfilled ? "claimed" : etaMs <= 0 ? "ready" : "queued";
|
|
15070
|
+
const amountView = {
|
|
15071
|
+
amount: receiptData.liqports,
|
|
15072
|
+
decimals: 9,
|
|
15073
|
+
symbol: "SOL"
|
|
15074
|
+
};
|
|
15075
|
+
receipts.push({
|
|
15076
|
+
tokenId: receiptData.receiptId,
|
|
15077
|
+
receipt: {
|
|
15078
|
+
amount: amountView,
|
|
15079
|
+
readyAt: readyAtMs,
|
|
15080
|
+
chain: "SOL",
|
|
15081
|
+
epoch: receiptData.epoch,
|
|
15082
|
+
status,
|
|
15083
|
+
mint: mintKey.toBase58(),
|
|
15084
|
+
ownerAta: pubkey.toBase58()
|
|
15085
|
+
}
|
|
15086
|
+
});
|
|
15087
|
+
}
|
|
15088
|
+
return receipts;
|
|
15089
|
+
});
|
|
15090
|
+
}
|
|
15091
|
+
buildClaimWithdrawTx(receiptId, user) {
|
|
15092
|
+
return __async$f(this, null, function* () {
|
|
15093
|
+
const mintAccount = this.pgs.deriveWithdrawNftMintPda(receiptId);
|
|
15094
|
+
const receiptData = this.pgs.deriveLiqReceiptDataPda(mintAccount);
|
|
15095
|
+
const ownerAta = splToken.getAssociatedTokenAddressSync(
|
|
15096
|
+
mintAccount,
|
|
15097
|
+
user,
|
|
15098
|
+
true,
|
|
15099
|
+
splToken.TOKEN_2022_PROGRAM_ID
|
|
15100
|
+
);
|
|
15101
|
+
const accounts = {
|
|
15102
|
+
user,
|
|
15103
|
+
global: this.pgs.deriveWithdrawGlobalPda(),
|
|
15104
|
+
mintAuthority: this.pgs.deriveWithdrawMintAuthorityPda(),
|
|
15105
|
+
receiptData,
|
|
15106
|
+
mintAccount,
|
|
15107
|
+
ownerAta,
|
|
15108
|
+
reservePool: this.pgs.deriveReservePoolPda(),
|
|
15109
|
+
vault: this.pgs.deriveVaultPda(),
|
|
15110
|
+
clock: web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
15111
|
+
stakeHistory: web3_js.SYSVAR_STAKE_HISTORY_PUBKEY,
|
|
15112
|
+
globalConfig: this.pgs.deriveGlobalConfigPda(),
|
|
15113
|
+
tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
|
|
15114
|
+
stakeProgram: web3_js.StakeProgram.programId,
|
|
15115
|
+
systemProgram: web3_js.SystemProgram.programId,
|
|
15116
|
+
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15117
|
+
};
|
|
15118
|
+
return this.program.methods.claimWithdraw().accounts(accounts).instruction();
|
|
15119
|
+
});
|
|
15120
|
+
}
|
|
15121
|
+
estimateEpochEta(targetEpoch) {
|
|
15122
|
+
return __async$f(this, null, function* () {
|
|
15123
|
+
const conn = this.connection;
|
|
15124
|
+
const epochInfo = yield conn.getEpochInfo();
|
|
15125
|
+
const schedule = yield conn.getEpochSchedule();
|
|
15126
|
+
const currentEpoch = BigInt(epochInfo.epoch);
|
|
15127
|
+
if (targetEpoch <= currentEpoch) {
|
|
15128
|
+
const now = Date.now();
|
|
15129
|
+
return { etaMs: 0, readyAtMs: now };
|
|
15130
|
+
}
|
|
15131
|
+
let slotTimeSec = 0.4;
|
|
15132
|
+
try {
|
|
15133
|
+
const samples = yield conn.getRecentPerformanceSamples(1);
|
|
15134
|
+
if (samples == null ? void 0 : samples.length) {
|
|
15135
|
+
const s = samples[0];
|
|
15136
|
+
slotTimeSec = s.numSlots > 0 ? s.samplePeriodSecs / s.numSlots : slotTimeSec;
|
|
15137
|
+
}
|
|
15138
|
+
} catch (_) {
|
|
15139
|
+
}
|
|
15140
|
+
const slotsPerEpoch = BigInt(schedule.slotsPerEpoch);
|
|
15141
|
+
const slotsRemainingInCurrent = slotsPerEpoch - BigInt(epochInfo.slotIndex);
|
|
15142
|
+
const epochsRemaining = targetEpoch - currentEpoch - BigInt(1);
|
|
15143
|
+
const slotsRemaining = (epochsRemaining > 0 ? epochsRemaining * slotsPerEpoch : BigInt(0)) + slotsRemainingInCurrent;
|
|
15144
|
+
const etaSeconds = Number(slotsRemaining) * slotTimeSec;
|
|
15145
|
+
const etaMs = Math.max(0, Math.round(etaSeconds * 1e3));
|
|
15146
|
+
return { etaMs, readyAtMs: Date.now() + etaMs };
|
|
15147
|
+
});
|
|
15148
|
+
}
|
|
15149
|
+
};
|
|
15150
|
+
|
|
15151
|
+
var __async$e = (__this, __arguments, generator) => {
|
|
15064
15152
|
return new Promise((resolve, reject) => {
|
|
15065
15153
|
var fulfilled = (value) => {
|
|
15066
15154
|
try {
|
|
@@ -15090,7 +15178,7 @@ class DistributionClient {
|
|
|
15090
15178
|
return this.provider.connection;
|
|
15091
15179
|
}
|
|
15092
15180
|
getDistributionState() {
|
|
15093
|
-
return __async$
|
|
15181
|
+
return __async$e(this, null, function* () {
|
|
15094
15182
|
const pda = this.pgs.deriveDistributionStatePda();
|
|
15095
15183
|
try {
|
|
15096
15184
|
return yield this.program.account.distributionState.fetch(pda);
|
|
@@ -15100,7 +15188,7 @@ class DistributionClient {
|
|
|
15100
15188
|
});
|
|
15101
15189
|
}
|
|
15102
15190
|
getPayRateHistory() {
|
|
15103
|
-
return __async$
|
|
15191
|
+
return __async$e(this, null, function* () {
|
|
15104
15192
|
const pda = this.pgs.derivePayRateHistoryPda();
|
|
15105
15193
|
try {
|
|
15106
15194
|
return yield this.program.account.payRateHistory.fetch(
|
|
@@ -15112,7 +15200,7 @@ class DistributionClient {
|
|
|
15112
15200
|
});
|
|
15113
15201
|
}
|
|
15114
15202
|
getGlobalConfig() {
|
|
15115
|
-
return __async$
|
|
15203
|
+
return __async$e(this, null, function* () {
|
|
15116
15204
|
const pda = this.pgs.deriveGlobalConfigPda();
|
|
15117
15205
|
try {
|
|
15118
15206
|
return yield this.program.account.globalConfig.fetch(
|
|
@@ -15124,7 +15212,7 @@ class DistributionClient {
|
|
|
15124
15212
|
});
|
|
15125
15213
|
}
|
|
15126
15214
|
getUserRecord(ownerOrAta) {
|
|
15127
|
-
return __async$
|
|
15215
|
+
return __async$e(this, null, function* () {
|
|
15128
15216
|
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
15129
15217
|
try {
|
|
15130
15218
|
const ata = splToken.getAssociatedTokenAddressSync(
|
|
@@ -15149,13 +15237,13 @@ class DistributionClient {
|
|
|
15149
15237
|
});
|
|
15150
15238
|
}
|
|
15151
15239
|
getUserShares(user) {
|
|
15152
|
-
return __async$
|
|
15240
|
+
return __async$e(this, null, function* () {
|
|
15153
15241
|
const record = yield this.getUserRecord(user);
|
|
15154
15242
|
return record ? record.shares : new anchor.BN(0);
|
|
15155
15243
|
});
|
|
15156
15244
|
}
|
|
15157
15245
|
getUserSharePosition(user) {
|
|
15158
|
-
return __async$
|
|
15246
|
+
return __async$e(this, null, function* () {
|
|
15159
15247
|
const [dist, userShares] = yield Promise.all([
|
|
15160
15248
|
this.getDistributionState(),
|
|
15161
15249
|
this.getUserShares(user)
|
|
@@ -15169,7 +15257,7 @@ class DistributionClient {
|
|
|
15169
15257
|
});
|
|
15170
15258
|
}
|
|
15171
15259
|
getAverageScaledPayRate(windowSize = 5) {
|
|
15172
|
-
return __async$
|
|
15260
|
+
return __async$e(this, null, function* () {
|
|
15173
15261
|
var _a, _b, _c, _d, _e;
|
|
15174
15262
|
const history = yield this.getPayRateHistory();
|
|
15175
15263
|
if (!history) {
|
|
@@ -15219,7 +15307,7 @@ class DistributionClient {
|
|
|
15219
15307
|
}
|
|
15220
15308
|
}
|
|
15221
15309
|
|
|
15222
|
-
var __async$
|
|
15310
|
+
var __async$d = (__this, __arguments, generator) => {
|
|
15223
15311
|
return new Promise((resolve, reject) => {
|
|
15224
15312
|
var fulfilled = (value) => {
|
|
15225
15313
|
try {
|
|
@@ -15246,7 +15334,7 @@ class LeaderboardClient {
|
|
|
15246
15334
|
this.program = pgs.getProgram("validatorLeaderboard");
|
|
15247
15335
|
}
|
|
15248
15336
|
getState() {
|
|
15249
|
-
return __async$
|
|
15337
|
+
return __async$d(this, null, function* () {
|
|
15250
15338
|
const pda = this.pgs.deriveLeaderboardStatePda();
|
|
15251
15339
|
try {
|
|
15252
15340
|
return yield this.program.account.leaderboardState.fetch(pda);
|
|
@@ -15256,7 +15344,7 @@ class LeaderboardClient {
|
|
|
15256
15344
|
});
|
|
15257
15345
|
}
|
|
15258
15346
|
getValidatorRecord(voteAccount) {
|
|
15259
|
-
return __async$
|
|
15347
|
+
return __async$d(this, null, function* () {
|
|
15260
15348
|
const pda = this.pgs.deriveValidatorRecordPda(voteAccount);
|
|
15261
15349
|
try {
|
|
15262
15350
|
return yield this.program.account.validatorRecord.fetchNullable(pda);
|
|
@@ -15266,7 +15354,7 @@ class LeaderboardClient {
|
|
|
15266
15354
|
});
|
|
15267
15355
|
}
|
|
15268
15356
|
getTopValidators(limit = 20) {
|
|
15269
|
-
return __async$
|
|
15357
|
+
return __async$d(this, null, function* () {
|
|
15270
15358
|
try {
|
|
15271
15359
|
const leaderboardPda = this.pgs.deriveLeaderboardStatePda();
|
|
15272
15360
|
const leaderboard = yield this.program.account.leaderboardState.fetch(leaderboardPda);
|
|
@@ -15305,7 +15393,7 @@ class LeaderboardClient {
|
|
|
15305
15393
|
}
|
|
15306
15394
|
}
|
|
15307
15395
|
|
|
15308
|
-
var __async$
|
|
15396
|
+
var __async$c = (__this, __arguments, generator) => {
|
|
15309
15397
|
return new Promise((resolve, reject) => {
|
|
15310
15398
|
var fulfilled = (value) => {
|
|
15311
15399
|
try {
|
|
@@ -15338,7 +15426,7 @@ class OutpostClient {
|
|
|
15338
15426
|
return this.provider.wallet;
|
|
15339
15427
|
}
|
|
15340
15428
|
buildAccounts(user) {
|
|
15341
|
-
return __async$
|
|
15429
|
+
return __async$c(this, null, function* () {
|
|
15342
15430
|
const userPk = user != null ? user : this.wallet.publicKey;
|
|
15343
15431
|
if (!userPk) {
|
|
15344
15432
|
throw new Error("OutpostClient.buildAccounts: wallet not connected");
|
|
@@ -15347,7 +15435,7 @@ class OutpostClient {
|
|
|
15347
15435
|
});
|
|
15348
15436
|
}
|
|
15349
15437
|
getTokenBalance(ata) {
|
|
15350
|
-
return __async$
|
|
15438
|
+
return __async$c(this, null, function* () {
|
|
15351
15439
|
try {
|
|
15352
15440
|
const bal = yield this.connection.getTokenAccountBalance(ata);
|
|
15353
15441
|
return new anchor.BN(bal.value.amount);
|
|
@@ -15357,7 +15445,7 @@ class OutpostClient {
|
|
|
15357
15445
|
});
|
|
15358
15446
|
}
|
|
15359
15447
|
fetchWireState(user) {
|
|
15360
|
-
return __async$
|
|
15448
|
+
return __async$c(this, null, function* () {
|
|
15361
15449
|
const userPk = user != null ? user : this.wallet.publicKey;
|
|
15362
15450
|
if (!userPk) {
|
|
15363
15451
|
throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
@@ -15397,7 +15485,7 @@ class OutpostClient {
|
|
|
15397
15485
|
});
|
|
15398
15486
|
}
|
|
15399
15487
|
buildStakeIx(_0) {
|
|
15400
|
-
return __async$
|
|
15488
|
+
return __async$c(this, arguments, function* (amountLamports, user = this.wallet.publicKey) {
|
|
15401
15489
|
if (!user) {
|
|
15402
15490
|
throw new Error("OutpostClient.buildStakeIx: wallet not connected");
|
|
15403
15491
|
}
|
|
@@ -15426,7 +15514,7 @@ class OutpostClient {
|
|
|
15426
15514
|
});
|
|
15427
15515
|
}
|
|
15428
15516
|
buildUnstakeIx(amountLamports, user) {
|
|
15429
|
-
return __async$
|
|
15517
|
+
return __async$c(this, null, function* () {
|
|
15430
15518
|
const userPk = user != null ? user : this.wallet.publicKey;
|
|
15431
15519
|
if (!userPk) {
|
|
15432
15520
|
throw new Error("OutpostClient.buildUnstakeIx: wallet not connected");
|
|
@@ -15489,7 +15577,7 @@ class OutpostClient {
|
|
|
15489
15577
|
}
|
|
15490
15578
|
}
|
|
15491
15579
|
|
|
15492
|
-
var __async$
|
|
15580
|
+
var __async$b = (__this, __arguments, generator) => {
|
|
15493
15581
|
return new Promise((resolve, reject) => {
|
|
15494
15582
|
var fulfilled = (value) => {
|
|
15495
15583
|
try {
|
|
@@ -15522,30 +15610,30 @@ class TokenClient {
|
|
|
15522
15610
|
return this.provider.connection;
|
|
15523
15611
|
}
|
|
15524
15612
|
getAccounts(user) {
|
|
15525
|
-
return __async$
|
|
15613
|
+
return __async$b(this, null, function* () {
|
|
15526
15614
|
return buildOutpostAccounts(this.provider.connection, user, this.pgs);
|
|
15527
15615
|
});
|
|
15528
15616
|
}
|
|
15529
15617
|
fetchGlobalState() {
|
|
15530
|
-
return __async$
|
|
15618
|
+
return __async$b(this, null, function* () {
|
|
15531
15619
|
const { globalState } = yield this.getAccounts(this.wallet.publicKey);
|
|
15532
15620
|
return this.program.account.globalState.fetch(globalState);
|
|
15533
15621
|
});
|
|
15534
15622
|
}
|
|
15535
15623
|
fetchTrancheState() {
|
|
15536
|
-
return __async$
|
|
15624
|
+
return __async$b(this, null, function* () {
|
|
15537
15625
|
const { trancheState } = yield this.getAccounts(this.wallet.publicKey);
|
|
15538
15626
|
return this.program.account.trancheState.fetch(trancheState);
|
|
15539
15627
|
});
|
|
15540
15628
|
}
|
|
15541
15629
|
fetchOutpostAccount(user) {
|
|
15542
|
-
return __async$
|
|
15630
|
+
return __async$b(this, null, function* () {
|
|
15543
15631
|
const { outpostAccount } = yield this.getAccounts(user);
|
|
15544
15632
|
return this.program.account.outpostAccount.fetchNullable(outpostAccount);
|
|
15545
15633
|
});
|
|
15546
15634
|
}
|
|
15547
15635
|
fetchUserPretokenRecord(user) {
|
|
15548
|
-
return __async$
|
|
15636
|
+
return __async$b(this, null, function* () {
|
|
15549
15637
|
const { userPretokenRecord } = yield this.getAccounts(user);
|
|
15550
15638
|
return this.program.account.userPretokenRecord.fetchNullable(
|
|
15551
15639
|
userPretokenRecord
|
|
@@ -15553,7 +15641,7 @@ class TokenClient {
|
|
|
15553
15641
|
});
|
|
15554
15642
|
}
|
|
15555
15643
|
buildPurchaseIx(_0) {
|
|
15556
|
-
return __async$
|
|
15644
|
+
return __async$b(this, arguments, function* (amountLamports, user = this.wallet.publicKey) {
|
|
15557
15645
|
var _a, _b;
|
|
15558
15646
|
console.log("build purchase for", user.toBase58());
|
|
15559
15647
|
const a = yield this.getAccounts(user);
|
|
@@ -15588,7 +15676,7 @@ class TokenClient {
|
|
|
15588
15676
|
});
|
|
15589
15677
|
}
|
|
15590
15678
|
getSolPriceUsdSafe() {
|
|
15591
|
-
return __async$
|
|
15679
|
+
return __async$b(this, null, function* () {
|
|
15592
15680
|
try {
|
|
15593
15681
|
const price = yield this.getSolPriceUsd();
|
|
15594
15682
|
return { price, timestamp: void 0 };
|
|
@@ -15598,7 +15686,7 @@ class TokenClient {
|
|
|
15598
15686
|
});
|
|
15599
15687
|
}
|
|
15600
15688
|
getSolPriceUsd() {
|
|
15601
|
-
return __async$
|
|
15689
|
+
return __async$b(this, null, function* () {
|
|
15602
15690
|
const priceHistoryPda = this.pgs.derivePriceHistoryPda();
|
|
15603
15691
|
const history = yield this.program.account.priceHistory.fetch(
|
|
15604
15692
|
priceHistoryPda
|
|
@@ -15644,7 +15732,7 @@ var __spreadValues = (a, b) => {
|
|
|
15644
15732
|
return a;
|
|
15645
15733
|
};
|
|
15646
15734
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
15647
|
-
var __async$
|
|
15735
|
+
var __async$a = (__this, __arguments, generator) => {
|
|
15648
15736
|
return new Promise((resolve, reject) => {
|
|
15649
15737
|
var fulfilled = (value) => {
|
|
15650
15738
|
try {
|
|
@@ -15922,14 +16010,14 @@ class SolanaProgramService {
|
|
|
15922
16010
|
)[0];
|
|
15923
16011
|
}
|
|
15924
16012
|
deriveEphemeralStakeAddress(user, seed) {
|
|
15925
|
-
return __async$
|
|
16013
|
+
return __async$a(this, null, function* () {
|
|
15926
16014
|
const seedStr = `ephemeral_${seed}`;
|
|
15927
16015
|
return web3_js.PublicKey.createWithSeed(user, seedStr, web3_js.StakeProgram.programId);
|
|
15928
16016
|
});
|
|
15929
16017
|
}
|
|
15930
16018
|
}
|
|
15931
16019
|
|
|
15932
|
-
var __async$
|
|
16020
|
+
var __async$9 = (__this, __arguments, generator) => {
|
|
15933
16021
|
return new Promise((resolve, reject) => {
|
|
15934
16022
|
var fulfilled = (value) => {
|
|
15935
16023
|
try {
|
|
@@ -15991,12 +16079,12 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
15991
16079
|
const anchorWallet = adapter ? {
|
|
15992
16080
|
publicKey: solWalletPubkey,
|
|
15993
16081
|
signTransaction(tx) {
|
|
15994
|
-
return __async$
|
|
16082
|
+
return __async$9(this, null, function* () {
|
|
15995
16083
|
return adapter.signTransaction(tx);
|
|
15996
16084
|
});
|
|
15997
16085
|
},
|
|
15998
16086
|
signAllTransactions(txs) {
|
|
15999
|
-
return __async$
|
|
16087
|
+
return __async$9(this, null, function* () {
|
|
16000
16088
|
if (adapter.signAllTransactions) {
|
|
16001
16089
|
return adapter.signAllTransactions(txs);
|
|
16002
16090
|
}
|
|
@@ -16008,14 +16096,14 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16008
16096
|
} : {
|
|
16009
16097
|
publicKey: solWalletPubkey,
|
|
16010
16098
|
signTransaction(_tx) {
|
|
16011
|
-
return __async$
|
|
16099
|
+
return __async$9(this, null, function* () {
|
|
16012
16100
|
throw new Error(
|
|
16013
16101
|
"Wallet not connected: signTransaction not available"
|
|
16014
16102
|
);
|
|
16015
16103
|
});
|
|
16016
16104
|
},
|
|
16017
16105
|
signAllTransactions(_txs) {
|
|
16018
|
-
return __async$
|
|
16106
|
+
return __async$9(this, null, function* () {
|
|
16019
16107
|
throw new Error(
|
|
16020
16108
|
"Wallet not connected: signAllTransactions not available"
|
|
16021
16109
|
);
|
|
@@ -16027,7 +16115,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16027
16115
|
commitment
|
|
16028
16116
|
});
|
|
16029
16117
|
this.program = new SolanaProgramService(this.anchor, config.network.chainId);
|
|
16030
|
-
this.
|
|
16118
|
+
this.convertClient = new ConvertClient$1(this.anchor, this.program);
|
|
16031
16119
|
this.distributionClient = new DistributionClient(this.anchor, this.program);
|
|
16032
16120
|
this.leaderboardClient = new LeaderboardClient(this.anchor, this.program);
|
|
16033
16121
|
this.outpostClient = new OutpostClient(this.anchor, this.program);
|
|
@@ -16051,12 +16139,12 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16051
16139
|
return config != null ? config : null;
|
|
16052
16140
|
}
|
|
16053
16141
|
deposit(amountLamports) {
|
|
16054
|
-
return __async$
|
|
16142
|
+
return __async$9(this, null, function* () {
|
|
16055
16143
|
this.ensureUser();
|
|
16056
16144
|
if (amountLamports <= BigInt(0))
|
|
16057
16145
|
throw new Error("Deposit amount must be greater than zero.");
|
|
16058
16146
|
try {
|
|
16059
|
-
const ix = yield this.
|
|
16147
|
+
const ix = yield this.convertClient.buildDepositTx(amountLamports, this.squadsVaultPDA);
|
|
16060
16148
|
return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
|
|
16061
16149
|
} catch (err) {
|
|
16062
16150
|
console.log(`Failed to deposit Solana: ${err}`);
|
|
@@ -16065,12 +16153,12 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16065
16153
|
});
|
|
16066
16154
|
}
|
|
16067
16155
|
withdraw(amountLamports) {
|
|
16068
|
-
return __async$
|
|
16156
|
+
return __async$9(this, null, function* () {
|
|
16069
16157
|
this.ensureUser();
|
|
16070
16158
|
if (amountLamports <= BigInt(0))
|
|
16071
16159
|
throw new Error("Withdraw amount must be greater than zero.");
|
|
16072
16160
|
try {
|
|
16073
|
-
const ix = yield this.
|
|
16161
|
+
const ix = yield this.convertClient.buildWithdrawTx(amountLamports, this.squadsVaultPDA);
|
|
16074
16162
|
return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
|
|
16075
16163
|
} catch (err) {
|
|
16076
16164
|
console.log(`Failed to withdraw Solana: ${err}`);
|
|
@@ -16078,8 +16166,30 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16078
16166
|
}
|
|
16079
16167
|
});
|
|
16080
16168
|
}
|
|
16169
|
+
getPendingWithdraws() {
|
|
16170
|
+
return __async$9(this, null, function* () {
|
|
16171
|
+
var _a;
|
|
16172
|
+
this.ensureUser();
|
|
16173
|
+
const owner = (_a = this.squadsVaultPDA) != null ? _a : this.anchor.wallet.publicKey;
|
|
16174
|
+
return yield this.convertClient.fetchWithdrawReceipts(owner);
|
|
16175
|
+
});
|
|
16176
|
+
}
|
|
16177
|
+
claimWithdraw(tokenId) {
|
|
16178
|
+
return __async$9(this, null, function* () {
|
|
16179
|
+
var _a;
|
|
16180
|
+
this.ensureUser();
|
|
16181
|
+
const owner = (_a = this.squadsVaultPDA) != null ? _a : this.anchor.wallet.publicKey;
|
|
16182
|
+
try {
|
|
16183
|
+
const ix = yield this.convertClient.buildClaimWithdrawTx(tokenId, owner);
|
|
16184
|
+
return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
|
|
16185
|
+
} catch (err) {
|
|
16186
|
+
console.log(`Failed to claim withdraw on Solana: ${err}`);
|
|
16187
|
+
throw err;
|
|
16188
|
+
}
|
|
16189
|
+
});
|
|
16190
|
+
}
|
|
16081
16191
|
stake(amountLamports) {
|
|
16082
|
-
return __async$
|
|
16192
|
+
return __async$9(this, null, function* () {
|
|
16083
16193
|
this.ensureUser();
|
|
16084
16194
|
if (!amountLamports || amountLamports <= BigInt(0))
|
|
16085
16195
|
throw new Error("Stake amount must be greater than zero.");
|
|
@@ -16093,7 +16203,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16093
16203
|
});
|
|
16094
16204
|
}
|
|
16095
16205
|
unstake(amountLamports) {
|
|
16096
|
-
return __async$
|
|
16206
|
+
return __async$9(this, null, function* () {
|
|
16097
16207
|
this.ensureUser();
|
|
16098
16208
|
if (!amountLamports || amountLamports <= BigInt(0))
|
|
16099
16209
|
throw new Error("Unstake amount must be greater than zero.");
|
|
@@ -16107,7 +16217,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16107
16217
|
});
|
|
16108
16218
|
}
|
|
16109
16219
|
buy(amountLamports) {
|
|
16110
|
-
return __async$
|
|
16220
|
+
return __async$9(this, null, function* () {
|
|
16111
16221
|
this.ensureUser();
|
|
16112
16222
|
if (!amountLamports || amountLamports <= BigInt(0))
|
|
16113
16223
|
throw new Error("liqSOL pretoken purchase requires a positive amount.");
|
|
@@ -16121,7 +16231,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16121
16231
|
});
|
|
16122
16232
|
}
|
|
16123
16233
|
getPortfolio() {
|
|
16124
|
-
return __async$
|
|
16234
|
+
return __async$9(this, null, function* () {
|
|
16125
16235
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
16126
16236
|
try {
|
|
16127
16237
|
const user = !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
|
|
@@ -16211,7 +16321,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16211
16321
|
});
|
|
16212
16322
|
}
|
|
16213
16323
|
getUserRecord() {
|
|
16214
|
-
return __async$
|
|
16324
|
+
return __async$9(this, null, function* () {
|
|
16215
16325
|
if (!this.pubKey) throw new Error("User pubKey is undefined");
|
|
16216
16326
|
return this.distributionClient.getUserRecord(this.solPubKey);
|
|
16217
16327
|
});
|
|
@@ -16229,7 +16339,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16229
16339
|
return pda[0];
|
|
16230
16340
|
}
|
|
16231
16341
|
sendSquadsIxs(ix) {
|
|
16232
|
-
return __async$
|
|
16342
|
+
return __async$9(this, null, function* () {
|
|
16233
16343
|
var _a, _b, _c, _d;
|
|
16234
16344
|
if (!this.squadsX) throw new Error("Attempting to wrap Squads instruction without SquadsX config");
|
|
16235
16345
|
const multisigPda = this.squadsMultisigPDA;
|
|
@@ -16273,7 +16383,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16273
16383
|
});
|
|
16274
16384
|
}
|
|
16275
16385
|
buildAndSendIx(ix) {
|
|
16276
|
-
return __async$
|
|
16386
|
+
return __async$9(this, null, function* () {
|
|
16277
16387
|
const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
|
|
16278
16388
|
const ixs = Array.isArray(ix) ? ix : [ix];
|
|
16279
16389
|
const tx = new web3_js.Transaction().add(cuIx, ...ixs);
|
|
@@ -16283,7 +16393,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16283
16393
|
});
|
|
16284
16394
|
}
|
|
16285
16395
|
sendAndConfirmHttp(signed, _ctx) {
|
|
16286
|
-
return __async$
|
|
16396
|
+
return __async$9(this, null, function* () {
|
|
16287
16397
|
var _a, _b, _c;
|
|
16288
16398
|
this.ensureUser();
|
|
16289
16399
|
const rawTx = signed.serialize();
|
|
@@ -16313,19 +16423,19 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16313
16423
|
});
|
|
16314
16424
|
}
|
|
16315
16425
|
signTransaction(tx) {
|
|
16316
|
-
return __async$
|
|
16426
|
+
return __async$9(this, null, function* () {
|
|
16317
16427
|
this.ensureUser();
|
|
16318
16428
|
return this.anchor.wallet.signTransaction(tx);
|
|
16319
16429
|
});
|
|
16320
16430
|
}
|
|
16321
16431
|
sendTransaction(signed) {
|
|
16322
|
-
return __async$
|
|
16432
|
+
return __async$9(this, null, function* () {
|
|
16323
16433
|
this.ensureUser();
|
|
16324
16434
|
return this.anchor.sendAndConfirm(signed);
|
|
16325
16435
|
});
|
|
16326
16436
|
}
|
|
16327
16437
|
prepareTx(tx) {
|
|
16328
|
-
return __async$
|
|
16438
|
+
return __async$9(this, null, function* () {
|
|
16329
16439
|
const { blockhash, lastValidBlockHeight } = yield this.connection.getLatestBlockhash("confirmed");
|
|
16330
16440
|
tx.recentBlockhash = blockhash;
|
|
16331
16441
|
tx.feePayer = this.feePayer;
|
|
@@ -16343,7 +16453,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16343
16453
|
}
|
|
16344
16454
|
}
|
|
16345
16455
|
getTrancheSnapshot(chainID) {
|
|
16346
|
-
return __async$
|
|
16456
|
+
return __async$9(this, null, function* () {
|
|
16347
16457
|
try {
|
|
16348
16458
|
const [globalState, trancheState] = yield Promise.all([
|
|
16349
16459
|
this.tokenClient.fetchGlobalState(),
|
|
@@ -16364,7 +16474,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16364
16474
|
});
|
|
16365
16475
|
}
|
|
16366
16476
|
getSystemAPY() {
|
|
16367
|
-
return __async$
|
|
16477
|
+
return __async$9(this, null, function* () {
|
|
16368
16478
|
try {
|
|
16369
16479
|
const ratePerEpoch = yield this.getEpochRateDecimalFromProgram();
|
|
16370
16480
|
const epochsPerYear = yield this.getEpochsPerYearFromCluster();
|
|
@@ -16378,7 +16488,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16378
16488
|
});
|
|
16379
16489
|
}
|
|
16380
16490
|
getEpochRateDecimalFromProgram() {
|
|
16381
|
-
return __async$
|
|
16491
|
+
return __async$9(this, null, function* () {
|
|
16382
16492
|
const liqSolCoreProgram = this.program.getProgram("liqsolCore");
|
|
16383
16493
|
const payRateHistoryPda = this.program.derivePayRateHistoryPda();
|
|
16384
16494
|
const payRateHistory = yield liqSolCoreProgram.account.payRateHistory.fetch(payRateHistoryPda);
|
|
@@ -16409,7 +16519,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16409
16519
|
});
|
|
16410
16520
|
}
|
|
16411
16521
|
getEpochsPerYearFromCluster() {
|
|
16412
|
-
return __async$
|
|
16522
|
+
return __async$9(this, null, function* () {
|
|
16413
16523
|
const now = Date.now();
|
|
16414
16524
|
if (this.epochsPerYearCache && now - this.epochsPerYearCache.fetchedAt < _SolanaStakingClient.EPOCHS_PER_YEAR_TTL_MS) {
|
|
16415
16525
|
return this.epochsPerYearCache.value;
|
|
@@ -16442,7 +16552,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16442
16552
|
});
|
|
16443
16553
|
}
|
|
16444
16554
|
getDepositFee(amountLamports, windowSize = 5) {
|
|
16445
|
-
return __async$
|
|
16555
|
+
return __async$9(this, null, function* () {
|
|
16446
16556
|
var _a, _b, _c;
|
|
16447
16557
|
if (amountLamports <= BigInt(0)) {
|
|
16448
16558
|
return BigInt(0);
|
|
@@ -16470,7 +16580,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16470
16580
|
});
|
|
16471
16581
|
}
|
|
16472
16582
|
getDepositBuffer(options) {
|
|
16473
|
-
return __async$
|
|
16583
|
+
return __async$9(this, null, function* () {
|
|
16474
16584
|
var _a, _b, _c, _d;
|
|
16475
16585
|
this.ensureUser();
|
|
16476
16586
|
const balanceLamports = (_a = options == null ? void 0 : options.balanceOverrideLamports) != null ? _a : BigInt(yield this.connection.getBalance(this.feePayer, commitment));
|
|
@@ -16526,7 +16636,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
16526
16636
|
});
|
|
16527
16637
|
}
|
|
16528
16638
|
getSingleTxFeeLamports() {
|
|
16529
|
-
return __async$
|
|
16639
|
+
return __async$9(this, null, function* () {
|
|
16530
16640
|
var _a;
|
|
16531
16641
|
const now = Date.now();
|
|
16532
16642
|
if (this.cachedTxFee && now - this.cachedTxFee.fetchedAt < _SolanaStakingClient.FEE_CACHE_TTL_MS) {
|
|
@@ -40568,7 +40678,7 @@ var ERC1155Artifact = {
|
|
|
40568
40678
|
deployedLinkReferences: deployedLinkReferences
|
|
40569
40679
|
};
|
|
40570
40680
|
|
|
40571
|
-
var __async$
|
|
40681
|
+
var __async$8 = (__this, __arguments, generator) => {
|
|
40572
40682
|
return new Promise((resolve, reject) => {
|
|
40573
40683
|
var fulfilled = (value) => {
|
|
40574
40684
|
try {
|
|
@@ -40788,7 +40898,7 @@ class EthereumContractService {
|
|
|
40788
40898
|
return new ethers.Contract(address, abi, this.signer);
|
|
40789
40899
|
}
|
|
40790
40900
|
getNetwork() {
|
|
40791
|
-
return __async$
|
|
40901
|
+
return __async$8(this, null, function* () {
|
|
40792
40902
|
var _a;
|
|
40793
40903
|
return (_a = this.provider) == null ? void 0 : _a.getNetwork();
|
|
40794
40904
|
});
|
|
@@ -40844,7 +40954,7 @@ class EthereumContractService {
|
|
|
40844
40954
|
}
|
|
40845
40955
|
}
|
|
40846
40956
|
|
|
40847
|
-
var __async$
|
|
40957
|
+
var __async$7 = (__this, __arguments, generator) => {
|
|
40848
40958
|
return new Promise((resolve, reject) => {
|
|
40849
40959
|
var fulfilled = (value) => {
|
|
40850
40960
|
try {
|
|
@@ -40888,7 +40998,7 @@ function formatContractErrors(err) {
|
|
|
40888
40998
|
}
|
|
40889
40999
|
}
|
|
40890
41000
|
function sendOPPFinalize(opp, gasLimit) {
|
|
40891
|
-
return __async$
|
|
41001
|
+
return __async$7(this, null, function* () {
|
|
40892
41002
|
var _a;
|
|
40893
41003
|
const overrides = {};
|
|
40894
41004
|
try {
|
|
@@ -41016,7 +41126,7 @@ function buildEthereumTrancheLadder(options) {
|
|
|
41016
41126
|
return ladder;
|
|
41017
41127
|
}
|
|
41018
41128
|
function buildEthereumTrancheSnapshot(options) {
|
|
41019
|
-
return __async$
|
|
41129
|
+
return __async$7(this, null, function* () {
|
|
41020
41130
|
const {
|
|
41021
41131
|
chainID,
|
|
41022
41132
|
ethPriceUsd,
|
|
@@ -41076,7 +41186,7 @@ function buildEthereumTrancheSnapshot(options) {
|
|
|
41076
41186
|
});
|
|
41077
41187
|
}
|
|
41078
41188
|
|
|
41079
|
-
var __async$
|
|
41189
|
+
var __async$6 = (__this, __arguments, generator) => {
|
|
41080
41190
|
return new Promise((resolve, reject) => {
|
|
41081
41191
|
var fulfilled = (value) => {
|
|
41082
41192
|
try {
|
|
@@ -41104,7 +41214,7 @@ class ConvertClient {
|
|
|
41104
41214
|
this.contractService = contract;
|
|
41105
41215
|
}
|
|
41106
41216
|
simulateDeposit(amount) {
|
|
41107
|
-
return __async$
|
|
41217
|
+
return __async$6(this, null, function* () {
|
|
41108
41218
|
const amountWei = ethers.BigNumber.isBigNumber(amount) ? amount : ethers.BigNumber.from(amount);
|
|
41109
41219
|
yield this.contract.DepositManager.callStatic.deposit({
|
|
41110
41220
|
value: amountWei
|
|
@@ -41112,7 +41222,7 @@ class ConvertClient {
|
|
|
41112
41222
|
});
|
|
41113
41223
|
}
|
|
41114
41224
|
performDeposit(amountWei) {
|
|
41115
|
-
return __async$
|
|
41225
|
+
return __async$6(this, null, function* () {
|
|
41116
41226
|
var _a, _b;
|
|
41117
41227
|
const minDeposit = yield this.contract.DepositManager.minDeposit();
|
|
41118
41228
|
if (amountWei.lt(minDeposit)) {
|
|
@@ -41148,7 +41258,7 @@ class ConvertClient {
|
|
|
41148
41258
|
});
|
|
41149
41259
|
}
|
|
41150
41260
|
performWithdraw(signerAddress, amountWei) {
|
|
41151
|
-
return __async$
|
|
41261
|
+
return __async$6(this, null, function* () {
|
|
41152
41262
|
var _a, _b;
|
|
41153
41263
|
let tx, receipt;
|
|
41154
41264
|
try {
|
|
@@ -41176,7 +41286,7 @@ class ConvertClient {
|
|
|
41176
41286
|
});
|
|
41177
41287
|
}
|
|
41178
41288
|
claimWithdraw(tokenId) {
|
|
41179
|
-
return __async$
|
|
41289
|
+
return __async$6(this, null, function* () {
|
|
41180
41290
|
var _a, _b;
|
|
41181
41291
|
let tx, receipt;
|
|
41182
41292
|
try {
|
|
@@ -41204,7 +41314,7 @@ class ConvertClient {
|
|
|
41204
41314
|
}
|
|
41205
41315
|
}
|
|
41206
41316
|
|
|
41207
|
-
var __async$
|
|
41317
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
41208
41318
|
return new Promise((resolve, reject) => {
|
|
41209
41319
|
var fulfilled = (value) => {
|
|
41210
41320
|
try {
|
|
@@ -41232,7 +41342,7 @@ class StakeClient {
|
|
|
41232
41342
|
this.contractService = contract;
|
|
41233
41343
|
}
|
|
41234
41344
|
simulateStake(amountWei) {
|
|
41235
|
-
return __async$
|
|
41345
|
+
return __async$5(this, null, function* () {
|
|
41236
41346
|
var _a;
|
|
41237
41347
|
try {
|
|
41238
41348
|
yield this.contract.Depositor.callStatic.stakeLiqETH(amountWei);
|
|
@@ -41243,7 +41353,7 @@ class StakeClient {
|
|
|
41243
41353
|
});
|
|
41244
41354
|
}
|
|
41245
41355
|
performStake(amountWei, signerAddress) {
|
|
41246
|
-
return __async$
|
|
41356
|
+
return __async$5(this, null, function* () {
|
|
41247
41357
|
var _a;
|
|
41248
41358
|
const depositor = this.contract.Depositor.address;
|
|
41249
41359
|
const liqRead = this.contract.LiqEthToken;
|
|
@@ -41286,7 +41396,7 @@ class StakeClient {
|
|
|
41286
41396
|
});
|
|
41287
41397
|
}
|
|
41288
41398
|
performWithdrawStake(tokenId, recipient) {
|
|
41289
|
-
return __async$
|
|
41399
|
+
return __async$5(this, null, function* () {
|
|
41290
41400
|
var _a;
|
|
41291
41401
|
const tx = yield this.contract.Depositor.withdrawStake(tokenId, recipient);
|
|
41292
41402
|
const receipt = yield tx.wait(1);
|
|
@@ -41309,7 +41419,7 @@ class StakeClient {
|
|
|
41309
41419
|
}
|
|
41310
41420
|
}
|
|
41311
41421
|
|
|
41312
|
-
var __async$
|
|
41422
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
41313
41423
|
return new Promise((resolve, reject) => {
|
|
41314
41424
|
var fulfilled = (value) => {
|
|
41315
41425
|
try {
|
|
@@ -41337,7 +41447,7 @@ class PretokenClient {
|
|
|
41337
41447
|
this.contractService = contract;
|
|
41338
41448
|
}
|
|
41339
41449
|
purchasePretokensWithLiqETH(amountLiq, buyer) {
|
|
41340
|
-
return __async$
|
|
41450
|
+
return __async$4(this, null, function* () {
|
|
41341
41451
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
41342
41452
|
const bal = yield this.contract.LiqEthToken.balanceOf(buyer);
|
|
41343
41453
|
const paused = yield this.contract.Depositor.paused();
|
|
@@ -41406,7 +41516,7 @@ class PretokenClient {
|
|
|
41406
41516
|
}
|
|
41407
41517
|
}
|
|
41408
41518
|
|
|
41409
|
-
var __async$
|
|
41519
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
41410
41520
|
return new Promise((resolve, reject) => {
|
|
41411
41521
|
var fulfilled = (value) => {
|
|
41412
41522
|
try {
|
|
@@ -41443,7 +41553,7 @@ class OPPClient {
|
|
|
41443
41553
|
return this.contractService.contract;
|
|
41444
41554
|
}
|
|
41445
41555
|
getStatus() {
|
|
41446
|
-
return __async$
|
|
41556
|
+
return __async$3(this, null, function* () {
|
|
41447
41557
|
const depositor = this.contract.Depositor;
|
|
41448
41558
|
const opp = this.contract.OPP;
|
|
41449
41559
|
const oppAddress = yield depositor.oppAddress();
|
|
@@ -41484,7 +41594,7 @@ class OPPClient {
|
|
|
41484
41594
|
});
|
|
41485
41595
|
}
|
|
41486
41596
|
getMessages(address) {
|
|
41487
|
-
return __async$
|
|
41597
|
+
return __async$3(this, null, function* () {
|
|
41488
41598
|
try {
|
|
41489
41599
|
const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
|
|
41490
41600
|
const events = yield this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
|
|
@@ -41504,7 +41614,7 @@ class OPPClient {
|
|
|
41504
41614
|
});
|
|
41505
41615
|
}
|
|
41506
41616
|
extractAssertionsFromEvent(event) {
|
|
41507
|
-
return __async$
|
|
41617
|
+
return __async$3(this, null, function* () {
|
|
41508
41618
|
var _a, _b;
|
|
41509
41619
|
const header = event.args.header;
|
|
41510
41620
|
const payloadAssertions = event.args.payload.assertions;
|
|
@@ -41739,7 +41849,7 @@ var ReceiptNFTKind = ((ReceiptNFTKind2) => {
|
|
|
41739
41849
|
return ReceiptNFTKind2;
|
|
41740
41850
|
})(ReceiptNFTKind || {});
|
|
41741
41851
|
|
|
41742
|
-
var __async$
|
|
41852
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
41743
41853
|
return new Promise((resolve, reject) => {
|
|
41744
41854
|
var fulfilled = (value) => {
|
|
41745
41855
|
try {
|
|
@@ -41767,12 +41877,12 @@ class ReceiptClient {
|
|
|
41767
41877
|
this.contractService = contract;
|
|
41768
41878
|
}
|
|
41769
41879
|
allReceipts(address) {
|
|
41770
|
-
return __async$
|
|
41880
|
+
return __async$2(this, null, function* () {
|
|
41771
41881
|
return this.fetchPreLaunchReceipts(address);
|
|
41772
41882
|
});
|
|
41773
41883
|
}
|
|
41774
41884
|
stakeReceipts(address) {
|
|
41775
|
-
return __async$
|
|
41885
|
+
return __async$2(this, null, function* () {
|
|
41776
41886
|
try {
|
|
41777
41887
|
const receipts = yield this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
|
|
41778
41888
|
return receipts;
|
|
@@ -41782,12 +41892,12 @@ class ReceiptClient {
|
|
|
41782
41892
|
});
|
|
41783
41893
|
}
|
|
41784
41894
|
pretokenReceipts(address) {
|
|
41785
|
-
return __async$
|
|
41895
|
+
return __async$2(this, null, function* () {
|
|
41786
41896
|
return this.fetchPreLaunchReceipts(address, ReceiptNFTKind.PRETOKEN_PURCHASE);
|
|
41787
41897
|
});
|
|
41788
41898
|
}
|
|
41789
41899
|
fetchPreLaunchReceipts(address, type) {
|
|
41790
|
-
return __async$
|
|
41900
|
+
return __async$2(this, null, function* () {
|
|
41791
41901
|
const receiptContract = this.contract.ReceiptNFT;
|
|
41792
41902
|
const tokenIds = yield this.getOwnedReceiptNFTsFor(address);
|
|
41793
41903
|
const results = [];
|
|
@@ -41823,51 +41933,26 @@ class ReceiptClient {
|
|
|
41823
41933
|
return results;
|
|
41824
41934
|
});
|
|
41825
41935
|
}
|
|
41826
|
-
getOwnedReceiptNFTsFor(owner, fromBlock = 0, toBlock = "latest") {
|
|
41827
|
-
return __async$1(this, null, function* () {
|
|
41828
|
-
var _a, _b;
|
|
41829
|
-
const receiptContract = this.contract.ReceiptNFT;
|
|
41830
|
-
const toLogs = yield receiptContract.queryFilter(
|
|
41831
|
-
receiptContract.filters.Transfer(null, owner),
|
|
41832
|
-
fromBlock,
|
|
41833
|
-
toBlock
|
|
41834
|
-
);
|
|
41835
|
-
const fromLogs = yield receiptContract.queryFilter(
|
|
41836
|
-
receiptContract.filters.Transfer(owner, null),
|
|
41837
|
-
fromBlock,
|
|
41838
|
-
toBlock
|
|
41839
|
-
);
|
|
41840
|
-
const owned = new Set();
|
|
41841
|
-
for (const e of toLogs) {
|
|
41842
|
-
const tokenId = (_a = e.args) == null ? void 0 : _a.tokenId;
|
|
41843
|
-
if (!tokenId) continue;
|
|
41844
|
-
owned.add(tokenId.toString());
|
|
41845
|
-
}
|
|
41846
|
-
for (const e of fromLogs) {
|
|
41847
|
-
const tokenId = (_b = e.args) == null ? void 0 : _b.tokenId;
|
|
41848
|
-
if (!tokenId) continue;
|
|
41849
|
-
owned.delete(tokenId.toString());
|
|
41850
|
-
}
|
|
41851
|
-
return Array.from(owned).map((id) => ethers.BigNumber.from(id));
|
|
41852
|
-
});
|
|
41853
|
-
}
|
|
41854
41936
|
fetchWithdrawReceipts(address) {
|
|
41855
|
-
return __async$
|
|
41937
|
+
return __async$2(this, null, function* () {
|
|
41856
41938
|
const tokenIds = yield this.getOwnedWithdrawReceiptsFor(address);
|
|
41857
41939
|
const results = [];
|
|
41858
41940
|
for (const idBN of tokenIds) {
|
|
41859
41941
|
try {
|
|
41860
41942
|
const receiptData = yield this.contract.WithdrawalQueue.info(idBN);
|
|
41943
|
+
const readyAtMs = Number(receiptData.readyAt) * 1e3;
|
|
41944
|
+
const status = readyAtMs <= Date.now() ? "ready" : "queued";
|
|
41861
41945
|
results.push({
|
|
41862
41946
|
tokenId: idBN.toBigInt(),
|
|
41863
41947
|
receipt: {
|
|
41864
|
-
|
|
41865
|
-
ethBalance: {
|
|
41948
|
+
amount: {
|
|
41866
41949
|
amount: receiptData.ethAmount.toBigInt(),
|
|
41867
41950
|
decimals: 18,
|
|
41868
41951
|
symbol: "ETH"
|
|
41869
41952
|
},
|
|
41870
|
-
readyAt:
|
|
41953
|
+
readyAt: readyAtMs,
|
|
41954
|
+
chain: "ETH",
|
|
41955
|
+
status
|
|
41871
41956
|
}
|
|
41872
41957
|
});
|
|
41873
41958
|
} catch (err) {
|
|
@@ -41879,7 +41964,7 @@ class ReceiptClient {
|
|
|
41879
41964
|
});
|
|
41880
41965
|
}
|
|
41881
41966
|
getOwnedWithdrawReceiptsFor(owner, fromBlock = 0, toBlock = "latest") {
|
|
41882
|
-
return __async$
|
|
41967
|
+
return __async$2(this, null, function* () {
|
|
41883
41968
|
var _a, _b;
|
|
41884
41969
|
const contract = this.contract.WithdrawalQueue;
|
|
41885
41970
|
const toLogs = yield contract.queryFilter(
|
|
@@ -41906,6 +41991,92 @@ class ReceiptClient {
|
|
|
41906
41991
|
return Array.from(owned).map((id) => ethers.BigNumber.from(id));
|
|
41907
41992
|
});
|
|
41908
41993
|
}
|
|
41994
|
+
getOwnedReceiptNFTsFor(owner, fromBlock = 0, toBlock = "latest") {
|
|
41995
|
+
return __async$2(this, null, function* () {
|
|
41996
|
+
var _a, _b;
|
|
41997
|
+
const receiptContract = this.contract.ReceiptNFT;
|
|
41998
|
+
const toLogs = yield receiptContract.queryFilter(
|
|
41999
|
+
receiptContract.filters.Transfer(null, owner),
|
|
42000
|
+
fromBlock,
|
|
42001
|
+
toBlock
|
|
42002
|
+
);
|
|
42003
|
+
const fromLogs = yield receiptContract.queryFilter(
|
|
42004
|
+
receiptContract.filters.Transfer(owner, null),
|
|
42005
|
+
fromBlock,
|
|
42006
|
+
toBlock
|
|
42007
|
+
);
|
|
42008
|
+
const owned = new Set();
|
|
42009
|
+
for (const e of toLogs) {
|
|
42010
|
+
const tokenId = (_a = e.args) == null ? void 0 : _a.tokenId;
|
|
42011
|
+
if (!tokenId) continue;
|
|
42012
|
+
owned.add(tokenId.toString());
|
|
42013
|
+
}
|
|
42014
|
+
for (const e of fromLogs) {
|
|
42015
|
+
const tokenId = (_b = e.args) == null ? void 0 : _b.tokenId;
|
|
42016
|
+
if (!tokenId) continue;
|
|
42017
|
+
owned.delete(tokenId.toString());
|
|
42018
|
+
}
|
|
42019
|
+
return Array.from(owned).map((id) => ethers.BigNumber.from(id));
|
|
42020
|
+
});
|
|
42021
|
+
}
|
|
42022
|
+
}
|
|
42023
|
+
|
|
42024
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
42025
|
+
return new Promise((resolve, reject) => {
|
|
42026
|
+
var fulfilled = (value) => {
|
|
42027
|
+
try {
|
|
42028
|
+
step(generator.next(value));
|
|
42029
|
+
} catch (e) {
|
|
42030
|
+
reject(e);
|
|
42031
|
+
}
|
|
42032
|
+
};
|
|
42033
|
+
var rejected = (value) => {
|
|
42034
|
+
try {
|
|
42035
|
+
step(generator.throw(value));
|
|
42036
|
+
} catch (e) {
|
|
42037
|
+
reject(e);
|
|
42038
|
+
}
|
|
42039
|
+
};
|
|
42040
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
42041
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42042
|
+
});
|
|
42043
|
+
};
|
|
42044
|
+
class ValidatorClient {
|
|
42045
|
+
get contract() {
|
|
42046
|
+
return this.contractService.contract;
|
|
42047
|
+
}
|
|
42048
|
+
constructor(contract) {
|
|
42049
|
+
this.contractService = contract;
|
|
42050
|
+
}
|
|
42051
|
+
validatorDepositAndLockBond() {
|
|
42052
|
+
return __async$1(this, null, function* () {
|
|
42053
|
+
var _a, _b;
|
|
42054
|
+
const amountWei = ethers.ethers.utils.parseEther("32");
|
|
42055
|
+
try {
|
|
42056
|
+
yield this.contract.DepositManager.callStatic.validatorDepositAndLockBond({ value: amountWei });
|
|
42057
|
+
} catch (err) {
|
|
42058
|
+
let errorObj = formatContractErrors(err);
|
|
42059
|
+
throw new Error((_a = errorObj.name) != null ? _a : errorObj.raw);
|
|
42060
|
+
}
|
|
42061
|
+
const tx = yield this.contract.DepositManager.validatorDepositAndLockBond({ value: amountWei });
|
|
42062
|
+
const receipt = yield tx.wait(1);
|
|
42063
|
+
let staked;
|
|
42064
|
+
const ev = (_b = receipt.events) == null ? void 0 : _b.find((e) => e.event === "Staked");
|
|
42065
|
+
if (ev && ev.args) {
|
|
42066
|
+
const { sender, amount, shares } = ev.args;
|
|
42067
|
+
staked = {
|
|
42068
|
+
sender,
|
|
42069
|
+
amount: ethers.BigNumber.from(amount),
|
|
42070
|
+
shares: ethers.BigNumber.from(shares)
|
|
42071
|
+
};
|
|
42072
|
+
}
|
|
42073
|
+
return {
|
|
42074
|
+
txHash: tx.hash,
|
|
42075
|
+
receipt,
|
|
42076
|
+
staked
|
|
42077
|
+
};
|
|
42078
|
+
});
|
|
42079
|
+
}
|
|
41909
42080
|
}
|
|
41910
42081
|
|
|
41911
42082
|
var __async = (__this, __arguments, generator) => {
|
|
@@ -41950,6 +42121,7 @@ class EthereumStakingClient {
|
|
|
41950
42121
|
this.stakeClient = new StakeClient(this.contractService);
|
|
41951
42122
|
this.oppClient = new OPPClient(this.contractService);
|
|
41952
42123
|
this.receiptClient = new ReceiptClient(this.contractService);
|
|
42124
|
+
this.validatorClient = new ValidatorClient(this.contractService);
|
|
41953
42125
|
} catch (error) {
|
|
41954
42126
|
throw error;
|
|
41955
42127
|
}
|
|
@@ -41977,7 +42149,7 @@ class EthereumStakingClient {
|
|
|
41977
42149
|
return result.txHash;
|
|
41978
42150
|
});
|
|
41979
42151
|
}
|
|
41980
|
-
|
|
42152
|
+
getPendingWithdraws() {
|
|
41981
42153
|
return __async(this, null, function* () {
|
|
41982
42154
|
this.ensureUser();
|
|
41983
42155
|
const address = yield this.signer.getAddress();
|
|
@@ -42022,6 +42194,13 @@ class EthereumStakingClient {
|
|
|
42022
42194
|
return result && result.txHash ? result.txHash : "Error - no resulting txHash";
|
|
42023
42195
|
});
|
|
42024
42196
|
}
|
|
42197
|
+
validatorDeposit() {
|
|
42198
|
+
return __async(this, null, function* () {
|
|
42199
|
+
this.ensureUser();
|
|
42200
|
+
let result = yield this.validatorClient.validatorDepositAndLockBond();
|
|
42201
|
+
return result && result.txHash ? result.txHash : "Error - no resulting txHash";
|
|
42202
|
+
});
|
|
42203
|
+
}
|
|
42025
42204
|
getPortfolio() {
|
|
42026
42205
|
return __async(this, null, function* () {
|
|
42027
42206
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
@@ -42298,12 +42477,12 @@ const CONTRACT_NAMES = [
|
|
|
42298
42477
|
];
|
|
42299
42478
|
|
|
42300
42479
|
var types$1 = /*#__PURE__*/Object.freeze({
|
|
42301
|
-
|
|
42302
|
-
|
|
42480
|
+
__proto__: null,
|
|
42481
|
+
CONTRACT_NAMES: CONTRACT_NAMES
|
|
42303
42482
|
});
|
|
42304
42483
|
|
|
42305
42484
|
var types = /*#__PURE__*/Object.freeze({
|
|
42306
|
-
|
|
42485
|
+
__proto__: null
|
|
42307
42486
|
});
|
|
42308
42487
|
|
|
42309
42488
|
exports.ADDRESSES = ADDRESSES;
|
|
@@ -42311,9 +42490,9 @@ exports.ADDRESS_BOOK_BY_CHAIN = ADDRESS_BOOK_BY_CHAIN;
|
|
|
42311
42490
|
exports.CHAINLINK_FEED = CHAINLINK_FEED;
|
|
42312
42491
|
exports.CHAINLINK_PROGRAM = CHAINLINK_PROGRAM;
|
|
42313
42492
|
exports.CONTRACTS_BY_CHAIN = CONTRACTS_BY_CHAIN;
|
|
42493
|
+
exports.ConvertClient = ConvertClient$1;
|
|
42314
42494
|
exports.DEFAULT_AVERAGE_PAY_RATE = DEFAULT_AVERAGE_PAY_RATE;
|
|
42315
42495
|
exports.DEFAULT_PAY_RATE_LOOKBACK = DEFAULT_PAY_RATE_LOOKBACK;
|
|
42316
|
-
exports.DepositClient = DepositClient;
|
|
42317
42496
|
exports.DistributionClient = DistributionClient;
|
|
42318
42497
|
exports.EPHEMERAL_RENT_EXEMPTION = EPHEMERAL_RENT_EXEMPTION;
|
|
42319
42498
|
exports.ERC1155Abi = ERC1155Abi;
|
|
@@ -42354,6 +42533,7 @@ exports.getErrorMessage = getErrorMessage;
|
|
|
42354
42533
|
exports.getProgramIds = getProgramIds;
|
|
42355
42534
|
exports.lamportsToSol = lamportsToSol;
|
|
42356
42535
|
exports.msToEpochEnd = msToEpochEnd;
|
|
42536
|
+
exports.normalizeToBigInt = normalizeToBigInt;
|
|
42357
42537
|
exports.scheduledInstruction = scheduledInstruction;
|
|
42358
42538
|
exports.sleep = sleep;
|
|
42359
42539
|
exports.solToLamports = solToLamports;
|