@perena/vault-sdk 1.0.47 → 1.0.49
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.ts +244 -5
- package/dist/index.js +1588 -943
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -149,7 +149,7 @@ var require_compat = __commonJS({
|
|
|
149
149
|
exports2.fromWeb3PublicKey = fromWeb3PublicKey;
|
|
150
150
|
exports2.toWeb3PublicKey = toWeb3PublicKey;
|
|
151
151
|
exports2.asWeb3PublicKey = asWeb3PublicKey2;
|
|
152
|
-
exports2.toKitInstruction =
|
|
152
|
+
exports2.toKitInstruction = toKitInstruction35;
|
|
153
153
|
exports2.fromKitInstruction = fromKitInstruction3;
|
|
154
154
|
var kit_1 = require("@solana/kit");
|
|
155
155
|
var web3_js_1 = require("@solana/web3.js");
|
|
@@ -165,7 +165,7 @@ var require_compat = __commonJS({
|
|
|
165
165
|
exports2.toAddress = fromWeb3PublicKey;
|
|
166
166
|
exports2.fromWeb3Pk = fromWeb3PublicKey;
|
|
167
167
|
exports2.toWeb3Pk = toWeb3PublicKey;
|
|
168
|
-
function
|
|
168
|
+
function toKitInstruction35(ix) {
|
|
169
169
|
return {
|
|
170
170
|
programAddress: ix.programId.toBase58(),
|
|
171
171
|
data: new Uint8Array(ix.data),
|
|
@@ -194,10 +194,10 @@ var require_ata = __commonJS({
|
|
|
194
194
|
"../common/dist/utils/accounts/ata.js"(exports2) {
|
|
195
195
|
"use strict";
|
|
196
196
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
197
|
-
exports2.getAtaAddress =
|
|
197
|
+
exports2.getAtaAddress = getAtaAddress20;
|
|
198
198
|
var spl_token_1 = require("@solana/spl-token");
|
|
199
199
|
var compat_1 = require_compat();
|
|
200
|
-
function
|
|
200
|
+
function getAtaAddress20(mint, owner, tokenProgram, allowOwnerOffCurve = true) {
|
|
201
201
|
const ata = (0, spl_token_1.getAssociatedTokenAddressSync)((0, compat_1.toWeb3PublicKey)(mint), (0, compat_1.toWeb3PublicKey)(owner), allowOwnerOffCurve, (0, compat_1.toWeb3PublicKey)(tokenProgram), spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
202
202
|
return ata.toBase58();
|
|
203
203
|
}
|
|
@@ -1479,6 +1479,140 @@ var require_dist2 = __commonJS({
|
|
|
1479
1479
|
}
|
|
1480
1480
|
});
|
|
1481
1481
|
|
|
1482
|
+
// ../nest/dist/priceApi.js
|
|
1483
|
+
var require_priceApi = __commonJS({
|
|
1484
|
+
"../nest/dist/priceApi.js"(exports2) {
|
|
1485
|
+
"use strict";
|
|
1486
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1487
|
+
exports2.NEST_API_BASE_URL = void 0;
|
|
1488
|
+
exports2.fetchNestVaultSharePrice = fetchNestVaultSharePrice2;
|
|
1489
|
+
exports2.NEST_API_BASE_URL = "https://api.nest.credit/v1";
|
|
1490
|
+
async function fetchNestVaultSharePrice2(vaultSlug, opts = {}) {
|
|
1491
|
+
const baseUrl = (opts.baseUrl ?? exports2.NEST_API_BASE_URL).replace(/\/$/, "");
|
|
1492
|
+
const response = await (opts.fetchFn ?? fetch)(`${baseUrl}/vaults/${encodeURIComponent(vaultSlug)}/price`);
|
|
1493
|
+
if (!response.ok) {
|
|
1494
|
+
throw new Error(`Nest price API request failed: ${response.status} ${response.statusText}`);
|
|
1495
|
+
}
|
|
1496
|
+
const body = await response.json();
|
|
1497
|
+
const price = [body.data?.interpolatedPrice, body.data?.price].map(Number).find((candidate) => Number.isFinite(candidate) && candidate > 0);
|
|
1498
|
+
if (price === void 0) {
|
|
1499
|
+
throw new Error("Nest price API returned no positive share price");
|
|
1500
|
+
}
|
|
1501
|
+
return price;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
// ../nest/dist/redemptionApi.js
|
|
1507
|
+
var require_redemptionApi = __commonJS({
|
|
1508
|
+
"../nest/dist/redemptionApi.js"(exports2) {
|
|
1509
|
+
"use strict";
|
|
1510
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1511
|
+
exports2.NestApiError = void 0;
|
|
1512
|
+
exports2.assertNestShareAmount = assertNestShareAmount;
|
|
1513
|
+
exports2.fetchNestRedemptionTransaction = fetchNestRedemptionTransaction2;
|
|
1514
|
+
exports2.fetchNestRedemptionQuote = fetchNestRedemptionQuote2;
|
|
1515
|
+
exports2.fetchNestRedemptionStatus = fetchNestRedemptionStatus2;
|
|
1516
|
+
var priceApi_1 = require_priceApi();
|
|
1517
|
+
var NestApiError2 = class extends Error {
|
|
1518
|
+
constructor(status, message2) {
|
|
1519
|
+
super(`Nest API (${status}): ${message2}`);
|
|
1520
|
+
this.status = status;
|
|
1521
|
+
this.name = "NestApiError";
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
exports2.NestApiError = NestApiError2;
|
|
1525
|
+
function assertNestShareAmount(amount) {
|
|
1526
|
+
if (typeof amount !== "bigint" || amount <= 0n || amount > 0xffffffffffffffffn) {
|
|
1527
|
+
throw new Error("Nest share amount must be a positive u64 bigint in base units");
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
async function request(path2, options, body) {
|
|
1531
|
+
const response = await (options.fetchFn ?? fetch)(`${(options.baseUrl ?? priceApi_1.NEST_API_BASE_URL).replace(/\/$/, "")}${path2}`, {
|
|
1532
|
+
method: body ? "POST" : "GET",
|
|
1533
|
+
headers: body ? { "Content-Type": "application/json" } : void 0,
|
|
1534
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
1535
|
+
signal: options.signal
|
|
1536
|
+
});
|
|
1537
|
+
const payload = await response.json().catch(() => null);
|
|
1538
|
+
if (!response.ok) {
|
|
1539
|
+
throw new NestApiError2(response.status, typeof payload?.error === "string" ? payload.error : response.statusText);
|
|
1540
|
+
}
|
|
1541
|
+
if (!payload || typeof payload !== "object" || !payload.data) {
|
|
1542
|
+
throw new Error("Nest API returned an invalid response");
|
|
1543
|
+
}
|
|
1544
|
+
return payload.data;
|
|
1545
|
+
}
|
|
1546
|
+
async function fetchNestRedemptionTransaction2(args, options = {}) {
|
|
1547
|
+
assertNestShareAmount(args.rawAmountNestToken);
|
|
1548
|
+
const data = await request("/solana/nest/async-redeem/request/build-tx", options, {
|
|
1549
|
+
...args,
|
|
1550
|
+
rawAmountNestToken: args.rawAmountNestToken.toString(),
|
|
1551
|
+
// Squads must sign both the token authority and LayerZero fee payer at execution.
|
|
1552
|
+
feePayer: args.owner
|
|
1553
|
+
});
|
|
1554
|
+
if (typeof data.txBase64 !== "string" || !data.txBase64.length) {
|
|
1555
|
+
throw new Error("Nest API returned no transaction");
|
|
1556
|
+
}
|
|
1557
|
+
return data.txBase64;
|
|
1558
|
+
}
|
|
1559
|
+
async function fetchNestRedemptionQuote2(args, options = {}) {
|
|
1560
|
+
assertNestShareAmount(args.rawAmountNestToken);
|
|
1561
|
+
const data = await request("/solana/nest/async-redeem/quote", options, {
|
|
1562
|
+
...args,
|
|
1563
|
+
rawAmountNestToken: args.rawAmountNestToken.toString()
|
|
1564
|
+
});
|
|
1565
|
+
if (data.nestVaultSlug !== args.nestVaultSlug || data.redemptionAsset !== "USDC" || data.shareAmount !== args.rawAmountNestToken.toString() || !Number.isInteger(data.shareDecimals) || data.shareDecimals < 0 || data.shareDecimals > 18 || data.redemptionDecimals !== 6 || typeof data.redemptionAmount !== "string" || typeof data.feeAmount !== "string" || !/^\d+$/.test(data.redemptionAmount) || !/^\d+$/.test(data.feeAmount)) {
|
|
1566
|
+
throw new Error("Nest API returned an invalid redemption quote");
|
|
1567
|
+
}
|
|
1568
|
+
return data;
|
|
1569
|
+
}
|
|
1570
|
+
async function fetchNestRedemptionStatus2(signature, options = {}) {
|
|
1571
|
+
if (!/^[1-9A-HJ-NP-Za-km-z]{64,88}$/.test(signature)) {
|
|
1572
|
+
throw new Error("Enter a Solana withdrawal execution signature");
|
|
1573
|
+
}
|
|
1574
|
+
let data;
|
|
1575
|
+
try {
|
|
1576
|
+
data = await request(`/solana/redeem-status/${encodeURIComponent(signature)}`, options);
|
|
1577
|
+
} catch (error) {
|
|
1578
|
+
if (error instanceof NestApiError2 && error.status === 404)
|
|
1579
|
+
return null;
|
|
1580
|
+
throw error;
|
|
1581
|
+
}
|
|
1582
|
+
if (data.solanaBurnSignature !== signature || typeof data.solanaWallet !== "string" || typeof data.overallStatus !== "string" || !["solanaBurn", "plumeProcessing", "cctpAttestation", "solanaClaim"].every((key) => typeof data.steps?.[key]?.status === "string")) {
|
|
1583
|
+
throw new Error("Nest API returned an invalid redemption status");
|
|
1584
|
+
}
|
|
1585
|
+
return data;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
// ../nest/dist/index.js
|
|
1591
|
+
var require_dist3 = __commonJS({
|
|
1592
|
+
"../nest/dist/index.js"(exports2) {
|
|
1593
|
+
"use strict";
|
|
1594
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1595
|
+
if (k2 === void 0) k2 = k;
|
|
1596
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1597
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1598
|
+
desc = { enumerable: true, get: function() {
|
|
1599
|
+
return m[k];
|
|
1600
|
+
} };
|
|
1601
|
+
}
|
|
1602
|
+
Object.defineProperty(o, k2, desc);
|
|
1603
|
+
}) : (function(o, m, k, k2) {
|
|
1604
|
+
if (k2 === void 0) k2 = k;
|
|
1605
|
+
o[k2] = m[k];
|
|
1606
|
+
}));
|
|
1607
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
1608
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
1609
|
+
};
|
|
1610
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1611
|
+
__exportStar(require_priceApi(), exports2);
|
|
1612
|
+
__exportStar(require_redemptionApi(), exports2);
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
|
|
1482
1616
|
// ../../node_modules/.pnpm/@jup-ag+api@6.0.48/node_modules/@jup-ag/api/dist/index.mjs
|
|
1483
1617
|
var dist_exports = {};
|
|
1484
1618
|
__export(dist_exports, {
|
|
@@ -2844,12 +2978,12 @@ var require_routePreInstructions = __commonJS({
|
|
|
2844
2978
|
if (existingAta.value) {
|
|
2845
2979
|
continue;
|
|
2846
2980
|
}
|
|
2847
|
-
instructions2.push(
|
|
2981
|
+
instructions2.push(toKitInstruction35((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(new web3_js_1.PublicKey(payer), new web3_js_1.PublicKey(ata), new web3_js_1.PublicKey(user), new web3_js_1.PublicKey(mint), new web3_js_1.PublicKey(tokenProgram), spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID)));
|
|
2848
2982
|
postSuccessCacheInvalidations.push({ address: ata });
|
|
2849
2983
|
}
|
|
2850
2984
|
return { instructions: instructions2, postSuccessCacheInvalidations };
|
|
2851
2985
|
}
|
|
2852
|
-
function
|
|
2986
|
+
function toKitInstruction35(ix) {
|
|
2853
2987
|
return {
|
|
2854
2988
|
programAddress: ix.programId.toBase58(),
|
|
2855
2989
|
accounts: ix.keys.map((account) => ({
|
|
@@ -2978,7 +3112,7 @@ var require_client = __commonJS({
|
|
|
2978
3112
|
});
|
|
2979
3113
|
|
|
2980
3114
|
// ../../node_modules/.pnpm/jupiter@file+typescript+jupiter_bufferutil@4.1.0_fastestsmallesttextencoderdecoder@1.0._929400004aea12c8b3c9bcc7c5a22ec9/node_modules/jupiter/dist/priceApi.js
|
|
2981
|
-
var
|
|
3115
|
+
var require_priceApi2 = __commonJS({
|
|
2982
3116
|
"../../node_modules/.pnpm/jupiter@file+typescript+jupiter_bufferutil@4.1.0_fastestsmallesttextencoderdecoder@1.0._929400004aea12c8b3c9bcc7c5a22ec9/node_modules/jupiter/dist/priceApi.js"(exports2) {
|
|
2983
3117
|
"use strict";
|
|
2984
3118
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -3109,7 +3243,7 @@ var require_types4 = __commonJS({
|
|
|
3109
3243
|
});
|
|
3110
3244
|
|
|
3111
3245
|
// ../../node_modules/.pnpm/jupiter@file+typescript+jupiter_bufferutil@4.1.0_fastestsmallesttextencoderdecoder@1.0._929400004aea12c8b3c9bcc7c5a22ec9/node_modules/jupiter/dist/index.js
|
|
3112
|
-
var
|
|
3246
|
+
var require_dist4 = __commonJS({
|
|
3113
3247
|
"../../node_modules/.pnpm/jupiter@file+typescript+jupiter_bufferutil@4.1.0_fastestsmallesttextencoderdecoder@1.0._929400004aea12c8b3c9bcc7c5a22ec9/node_modules/jupiter/dist/index.js"(exports2) {
|
|
3114
3248
|
"use strict";
|
|
3115
3249
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -3132,147 +3266,13 @@ var require_dist3 = __commonJS({
|
|
|
3132
3266
|
__exportStar(require_api(), exports2);
|
|
3133
3267
|
__exportStar(require_client(), exports2);
|
|
3134
3268
|
__exportStar(require_constants4(), exports2);
|
|
3135
|
-
__exportStar(
|
|
3269
|
+
__exportStar(require_priceApi2(), exports2);
|
|
3136
3270
|
__exportStar(require_routePreInstructions(), exports2);
|
|
3137
3271
|
__exportStar(require_sizeExactInForMinOutput(), exports2);
|
|
3138
3272
|
__exportStar(require_types4(), exports2);
|
|
3139
3273
|
}
|
|
3140
3274
|
});
|
|
3141
3275
|
|
|
3142
|
-
// ../nest/dist/priceApi.js
|
|
3143
|
-
var require_priceApi2 = __commonJS({
|
|
3144
|
-
"../nest/dist/priceApi.js"(exports2) {
|
|
3145
|
-
"use strict";
|
|
3146
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3147
|
-
exports2.NEST_API_BASE_URL = void 0;
|
|
3148
|
-
exports2.fetchNestVaultSharePrice = fetchNestVaultSharePrice2;
|
|
3149
|
-
exports2.NEST_API_BASE_URL = "https://api.nest.credit/v1";
|
|
3150
|
-
async function fetchNestVaultSharePrice2(vaultSlug, opts = {}) {
|
|
3151
|
-
const baseUrl = (opts.baseUrl ?? exports2.NEST_API_BASE_URL).replace(/\/$/, "");
|
|
3152
|
-
const response = await (opts.fetchFn ?? fetch)(`${baseUrl}/vaults/${encodeURIComponent(vaultSlug)}/price`);
|
|
3153
|
-
if (!response.ok) {
|
|
3154
|
-
throw new Error(`Nest price API request failed: ${response.status} ${response.statusText}`);
|
|
3155
|
-
}
|
|
3156
|
-
const body = await response.json();
|
|
3157
|
-
const price = [body.data?.interpolatedPrice, body.data?.price].map(Number).find((candidate) => Number.isFinite(candidate) && candidate > 0);
|
|
3158
|
-
if (price === void 0) {
|
|
3159
|
-
throw new Error("Nest price API returned no positive share price");
|
|
3160
|
-
}
|
|
3161
|
-
return price;
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
});
|
|
3165
|
-
|
|
3166
|
-
// ../nest/dist/redemptionApi.js
|
|
3167
|
-
var require_redemptionApi = __commonJS({
|
|
3168
|
-
"../nest/dist/redemptionApi.js"(exports2) {
|
|
3169
|
-
"use strict";
|
|
3170
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3171
|
-
exports2.NestApiError = void 0;
|
|
3172
|
-
exports2.assertNestShareAmount = assertNestShareAmount;
|
|
3173
|
-
exports2.fetchNestRedemptionTransaction = fetchNestRedemptionTransaction2;
|
|
3174
|
-
exports2.fetchNestRedemptionQuote = fetchNestRedemptionQuote2;
|
|
3175
|
-
exports2.fetchNestRedemptionStatus = fetchNestRedemptionStatus2;
|
|
3176
|
-
var priceApi_1 = require_priceApi2();
|
|
3177
|
-
var NestApiError2 = class extends Error {
|
|
3178
|
-
constructor(status, message2) {
|
|
3179
|
-
super(`Nest API (${status}): ${message2}`);
|
|
3180
|
-
this.status = status;
|
|
3181
|
-
this.name = "NestApiError";
|
|
3182
|
-
}
|
|
3183
|
-
};
|
|
3184
|
-
exports2.NestApiError = NestApiError2;
|
|
3185
|
-
function assertNestShareAmount(amount) {
|
|
3186
|
-
if (typeof amount !== "bigint" || amount <= 0n || amount > 0xffffffffffffffffn) {
|
|
3187
|
-
throw new Error("Nest share amount must be a positive u64 bigint in base units");
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
async function request(path2, options, body) {
|
|
3191
|
-
const response = await (options.fetchFn ?? fetch)(`${(options.baseUrl ?? priceApi_1.NEST_API_BASE_URL).replace(/\/$/, "")}${path2}`, {
|
|
3192
|
-
method: body ? "POST" : "GET",
|
|
3193
|
-
headers: body ? { "Content-Type": "application/json" } : void 0,
|
|
3194
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
3195
|
-
signal: options.signal
|
|
3196
|
-
});
|
|
3197
|
-
const payload = await response.json().catch(() => null);
|
|
3198
|
-
if (!response.ok) {
|
|
3199
|
-
throw new NestApiError2(response.status, typeof payload?.error === "string" ? payload.error : response.statusText);
|
|
3200
|
-
}
|
|
3201
|
-
if (!payload || typeof payload !== "object" || !payload.data) {
|
|
3202
|
-
throw new Error("Nest API returned an invalid response");
|
|
3203
|
-
}
|
|
3204
|
-
return payload.data;
|
|
3205
|
-
}
|
|
3206
|
-
async function fetchNestRedemptionTransaction2(args, options = {}) {
|
|
3207
|
-
assertNestShareAmount(args.rawAmountNestToken);
|
|
3208
|
-
const data = await request("/solana/nest/async-redeem/request/build-tx", options, {
|
|
3209
|
-
...args,
|
|
3210
|
-
rawAmountNestToken: args.rawAmountNestToken.toString(),
|
|
3211
|
-
// Squads must sign both the token authority and LayerZero fee payer at execution.
|
|
3212
|
-
feePayer: args.owner
|
|
3213
|
-
});
|
|
3214
|
-
if (typeof data.txBase64 !== "string" || !data.txBase64.length) {
|
|
3215
|
-
throw new Error("Nest API returned no transaction");
|
|
3216
|
-
}
|
|
3217
|
-
return data.txBase64;
|
|
3218
|
-
}
|
|
3219
|
-
async function fetchNestRedemptionQuote2(args, options = {}) {
|
|
3220
|
-
assertNestShareAmount(args.rawAmountNestToken);
|
|
3221
|
-
const data = await request("/solana/nest/async-redeem/quote", options, {
|
|
3222
|
-
...args,
|
|
3223
|
-
rawAmountNestToken: args.rawAmountNestToken.toString()
|
|
3224
|
-
});
|
|
3225
|
-
if (data.nestVaultSlug !== args.nestVaultSlug || data.redemptionAsset !== "USDC" || data.shareAmount !== args.rawAmountNestToken.toString() || !Number.isInteger(data.shareDecimals) || data.shareDecimals < 0 || data.shareDecimals > 18 || data.redemptionDecimals !== 6 || typeof data.redemptionAmount !== "string" || typeof data.feeAmount !== "string" || !/^\d+$/.test(data.redemptionAmount) || !/^\d+$/.test(data.feeAmount)) {
|
|
3226
|
-
throw new Error("Nest API returned an invalid redemption quote");
|
|
3227
|
-
}
|
|
3228
|
-
return data;
|
|
3229
|
-
}
|
|
3230
|
-
async function fetchNestRedemptionStatus2(signature, options = {}) {
|
|
3231
|
-
if (!/^[1-9A-HJ-NP-Za-km-z]{64,88}$/.test(signature)) {
|
|
3232
|
-
throw new Error("Enter a Solana withdrawal execution signature");
|
|
3233
|
-
}
|
|
3234
|
-
let data;
|
|
3235
|
-
try {
|
|
3236
|
-
data = await request(`/solana/redeem-status/${encodeURIComponent(signature)}`, options);
|
|
3237
|
-
} catch (error) {
|
|
3238
|
-
if (error instanceof NestApiError2 && error.status === 404)
|
|
3239
|
-
return null;
|
|
3240
|
-
throw error;
|
|
3241
|
-
}
|
|
3242
|
-
if (data.solanaBurnSignature !== signature || typeof data.solanaWallet !== "string" || typeof data.overallStatus !== "string" || !["solanaBurn", "plumeProcessing", "cctpAttestation", "solanaClaim"].every((key) => typeof data.steps?.[key]?.status === "string")) {
|
|
3243
|
-
throw new Error("Nest API returned an invalid redemption status");
|
|
3244
|
-
}
|
|
3245
|
-
return data;
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
});
|
|
3249
|
-
|
|
3250
|
-
// ../nest/dist/index.js
|
|
3251
|
-
var require_dist4 = __commonJS({
|
|
3252
|
-
"../nest/dist/index.js"(exports2) {
|
|
3253
|
-
"use strict";
|
|
3254
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
3255
|
-
if (k2 === void 0) k2 = k;
|
|
3256
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3257
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3258
|
-
desc = { enumerable: true, get: function() {
|
|
3259
|
-
return m[k];
|
|
3260
|
-
} };
|
|
3261
|
-
}
|
|
3262
|
-
Object.defineProperty(o, k2, desc);
|
|
3263
|
-
}) : (function(o, m, k, k2) {
|
|
3264
|
-
if (k2 === void 0) k2 = k;
|
|
3265
|
-
o[k2] = m[k];
|
|
3266
|
-
}));
|
|
3267
|
-
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
3268
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
3269
|
-
};
|
|
3270
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3271
|
-
__exportStar(require_priceApi2(), exports2);
|
|
3272
|
-
__exportStar(require_redemptionApi(), exports2);
|
|
3273
|
-
}
|
|
3274
|
-
});
|
|
3275
|
-
|
|
3276
3276
|
// src/index.ts
|
|
3277
3277
|
var index_exports = {};
|
|
3278
3278
|
__export(index_exports, {
|
|
@@ -3281,16 +3281,19 @@ __export(index_exports, {
|
|
|
3281
3281
|
AccountClient: () => AccountClient,
|
|
3282
3282
|
ActivateCircuitBreakerBuilder: () => ActivateCircuitBreakerBuilder,
|
|
3283
3283
|
AddIncentiveRecipientBuilder: () => AddIncentiveRecipientBuilder,
|
|
3284
|
+
AddIncentiveRecipientV3Builder: () => AddIncentiveRecipientV3Builder,
|
|
3284
3285
|
BALANCE_CHANGE_BASELINE_MAX_AGE_SECS: () => BALANCE_CHANGE_BASELINE_MAX_AGE_SECS,
|
|
3285
3286
|
CONSENSUS_ORACLE_VARIANT: () => CONSENSUS_ORACLE_VARIANT,
|
|
3286
3287
|
CancelIncentiveProposalBuilder: () => CancelIncentiveProposalBuilder,
|
|
3287
3288
|
CancelJuniorTrancheWithdrawBuilder: () => CancelJuniorTrancheWithdrawBuilder,
|
|
3288
3289
|
ClaimIncentiveBuilder: () => ClaimIncentiveBuilder,
|
|
3290
|
+
ClaimIncentiveV3Builder: () => ClaimIncentiveV3Builder,
|
|
3289
3291
|
ConsensusOracleService: () => ConsensusOracleService,
|
|
3290
3292
|
CrankNavBuilder: () => CrankNavBuilder,
|
|
3291
3293
|
CrankPerformanceFeesBuilder: () => CrankPerformanceFeesBuilder,
|
|
3292
3294
|
CreateAssetHoldingBuilder: () => CreateAssetHoldingBuilder,
|
|
3293
3295
|
CreateIncentiveBuilder: () => CreateIncentiveBuilder,
|
|
3296
|
+
CreateIncentiveV3Builder: () => CreateIncentiveV3Builder,
|
|
3294
3297
|
CreateTrancheStateBuilder: () => CreateTrancheStateBuilder,
|
|
3295
3298
|
CreateVaultBuilder: () => CreateVaultBuilder,
|
|
3296
3299
|
DEFAULT_CU_PRICE_MICRO_LAMPORTS: () => DEFAULT_CU_PRICE_MICRO_LAMPORTS,
|
|
@@ -3299,7 +3302,7 @@ __export(index_exports, {
|
|
|
3299
3302
|
DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
|
|
3300
3303
|
DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
3301
3304
|
DEFAULT_MAX_ACCOUNTS: () => DEFAULT_MAX_ACCOUNTS,
|
|
3302
|
-
DEFAULT_MINTS: () =>
|
|
3305
|
+
DEFAULT_MINTS: () => import_common61.DEFAULT_MINTS,
|
|
3303
3306
|
DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
|
|
3304
3307
|
DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
|
|
3305
3308
|
DEFAULT_PRICE_ORACLE_ACCOUNT: () => DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -3311,6 +3314,7 @@ __export(index_exports, {
|
|
|
3311
3314
|
DEFAULT_VAULT_ID: () => DEFAULT_VAULT_ID,
|
|
3312
3315
|
DisableCircuitBreakerBuilder: () => DisableCircuitBreakerBuilder,
|
|
3313
3316
|
DistributeIncentiveBuilder: () => DistributeIncentiveBuilder,
|
|
3317
|
+
DistributeIncentiveV3Builder: () => DistributeIncentiveV3Builder,
|
|
3314
3318
|
EXTERNAL_POSITION_SAMPLES: () => EXTERNAL_POSITION_SAMPLES,
|
|
3315
3319
|
ExecuteDepositBuilder: () => ExecuteDepositBuilder,
|
|
3316
3320
|
ExecuteShareSwapBuilder: () => ExecuteShareSwapBuilder,
|
|
@@ -3334,17 +3338,20 @@ __export(index_exports, {
|
|
|
3334
3338
|
LOCAL_PROTOCOL_ADMIN: () => LOCAL_PROTOCOL_ADMIN,
|
|
3335
3339
|
LargeBalanceChangeError: () => LargeBalanceChangeError,
|
|
3336
3340
|
LivePriceSource: () => LivePriceSource,
|
|
3341
|
+
MANAGER_WALLET_NAV_DROP_TRIGGER_BPS: () => MANAGER_WALLET_NAV_DROP_TRIGGER_BPS,
|
|
3342
|
+
MANAGER_WALLET_NAV_TOLERANCE_BPS: () => MANAGER_WALLET_NAV_TOLERANCE_BPS,
|
|
3337
3343
|
MAX_APY_ANCHOR_WINDOW_SECS: () => MAX_APY_ANCHOR_WINDOW_SECS,
|
|
3338
3344
|
MAX_BALANCE_CHANGE_BPS: () => MAX_BALANCE_CHANGE_BPS,
|
|
3339
3345
|
MAX_CONSENSUS_SIGNERS: () => MAX_CONSENSUS_SIGNERS,
|
|
3340
3346
|
MAX_INCENTIVE_RECIPIENTS: () => MAX_INCENTIVE_RECIPIENTS,
|
|
3347
|
+
MAX_INCENTIVE_REPORT_TTL: () => MAX_INCENTIVE_REPORT_TTL,
|
|
3341
3348
|
MAX_MANAGER_WITHDRAW_DESTINATIONS: () => MAX_MANAGER_WITHDRAW_DESTINATIONS,
|
|
3342
3349
|
MAX_PRICE_STALENESS_THRESHOLD_SECS: () => MAX_PRICE_STALENESS_THRESHOLD_SECS,
|
|
3343
3350
|
MIN_EXTERNAL_POSITION_SAMPLES: () => MIN_EXTERNAL_POSITION_SAMPLES,
|
|
3344
3351
|
ManagerRedepositAssetBuilder: () => ManagerRedepositAssetBuilder,
|
|
3345
3352
|
ManagerWithdrawAssetBuilder: () => ManagerWithdrawAssetBuilder,
|
|
3346
3353
|
MarginfiPositionProvider: () => MarginfiPositionProvider,
|
|
3347
|
-
MintRegistry: () =>
|
|
3354
|
+
MintRegistry: () => import_common61.MintRegistry,
|
|
3348
3355
|
MockYieldTracker: () => MockYieldTracker,
|
|
3349
3356
|
NEST_API_BASE_URL: () => import_nest2.NEST_API_BASE_URL,
|
|
3350
3357
|
NEST_RWA_SHARE_MINT: () => NEST_RWA_SHARE_MINT,
|
|
@@ -3355,7 +3362,7 @@ __export(index_exports, {
|
|
|
3355
3362
|
ORACLE_ENTRY_SIZE: () => ORACLE_ENTRY_SIZE,
|
|
3356
3363
|
ORACLE_SETTLED_NAV_TS_OFFSET: () => ORACLE_SETTLED_NAV_TS_OFFSET,
|
|
3357
3364
|
OracleService: () => OracleService,
|
|
3358
|
-
PRICE_ORACLE_TYPES_BY_INDEX: () =>
|
|
3365
|
+
PRICE_ORACLE_TYPES_BY_INDEX: () => PRICE_ORACLE_TYPES_BY_INDEX,
|
|
3359
3366
|
PROGRAM_FEE_EXEMPT_OWNER_WHITELIST: () => PROGRAM_FEE_EXEMPT_OWNER_WHITELIST,
|
|
3360
3367
|
PROTOCOL_ADMIN: () => PROTOCOL_ADMIN,
|
|
3361
3368
|
PROTOCOL_FEE_RECIPIENT: () => PROTOCOL_FEE_RECIPIENT,
|
|
@@ -3363,15 +3370,19 @@ __export(index_exports, {
|
|
|
3363
3370
|
ProtocolInteractionBuilder: () => ProtocolInteractionBuilder,
|
|
3364
3371
|
REPORTABLE_ORACLE_VARIANTS: () => REPORTABLE_ORACLE_VARIANTS,
|
|
3365
3372
|
RemoveAssetHoldingBuilder: () => RemoveAssetHoldingBuilder,
|
|
3373
|
+
ReportIncentiveV3Builder: () => ReportIncentiveV3Builder,
|
|
3366
3374
|
RequestJuniorTrancheWithdrawBuilder: () => RequestJuniorTrancheWithdrawBuilder,
|
|
3375
|
+
RpcManagerWalletBalanceSource: () => RpcManagerWalletBalanceSource,
|
|
3367
3376
|
SHARE_DECIMALS: () => SHARE_DECIMALS,
|
|
3368
|
-
SYSTEM_PROGRAM: () =>
|
|
3377
|
+
SYSTEM_PROGRAM: () => SYSTEM_PROGRAM,
|
|
3369
3378
|
SetAssetPriceOracleBuilder: () => SetAssetPriceOracleBuilder,
|
|
3370
3379
|
SetExternalLiquidityBuilder: () => SetExternalLiquidityBuilder,
|
|
3371
3380
|
SetIncentiveLimitsBuilder: () => SetIncentiveLimitsBuilder,
|
|
3381
|
+
SetIncentiveLimitsV3Builder: () => SetIncentiveLimitsV3Builder,
|
|
3372
3382
|
SetManagerWithdrawDestinationBuilder: () => SetManagerWithdrawDestinationBuilder,
|
|
3373
3383
|
SetProtocolFeeBuilder: () => SetProtocolFeeBuilder,
|
|
3374
3384
|
SetVaultConfigBuilder: () => SetVaultConfigBuilder,
|
|
3385
|
+
SettleIncentiveV3Builder: () => SettleIncentiveV3Builder,
|
|
3375
3386
|
SquadsProposalExecutionSimulationError: () => SquadsProposalExecutionSimulationError,
|
|
3376
3387
|
StaticPositionProvider: () => StaticPositionProvider,
|
|
3377
3388
|
SubmitIncentiveBuilder: () => SubmitIncentiveBuilder,
|
|
@@ -3412,6 +3423,7 @@ __export(index_exports, {
|
|
|
3412
3423
|
buildMarginfiWithdrawInteraction: () => buildMarginfiWithdrawInteraction,
|
|
3413
3424
|
buildNestWithdrawalRequest: () => buildNestWithdrawalRequest,
|
|
3414
3425
|
buildUpdates: () => buildUpdates,
|
|
3426
|
+
candidateGrossNav: () => candidateGrossNav,
|
|
3415
3427
|
coerceBool: () => coerceBool3,
|
|
3416
3428
|
collectSamples: () => collectSamples,
|
|
3417
3429
|
confirmYieldPayment: () => confirmYieldPayment,
|
|
@@ -3448,6 +3460,10 @@ __export(index_exports, {
|
|
|
3448
3460
|
getIncentiveRecipients: () => getIncentiveRecipients,
|
|
3449
3461
|
getIncentiveReportRecipients: () => getIncentiveReportRecipients,
|
|
3450
3462
|
getIncentiveTotals: () => getIncentiveTotals,
|
|
3463
|
+
getIncentiveV3OracleState: () => getIncentiveV3OracleState,
|
|
3464
|
+
getIncentiveV3RecipientShareAtas: () => getIncentiveV3RecipientShareAtas,
|
|
3465
|
+
getIncentiveV3Recipients: () => getIncentiveV3Recipients,
|
|
3466
|
+
getIncentiveV3Totals: () => getIncentiveV3Totals,
|
|
3451
3467
|
getNavValue: () => getNavValue,
|
|
3452
3468
|
getRpcUrl: () => getRpcUrl,
|
|
3453
3469
|
getTotalOutstandingYield: () => getTotalOutstandingYield,
|
|
@@ -3466,16 +3482,19 @@ __export(index_exports, {
|
|
|
3466
3482
|
loadKeypair: () => loadKeypair,
|
|
3467
3483
|
logProspectiveApy: () => logProspectiveApy,
|
|
3468
3484
|
makeProvider: () => makeProvider,
|
|
3485
|
+
managerReconciliationStateKey: () => managerReconciliationStateKey,
|
|
3469
3486
|
mintTokensTo: () => mintTokensTo,
|
|
3470
|
-
mints: () =>
|
|
3487
|
+
mints: () => import_common61.mints,
|
|
3471
3488
|
mostFrequent: () => mostFrequent,
|
|
3472
3489
|
parseExternalLiquidityRefs: () => parseExternalLiquidityRefs,
|
|
3473
3490
|
planRebalance: () => planRebalance,
|
|
3474
3491
|
prepareSquadsProposalUpload: () => prepareSquadsProposalUpload,
|
|
3475
3492
|
prepareVaultTransaction: () => prepareVaultTransaction,
|
|
3493
|
+
previousPhysicalNav: () => previousPhysicalNav,
|
|
3476
3494
|
priceInAccountingUnit: () => priceInAccountingUnit,
|
|
3477
3495
|
readI64LE: () => readI64LE,
|
|
3478
3496
|
readSplMintSupply: () => readSplMintSupply,
|
|
3497
|
+
reconcileManagerWalletBalances: () => reconcileManagerWalletBalances,
|
|
3479
3498
|
refreshLiveOraclePrices: () => refreshLiveOraclePrices,
|
|
3480
3499
|
resolveExternalWithdraw: () => resolveExternalWithdraw,
|
|
3481
3500
|
resolveKeypairPath: () => resolveKeypairPath,
|
|
@@ -3567,16 +3586,16 @@ var USD_STAR_PRINCIPAL_MINT = (0, import_kit.address)(
|
|
|
3567
3586
|
var import_fs = __toESM(require("fs"));
|
|
3568
3587
|
var import_os = __toESM(require("os"));
|
|
3569
3588
|
var import_path = __toESM(require("path"));
|
|
3570
|
-
var
|
|
3571
|
-
var
|
|
3589
|
+
var import_core20 = require("@anchor-lang/core");
|
|
3590
|
+
var import_web323 = require("@solana/web3.js");
|
|
3572
3591
|
var import_kit10 = require("@solana/kit");
|
|
3573
|
-
var
|
|
3592
|
+
var import_common43 = __toESM(require_dist());
|
|
3574
3593
|
|
|
3575
3594
|
// src/client/client.ts
|
|
3576
|
-
var
|
|
3595
|
+
var import_core19 = require("@anchor-lang/core");
|
|
3577
3596
|
var import_kit9 = require("@solana/kit");
|
|
3578
|
-
var
|
|
3579
|
-
var
|
|
3597
|
+
var import_web322 = require("@solana/web3.js");
|
|
3598
|
+
var import_common42 = __toESM(require_dist());
|
|
3580
3599
|
|
|
3581
3600
|
// src/idl/vault.ts
|
|
3582
3601
|
var IDL = {
|
|
@@ -13644,6 +13663,36 @@ var AccountClient = class extends import_common.BaseAccountClient {
|
|
|
13644
13663
|
this.program = program;
|
|
13645
13664
|
this.pda = pda;
|
|
13646
13665
|
}
|
|
13666
|
+
/** Always fresh: report sequences, generations, USD and share counters must not be cached. */
|
|
13667
|
+
async fetchIncentiveV3(incentive) {
|
|
13668
|
+
return this.program.account.vaultIncentiveV3.fetch((0, import_common.toWeb3Pk)(incentive));
|
|
13669
|
+
}
|
|
13670
|
+
async fetchIncentiveV3Nullable(incentive) {
|
|
13671
|
+
return this.program.account.vaultIncentiveV3.fetchNullable(
|
|
13672
|
+
(0, import_common.toWeb3Pk)(incentive)
|
|
13673
|
+
);
|
|
13674
|
+
}
|
|
13675
|
+
async fetchIncentiveV3ForVault(vault, id) {
|
|
13676
|
+
const [incentive] = await this.pda.deriveIncentiveV3Pda(vault, id);
|
|
13677
|
+
return this.fetchIncentiveV3(incentive);
|
|
13678
|
+
}
|
|
13679
|
+
/** Fresh batch lookup preserving input order, duplicates, and missing entries. */
|
|
13680
|
+
async fetchIncentivesV3(incentives) {
|
|
13681
|
+
if (incentives.length === 0) return [];
|
|
13682
|
+
return this.program.account.vaultIncentiveV3.fetchMultiple(
|
|
13683
|
+
incentives.map(import_common.toWeb3Pk)
|
|
13684
|
+
);
|
|
13685
|
+
}
|
|
13686
|
+
/** V3 campaigns only; the discriminator excludes legacy share-denominated accounts. */
|
|
13687
|
+
async fetchAllIncentivesV3ForVault(vault) {
|
|
13688
|
+
const accounts2 = await this.program.account.vaultIncentiveV3.all([
|
|
13689
|
+
{ memcmp: { offset: 8, bytes: vault } }
|
|
13690
|
+
]);
|
|
13691
|
+
return accounts2.map(({ publicKey, account }) => ({
|
|
13692
|
+
publicKey: (0, import_common.fromWeb3Pk)(publicKey),
|
|
13693
|
+
account
|
|
13694
|
+
}));
|
|
13695
|
+
}
|
|
13647
13696
|
/** Always fresh: callers use the proposal round and cumulative entitlements. */
|
|
13648
13697
|
async fetchIncentive(incentive) {
|
|
13649
13698
|
return this.program.account.vaultIncentive.fetch((0, import_common.toWeb3Pk)(incentive));
|
|
@@ -13820,6 +13869,17 @@ var PdaClient = class {
|
|
|
13820
13869
|
seeds: [Buffer.from("incentive"), addressEncoder.encode(vault), bytes]
|
|
13821
13870
|
});
|
|
13822
13871
|
}
|
|
13872
|
+
/** Separate V3 namespace: `["incentive_v3", vault, id_u64_le]`. */
|
|
13873
|
+
async deriveIncentiveV3Pda(vault, id) {
|
|
13874
|
+
if (id < 0n || id > 0xffffffffffffffffn)
|
|
13875
|
+
throw new RangeError("Incentive ID must fit u64");
|
|
13876
|
+
const bytes = new Uint8Array(8);
|
|
13877
|
+
new DataView(bytes.buffer).setBigUint64(0, id, true);
|
|
13878
|
+
return (0, import_kit3.getProgramDerivedAddress)({
|
|
13879
|
+
programAddress: this.programAddress,
|
|
13880
|
+
seeds: [Buffer.from("incentive_v3"), addressEncoder.encode(vault), bytes]
|
|
13881
|
+
});
|
|
13882
|
+
}
|
|
13823
13883
|
/**
|
|
13824
13884
|
* Vault PDA for a global vault id.
|
|
13825
13885
|
*
|
|
@@ -14522,25 +14582,360 @@ var ClaimIncentiveBuilder = class extends VaultBuilderBase {
|
|
|
14522
14582
|
}
|
|
14523
14583
|
};
|
|
14524
14584
|
|
|
14525
|
-
// src/client/builders/
|
|
14526
|
-
var
|
|
14585
|
+
// src/client/builders/incentivesV3.ts
|
|
14586
|
+
var import_core2 = require("@anchor-lang/core");
|
|
14527
14587
|
var import_web35 = require("@solana/web3.js");
|
|
14528
14588
|
var import_common6 = __toESM(require_dist());
|
|
14529
|
-
var
|
|
14589
|
+
var u64 = (value) => {
|
|
14590
|
+
if (value < 0n || value > 0xffffffffffffffffn)
|
|
14591
|
+
throw new RangeError("Incentive value must fit u64");
|
|
14592
|
+
return new import_core2.BN(value.toString());
|
|
14593
|
+
};
|
|
14594
|
+
function validateIndices(indices) {
|
|
14595
|
+
if (indices.length === 0 || indices.length > MAX_INCENTIVE_RECIPIENTS || new Set(indices).size !== indices.length || indices.some(
|
|
14596
|
+
(index) => !Number.isInteger(index) || index < 0 || index >= MAX_INCENTIVE_RECIPIENTS
|
|
14597
|
+
))
|
|
14598
|
+
throw new RangeError(
|
|
14599
|
+
"Supply distinct incentive recipient indices from 0 to 4"
|
|
14600
|
+
);
|
|
14601
|
+
}
|
|
14602
|
+
var CreateIncentiveV3Builder = class extends VaultBuilderBase {
|
|
14530
14603
|
async getIx(args) {
|
|
14531
|
-
return this.program.methods.
|
|
14532
|
-
|
|
14533
|
-
|
|
14604
|
+
return this.program.methods.createIncentiveV3({
|
|
14605
|
+
id: u64(args.id),
|
|
14606
|
+
recipients: args.recipients.map(import_common6.toWeb3Pk),
|
|
14607
|
+
maxTotalUsd: u64(args.maxTotalUsd)
|
|
14608
|
+
}).accountsStrict({
|
|
14609
|
+
oracle: (0, import_common6.toWeb3Pk)(args.oracle),
|
|
14534
14610
|
vault: (0, import_common6.toWeb3Pk)(args.vault),
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
userInputAta: (0, import_common6.toWeb3Pk)(args.userInputAta),
|
|
14538
|
-
queueInputAta: (0, import_common6.toWeb3Pk)(args.queueInputAta),
|
|
14539
|
-
shareTokenProgram: (0, import_common6.toWeb3Pk)(args.shareTokenProgram),
|
|
14540
|
-
associatedTokenProgram: import_spl_token4.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
14611
|
+
vaultOracle: (0, import_common6.toWeb3Pk)(args.vaultOracle),
|
|
14612
|
+
incentive: (0, import_common6.toWeb3Pk)(args.incentive),
|
|
14541
14613
|
systemProgram: import_web35.SystemProgram.programId
|
|
14542
14614
|
}).instruction().then(import_common6.toKitInstruction);
|
|
14543
14615
|
}
|
|
14616
|
+
async deriveIxArgs(args) {
|
|
14617
|
+
const [incentive] = await this.pda.deriveIncentiveV3Pda(
|
|
14618
|
+
args.vault,
|
|
14619
|
+
args.id
|
|
14620
|
+
);
|
|
14621
|
+
const [vaultOracle] = await this.pda.deriveVaultOraclePda(args.vault);
|
|
14622
|
+
return { ...args, incentive, vaultOracle };
|
|
14623
|
+
}
|
|
14624
|
+
async buildPlanExtras(args) {
|
|
14625
|
+
return {
|
|
14626
|
+
postSuccessCacheInvalidations: [
|
|
14627
|
+
{ vaultPda: args.vault, vaultOraclePda: args.vaultOracle }
|
|
14628
|
+
]
|
|
14629
|
+
};
|
|
14630
|
+
}
|
|
14631
|
+
};
|
|
14632
|
+
var AddIncentiveRecipientV3Builder = class extends VaultBuilderBase {
|
|
14633
|
+
async getIx(args) {
|
|
14634
|
+
return this.program.methods.addIncentiveRecipientV3((0, import_common6.toWeb3Pk)(args.wallet)).accountsStrict({
|
|
14635
|
+
oracle: (0, import_common6.toWeb3Pk)(args.oracle),
|
|
14636
|
+
vault: (0, import_common6.toWeb3Pk)(args.vault),
|
|
14637
|
+
vaultOracle: (0, import_common6.toWeb3Pk)(args.vaultOracle),
|
|
14638
|
+
incentive: (0, import_common6.toWeb3Pk)(args.incentive)
|
|
14639
|
+
}).instruction().then(import_common6.toKitInstruction);
|
|
14640
|
+
}
|
|
14641
|
+
async deriveIxArgs(args) {
|
|
14642
|
+
const [vaultOracle] = await this.pda.deriveVaultOraclePda(args.vault);
|
|
14643
|
+
return { ...args, vaultOracle };
|
|
14644
|
+
}
|
|
14645
|
+
async buildPlanExtras(args) {
|
|
14646
|
+
return {
|
|
14647
|
+
postSuccessCacheInvalidations: [
|
|
14648
|
+
{ vaultPda: args.vault, vaultOraclePda: args.vaultOracle }
|
|
14649
|
+
]
|
|
14650
|
+
};
|
|
14651
|
+
}
|
|
14652
|
+
};
|
|
14653
|
+
var SetIncentiveLimitsV3Builder = class extends VaultBuilderBase {
|
|
14654
|
+
async getIx(args) {
|
|
14655
|
+
return this.program.methods.setIncentiveLimitsV3({
|
|
14656
|
+
maxTotalUsd: u64(args.maxTotalUsd),
|
|
14657
|
+
maxSurplusValue: u64(args.maxSurplusValue),
|
|
14658
|
+
minSurplusReserve: u64(args.minSurplusReserve)
|
|
14659
|
+
}).accountsStrict({
|
|
14660
|
+
curator: (0, import_common6.toWeb3Pk)(args.curator),
|
|
14661
|
+
vault: (0, import_common6.toWeb3Pk)(args.vault),
|
|
14662
|
+
incentive: (0, import_common6.toWeb3Pk)(args.incentive)
|
|
14663
|
+
}).instruction().then(import_common6.toKitInstruction);
|
|
14664
|
+
}
|
|
14665
|
+
async buildPlanExtras(args) {
|
|
14666
|
+
return { postSuccessCacheInvalidations: [{ vaultPda: args.vault }] };
|
|
14667
|
+
}
|
|
14668
|
+
};
|
|
14669
|
+
var ReportIncentiveV3Builder = class extends VaultBuilderBase {
|
|
14670
|
+
async getIx(args) {
|
|
14671
|
+
validateIndices(args.updates.map((update) => update.recipientIndex));
|
|
14672
|
+
if (args.sequence <= 0n)
|
|
14673
|
+
throw new RangeError("Incentive sequence must be positive");
|
|
14674
|
+
if (args.expiresAt < -0x8000000000000000n || args.expiresAt > 0x7fffffffffffffffn)
|
|
14675
|
+
throw new RangeError("Incentive expiry must fit i64");
|
|
14676
|
+
return this.program.methods.reportIncentiveV3({
|
|
14677
|
+
signerGeneration: u64(args.signerGeneration),
|
|
14678
|
+
configGeneration: u64(args.configGeneration),
|
|
14679
|
+
sequence: u64(args.sequence),
|
|
14680
|
+
expiresAt: new import_core2.BN(args.expiresAt.toString()),
|
|
14681
|
+
updates: args.updates.map((update) => ({
|
|
14682
|
+
recipientIndex: update.recipientIndex,
|
|
14683
|
+
totalUsd: u64(update.totalUsd)
|
|
14684
|
+
}))
|
|
14685
|
+
}).accountsStrict({
|
|
14686
|
+
oracle: (0, import_common6.toWeb3Pk)(args.oracle),
|
|
14687
|
+
vault: (0, import_common6.toWeb3Pk)(args.vault),
|
|
14688
|
+
vaultOracle: (0, import_common6.toWeb3Pk)(args.vaultOracle),
|
|
14689
|
+
incentive: (0, import_common6.toWeb3Pk)(args.incentive)
|
|
14690
|
+
}).instruction().then(import_common6.toKitInstruction);
|
|
14691
|
+
}
|
|
14692
|
+
async deriveIxArgs(args) {
|
|
14693
|
+
const [vaultOracle] = await this.pda.deriveVaultOraclePda(args.vault);
|
|
14694
|
+
return { ...args, vaultOracle };
|
|
14695
|
+
}
|
|
14696
|
+
async buildPlanExtras(args) {
|
|
14697
|
+
return {
|
|
14698
|
+
postSuccessCacheInvalidations: [
|
|
14699
|
+
{ vaultPda: args.vault, vaultOraclePda: args.vaultOracle }
|
|
14700
|
+
]
|
|
14701
|
+
};
|
|
14702
|
+
}
|
|
14703
|
+
};
|
|
14704
|
+
var SettleIncentiveV3Builder = class extends VaultBuilderBase {
|
|
14705
|
+
async getIx(args) {
|
|
14706
|
+
validateIndices(args.recipientIndices);
|
|
14707
|
+
return this.program.methods.settleIncentiveV3(Buffer.from(args.recipientIndices)).accountsStrict({
|
|
14708
|
+
cranker: (0, import_common6.toWeb3Pk)(args.cranker),
|
|
14709
|
+
vault: (0, import_common6.toWeb3Pk)(args.vault),
|
|
14710
|
+
incentive: (0, import_common6.toWeb3Pk)(args.incentive),
|
|
14711
|
+
vaultOracle: (0, import_common6.toWeb3Pk)(args.vaultOracle),
|
|
14712
|
+
shareMint: (0, import_common6.toWeb3Pk)(args.shareMint),
|
|
14713
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common6.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
14714
|
+
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0, import_common6.toWeb3Pk)(args.juniorTrancheShareMint) : null,
|
|
14715
|
+
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0, import_common6.toWeb3Pk)(args.seniorTrancheShareMint) : null
|
|
14716
|
+
}).instruction().then(import_common6.toKitInstruction);
|
|
14717
|
+
}
|
|
14718
|
+
async deriveIxArgs(args) {
|
|
14719
|
+
const [vaultOracle] = await this.pda.deriveVaultOraclePda(args.vault);
|
|
14720
|
+
const vault = await this.account.fetchVault(args.vault, { fresh: true });
|
|
14721
|
+
const vaultTrancheState = await resolveVaultTrancheState(
|
|
14722
|
+
this.account,
|
|
14723
|
+
this.pda,
|
|
14724
|
+
args.vault,
|
|
14725
|
+
void 0
|
|
14726
|
+
);
|
|
14727
|
+
const tranche = vaultTrancheState ? await this.account.fetchVaultTrancheState(vaultTrancheState, {
|
|
14728
|
+
fresh: true
|
|
14729
|
+
}) : null;
|
|
14730
|
+
return {
|
|
14731
|
+
...args,
|
|
14732
|
+
vaultOracle,
|
|
14733
|
+
shareMint: (0, import_common6.fromWeb3Pk)(vault.mint),
|
|
14734
|
+
vaultTrancheState,
|
|
14735
|
+
juniorTrancheShareMint: tranche ? (0, import_common6.fromWeb3Pk)(tranche.config.juniorMint) : null,
|
|
14736
|
+
seniorTrancheShareMint: tranche ? (0, import_common6.fromWeb3Pk)(tranche.config.seniorMint) : null
|
|
14737
|
+
};
|
|
14738
|
+
}
|
|
14739
|
+
async buildPlanExtras(args) {
|
|
14740
|
+
return {
|
|
14741
|
+
postSuccessCacheInvalidations: [
|
|
14742
|
+
{
|
|
14743
|
+
vaultPda: args.vault,
|
|
14744
|
+
vaultOraclePda: args.vaultOracle,
|
|
14745
|
+
vaultTrancheStatePda: args.vaultTrancheState ?? void 0
|
|
14746
|
+
}
|
|
14747
|
+
]
|
|
14748
|
+
};
|
|
14749
|
+
}
|
|
14750
|
+
};
|
|
14751
|
+
|
|
14752
|
+
// src/client/builders/incentivesV3Claims.ts
|
|
14753
|
+
var import_common8 = __toESM(require_dist());
|
|
14754
|
+
|
|
14755
|
+
// src/utils/incentivesV3.ts
|
|
14756
|
+
var import_web36 = require("@solana/web3.js");
|
|
14757
|
+
var import_common7 = __toESM(require_dist());
|
|
14758
|
+
|
|
14759
|
+
// src/services/consensusOracle/constants.ts
|
|
14760
|
+
var SYSTEM_PROGRAM = "11111111111111111111111111111111";
|
|
14761
|
+
var PRICE_ORACLE_TYPES_BY_INDEX = [
|
|
14762
|
+
"none",
|
|
14763
|
+
"consensusOracle",
|
|
14764
|
+
"pyth",
|
|
14765
|
+
"perenaVault"
|
|
14766
|
+
];
|
|
14767
|
+
var CONSENSUS_ORACLE_VARIANT = "consensusoracle";
|
|
14768
|
+
var LIVE_ORACLE_VARIANTS = /* @__PURE__ */ new Set(["pyth", "perenavault"]);
|
|
14769
|
+
var REPORTABLE_ORACLE_VARIANTS = /* @__PURE__ */ new Set([
|
|
14770
|
+
CONSENSUS_ORACLE_VARIANT,
|
|
14771
|
+
...LIVE_ORACLE_VARIANTS
|
|
14772
|
+
]);
|
|
14773
|
+
var LIVE_PRICE_REFRESH_INTERVAL_SECS = 60n * 60n;
|
|
14774
|
+
var DEFAULT_PRICE_STALENESS_SECS = BigInt(
|
|
14775
|
+
DEFAULT_PRICE_STALENESS_THRESHOLD_SECS
|
|
14776
|
+
);
|
|
14777
|
+
var EXTERNAL_POSITION_SAMPLES = 5;
|
|
14778
|
+
var MIN_EXTERNAL_POSITION_SAMPLES = 4;
|
|
14779
|
+
var ORACLE_ENTRY_SIZE = 272;
|
|
14780
|
+
var ORACLE_ENTRIES_OFFSET = 40;
|
|
14781
|
+
var ORACLE_SETTLED_NAV_TS_OFFSET = 8;
|
|
14782
|
+
var MAX_CONSENSUS_SIGNERS = 4;
|
|
14783
|
+
|
|
14784
|
+
// src/utils/incentivesV3.ts
|
|
14785
|
+
var MAX_INCENTIVE_REPORT_TTL = 86400n;
|
|
14786
|
+
function getIncentiveV3OracleState(oracle, now) {
|
|
14787
|
+
const data = Buffer.from(oracle.data);
|
|
14788
|
+
if (!("consensusOracle" in oracle.oracleType) || data.length !== 2048)
|
|
14789
|
+
throw new RangeError(
|
|
14790
|
+
"Expected a consensus oracle with a 2048-byte payload"
|
|
14791
|
+
);
|
|
14792
|
+
const pendingOffset = ORACLE_ENTRIES_OFFSET + MAX_CONSENSUS_SIGNERS * ORACLE_ENTRY_SIZE;
|
|
14793
|
+
const pendingTimestampOffset = pendingOffset + MAX_CONSENSUS_SIGNERS * 32;
|
|
14794
|
+
const pendingCount = data[pendingTimestampOffset + 8];
|
|
14795
|
+
if (pendingCount > MAX_CONSENSUS_SIGNERS)
|
|
14796
|
+
throw new RangeError("Invalid pending oracle signer count");
|
|
14797
|
+
const matured = pendingCount > 0 && data.readBigInt64LE(pendingTimestampOffset) <= now;
|
|
14798
|
+
const signers = [0, 1].map((index) => {
|
|
14799
|
+
if (matured && index >= pendingCount) return (0, import_common7.fromWeb3Pk)(import_web36.PublicKey.default);
|
|
14800
|
+
const offset = matured ? pendingOffset + index * 32 : ORACLE_ENTRIES_OFFSET + index * ORACLE_ENTRY_SIZE;
|
|
14801
|
+
return (0, import_common7.fromWeb3Pk)(new import_web36.PublicKey(data.subarray(offset, offset + 32)));
|
|
14802
|
+
});
|
|
14803
|
+
if (signers.includes((0, import_common7.fromWeb3Pk)(import_web36.PublicKey.default)) || signers[0] === signers[1])
|
|
14804
|
+
throw new RangeError(
|
|
14805
|
+
"Incentives require two distinct nonzero oracle signers"
|
|
14806
|
+
);
|
|
14807
|
+
const signerGeneration = data.readBigUInt64LE(data.length - 8) + (matured ? 1n : 0n);
|
|
14808
|
+
if (signerGeneration > 0xffffffffffffffffn)
|
|
14809
|
+
throw new RangeError("Oracle signer generation overflow");
|
|
14810
|
+
return { signers, signerGeneration };
|
|
14811
|
+
}
|
|
14812
|
+
function getIncentiveV3Recipients(incentive) {
|
|
14813
|
+
const count = incentive.recipientCount;
|
|
14814
|
+
if (incentive.version !== 3)
|
|
14815
|
+
throw new RangeError("Expected a V3 incentive account");
|
|
14816
|
+
if (!Number.isInteger(count) || count < 0 || count > MAX_INCENTIVE_RECIPIENTS || count > incentive.recipients.length)
|
|
14817
|
+
throw new RangeError("Invalid incentive recipient count");
|
|
14818
|
+
return incentive.recipients.slice(0, count).map((entry, recipientIndex) => {
|
|
14819
|
+
const settledShares = BigInt(entry.settledShares.toString());
|
|
14820
|
+
const claimedShares = BigInt(entry.claimedShares.toString());
|
|
14821
|
+
return {
|
|
14822
|
+
recipientIndex,
|
|
14823
|
+
wallet: (0, import_common7.fromWeb3Pk)(entry.wallet),
|
|
14824
|
+
oracleTotalUsd: [
|
|
14825
|
+
BigInt(entry.oracleTotalUsd[0].toString()),
|
|
14826
|
+
BigInt(entry.oracleTotalUsd[1].toString())
|
|
14827
|
+
],
|
|
14828
|
+
expiresAt: [
|
|
14829
|
+
BigInt(entry.expiresAt[0].toString()),
|
|
14830
|
+
BigInt(entry.expiresAt[1].toString())
|
|
14831
|
+
],
|
|
14832
|
+
settledUsd: BigInt(entry.settledUsd.toString()),
|
|
14833
|
+
settledShares,
|
|
14834
|
+
claimedShares,
|
|
14835
|
+
outstandingShares: settledShares - claimedShares
|
|
14836
|
+
};
|
|
14837
|
+
});
|
|
14838
|
+
}
|
|
14839
|
+
function getIncentiveV3Totals(incentive) {
|
|
14840
|
+
return getIncentiveV3Recipients(incentive).reduce(
|
|
14841
|
+
(totals, recipient) => ({
|
|
14842
|
+
settledUsd: totals.settledUsd + recipient.settledUsd,
|
|
14843
|
+
settledShares: totals.settledShares + recipient.settledShares,
|
|
14844
|
+
claimedShares: totals.claimedShares + recipient.claimedShares,
|
|
14845
|
+
outstandingShares: totals.outstandingShares + recipient.outstandingShares
|
|
14846
|
+
}),
|
|
14847
|
+
{
|
|
14848
|
+
settledUsd: 0n,
|
|
14849
|
+
settledShares: 0n,
|
|
14850
|
+
claimedShares: 0n,
|
|
14851
|
+
outstandingShares: 0n
|
|
14852
|
+
}
|
|
14853
|
+
);
|
|
14854
|
+
}
|
|
14855
|
+
function getIncentiveV3RecipientShareAtas(incentive, shareMint, shareTokenProgram) {
|
|
14856
|
+
return getIncentiveV3Recipients(incentive).map(
|
|
14857
|
+
({ wallet }) => (0, import_common7.getAtaAddress)(shareMint, wallet, shareTokenProgram, true)
|
|
14858
|
+
);
|
|
14859
|
+
}
|
|
14860
|
+
|
|
14861
|
+
// src/client/builders/incentivesV3Claims.ts
|
|
14862
|
+
var ClaimIncentiveV3Builder = class extends ClaimIncentiveBuilder {
|
|
14863
|
+
async getIx(args) {
|
|
14864
|
+
return this.program.methods.claimIncentiveV3().accountsStrict({
|
|
14865
|
+
recipient: (0, import_common8.toWeb3Pk)(args.recipient),
|
|
14866
|
+
vault: (0, import_common8.toWeb3Pk)(args.vault),
|
|
14867
|
+
incentive: (0, import_common8.toWeb3Pk)(args.incentive),
|
|
14868
|
+
shareMint: (0, import_common8.toWeb3Pk)(args.shareMint),
|
|
14869
|
+
shareTokenProgram: (0, import_common8.toWeb3Pk)(args.shareTokenProgram),
|
|
14870
|
+
recipientShareAta: (0, import_common8.toWeb3Pk)(args.recipientShareAta)
|
|
14871
|
+
}).instruction().then(import_common8.toKitInstruction);
|
|
14872
|
+
}
|
|
14873
|
+
};
|
|
14874
|
+
var DistributeIncentiveV3Builder = class extends DistributeIncentiveBuilder {
|
|
14875
|
+
async getIx(args) {
|
|
14876
|
+
return this.program.methods.distributeIncentiveV3().accountsStrict({
|
|
14877
|
+
cranker: (0, import_common8.toWeb3Pk)(args.cranker),
|
|
14878
|
+
vault: (0, import_common8.toWeb3Pk)(args.vault),
|
|
14879
|
+
incentive: (0, import_common8.toWeb3Pk)(args.incentive),
|
|
14880
|
+
shareMint: (0, import_common8.toWeb3Pk)(args.shareMint),
|
|
14881
|
+
shareTokenProgram: (0, import_common8.toWeb3Pk)(args.shareTokenProgram)
|
|
14882
|
+
}).remainingAccounts([
|
|
14883
|
+
...args.recipientShareAtas.map((ata) => ({
|
|
14884
|
+
pubkey: (0, import_common8.toWeb3Pk)(ata),
|
|
14885
|
+
isWritable: true,
|
|
14886
|
+
isSigner: false
|
|
14887
|
+
})),
|
|
14888
|
+
...(args.recipientSigners ?? args.recipients).map((wallet) => ({
|
|
14889
|
+
pubkey: (0, import_common8.toWeb3Pk)(wallet),
|
|
14890
|
+
isWritable: false,
|
|
14891
|
+
isSigner: true
|
|
14892
|
+
}))
|
|
14893
|
+
]).instruction().then(import_common8.toKitInstruction);
|
|
14894
|
+
}
|
|
14895
|
+
async deriveIxArgs(args) {
|
|
14896
|
+
const [vault, incentive] = await Promise.all([
|
|
14897
|
+
this.account.fetchVault(args.vault, { fresh: true }),
|
|
14898
|
+
this.account.fetchIncentiveV3(args.incentive)
|
|
14899
|
+
]);
|
|
14900
|
+
const shareMint = (0, import_common8.fromWeb3Pk)(vault.mint);
|
|
14901
|
+
const shareTokenProgram = tokenProgramAddressFromIdlEnum(
|
|
14902
|
+
vault.mintTokenProgram
|
|
14903
|
+
);
|
|
14904
|
+
const recipients = getIncentiveV3Recipients(incentive);
|
|
14905
|
+
return {
|
|
14906
|
+
...args,
|
|
14907
|
+
shareMint,
|
|
14908
|
+
shareTokenProgram,
|
|
14909
|
+
recipients: recipients.map(({ wallet }) => wallet),
|
|
14910
|
+
recipientSigners: recipients.filter((entry) => entry.outstandingShares > 0n).map(({ wallet }) => wallet),
|
|
14911
|
+
recipientShareAtas: getIncentiveV3RecipientShareAtas(
|
|
14912
|
+
incentive,
|
|
14913
|
+
shareMint,
|
|
14914
|
+
shareTokenProgram
|
|
14915
|
+
)
|
|
14916
|
+
};
|
|
14917
|
+
}
|
|
14918
|
+
};
|
|
14919
|
+
|
|
14920
|
+
// src/client/builders/cancelJuniorTrancheWithdraw.ts
|
|
14921
|
+
var import_spl_token4 = require("@solana/spl-token");
|
|
14922
|
+
var import_web37 = require("@solana/web3.js");
|
|
14923
|
+
var import_common9 = __toESM(require_dist());
|
|
14924
|
+
var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
14925
|
+
async getIx(args) {
|
|
14926
|
+
return this.program.methods.cancelJuniorTrancheWithdraw().accountsPartial({
|
|
14927
|
+
user: (0, import_common9.toWeb3Pk)(args.user),
|
|
14928
|
+
payer: (0, import_common9.toWeb3Pk)(args.payer),
|
|
14929
|
+
vault: (0, import_common9.toWeb3Pk)(args.vault),
|
|
14930
|
+
withdrawalQueue: (0, import_common9.toWeb3Pk)(args.withdrawalQueue),
|
|
14931
|
+
inputMint: (0, import_common9.toWeb3Pk)(args.inputMint),
|
|
14932
|
+
userInputAta: (0, import_common9.toWeb3Pk)(args.userInputAta),
|
|
14933
|
+
queueInputAta: (0, import_common9.toWeb3Pk)(args.queueInputAta),
|
|
14934
|
+
shareTokenProgram: (0, import_common9.toWeb3Pk)(args.shareTokenProgram),
|
|
14935
|
+
associatedTokenProgram: import_spl_token4.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
14936
|
+
systemProgram: import_web37.SystemProgram.programId
|
|
14937
|
+
}).instruction().then(import_common9.toKitInstruction);
|
|
14938
|
+
}
|
|
14544
14939
|
async deriveIxArgs(txArgs) {
|
|
14545
14940
|
const payer = txArgs.payer ?? txArgs.user;
|
|
14546
14941
|
const [[withdrawalQueue], juniorShare] = await Promise.all([
|
|
@@ -14568,8 +14963,8 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14568
14963
|
withdrawalQueue: queuePda,
|
|
14569
14964
|
inputMint: juniorShareMint,
|
|
14570
14965
|
shareTokenProgram,
|
|
14571
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
14572
|
-
queueInputAta: (0,
|
|
14966
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common9.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
14967
|
+
queueInputAta: (0, import_common9.getAtaAddress)(
|
|
14573
14968
|
juniorShareMint,
|
|
14574
14969
|
queuePda,
|
|
14575
14970
|
shareTokenProgram,
|
|
@@ -14587,19 +14982,19 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14587
14982
|
};
|
|
14588
14983
|
|
|
14589
14984
|
// src/client/builders/createAssetHolding.ts
|
|
14590
|
-
var
|
|
14985
|
+
var import_common10 = __toESM(require_dist());
|
|
14591
14986
|
var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
14592
14987
|
async getIx(args) {
|
|
14593
14988
|
return this.program.methods.createAssetHolding({
|
|
14594
14989
|
priceOracleType: args.args.priceOracleType,
|
|
14595
|
-
priceOracleAccount: (0,
|
|
14990
|
+
priceOracleAccount: (0, import_common10.toWeb3Pk)(args.args.priceOracleAccount)
|
|
14596
14991
|
}).accountsPartial({
|
|
14597
|
-
hwManager: (0,
|
|
14598
|
-
vault: (0,
|
|
14599
|
-
vaultOracle: (0,
|
|
14600
|
-
mint: (0,
|
|
14601
|
-
tokenProgram: (0,
|
|
14602
|
-
}).instruction().then(
|
|
14992
|
+
hwManager: (0, import_common10.toWeb3Pk)(args.hwManager),
|
|
14993
|
+
vault: (0, import_common10.toWeb3Pk)(args.vault),
|
|
14994
|
+
vaultOracle: (0, import_common10.toWeb3Pk)(args.vaultOracle),
|
|
14995
|
+
mint: (0, import_common10.toWeb3Pk)(args.mint),
|
|
14996
|
+
tokenProgram: (0, import_common10.toWeb3Pk)(args.tokenProgram)
|
|
14997
|
+
}).instruction().then(import_common10.toKitInstruction);
|
|
14603
14998
|
}
|
|
14604
14999
|
async deriveIxArgs(txArgs) {
|
|
14605
15000
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -14625,15 +15020,15 @@ var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
14625
15020
|
};
|
|
14626
15021
|
|
|
14627
15022
|
// src/client/builders/removeAssetHolding.ts
|
|
14628
|
-
var
|
|
15023
|
+
var import_common11 = __toESM(require_dist());
|
|
14629
15024
|
var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
14630
15025
|
async getIx(args) {
|
|
14631
15026
|
return this.program.methods.removeAssetHolding().accountsPartial({
|
|
14632
|
-
hwManager: (0,
|
|
14633
|
-
vault: (0,
|
|
14634
|
-
vaultOracle: (0,
|
|
14635
|
-
mint: (0,
|
|
14636
|
-
}).instruction().then(
|
|
15027
|
+
hwManager: (0, import_common11.toWeb3Pk)(args.hwManager),
|
|
15028
|
+
vault: (0, import_common11.toWeb3Pk)(args.vault),
|
|
15029
|
+
vaultOracle: (0, import_common11.toWeb3Pk)(args.vaultOracle),
|
|
15030
|
+
mint: (0, import_common11.toWeb3Pk)(args.mint)
|
|
15031
|
+
}).instruction().then(import_common11.toKitInstruction);
|
|
14637
15032
|
}
|
|
14638
15033
|
async deriveIxArgs(txArgs) {
|
|
14639
15034
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -14654,16 +15049,16 @@ var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
14654
15049
|
};
|
|
14655
15050
|
|
|
14656
15051
|
// src/client/builders/updateConsensusSigners.ts
|
|
14657
|
-
var
|
|
15052
|
+
var import_common12 = __toESM(require_dist());
|
|
14658
15053
|
var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
14659
15054
|
async getIx(args) {
|
|
14660
15055
|
return this.program.methods.updateConsensusSigners({
|
|
14661
|
-
signers: args.args.signers.map(
|
|
15056
|
+
signers: args.args.signers.map(import_common12.toWeb3Pk)
|
|
14662
15057
|
}).accountsPartial({
|
|
14663
|
-
curator: (0,
|
|
14664
|
-
vault: (0,
|
|
14665
|
-
vaultOracle: (0,
|
|
14666
|
-
}).instruction().then(
|
|
15058
|
+
curator: (0, import_common12.toWeb3Pk)(args.curator),
|
|
15059
|
+
vault: (0, import_common12.toWeb3Pk)(args.vault),
|
|
15060
|
+
vaultOracle: (0, import_common12.toWeb3Pk)(args.vaultOracle)
|
|
15061
|
+
}).instruction().then(import_common12.toKitInstruction);
|
|
14667
15062
|
}
|
|
14668
15063
|
async deriveIxArgs(txArgs) {
|
|
14669
15064
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -14684,9 +15079,9 @@ var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
|
14684
15079
|
};
|
|
14685
15080
|
|
|
14686
15081
|
// src/client/builders/createTrancheState.ts
|
|
14687
|
-
var
|
|
14688
|
-
var
|
|
14689
|
-
var
|
|
15082
|
+
var import_core3 = require("@anchor-lang/core");
|
|
15083
|
+
var import_web38 = require("@solana/web3.js");
|
|
15084
|
+
var import_common13 = __toESM(require_dist());
|
|
14690
15085
|
var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
14691
15086
|
async getIx(args) {
|
|
14692
15087
|
return this.program.methods.vaultCreateTrancheState({
|
|
@@ -14698,18 +15093,18 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
14698
15093
|
juniorDepositCap: args.juniorDepositCap,
|
|
14699
15094
|
forMigration: args.forMigration
|
|
14700
15095
|
}).accountsPartial({
|
|
14701
|
-
curator: (0,
|
|
14702
|
-
vault: (0,
|
|
14703
|
-
vaultTrancheState: (0,
|
|
14704
|
-
juniorShareMint: (0,
|
|
14705
|
-
seniorShareMint: (0,
|
|
15096
|
+
curator: (0, import_common13.toWeb3Pk)(args.curator),
|
|
15097
|
+
vault: (0, import_common13.toWeb3Pk)(args.vault),
|
|
15098
|
+
vaultTrancheState: (0, import_common13.toWeb3Pk)(args.vaultTrancheState),
|
|
15099
|
+
juniorShareMint: (0, import_common13.toWeb3Pk)(args.juniorShareMint),
|
|
15100
|
+
seniorShareMint: (0, import_common13.toWeb3Pk)(args.seniorShareMint),
|
|
14706
15101
|
// Optional on-chain: required only on the organic path, where the
|
|
14707
15102
|
// program enforces a fresh NAV before enabling tranching. Left null on
|
|
14708
15103
|
// the migration path so Anchor resolves it to the program ID.
|
|
14709
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
14710
|
-
tokenProgram: (0,
|
|
14711
|
-
systemProgram:
|
|
14712
|
-
}).instruction().then(
|
|
15104
|
+
vaultOracle: args.vaultOracle ? (0, import_common13.toWeb3Pk)(args.vaultOracle) : null,
|
|
15105
|
+
tokenProgram: (0, import_common13.toWeb3Pk)(args.tokenProgram),
|
|
15106
|
+
systemProgram: import_web38.SystemProgram.programId
|
|
15107
|
+
}).instruction().then(import_common13.toKitInstruction);
|
|
14713
15108
|
}
|
|
14714
15109
|
async deriveIxArgs(txArgs) {
|
|
14715
15110
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -14738,10 +15133,10 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
14738
15133
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? 0,
|
|
14739
15134
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS,
|
|
14740
15135
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS,
|
|
14741
|
-
targetLockupDurationSecs: new
|
|
15136
|
+
targetLockupDurationSecs: new import_core3.BN(
|
|
14742
15137
|
(txArgs.targetLockupDurationSecs ?? DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS).toString()
|
|
14743
15138
|
),
|
|
14744
|
-
juniorDepositCap: new
|
|
15139
|
+
juniorDepositCap: new import_core3.BN((txArgs.juniorDepositCap ?? 0n).toString()),
|
|
14745
15140
|
forMigration,
|
|
14746
15141
|
tokenProgram: txArgs.tokenProgram ?? TOKEN_PROGRAM_ID
|
|
14747
15142
|
};
|
|
@@ -14756,13 +15151,13 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
14756
15151
|
};
|
|
14757
15152
|
|
|
14758
15153
|
// src/client/builders/activateCircuitBreaker.ts
|
|
14759
|
-
var
|
|
15154
|
+
var import_common14 = __toESM(require_dist());
|
|
14760
15155
|
var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
14761
15156
|
async getIx(args) {
|
|
14762
15157
|
return this.program.methods.activateCircuitBreaker().accountsPartial({
|
|
14763
|
-
cbTrigger: (0,
|
|
14764
|
-
vault: (0,
|
|
14765
|
-
}).instruction().then(
|
|
15158
|
+
cbTrigger: (0, import_common14.toWeb3Pk)(args.cbTrigger),
|
|
15159
|
+
vault: (0, import_common14.toWeb3Pk)(args.vault)
|
|
15160
|
+
}).instruction().then(import_common14.toKitInstruction);
|
|
14766
15161
|
}
|
|
14767
15162
|
async deriveIxArgs(txArgs) {
|
|
14768
15163
|
return txArgs;
|
|
@@ -14775,34 +15170,34 @@ var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
14775
15170
|
};
|
|
14776
15171
|
|
|
14777
15172
|
// src/client/builders/createVault.ts
|
|
14778
|
-
var
|
|
15173
|
+
var import_core5 = require("@anchor-lang/core");
|
|
14779
15174
|
var import_token = require("@solana-program/token");
|
|
14780
15175
|
var import_spl_token5 = require("@solana/spl-token");
|
|
14781
|
-
var
|
|
14782
|
-
var
|
|
15176
|
+
var import_web39 = require("@solana/web3.js");
|
|
15177
|
+
var import_common16 = __toESM(require_dist());
|
|
14783
15178
|
|
|
14784
15179
|
// src/client/builders/anchorArgs.ts
|
|
14785
|
-
var
|
|
14786
|
-
var
|
|
15180
|
+
var import_core4 = require("@anchor-lang/core");
|
|
15181
|
+
var import_common15 = __toESM(require_dist());
|
|
14787
15182
|
function toAnchorCreateVaultParams(params) {
|
|
14788
15183
|
return {
|
|
14789
15184
|
...params,
|
|
14790
|
-
hwManager: (0,
|
|
14791
|
-
cbTrigger: (0,
|
|
14792
|
-
feeCollector: (0,
|
|
14793
|
-
baseAssetMint: (0,
|
|
14794
|
-
basePriceOracleAccount: (0,
|
|
14795
|
-
consensusSigners: params.consensusSigners.map(
|
|
15185
|
+
hwManager: (0, import_common15.toWeb3Pk)(params.hwManager),
|
|
15186
|
+
cbTrigger: (0, import_common15.toWeb3Pk)(params.cbTrigger),
|
|
15187
|
+
feeCollector: (0, import_common15.toWeb3Pk)(params.feeCollector),
|
|
15188
|
+
baseAssetMint: (0, import_common15.toWeb3Pk)(params.baseAssetMint),
|
|
15189
|
+
basePriceOracleAccount: (0, import_common15.toWeb3Pk)(params.basePriceOracleAccount),
|
|
15190
|
+
consensusSigners: params.consensusSigners.map(import_common15.toWeb3Pk)
|
|
14796
15191
|
};
|
|
14797
15192
|
}
|
|
14798
15193
|
function toAnchorSetVaultConfigArgs(args) {
|
|
14799
15194
|
return {
|
|
14800
|
-
manager: args.manager ? (0,
|
|
14801
|
-
hwManager: args.hwManager ? (0,
|
|
14802
|
-
cbTrigger: args.cbTrigger ? (0,
|
|
14803
|
-
fulfiller: args.fulfiller ? (0,
|
|
14804
|
-
feeCollector: args.feeCollector ? (0,
|
|
14805
|
-
newCurator: args.newCurator ? (0,
|
|
15195
|
+
manager: args.manager ? (0, import_common15.toWeb3Pk)(args.manager) : null,
|
|
15196
|
+
hwManager: args.hwManager ? (0, import_common15.toWeb3Pk)(args.hwManager) : null,
|
|
15197
|
+
cbTrigger: args.cbTrigger ? (0, import_common15.toWeb3Pk)(args.cbTrigger) : null,
|
|
15198
|
+
fulfiller: args.fulfiller ? (0, import_common15.toWeb3Pk)(args.fulfiller) : null,
|
|
15199
|
+
feeCollector: args.feeCollector ? (0, import_common15.toWeb3Pk)(args.feeCollector) : null,
|
|
15200
|
+
newCurator: args.newCurator ? (0, import_common15.toWeb3Pk)(args.newCurator) : null,
|
|
14806
15201
|
mintFeeBps: args.mintFeeBps,
|
|
14807
15202
|
burnFeeBps: args.burnFeeBps,
|
|
14808
15203
|
performanceFeeBps: args.performanceFeeBps,
|
|
@@ -14819,9 +15214,9 @@ function toAnchorSetVaultConfigArgs(args) {
|
|
|
14819
15214
|
function toAnchorConsensusUpdates(updates) {
|
|
14820
15215
|
return updates.map((update) => ({
|
|
14821
15216
|
holdingIndex: update.holdingIndex,
|
|
14822
|
-
mint: update.mint ? (0,
|
|
14823
|
-
price: new
|
|
14824
|
-
externalAmount: new
|
|
15217
|
+
mint: update.mint ? (0, import_common15.toWeb3Pk)(update.mint) : null,
|
|
15218
|
+
price: new import_core4.BN(update.price.toString()),
|
|
15219
|
+
externalAmount: new import_core4.BN(update.externalAmount.toString())
|
|
14825
15220
|
}));
|
|
14826
15221
|
}
|
|
14827
15222
|
|
|
@@ -14829,16 +15224,16 @@ function toAnchorConsensusUpdates(updates) {
|
|
|
14829
15224
|
var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
14830
15225
|
async getIx(args) {
|
|
14831
15226
|
return this.program.methods.createVault(toAnchorCreateVaultParams(args.params)).accountsPartial({
|
|
14832
|
-
curator: (0,
|
|
14833
|
-
vault: (0,
|
|
14834
|
-
vaultOracle: (0,
|
|
14835
|
-
feeVault: (0,
|
|
14836
|
-
shareMint: (0,
|
|
14837
|
-
assetMint: (0,
|
|
14838
|
-
assetTokenProgram: (0,
|
|
14839
|
-
tokenProgram: (0,
|
|
14840
|
-
systemProgram:
|
|
14841
|
-
}).instruction().then(
|
|
15227
|
+
curator: (0, import_common16.toWeb3Pk)(args.curator),
|
|
15228
|
+
vault: (0, import_common16.toWeb3Pk)(args.vault),
|
|
15229
|
+
vaultOracle: (0, import_common16.toWeb3Pk)(args.vaultOracle),
|
|
15230
|
+
feeVault: (0, import_common16.toWeb3Pk)(args.feeVault),
|
|
15231
|
+
shareMint: (0, import_common16.toWeb3Pk)(args.shareMint),
|
|
15232
|
+
assetMint: (0, import_common16.toWeb3Pk)(args.assetMint),
|
|
15233
|
+
assetTokenProgram: (0, import_common16.toWeb3Pk)(args.assetTokenProgram),
|
|
15234
|
+
tokenProgram: (0, import_common16.toWeb3Pk)(args.shareTokenProgram ?? TOKEN_PROGRAM_ID),
|
|
15235
|
+
systemProgram: import_web39.SystemProgram.programId
|
|
15236
|
+
}).instruction().then(import_common16.toKitInstruction);
|
|
14842
15237
|
}
|
|
14843
15238
|
async deriveIxArgs(txArgs) {
|
|
14844
15239
|
const vaultId = txArgs.vaultId ?? DEFAULT_VAULT_ID;
|
|
@@ -14867,11 +15262,11 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
14867
15262
|
performanceFeeBps: txArgs.performanceFeeBps ?? 0,
|
|
14868
15263
|
fixedApyBps: txArgs.fixedApyBps ?? 0,
|
|
14869
15264
|
maxApyBps: txArgs.maxApyBps ?? DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
14870
|
-
tvlLimit: new
|
|
15265
|
+
tvlLimit: new import_core5.BN((txArgs.tvlLimit ?? 0n).toString()),
|
|
14871
15266
|
lossesEnabled: txArgs.lossesEnabled ?? false,
|
|
14872
15267
|
initialMintSharePrice: null,
|
|
14873
15268
|
basePriceOracleType: txArgs.basePriceOracleType ?? 1,
|
|
14874
|
-
basePrice: new
|
|
15269
|
+
basePrice: new import_core5.BN(
|
|
14875
15270
|
(txArgs.basePrice ?? 10n ** BigInt(accountingDecimals)).toString()
|
|
14876
15271
|
),
|
|
14877
15272
|
basePriceOracleAccount: txArgs.basePriceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -14883,16 +15278,16 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
14883
15278
|
async getTx(txArgs) {
|
|
14884
15279
|
const args = await this.deriveIxArgs(txArgs);
|
|
14885
15280
|
const createIx = await this.getIx(args);
|
|
14886
|
-
const payer = (0,
|
|
14887
|
-
const assetMint = (0,
|
|
14888
|
-
const assetTokenProgram = (0,
|
|
14889
|
-
const vaultAssetAta = (0,
|
|
15281
|
+
const payer = (0, import_common16.toWeb3Pk)(args.curator);
|
|
15282
|
+
const assetMint = (0, import_common16.toWeb3Pk)(args.assetMint);
|
|
15283
|
+
const assetTokenProgram = (0, import_common16.toWeb3Pk)(args.assetTokenProgram);
|
|
15284
|
+
const vaultAssetAta = (0, import_common16.getAtaAddress)(
|
|
14890
15285
|
args.assetMint,
|
|
14891
15286
|
args.vault,
|
|
14892
15287
|
args.assetTokenProgram,
|
|
14893
15288
|
true
|
|
14894
15289
|
);
|
|
14895
|
-
const feeVaultAta = (0,
|
|
15290
|
+
const feeVaultAta = (0, import_common16.getAtaAddress)(
|
|
14896
15291
|
args.assetMint,
|
|
14897
15292
|
args.feeVault,
|
|
14898
15293
|
args.assetTokenProgram,
|
|
@@ -14900,16 +15295,16 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
14900
15295
|
);
|
|
14901
15296
|
const createVaultAssetAta = (0, import_spl_token5.createAssociatedTokenAccountIdempotentInstruction)(
|
|
14902
15297
|
payer,
|
|
14903
|
-
(0,
|
|
14904
|
-
(0,
|
|
15298
|
+
(0, import_common16.toWeb3Pk)(vaultAssetAta),
|
|
15299
|
+
(0, import_common16.toWeb3Pk)(args.vault),
|
|
14905
15300
|
assetMint,
|
|
14906
15301
|
assetTokenProgram,
|
|
14907
15302
|
import_spl_token5.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
14908
15303
|
);
|
|
14909
15304
|
const createFeeVaultAta = (0, import_spl_token5.createAssociatedTokenAccountIdempotentInstruction)(
|
|
14910
15305
|
payer,
|
|
14911
|
-
(0,
|
|
14912
|
-
(0,
|
|
15306
|
+
(0, import_common16.toWeb3Pk)(feeVaultAta),
|
|
15307
|
+
(0, import_common16.toWeb3Pk)(args.feeVault),
|
|
14913
15308
|
assetMint,
|
|
14914
15309
|
assetTokenProgram,
|
|
14915
15310
|
import_spl_token5.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
@@ -14917,8 +15312,8 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
14917
15312
|
return {
|
|
14918
15313
|
instructions: [
|
|
14919
15314
|
createIx,
|
|
14920
|
-
(0,
|
|
14921
|
-
(0,
|
|
15315
|
+
(0, import_common16.toKitInstruction)(createVaultAssetAta),
|
|
15316
|
+
(0, import_common16.toKitInstruction)(createFeeVaultAta)
|
|
14922
15317
|
],
|
|
14923
15318
|
postSuccessCacheInvalidations: [
|
|
14924
15319
|
{ vaultPda: args.vault, vaultOraclePda: args.vaultOracle }
|
|
@@ -14928,16 +15323,16 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
14928
15323
|
};
|
|
14929
15324
|
|
|
14930
15325
|
// src/client/builders/initializeVaultRoles.ts
|
|
14931
|
-
var
|
|
15326
|
+
var import_common17 = __toESM(require_dist());
|
|
14932
15327
|
var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
14933
15328
|
async getIx(args) {
|
|
14934
15329
|
return this.program.methods.initializeVaultRoles({
|
|
14935
|
-
manager: (0,
|
|
14936
|
-
fulfiller: (0,
|
|
15330
|
+
manager: (0, import_common17.toWeb3Pk)(args.args.manager),
|
|
15331
|
+
fulfiller: (0, import_common17.toWeb3Pk)(args.args.fulfiller)
|
|
14937
15332
|
}).accountsPartial({
|
|
14938
|
-
curator: (0,
|
|
14939
|
-
vault: (0,
|
|
14940
|
-
}).instruction().then(
|
|
15333
|
+
curator: (0, import_common17.toWeb3Pk)(args.curator),
|
|
15334
|
+
vault: (0, import_common17.toWeb3Pk)(args.vault)
|
|
15335
|
+
}).instruction().then(import_common17.toKitInstruction);
|
|
14941
15336
|
}
|
|
14942
15337
|
async deriveIxArgs(txArgs) {
|
|
14943
15338
|
return {
|
|
@@ -14957,13 +15352,13 @@ var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
|
14957
15352
|
};
|
|
14958
15353
|
|
|
14959
15354
|
// src/client/builders/disableCircuitBreaker.ts
|
|
14960
|
-
var
|
|
15355
|
+
var import_common18 = __toESM(require_dist());
|
|
14961
15356
|
var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
14962
15357
|
async getIx(args) {
|
|
14963
15358
|
return this.program.methods.disableCircuitBreaker().accountsPartial({
|
|
14964
|
-
curator: (0,
|
|
14965
|
-
vault: (0,
|
|
14966
|
-
}).instruction().then(
|
|
15359
|
+
curator: (0, import_common18.toWeb3Pk)(args.curator),
|
|
15360
|
+
vault: (0, import_common18.toWeb3Pk)(args.vault)
|
|
15361
|
+
}).instruction().then(import_common18.toKitInstruction);
|
|
14967
15362
|
}
|
|
14968
15363
|
async deriveIxArgs(txArgs) {
|
|
14969
15364
|
return txArgs;
|
|
@@ -14976,15 +15371,15 @@ var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
14976
15371
|
};
|
|
14977
15372
|
|
|
14978
15373
|
// src/client/builders/setVaultConfig.ts
|
|
14979
|
-
var
|
|
14980
|
-
var
|
|
15374
|
+
var import_core6 = require("@anchor-lang/core");
|
|
15375
|
+
var import_common19 = __toESM(require_dist());
|
|
14981
15376
|
var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
14982
15377
|
async getIx(args) {
|
|
14983
15378
|
return this.program.methods.setVaultConfig(toAnchorSetVaultConfigArgs(args.args)).accountsPartial({
|
|
14984
|
-
curator: (0,
|
|
14985
|
-
vault: (0,
|
|
14986
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
14987
|
-
}).instruction().then(
|
|
15379
|
+
curator: (0, import_common19.toWeb3Pk)(args.curator),
|
|
15380
|
+
vault: (0, import_common19.toWeb3Pk)(args.vault),
|
|
15381
|
+
vaultOracle: args.vaultOracle ? (0, import_common19.toWeb3Pk)(args.vaultOracle) : null
|
|
15382
|
+
}).instruction().then(import_common19.toKitInstruction);
|
|
14988
15383
|
}
|
|
14989
15384
|
async deriveIxArgs(txArgs) {
|
|
14990
15385
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15006,28 +15401,28 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15006
15401
|
performanceFeeBps: txArgs.performanceFeeBps ?? null,
|
|
15007
15402
|
fixedApyBps: txArgs.fixedApyBps ?? null,
|
|
15008
15403
|
maxApyBps: txArgs.maxApyBps ?? null,
|
|
15009
|
-
tvlLimit: txArgs.tvlLimit !== void 0 ? new
|
|
15404
|
+
tvlLimit: txArgs.tvlLimit !== void 0 ? new import_core6.BN(txArgs.tvlLimit.toString()) : null,
|
|
15010
15405
|
lossesEnabled: txArgs.lossesEnabled ?? null,
|
|
15011
|
-
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new
|
|
15406
|
+
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new import_core6.BN(txArgs.priceStalenessThresholdSecs.toString()) : null,
|
|
15012
15407
|
userBurnLimit: txArgs.userBurnLimit !== void 0 ? {
|
|
15013
|
-
windowLimit: new
|
|
15408
|
+
windowLimit: new import_core6.BN(
|
|
15014
15409
|
txArgs.userBurnLimit.windowLimit.toString()
|
|
15015
15410
|
),
|
|
15016
|
-
windowDurationSeconds: new
|
|
15411
|
+
windowDurationSeconds: new import_core6.BN(
|
|
15017
15412
|
txArgs.userBurnLimit.windowDurationSeconds.toString()
|
|
15018
15413
|
)
|
|
15019
15414
|
} : null,
|
|
15020
15415
|
managerPullLimit: txArgs.managerPullLimit !== void 0 ? {
|
|
15021
|
-
windowLimit: new
|
|
15416
|
+
windowLimit: new import_core6.BN(
|
|
15022
15417
|
txArgs.managerPullLimit.windowLimit.toString()
|
|
15023
15418
|
),
|
|
15024
|
-
windowDurationSeconds: new
|
|
15419
|
+
windowDurationSeconds: new import_core6.BN(
|
|
15025
15420
|
txArgs.managerPullLimit.windowDurationSeconds.toString()
|
|
15026
15421
|
)
|
|
15027
15422
|
} : null,
|
|
15028
15423
|
rebalanceLimit: txArgs.rebalanceLimit !== void 0 ? {
|
|
15029
15424
|
windowLimitBps: txArgs.rebalanceLimit.windowLimitBps,
|
|
15030
|
-
windowDurationSeconds: new
|
|
15425
|
+
windowDurationSeconds: new import_core6.BN(
|
|
15031
15426
|
txArgs.rebalanceLimit.windowDurationSeconds.toString()
|
|
15032
15427
|
)
|
|
15033
15428
|
} : null
|
|
@@ -15042,14 +15437,14 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15042
15437
|
};
|
|
15043
15438
|
|
|
15044
15439
|
// src/client/builders/setProtocolFee.ts
|
|
15045
|
-
var
|
|
15440
|
+
var import_common20 = __toESM(require_dist());
|
|
15046
15441
|
var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
15047
15442
|
async getIx(args) {
|
|
15048
15443
|
return this.program.methods.setProtocolFee({ protocolFeeBps: args.args.protocolFeeBps }).accountsPartial({
|
|
15049
|
-
protocolAuthority: (0,
|
|
15050
|
-
vault: (0,
|
|
15051
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15052
|
-
}).instruction().then(
|
|
15444
|
+
protocolAuthority: (0, import_common20.toWeb3Pk)(args.protocolAuthority),
|
|
15445
|
+
vault: (0, import_common20.toWeb3Pk)(args.vault),
|
|
15446
|
+
vaultOracle: args.vaultOracle ? (0, import_common20.toWeb3Pk)(args.vaultOracle) : null
|
|
15447
|
+
}).instruction().then(import_common20.toKitInstruction);
|
|
15053
15448
|
}
|
|
15054
15449
|
async deriveIxArgs(txArgs) {
|
|
15055
15450
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15075,11 +15470,11 @@ var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
|
15075
15470
|
// src/client/builders/crankNav.ts
|
|
15076
15471
|
var import_spl_token6 = require("@solana/spl-token");
|
|
15077
15472
|
var import_kit6 = require("@solana/kit");
|
|
15078
|
-
var
|
|
15079
|
-
var
|
|
15473
|
+
var import_web310 = require("@solana/web3.js");
|
|
15474
|
+
var import_common22 = __toESM(require_dist());
|
|
15080
15475
|
|
|
15081
15476
|
// src/client/builders/feeCollector.ts
|
|
15082
|
-
var
|
|
15477
|
+
var import_common21 = __toESM(require_dist());
|
|
15083
15478
|
function resolveProtocolFeeRecipient(override) {
|
|
15084
15479
|
return override ?? PROTOCOL_FEE_RECIPIENT;
|
|
15085
15480
|
}
|
|
@@ -15088,14 +15483,14 @@ async function resolveVaultFeeCollector(account, vault, override) {
|
|
|
15088
15483
|
return override;
|
|
15089
15484
|
}
|
|
15090
15485
|
const vaultState = await account.fetchVault(vault);
|
|
15091
|
-
return (0,
|
|
15486
|
+
return (0, import_common21.fromWeb3Pk)(vaultState.roles.feeCollector);
|
|
15092
15487
|
}
|
|
15093
15488
|
function baseAssetMintFromVault(vaultState) {
|
|
15094
15489
|
const baseHolding = vaultState.holdings.find((holding) => holding.isBase);
|
|
15095
15490
|
if (!baseHolding) {
|
|
15096
15491
|
throw new Error("Vault has no base asset holding");
|
|
15097
15492
|
}
|
|
15098
|
-
return (0,
|
|
15493
|
+
return (0, import_common21.fromWeb3Pk)(baseHolding.mint);
|
|
15099
15494
|
}
|
|
15100
15495
|
async function resolveVaultBaseAssetMint(account, vault, override) {
|
|
15101
15496
|
if (override) {
|
|
@@ -15110,7 +15505,7 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15110
15505
|
}
|
|
15111
15506
|
const vaultState = await account.fetchVault(vault);
|
|
15112
15507
|
const holding = vaultState.holdings.find(
|
|
15113
|
-
(entry) => (0,
|
|
15508
|
+
(entry) => (0, import_common21.fromWeb3Pk)(entry.mint) === feeAssetMint
|
|
15114
15509
|
);
|
|
15115
15510
|
if (!holding) {
|
|
15116
15511
|
return TOKEN_PROGRAM_ID;
|
|
@@ -15122,21 +15517,21 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15122
15517
|
var CrankNavBuilder = class extends VaultBuilderBase {
|
|
15123
15518
|
async getIx(args) {
|
|
15124
15519
|
return this.program.methods.crankNav().accountsPartial({
|
|
15125
|
-
cranker: (0,
|
|
15126
|
-
vault: (0,
|
|
15127
|
-
vaultOracle: (0,
|
|
15128
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
15129
|
-
shareMint: (0,
|
|
15130
|
-
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0,
|
|
15131
|
-
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0,
|
|
15132
|
-
feeAssetMint: (0,
|
|
15133
|
-
vaultFeeAssetAta: (0,
|
|
15134
|
-
feeVault: (0,
|
|
15135
|
-
feeVaultAta: (0,
|
|
15136
|
-
feeAssetTokenProgram: (0,
|
|
15520
|
+
cranker: (0, import_common22.toWeb3Pk)(args.cranker),
|
|
15521
|
+
vault: (0, import_common22.toWeb3Pk)(args.vault),
|
|
15522
|
+
vaultOracle: (0, import_common22.toWeb3Pk)(args.vaultOracle),
|
|
15523
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common22.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
15524
|
+
shareMint: (0, import_common22.toWeb3Pk)(args.shareMint),
|
|
15525
|
+
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0, import_common22.toWeb3Pk)(args.juniorTrancheShareMint) : null,
|
|
15526
|
+
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0, import_common22.toWeb3Pk)(args.seniorTrancheShareMint) : null,
|
|
15527
|
+
feeAssetMint: (0, import_common22.toWeb3Pk)(args.feeAssetMint),
|
|
15528
|
+
vaultFeeAssetAta: (0, import_common22.toWeb3Pk)(args.vaultFeeAssetAta),
|
|
15529
|
+
feeVault: (0, import_common22.toWeb3Pk)(args.feeVault),
|
|
15530
|
+
feeVaultAta: (0, import_common22.toWeb3Pk)(args.feeVaultAta),
|
|
15531
|
+
feeAssetTokenProgram: (0, import_common22.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15137
15532
|
associatedTokenProgram: import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15138
|
-
systemProgram:
|
|
15139
|
-
}).instruction().then(
|
|
15533
|
+
systemProgram: import_web310.SystemProgram.programId
|
|
15534
|
+
}).instruction().then(import_common22.toKitInstruction);
|
|
15140
15535
|
}
|
|
15141
15536
|
async deriveIxArgs(txArgs) {
|
|
15142
15537
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15186,13 +15581,13 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15186
15581
|
seniorTrancheShareMint,
|
|
15187
15582
|
feeAssetMint,
|
|
15188
15583
|
feeVault,
|
|
15189
|
-
vaultFeeAssetAta: (0,
|
|
15584
|
+
vaultFeeAssetAta: (0, import_common22.getAtaAddress)(
|
|
15190
15585
|
feeAssetMint,
|
|
15191
15586
|
txArgs.vault,
|
|
15192
15587
|
feeAssetTokenProgram,
|
|
15193
15588
|
true
|
|
15194
15589
|
),
|
|
15195
|
-
feeVaultAta: (0,
|
|
15590
|
+
feeVaultAta: (0, import_common22.getAtaAddress)(
|
|
15196
15591
|
feeAssetMint,
|
|
15197
15592
|
feeVault,
|
|
15198
15593
|
feeAssetTokenProgram,
|
|
@@ -15202,25 +15597,25 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15202
15597
|
};
|
|
15203
15598
|
}
|
|
15204
15599
|
async buildPreambleInstructions(args) {
|
|
15205
|
-
const payer = (0,
|
|
15600
|
+
const payer = (0, import_common22.toWeb3Pk)(args.cranker);
|
|
15206
15601
|
return [
|
|
15207
15602
|
(0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15208
15603
|
payer,
|
|
15209
|
-
(0,
|
|
15210
|
-
(0,
|
|
15211
|
-
(0,
|
|
15212
|
-
(0,
|
|
15604
|
+
(0, import_common22.toWeb3Pk)(args.vaultFeeAssetAta),
|
|
15605
|
+
(0, import_common22.toWeb3Pk)(args.vault),
|
|
15606
|
+
(0, import_common22.toWeb3Pk)(args.feeAssetMint),
|
|
15607
|
+
(0, import_common22.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15213
15608
|
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15214
15609
|
),
|
|
15215
15610
|
(0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15216
15611
|
payer,
|
|
15217
|
-
(0,
|
|
15218
|
-
(0,
|
|
15219
|
-
(0,
|
|
15220
|
-
(0,
|
|
15612
|
+
(0, import_common22.toWeb3Pk)(args.feeVaultAta),
|
|
15613
|
+
(0, import_common22.toWeb3Pk)(args.feeVault),
|
|
15614
|
+
(0, import_common22.toWeb3Pk)(args.feeAssetMint),
|
|
15615
|
+
(0, import_common22.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15221
15616
|
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15222
15617
|
)
|
|
15223
|
-
].map(
|
|
15618
|
+
].map(import_common22.toKitInstruction);
|
|
15224
15619
|
}
|
|
15225
15620
|
async buildPlanExtras(args) {
|
|
15226
15621
|
return {
|
|
@@ -15247,28 +15642,28 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15247
15642
|
|
|
15248
15643
|
// src/client/builders/crankPerformanceFees.ts
|
|
15249
15644
|
var import_spl_token7 = require("@solana/spl-token");
|
|
15250
|
-
var
|
|
15251
|
-
var
|
|
15645
|
+
var import_web311 = require("@solana/web3.js");
|
|
15646
|
+
var import_common23 = __toESM(require_dist());
|
|
15252
15647
|
var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
15253
15648
|
async getIx(args) {
|
|
15254
15649
|
return this.program.methods.crankPerformanceFees().accountsPartial({
|
|
15255
|
-
cranker: (0,
|
|
15256
|
-
vault: (0,
|
|
15257
|
-
shareMint: (0,
|
|
15258
|
-
feeCollector: (0,
|
|
15259
|
-
feeCollectorShareAta: (0,
|
|
15260
|
-
protocolFeeCollector: (0,
|
|
15261
|
-
protocolFeeCollectorShareAta: (0,
|
|
15650
|
+
cranker: (0, import_common23.toWeb3Pk)(args.cranker),
|
|
15651
|
+
vault: (0, import_common23.toWeb3Pk)(args.vault),
|
|
15652
|
+
shareMint: (0, import_common23.toWeb3Pk)(args.shareMint),
|
|
15653
|
+
feeCollector: (0, import_common23.toWeb3Pk)(args.feeCollector),
|
|
15654
|
+
feeCollectorShareAta: (0, import_common23.toWeb3Pk)(args.feeCollectorShareAta),
|
|
15655
|
+
protocolFeeCollector: (0, import_common23.toWeb3Pk)(args.protocolFeeCollector),
|
|
15656
|
+
protocolFeeCollectorShareAta: (0, import_common23.toWeb3Pk)(
|
|
15262
15657
|
args.protocolFeeCollectorShareAta
|
|
15263
15658
|
),
|
|
15264
|
-
shareTokenProgram: (0,
|
|
15659
|
+
shareTokenProgram: (0, import_common23.toWeb3Pk)(args.shareTokenProgram),
|
|
15265
15660
|
associatedTokenProgram: import_spl_token7.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15266
|
-
systemProgram:
|
|
15267
|
-
}).instruction().then(
|
|
15661
|
+
systemProgram: import_web311.SystemProgram.programId
|
|
15662
|
+
}).instruction().then(import_common23.toKitInstruction);
|
|
15268
15663
|
}
|
|
15269
15664
|
async deriveIxArgs(txArgs) {
|
|
15270
15665
|
const vaultState = await this.account.fetchVault(txArgs.vault);
|
|
15271
|
-
const shareMint = (0,
|
|
15666
|
+
const shareMint = (0, import_common23.fromWeb3Pk)(vaultState.mint);
|
|
15272
15667
|
const shareTokenProgram = txArgs.shareTokenProgram ?? tokenProgramAddressFromIdlEnum(vaultState.mintTokenProgram);
|
|
15273
15668
|
const feeCollector = await resolveVaultFeeCollector(
|
|
15274
15669
|
this.account,
|
|
@@ -15285,7 +15680,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15285
15680
|
feeCollector,
|
|
15286
15681
|
// The vault fee collector is a role that is routinely a Squads vault
|
|
15287
15682
|
// (off-curve PDA), so allow an off-curve owner here too.
|
|
15288
|
-
feeCollectorShareAta: (0,
|
|
15683
|
+
feeCollectorShareAta: (0, import_common23.getAtaAddress)(
|
|
15289
15684
|
shareMint,
|
|
15290
15685
|
feeCollector,
|
|
15291
15686
|
shareTokenProgram,
|
|
@@ -15295,7 +15690,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15295
15690
|
// The protocol fee recipient is a hardcoded protocol-controlled address
|
|
15296
15691
|
// that may be off-curve (e.g. a PDA / multisig vault), so allow an
|
|
15297
15692
|
// off-curve owner when deriving its ATA.
|
|
15298
|
-
protocolFeeCollectorShareAta: (0,
|
|
15693
|
+
protocolFeeCollectorShareAta: (0, import_common23.getAtaAddress)(
|
|
15299
15694
|
shareMint,
|
|
15300
15695
|
protocolFeeCollector,
|
|
15301
15696
|
shareTokenProgram,
|
|
@@ -15321,7 +15716,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15321
15716
|
};
|
|
15322
15717
|
|
|
15323
15718
|
// src/client/builders/setExternalLiquidity.ts
|
|
15324
|
-
var
|
|
15719
|
+
var import_common24 = __toESM(require_dist());
|
|
15325
15720
|
function toExternalLiquiditySource(source) {
|
|
15326
15721
|
switch (source) {
|
|
15327
15722
|
case 0:
|
|
@@ -15337,11 +15732,11 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15337
15732
|
return this.program.methods.setExternalLiquidity({
|
|
15338
15733
|
index: args.args.index,
|
|
15339
15734
|
source: args.args.source,
|
|
15340
|
-
userAccount: (0,
|
|
15735
|
+
userAccount: (0, import_common24.toWeb3Pk)(args.args.userAccount)
|
|
15341
15736
|
}).accountsPartial({
|
|
15342
|
-
curator: (0,
|
|
15343
|
-
vault: (0,
|
|
15344
|
-
}).instruction().then(
|
|
15737
|
+
curator: (0, import_common24.toWeb3Pk)(args.curator),
|
|
15738
|
+
vault: (0, import_common24.toWeb3Pk)(args.vault)
|
|
15739
|
+
}).instruction().then(import_common24.toKitInstruction);
|
|
15345
15740
|
}
|
|
15346
15741
|
async deriveIxArgs(txArgs) {
|
|
15347
15742
|
return {
|
|
@@ -15362,16 +15757,16 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15362
15757
|
};
|
|
15363
15758
|
|
|
15364
15759
|
// src/client/builders/setManagerWithdrawDestination.ts
|
|
15365
|
-
var
|
|
15760
|
+
var import_common25 = __toESM(require_dist());
|
|
15366
15761
|
var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
15367
15762
|
async getIx(args) {
|
|
15368
15763
|
return this.program.methods.setManagerWithdrawDestination({
|
|
15369
15764
|
slot: args.args.slot,
|
|
15370
|
-
address: (0,
|
|
15765
|
+
address: (0, import_common25.toWeb3Pk)(args.args.address)
|
|
15371
15766
|
}).accountsPartial({
|
|
15372
|
-
curator: (0,
|
|
15373
|
-
vault: (0,
|
|
15374
|
-
}).instruction().then(
|
|
15767
|
+
curator: (0, import_common25.toWeb3Pk)(args.curator),
|
|
15768
|
+
vault: (0, import_common25.toWeb3Pk)(args.vault)
|
|
15769
|
+
}).instruction().then(import_common25.toKitInstruction);
|
|
15375
15770
|
}
|
|
15376
15771
|
async deriveIxArgs(txArgs) {
|
|
15377
15772
|
return {
|
|
@@ -15391,17 +15786,17 @@ var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
|
15391
15786
|
};
|
|
15392
15787
|
|
|
15393
15788
|
// src/client/builders/setAssetPriceOracle.ts
|
|
15394
|
-
var
|
|
15789
|
+
var import_common26 = __toESM(require_dist());
|
|
15395
15790
|
var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
15396
15791
|
async getIx(args) {
|
|
15397
15792
|
return this.program.methods.setAssetPriceOracle({
|
|
15398
|
-
mint: (0,
|
|
15793
|
+
mint: (0, import_common26.toWeb3Pk)(args.args.mint),
|
|
15399
15794
|
priceOracleType: args.args.priceOracleType,
|
|
15400
|
-
priceOracleAccount: (0,
|
|
15795
|
+
priceOracleAccount: (0, import_common26.toWeb3Pk)(args.args.priceOracleAccount)
|
|
15401
15796
|
}).accountsPartial({
|
|
15402
|
-
curator: (0,
|
|
15403
|
-
vault: (0,
|
|
15404
|
-
}).instruction().then(
|
|
15797
|
+
curator: (0, import_common26.toWeb3Pk)(args.curator),
|
|
15798
|
+
vault: (0, import_common26.toWeb3Pk)(args.vault)
|
|
15799
|
+
}).instruction().then(import_common26.toKitInstruction);
|
|
15405
15800
|
}
|
|
15406
15801
|
async deriveIxArgs(txArgs) {
|
|
15407
15802
|
return {
|
|
@@ -15422,19 +15817,19 @@ var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
|
15422
15817
|
};
|
|
15423
15818
|
|
|
15424
15819
|
// src/client/builders/updateAssetPrice.ts
|
|
15425
|
-
var
|
|
15426
|
-
var
|
|
15820
|
+
var import_core7 = require("@anchor-lang/core");
|
|
15821
|
+
var import_common27 = __toESM(require_dist());
|
|
15427
15822
|
var DEFAULT_PRICE_MAX_AGE_SECS = 90n;
|
|
15428
15823
|
var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
15429
15824
|
async getIx(args) {
|
|
15430
15825
|
return this.program.methods.updateAssetPrice({
|
|
15431
|
-
mint: (0,
|
|
15826
|
+
mint: (0, import_common27.toWeb3Pk)(args.args.mint),
|
|
15432
15827
|
maxAgeSecs: args.args.maxAgeSecs
|
|
15433
15828
|
}).accountsPartial({
|
|
15434
|
-
updater: (0,
|
|
15435
|
-
vault: (0,
|
|
15436
|
-
oracleAccount: (0,
|
|
15437
|
-
}).instruction().then(
|
|
15829
|
+
updater: (0, import_common27.toWeb3Pk)(args.updater),
|
|
15830
|
+
vault: (0, import_common27.toWeb3Pk)(args.vault),
|
|
15831
|
+
oracleAccount: (0, import_common27.toWeb3Pk)(args.oracleAccount)
|
|
15832
|
+
}).instruction().then(import_common27.toKitInstruction);
|
|
15438
15833
|
}
|
|
15439
15834
|
async deriveIxArgs(txArgs) {
|
|
15440
15835
|
return {
|
|
@@ -15443,7 +15838,7 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15443
15838
|
oracleAccount: txArgs.oracleAccount,
|
|
15444
15839
|
args: {
|
|
15445
15840
|
mint: txArgs.mint,
|
|
15446
|
-
maxAgeSecs: new
|
|
15841
|
+
maxAgeSecs: new import_core7.BN(
|
|
15447
15842
|
(txArgs.maxAgeSecs ?? DEFAULT_PRICE_MAX_AGE_SECS).toString()
|
|
15448
15843
|
)
|
|
15449
15844
|
}
|
|
@@ -15466,18 +15861,18 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15466
15861
|
};
|
|
15467
15862
|
|
|
15468
15863
|
// src/client/builders/updateConsensusOracle.ts
|
|
15469
|
-
var
|
|
15864
|
+
var import_common28 = __toESM(require_dist());
|
|
15470
15865
|
var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
15471
15866
|
async getIx(args) {
|
|
15472
15867
|
return this.program.methods.updateConsensusOracle({
|
|
15473
15868
|
updates: toAnchorConsensusUpdates(args.updates)
|
|
15474
15869
|
}).accountsPartial({
|
|
15475
|
-
signer: (0,
|
|
15476
|
-
vault: (0,
|
|
15477
|
-
vaultOracle: (0,
|
|
15478
|
-
assetMint: args.assetMint ? (0,
|
|
15479
|
-
assetTokenProgram: args.assetTokenProgram ? (0,
|
|
15480
|
-
}).instruction().then(
|
|
15870
|
+
signer: (0, import_common28.toWeb3Pk)(args.signer),
|
|
15871
|
+
vault: (0, import_common28.toWeb3Pk)(args.vault),
|
|
15872
|
+
vaultOracle: (0, import_common28.toWeb3Pk)(args.vaultOracle),
|
|
15873
|
+
assetMint: args.assetMint ? (0, import_common28.toWeb3Pk)(args.assetMint) : null,
|
|
15874
|
+
assetTokenProgram: args.assetTokenProgram ? (0, import_common28.toWeb3Pk)(args.assetTokenProgram) : null
|
|
15875
|
+
}).instruction().then(import_common28.toKitInstruction);
|
|
15481
15876
|
}
|
|
15482
15877
|
async deriveIxArgs(txArgs) {
|
|
15483
15878
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15521,25 +15916,25 @@ var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
|
15521
15916
|
};
|
|
15522
15917
|
|
|
15523
15918
|
// src/client/builders/executeShareSwap.ts
|
|
15524
|
-
var
|
|
15919
|
+
var import_core8 = require("@anchor-lang/core");
|
|
15525
15920
|
var import_spl_token8 = require("@solana/spl-token");
|
|
15526
|
-
var
|
|
15527
|
-
var
|
|
15921
|
+
var import_web312 = require("@solana/web3.js");
|
|
15922
|
+
var import_common29 = __toESM(require_dist());
|
|
15528
15923
|
var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
15529
15924
|
getIxAccounts(args) {
|
|
15530
15925
|
return {
|
|
15531
|
-
user: (0,
|
|
15532
|
-
vault: (0,
|
|
15533
|
-
vaultOracle: (0,
|
|
15534
|
-
vaultTrancheState: (0,
|
|
15535
|
-
shareMint: (0,
|
|
15536
|
-
trancheShareMint: (0,
|
|
15537
|
-
userShareAta: (0,
|
|
15538
|
-
userTrancheShareAta: (0,
|
|
15539
|
-
shareTokenProgram: (0,
|
|
15540
|
-
trancheShareTokenProgram: (0,
|
|
15926
|
+
user: (0, import_common29.toWeb3Pk)(args.user),
|
|
15927
|
+
vault: (0, import_common29.toWeb3Pk)(args.vault),
|
|
15928
|
+
vaultOracle: (0, import_common29.toWeb3Pk)(args.vaultOracle),
|
|
15929
|
+
vaultTrancheState: (0, import_common29.toWeb3Pk)(args.vaultTrancheState),
|
|
15930
|
+
shareMint: (0, import_common29.toWeb3Pk)(args.shareMint),
|
|
15931
|
+
trancheShareMint: (0, import_common29.toWeb3Pk)(args.trancheShareMint),
|
|
15932
|
+
userShareAta: (0, import_common29.toWeb3Pk)(args.userShareAta),
|
|
15933
|
+
userTrancheShareAta: (0, import_common29.toWeb3Pk)(args.userTrancheShareAta),
|
|
15934
|
+
shareTokenProgram: (0, import_common29.toWeb3Pk)(args.shareTokenProgram),
|
|
15935
|
+
trancheShareTokenProgram: (0, import_common29.toWeb3Pk)(args.trancheShareTokenProgram),
|
|
15541
15936
|
associatedTokenProgram: import_spl_token8.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15542
|
-
systemProgram:
|
|
15937
|
+
systemProgram: import_web312.SystemProgram.programId
|
|
15543
15938
|
};
|
|
15544
15939
|
}
|
|
15545
15940
|
getIxData(args) {
|
|
@@ -15550,7 +15945,7 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15550
15945
|
}
|
|
15551
15946
|
async getIx(args) {
|
|
15552
15947
|
const data = this.getIxData(args);
|
|
15553
|
-
return this.program.methods.executeShareSwap(data.kind, data.shareAmount).accountsPartial(this.getIxAccounts(args)).instruction().then(
|
|
15948
|
+
return this.program.methods.executeShareSwap(data.kind, data.shareAmount).accountsPartial(this.getIxAccounts(args)).instruction().then(import_common29.toKitInstruction);
|
|
15554
15949
|
}
|
|
15555
15950
|
async deriveIxArgs(txArgs) {
|
|
15556
15951
|
const [
|
|
@@ -15581,11 +15976,11 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15581
15976
|
shareMint,
|
|
15582
15977
|
trancheShareMint,
|
|
15583
15978
|
kind: txArgs.kind,
|
|
15584
|
-
shareAmount: new
|
|
15979
|
+
shareAmount: new import_core8.BN(txArgs.shareAmount.toString()),
|
|
15585
15980
|
shareTokenProgram,
|
|
15586
15981
|
trancheShareTokenProgram,
|
|
15587
|
-
userShareAta: (0,
|
|
15588
|
-
userTrancheShareAta: (0,
|
|
15982
|
+
userShareAta: (0, import_common29.getAtaAddress)(shareMint, txArgs.user, shareTokenProgram),
|
|
15983
|
+
userTrancheShareAta: (0, import_common29.getAtaAddress)(
|
|
15589
15984
|
trancheShareMint,
|
|
15590
15985
|
txArgs.user,
|
|
15591
15986
|
trancheShareTokenProgram
|
|
@@ -15593,16 +15988,16 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15593
15988
|
};
|
|
15594
15989
|
}
|
|
15595
15990
|
async buildPreambleInstructions(args) {
|
|
15596
|
-
const payer = (0,
|
|
15991
|
+
const payer = (0, import_common29.toWeb3Pk)(args.user);
|
|
15597
15992
|
const createUserTrancheShareAta = (0, import_spl_token8.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15598
15993
|
payer,
|
|
15599
|
-
(0,
|
|
15994
|
+
(0, import_common29.toWeb3Pk)(args.userTrancheShareAta),
|
|
15600
15995
|
payer,
|
|
15601
|
-
(0,
|
|
15602
|
-
(0,
|
|
15996
|
+
(0, import_common29.toWeb3Pk)(args.trancheShareMint),
|
|
15997
|
+
(0, import_common29.toWeb3Pk)(args.trancheShareTokenProgram),
|
|
15603
15998
|
import_spl_token8.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15604
15999
|
);
|
|
15605
|
-
return [createUserTrancheShareAta].map(
|
|
16000
|
+
return [createUserTrancheShareAta].map(import_common29.toKitInstruction);
|
|
15606
16001
|
}
|
|
15607
16002
|
async buildPlanExtras(args) {
|
|
15608
16003
|
return {
|
|
@@ -15624,25 +16019,25 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15624
16019
|
};
|
|
15625
16020
|
|
|
15626
16021
|
// src/client/builders/executeDeposit.ts
|
|
15627
|
-
var
|
|
16022
|
+
var import_core9 = require("@anchor-lang/core");
|
|
15628
16023
|
var import_spl_token9 = require("@solana/spl-token");
|
|
15629
|
-
var
|
|
16024
|
+
var import_common30 = __toESM(require_dist());
|
|
15630
16025
|
var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
15631
16026
|
getIxAccounts(args) {
|
|
15632
16027
|
return {
|
|
15633
|
-
user: (0,
|
|
15634
|
-
vault: (0,
|
|
15635
|
-
vaultOracle: (0,
|
|
15636
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
15637
|
-
assetMint: (0,
|
|
15638
|
-
shareMint: (0,
|
|
15639
|
-
userAssetAta: (0,
|
|
15640
|
-
vaultAssetAta: (0,
|
|
15641
|
-
feeVault: (0,
|
|
15642
|
-
feeVaultAta: (0,
|
|
15643
|
-
userShareAta: (0,
|
|
15644
|
-
assetTokenProgram: (0,
|
|
15645
|
-
shareTokenProgram: (0,
|
|
16028
|
+
user: (0, import_common30.toWeb3Pk)(args.user),
|
|
16029
|
+
vault: (0, import_common30.toWeb3Pk)(args.vault),
|
|
16030
|
+
vaultOracle: (0, import_common30.toWeb3Pk)(args.vaultOracle),
|
|
16031
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common30.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
16032
|
+
assetMint: (0, import_common30.toWeb3Pk)(args.assetMint),
|
|
16033
|
+
shareMint: (0, import_common30.toWeb3Pk)(args.shareMint),
|
|
16034
|
+
userAssetAta: (0, import_common30.toWeb3Pk)(args.userAssetAta),
|
|
16035
|
+
vaultAssetAta: (0, import_common30.toWeb3Pk)(args.vaultAssetAta),
|
|
16036
|
+
feeVault: (0, import_common30.toWeb3Pk)(args.feeVault),
|
|
16037
|
+
feeVaultAta: (0, import_common30.toWeb3Pk)(args.feeVaultAta),
|
|
16038
|
+
userShareAta: (0, import_common30.toWeb3Pk)(args.userShareAta),
|
|
16039
|
+
assetTokenProgram: (0, import_common30.toWeb3Pk)(args.assetTokenProgram),
|
|
16040
|
+
shareTokenProgram: (0, import_common30.toWeb3Pk)(args.shareTokenProgram)
|
|
15646
16041
|
};
|
|
15647
16042
|
}
|
|
15648
16043
|
getIxData(args) {
|
|
@@ -15659,7 +16054,7 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
15659
16054
|
) : this.program.methods.executeDeposit(data.amount);
|
|
15660
16055
|
return methods.accountsPartial(
|
|
15661
16056
|
this.getIxAccounts(args)
|
|
15662
|
-
).instruction().then(
|
|
16057
|
+
).instruction().then(import_common30.toKitInstruction);
|
|
15663
16058
|
}
|
|
15664
16059
|
async deriveIxArgs(txArgs) {
|
|
15665
16060
|
const connection = this.program.provider.connection;
|
|
@@ -15698,61 +16093,61 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
15698
16093
|
vaultTrancheState,
|
|
15699
16094
|
assetMint: txArgs.assetMint,
|
|
15700
16095
|
shareMint: txArgs.shareMint,
|
|
15701
|
-
amount: new
|
|
16096
|
+
amount: new import_core9.BN(txArgs.amount.toString()),
|
|
15702
16097
|
addressSeeds: txArgs.addressSeeds,
|
|
15703
16098
|
assetTokenProgram,
|
|
15704
16099
|
shareTokenProgram,
|
|
15705
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
15706
|
-
vaultAssetAta: (0,
|
|
16100
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common30.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16101
|
+
vaultAssetAta: (0, import_common30.getAtaAddress)(
|
|
15707
16102
|
txArgs.assetMint,
|
|
15708
16103
|
txArgs.vault,
|
|
15709
16104
|
assetTokenProgram,
|
|
15710
16105
|
true
|
|
15711
16106
|
),
|
|
15712
16107
|
feeVault,
|
|
15713
|
-
feeVaultAta: (0,
|
|
16108
|
+
feeVaultAta: (0, import_common30.getAtaAddress)(
|
|
15714
16109
|
txArgs.assetMint,
|
|
15715
16110
|
feeVault,
|
|
15716
16111
|
assetTokenProgram,
|
|
15717
16112
|
true
|
|
15718
16113
|
),
|
|
15719
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
16114
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common30.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram)
|
|
15720
16115
|
};
|
|
15721
16116
|
}
|
|
15722
16117
|
async buildPreambleInstructions(args) {
|
|
15723
|
-
const payer = (0,
|
|
16118
|
+
const payer = (0, import_common30.toWeb3Pk)(args.user);
|
|
15724
16119
|
const createVaultAssetAta = (0, import_spl_token9.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15725
16120
|
payer,
|
|
15726
|
-
(0,
|
|
15727
|
-
(0,
|
|
15728
|
-
(0,
|
|
15729
|
-
(0,
|
|
16121
|
+
(0, import_common30.toWeb3Pk)(args.vaultAssetAta),
|
|
16122
|
+
(0, import_common30.toWeb3Pk)(args.vault),
|
|
16123
|
+
(0, import_common30.toWeb3Pk)(args.assetMint),
|
|
16124
|
+
(0, import_common30.toWeb3Pk)(args.assetTokenProgram),
|
|
15730
16125
|
import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15731
16126
|
);
|
|
15732
16127
|
const createFeeVaultAta = (0, import_spl_token9.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15733
16128
|
payer,
|
|
15734
|
-
(0,
|
|
15735
|
-
(0,
|
|
15736
|
-
(0,
|
|
15737
|
-
(0,
|
|
16129
|
+
(0, import_common30.toWeb3Pk)(args.feeVaultAta),
|
|
16130
|
+
(0, import_common30.toWeb3Pk)(args.feeVault),
|
|
16131
|
+
(0, import_common30.toWeb3Pk)(args.assetMint),
|
|
16132
|
+
(0, import_common30.toWeb3Pk)(args.assetTokenProgram),
|
|
15738
16133
|
import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15739
16134
|
);
|
|
15740
|
-
const defaultUserShareAta = (0,
|
|
16135
|
+
const defaultUserShareAta = (0, import_common30.getAtaAddress)(
|
|
15741
16136
|
args.shareMint,
|
|
15742
16137
|
args.user,
|
|
15743
16138
|
args.shareTokenProgram
|
|
15744
16139
|
);
|
|
15745
|
-
const createUserShareAta = (0,
|
|
15746
|
-
(0,
|
|
16140
|
+
const createUserShareAta = (0, import_common30.toWeb3Pk)(args.userShareAta).equals(
|
|
16141
|
+
(0, import_common30.toWeb3Pk)(defaultUserShareAta)
|
|
15747
16142
|
) ? (0, import_spl_token9.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15748
16143
|
payer,
|
|
15749
|
-
(0,
|
|
16144
|
+
(0, import_common30.toWeb3Pk)(args.userShareAta),
|
|
15750
16145
|
payer,
|
|
15751
|
-
(0,
|
|
15752
|
-
(0,
|
|
16146
|
+
(0, import_common30.toWeb3Pk)(args.shareMint),
|
|
16147
|
+
(0, import_common30.toWeb3Pk)(args.shareTokenProgram),
|
|
15753
16148
|
import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15754
16149
|
) : null;
|
|
15755
|
-
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(
|
|
16150
|
+
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(import_common30.toKitInstruction);
|
|
15756
16151
|
}
|
|
15757
16152
|
async buildPlanExtras(args) {
|
|
15758
16153
|
return {
|
|
@@ -15772,28 +16167,28 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
15772
16167
|
};
|
|
15773
16168
|
|
|
15774
16169
|
// src/client/builders/executeTrancheDeposit.ts
|
|
15775
|
-
var
|
|
16170
|
+
var import_core10 = require("@anchor-lang/core");
|
|
15776
16171
|
var import_spl_token10 = require("@solana/spl-token");
|
|
15777
|
-
var
|
|
15778
|
-
var
|
|
16172
|
+
var import_web313 = require("@solana/web3.js");
|
|
16173
|
+
var import_common31 = __toESM(require_dist());
|
|
15779
16174
|
var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
15780
16175
|
getIxAccounts(args) {
|
|
15781
16176
|
return {
|
|
15782
|
-
user: (0,
|
|
15783
|
-
vault: (0,
|
|
15784
|
-
vaultOracle: (0,
|
|
15785
|
-
vaultTrancheState: (0,
|
|
15786
|
-
assetMint: (0,
|
|
15787
|
-
trancheShareMint: (0,
|
|
15788
|
-
userAssetAta: (0,
|
|
15789
|
-
vaultAssetAta: (0,
|
|
15790
|
-
feeVault: (0,
|
|
15791
|
-
feeVaultAta: (0,
|
|
15792
|
-
userTrancheShareAta: (0,
|
|
15793
|
-
assetTokenProgram: (0,
|
|
15794
|
-
shareTokenProgram: (0,
|
|
16177
|
+
user: (0, import_common31.toWeb3Pk)(args.user),
|
|
16178
|
+
vault: (0, import_common31.toWeb3Pk)(args.vault),
|
|
16179
|
+
vaultOracle: (0, import_common31.toWeb3Pk)(args.vaultOracle),
|
|
16180
|
+
vaultTrancheState: (0, import_common31.toWeb3Pk)(args.vaultTrancheState),
|
|
16181
|
+
assetMint: (0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16182
|
+
trancheShareMint: (0, import_common31.toWeb3Pk)(args.trancheShareMint),
|
|
16183
|
+
userAssetAta: (0, import_common31.toWeb3Pk)(args.userAssetAta),
|
|
16184
|
+
vaultAssetAta: (0, import_common31.toWeb3Pk)(args.vaultAssetAta),
|
|
16185
|
+
feeVault: (0, import_common31.toWeb3Pk)(args.feeVault),
|
|
16186
|
+
feeVaultAta: (0, import_common31.toWeb3Pk)(args.feeVaultAta),
|
|
16187
|
+
userTrancheShareAta: (0, import_common31.toWeb3Pk)(args.userTrancheShareAta),
|
|
16188
|
+
assetTokenProgram: (0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
16189
|
+
shareTokenProgram: (0, import_common31.toWeb3Pk)(args.shareTokenProgram),
|
|
15795
16190
|
associatedTokenProgram: import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15796
|
-
systemProgram:
|
|
16191
|
+
systemProgram: import_web313.SystemProgram.programId
|
|
15797
16192
|
};
|
|
15798
16193
|
}
|
|
15799
16194
|
getIxData(args) {
|
|
@@ -15812,7 +16207,7 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
15812
16207
|
) : this.program.methods.executeTrancheDeposit(data.kind, data.amount);
|
|
15813
16208
|
return methods.accountsPartial(
|
|
15814
16209
|
this.getIxAccounts(args)
|
|
15815
|
-
).instruction().then(
|
|
16210
|
+
).instruction().then(import_common31.toKitInstruction);
|
|
15816
16211
|
}
|
|
15817
16212
|
async deriveIxArgs(txArgs) {
|
|
15818
16213
|
const connection = this.program.provider.connection;
|
|
@@ -15841,29 +16236,29 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
15841
16236
|
assetMint: txArgs.assetMint,
|
|
15842
16237
|
trancheShareMint,
|
|
15843
16238
|
kind: txArgs.kind,
|
|
15844
|
-
amount: new
|
|
16239
|
+
amount: new import_core10.BN(txArgs.amount.toString()),
|
|
15845
16240
|
addressSeeds: txArgs.addressSeeds,
|
|
15846
16241
|
assetTokenProgram,
|
|
15847
16242
|
shareTokenProgram,
|
|
15848
|
-
userAssetAta: (0,
|
|
16243
|
+
userAssetAta: (0, import_common31.getAtaAddress)(
|
|
15849
16244
|
txArgs.assetMint,
|
|
15850
16245
|
txArgs.user,
|
|
15851
16246
|
assetTokenProgram
|
|
15852
16247
|
),
|
|
15853
|
-
vaultAssetAta: (0,
|
|
16248
|
+
vaultAssetAta: (0, import_common31.getAtaAddress)(
|
|
15854
16249
|
txArgs.assetMint,
|
|
15855
16250
|
txArgs.vault,
|
|
15856
16251
|
assetTokenProgram,
|
|
15857
16252
|
true
|
|
15858
16253
|
),
|
|
15859
16254
|
feeVault,
|
|
15860
|
-
feeVaultAta: (0,
|
|
16255
|
+
feeVaultAta: (0, import_common31.getAtaAddress)(
|
|
15861
16256
|
txArgs.assetMint,
|
|
15862
16257
|
feeVault,
|
|
15863
16258
|
assetTokenProgram,
|
|
15864
16259
|
true
|
|
15865
16260
|
),
|
|
15866
|
-
userTrancheShareAta: (0,
|
|
16261
|
+
userTrancheShareAta: (0, import_common31.getAtaAddress)(
|
|
15867
16262
|
trancheShareMint,
|
|
15868
16263
|
txArgs.user,
|
|
15869
16264
|
shareTokenProgram
|
|
@@ -15871,33 +16266,33 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
15871
16266
|
};
|
|
15872
16267
|
}
|
|
15873
16268
|
async buildPreambleInstructions(args) {
|
|
15874
|
-
const payer = (0,
|
|
16269
|
+
const payer = (0, import_common31.toWeb3Pk)(args.user);
|
|
15875
16270
|
const createVaultAssetAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15876
16271
|
payer,
|
|
15877
|
-
(0,
|
|
15878
|
-
(0,
|
|
15879
|
-
(0,
|
|
15880
|
-
(0,
|
|
16272
|
+
(0, import_common31.toWeb3Pk)(args.vaultAssetAta),
|
|
16273
|
+
(0, import_common31.toWeb3Pk)(args.vault),
|
|
16274
|
+
(0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16275
|
+
(0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
15881
16276
|
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15882
16277
|
);
|
|
15883
16278
|
const createUserShareAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15884
16279
|
payer,
|
|
15885
|
-
(0,
|
|
16280
|
+
(0, import_common31.toWeb3Pk)(args.userTrancheShareAta),
|
|
15886
16281
|
payer,
|
|
15887
|
-
(0,
|
|
15888
|
-
(0,
|
|
16282
|
+
(0, import_common31.toWeb3Pk)(args.trancheShareMint),
|
|
16283
|
+
(0, import_common31.toWeb3Pk)(args.shareTokenProgram),
|
|
15889
16284
|
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15890
16285
|
);
|
|
15891
16286
|
const createFeeVaultAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15892
16287
|
payer,
|
|
15893
|
-
(0,
|
|
15894
|
-
(0,
|
|
15895
|
-
(0,
|
|
15896
|
-
(0,
|
|
16288
|
+
(0, import_common31.toWeb3Pk)(args.feeVaultAta),
|
|
16289
|
+
(0, import_common31.toWeb3Pk)(args.feeVault),
|
|
16290
|
+
(0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16291
|
+
(0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
15897
16292
|
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15898
16293
|
);
|
|
15899
16294
|
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].map(
|
|
15900
|
-
|
|
16295
|
+
import_common31.toKitInstruction
|
|
15901
16296
|
);
|
|
15902
16297
|
}
|
|
15903
16298
|
async buildPlanExtras(args) {
|
|
@@ -15920,27 +16315,27 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
15920
16315
|
};
|
|
15921
16316
|
|
|
15922
16317
|
// src/client/builders/executeTrancheWithdraw.ts
|
|
15923
|
-
var
|
|
16318
|
+
var import_core11 = require("@anchor-lang/core");
|
|
15924
16319
|
var import_spl_token11 = require("@solana/spl-token");
|
|
15925
|
-
var
|
|
15926
|
-
var
|
|
16320
|
+
var import_web315 = require("@solana/web3.js");
|
|
16321
|
+
var import_common33 = __toESM(require_dist());
|
|
15927
16322
|
|
|
15928
16323
|
// src/client/builders/externalLiquidity.ts
|
|
15929
16324
|
var import_kit7 = require("@solana/kit");
|
|
15930
|
-
var
|
|
15931
|
-
var
|
|
16325
|
+
var import_web314 = require("@solana/web3.js");
|
|
16326
|
+
var import_common32 = __toESM(require_dist());
|
|
15932
16327
|
var import_marginfi = __toESM(require_dist2());
|
|
15933
16328
|
function parseMarginfiSlot(slot) {
|
|
15934
16329
|
const data = slot?.data;
|
|
15935
16330
|
if (!data || data.length < 40) return null;
|
|
15936
16331
|
if (data[0] !== 1) return null;
|
|
15937
16332
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
15938
|
-
const userAccount = new
|
|
16333
|
+
const userAccount = new import_web314.PublicKey(pubkeyBytes).toBase58();
|
|
15939
16334
|
return { userAccount };
|
|
15940
16335
|
}
|
|
15941
16336
|
function toWeb3AccountMeta(account) {
|
|
15942
16337
|
return {
|
|
15943
|
-
pubkey: new
|
|
16338
|
+
pubkey: new import_web314.PublicKey(account.address),
|
|
15944
16339
|
isWritable: account.role === import_kit7.AccountRole.WRITABLE || account.role === import_kit7.AccountRole.WRITABLE_SIGNER,
|
|
15945
16340
|
isSigner: account.role === import_kit7.AccountRole.READONLY_SIGNER || account.role === import_kit7.AccountRole.WRITABLE_SIGNER
|
|
15946
16341
|
};
|
|
@@ -15979,7 +16374,7 @@ function resolveExternalWithdraw({
|
|
|
15979
16374
|
};
|
|
15980
16375
|
}
|
|
15981
16376
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
15982
|
-
const withdrawRefs = (0,
|
|
16377
|
+
const withdrawRefs = (0, import_common32.createCpiRefs)([
|
|
15983
16378
|
marginfiClient.withdraw_cpi({
|
|
15984
16379
|
marginfiAccount: slot0.userAccount,
|
|
15985
16380
|
authority: vault,
|
|
@@ -15999,14 +16394,14 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
15999
16394
|
`No Marginfi market is configured for asset mint ${args.assetMint}`
|
|
16000
16395
|
);
|
|
16001
16396
|
}
|
|
16002
|
-
const vaultAssetAta = (0,
|
|
16397
|
+
const vaultAssetAta = (0, import_common32.getAtaAddress)(
|
|
16003
16398
|
args.assetMint,
|
|
16004
16399
|
args.vault,
|
|
16005
16400
|
marginfiAccounts.tokenProgram,
|
|
16006
16401
|
true
|
|
16007
16402
|
);
|
|
16008
16403
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
16009
|
-
const withdraw = (0,
|
|
16404
|
+
const withdraw = (0, import_common32.createCpiRefs)([
|
|
16010
16405
|
marginfiClient.withdraw_cpi({
|
|
16011
16406
|
marginfiAccount: args.marginfiAccount,
|
|
16012
16407
|
authority: args.vault,
|
|
@@ -16030,19 +16425,19 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
16030
16425
|
var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16031
16426
|
getIxAccounts(args) {
|
|
16032
16427
|
return {
|
|
16033
|
-
user: (0,
|
|
16034
|
-
vault: (0,
|
|
16035
|
-
vaultOracle: (0,
|
|
16036
|
-
vaultTrancheState: (0,
|
|
16037
|
-
assetMint: (0,
|
|
16038
|
-
trancheShareMint: (0,
|
|
16039
|
-
userAssetAta: (0,
|
|
16040
|
-
vaultAssetAta: (0,
|
|
16041
|
-
userTrancheShareAta: (0,
|
|
16042
|
-
assetTokenProgram: (0,
|
|
16043
|
-
shareTokenProgram: (0,
|
|
16428
|
+
user: (0, import_common33.toWeb3Pk)(args.user),
|
|
16429
|
+
vault: (0, import_common33.toWeb3Pk)(args.vault),
|
|
16430
|
+
vaultOracle: (0, import_common33.toWeb3Pk)(args.vaultOracle),
|
|
16431
|
+
vaultTrancheState: (0, import_common33.toWeb3Pk)(args.vaultTrancheState),
|
|
16432
|
+
assetMint: (0, import_common33.toWeb3Pk)(args.assetMint),
|
|
16433
|
+
trancheShareMint: (0, import_common33.toWeb3Pk)(args.trancheShareMint),
|
|
16434
|
+
userAssetAta: (0, import_common33.toWeb3Pk)(args.userAssetAta),
|
|
16435
|
+
vaultAssetAta: (0, import_common33.toWeb3Pk)(args.vaultAssetAta),
|
|
16436
|
+
userTrancheShareAta: (0, import_common33.toWeb3Pk)(args.userTrancheShareAta),
|
|
16437
|
+
assetTokenProgram: (0, import_common33.toWeb3Pk)(args.assetTokenProgram),
|
|
16438
|
+
shareTokenProgram: (0, import_common33.toWeb3Pk)(args.shareTokenProgram),
|
|
16044
16439
|
associatedTokenProgram: import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16045
|
-
systemProgram:
|
|
16440
|
+
systemProgram: import_web315.SystemProgram.programId
|
|
16046
16441
|
};
|
|
16047
16442
|
}
|
|
16048
16443
|
getIxData(args) {
|
|
@@ -16079,7 +16474,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16079
16474
|
);
|
|
16080
16475
|
return methods.accountsPartial(
|
|
16081
16476
|
this.getIxAccounts(args)
|
|
16082
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16477
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common33.toKitInstruction);
|
|
16083
16478
|
}
|
|
16084
16479
|
async deriveIxArgs(txArgs) {
|
|
16085
16480
|
const connection = this.program.provider.connection;
|
|
@@ -16100,7 +16495,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16100
16495
|
txArgs.assetTokenProgram
|
|
16101
16496
|
);
|
|
16102
16497
|
const { mint: trancheShareMint, tokenProgram: shareTokenProgram } = trancheShare;
|
|
16103
|
-
const vaultAssetAta = (0,
|
|
16498
|
+
const vaultAssetAta = (0, import_common33.getAtaAddress)(
|
|
16104
16499
|
txArgs.assetMint,
|
|
16105
16500
|
txArgs.vault,
|
|
16106
16501
|
assetTokenProgram,
|
|
@@ -16125,17 +16520,17 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16125
16520
|
assetMint: txArgs.assetMint,
|
|
16126
16521
|
trancheShareMint,
|
|
16127
16522
|
kind: txArgs.kind,
|
|
16128
|
-
shareAmount: new
|
|
16523
|
+
shareAmount: new import_core11.BN(txArgs.shareAmount.toString()),
|
|
16129
16524
|
addressSeeds: txArgs.addressSeeds,
|
|
16130
16525
|
assetTokenProgram,
|
|
16131
16526
|
shareTokenProgram,
|
|
16132
|
-
userAssetAta: (0,
|
|
16527
|
+
userAssetAta: (0, import_common33.getAtaAddress)(
|
|
16133
16528
|
txArgs.assetMint,
|
|
16134
16529
|
txArgs.user,
|
|
16135
16530
|
assetTokenProgram
|
|
16136
16531
|
),
|
|
16137
16532
|
vaultAssetAta,
|
|
16138
|
-
userTrancheShareAta: (0,
|
|
16533
|
+
userTrancheShareAta: (0, import_common33.getAtaAddress)(
|
|
16139
16534
|
trancheShareMint,
|
|
16140
16535
|
txArgs.user,
|
|
16141
16536
|
shareTokenProgram
|
|
@@ -16149,16 +16544,16 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16149
16544
|
return txArgs.lookupTables;
|
|
16150
16545
|
}
|
|
16151
16546
|
async buildPreambleInstructions(args) {
|
|
16152
|
-
const payer = (0,
|
|
16547
|
+
const payer = (0, import_common33.toWeb3Pk)(args.user);
|
|
16153
16548
|
const createUserAssetAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16154
16549
|
payer,
|
|
16155
|
-
(0,
|
|
16550
|
+
(0, import_common33.toWeb3Pk)(args.userAssetAta),
|
|
16156
16551
|
payer,
|
|
16157
|
-
(0,
|
|
16158
|
-
(0,
|
|
16552
|
+
(0, import_common33.toWeb3Pk)(args.assetMint),
|
|
16553
|
+
(0, import_common33.toWeb3Pk)(args.assetTokenProgram),
|
|
16159
16554
|
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16160
16555
|
);
|
|
16161
|
-
return [createUserAssetAta].map(
|
|
16556
|
+
return [createUserAssetAta].map(import_common33.toKitInstruction);
|
|
16162
16557
|
}
|
|
16163
16558
|
async buildPlanExtras(args) {
|
|
16164
16559
|
return {
|
|
@@ -16170,25 +16565,25 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16170
16565
|
};
|
|
16171
16566
|
|
|
16172
16567
|
// src/client/builders/executeWithdraw.ts
|
|
16173
|
-
var
|
|
16568
|
+
var import_core12 = require("@anchor-lang/core");
|
|
16174
16569
|
var import_spl_token12 = require("@solana/spl-token");
|
|
16175
|
-
var
|
|
16570
|
+
var import_common34 = __toESM(require_dist());
|
|
16176
16571
|
var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
16177
16572
|
getIxAccounts(args) {
|
|
16178
16573
|
return {
|
|
16179
|
-
user: (0,
|
|
16180
|
-
vault: (0,
|
|
16181
|
-
vaultOracle: (0,
|
|
16182
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
16183
|
-
assetMint: (0,
|
|
16184
|
-
shareMint: (0,
|
|
16185
|
-
userAssetAta: (0,
|
|
16186
|
-
vaultAssetAta: (0,
|
|
16187
|
-
feeVault: (0,
|
|
16188
|
-
feeVaultAta: (0,
|
|
16189
|
-
userShareAta: (0,
|
|
16190
|
-
assetTokenProgram: (0,
|
|
16191
|
-
shareTokenProgram: (0,
|
|
16574
|
+
user: (0, import_common34.toWeb3Pk)(args.user),
|
|
16575
|
+
vault: (0, import_common34.toWeb3Pk)(args.vault),
|
|
16576
|
+
vaultOracle: (0, import_common34.toWeb3Pk)(args.vaultOracle),
|
|
16577
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common34.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
16578
|
+
assetMint: (0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16579
|
+
shareMint: (0, import_common34.toWeb3Pk)(args.shareMint),
|
|
16580
|
+
userAssetAta: (0, import_common34.toWeb3Pk)(args.userAssetAta),
|
|
16581
|
+
vaultAssetAta: (0, import_common34.toWeb3Pk)(args.vaultAssetAta),
|
|
16582
|
+
feeVault: (0, import_common34.toWeb3Pk)(args.feeVault),
|
|
16583
|
+
feeVaultAta: (0, import_common34.toWeb3Pk)(args.feeVaultAta),
|
|
16584
|
+
userShareAta: (0, import_common34.toWeb3Pk)(args.userShareAta),
|
|
16585
|
+
assetTokenProgram: (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16586
|
+
shareTokenProgram: (0, import_common34.toWeb3Pk)(args.shareTokenProgram)
|
|
16192
16587
|
};
|
|
16193
16588
|
}
|
|
16194
16589
|
getIxData(args) {
|
|
@@ -16218,7 +16613,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16218
16613
|
) : this.program.methods.executeWithdraw(data.shareAmount);
|
|
16219
16614
|
return methods.accountsPartial(
|
|
16220
16615
|
this.getIxAccounts(args)
|
|
16221
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16616
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common34.toKitInstruction);
|
|
16222
16617
|
}
|
|
16223
16618
|
async deriveIxArgs(txArgs) {
|
|
16224
16619
|
const connection = this.program.provider.connection;
|
|
@@ -16252,7 +16647,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16252
16647
|
),
|
|
16253
16648
|
this.account.fetchVault(txArgs.vault)
|
|
16254
16649
|
]);
|
|
16255
|
-
const vaultAssetAta = (0,
|
|
16650
|
+
const vaultAssetAta = (0, import_common34.getAtaAddress)(
|
|
16256
16651
|
txArgs.assetMint,
|
|
16257
16652
|
txArgs.vault,
|
|
16258
16653
|
assetTokenProgram,
|
|
@@ -16276,19 +16671,19 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16276
16671
|
vaultTrancheState: vaultTrancheState ?? null,
|
|
16277
16672
|
assetMint: txArgs.assetMint,
|
|
16278
16673
|
shareMint: txArgs.shareMint,
|
|
16279
|
-
shareAmount: new
|
|
16674
|
+
shareAmount: new import_core12.BN(txArgs.shareAmount.toString()),
|
|
16280
16675
|
assetTokenProgram,
|
|
16281
16676
|
shareTokenProgram,
|
|
16282
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
16677
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common34.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16283
16678
|
vaultAssetAta,
|
|
16284
16679
|
feeVault,
|
|
16285
|
-
feeVaultAta: (0,
|
|
16680
|
+
feeVaultAta: (0, import_common34.getAtaAddress)(
|
|
16286
16681
|
txArgs.assetMint,
|
|
16287
16682
|
feeVault,
|
|
16288
16683
|
assetTokenProgram,
|
|
16289
16684
|
true
|
|
16290
16685
|
),
|
|
16291
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
16686
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common34.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
|
|
16292
16687
|
externalWithdrawIxRefs,
|
|
16293
16688
|
externalLiquiditySource,
|
|
16294
16689
|
externalWithdrawAccounts,
|
|
@@ -16299,31 +16694,31 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16299
16694
|
return txArgs.lookupTables;
|
|
16300
16695
|
}
|
|
16301
16696
|
async buildPreambleInstructions(args) {
|
|
16302
|
-
const defaultUserAssetAta = (0,
|
|
16697
|
+
const defaultUserAssetAta = (0, import_common34.getAtaAddress)(
|
|
16303
16698
|
args.assetMint,
|
|
16304
16699
|
args.user,
|
|
16305
16700
|
args.assetTokenProgram
|
|
16306
16701
|
);
|
|
16307
|
-
const payer = (0,
|
|
16308
|
-
const createUserAssetAta = (0,
|
|
16309
|
-
(0,
|
|
16702
|
+
const payer = (0, import_common34.toWeb3Pk)(args.user);
|
|
16703
|
+
const createUserAssetAta = (0, import_common34.toWeb3Pk)(args.userAssetAta).equals(
|
|
16704
|
+
(0, import_common34.toWeb3Pk)(defaultUserAssetAta)
|
|
16310
16705
|
) ? (0, import_spl_token12.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16311
16706
|
payer,
|
|
16312
|
-
(0,
|
|
16707
|
+
(0, import_common34.toWeb3Pk)(args.userAssetAta),
|
|
16313
16708
|
payer,
|
|
16314
|
-
(0,
|
|
16315
|
-
(0,
|
|
16709
|
+
(0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16710
|
+
(0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16316
16711
|
import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16317
16712
|
) : null;
|
|
16318
16713
|
const createFeeVaultAta = (0, import_spl_token12.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16319
16714
|
payer,
|
|
16320
|
-
(0,
|
|
16321
|
-
(0,
|
|
16322
|
-
(0,
|
|
16323
|
-
(0,
|
|
16715
|
+
(0, import_common34.toWeb3Pk)(args.feeVaultAta),
|
|
16716
|
+
(0, import_common34.toWeb3Pk)(args.feeVault),
|
|
16717
|
+
(0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16718
|
+
(0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16324
16719
|
import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16325
16720
|
);
|
|
16326
|
-
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(
|
|
16721
|
+
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common34.toKitInstruction);
|
|
16327
16722
|
}
|
|
16328
16723
|
async buildPlanExtras(args) {
|
|
16329
16724
|
return {
|
|
@@ -16334,8 +16729,8 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16334
16729
|
|
|
16335
16730
|
// src/client/builders/fulfillJuniorTrancheWithdraw.ts
|
|
16336
16731
|
var import_spl_token13 = require("@solana/spl-token");
|
|
16337
|
-
var
|
|
16338
|
-
var
|
|
16732
|
+
var import_web316 = require("@solana/web3.js");
|
|
16733
|
+
var import_common35 = __toESM(require_dist());
|
|
16339
16734
|
var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16340
16735
|
async getIx(args) {
|
|
16341
16736
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -16349,24 +16744,24 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16349
16744
|
externalLiquiditySource
|
|
16350
16745
|
);
|
|
16351
16746
|
return methods.accountsPartial({
|
|
16352
|
-
signer: (0,
|
|
16353
|
-
owner: (0,
|
|
16354
|
-
queuePayer: (0,
|
|
16355
|
-
vault: (0,
|
|
16356
|
-
vaultOracle: (0,
|
|
16357
|
-
vaultTrancheState: (0,
|
|
16358
|
-
withdrawalQueue: (0,
|
|
16359
|
-
outputMint: (0,
|
|
16360
|
-
inputMint: (0,
|
|
16361
|
-
ownerInputAta: (0,
|
|
16362
|
-
ownerOutputAta: (0,
|
|
16363
|
-
vaultOutputAta: (0,
|
|
16364
|
-
queueInputAta: (0,
|
|
16365
|
-
assetTokenProgram: (0,
|
|
16366
|
-
shareTokenProgram: (0,
|
|
16747
|
+
signer: (0, import_common35.toWeb3Pk)(args.signer),
|
|
16748
|
+
owner: (0, import_common35.toWeb3Pk)(args.owner),
|
|
16749
|
+
queuePayer: (0, import_common35.toWeb3Pk)(args.queuePayer),
|
|
16750
|
+
vault: (0, import_common35.toWeb3Pk)(args.vault),
|
|
16751
|
+
vaultOracle: (0, import_common35.toWeb3Pk)(args.vaultOracle),
|
|
16752
|
+
vaultTrancheState: (0, import_common35.toWeb3Pk)(args.vaultTrancheState),
|
|
16753
|
+
withdrawalQueue: (0, import_common35.toWeb3Pk)(args.withdrawalQueue),
|
|
16754
|
+
outputMint: (0, import_common35.toWeb3Pk)(args.outputMint),
|
|
16755
|
+
inputMint: (0, import_common35.toWeb3Pk)(args.inputMint),
|
|
16756
|
+
ownerInputAta: (0, import_common35.toWeb3Pk)(args.ownerInputAta),
|
|
16757
|
+
ownerOutputAta: (0, import_common35.toWeb3Pk)(args.ownerOutputAta),
|
|
16758
|
+
vaultOutputAta: (0, import_common35.toWeb3Pk)(args.vaultOutputAta),
|
|
16759
|
+
queueInputAta: (0, import_common35.toWeb3Pk)(args.queueInputAta),
|
|
16760
|
+
assetTokenProgram: (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
16761
|
+
shareTokenProgram: (0, import_common35.toWeb3Pk)(args.shareTokenProgram),
|
|
16367
16762
|
associatedTokenProgram: import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16368
|
-
systemProgram:
|
|
16369
|
-
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16763
|
+
systemProgram: import_web316.SystemProgram.programId
|
|
16764
|
+
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common35.toKitInstruction);
|
|
16370
16765
|
}
|
|
16371
16766
|
async deriveIxArgs(txArgs) {
|
|
16372
16767
|
const connection = this.program.provider.connection;
|
|
@@ -16407,7 +16802,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16407
16802
|
]);
|
|
16408
16803
|
const { mint: juniorShareMint, tokenProgram: shareTokenProgram } = juniorShare;
|
|
16409
16804
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
16410
|
-
const vaultOutputAta = (0,
|
|
16805
|
+
const vaultOutputAta = (0, import_common35.getAtaAddress)(
|
|
16411
16806
|
txArgs.assetMint,
|
|
16412
16807
|
txArgs.vault,
|
|
16413
16808
|
assetTokenProgram,
|
|
@@ -16436,14 +16831,14 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16436
16831
|
inputMint: juniorShareMint,
|
|
16437
16832
|
assetTokenProgram,
|
|
16438
16833
|
shareTokenProgram,
|
|
16439
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
16440
|
-
ownerOutputAta: (0,
|
|
16834
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common35.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
|
|
16835
|
+
ownerOutputAta: (0, import_common35.getAtaAddress)(
|
|
16441
16836
|
txArgs.assetMint,
|
|
16442
16837
|
txArgs.owner,
|
|
16443
16838
|
assetTokenProgram
|
|
16444
16839
|
),
|
|
16445
16840
|
vaultOutputAta,
|
|
16446
|
-
queueInputAta: (0,
|
|
16841
|
+
queueInputAta: (0, import_common35.getAtaAddress)(
|
|
16447
16842
|
juniorShareMint,
|
|
16448
16843
|
queuePda,
|
|
16449
16844
|
shareTokenProgram,
|
|
@@ -16459,22 +16854,22 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16459
16854
|
return txArgs.lookupTables;
|
|
16460
16855
|
}
|
|
16461
16856
|
async buildPreambleInstructions(args) {
|
|
16462
|
-
const defaultOwnerInputAta = (0,
|
|
16857
|
+
const defaultOwnerInputAta = (0, import_common35.getAtaAddress)(
|
|
16463
16858
|
args.inputMint,
|
|
16464
16859
|
args.owner,
|
|
16465
16860
|
args.shareTokenProgram
|
|
16466
16861
|
);
|
|
16467
|
-
if (!(0,
|
|
16862
|
+
if (!(0, import_common35.toWeb3Pk)(args.ownerInputAta).equals((0, import_common35.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
16468
16863
|
return [];
|
|
16469
16864
|
}
|
|
16470
16865
|
return [
|
|
16471
|
-
(0,
|
|
16866
|
+
(0, import_common35.toKitInstruction)(
|
|
16472
16867
|
(0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16473
|
-
(0,
|
|
16474
|
-
(0,
|
|
16475
|
-
(0,
|
|
16476
|
-
(0,
|
|
16477
|
-
(0,
|
|
16868
|
+
(0, import_common35.toWeb3Pk)(args.signer),
|
|
16869
|
+
(0, import_common35.toWeb3Pk)(args.ownerInputAta),
|
|
16870
|
+
(0, import_common35.toWeb3Pk)(args.owner),
|
|
16871
|
+
(0, import_common35.toWeb3Pk)(args.inputMint),
|
|
16872
|
+
(0, import_common35.toWeb3Pk)(args.shareTokenProgram),
|
|
16478
16873
|
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16479
16874
|
)
|
|
16480
16875
|
)
|
|
@@ -16494,8 +16889,8 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16494
16889
|
};
|
|
16495
16890
|
|
|
16496
16891
|
// src/client/builders/updateTrancheConfig.ts
|
|
16497
|
-
var
|
|
16498
|
-
var
|
|
16892
|
+
var import_core13 = require("@anchor-lang/core");
|
|
16893
|
+
var import_common36 = __toESM(require_dist());
|
|
16499
16894
|
var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
16500
16895
|
async getIx(args) {
|
|
16501
16896
|
return this.program.methods.vaultUpdateTrancheConfig({
|
|
@@ -16506,11 +16901,11 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16506
16901
|
targetLockupDurationSecs: args.targetLockupDurationSecs,
|
|
16507
16902
|
juniorDepositCap: args.juniorDepositCap
|
|
16508
16903
|
}).accountsPartial({
|
|
16509
|
-
curator: (0,
|
|
16510
|
-
vault: (0,
|
|
16511
|
-
vaultTrancheState: (0,
|
|
16512
|
-
vaultOracle: (0,
|
|
16513
|
-
}).instruction().then(
|
|
16904
|
+
curator: (0, import_common36.toWeb3Pk)(args.curator),
|
|
16905
|
+
vault: (0, import_common36.toWeb3Pk)(args.vault),
|
|
16906
|
+
vaultTrancheState: (0, import_common36.toWeb3Pk)(args.vaultTrancheState),
|
|
16907
|
+
vaultOracle: (0, import_common36.toWeb3Pk)(args.vaultOracle)
|
|
16908
|
+
}).instruction().then(import_common36.toKitInstruction);
|
|
16514
16909
|
}
|
|
16515
16910
|
async deriveIxArgs(txArgs) {
|
|
16516
16911
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -16526,8 +16921,8 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16526
16921
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? null,
|
|
16527
16922
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? null,
|
|
16528
16923
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? null,
|
|
16529
|
-
targetLockupDurationSecs: txArgs.targetLockupDurationSecs === void 0 ? null : new
|
|
16530
|
-
juniorDepositCap: txArgs.juniorDepositCap === void 0 ? null : new
|
|
16924
|
+
targetLockupDurationSecs: txArgs.targetLockupDurationSecs === void 0 ? null : new import_core13.BN(txArgs.targetLockupDurationSecs.toString()),
|
|
16925
|
+
juniorDepositCap: txArgs.juniorDepositCap === void 0 ? null : new import_core13.BN(txArgs.juniorDepositCap.toString())
|
|
16531
16926
|
};
|
|
16532
16927
|
}
|
|
16533
16928
|
async buildPlanExtras(args) {
|
|
@@ -16540,25 +16935,25 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16540
16935
|
};
|
|
16541
16936
|
|
|
16542
16937
|
// src/client/builders/managerRedepositAsset.ts
|
|
16543
|
-
var
|
|
16938
|
+
var import_core14 = require("@anchor-lang/core");
|
|
16544
16939
|
var import_spl_token14 = require("@solana/spl-token");
|
|
16545
|
-
var
|
|
16546
|
-
var
|
|
16940
|
+
var import_web317 = require("@solana/web3.js");
|
|
16941
|
+
var import_common37 = __toESM(require_dist());
|
|
16547
16942
|
var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
16548
16943
|
async getIx(args) {
|
|
16549
16944
|
return this.program.methods.managerRedepositAsset({
|
|
16550
16945
|
depositAmount: args.depositAmount,
|
|
16551
16946
|
externalAmount: args.externalAmount
|
|
16552
16947
|
}).accountsPartial({
|
|
16553
|
-
manager: (0,
|
|
16554
|
-
vault: (0,
|
|
16555
|
-
assetMint: (0,
|
|
16556
|
-
vaultAssetAta: (0,
|
|
16557
|
-
managerAssetAta: (0,
|
|
16558
|
-
assetTokenProgram: (0,
|
|
16948
|
+
manager: (0, import_common37.toWeb3Pk)(args.manager),
|
|
16949
|
+
vault: (0, import_common37.toWeb3Pk)(args.vault),
|
|
16950
|
+
assetMint: (0, import_common37.toWeb3Pk)(args.assetMint),
|
|
16951
|
+
vaultAssetAta: (0, import_common37.toWeb3Pk)(args.vaultAssetAta),
|
|
16952
|
+
managerAssetAta: (0, import_common37.toWeb3Pk)(args.managerAssetAta),
|
|
16953
|
+
assetTokenProgram: (0, import_common37.toWeb3Pk)(args.assetTokenProgram),
|
|
16559
16954
|
associatedTokenProgram: import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16560
|
-
systemProgram:
|
|
16561
|
-
}).instruction().then(
|
|
16955
|
+
systemProgram: import_web317.SystemProgram.programId
|
|
16956
|
+
}).instruction().then(import_common37.toKitInstruction);
|
|
16562
16957
|
}
|
|
16563
16958
|
async deriveIxArgs(txArgs) {
|
|
16564
16959
|
const connection = this.program.provider.connection;
|
|
@@ -16572,10 +16967,10 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16572
16967
|
manager: txArgs.manager,
|
|
16573
16968
|
vault: txArgs.vault,
|
|
16574
16969
|
assetMint: txArgs.assetMint,
|
|
16575
|
-
depositAmount: new
|
|
16576
|
-
externalAmount: new
|
|
16970
|
+
depositAmount: new import_core14.BN(txArgs.depositAmount.toString()),
|
|
16971
|
+
externalAmount: new import_core14.BN(externalAmount.toString()),
|
|
16577
16972
|
assetTokenProgram,
|
|
16578
|
-
vaultAssetAta: (0,
|
|
16973
|
+
vaultAssetAta: (0, import_common37.getAtaAddress)(
|
|
16579
16974
|
txArgs.assetMint,
|
|
16580
16975
|
txArgs.vault,
|
|
16581
16976
|
assetTokenProgram,
|
|
@@ -16583,7 +16978,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16583
16978
|
),
|
|
16584
16979
|
// The manager may be a PDA (e.g. a Squads vault), so allow off-curve
|
|
16585
16980
|
// owners when deriving its ATA.
|
|
16586
|
-
managerAssetAta: (0,
|
|
16981
|
+
managerAssetAta: (0, import_common37.getAtaAddress)(
|
|
16587
16982
|
txArgs.assetMint,
|
|
16588
16983
|
txArgs.manager,
|
|
16589
16984
|
assetTokenProgram,
|
|
@@ -16599,23 +16994,23 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16599
16994
|
};
|
|
16600
16995
|
|
|
16601
16996
|
// src/client/builders/managerWithdrawAsset.ts
|
|
16602
|
-
var
|
|
16997
|
+
var import_core15 = require("@anchor-lang/core");
|
|
16603
16998
|
var import_spl_token15 = require("@solana/spl-token");
|
|
16604
|
-
var
|
|
16605
|
-
var
|
|
16999
|
+
var import_web318 = require("@solana/web3.js");
|
|
17000
|
+
var import_common38 = __toESM(require_dist());
|
|
16606
17001
|
var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
16607
17002
|
async getIx(args) {
|
|
16608
17003
|
return this.program.methods.managerWithdrawAsset(args.amount).accountsPartial({
|
|
16609
|
-
manager: (0,
|
|
16610
|
-
vault: (0,
|
|
16611
|
-
assetMint: (0,
|
|
16612
|
-
vaultAssetAta: (0,
|
|
16613
|
-
destination: (0,
|
|
16614
|
-
destinationAssetAta: (0,
|
|
16615
|
-
assetTokenProgram: (0,
|
|
17004
|
+
manager: (0, import_common38.toWeb3Pk)(args.manager),
|
|
17005
|
+
vault: (0, import_common38.toWeb3Pk)(args.vault),
|
|
17006
|
+
assetMint: (0, import_common38.toWeb3Pk)(args.assetMint),
|
|
17007
|
+
vaultAssetAta: (0, import_common38.toWeb3Pk)(args.vaultAssetAta),
|
|
17008
|
+
destination: (0, import_common38.toWeb3Pk)(args.destination),
|
|
17009
|
+
destinationAssetAta: (0, import_common38.toWeb3Pk)(args.destinationAssetAta),
|
|
17010
|
+
assetTokenProgram: (0, import_common38.toWeb3Pk)(args.assetTokenProgram),
|
|
16616
17011
|
associatedTokenProgram: import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16617
|
-
systemProgram:
|
|
16618
|
-
}).instruction().then(
|
|
17012
|
+
systemProgram: import_web318.SystemProgram.programId
|
|
17013
|
+
}).instruction().then(import_common38.toKitInstruction);
|
|
16619
17014
|
}
|
|
16620
17015
|
async deriveIxArgs(txArgs) {
|
|
16621
17016
|
const connection = this.program.provider.connection;
|
|
@@ -16630,15 +17025,15 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
16630
17025
|
vault: txArgs.vault,
|
|
16631
17026
|
assetMint: txArgs.assetMint,
|
|
16632
17027
|
destination,
|
|
16633
|
-
amount: new
|
|
17028
|
+
amount: new import_core15.BN(txArgs.amount.toString()),
|
|
16634
17029
|
assetTokenProgram,
|
|
16635
|
-
vaultAssetAta: (0,
|
|
17030
|
+
vaultAssetAta: (0, import_common38.getAtaAddress)(
|
|
16636
17031
|
txArgs.assetMint,
|
|
16637
17032
|
txArgs.vault,
|
|
16638
17033
|
assetTokenProgram,
|
|
16639
17034
|
true
|
|
16640
17035
|
),
|
|
16641
|
-
destinationAssetAta: (0,
|
|
17036
|
+
destinationAssetAta: (0, import_common38.getAtaAddress)(
|
|
16642
17037
|
txArgs.assetMint,
|
|
16643
17038
|
destination,
|
|
16644
17039
|
assetTokenProgram,
|
|
@@ -16655,18 +17050,18 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
16655
17050
|
};
|
|
16656
17051
|
|
|
16657
17052
|
// src/client/builders/protocolInteraction.ts
|
|
16658
|
-
var
|
|
17053
|
+
var import_core16 = require("@anchor-lang/core");
|
|
16659
17054
|
var import_kit8 = require("@solana/kit");
|
|
16660
17055
|
var import_spl_token16 = require("@solana/spl-token");
|
|
16661
|
-
var
|
|
16662
|
-
var
|
|
17056
|
+
var import_web319 = require("@solana/web3.js");
|
|
17057
|
+
var import_common39 = __toESM(require_dist());
|
|
16663
17058
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS = 90n;
|
|
16664
17059
|
function toAssetPriceOracleConfig(args) {
|
|
16665
17060
|
return {
|
|
16666
17061
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
16667
|
-
initialPrice: new
|
|
17062
|
+
initialPrice: new import_core16.BN((args?.initialPrice ?? 0n).toString()),
|
|
16668
17063
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
16669
|
-
pythMaxAgeSecs: new
|
|
17064
|
+
pythMaxAgeSecs: new import_core16.BN(
|
|
16670
17065
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS).toString()
|
|
16671
17066
|
)
|
|
16672
17067
|
};
|
|
@@ -16674,12 +17069,12 @@ function toAssetPriceOracleConfig(args) {
|
|
|
16674
17069
|
function toAnchorAssetPriceOracleConfig(config) {
|
|
16675
17070
|
return {
|
|
16676
17071
|
...config,
|
|
16677
|
-
priceOracleAccount: (0,
|
|
17072
|
+
priceOracleAccount: (0, import_common39.toWeb3Pk)(config.priceOracleAccount)
|
|
16678
17073
|
};
|
|
16679
17074
|
}
|
|
16680
17075
|
function toWeb3AccountMeta2(account) {
|
|
16681
17076
|
return {
|
|
16682
|
-
pubkey: new
|
|
17077
|
+
pubkey: new import_web319.PublicKey(account.address),
|
|
16683
17078
|
isWritable: account.role === import_kit8.AccountRole.WRITABLE || account.role === import_kit8.AccountRole.WRITABLE_SIGNER,
|
|
16684
17079
|
isSigner: account.role === import_kit8.AccountRole.READONLY_SIGNER || account.role === import_kit8.AccountRole.WRITABLE_SIGNER
|
|
16685
17080
|
};
|
|
@@ -16688,14 +17083,14 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
16688
17083
|
async getIx(args) {
|
|
16689
17084
|
return this.program.methods.protocolInteraction(args.refs, {
|
|
16690
17085
|
externalLiquidityIndex: args.externalLiquidityIndex,
|
|
16691
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
17086
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common39.toWeb3Pk)(args.affectedAssetMint) : null
|
|
16692
17087
|
}).accountsPartial({
|
|
16693
|
-
hwManager: (0,
|
|
16694
|
-
vault: (0,
|
|
16695
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
16696
|
-
affectedVaultAta: args.affectedVaultAta ? (0,
|
|
16697
|
-
affectedTokenProgram: args.affectedTokenProgram ? (0,
|
|
16698
|
-
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(
|
|
17088
|
+
hwManager: (0, import_common39.toWeb3Pk)(args.hwManager),
|
|
17089
|
+
vault: (0, import_common39.toWeb3Pk)(args.vault),
|
|
17090
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common39.toWeb3Pk)(args.affectedAssetMint) : null,
|
|
17091
|
+
affectedVaultAta: args.affectedVaultAta ? (0, import_common39.toWeb3Pk)(args.affectedVaultAta) : null,
|
|
17092
|
+
affectedTokenProgram: args.affectedTokenProgram ? (0, import_common39.toWeb3Pk)(args.affectedTokenProgram) : null
|
|
17093
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common39.toKitInstruction);
|
|
16699
17094
|
}
|
|
16700
17095
|
async deriveIxArgs(txArgs) {
|
|
16701
17096
|
const affectedTokenProgram = txArgs.affectedAssetMint ? txArgs.affectedTokenProgram ?? TOKEN_PROGRAM_ID : null;
|
|
@@ -16707,7 +17102,7 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
16707
17102
|
accounts: txArgs.accounts,
|
|
16708
17103
|
affectedAssetMint: txArgs.affectedAssetMint ?? null,
|
|
16709
17104
|
affectedTokenProgram,
|
|
16710
|
-
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0,
|
|
17105
|
+
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common39.getAtaAddress)(
|
|
16711
17106
|
txArgs.affectedAssetMint,
|
|
16712
17107
|
txArgs.vault,
|
|
16713
17108
|
affectedTokenProgram,
|
|
@@ -16726,18 +17121,18 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
16726
17121
|
args.destinationPriceOracle
|
|
16727
17122
|
)
|
|
16728
17123
|
}).accountsPartial({
|
|
16729
|
-
hwManager: (0,
|
|
16730
|
-
vault: (0,
|
|
16731
|
-
sourceMint: (0,
|
|
16732
|
-
destinationMint: (0,
|
|
16733
|
-
vaultSourceAta: (0,
|
|
16734
|
-
vaultDestinationAta: (0,
|
|
16735
|
-
sourceTokenProgram: (0,
|
|
16736
|
-
destinationTokenProgram: (0,
|
|
16737
|
-
destinationOracleAccount: args.destinationOracleAccount ? (0,
|
|
16738
|
-
vaultOracle: (0,
|
|
16739
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
16740
|
-
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(
|
|
17124
|
+
hwManager: (0, import_common39.toWeb3Pk)(args.hwManager),
|
|
17125
|
+
vault: (0, import_common39.toWeb3Pk)(args.vault),
|
|
17126
|
+
sourceMint: (0, import_common39.toWeb3Pk)(args.sourceMint),
|
|
17127
|
+
destinationMint: (0, import_common39.toWeb3Pk)(args.destinationMint),
|
|
17128
|
+
vaultSourceAta: (0, import_common39.toWeb3Pk)(args.vaultSourceAta),
|
|
17129
|
+
vaultDestinationAta: (0, import_common39.toWeb3Pk)(args.vaultDestinationAta),
|
|
17130
|
+
sourceTokenProgram: (0, import_common39.toWeb3Pk)(args.sourceTokenProgram),
|
|
17131
|
+
destinationTokenProgram: (0, import_common39.toWeb3Pk)(args.destinationTokenProgram),
|
|
17132
|
+
destinationOracleAccount: args.destinationOracleAccount ? (0, import_common39.toWeb3Pk)(args.destinationOracleAccount) : null,
|
|
17133
|
+
vaultOracle: (0, import_common39.toWeb3Pk)(args.vaultOracle),
|
|
17134
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common39.toWeb3Pk)(args.vaultTrancheState) : null
|
|
17135
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common39.toKitInstruction);
|
|
16741
17136
|
}
|
|
16742
17137
|
async deriveIxArgs(txArgs) {
|
|
16743
17138
|
const sourceTokenProgram = txArgs.sourceTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -16758,13 +17153,13 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
16758
17153
|
accounts: txArgs.accounts,
|
|
16759
17154
|
sourceTokenProgram,
|
|
16760
17155
|
destinationTokenProgram,
|
|
16761
|
-
vaultSourceAta: (0,
|
|
17156
|
+
vaultSourceAta: (0, import_common39.getAtaAddress)(
|
|
16762
17157
|
txArgs.sourceMint,
|
|
16763
17158
|
txArgs.vault,
|
|
16764
17159
|
sourceTokenProgram,
|
|
16765
17160
|
true
|
|
16766
17161
|
),
|
|
16767
|
-
vaultDestinationAta: (0,
|
|
17162
|
+
vaultDestinationAta: (0, import_common39.getAtaAddress)(
|
|
16768
17163
|
txArgs.destinationMint,
|
|
16769
17164
|
txArgs.vault,
|
|
16770
17165
|
destinationTokenProgram,
|
|
@@ -16773,24 +17168,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
16773
17168
|
};
|
|
16774
17169
|
}
|
|
16775
17170
|
async buildPreambleInstructions(args) {
|
|
16776
|
-
const payer = (0,
|
|
17171
|
+
const payer = (0, import_common39.toWeb3Pk)(args.hwManager);
|
|
16777
17172
|
const createSourceAta = (0, import_spl_token16.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16778
17173
|
payer,
|
|
16779
|
-
(0,
|
|
16780
|
-
(0,
|
|
16781
|
-
(0,
|
|
16782
|
-
(0,
|
|
17174
|
+
(0, import_common39.toWeb3Pk)(args.vaultSourceAta),
|
|
17175
|
+
(0, import_common39.toWeb3Pk)(args.vault),
|
|
17176
|
+
(0, import_common39.toWeb3Pk)(args.sourceMint),
|
|
17177
|
+
(0, import_common39.toWeb3Pk)(args.sourceTokenProgram),
|
|
16783
17178
|
import_spl_token16.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16784
17179
|
);
|
|
16785
17180
|
const createDestinationAta = (0, import_spl_token16.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16786
17181
|
payer,
|
|
16787
|
-
(0,
|
|
16788
|
-
(0,
|
|
16789
|
-
(0,
|
|
16790
|
-
(0,
|
|
17182
|
+
(0, import_common39.toWeb3Pk)(args.vaultDestinationAta),
|
|
17183
|
+
(0, import_common39.toWeb3Pk)(args.vault),
|
|
17184
|
+
(0, import_common39.toWeb3Pk)(args.destinationMint),
|
|
17185
|
+
(0, import_common39.toWeb3Pk)(args.destinationTokenProgram),
|
|
16791
17186
|
import_spl_token16.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16792
17187
|
);
|
|
16793
|
-
return [createSourceAta, createDestinationAta].map(
|
|
17188
|
+
return [createSourceAta, createDestinationAta].map(import_common39.toKitInstruction);
|
|
16794
17189
|
}
|
|
16795
17190
|
async buildLookupTables(_args, txArgs) {
|
|
16796
17191
|
return txArgs.lookupTables;
|
|
@@ -16823,27 +17218,27 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
16823
17218
|
};
|
|
16824
17219
|
|
|
16825
17220
|
// src/client/builders/requestJuniorTrancheWithdraw.ts
|
|
16826
|
-
var
|
|
17221
|
+
var import_core17 = require("@anchor-lang/core");
|
|
16827
17222
|
var import_spl_token17 = require("@solana/spl-token");
|
|
16828
|
-
var
|
|
16829
|
-
var
|
|
17223
|
+
var import_web320 = require("@solana/web3.js");
|
|
17224
|
+
var import_common40 = __toESM(require_dist());
|
|
16830
17225
|
var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16831
17226
|
async getIx(args) {
|
|
16832
17227
|
return this.program.methods.requestJuniorTrancheWithdraw(args.queueId, args.shareAmount).accountsPartial({
|
|
16833
|
-
user: (0,
|
|
16834
|
-
payer: (0,
|
|
16835
|
-
vault: (0,
|
|
16836
|
-
vaultOracle: (0,
|
|
16837
|
-
vaultTrancheState: (0,
|
|
16838
|
-
withdrawalQueue: (0,
|
|
16839
|
-
outputMint: (0,
|
|
16840
|
-
inputMint: (0,
|
|
16841
|
-
userInputAta: (0,
|
|
16842
|
-
queueInputAta: (0,
|
|
16843
|
-
shareTokenProgram: (0,
|
|
17228
|
+
user: (0, import_common40.toWeb3Pk)(args.user),
|
|
17229
|
+
payer: (0, import_common40.toWeb3Pk)(args.payer),
|
|
17230
|
+
vault: (0, import_common40.toWeb3Pk)(args.vault),
|
|
17231
|
+
vaultOracle: (0, import_common40.toWeb3Pk)(args.vaultOracle),
|
|
17232
|
+
vaultTrancheState: (0, import_common40.toWeb3Pk)(args.vaultTrancheState),
|
|
17233
|
+
withdrawalQueue: (0, import_common40.toWeb3Pk)(args.withdrawalQueue),
|
|
17234
|
+
outputMint: (0, import_common40.toWeb3Pk)(args.outputMint),
|
|
17235
|
+
inputMint: (0, import_common40.toWeb3Pk)(args.inputMint),
|
|
17236
|
+
userInputAta: (0, import_common40.toWeb3Pk)(args.userInputAta),
|
|
17237
|
+
queueInputAta: (0, import_common40.toWeb3Pk)(args.queueInputAta),
|
|
17238
|
+
shareTokenProgram: (0, import_common40.toWeb3Pk)(args.shareTokenProgram),
|
|
16844
17239
|
associatedTokenProgram: import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16845
|
-
systemProgram:
|
|
16846
|
-
}).instruction().then(
|
|
17240
|
+
systemProgram: import_web320.SystemProgram.programId
|
|
17241
|
+
}).instruction().then(import_common40.toKitInstruction);
|
|
16847
17242
|
}
|
|
16848
17243
|
async deriveIxArgs(txArgs) {
|
|
16849
17244
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -16877,10 +17272,10 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16877
17272
|
outputMint: txArgs.assetMint,
|
|
16878
17273
|
inputMint: juniorShareMint,
|
|
16879
17274
|
queueId: txArgs.queueId,
|
|
16880
|
-
shareAmount: new
|
|
17275
|
+
shareAmount: new import_core17.BN(txArgs.shareAmount.toString()),
|
|
16881
17276
|
shareTokenProgram,
|
|
16882
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
16883
|
-
queueInputAta: (0,
|
|
17277
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common40.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
17278
|
+
queueInputAta: (0, import_common40.getAtaAddress)(
|
|
16884
17279
|
juniorShareMint,
|
|
16885
17280
|
queuePda,
|
|
16886
17281
|
shareTokenProgram,
|
|
@@ -16902,17 +17297,17 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16902
17297
|
};
|
|
16903
17298
|
|
|
16904
17299
|
// src/client/builders/vaultReallocation.ts
|
|
16905
|
-
var
|
|
17300
|
+
var import_core18 = require("@anchor-lang/core");
|
|
16906
17301
|
var import_spl_token18 = require("@solana/spl-token");
|
|
16907
|
-
var
|
|
16908
|
-
var
|
|
17302
|
+
var import_web321 = require("@solana/web3.js");
|
|
17303
|
+
var import_common41 = __toESM(require_dist());
|
|
16909
17304
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS2 = 90n;
|
|
16910
17305
|
function toAssetPriceOracleConfig2(args) {
|
|
16911
17306
|
return {
|
|
16912
17307
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
16913
|
-
initialPrice: new
|
|
17308
|
+
initialPrice: new import_core18.BN((args?.initialPrice ?? 0n).toString()),
|
|
16914
17309
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
16915
|
-
pythMaxAgeSecs: new
|
|
17310
|
+
pythMaxAgeSecs: new import_core18.BN(
|
|
16916
17311
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS2).toString()
|
|
16917
17312
|
)
|
|
16918
17313
|
};
|
|
@@ -16920,7 +17315,7 @@ function toAssetPriceOracleConfig2(args) {
|
|
|
16920
17315
|
function toAnchorAssetPriceOracleConfig2(config) {
|
|
16921
17316
|
return {
|
|
16922
17317
|
...config,
|
|
16923
|
-
priceOracleAccount: (0,
|
|
17318
|
+
priceOracleAccount: (0, import_common41.toWeb3Pk)(config.priceOracleAccount)
|
|
16924
17319
|
};
|
|
16925
17320
|
}
|
|
16926
17321
|
var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
@@ -16929,35 +17324,35 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
16929
17324
|
amount: args.amount,
|
|
16930
17325
|
assetPriceOracle: toAnchorAssetPriceOracleConfig2(args.assetPriceOracle)
|
|
16931
17326
|
}).accountsPartial({
|
|
16932
|
-
manager: (0,
|
|
16933
|
-
allocationVault: (0,
|
|
16934
|
-
sourceVault: args.sourceVault ? (0,
|
|
16935
|
-
sourceVaultOracle: args.sourceVaultOracle ? (0,
|
|
16936
|
-
destinationVault: (0,
|
|
16937
|
-
destinationVaultOracle: (0,
|
|
16938
|
-
mint: (0,
|
|
16939
|
-
sourceShareMint: args.sourceShareMint ? (0,
|
|
16940
|
-
destinationShareMint: (0,
|
|
16941
|
-
allocationMintAta: (0,
|
|
16942
|
-
sourceVaultMintAta: args.sourceVaultMintAta ? (0,
|
|
16943
|
-
destinationVaultMintAta: (0,
|
|
16944
|
-
destinationFeeVault: (0,
|
|
16945
|
-
destinationFeeVaultMintAta: (0,
|
|
16946
|
-
allocationSourceShareAta: args.allocationSourceShareAta ? (0,
|
|
16947
|
-
allocationDestinationShareAta: (0,
|
|
17327
|
+
manager: (0, import_common41.toWeb3Pk)(args.manager),
|
|
17328
|
+
allocationVault: (0, import_common41.toWeb3Pk)(args.allocationVault),
|
|
17329
|
+
sourceVault: args.sourceVault ? (0, import_common41.toWeb3Pk)(args.sourceVault) : null,
|
|
17330
|
+
sourceVaultOracle: args.sourceVaultOracle ? (0, import_common41.toWeb3Pk)(args.sourceVaultOracle) : null,
|
|
17331
|
+
destinationVault: (0, import_common41.toWeb3Pk)(args.destinationVault),
|
|
17332
|
+
destinationVaultOracle: (0, import_common41.toWeb3Pk)(args.destinationVaultOracle),
|
|
17333
|
+
mint: (0, import_common41.toWeb3Pk)(args.mint),
|
|
17334
|
+
sourceShareMint: args.sourceShareMint ? (0, import_common41.toWeb3Pk)(args.sourceShareMint) : null,
|
|
17335
|
+
destinationShareMint: (0, import_common41.toWeb3Pk)(args.destinationShareMint),
|
|
17336
|
+
allocationMintAta: (0, import_common41.toWeb3Pk)(args.allocationMintAta),
|
|
17337
|
+
sourceVaultMintAta: args.sourceVaultMintAta ? (0, import_common41.toWeb3Pk)(args.sourceVaultMintAta) : null,
|
|
17338
|
+
destinationVaultMintAta: (0, import_common41.toWeb3Pk)(args.destinationVaultMintAta),
|
|
17339
|
+
destinationFeeVault: (0, import_common41.toWeb3Pk)(args.destinationFeeVault),
|
|
17340
|
+
destinationFeeVaultMintAta: (0, import_common41.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
17341
|
+
allocationSourceShareAta: args.allocationSourceShareAta ? (0, import_common41.toWeb3Pk)(args.allocationSourceShareAta) : null,
|
|
17342
|
+
allocationDestinationShareAta: (0, import_common41.toWeb3Pk)(
|
|
16948
17343
|
args.allocationDestinationShareAta
|
|
16949
17344
|
),
|
|
16950
|
-
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0,
|
|
16951
|
-
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0,
|
|
16952
|
-
assetOracleAccount: args.assetOracleAccount ? (0,
|
|
16953
|
-
assetTokenProgram: (0,
|
|
16954
|
-
sourceShareTokenProgram: (0,
|
|
16955
|
-
destinationShareTokenProgram: (0,
|
|
17345
|
+
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0, import_common41.toWeb3Pk)(args.sourceVaultTrancheState) : null,
|
|
17346
|
+
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0, import_common41.toWeb3Pk)(args.destinationVaultTrancheState) : null,
|
|
17347
|
+
assetOracleAccount: args.assetOracleAccount ? (0, import_common41.toWeb3Pk)(args.assetOracleAccount) : null,
|
|
17348
|
+
assetTokenProgram: (0, import_common41.toWeb3Pk)(args.assetTokenProgram),
|
|
17349
|
+
sourceShareTokenProgram: (0, import_common41.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
17350
|
+
destinationShareTokenProgram: (0, import_common41.toWeb3Pk)(
|
|
16956
17351
|
args.destinationShareTokenProgram
|
|
16957
17352
|
),
|
|
16958
17353
|
associatedTokenProgram: import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16959
|
-
systemProgram:
|
|
16960
|
-
}).instruction().then(
|
|
17354
|
+
systemProgram: import_web321.SystemProgram.programId
|
|
17355
|
+
}).instruction().then(import_common41.toKitInstruction);
|
|
16961
17356
|
}
|
|
16962
17357
|
async deriveIxArgs(txArgs) {
|
|
16963
17358
|
const assetTokenProgram = txArgs.assetTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -16982,7 +17377,7 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
16982
17377
|
mint: txArgs.mint,
|
|
16983
17378
|
sourceShareMint,
|
|
16984
17379
|
destinationShareMint: txArgs.destinationShareMint,
|
|
16985
|
-
amount: new
|
|
17380
|
+
amount: new import_core18.BN(txArgs.amount.toString()),
|
|
16986
17381
|
assetPriceOracle: toAssetPriceOracleConfig2(txArgs.assetPriceOracle),
|
|
16987
17382
|
sourceVaultTrancheState: txArgs.sourceVaultTrancheState ?? null,
|
|
16988
17383
|
destinationVaultTrancheState: txArgs.destinationVaultTrancheState ?? null,
|
|
@@ -16990,33 +17385,33 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
16990
17385
|
assetTokenProgram,
|
|
16991
17386
|
sourceShareTokenProgram,
|
|
16992
17387
|
destinationShareTokenProgram,
|
|
16993
|
-
allocationMintAta: (0,
|
|
17388
|
+
allocationMintAta: (0, import_common41.getAtaAddress)(
|
|
16994
17389
|
txArgs.mint,
|
|
16995
17390
|
txArgs.allocationVault,
|
|
16996
17391
|
assetTokenProgram,
|
|
16997
17392
|
true
|
|
16998
17393
|
),
|
|
16999
|
-
sourceVaultMintAta: sourceVault ? (0,
|
|
17000
|
-
destinationVaultMintAta: (0,
|
|
17394
|
+
sourceVaultMintAta: sourceVault ? (0, import_common41.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
|
|
17395
|
+
destinationVaultMintAta: (0, import_common41.getAtaAddress)(
|
|
17001
17396
|
txArgs.mint,
|
|
17002
17397
|
txArgs.destinationVault,
|
|
17003
17398
|
assetTokenProgram,
|
|
17004
17399
|
true
|
|
17005
17400
|
),
|
|
17006
17401
|
destinationFeeVault,
|
|
17007
|
-
destinationFeeVaultMintAta: (0,
|
|
17402
|
+
destinationFeeVaultMintAta: (0, import_common41.getAtaAddress)(
|
|
17008
17403
|
txArgs.mint,
|
|
17009
17404
|
destinationFeeVault,
|
|
17010
17405
|
assetTokenProgram,
|
|
17011
17406
|
true
|
|
17012
17407
|
),
|
|
17013
|
-
allocationSourceShareAta: sourceShareMint && sourceVault ? (0,
|
|
17408
|
+
allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common41.getAtaAddress)(
|
|
17014
17409
|
sourceShareMint,
|
|
17015
17410
|
txArgs.allocationVault,
|
|
17016
17411
|
sourceShareTokenProgram,
|
|
17017
17412
|
true
|
|
17018
17413
|
) : null,
|
|
17019
|
-
allocationDestinationShareAta: (0,
|
|
17414
|
+
allocationDestinationShareAta: (0, import_common41.getAtaAddress)(
|
|
17020
17415
|
txArgs.destinationShareMint,
|
|
17021
17416
|
txArgs.allocationVault,
|
|
17022
17417
|
destinationShareTokenProgram,
|
|
@@ -17025,38 +17420,38 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17025
17420
|
};
|
|
17026
17421
|
}
|
|
17027
17422
|
async buildPreambleInstructions(args) {
|
|
17028
|
-
const payer = (0,
|
|
17423
|
+
const payer = (0, import_common41.toWeb3Pk)(args.manager);
|
|
17029
17424
|
const instructions2 = [
|
|
17030
17425
|
(0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17031
17426
|
payer,
|
|
17032
|
-
(0,
|
|
17033
|
-
(0,
|
|
17034
|
-
(0,
|
|
17035
|
-
(0,
|
|
17427
|
+
(0, import_common41.toWeb3Pk)(args.allocationMintAta),
|
|
17428
|
+
(0, import_common41.toWeb3Pk)(args.allocationVault),
|
|
17429
|
+
(0, import_common41.toWeb3Pk)(args.mint),
|
|
17430
|
+
(0, import_common41.toWeb3Pk)(args.assetTokenProgram),
|
|
17036
17431
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17037
17432
|
),
|
|
17038
17433
|
(0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17039
17434
|
payer,
|
|
17040
|
-
(0,
|
|
17041
|
-
(0,
|
|
17042
|
-
(0,
|
|
17043
|
-
(0,
|
|
17435
|
+
(0, import_common41.toWeb3Pk)(args.destinationVaultMintAta),
|
|
17436
|
+
(0, import_common41.toWeb3Pk)(args.destinationVault),
|
|
17437
|
+
(0, import_common41.toWeb3Pk)(args.mint),
|
|
17438
|
+
(0, import_common41.toWeb3Pk)(args.assetTokenProgram),
|
|
17044
17439
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17045
17440
|
),
|
|
17046
17441
|
(0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17047
17442
|
payer,
|
|
17048
|
-
(0,
|
|
17049
|
-
(0,
|
|
17050
|
-
(0,
|
|
17051
|
-
(0,
|
|
17443
|
+
(0, import_common41.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
17444
|
+
(0, import_common41.toWeb3Pk)(args.destinationFeeVault),
|
|
17445
|
+
(0, import_common41.toWeb3Pk)(args.mint),
|
|
17446
|
+
(0, import_common41.toWeb3Pk)(args.assetTokenProgram),
|
|
17052
17447
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17053
17448
|
),
|
|
17054
17449
|
(0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17055
17450
|
payer,
|
|
17056
|
-
(0,
|
|
17057
|
-
(0,
|
|
17058
|
-
(0,
|
|
17059
|
-
(0,
|
|
17451
|
+
(0, import_common41.toWeb3Pk)(args.allocationDestinationShareAta),
|
|
17452
|
+
(0, import_common41.toWeb3Pk)(args.allocationVault),
|
|
17453
|
+
(0, import_common41.toWeb3Pk)(args.destinationShareMint),
|
|
17454
|
+
(0, import_common41.toWeb3Pk)(args.destinationShareTokenProgram),
|
|
17060
17455
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17061
17456
|
)
|
|
17062
17457
|
];
|
|
@@ -17064,23 +17459,23 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17064
17459
|
instructions2.push(
|
|
17065
17460
|
(0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17066
17461
|
payer,
|
|
17067
|
-
(0,
|
|
17068
|
-
(0,
|
|
17069
|
-
(0,
|
|
17070
|
-
(0,
|
|
17462
|
+
(0, import_common41.toWeb3Pk)(args.sourceVaultMintAta),
|
|
17463
|
+
(0, import_common41.toWeb3Pk)(args.sourceVault),
|
|
17464
|
+
(0, import_common41.toWeb3Pk)(args.mint),
|
|
17465
|
+
(0, import_common41.toWeb3Pk)(args.assetTokenProgram),
|
|
17071
17466
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17072
17467
|
),
|
|
17073
17468
|
(0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17074
17469
|
payer,
|
|
17075
|
-
(0,
|
|
17076
|
-
(0,
|
|
17077
|
-
(0,
|
|
17078
|
-
(0,
|
|
17470
|
+
(0, import_common41.toWeb3Pk)(args.allocationSourceShareAta),
|
|
17471
|
+
(0, import_common41.toWeb3Pk)(args.allocationVault),
|
|
17472
|
+
(0, import_common41.toWeb3Pk)(args.sourceShareMint),
|
|
17473
|
+
(0, import_common41.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
17079
17474
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17080
17475
|
)
|
|
17081
17476
|
);
|
|
17082
17477
|
}
|
|
17083
|
-
return instructions2.map(
|
|
17478
|
+
return instructions2.map(import_common41.toKitInstruction);
|
|
17084
17479
|
}
|
|
17085
17480
|
async buildPlanExtras(args) {
|
|
17086
17481
|
return {
|
|
@@ -17118,6 +17513,13 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17118
17513
|
// src/client/transaction.ts
|
|
17119
17514
|
var TransactionClient = class {
|
|
17120
17515
|
constructor(context) {
|
|
17516
|
+
this.createIncentiveV3 = new CreateIncentiveV3Builder(context);
|
|
17517
|
+
this.addIncentiveRecipientV3 = new AddIncentiveRecipientV3Builder(context);
|
|
17518
|
+
this.setIncentiveLimitsV3 = new SetIncentiveLimitsV3Builder(context);
|
|
17519
|
+
this.reportIncentiveV3 = new ReportIncentiveV3Builder(context);
|
|
17520
|
+
this.settleIncentiveV3 = new SettleIncentiveV3Builder(context);
|
|
17521
|
+
this.claimIncentiveV3 = new ClaimIncentiveV3Builder(context);
|
|
17522
|
+
this.distributeIncentiveV3 = new DistributeIncentiveV3Builder(context);
|
|
17121
17523
|
this.claimIncentive = new ClaimIncentiveBuilder(context);
|
|
17122
17524
|
this.createIncentive = new CreateIncentiveBuilder(context);
|
|
17123
17525
|
this.addIncentiveRecipient = new AddIncentiveRecipientBuilder(context);
|
|
@@ -17171,7 +17573,7 @@ var VaultClient = class {
|
|
|
17171
17573
|
this.provider = provider;
|
|
17172
17574
|
this.skipSimulation = options.skipSimulation ?? false;
|
|
17173
17575
|
const idl = { ...IDL, address: programId };
|
|
17174
|
-
this.program = new
|
|
17576
|
+
this.program = new import_core19.Program(idl, provider);
|
|
17175
17577
|
this.pda = new PdaClient((0, import_kit9.address)(this.program.programId.toBase58()));
|
|
17176
17578
|
const rpc = createRpcFromConnection(provider.connection);
|
|
17177
17579
|
this.account = new AccountClient(this.program, this.pda, rpc);
|
|
@@ -17193,8 +17595,8 @@ var VaultClient = class {
|
|
|
17193
17595
|
*/
|
|
17194
17596
|
async sendTransaction(payer, plan, extraSigners = []) {
|
|
17195
17597
|
const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
|
|
17196
|
-
const tx = new
|
|
17197
|
-
...plan.instructions.map(
|
|
17598
|
+
const tx = new import_web322.Transaction().add(
|
|
17599
|
+
...plan.instructions.map(import_common42.fromKitInstruction)
|
|
17198
17600
|
);
|
|
17199
17601
|
tx.feePayer = payer.publicKey;
|
|
17200
17602
|
tx.recentBlockhash = blockhash;
|
|
@@ -17228,13 +17630,13 @@ var VaultClient = class {
|
|
|
17228
17630
|
const { blockhash } = await this.provider.connection.getLatestBlockhash(
|
|
17229
17631
|
"confirmed"
|
|
17230
17632
|
);
|
|
17231
|
-
const lookupTableAccounts = plan.lookupTables?.length ? await (0,
|
|
17232
|
-
const message2 = new
|
|
17633
|
+
const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common42.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
|
|
17634
|
+
const message2 = new import_web322.TransactionMessage({
|
|
17233
17635
|
payerKey: payer.publicKey,
|
|
17234
17636
|
recentBlockhash: blockhash,
|
|
17235
|
-
instructions: plan.instructions.map(
|
|
17637
|
+
instructions: plan.instructions.map(import_common42.fromKitInstruction)
|
|
17236
17638
|
}).compileToV0Message(lookupTableAccounts);
|
|
17237
|
-
const tx = new
|
|
17639
|
+
const tx = new import_web322.VersionedTransaction(message2);
|
|
17238
17640
|
const result = await this.provider.connection.simulateTransaction(tx, {
|
|
17239
17641
|
sigVerify: false,
|
|
17240
17642
|
commitment: "processed"
|
|
@@ -17308,7 +17710,7 @@ function resolveKeypairPath(keypairPath) {
|
|
|
17308
17710
|
}
|
|
17309
17711
|
function loadKeypair(keypairPath) {
|
|
17310
17712
|
const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
|
|
17311
|
-
return
|
|
17713
|
+
return import_web323.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
|
|
17312
17714
|
}
|
|
17313
17715
|
var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
|
|
17314
17716
|
function defaultKeypairPath(env, role = "vault") {
|
|
@@ -17319,8 +17721,8 @@ function defaultKeypairPath(env, role = "vault") {
|
|
|
17319
17721
|
}
|
|
17320
17722
|
function createVaultClient(env, opts = {}) {
|
|
17321
17723
|
const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
|
|
17322
|
-
const connection = new
|
|
17323
|
-
const provider = new
|
|
17724
|
+
const connection = new import_web323.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
|
|
17725
|
+
const provider = new import_core20.AnchorProvider(connection, new import_core20.Wallet(payer), {
|
|
17324
17726
|
commitment: "confirmed"
|
|
17325
17727
|
});
|
|
17326
17728
|
const client = new VaultClient(
|
|
@@ -17333,11 +17735,11 @@ function createVaultClient(env, opts = {}) {
|
|
|
17333
17735
|
client,
|
|
17334
17736
|
provider,
|
|
17335
17737
|
payer,
|
|
17336
|
-
signer: (0,
|
|
17738
|
+
signer: (0, import_common43.fromWeb3Pk)(payer.publicKey)
|
|
17337
17739
|
};
|
|
17338
17740
|
}
|
|
17339
17741
|
function keypairAddress(keypairPath) {
|
|
17340
|
-
return (0,
|
|
17742
|
+
return (0, import_common43.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
|
|
17341
17743
|
}
|
|
17342
17744
|
|
|
17343
17745
|
// src/utils/math.ts
|
|
@@ -17351,16 +17753,16 @@ function fromUiAmount(amount, decimals) {
|
|
|
17351
17753
|
}
|
|
17352
17754
|
|
|
17353
17755
|
// src/utils/provider.ts
|
|
17354
|
-
var
|
|
17756
|
+
var import_core21 = require("@anchor-lang/core");
|
|
17355
17757
|
function makeProvider(connection, payer) {
|
|
17356
|
-
return new
|
|
17758
|
+
return new import_core21.AnchorProvider(connection, new import_core21.Wallet(payer), {
|
|
17357
17759
|
commitment: "confirmed"
|
|
17358
17760
|
});
|
|
17359
17761
|
}
|
|
17360
17762
|
|
|
17361
17763
|
// src/utils/squads.ts
|
|
17362
17764
|
var squads = __toESM(require("@sqds/multisig"));
|
|
17363
|
-
var
|
|
17765
|
+
var import_web324 = require("@solana/web3.js");
|
|
17364
17766
|
var SQUADS_SIMULATION_COMMITMENT = "processed";
|
|
17365
17767
|
var SquadsProposalExecutionSimulationError = class extends Error {
|
|
17366
17768
|
constructor(transactionError, logs, unitsConsumed) {
|
|
@@ -17384,8 +17786,8 @@ function validateVaultIndex(vaultIndex) {
|
|
|
17384
17786
|
}
|
|
17385
17787
|
function resolveSquadsWalletRoute(route) {
|
|
17386
17788
|
validateVaultIndex(route.vaultIndex);
|
|
17387
|
-
const wallet = new
|
|
17388
|
-
const multisigPda = new
|
|
17789
|
+
const wallet = new import_web324.PublicKey(route.wallet);
|
|
17790
|
+
const multisigPda = new import_web324.PublicKey(route.multisigPda);
|
|
17389
17791
|
const [vaultPda] = squads.getVaultPda({
|
|
17390
17792
|
multisigPda,
|
|
17391
17793
|
index: route.vaultIndex
|
|
@@ -17393,7 +17795,7 @@ function resolveSquadsWalletRoute(route) {
|
|
|
17393
17795
|
return { ...route, wallet, multisigPda, vaultPda };
|
|
17394
17796
|
}
|
|
17395
17797
|
function findSquadsWalletRoute(wallet, routes) {
|
|
17396
|
-
const walletKey = typeof wallet === "string" ? new
|
|
17798
|
+
const walletKey = typeof wallet === "string" ? new import_web324.PublicKey(wallet) : wallet;
|
|
17397
17799
|
const route = routes.find(
|
|
17398
17800
|
(candidate) => candidate.wallet === walletKey.toBase58()
|
|
17399
17801
|
);
|
|
@@ -17411,18 +17813,18 @@ function validateSquadsWalletRoutes(routes) {
|
|
|
17411
17813
|
}
|
|
17412
17814
|
}
|
|
17413
17815
|
function vaultAuthorityForWallet(wallet, routes) {
|
|
17414
|
-
const walletKey = typeof wallet === "string" ? new
|
|
17816
|
+
const walletKey = typeof wallet === "string" ? new import_web324.PublicKey(wallet) : wallet;
|
|
17415
17817
|
return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
|
|
17416
17818
|
}
|
|
17417
17819
|
async function simulateSquadsProposalExecution(args) {
|
|
17418
17820
|
const { connection, feePayer, instructions: instructions2 } = args;
|
|
17419
17821
|
const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
|
|
17420
|
-
const message2 = new
|
|
17822
|
+
const message2 = new import_web324.TransactionMessage({
|
|
17421
17823
|
payerKey: feePayer,
|
|
17422
17824
|
recentBlockhash,
|
|
17423
17825
|
instructions: [...instructions2]
|
|
17424
17826
|
}).compileToV0Message(args.addressLookupTableAccounts);
|
|
17425
|
-
const transaction = new
|
|
17827
|
+
const transaction = new import_web324.VersionedTransaction(message2);
|
|
17426
17828
|
const { value } = await connection.simulateTransaction(transaction, {
|
|
17427
17829
|
sigVerify: false,
|
|
17428
17830
|
commitment: SQUADS_SIMULATION_COMMITMENT,
|
|
@@ -17443,7 +17845,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17443
17845
|
if (!route) {
|
|
17444
17846
|
return {
|
|
17445
17847
|
kind: "direct",
|
|
17446
|
-
transaction: new
|
|
17848
|
+
transaction: new import_web324.Transaction().add(...instructions2),
|
|
17447
17849
|
authority: proposer
|
|
17448
17850
|
};
|
|
17449
17851
|
}
|
|
@@ -17478,7 +17880,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17478
17880
|
addressLookupTableAccounts: args.addressLookupTableAccounts
|
|
17479
17881
|
});
|
|
17480
17882
|
}
|
|
17481
|
-
const transactionMessage = new
|
|
17883
|
+
const transactionMessage = new import_web324.TransactionMessage({
|
|
17482
17884
|
payerKey: route.vaultPda,
|
|
17483
17885
|
recentBlockhash: blockhash,
|
|
17484
17886
|
instructions: [...instructions2]
|
|
@@ -17508,7 +17910,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17508
17910
|
});
|
|
17509
17911
|
return {
|
|
17510
17912
|
kind: "squads",
|
|
17511
|
-
transaction: new
|
|
17913
|
+
transaction: new import_web324.Transaction().add(
|
|
17512
17914
|
createVaultTransactionIx,
|
|
17513
17915
|
createProposalIx
|
|
17514
17916
|
),
|
|
@@ -17523,16 +17925,16 @@ async function prepareVaultTransaction(args) {
|
|
|
17523
17925
|
|
|
17524
17926
|
// src/utils/squadsBuffer.ts
|
|
17525
17927
|
var squads2 = __toESM(require("@sqds/multisig"));
|
|
17526
|
-
var
|
|
17928
|
+
var import_web325 = require("@solana/web3.js");
|
|
17527
17929
|
var PacketSize = 1232;
|
|
17528
17930
|
var BufferChunkSize = 700;
|
|
17529
17931
|
var MaxBufferSize = 4e3;
|
|
17530
17932
|
async function prepareSquadsProposalUpload(args) {
|
|
17531
17933
|
const { connection, proposer, prepared } = args;
|
|
17532
17934
|
const transaction = prepared.transaction;
|
|
17533
|
-
const sizeProbe = new
|
|
17935
|
+
const sizeProbe = new import_web325.Transaction({
|
|
17534
17936
|
feePayer: proposer,
|
|
17535
|
-
recentBlockhash:
|
|
17937
|
+
recentBlockhash: import_web325.PublicKey.default.toBase58()
|
|
17536
17938
|
}).add(...transaction.instructions);
|
|
17537
17939
|
let fits = false;
|
|
17538
17940
|
try {
|
|
@@ -17552,7 +17954,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17552
17954
|
let bufferPda;
|
|
17553
17955
|
let bufferIndex = 0;
|
|
17554
17956
|
for (; bufferIndex <= 255; bufferIndex++) {
|
|
17555
|
-
const [candidate] =
|
|
17957
|
+
const [candidate] = import_web325.PublicKey.findProgramAddressSync(
|
|
17556
17958
|
[
|
|
17557
17959
|
Buffer.from("multisig"),
|
|
17558
17960
|
prepared.multisigPda.toBuffer(),
|
|
@@ -17580,7 +17982,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17580
17982
|
creator: proposer
|
|
17581
17983
|
};
|
|
17582
17984
|
const setupTransactions = [
|
|
17583
|
-
new
|
|
17985
|
+
new import_web325.Transaction().add(
|
|
17584
17986
|
squads2.generated.createTransactionBufferCreateInstruction(
|
|
17585
17987
|
{
|
|
17586
17988
|
...accounts2,
|
|
@@ -17600,7 +18002,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17600
18002
|
];
|
|
17601
18003
|
for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
|
|
17602
18004
|
setupTransactions.push(
|
|
17603
|
-
new
|
|
18005
|
+
new import_web325.Transaction().add(
|
|
17604
18006
|
squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
|
|
17605
18007
|
args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
|
|
17606
18008
|
})
|
|
@@ -17613,7 +18015,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17613
18015
|
vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
|
|
17614
18016
|
vaultTransactionCreateItemCreator: proposer,
|
|
17615
18017
|
vaultTransactionCreateItemRentPayer: proposer,
|
|
17616
|
-
vaultTransactionCreateItemSystemProgram:
|
|
18018
|
+
vaultTransactionCreateItemSystemProgram: import_web325.SystemProgram.programId,
|
|
17617
18019
|
transactionBuffer: bufferPda,
|
|
17618
18020
|
creator: proposer
|
|
17619
18021
|
},
|
|
@@ -17625,7 +18027,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17625
18027
|
).isWritable = true;
|
|
17626
18028
|
return {
|
|
17627
18029
|
setupTransactions,
|
|
17628
|
-
proposalTransaction: new
|
|
18030
|
+
proposalTransaction: new import_web325.Transaction().add(
|
|
17629
18031
|
finalize,
|
|
17630
18032
|
...transaction.instructions.slice(1)
|
|
17631
18033
|
),
|
|
@@ -17636,13 +18038,13 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17636
18038
|
|
|
17637
18039
|
// src/utils/token.ts
|
|
17638
18040
|
var import_spl_token19 = require("@solana/spl-token");
|
|
17639
|
-
var
|
|
17640
|
-
var
|
|
18041
|
+
var import_web326 = require("@solana/web3.js");
|
|
18042
|
+
var import_common44 = __toESM(require_dist());
|
|
17641
18043
|
async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token19.TOKEN_2022_PROGRAM_ID) {
|
|
17642
|
-
const mint =
|
|
18044
|
+
const mint = import_web326.Keypair.generate();
|
|
17643
18045
|
const lamports = await (0, import_spl_token19.getMinimumBalanceForRentExemptMint)(connection);
|
|
17644
18046
|
const ixs = [
|
|
17645
|
-
|
|
18047
|
+
import_web326.SystemProgram.createAccount({
|
|
17646
18048
|
fromPubkey: payer,
|
|
17647
18049
|
newAccountPubkey: mint.publicKey,
|
|
17648
18050
|
space: import_spl_token19.MINT_SIZE,
|
|
@@ -17668,7 +18070,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
17668
18070
|
tokenProgram
|
|
17669
18071
|
);
|
|
17670
18072
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
17671
|
-
const tx = new
|
|
18073
|
+
const tx = new import_web326.Transaction().add(...ixs);
|
|
17672
18074
|
tx.feePayer = payer.publicKey;
|
|
17673
18075
|
tx.recentBlockhash = blockhash;
|
|
17674
18076
|
tx.sign(payer, mint);
|
|
@@ -17682,7 +18084,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
17682
18084
|
return mint.publicKey;
|
|
17683
18085
|
}
|
|
17684
18086
|
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token19.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
|
|
17685
|
-
const tokenProgramPk = (0,
|
|
18087
|
+
const tokenProgramPk = (0, import_common44.asWeb3PublicKey)(tokenProgram);
|
|
17686
18088
|
const ata = (0, import_spl_token19.getAssociatedTokenAddressSync)(
|
|
17687
18089
|
mint,
|
|
17688
18090
|
destination,
|
|
@@ -17707,12 +18109,12 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
|
|
|
17707
18109
|
tokenProgramPk
|
|
17708
18110
|
)
|
|
17709
18111
|
];
|
|
17710
|
-
const tx = new
|
|
18112
|
+
const tx = new import_web326.Transaction().add(...ixs);
|
|
17711
18113
|
await connection.sendTransaction(tx, [payer]);
|
|
17712
18114
|
}
|
|
17713
18115
|
|
|
17714
18116
|
// src/utils/yieldApi.ts
|
|
17715
|
-
var
|
|
18117
|
+
var import_core22 = require("@anchor-lang/core");
|
|
17716
18118
|
var YIELD_API_BASE = process.env.YIELD_API_BASE ?? "https://yield-tracker.perena.org";
|
|
17717
18119
|
async function yieldApiReq(endpoint, reqType, bodyData, options) {
|
|
17718
18120
|
const headers = {
|
|
@@ -18038,7 +18440,7 @@ async function getTrackedValue(accountName) {
|
|
|
18038
18440
|
return trackedValueFromResponse(await getYield(accountName));
|
|
18039
18441
|
}
|
|
18040
18442
|
async function getTotalYield(accountNames, start, end) {
|
|
18041
|
-
let totalYield = new
|
|
18443
|
+
let totalYield = new import_core22.BN(0);
|
|
18042
18444
|
for (const accountName of accountNames) {
|
|
18043
18445
|
const res = await getYield(accountName, start, end);
|
|
18044
18446
|
if (isNavAccountValue(res)) {
|
|
@@ -18047,7 +18449,7 @@ async function getTotalYield(accountNames, start, end) {
|
|
|
18047
18449
|
);
|
|
18048
18450
|
}
|
|
18049
18451
|
console.log(res);
|
|
18050
|
-
totalYield = totalYield.add(new
|
|
18452
|
+
totalYield = totalYield.add(new import_core22.BN(res.total_yield));
|
|
18051
18453
|
}
|
|
18052
18454
|
return totalYield;
|
|
18053
18455
|
}
|
|
@@ -18079,7 +18481,7 @@ async function getTotalTrackedValue(accountNames, start, end) {
|
|
|
18079
18481
|
}
|
|
18080
18482
|
|
|
18081
18483
|
// src/services/withdrawalQueueService.ts
|
|
18082
|
-
var
|
|
18484
|
+
var import_common45 = __toESM(require_dist());
|
|
18083
18485
|
function bnToBigInt(value) {
|
|
18084
18486
|
return BigInt(value.toString());
|
|
18085
18487
|
}
|
|
@@ -18100,7 +18502,7 @@ var WithdrawalQueueService = class {
|
|
|
18100
18502
|
const program = this.client.program.account;
|
|
18101
18503
|
const accounts2 = await program.vaultWithdrawalQueue.all();
|
|
18102
18504
|
return accounts2.map(
|
|
18103
|
-
(entry) => this.toSnapshot((0,
|
|
18505
|
+
(entry) => this.toSnapshot((0, import_common45.fromWeb3Pk)(entry.publicKey), entry.account)
|
|
18104
18506
|
);
|
|
18105
18507
|
}
|
|
18106
18508
|
/** Withdrawal queues for a single vault. */
|
|
@@ -18141,7 +18543,7 @@ var WithdrawalQueueService = class {
|
|
|
18141
18543
|
async fulfill(signer, queue) {
|
|
18142
18544
|
const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
|
|
18143
18545
|
owner: queue.owner,
|
|
18144
|
-
signer: (0,
|
|
18546
|
+
signer: (0, import_common45.fromWeb3Pk)(signer.publicKey),
|
|
18145
18547
|
queuePayer: queue.payer,
|
|
18146
18548
|
vault: queue.vault,
|
|
18147
18549
|
withdrawalQueue: queue.pda,
|
|
@@ -18195,12 +18597,12 @@ var WithdrawalQueueService = class {
|
|
|
18195
18597
|
const a = account;
|
|
18196
18598
|
return {
|
|
18197
18599
|
pda,
|
|
18198
|
-
vault: (0,
|
|
18199
|
-
owner: (0,
|
|
18200
|
-
payer: (0,
|
|
18600
|
+
vault: (0, import_common45.fromWeb3Pk)(a.parties.vault),
|
|
18601
|
+
owner: (0, import_common45.fromWeb3Pk)(a.parties.owner),
|
|
18602
|
+
payer: (0, import_common45.fromWeb3Pk)(a.parties.payer),
|
|
18201
18603
|
queueId: a.header.queueId,
|
|
18202
|
-
inputMint: (0,
|
|
18203
|
-
outputMint: (0,
|
|
18604
|
+
inputMint: (0, import_common45.fromWeb3Pk)(a.mints.inputMint),
|
|
18605
|
+
outputMint: (0, import_common45.fromWeb3Pk)(a.mints.outputMint),
|
|
18204
18606
|
inputAmount: bnToBigInt(a.request.inputAmount),
|
|
18205
18607
|
requestTs: bnToNumber(a.request.requestTs),
|
|
18206
18608
|
expiryTs: bnToNumber(a.request.expiryTs)
|
|
@@ -18210,10 +18612,10 @@ var WithdrawalQueueService = class {
|
|
|
18210
18612
|
|
|
18211
18613
|
// src/services/oracleService.ts
|
|
18212
18614
|
var import_kit11 = require("@solana/kit");
|
|
18213
|
-
var
|
|
18214
|
-
var
|
|
18615
|
+
var import_common46 = __toESM(require_dist());
|
|
18616
|
+
var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
|
|
18215
18617
|
var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
|
|
18216
|
-
var
|
|
18618
|
+
var PRICE_ORACLE_TYPES_BY_INDEX2 = [
|
|
18217
18619
|
"none",
|
|
18218
18620
|
"consensusOracle",
|
|
18219
18621
|
"pyth",
|
|
@@ -18234,14 +18636,14 @@ function pubkeyString2(value) {
|
|
|
18234
18636
|
return String(value);
|
|
18235
18637
|
}
|
|
18236
18638
|
function isZeroPubkey(value) {
|
|
18237
|
-
return !value || value ===
|
|
18639
|
+
return !value || value === SYSTEM_PROGRAM2 || /^1+$/.test(value);
|
|
18238
18640
|
}
|
|
18239
18641
|
function variantName(value) {
|
|
18240
18642
|
if (typeof value === "number") {
|
|
18241
|
-
return
|
|
18643
|
+
return PRICE_ORACLE_TYPES_BY_INDEX2[value] ?? String(value);
|
|
18242
18644
|
}
|
|
18243
18645
|
if (typeof value === "bigint") {
|
|
18244
|
-
return
|
|
18646
|
+
return PRICE_ORACLE_TYPES_BY_INDEX2[Number(value)] ?? String(value);
|
|
18245
18647
|
}
|
|
18246
18648
|
if (value && typeof value === "object") return Object.keys(value)[0] ?? "";
|
|
18247
18649
|
return String(value ?? "");
|
|
@@ -18274,7 +18676,7 @@ var OracleService = class {
|
|
|
18274
18676
|
*/
|
|
18275
18677
|
async updateAssetConsensusPrice(signer, args, log) {
|
|
18276
18678
|
const plan = await this.client.tx.updateConsensusOracle.getTx({
|
|
18277
|
-
signer: (0,
|
|
18679
|
+
signer: (0, import_common46.fromWeb3Pk)(signer.publicKey),
|
|
18278
18680
|
vault: args.vault,
|
|
18279
18681
|
updates: args.updates,
|
|
18280
18682
|
assetMint: args.assetMint,
|
|
@@ -18290,7 +18692,7 @@ var OracleService = class {
|
|
|
18290
18692
|
/** Settle the vault NAV from its current holdings (permissionless). */
|
|
18291
18693
|
async crankNav(cranker, args, log) {
|
|
18292
18694
|
const plan = await this.client.tx.crankNav.getTx({
|
|
18293
|
-
cranker: (0,
|
|
18695
|
+
cranker: (0, import_common46.fromWeb3Pk)(cranker.publicKey),
|
|
18294
18696
|
vault: args.vault,
|
|
18295
18697
|
vaultTrancheState: args.vaultTrancheState
|
|
18296
18698
|
});
|
|
@@ -18363,7 +18765,7 @@ var OracleService = class {
|
|
|
18363
18765
|
/** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
|
|
18364
18766
|
async refreshAssetPrice(updater, args, log) {
|
|
18365
18767
|
const plan = await this.client.tx.updateAssetPrice.getTx({
|
|
18366
|
-
updater: (0,
|
|
18768
|
+
updater: (0, import_common46.fromWeb3Pk)(updater.publicKey),
|
|
18367
18769
|
vault: args.vault,
|
|
18368
18770
|
mint: args.mint,
|
|
18369
18771
|
oracleAccount: args.oracleAccount,
|
|
@@ -18400,31 +18802,6 @@ var OracleService = class {
|
|
|
18400
18802
|
// src/services/consensusOracle/types.ts
|
|
18401
18803
|
var systemClock = { now: () => Date.now() };
|
|
18402
18804
|
|
|
18403
|
-
// src/services/consensusOracle/constants.ts
|
|
18404
|
-
var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
|
|
18405
|
-
var PRICE_ORACLE_TYPES_BY_INDEX2 = [
|
|
18406
|
-
"none",
|
|
18407
|
-
"consensusOracle",
|
|
18408
|
-
"pyth",
|
|
18409
|
-
"perenaVault"
|
|
18410
|
-
];
|
|
18411
|
-
var CONSENSUS_ORACLE_VARIANT = "consensusoracle";
|
|
18412
|
-
var LIVE_ORACLE_VARIANTS = /* @__PURE__ */ new Set(["pyth", "perenavault"]);
|
|
18413
|
-
var REPORTABLE_ORACLE_VARIANTS = /* @__PURE__ */ new Set([
|
|
18414
|
-
CONSENSUS_ORACLE_VARIANT,
|
|
18415
|
-
...LIVE_ORACLE_VARIANTS
|
|
18416
|
-
]);
|
|
18417
|
-
var LIVE_PRICE_REFRESH_INTERVAL_SECS = 60n * 60n;
|
|
18418
|
-
var DEFAULT_PRICE_STALENESS_SECS = BigInt(
|
|
18419
|
-
DEFAULT_PRICE_STALENESS_THRESHOLD_SECS
|
|
18420
|
-
);
|
|
18421
|
-
var EXTERNAL_POSITION_SAMPLES = 5;
|
|
18422
|
-
var MIN_EXTERNAL_POSITION_SAMPLES = 4;
|
|
18423
|
-
var ORACLE_ENTRY_SIZE = 272;
|
|
18424
|
-
var ORACLE_ENTRIES_OFFSET = 40;
|
|
18425
|
-
var ORACLE_SETTLED_NAV_TS_OFFSET = 8;
|
|
18426
|
-
var MAX_CONSENSUS_SIGNERS = 4;
|
|
18427
|
-
|
|
18428
18805
|
// src/services/consensusOracle/utils/accountLayout.ts
|
|
18429
18806
|
function readI64LE(data, offset) {
|
|
18430
18807
|
let value = 0n;
|
|
@@ -18461,10 +18838,10 @@ function signerInOracleData(data, signerBytes) {
|
|
|
18461
18838
|
// src/services/consensusOracle/utils/decode.ts
|
|
18462
18839
|
function variantName2(value) {
|
|
18463
18840
|
if (typeof value === "number") {
|
|
18464
|
-
return
|
|
18841
|
+
return PRICE_ORACLE_TYPES_BY_INDEX[value] ?? String(value);
|
|
18465
18842
|
}
|
|
18466
18843
|
if (typeof value === "bigint") {
|
|
18467
|
-
return
|
|
18844
|
+
return PRICE_ORACLE_TYPES_BY_INDEX[Number(value)] ?? String(value);
|
|
18468
18845
|
}
|
|
18469
18846
|
if (value && typeof value === "object") return Object.keys(value)[0] ?? "";
|
|
18470
18847
|
return String(value ?? "");
|
|
@@ -18484,12 +18861,12 @@ function toBigInt2(value) {
|
|
|
18484
18861
|
}
|
|
18485
18862
|
|
|
18486
18863
|
// src/services/consensusOracle/utils/holdings.ts
|
|
18487
|
-
var
|
|
18488
|
-
var
|
|
18864
|
+
var import_web327 = require("@solana/web3.js");
|
|
18865
|
+
var import_common47 = __toESM(require_dist());
|
|
18489
18866
|
function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
|
|
18490
18867
|
return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
|
|
18491
|
-
const mint = (0,
|
|
18492
|
-
return mint !==
|
|
18868
|
+
const mint = (0, import_common47.fromWeb3Pk)(holding.mint);
|
|
18869
|
+
return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
|
|
18493
18870
|
variantName2(holding.priceOracleType).toLowerCase()
|
|
18494
18871
|
);
|
|
18495
18872
|
});
|
|
@@ -18523,7 +18900,7 @@ function parseExternalLiquidityRefs(vaultState) {
|
|
|
18523
18900
|
if (!data || data.length < 40) continue;
|
|
18524
18901
|
if (data[0] !== 1) continue;
|
|
18525
18902
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
18526
|
-
const userAccount = new
|
|
18903
|
+
const userAccount = new import_web327.PublicKey(pubkeyBytes).toBase58();
|
|
18527
18904
|
refs.push({
|
|
18528
18905
|
kind: "marginfi",
|
|
18529
18906
|
mint: "",
|
|
@@ -18749,12 +19126,12 @@ function formatBpsAsPercent(bps) {
|
|
|
18749
19126
|
}
|
|
18750
19127
|
|
|
18751
19128
|
// src/services/consensusOracle/pipeline/dryRunSettlement.ts
|
|
18752
|
-
var
|
|
18753
|
-
var
|
|
19129
|
+
var import_web329 = require("@solana/web3.js");
|
|
19130
|
+
var import_common48 = __toESM(require_dist());
|
|
18754
19131
|
|
|
18755
19132
|
// src/services/consensusOracle/settlement/settlementSimulator.ts
|
|
18756
19133
|
var import_kit12 = require("@solana/kit");
|
|
18757
|
-
var
|
|
19134
|
+
var import_web328 = require("@solana/web3.js");
|
|
18758
19135
|
var DEFAULT_SHARE_PRICE = 1000000n;
|
|
18759
19136
|
var BPS_DENOMINATOR3 = 10000n;
|
|
18760
19137
|
var NAV_LOSS_TOLERANCE_BPS = 25n;
|
|
@@ -18957,7 +19334,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
|
|
|
18957
19334
|
continue;
|
|
18958
19335
|
}
|
|
18959
19336
|
const reports = entries.filter(
|
|
18960
|
-
(entry) => entry.signer !==
|
|
19337
|
+
(entry) => entry.signer !== import_web328.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
|
|
18961
19338
|
);
|
|
18962
19339
|
const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
|
|
18963
19340
|
const prices = reports.map((entry) => entry.prices[index] ?? 0n);
|
|
@@ -19455,7 +19832,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19455
19832
|
(_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
|
|
19456
19833
|
);
|
|
19457
19834
|
entries.push({
|
|
19458
|
-
signer: new
|
|
19835
|
+
signer: new import_web328.PublicKey(signerBytes).toBase58(),
|
|
19459
19836
|
lastUpdateTs: readI64(data, offset + 32),
|
|
19460
19837
|
prices,
|
|
19461
19838
|
externalAmounts
|
|
@@ -19470,7 +19847,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19470
19847
|
data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
|
|
19471
19848
|
);
|
|
19472
19849
|
entries[index] = {
|
|
19473
|
-
signer: index < pendingCount ? new
|
|
19850
|
+
signer: index < pendingCount ? new import_web328.PublicKey(signerBytes).toBase58() : import_web328.PublicKey.default.toBase58(),
|
|
19474
19851
|
lastUpdateTs: 0n,
|
|
19475
19852
|
prices: Array(MAX_HOLDINGS).fill(0n),
|
|
19476
19853
|
externalAmounts: Array(MAX_HOLDINGS).fill(0n)
|
|
@@ -19498,7 +19875,7 @@ function decodeHolding(value) {
|
|
|
19498
19875
|
externalAmount: bigint(holding.externalAmount),
|
|
19499
19876
|
price: bigint(holding.price),
|
|
19500
19877
|
lastUpdateTs: bigint(holding.lastUpdateTs),
|
|
19501
|
-
cleared: mintString ===
|
|
19878
|
+
cleared: mintString === import_web328.PublicKey.default.toBase58()
|
|
19502
19879
|
};
|
|
19503
19880
|
}
|
|
19504
19881
|
function decodeTrancheState(decoded, args, warnings, blockers) {
|
|
@@ -19963,11 +20340,11 @@ async function simulateDryRunSettlement({
|
|
|
19963
20340
|
client.account.fetchVaultOracleForVault(vault, { fresh: true }),
|
|
19964
20341
|
tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
|
|
19965
20342
|
]);
|
|
19966
|
-
const mintKeys = [new
|
|
20343
|
+
const mintKeys = [new import_web329.PublicKey(vaultState.mint)];
|
|
19967
20344
|
if (trancheState) {
|
|
19968
20345
|
mintKeys.push(
|
|
19969
|
-
new
|
|
19970
|
-
new
|
|
20346
|
+
new import_web329.PublicKey(trancheState.config.juniorMint),
|
|
20347
|
+
new import_web329.PublicKey(trancheState.config.seniorMint)
|
|
19971
20348
|
);
|
|
19972
20349
|
}
|
|
19973
20350
|
const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
|
|
@@ -19983,7 +20360,7 @@ async function simulateDryRunSettlement({
|
|
|
19983
20360
|
oracleData: oracleState.data,
|
|
19984
20361
|
trancheState,
|
|
19985
20362
|
updates,
|
|
19986
|
-
signer: (0,
|
|
20363
|
+
signer: (0, import_common48.fromWeb3Pk)(signer.publicKey),
|
|
19987
20364
|
nowTs: nowSecs,
|
|
19988
20365
|
physicalShareSupply: supplies[0],
|
|
19989
20366
|
physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
|
|
@@ -19992,7 +20369,7 @@ async function simulateDryRunSettlement({
|
|
|
19992
20369
|
}
|
|
19993
20370
|
|
|
19994
20371
|
// src/services/consensusOracle/pipeline/holdingUpdates.ts
|
|
19995
|
-
var
|
|
20372
|
+
var import_common49 = __toESM(require_dist());
|
|
19996
20373
|
async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
19997
20374
|
const updates = [];
|
|
19998
20375
|
for (const entry of reportableHoldings) {
|
|
@@ -20002,7 +20379,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
|
20002
20379
|
}
|
|
20003
20380
|
async function buildHoldingUpdate(yieldTracker, entry, inputs) {
|
|
20004
20381
|
const { holding, holdingIndex } = entry;
|
|
20005
|
-
const mint = (0,
|
|
20382
|
+
const mint = (0, import_common49.fromWeb3Pk)(holding.mint);
|
|
20006
20383
|
const mintKey = mint.toString();
|
|
20007
20384
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20008
20385
|
let usd;
|
|
@@ -20064,14 +20441,14 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
|
|
|
20064
20441
|
);
|
|
20065
20442
|
}
|
|
20066
20443
|
return {
|
|
20067
|
-
trackedValueAmount: tracked.totalValue > 0 ? (0,
|
|
20068
|
-
principalAmount: tracked.principal > 0 ? (0,
|
|
20069
|
-
yieldAmount: tracked.outstandingYield > 0 ? (0,
|
|
20444
|
+
trackedValueAmount: tracked.totalValue > 0 ? (0, import_common49.fromUiAmount)(tracked.totalValue, decimals) : 0n,
|
|
20445
|
+
principalAmount: tracked.principal > 0 ? (0, import_common49.fromUiAmount)(tracked.principal, decimals) : 0n,
|
|
20446
|
+
yieldAmount: tracked.outstandingYield > 0 ? (0, import_common49.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
|
|
20070
20447
|
};
|
|
20071
20448
|
}
|
|
20072
20449
|
|
|
20073
20450
|
// src/services/consensusOracle/pipeline/livePriceRefresh.ts
|
|
20074
|
-
var
|
|
20451
|
+
var import_common50 = __toESM(require_dist());
|
|
20075
20452
|
async function refreshLiveOraclePrices({
|
|
20076
20453
|
oracle,
|
|
20077
20454
|
signer,
|
|
@@ -20090,8 +20467,8 @@ async function refreshLiveOraclePrices({
|
|
|
20090
20467
|
for (const holding of vaultState.holdings) {
|
|
20091
20468
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20092
20469
|
if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
|
|
20093
|
-
const mint = (0,
|
|
20094
|
-
if (mint.toString() ===
|
|
20470
|
+
const mint = (0, import_common50.fromWeb3Pk)(holding.mint);
|
|
20471
|
+
if (mint.toString() === SYSTEM_PROGRAM) continue;
|
|
20095
20472
|
const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
|
|
20096
20473
|
if (activeAmount === 0n) continue;
|
|
20097
20474
|
const lastUpdateTs = toBigInt2(holding.lastUpdateTs);
|
|
@@ -20105,8 +20482,8 @@ async function refreshLiveOraclePrices({
|
|
|
20105
20482
|
);
|
|
20106
20483
|
continue;
|
|
20107
20484
|
}
|
|
20108
|
-
const oracleAccount = (0,
|
|
20109
|
-
if (oracleAccount.toString() ===
|
|
20485
|
+
const oracleAccount = (0, import_common50.fromWeb3Pk)(holding.priceOracleAccount);
|
|
20486
|
+
if (oracleAccount.toString() === SYSTEM_PROGRAM) {
|
|
20110
20487
|
log(
|
|
20111
20488
|
`vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
|
|
20112
20489
|
);
|
|
@@ -20128,15 +20505,199 @@ async function refreshLiveOraclePrices({
|
|
|
20128
20505
|
return results.some((result) => Boolean(result.signature));
|
|
20129
20506
|
}
|
|
20130
20507
|
|
|
20508
|
+
// src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
|
|
20509
|
+
var import_common51 = __toESM(require_dist());
|
|
20510
|
+
|
|
20511
|
+
// src/services/consensusOracle/sources/nestPriceSource.ts
|
|
20512
|
+
var import_kit13 = require("@solana/kit");
|
|
20513
|
+
var import_nest = __toESM(require_dist3());
|
|
20514
|
+
var import_nest2 = __toESM(require_dist3());
|
|
20515
|
+
var NEST_VAULT_SLUG = "nest-perena-vault";
|
|
20516
|
+
var NEST_RWA_SHARE_MINT = (0, import_kit13.address)(
|
|
20517
|
+
"VyXKJnVhkSkB6KAozSZCiLQbuB1k1r6Nu4etNYVo5LJ"
|
|
20518
|
+
);
|
|
20519
|
+
async function fetchNestTokenPrice(nestVaultSlug = NEST_VAULT_SLUG, opts = {}) {
|
|
20520
|
+
return (0, import_nest.fetchNestVaultSharePrice)(nestVaultSlug, opts);
|
|
20521
|
+
}
|
|
20522
|
+
var NestPriceSource = class {
|
|
20523
|
+
constructor(opts = {}) {
|
|
20524
|
+
this.shareMint = opts.shareMint ?? NEST_RWA_SHARE_MINT;
|
|
20525
|
+
this.nestVaultSlug = opts.nestVaultSlug ?? NEST_VAULT_SLUG;
|
|
20526
|
+
this.options = { baseUrl: opts.baseUrl, fetchFn: opts.fetchFn };
|
|
20527
|
+
}
|
|
20528
|
+
async fetchUsdPrices(mints2) {
|
|
20529
|
+
if (!mints2.some((mint) => mint.toString() === this.shareMint.toString())) {
|
|
20530
|
+
return {};
|
|
20531
|
+
}
|
|
20532
|
+
return {
|
|
20533
|
+
[this.shareMint.toString()]: await (0, import_nest.fetchNestVaultSharePrice)(
|
|
20534
|
+
this.nestVaultSlug,
|
|
20535
|
+
this.options
|
|
20536
|
+
)
|
|
20537
|
+
};
|
|
20538
|
+
}
|
|
20539
|
+
};
|
|
20540
|
+
|
|
20541
|
+
// src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
|
|
20542
|
+
var MANAGER_WALLET_NAV_DROP_TRIGGER_BPS = 10n;
|
|
20543
|
+
var MANAGER_WALLET_NAV_TOLERANCE_BPS = 5n;
|
|
20544
|
+
var BPS = 10000n;
|
|
20545
|
+
var U64_MAX = 0xffffffffffffffffn;
|
|
20546
|
+
function previousPhysicalNav(state) {
|
|
20547
|
+
const banked = toBigInt2(state.config.apy?.accruedApyBalance);
|
|
20548
|
+
return toBigInt2(state.accounting?.tvl) + (banked > 0n ? banked : 0n);
|
|
20549
|
+
}
|
|
20550
|
+
function candidateGrossNav(state, updates) {
|
|
20551
|
+
const byIndex = /* @__PURE__ */ new Map();
|
|
20552
|
+
for (const update of updates) {
|
|
20553
|
+
const holding = state.holdings[update.holdingIndex];
|
|
20554
|
+
if (!holding || (0, import_common51.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
|
|
20555
|
+
throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
|
|
20556
|
+
}
|
|
20557
|
+
byIndex.set(update.holdingIndex, update);
|
|
20558
|
+
}
|
|
20559
|
+
return state.holdings.reduce((nav, holding, index) => {
|
|
20560
|
+
if ((0, import_common51.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
|
|
20561
|
+
const update = byIndex.get(index);
|
|
20562
|
+
const local = toBigInt2(holding.localAmount);
|
|
20563
|
+
const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
|
|
20564
|
+
if (local < 0n || external < 0n || local + external > U64_MAX) {
|
|
20565
|
+
throw new Error(`Invalid NAV amount for holding #${index}`);
|
|
20566
|
+
}
|
|
20567
|
+
if (local + external === 0n) return nav;
|
|
20568
|
+
const price = update && variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT ? update.price : toBigInt2(holding.price);
|
|
20569
|
+
if (price <= 0n || !Number.isInteger(holding.decimals) || holding.decimals < 0 || holding.decimals > 18) {
|
|
20570
|
+
throw new Error(
|
|
20571
|
+
`Cannot value holding #${index} for manager reconciliation`
|
|
20572
|
+
);
|
|
20573
|
+
}
|
|
20574
|
+
const nextNav = nav + (local + external) * price / 10n ** BigInt(holding.decimals);
|
|
20575
|
+
if (nextNav > U64_MAX) throw new Error("Candidate NAV exceeds u64");
|
|
20576
|
+
return nextNav;
|
|
20577
|
+
}, 0n);
|
|
20578
|
+
}
|
|
20579
|
+
function retainPendingNestShares(state, updates) {
|
|
20580
|
+
return updates.map((update) => {
|
|
20581
|
+
if (update.mint !== NEST_RWA_SHARE_MINT) return update;
|
|
20582
|
+
const recorded = toBigInt2(
|
|
20583
|
+
state.holdings[update.holdingIndex]?.externalAmount
|
|
20584
|
+
);
|
|
20585
|
+
if (recorded <= update.externalAmount) return update;
|
|
20586
|
+
return {
|
|
20587
|
+
...update,
|
|
20588
|
+
pendingNestAmount: recorded - update.externalAmount,
|
|
20589
|
+
externalAmount: recorded
|
|
20590
|
+
};
|
|
20591
|
+
});
|
|
20592
|
+
}
|
|
20593
|
+
async function reconcileManagerWalletBalances({
|
|
20594
|
+
vault,
|
|
20595
|
+
vaultState,
|
|
20596
|
+
updates,
|
|
20597
|
+
source,
|
|
20598
|
+
log = () => {
|
|
20599
|
+
}
|
|
20600
|
+
}) {
|
|
20601
|
+
const previousNav = previousPhysicalNav(vaultState);
|
|
20602
|
+
if (updates.some(
|
|
20603
|
+
(update) => (update.managerWalletAmount ?? 0n) !== 0n || (update.pendingNestAmount ?? 0n) !== 0n
|
|
20604
|
+
)) {
|
|
20605
|
+
throw new Error("Manager reconciliation requires fresh source amounts");
|
|
20606
|
+
}
|
|
20607
|
+
const pendingUpdates = retainPendingNestShares(vaultState, updates);
|
|
20608
|
+
if (!source || previousNav <= 0n) {
|
|
20609
|
+
return {
|
|
20610
|
+
accepted: false,
|
|
20611
|
+
updates: pendingUpdates,
|
|
20612
|
+
previousNav,
|
|
20613
|
+
candidateNav: 0n
|
|
20614
|
+
};
|
|
20615
|
+
}
|
|
20616
|
+
const candidateNav = candidateGrossNav(vaultState, updates);
|
|
20617
|
+
const result = {
|
|
20618
|
+
accepted: false,
|
|
20619
|
+
updates: pendingUpdates,
|
|
20620
|
+
previousNav,
|
|
20621
|
+
candidateNav
|
|
20622
|
+
};
|
|
20623
|
+
if ((previousNav - candidateNav) * BPS < previousNav * MANAGER_WALLET_NAV_DROP_TRIGGER_BPS) {
|
|
20624
|
+
return result;
|
|
20625
|
+
}
|
|
20626
|
+
const baseUpdates = updates.filter(
|
|
20627
|
+
(update) => coerceBool3(vaultState.holdings[update.holdingIndex].isBase)
|
|
20628
|
+
);
|
|
20629
|
+
const mints2 = baseUpdates.map((update) => update.mint);
|
|
20630
|
+
if (mints2.length === 0) return result;
|
|
20631
|
+
if (new Set(mints2).size !== mints2.length) {
|
|
20632
|
+
throw new Error("Duplicate base mint in manager reconciliation");
|
|
20633
|
+
}
|
|
20634
|
+
if (vaultState.holdings.some(
|
|
20635
|
+
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common51.fromWeb3Pk)(holding.mint))
|
|
20636
|
+
)) {
|
|
20637
|
+
throw new Error(
|
|
20638
|
+
"Cannot reconcile all vault base assets with oracle reports"
|
|
20639
|
+
);
|
|
20640
|
+
}
|
|
20641
|
+
const manager = (0, import_common51.fromWeb3Pk)(vaultState.roles.manager);
|
|
20642
|
+
if (manager === SYSTEM_PROGRAM || manager === vault) {
|
|
20643
|
+
throw new Error("Invalid manager wallet for NAV reconciliation");
|
|
20644
|
+
}
|
|
20645
|
+
log(
|
|
20646
|
+
`vault ${vault}: NAV ${candidateNav} is at least 0.1% below ${previousNav}; checking manager ${manager}`
|
|
20647
|
+
);
|
|
20648
|
+
const amounts = await source.fetchBalances(manager, mints2);
|
|
20649
|
+
const adjusted = updates.map((update) => {
|
|
20650
|
+
if (!mints2.includes(update.mint)) return update;
|
|
20651
|
+
const amount = amounts.get(update.mint) ?? 0n;
|
|
20652
|
+
if (typeof amount !== "bigint" || amount < 0n || amount > U64_MAX) {
|
|
20653
|
+
throw new Error(`Invalid manager base-asset balance for ${update.mint}`);
|
|
20654
|
+
}
|
|
20655
|
+
return {
|
|
20656
|
+
...update,
|
|
20657
|
+
managerWalletAmount: amount,
|
|
20658
|
+
externalAmount: update.externalAmount + amount
|
|
20659
|
+
};
|
|
20660
|
+
});
|
|
20661
|
+
const adjustedNav = candidateGrossNav(vaultState, adjusted);
|
|
20662
|
+
const delta = adjustedNav - previousNav;
|
|
20663
|
+
const absoluteDelta = delta < 0n ? -delta : delta;
|
|
20664
|
+
const accepted = adjustedNav > candidateNav && absoluteDelta * BPS <= previousNav * MANAGER_WALLET_NAV_TOLERANCE_BPS;
|
|
20665
|
+
log(
|
|
20666
|
+
`vault ${vault}: manager wallet ${accepted ? "accepted" : "rejected"}; adjusted NAV ${adjustedNav}, previous NAV ${previousNav}, allowed difference \xB10.05%`
|
|
20667
|
+
);
|
|
20668
|
+
return {
|
|
20669
|
+
accepted,
|
|
20670
|
+
updates: accepted ? adjusted : pendingUpdates,
|
|
20671
|
+
previousNav,
|
|
20672
|
+
candidateNav,
|
|
20673
|
+
adjustedNav
|
|
20674
|
+
};
|
|
20675
|
+
}
|
|
20676
|
+
function managerReconciliationStateKey(state) {
|
|
20677
|
+
return JSON.stringify({
|
|
20678
|
+
manager: (0, import_common51.fromWeb3Pk)(state.roles.manager),
|
|
20679
|
+
previousNav: previousPhysicalNav(state).toString(),
|
|
20680
|
+
holdings: state.holdings.map((holding) => [
|
|
20681
|
+
(0, import_common51.fromWeb3Pk)(holding.mint),
|
|
20682
|
+
holding.decimals,
|
|
20683
|
+
variantName2(holding.priceOracleType),
|
|
20684
|
+
coerceBool3(holding.isBase),
|
|
20685
|
+
toBigInt2(holding.localAmount).toString(),
|
|
20686
|
+
toBigInt2(holding.externalAmount).toString(),
|
|
20687
|
+
toBigInt2(holding.price).toString()
|
|
20688
|
+
])
|
|
20689
|
+
});
|
|
20690
|
+
}
|
|
20691
|
+
|
|
20131
20692
|
// src/services/consensusOracle/pipeline/pricingInputs.ts
|
|
20132
|
-
var
|
|
20693
|
+
var import_common52 = __toESM(require_dist());
|
|
20133
20694
|
async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
|
|
20134
20695
|
}) {
|
|
20135
20696
|
const consensusMints = reportableHoldings.filter(
|
|
20136
20697
|
({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
|
|
20137
|
-
).map(({ holding }) => (0,
|
|
20698
|
+
).map(({ holding }) => (0, import_common52.fromWeb3Pk)(holding.mint));
|
|
20138
20699
|
const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
|
|
20139
|
-
const baseMint = baseHolding ? (0,
|
|
20700
|
+
const baseMint = baseHolding ? (0, import_common52.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
|
|
20140
20701
|
if (!baseMint) {
|
|
20141
20702
|
throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
|
|
20142
20703
|
}
|
|
@@ -20220,11 +20781,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
|
|
|
20220
20781
|
}
|
|
20221
20782
|
|
|
20222
20783
|
// src/services/consensusOracle/pipeline/receiptMints.ts
|
|
20223
|
-
var
|
|
20784
|
+
var import_common53 = __toESM(require_dist());
|
|
20224
20785
|
async function fetchReceiptMints(client, vault, vaultState) {
|
|
20225
20786
|
const receiptMints = /* @__PURE__ */ new Set();
|
|
20226
20787
|
if (vaultState.mint) {
|
|
20227
|
-
receiptMints.add((0,
|
|
20788
|
+
receiptMints.add((0, import_common53.fromWeb3Pk)(vaultState.mint).toString());
|
|
20228
20789
|
}
|
|
20229
20790
|
if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
|
|
20230
20791
|
const trancheState = await client.account.fetchVaultTrancheStateForVault(
|
|
@@ -20232,19 +20793,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
|
|
|
20232
20793
|
{ fresh: true }
|
|
20233
20794
|
);
|
|
20234
20795
|
receiptMints.add(
|
|
20235
|
-
(0,
|
|
20796
|
+
(0, import_common53.fromWeb3Pk)(trancheState.config.juniorMint).toString()
|
|
20236
20797
|
);
|
|
20237
20798
|
receiptMints.add(
|
|
20238
|
-
(0,
|
|
20799
|
+
(0, import_common53.fromWeb3Pk)(trancheState.config.seniorMint).toString()
|
|
20239
20800
|
);
|
|
20240
20801
|
return receiptMints;
|
|
20241
20802
|
}
|
|
20242
20803
|
|
|
20243
20804
|
// src/services/consensusOracle/pipeline/settlement.ts
|
|
20244
|
-
var
|
|
20805
|
+
var import_common55 = __toESM(require_dist());
|
|
20245
20806
|
|
|
20246
20807
|
// src/services/consensusOracle/pipeline/yieldAccounts.ts
|
|
20247
|
-
var
|
|
20808
|
+
var import_common54 = __toESM(require_dist());
|
|
20248
20809
|
async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
|
|
20249
20810
|
const accountNames = [
|
|
20250
20811
|
...new Set(
|
|
@@ -20286,7 +20847,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20286
20847
|
);
|
|
20287
20848
|
if (namesToAttach.length === 0) return target;
|
|
20288
20849
|
const baseHolding = vaultState.holdings.find((holding) => {
|
|
20289
|
-
const mint = (0,
|
|
20850
|
+
const mint = (0, import_common54.fromWeb3Pk)(holding.mint).toString();
|
|
20290
20851
|
return coerceBool3(holding.isBase) && !excludedMints.has(mint);
|
|
20291
20852
|
});
|
|
20292
20853
|
if (!baseHolding) {
|
|
@@ -20294,7 +20855,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20294
20855
|
`vault ${target.vault}: tagged yield accounts found but no base holding is available`
|
|
20295
20856
|
);
|
|
20296
20857
|
}
|
|
20297
|
-
const baseMint = (0,
|
|
20858
|
+
const baseMint = (0, import_common54.fromWeb3Pk)(baseHolding.mint);
|
|
20298
20859
|
const holdings = [...target.holdings ?? []];
|
|
20299
20860
|
const existingIndex = holdings.findIndex(
|
|
20300
20861
|
(holding) => holding.mint.toString() === baseMint.toString()
|
|
@@ -20327,13 +20888,14 @@ async function settleVault2({
|
|
|
20327
20888
|
updates,
|
|
20328
20889
|
vaultState,
|
|
20329
20890
|
nowSecs,
|
|
20330
|
-
log
|
|
20891
|
+
log,
|
|
20892
|
+
beforeSubmit
|
|
20331
20893
|
}) {
|
|
20332
20894
|
const vault = target.vault;
|
|
20333
20895
|
log(`vault ${vault}: submitting ${updates.length} consensus asset update(s)`);
|
|
20334
20896
|
for (const update of updates) {
|
|
20335
20897
|
log(
|
|
20336
|
-
` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [lp=${update.lpAmount} tracked=${update.trackedValueAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
|
|
20898
|
+
` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [pendingNest=${update.pendingNestAmount ?? 0n} managerWallet=${update.managerWalletAmount ?? 0n} lp=${update.lpAmount} tracked=${update.trackedValueAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
|
|
20337
20899
|
);
|
|
20338
20900
|
}
|
|
20339
20901
|
try {
|
|
@@ -20355,6 +20917,7 @@ async function settleVault2({
|
|
|
20355
20917
|
);
|
|
20356
20918
|
}
|
|
20357
20919
|
await assertNoUnconfirmedYieldPayments(yieldTracker, target);
|
|
20920
|
+
await beforeSubmit?.();
|
|
20358
20921
|
const updateSignature = await oracle.updateAssetConsensusPrice(
|
|
20359
20922
|
signer,
|
|
20360
20923
|
{
|
|
@@ -20395,8 +20958,8 @@ async function logProspectiveApy({
|
|
|
20395
20958
|
);
|
|
20396
20959
|
const prospectiveNav = vaultState.holdings.reduce(
|
|
20397
20960
|
(sum, holding, holdingIndex) => {
|
|
20398
|
-
const mint = (0,
|
|
20399
|
-
if (mint ===
|
|
20961
|
+
const mint = (0, import_common55.fromWeb3Pk)(holding.mint).toString();
|
|
20962
|
+
if (mint === SYSTEM_PROGRAM) return sum;
|
|
20400
20963
|
const update = updatesByIndex.get(holdingIndex);
|
|
20401
20964
|
const localAmount = toBigInt2(holding.localAmount);
|
|
20402
20965
|
const externalAmount = update ? update.externalAmount : toBigInt2(holding.externalAmount);
|
|
@@ -20451,7 +21014,7 @@ async function discoverVaultsForSigner(client, signer, opts = {}) {
|
|
|
20451
21014
|
}
|
|
20452
21015
|
|
|
20453
21016
|
// src/services/consensusOracle/sources/jupiterPriceSource.ts
|
|
20454
|
-
var import_jupiter = __toESM(
|
|
21017
|
+
var import_jupiter = __toESM(require_dist4());
|
|
20455
21018
|
var JupiterPriceSource = class {
|
|
20456
21019
|
constructor(opts = {}) {
|
|
20457
21020
|
this.opts = opts;
|
|
@@ -20461,36 +21024,6 @@ var JupiterPriceSource = class {
|
|
|
20461
21024
|
}
|
|
20462
21025
|
};
|
|
20463
21026
|
|
|
20464
|
-
// src/services/consensusOracle/sources/nestPriceSource.ts
|
|
20465
|
-
var import_kit13 = require("@solana/kit");
|
|
20466
|
-
var import_nest = __toESM(require_dist4());
|
|
20467
|
-
var import_nest2 = __toESM(require_dist4());
|
|
20468
|
-
var NEST_VAULT_SLUG = "nest-perena-vault";
|
|
20469
|
-
var NEST_RWA_SHARE_MINT = (0, import_kit13.address)(
|
|
20470
|
-
"VyXKJnVhkSkB6KAozSZCiLQbuB1k1r6Nu4etNYVo5LJ"
|
|
20471
|
-
);
|
|
20472
|
-
async function fetchNestTokenPrice(nestVaultSlug = NEST_VAULT_SLUG, opts = {}) {
|
|
20473
|
-
return (0, import_nest.fetchNestVaultSharePrice)(nestVaultSlug, opts);
|
|
20474
|
-
}
|
|
20475
|
-
var NestPriceSource = class {
|
|
20476
|
-
constructor(opts = {}) {
|
|
20477
|
-
this.shareMint = opts.shareMint ?? NEST_RWA_SHARE_MINT;
|
|
20478
|
-
this.nestVaultSlug = opts.nestVaultSlug ?? NEST_VAULT_SLUG;
|
|
20479
|
-
this.options = { baseUrl: opts.baseUrl, fetchFn: opts.fetchFn };
|
|
20480
|
-
}
|
|
20481
|
-
async fetchUsdPrices(mints2) {
|
|
20482
|
-
if (!mints2.some((mint) => mint.toString() === this.shareMint.toString())) {
|
|
20483
|
-
return {};
|
|
20484
|
-
}
|
|
20485
|
-
return {
|
|
20486
|
-
[this.shareMint.toString()]: await (0, import_nest.fetchNestVaultSharePrice)(
|
|
20487
|
-
this.nestVaultSlug,
|
|
20488
|
-
this.options
|
|
20489
|
-
)
|
|
20490
|
-
};
|
|
20491
|
-
}
|
|
20492
|
-
};
|
|
20493
|
-
|
|
20494
21027
|
// src/services/consensusOracle/sources/livePriceSource.ts
|
|
20495
21028
|
var LivePriceSource = class {
|
|
20496
21029
|
constructor(opts = {}) {
|
|
@@ -20512,6 +21045,59 @@ var LivePriceSource = class {
|
|
|
20512
21045
|
}
|
|
20513
21046
|
};
|
|
20514
21047
|
|
|
21048
|
+
// src/services/consensusOracle/sources/managerWalletBalanceSource.ts
|
|
21049
|
+
var import_web330 = require("@solana/web3.js");
|
|
21050
|
+
var import_spl_token20 = require("@solana/spl-token");
|
|
21051
|
+
var RpcManagerWalletBalanceSource = class {
|
|
21052
|
+
constructor(connection) {
|
|
21053
|
+
this.connection = connection;
|
|
21054
|
+
}
|
|
21055
|
+
async fetchBalances(manager, mints2) {
|
|
21056
|
+
const wanted = new Set(mints2);
|
|
21057
|
+
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
21058
|
+
const owner = new import_web330.PublicKey(manager);
|
|
21059
|
+
const programs = [import_spl_token20.TOKEN_PROGRAM_ID, import_spl_token20.TOKEN_2022_PROGRAM_ID];
|
|
21060
|
+
const responses = await Promise.all(
|
|
21061
|
+
programs.map(
|
|
21062
|
+
(programId) => this.connection.getParsedTokenAccountsByOwner(
|
|
21063
|
+
owner,
|
|
21064
|
+
{ programId },
|
|
21065
|
+
"confirmed"
|
|
21066
|
+
)
|
|
21067
|
+
)
|
|
21068
|
+
);
|
|
21069
|
+
const amounts = /* @__PURE__ */ new Map();
|
|
21070
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21071
|
+
for (let index = 0; index < responses.length; index += 1) {
|
|
21072
|
+
for (const { pubkey: pubkey2, account } of responses[index].value) {
|
|
21073
|
+
const data = account.data;
|
|
21074
|
+
if (!("parsed" in data) || data.parsed?.type !== "account") {
|
|
21075
|
+
throw new Error(`Unparsed manager token account ${pubkey2}`);
|
|
21076
|
+
}
|
|
21077
|
+
const info = data.parsed.info;
|
|
21078
|
+
if (!account.owner.equals(programs[index]) || info?.owner !== manager) {
|
|
21079
|
+
throw new Error(`Invalid manager token account owner ${pubkey2}`);
|
|
21080
|
+
}
|
|
21081
|
+
if (!wanted.has(info.mint)) continue;
|
|
21082
|
+
const key = pubkey2.toBase58();
|
|
21083
|
+
if (seen.has(key))
|
|
21084
|
+
throw new Error(`Duplicate manager token account ${key}`);
|
|
21085
|
+
seen.add(key);
|
|
21086
|
+
const raw = info.tokenAmount?.amount;
|
|
21087
|
+
if (typeof raw !== "string" || !/^\d+$/.test(raw)) {
|
|
21088
|
+
throw new Error(`Invalid manager token balance ${key}`);
|
|
21089
|
+
}
|
|
21090
|
+
const amount = BigInt(raw);
|
|
21091
|
+
if (amount > 0xffffffffffffffffn) {
|
|
21092
|
+
throw new Error(`Manager token balance exceeds u64: ${key}`);
|
|
21093
|
+
}
|
|
21094
|
+
amounts.set(info.mint, (amounts.get(info.mint) ?? 0n) + amount);
|
|
21095
|
+
}
|
|
21096
|
+
}
|
|
21097
|
+
return amounts;
|
|
21098
|
+
}
|
|
21099
|
+
};
|
|
21100
|
+
|
|
20515
21101
|
// src/services/consensusOracle/positions/externalPositions.ts
|
|
20516
21102
|
var ExternalPositionRegistry = class {
|
|
20517
21103
|
constructor(providers = [], log = () => {
|
|
@@ -20548,7 +21134,7 @@ var StaticPositionProvider = class {
|
|
|
20548
21134
|
|
|
20549
21135
|
// src/services/consensusOracle/positions/kaminoPositionProvider.ts
|
|
20550
21136
|
var import_kit14 = require("@solana/kit");
|
|
20551
|
-
var
|
|
21137
|
+
var import_web331 = require("@solana/web3.js");
|
|
20552
21138
|
var import_klend_sdk = require("@kamino-finance/klend-sdk");
|
|
20553
21139
|
async function readKaminoBalance(manager, vault, sharesHolder) {
|
|
20554
21140
|
const userShares = await manager.getUserSharesBalanceSingleVault(
|
|
@@ -20585,7 +21171,7 @@ var KaminoPositionProvider = class {
|
|
|
20585
21171
|
const amount = await readKaminoBalance(
|
|
20586
21172
|
manager,
|
|
20587
21173
|
kVault,
|
|
20588
|
-
new
|
|
21174
|
+
new import_web331.PublicKey(sharesHolder)
|
|
20589
21175
|
);
|
|
20590
21176
|
out.push({ mint: ref.mint, amount });
|
|
20591
21177
|
}
|
|
@@ -20594,7 +21180,7 @@ var KaminoPositionProvider = class {
|
|
|
20594
21180
|
};
|
|
20595
21181
|
|
|
20596
21182
|
// src/services/consensusOracle/positions/marginfiPositionProvider.ts
|
|
20597
|
-
var
|
|
21183
|
+
var import_web332 = require("@solana/web3.js");
|
|
20598
21184
|
var import_marginfi2 = __toESM(require_dist2());
|
|
20599
21185
|
var MarginfiPositionProvider = class {
|
|
20600
21186
|
constructor(connection, log = () => {
|
|
@@ -20605,8 +21191,8 @@ var MarginfiPositionProvider = class {
|
|
|
20605
21191
|
async positionsFor(ctx) {
|
|
20606
21192
|
const refs = ctx.refs.filter((r) => r.kind === "marginfi");
|
|
20607
21193
|
if (refs.length === 0) return [];
|
|
20608
|
-
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new
|
|
20609
|
-
const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new
|
|
21194
|
+
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web332.PublicKey(bank));
|
|
21195
|
+
const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web332.PublicKey(account));
|
|
20610
21196
|
const autoBanks = [];
|
|
20611
21197
|
for (const accountPk of autoAccountPks) {
|
|
20612
21198
|
try {
|
|
@@ -20635,14 +21221,14 @@ var MarginfiPositionProvider = class {
|
|
|
20635
21221
|
if (bank) {
|
|
20636
21222
|
const amount = await (0, import_marginfi2.readMarginfiBankBalance)(
|
|
20637
21223
|
client,
|
|
20638
|
-
new
|
|
20639
|
-
new
|
|
21224
|
+
new import_web332.PublicKey(account),
|
|
21225
|
+
new import_web332.PublicKey(bank)
|
|
20640
21226
|
);
|
|
20641
21227
|
out.push({ mint: ref.mint, amount });
|
|
20642
21228
|
} else {
|
|
20643
21229
|
const balances = await (0, import_marginfi2.readAllMarginfiBalances)(
|
|
20644
21230
|
client,
|
|
20645
|
-
new
|
|
21231
|
+
new import_web332.PublicKey(account)
|
|
20646
21232
|
);
|
|
20647
21233
|
for (const { mint, amount } of balances) {
|
|
20648
21234
|
out.push({ mint: mint.toBase58(), amount });
|
|
@@ -20849,6 +21435,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
20849
21435
|
});
|
|
20850
21436
|
const deps = {
|
|
20851
21437
|
priceSource: new LivePriceSource(),
|
|
21438
|
+
managerWalletBalances: new RpcManagerWalletBalanceSource(connection),
|
|
20852
21439
|
yieldTracker: {
|
|
20853
21440
|
async getAccountNamesForVault(vault) {
|
|
20854
21441
|
const accounts2 = await getAccounts();
|
|
@@ -20882,7 +21469,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
20882
21469
|
}
|
|
20883
21470
|
|
|
20884
21471
|
// src/services/consensusOracle/consensusOracleService.ts
|
|
20885
|
-
var
|
|
21472
|
+
var import_common56 = __toESM(require_dist());
|
|
20886
21473
|
var ConsensusOracleService = class {
|
|
20887
21474
|
constructor(client, deps) {
|
|
20888
21475
|
this.client = client;
|
|
@@ -20918,7 +21505,7 @@ var ConsensusOracleService = class {
|
|
|
20918
21505
|
receiptMints
|
|
20919
21506
|
);
|
|
20920
21507
|
const filteredCount = vaultState.holdings.filter(
|
|
20921
|
-
(holding) => receiptMints.has((0,
|
|
21508
|
+
(holding) => receiptMints.has((0, import_common56.fromWeb3Pk)(holding.mint).toString())
|
|
20922
21509
|
).length;
|
|
20923
21510
|
if (filteredCount > 0) {
|
|
20924
21511
|
log(
|
|
@@ -20948,18 +21535,35 @@ var ConsensusOracleService = class {
|
|
|
20948
21535
|
reportableHoldings,
|
|
20949
21536
|
log
|
|
20950
21537
|
);
|
|
20951
|
-
const
|
|
21538
|
+
const sourcedUpdates = await buildUpdates(
|
|
20952
21539
|
this.deps.yieldTracker,
|
|
20953
21540
|
reportableHoldings,
|
|
20954
21541
|
inputs
|
|
20955
21542
|
);
|
|
20956
|
-
|
|
20957
|
-
target.vault,
|
|
21543
|
+
const reconciliation = await reconcileManagerWalletBalances({
|
|
21544
|
+
vault: target.vault,
|
|
20958
21545
|
vaultState,
|
|
20959
|
-
updates,
|
|
20960
|
-
this.
|
|
21546
|
+
updates: sourcedUpdates,
|
|
21547
|
+
source: this.deps.managerWalletBalances,
|
|
20961
21548
|
log
|
|
20962
|
-
);
|
|
21549
|
+
});
|
|
21550
|
+
const updates = reconciliation.updates;
|
|
21551
|
+
const needsRevalidation = reconciliation.accepted || // A new withdrawal can be queued after the first vault read, too.
|
|
21552
|
+
updates.some((update) => update.mint === NEST_RWA_SHARE_MINT);
|
|
21553
|
+
const reconciliationStateKey = needsRevalidation ? managerReconciliationStateKey(vaultState) : void 0;
|
|
21554
|
+
if (!reconciliation.accepted) {
|
|
21555
|
+
assertNoLargeBalanceChanges(
|
|
21556
|
+
target.vault,
|
|
21557
|
+
vaultState,
|
|
21558
|
+
updates,
|
|
21559
|
+
this.nowSecs(),
|
|
21560
|
+
log
|
|
21561
|
+
);
|
|
21562
|
+
} else {
|
|
21563
|
+
log(
|
|
21564
|
+
`vault ${target.vault}: manager NAV reconciliation passed; allowing cross-asset external balance changes`
|
|
21565
|
+
);
|
|
21566
|
+
}
|
|
20963
21567
|
if (dryRun) {
|
|
20964
21568
|
log(`vault ${target.vault}: dry run, ${updates.length} holding(s)`);
|
|
20965
21569
|
try {
|
|
@@ -20999,7 +21603,29 @@ var ConsensusOracleService = class {
|
|
|
20999
21603
|
updates,
|
|
21000
21604
|
vaultState,
|
|
21001
21605
|
nowSecs: this.nowSecs(),
|
|
21002
|
-
log
|
|
21606
|
+
log,
|
|
21607
|
+
beforeSubmit: needsRevalidation ? async () => {
|
|
21608
|
+
const freshState = await this.fetchDecodedVault(target.vault);
|
|
21609
|
+
if (managerReconciliationStateKey(freshState) !== reconciliationStateKey) {
|
|
21610
|
+
throw new Error(
|
|
21611
|
+
"Vault changed during manager-wallet reconciliation; retry with fresh inputs"
|
|
21612
|
+
);
|
|
21613
|
+
}
|
|
21614
|
+
if (!reconciliation.accepted) return;
|
|
21615
|
+
const fresh = await reconcileManagerWalletBalances({
|
|
21616
|
+
vault: target.vault,
|
|
21617
|
+
vaultState: freshState,
|
|
21618
|
+
updates: sourcedUpdates,
|
|
21619
|
+
source: this.deps.managerWalletBalances
|
|
21620
|
+
});
|
|
21621
|
+
if (!fresh.accepted || fresh.updates.some(
|
|
21622
|
+
(update, index) => update.externalAmount !== updates[index].externalAmount
|
|
21623
|
+
)) {
|
|
21624
|
+
throw new Error(
|
|
21625
|
+
"Manager wallet changed during reconciliation; retry with fresh inputs"
|
|
21626
|
+
);
|
|
21627
|
+
}
|
|
21628
|
+
} : void 0
|
|
21003
21629
|
});
|
|
21004
21630
|
return {
|
|
21005
21631
|
vault: target.vault,
|
|
@@ -21099,8 +21725,8 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
|
|
|
21099
21725
|
|
|
21100
21726
|
// src/services/externalLiquidityIntegrityService.ts
|
|
21101
21727
|
var import_kit15 = require("@solana/kit");
|
|
21102
|
-
var
|
|
21103
|
-
var
|
|
21728
|
+
var import_web333 = require("@solana/web3.js");
|
|
21729
|
+
var import_common57 = __toESM(require_dist());
|
|
21104
21730
|
var import_marginfi3 = __toESM(require_dist2());
|
|
21105
21731
|
var DEFAULT_MIN_AMOUNT_UI = 1;
|
|
21106
21732
|
var DEFAULT_TARGET_LOCAL_BPS = 50;
|
|
@@ -21122,7 +21748,7 @@ function parseActiveSlots(externalLiquidity) {
|
|
|
21122
21748
|
if (discriminant === 0) continue;
|
|
21123
21749
|
if (discriminant !== 1) continue;
|
|
21124
21750
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
21125
|
-
const userAccount = (0,
|
|
21751
|
+
const userAccount = (0, import_common57.toAddress)(new import_web333.PublicKey(pubkeyBytes));
|
|
21126
21752
|
results.push({ index: i, source: "marginfi", userAccount });
|
|
21127
21753
|
}
|
|
21128
21754
|
return results;
|
|
@@ -21238,8 +21864,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21238
21864
|
result.skipped++;
|
|
21239
21865
|
return result;
|
|
21240
21866
|
}
|
|
21241
|
-
const hwManagerAddress = (0,
|
|
21242
|
-
const vaultPk = new
|
|
21867
|
+
const hwManagerAddress = (0, import_common57.fromWeb3Pk)(hwManager.publicKey);
|
|
21868
|
+
const vaultPk = new import_web333.PublicKey(vault.toString());
|
|
21243
21869
|
const registeredHwManager = pubkeyStr(
|
|
21244
21870
|
vaultState.roles.hwManager
|
|
21245
21871
|
);
|
|
@@ -21359,14 +21985,14 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21359
21985
|
const marginfiClient = new import_marginfi3.CpiClient({
|
|
21360
21986
|
accounts: marginfiAccounts
|
|
21361
21987
|
});
|
|
21362
|
-
const { getAtaAddress:
|
|
21363
|
-
const vaultAta =
|
|
21988
|
+
const { getAtaAddress: getAtaAddress20 } = await Promise.resolve().then(() => __toESM(require_dist()));
|
|
21989
|
+
const vaultAta = getAtaAddress20(
|
|
21364
21990
|
mintAddress,
|
|
21365
21991
|
vault,
|
|
21366
21992
|
marginfiAccounts.tokenProgram,
|
|
21367
21993
|
true
|
|
21368
21994
|
);
|
|
21369
|
-
const cpiRefs = (0,
|
|
21995
|
+
const cpiRefs = (0, import_common57.createCpiRefs)([
|
|
21370
21996
|
direction === "deposit" ? marginfiClient.deposit_cpi({
|
|
21371
21997
|
marginfiAccount: slot.userAccount,
|
|
21372
21998
|
authority: vault,
|
|
@@ -21418,11 +22044,11 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21418
22044
|
|
|
21419
22045
|
// src/services/idleLiquidityService.ts
|
|
21420
22046
|
var import_kit16 = require("@solana/kit");
|
|
21421
|
-
var
|
|
22047
|
+
var import_spl_token21 = require("@solana/spl-token");
|
|
21422
22048
|
var import_marginfi_client_v2 = require("@mrgnlabs/marginfi-client-v2");
|
|
21423
|
-
var
|
|
21424
|
-
var
|
|
21425
|
-
var import_jupiter2 = __toESM(
|
|
22049
|
+
var import_web334 = require("@solana/web3.js");
|
|
22050
|
+
var import_common58 = __toESM(require_dist());
|
|
22051
|
+
var import_jupiter2 = __toESM(require_dist4());
|
|
21426
22052
|
var import_marginfi4 = __toESM(require_dist2());
|
|
21427
22053
|
var IDLE_RESERVE_FLOOR_BPS = 400;
|
|
21428
22054
|
var IDLE_RESERVE_TARGET_BPS = 500;
|
|
@@ -21520,8 +22146,8 @@ var IdleLiquidityService = class {
|
|
|
21520
22146
|
let quote;
|
|
21521
22147
|
try {
|
|
21522
22148
|
quote = await jupiter.getQuote({
|
|
21523
|
-
inputMint:
|
|
21524
|
-
outputMint:
|
|
22149
|
+
inputMint: import_common58.PST_MINT,
|
|
22150
|
+
outputMint: import_common58.USDC_MINT,
|
|
21525
22151
|
amount: pstInput,
|
|
21526
22152
|
slippageBps: opts.slippageBps ?? DEFAULT_SLIPPAGE_BPS,
|
|
21527
22153
|
maxAccounts: DEFAULT_MAX_ACCOUNTS
|
|
@@ -21567,13 +22193,13 @@ var IdleLiquidityService = class {
|
|
|
21567
22193
|
/** Read only the two locations that constitute the idle USDC reserve. */
|
|
21568
22194
|
async fetchIdleUsdc(vault, vaultState) {
|
|
21569
22195
|
const connection = this.client.provider.connection;
|
|
21570
|
-
const vaultPk = new
|
|
21571
|
-
const usdcMint = new
|
|
21572
|
-
const ata = (0,
|
|
22196
|
+
const vaultPk = new import_web334.PublicKey(vault);
|
|
22197
|
+
const usdcMint = new import_web334.PublicKey(import_common58.USDC_MINT);
|
|
22198
|
+
const ata = (0, import_spl_token21.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
|
|
21573
22199
|
const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
|
|
21574
22200
|
let localAmount = 0n;
|
|
21575
22201
|
if (tokenInfo) {
|
|
21576
|
-
const tokenAccount = (0,
|
|
22202
|
+
const tokenAccount = (0, import_spl_token21.unpackAccount)(ata, tokenInfo, import_spl_token21.TOKEN_PROGRAM_ID);
|
|
21577
22203
|
if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
|
|
21578
22204
|
throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
|
|
21579
22205
|
}
|
|
@@ -21587,12 +22213,12 @@ var IdleLiquidityService = class {
|
|
|
21587
22213
|
if (data[0] !== 1) {
|
|
21588
22214
|
throw new Error("External-liquidity slot 0 is not Marginfi");
|
|
21589
22215
|
}
|
|
21590
|
-
const positionPk = new
|
|
22216
|
+
const positionPk = new import_web334.PublicKey(new Uint8Array(data.slice(8, 40)));
|
|
21591
22217
|
const positionInfo = await connection.getAccountInfo(
|
|
21592
22218
|
positionPk,
|
|
21593
22219
|
"confirmed"
|
|
21594
22220
|
);
|
|
21595
|
-
if (!positionInfo || !positionInfo.owner.equals(new
|
|
22221
|
+
if (!positionInfo || !positionInfo.owner.equals(new import_web334.PublicKey(import_marginfi4.MARGINFI_PROGRAM_ID))) {
|
|
21596
22222
|
throw new Error(
|
|
21597
22223
|
`Invalid Marginfi slot-0 account: ${positionPk.toBase58()}`
|
|
21598
22224
|
);
|
|
@@ -21642,8 +22268,8 @@ var IdleLiquidityService = class {
|
|
|
21642
22268
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
21643
22269
|
return { result: { ...empty, status: "no-tvl", reason } };
|
|
21644
22270
|
}
|
|
21645
|
-
const usdc = findHolding2(vaultState,
|
|
21646
|
-
const pst = findHolding2(vaultState,
|
|
22271
|
+
const usdc = findHolding2(vaultState, import_common58.USDC_MINT);
|
|
22272
|
+
const pst = findHolding2(vaultState, import_common58.PST_MINT);
|
|
21647
22273
|
if (!usdc || !pst) {
|
|
21648
22274
|
const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
|
|
21649
22275
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
@@ -21771,16 +22397,16 @@ var IdleLiquidityService = class {
|
|
|
21771
22397
|
*/
|
|
21772
22398
|
async mintTokenProgram(mint) {
|
|
21773
22399
|
const account = await this.client.provider.connection.getAccountInfo(
|
|
21774
|
-
new
|
|
22400
|
+
new import_web334.PublicKey(mint),
|
|
21775
22401
|
"confirmed"
|
|
21776
22402
|
);
|
|
21777
22403
|
if (!account) throw new Error(`Mint account not found: ${mint}`);
|
|
21778
|
-
if (!account.owner.equals(
|
|
22404
|
+
if (!account.owner.equals(import_spl_token21.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token21.TOKEN_2022_PROGRAM_ID)) {
|
|
21779
22405
|
throw new Error(
|
|
21780
22406
|
`Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
|
|
21781
22407
|
);
|
|
21782
22408
|
}
|
|
21783
|
-
return (0,
|
|
22409
|
+
return (0, import_common58.fromWeb3Pk)(account.owner);
|
|
21784
22410
|
}
|
|
21785
22411
|
/**
|
|
21786
22412
|
* Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
|
|
@@ -21800,23 +22426,23 @@ var IdleLiquidityService = class {
|
|
|
21800
22426
|
dryRun,
|
|
21801
22427
|
log
|
|
21802
22428
|
} = params;
|
|
21803
|
-
const signer = (0,
|
|
22429
|
+
const signer = (0, import_common58.fromWeb3Pk)(hwManager.publicKey);
|
|
21804
22430
|
const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
|
|
21805
|
-
this.mintTokenProgram(
|
|
21806
|
-
this.mintTokenProgram(
|
|
22431
|
+
this.mintTokenProgram(import_common58.PST_MINT),
|
|
22432
|
+
this.mintTokenProgram(import_common58.USDC_MINT)
|
|
21807
22433
|
]);
|
|
21808
22434
|
const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
|
|
21809
22435
|
payer: signer
|
|
21810
22436
|
});
|
|
21811
|
-
const { accounts: accounts2, refs, lookupTables } = (0,
|
|
22437
|
+
const { accounts: accounts2, refs, lookupTables } = (0, import_common58.createCpiRefs)([jupiterCpi]);
|
|
21812
22438
|
const vaultTrancheState = coerceBool4(
|
|
21813
22439
|
vaultState.tranchingEnabled
|
|
21814
22440
|
) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
|
|
21815
22441
|
const plan = await this.client.tx.jupiterSwap.getTx({
|
|
21816
22442
|
hwManager: signer,
|
|
21817
22443
|
vault,
|
|
21818
|
-
sourceMint:
|
|
21819
|
-
destinationMint:
|
|
22444
|
+
sourceMint: import_common58.PST_MINT,
|
|
22445
|
+
destinationMint: import_common58.USDC_MINT,
|
|
21820
22446
|
refs,
|
|
21821
22447
|
accounts: accounts2,
|
|
21822
22448
|
sourceTokenProgram,
|
|
@@ -21826,26 +22452,26 @@ var IdleLiquidityService = class {
|
|
|
21826
22452
|
});
|
|
21827
22453
|
const connection = this.client.provider.connection;
|
|
21828
22454
|
const instructions2 = [
|
|
21829
|
-
|
|
22455
|
+
import_web334.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
|
|
21830
22456
|
...cuPriceMicroLamports > 0 ? [
|
|
21831
|
-
|
|
22457
|
+
import_web334.ComputeBudgetProgram.setComputeUnitPrice({
|
|
21832
22458
|
microLamports: cuPriceMicroLamports
|
|
21833
22459
|
})
|
|
21834
22460
|
] : [],
|
|
21835
|
-
...(jupiterCpi.preInstructions ?? []).map(
|
|
21836
|
-
...plan.instructions.map(
|
|
22461
|
+
...(jupiterCpi.preInstructions ?? []).map(import_common58.fromKitInstruction),
|
|
22462
|
+
...plan.instructions.map(import_common58.fromKitInstruction)
|
|
21837
22463
|
];
|
|
21838
22464
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
21839
|
-
const lookupTableAccounts = await (0,
|
|
22465
|
+
const lookupTableAccounts = await (0, import_common58.fetchLookupTables)(
|
|
21840
22466
|
connection,
|
|
21841
22467
|
plan.lookupTables ?? []
|
|
21842
22468
|
);
|
|
21843
|
-
const message2 = new
|
|
22469
|
+
const message2 = new import_web334.TransactionMessage({
|
|
21844
22470
|
payerKey: hwManager.publicKey,
|
|
21845
22471
|
recentBlockhash: blockhash,
|
|
21846
22472
|
instructions: instructions2
|
|
21847
22473
|
}).compileToV0Message(lookupTableAccounts);
|
|
21848
|
-
const transaction = new
|
|
22474
|
+
const transaction = new import_web334.VersionedTransaction(message2);
|
|
21849
22475
|
transaction.sign([hwManager]);
|
|
21850
22476
|
if (!this.client.skipSimulation) {
|
|
21851
22477
|
const simulation = await connection.simulateTransaction(transaction, {
|
|
@@ -21891,9 +22517,9 @@ var IdleLiquidityService = class {
|
|
|
21891
22517
|
|
|
21892
22518
|
// src/services/timelockSettlementService.ts
|
|
21893
22519
|
var import_kit17 = require("@solana/kit");
|
|
21894
|
-
var
|
|
21895
|
-
var
|
|
21896
|
-
var ZERO_PUBKEY =
|
|
22520
|
+
var import_web335 = require("@solana/web3.js");
|
|
22521
|
+
var import_common59 = __toESM(require_dist());
|
|
22522
|
+
var ZERO_PUBKEY = import_web335.PublicKey.default.toBase58();
|
|
21897
22523
|
var CONSENSUS_SIGNER_CAPACITY = 4;
|
|
21898
22524
|
var CONSENSUS_ENTRY_OFFSET = 40;
|
|
21899
22525
|
var CONSENSUS_ENTRY_SIZE = 272;
|
|
@@ -21933,7 +22559,7 @@ function decodePendingConsensusSigners(data) {
|
|
|
21933
22559
|
const signers = [];
|
|
21934
22560
|
for (let i = 0; i < count; i += 1) {
|
|
21935
22561
|
const start = CONSENSUS_PENDING_OFFSET + i * 32;
|
|
21936
|
-
const signer = new
|
|
22562
|
+
const signer = new import_web335.PublicKey(bytes.slice(start, start + 32)).toBase58();
|
|
21937
22563
|
if (signer === ZERO_PUBKEY) {
|
|
21938
22564
|
throw new Error(`pending consensus signer ${i} is unset`);
|
|
21939
22565
|
}
|
|
@@ -21989,7 +22615,7 @@ var TimelockSettlementService = class {
|
|
|
21989
22615
|
});
|
|
21990
22616
|
const dryRun = opts.dryRun ?? false;
|
|
21991
22617
|
const now = opts.now ?? await this.chainTime();
|
|
21992
|
-
const fulfillerAddress = (0,
|
|
22618
|
+
const fulfillerAddress = (0, import_common59.fromWeb3Pk)(fulfiller.publicKey);
|
|
21993
22619
|
const allVaults = opts.vault ? [
|
|
21994
22620
|
{
|
|
21995
22621
|
publicKey: opts.vault,
|
|
@@ -22132,18 +22758,18 @@ var TimelockSettlementService = class {
|
|
|
22132
22758
|
|
|
22133
22759
|
// src/services/nestWithdrawalService.ts
|
|
22134
22760
|
var import_kit18 = require("@solana/kit");
|
|
22135
|
-
var
|
|
22136
|
-
var
|
|
22137
|
-
var
|
|
22138
|
-
var import_nest3 = __toESM(
|
|
22139
|
-
var import_nest4 = __toESM(
|
|
22140
|
-
var NestOftProgram = new
|
|
22761
|
+
var import_spl_token22 = require("@solana/spl-token");
|
|
22762
|
+
var import_web336 = require("@solana/web3.js");
|
|
22763
|
+
var import_common60 = __toESM(require_dist());
|
|
22764
|
+
var import_nest3 = __toESM(require_dist3());
|
|
22765
|
+
var import_nest4 = __toESM(require_dist3());
|
|
22766
|
+
var NestOftProgram = new import_web336.PublicKey(
|
|
22141
22767
|
"ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
|
|
22142
22768
|
);
|
|
22143
|
-
var NestOftStore = new
|
|
22769
|
+
var NestOftStore = new import_web336.PublicKey(
|
|
22144
22770
|
"k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
|
|
22145
22771
|
);
|
|
22146
|
-
var UsdcMint = new
|
|
22772
|
+
var UsdcMint = new import_web336.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
22147
22773
|
var NestPerenaComposer = Buffer.from(
|
|
22148
22774
|
"000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
|
|
22149
22775
|
"hex"
|
|
@@ -22160,7 +22786,7 @@ async function buildNestWithdrawalRequest(args) {
|
|
|
22160
22786
|
return decodeNestWithdrawalRequest({ ...args, txBase64 });
|
|
22161
22787
|
}
|
|
22162
22788
|
async function decodeNestWithdrawalRequest(args) {
|
|
22163
|
-
const transaction =
|
|
22789
|
+
const transaction = import_web336.VersionedTransaction.deserialize(
|
|
22164
22790
|
Buffer.from(args.txBase64, "base64")
|
|
22165
22791
|
);
|
|
22166
22792
|
const message2 = transaction.message;
|
|
@@ -22181,19 +22807,19 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22181
22807
|
return value;
|
|
22182
22808
|
})
|
|
22183
22809
|
);
|
|
22184
|
-
const decoded =
|
|
22810
|
+
const decoded = import_web336.TransactionMessage.decompile(message2, {
|
|
22185
22811
|
addressLookupTableAccounts: tables
|
|
22186
22812
|
});
|
|
22187
|
-
const nestMint = new
|
|
22188
|
-
const sourceAta = (0,
|
|
22189
|
-
const usdcAta = (0,
|
|
22813
|
+
const nestMint = new import_web336.PublicKey(NEST_RWA_SHARE_MINT);
|
|
22814
|
+
const sourceAta = (0, import_spl_token22.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
|
|
22815
|
+
const usdcAta = (0, import_spl_token22.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
|
|
22190
22816
|
const instructions2 = decoded.instructions.filter(
|
|
22191
|
-
(ix) => !ix.programId.equals(
|
|
22817
|
+
(ix) => !ix.programId.equals(import_web336.ComputeBudgetProgram.programId)
|
|
22192
22818
|
);
|
|
22193
22819
|
let sends = 0;
|
|
22194
22820
|
for (const ix of instructions2) {
|
|
22195
|
-
if (ix.programId.equals(
|
|
22196
|
-
if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(usdcAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(UsdcMint) || !ix.keys[5]?.pubkey.equals(
|
|
22821
|
+
if (ix.programId.equals(import_spl_token22.ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
22822
|
+
if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(usdcAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(UsdcMint) || !ix.keys[5]?.pubkey.equals(import_spl_token22.TOKEN_PROGRAM_ID)) {
|
|
22197
22823
|
throw new Error("Unexpected token account creation in Nest withdrawal");
|
|
22198
22824
|
}
|
|
22199
22825
|
continue;
|
|
@@ -22210,13 +22836,13 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22210
22836
|
if (sends !== 1)
|
|
22211
22837
|
throw new Error("Nest withdrawal must contain exactly one OFT send");
|
|
22212
22838
|
return {
|
|
22213
|
-
instructions: instructions2.map(
|
|
22839
|
+
instructions: instructions2.map(import_common60.toKitInstruction),
|
|
22214
22840
|
lookupTables: tables.map((table) => (0, import_kit18.address)(table.key.toBase58()))
|
|
22215
22841
|
};
|
|
22216
22842
|
}
|
|
22217
22843
|
|
|
22218
22844
|
// src/index.ts
|
|
22219
|
-
var
|
|
22845
|
+
var import_common61 = __toESM(require_dist());
|
|
22220
22846
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22221
22847
|
0 && (module.exports = {
|
|
22222
22848
|
ASSET_DECIMALS,
|
|
@@ -22224,16 +22850,19 @@ var import_common57 = __toESM(require_dist());
|
|
|
22224
22850
|
AccountClient,
|
|
22225
22851
|
ActivateCircuitBreakerBuilder,
|
|
22226
22852
|
AddIncentiveRecipientBuilder,
|
|
22853
|
+
AddIncentiveRecipientV3Builder,
|
|
22227
22854
|
BALANCE_CHANGE_BASELINE_MAX_AGE_SECS,
|
|
22228
22855
|
CONSENSUS_ORACLE_VARIANT,
|
|
22229
22856
|
CancelIncentiveProposalBuilder,
|
|
22230
22857
|
CancelJuniorTrancheWithdrawBuilder,
|
|
22231
22858
|
ClaimIncentiveBuilder,
|
|
22859
|
+
ClaimIncentiveV3Builder,
|
|
22232
22860
|
ConsensusOracleService,
|
|
22233
22861
|
CrankNavBuilder,
|
|
22234
22862
|
CrankPerformanceFeesBuilder,
|
|
22235
22863
|
CreateAssetHoldingBuilder,
|
|
22236
22864
|
CreateIncentiveBuilder,
|
|
22865
|
+
CreateIncentiveV3Builder,
|
|
22237
22866
|
CreateTrancheStateBuilder,
|
|
22238
22867
|
CreateVaultBuilder,
|
|
22239
22868
|
DEFAULT_CU_PRICE_MICRO_LAMPORTS,
|
|
@@ -22254,6 +22883,7 @@ var import_common57 = __toESM(require_dist());
|
|
|
22254
22883
|
DEFAULT_VAULT_ID,
|
|
22255
22884
|
DisableCircuitBreakerBuilder,
|
|
22256
22885
|
DistributeIncentiveBuilder,
|
|
22886
|
+
DistributeIncentiveV3Builder,
|
|
22257
22887
|
EXTERNAL_POSITION_SAMPLES,
|
|
22258
22888
|
ExecuteDepositBuilder,
|
|
22259
22889
|
ExecuteShareSwapBuilder,
|
|
@@ -22277,10 +22907,13 @@ var import_common57 = __toESM(require_dist());
|
|
|
22277
22907
|
LOCAL_PROTOCOL_ADMIN,
|
|
22278
22908
|
LargeBalanceChangeError,
|
|
22279
22909
|
LivePriceSource,
|
|
22910
|
+
MANAGER_WALLET_NAV_DROP_TRIGGER_BPS,
|
|
22911
|
+
MANAGER_WALLET_NAV_TOLERANCE_BPS,
|
|
22280
22912
|
MAX_APY_ANCHOR_WINDOW_SECS,
|
|
22281
22913
|
MAX_BALANCE_CHANGE_BPS,
|
|
22282
22914
|
MAX_CONSENSUS_SIGNERS,
|
|
22283
22915
|
MAX_INCENTIVE_RECIPIENTS,
|
|
22916
|
+
MAX_INCENTIVE_REPORT_TTL,
|
|
22284
22917
|
MAX_MANAGER_WITHDRAW_DESTINATIONS,
|
|
22285
22918
|
MAX_PRICE_STALENESS_THRESHOLD_SECS,
|
|
22286
22919
|
MIN_EXTERNAL_POSITION_SAMPLES,
|
|
@@ -22306,15 +22939,19 @@ var import_common57 = __toESM(require_dist());
|
|
|
22306
22939
|
ProtocolInteractionBuilder,
|
|
22307
22940
|
REPORTABLE_ORACLE_VARIANTS,
|
|
22308
22941
|
RemoveAssetHoldingBuilder,
|
|
22942
|
+
ReportIncentiveV3Builder,
|
|
22309
22943
|
RequestJuniorTrancheWithdrawBuilder,
|
|
22944
|
+
RpcManagerWalletBalanceSource,
|
|
22310
22945
|
SHARE_DECIMALS,
|
|
22311
22946
|
SYSTEM_PROGRAM,
|
|
22312
22947
|
SetAssetPriceOracleBuilder,
|
|
22313
22948
|
SetExternalLiquidityBuilder,
|
|
22314
22949
|
SetIncentiveLimitsBuilder,
|
|
22950
|
+
SetIncentiveLimitsV3Builder,
|
|
22315
22951
|
SetManagerWithdrawDestinationBuilder,
|
|
22316
22952
|
SetProtocolFeeBuilder,
|
|
22317
22953
|
SetVaultConfigBuilder,
|
|
22954
|
+
SettleIncentiveV3Builder,
|
|
22318
22955
|
SquadsProposalExecutionSimulationError,
|
|
22319
22956
|
StaticPositionProvider,
|
|
22320
22957
|
SubmitIncentiveBuilder,
|
|
@@ -22355,6 +22992,7 @@ var import_common57 = __toESM(require_dist());
|
|
|
22355
22992
|
buildMarginfiWithdrawInteraction,
|
|
22356
22993
|
buildNestWithdrawalRequest,
|
|
22357
22994
|
buildUpdates,
|
|
22995
|
+
candidateGrossNav,
|
|
22358
22996
|
coerceBool,
|
|
22359
22997
|
collectSamples,
|
|
22360
22998
|
confirmYieldPayment,
|
|
@@ -22391,6 +23029,10 @@ var import_common57 = __toESM(require_dist());
|
|
|
22391
23029
|
getIncentiveRecipients,
|
|
22392
23030
|
getIncentiveReportRecipients,
|
|
22393
23031
|
getIncentiveTotals,
|
|
23032
|
+
getIncentiveV3OracleState,
|
|
23033
|
+
getIncentiveV3RecipientShareAtas,
|
|
23034
|
+
getIncentiveV3Recipients,
|
|
23035
|
+
getIncentiveV3Totals,
|
|
22394
23036
|
getNavValue,
|
|
22395
23037
|
getRpcUrl,
|
|
22396
23038
|
getTotalOutstandingYield,
|
|
@@ -22409,6 +23051,7 @@ var import_common57 = __toESM(require_dist());
|
|
|
22409
23051
|
loadKeypair,
|
|
22410
23052
|
logProspectiveApy,
|
|
22411
23053
|
makeProvider,
|
|
23054
|
+
managerReconciliationStateKey,
|
|
22412
23055
|
mintTokensTo,
|
|
22413
23056
|
mints,
|
|
22414
23057
|
mostFrequent,
|
|
@@ -22416,9 +23059,11 @@ var import_common57 = __toESM(require_dist());
|
|
|
22416
23059
|
planRebalance,
|
|
22417
23060
|
prepareSquadsProposalUpload,
|
|
22418
23061
|
prepareVaultTransaction,
|
|
23062
|
+
previousPhysicalNav,
|
|
22419
23063
|
priceInAccountingUnit,
|
|
22420
23064
|
readI64LE,
|
|
22421
23065
|
readSplMintSupply,
|
|
23066
|
+
reconcileManagerWalletBalances,
|
|
22422
23067
|
refreshLiveOraclePrices,
|
|
22423
23068
|
resolveExternalWithdraw,
|
|
22424
23069
|
resolveKeypairPath,
|