@xitadel-fi/sdk 0.1.4 → 0.1.5
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/sdk/src/program.js
CHANGED
|
@@ -165,7 +165,6 @@ class XitadelProgram {
|
|
|
165
165
|
*/
|
|
166
166
|
async fundLTT(lttId, investor, fundingAmount) {
|
|
167
167
|
const lttConfigPda = this.getLTTConfigPda(lttId);
|
|
168
|
-
const fundingRecordPda = this.getFundingRecordPda(lttConfigPda, investor);
|
|
169
168
|
const lttConfig = await this.program.account.lttConfiguration.fetch(lttConfigPda);
|
|
170
169
|
const fundingTokenMint = lttConfig.fundingTokenMint;
|
|
171
170
|
const fundingVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(fundingTokenMint, lttConfigPda, true);
|
|
@@ -506,9 +505,6 @@ class XitadelProgram {
|
|
|
506
505
|
const lpAuthority = this.getLpAuthority();
|
|
507
506
|
const lttConfigPda = this.getLTTConfigPda(params.lttId);
|
|
508
507
|
const lttTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(params.lttId, lpAuthority, true);
|
|
509
|
-
const lpUsdcAta = (0, spl_token_1.getAssociatedTokenAddressSync)(params.stableCoinMint, lpAuthority, true);
|
|
510
|
-
const fundingVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(params.stableCoinMint, lttConfigPda, true);
|
|
511
|
-
// console.log("lpAuthority", lpAuthority.toBase58());
|
|
512
508
|
const instructions = [];
|
|
513
509
|
// Create stable coin token account if it doesn't exist
|
|
514
510
|
const stableCoinVaultTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(params.stableCoinMint, lpAuthority, true);
|
|
@@ -572,29 +568,37 @@ class XitadelProgram {
|
|
|
572
568
|
recentSlot: await this.program.provider.connection.getSlot(),
|
|
573
569
|
});
|
|
574
570
|
const addresses = [
|
|
571
|
+
signer,
|
|
575
572
|
lttConfigPda,
|
|
576
573
|
lpAuthority,
|
|
577
574
|
poolAuthority,
|
|
575
|
+
pool,
|
|
576
|
+
poolb,
|
|
578
577
|
lpMint,
|
|
579
578
|
ammConfig,
|
|
580
579
|
ammConfigB,
|
|
581
580
|
params.lttId,
|
|
582
581
|
params.stableCoinMint,
|
|
583
|
-
|
|
584
|
-
lttVaultAta,
|
|
585
|
-
stableVaultAta,
|
|
586
|
-
lttTokenAccount,
|
|
587
|
-
lpUsdcAta,
|
|
582
|
+
fundingVaultTokenAccount,
|
|
588
583
|
lttVaultAta,
|
|
589
584
|
stableVaultAta,
|
|
590
585
|
lttVaultAtaB,
|
|
591
586
|
stableVaultAtaB,
|
|
592
|
-
|
|
593
|
-
|
|
587
|
+
payerLttTokenAccount,
|
|
588
|
+
payerStableCoinTokenAccount,
|
|
589
|
+
positionNftMintKeypair.publicKey,
|
|
590
|
+
positionNftMintKeypairB.publicKey,
|
|
591
|
+
positionNftAccount,
|
|
592
|
+
positionNftAccountB,
|
|
593
|
+
position,
|
|
594
|
+
positionB,
|
|
594
595
|
spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
595
596
|
web3_js_2.SystemProgram.programId,
|
|
597
|
+
collateralVaultAta,
|
|
598
|
+
spl_token_1.TOKEN_PROGRAM_ID,
|
|
596
599
|
spl_token_1.TOKEN_PROGRAM_ID,
|
|
597
600
|
spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
601
|
+
eventAuthority,
|
|
598
602
|
params.cpAmmProgramId,
|
|
599
603
|
web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
600
604
|
];
|
|
@@ -772,7 +776,6 @@ class XitadelProgram {
|
|
|
772
776
|
const managerFundingAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, manager, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
773
777
|
const managerCollateralAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.collateralTokenMint, manager, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
774
778
|
const fundingVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, lttConfigPda, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
775
|
-
const collateralVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.collateralTokenMint, lttConfigPda, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
776
779
|
const interestVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, lttConfigPda, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
777
780
|
const instructions = [];
|
|
778
781
|
// Create missing ATAs if needed
|
|
@@ -988,9 +991,10 @@ class XitadelProgram {
|
|
|
988
991
|
const configPda = this.getConfigPda();
|
|
989
992
|
const lttConfigPda = this.getLTTConfigPda(lttId);
|
|
990
993
|
const collateralVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lpTokenMint, lttConfigPda, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
991
|
-
const tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(
|
|
994
|
+
const tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('token_stake'), lttConfigPda.toBuffer()], flashTradeProgramId)[0];
|
|
992
995
|
let tokenStakeAccounts = [];
|
|
993
|
-
if (tokenStakeAccount &&
|
|
996
|
+
if (tokenStakeAccount &&
|
|
997
|
+
(await (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.program.provider.connection))) {
|
|
994
998
|
tokenStakeAccounts.push({
|
|
995
999
|
pubkey: tokenStakeAccount,
|
|
996
1000
|
isSigner: false,
|
|
@@ -5356,26 +5356,41 @@
|
|
|
5356
5356
|
},
|
|
5357
5357
|
{
|
|
5358
5358
|
"code": 6032,
|
|
5359
|
+
"name": "WithdrawalNotAllowed",
|
|
5360
|
+
"msg": "Withdrawal of staked collateral is only allowed when maturity time is reached or liquidation has started"
|
|
5361
|
+
},
|
|
5362
|
+
{
|
|
5363
|
+
"code": 6033,
|
|
5364
|
+
"name": "StakedCollateralNotWithdrawnForMaturity",
|
|
5365
|
+
"msg": "All staked collateral must be withdrawn before maturity"
|
|
5366
|
+
},
|
|
5367
|
+
{
|
|
5368
|
+
"code": 6034,
|
|
5369
|
+
"name": "StakedCollateralNotWithdrawnForLiquidation",
|
|
5370
|
+
"msg": "All staked collateral must be withdrawn before liquidation execution"
|
|
5371
|
+
},
|
|
5372
|
+
{
|
|
5373
|
+
"code": 6035,
|
|
5359
5374
|
"name": "InvalidAccount",
|
|
5360
5375
|
"msg": "Invalid Account"
|
|
5361
5376
|
},
|
|
5362
5377
|
{
|
|
5363
|
-
"code":
|
|
5378
|
+
"code": 6036,
|
|
5364
5379
|
"name": "InvalidAccessController",
|
|
5365
5380
|
"msg": "Invalid access controller account"
|
|
5366
5381
|
},
|
|
5367
5382
|
{
|
|
5368
|
-
"code":
|
|
5383
|
+
"code": 6037,
|
|
5369
5384
|
"name": "InvalidConfigAccount",
|
|
5370
5385
|
"msg": "Invalid config account"
|
|
5371
5386
|
},
|
|
5372
5387
|
{
|
|
5373
|
-
"code":
|
|
5388
|
+
"code": 6038,
|
|
5374
5389
|
"name": "InvalidPriceFeedId",
|
|
5375
5390
|
"msg": "Invalid price feed ID"
|
|
5376
5391
|
},
|
|
5377
5392
|
{
|
|
5378
|
-
"code":
|
|
5393
|
+
"code": 6039,
|
|
5379
5394
|
"name": "InvalidVerifierAccount",
|
|
5380
5395
|
"msg": "Invalid verifier account"
|
|
5381
5396
|
}
|
|
@@ -5362,26 +5362,41 @@ export type Xitadel = {
|
|
|
5362
5362
|
},
|
|
5363
5363
|
{
|
|
5364
5364
|
"code": 6032;
|
|
5365
|
+
"name": "withdrawalNotAllowed";
|
|
5366
|
+
"msg": "Withdrawal of staked collateral is only allowed when maturity time is reached or liquidation has started";
|
|
5367
|
+
},
|
|
5368
|
+
{
|
|
5369
|
+
"code": 6033;
|
|
5370
|
+
"name": "stakedCollateralNotWithdrawnForMaturity";
|
|
5371
|
+
"msg": "All staked collateral must be withdrawn before maturity";
|
|
5372
|
+
},
|
|
5373
|
+
{
|
|
5374
|
+
"code": 6034;
|
|
5375
|
+
"name": "stakedCollateralNotWithdrawnForLiquidation";
|
|
5376
|
+
"msg": "All staked collateral must be withdrawn before liquidation execution";
|
|
5377
|
+
},
|
|
5378
|
+
{
|
|
5379
|
+
"code": 6035;
|
|
5365
5380
|
"name": "invalidAccount";
|
|
5366
5381
|
"msg": "Invalid Account";
|
|
5367
5382
|
},
|
|
5368
5383
|
{
|
|
5369
|
-
"code":
|
|
5384
|
+
"code": 6036;
|
|
5370
5385
|
"name": "invalidAccessController";
|
|
5371
5386
|
"msg": "Invalid access controller account";
|
|
5372
5387
|
},
|
|
5373
5388
|
{
|
|
5374
|
-
"code":
|
|
5389
|
+
"code": 6037;
|
|
5375
5390
|
"name": "invalidConfigAccount";
|
|
5376
5391
|
"msg": "Invalid config account";
|
|
5377
5392
|
},
|
|
5378
5393
|
{
|
|
5379
|
-
"code":
|
|
5394
|
+
"code": 6038;
|
|
5380
5395
|
"name": "invalidPriceFeedId";
|
|
5381
5396
|
"msg": "Invalid price feed ID";
|
|
5382
5397
|
},
|
|
5383
5398
|
{
|
|
5384
|
-
"code":
|
|
5399
|
+
"code": 6039;
|
|
5385
5400
|
"name": "invalidVerifierAccount";
|
|
5386
5401
|
"msg": "Invalid verifier account";
|
|
5387
5402
|
}
|