@xitadel-fi/sdk 0.1.4 → 0.1.6
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);
|
|
@@ -573,28 +569,34 @@ class XitadelProgram {
|
|
|
573
569
|
});
|
|
574
570
|
const addresses = [
|
|
575
571
|
lttConfigPda,
|
|
576
|
-
lpAuthority,
|
|
577
572
|
poolAuthority,
|
|
573
|
+
pool,
|
|
574
|
+
poolb,
|
|
578
575
|
lpMint,
|
|
579
576
|
ammConfig,
|
|
580
577
|
ammConfigB,
|
|
581
578
|
params.lttId,
|
|
582
579
|
params.stableCoinMint,
|
|
583
|
-
|
|
584
|
-
lttVaultAta,
|
|
585
|
-
stableVaultAta,
|
|
586
|
-
lttTokenAccount,
|
|
587
|
-
lpUsdcAta,
|
|
580
|
+
fundingVaultTokenAccount,
|
|
588
581
|
lttVaultAta,
|
|
589
582
|
stableVaultAta,
|
|
590
583
|
lttVaultAtaB,
|
|
591
584
|
stableVaultAtaB,
|
|
592
|
-
|
|
593
|
-
|
|
585
|
+
payerLttTokenAccount,
|
|
586
|
+
payerStableCoinTokenAccount,
|
|
587
|
+
positionNftMintKeypair.publicKey,
|
|
588
|
+
positionNftMintKeypairB.publicKey,
|
|
589
|
+
positionNftAccount,
|
|
590
|
+
positionNftAccountB,
|
|
591
|
+
position,
|
|
592
|
+
positionB,
|
|
594
593
|
spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
595
594
|
web3_js_2.SystemProgram.programId,
|
|
595
|
+
collateralVaultAta,
|
|
596
|
+
spl_token_1.TOKEN_PROGRAM_ID,
|
|
596
597
|
spl_token_1.TOKEN_PROGRAM_ID,
|
|
597
598
|
spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
599
|
+
eventAuthority,
|
|
598
600
|
params.cpAmmProgramId,
|
|
599
601
|
web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
600
602
|
];
|
|
@@ -772,7 +774,6 @@ class XitadelProgram {
|
|
|
772
774
|
const managerFundingAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, manager, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
773
775
|
const managerCollateralAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.collateralTokenMint, manager, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
774
776
|
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
777
|
const interestVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, lttConfigPda, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
777
778
|
const instructions = [];
|
|
778
779
|
// Create missing ATAs if needed
|
|
@@ -988,9 +989,10 @@ class XitadelProgram {
|
|
|
988
989
|
const configPda = this.getConfigPda();
|
|
989
990
|
const lttConfigPda = this.getLTTConfigPda(lttId);
|
|
990
991
|
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(
|
|
992
|
+
const tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('token_stake'), lttConfigPda.toBuffer()], flashTradeProgramId)[0];
|
|
992
993
|
let tokenStakeAccounts = [];
|
|
993
|
-
if (tokenStakeAccount &&
|
|
994
|
+
if (tokenStakeAccount &&
|
|
995
|
+
(await (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.program.provider.connection))) {
|
|
994
996
|
tokenStakeAccounts.push({
|
|
995
997
|
pubkey: tokenStakeAccount,
|
|
996
998
|
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
|
}
|