flash-sdk 2.0.35 → 2.0.37
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/PerpetualsClient.d.ts +15 -1
- package/dist/PerpetualsClient.js +162 -15
- package/dist/PoolConfig.d.ts +2 -1
- package/dist/PoolConfig.js +3 -2
- package/dist/PoolConfig.json +4 -0
- package/dist/idl/fbnft_rewards.d.ts +285 -0
- package/dist/idl/fbnft_rewards.js +287 -0
- package/dist/test2.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
@@ -12,6 +12,7 @@ import { SendTransactionOpts } from "./utils/rpc";
|
|
12
12
|
import { MarketConfig, PoolConfig, Token } from "./PoolConfig";
|
13
13
|
import { max } from "bn.js";
|
14
14
|
import { MarketAccount } from "./MarketAccount";
|
15
|
+
import { FbnftRewards } from "./idl/fbnft_rewards";
|
15
16
|
export type PerpClientOptions = {
|
16
17
|
postSendTxCallback?: ({ txid }: {
|
17
18
|
txid: string;
|
@@ -23,6 +24,7 @@ export declare class PerpetualsClient {
|
|
23
24
|
provider: AnchorProvider;
|
24
25
|
program: Program<Perpetuals>;
|
25
26
|
programPerpComposability: Program<PerpComposability>;
|
27
|
+
programFbnftReward: Program<FbnftRewards>;
|
26
28
|
admin: PublicKey;
|
27
29
|
programId: PublicKey;
|
28
30
|
composabilityProgramId: PublicKey;
|
@@ -46,7 +48,7 @@ export declare class PerpetualsClient {
|
|
46
48
|
private postSendTxCallback?;
|
47
49
|
private prioritizationFee;
|
48
50
|
private txConfirmationCommitment;
|
49
|
-
constructor(provider: AnchorProvider, programId: PublicKey, composabilityProgramId: PublicKey, opts: PerpClientOptions);
|
51
|
+
constructor(provider: AnchorProvider, programId: PublicKey, composabilityProgramId: PublicKey, fbNftRewardProgramId: PublicKey, opts: PerpClientOptions);
|
50
52
|
setPrioritizationFee: (fee: number) => void;
|
51
53
|
loadAddressLookupTable: (poolConfig: PoolConfig) => Promise<void>;
|
52
54
|
findProgramAddress: (label: string, extraSeeds?: any) => {
|
@@ -2290,6 +2292,18 @@ export declare class PerpetualsClient {
|
|
2290
2292
|
instructions: TransactionInstruction[];
|
2291
2293
|
additionalSigners: Signer[];
|
2292
2294
|
}>;
|
2295
|
+
initRewardVault: (nftCount: BN, rewardSymbol: string, collectionMint: PublicKey, poolConfig: PoolConfig) => Promise<{
|
2296
|
+
instructions: TransactionInstruction[];
|
2297
|
+
additionalSigners: Signer[];
|
2298
|
+
}>;
|
2299
|
+
distributeReward: (rewardAmount: BN, rewardSymbol: string, poolConfig: PoolConfig) => Promise<{
|
2300
|
+
instructions: TransactionInstruction[];
|
2301
|
+
additionalSigners: Signer[];
|
2302
|
+
}>;
|
2303
|
+
collectNftReward: (rewardSymbol: string, poolConfig: PoolConfig, nftMint: PublicKey) => Promise<{
|
2304
|
+
instructions: TransactionInstruction[];
|
2305
|
+
additionalSigners: Signer[];
|
2306
|
+
}>;
|
2293
2307
|
setPoolConfig: (permissions: Permissions, oracleAuthority: PublicKey, maxAumUsd: BN, stakingFeeShareBps: BN, poolConfig: PoolConfig) => Promise<{
|
2294
2308
|
instructions: TransactionInstruction[];
|
2295
2309
|
additionalSigners: Signer[];
|
package/dist/PerpetualsClient.js
CHANGED
@@ -70,13 +70,14 @@ var types_1 = require("./types");
|
|
70
70
|
var OraclePrice_1 = require("./OraclePrice");
|
71
71
|
var perpetuals_1 = require("./idl/perpetuals");
|
72
72
|
var perp_composability_1 = require("./idl/perp_composability");
|
73
|
+
var fbnft_rewards_1 = require("./idl/fbnft_rewards");
|
73
74
|
var rpc_1 = require("./utils/rpc");
|
74
75
|
var utils_1 = require("./utils");
|
75
76
|
var constants_1 = require("./constants");
|
76
77
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
77
78
|
var getNftAccounts_1 = require("./utils/getNftAccounts");
|
78
79
|
var PerpetualsClient = (function () {
|
79
|
-
function PerpetualsClient(provider, programId, composabilityProgramId, opts) {
|
80
|
+
function PerpetualsClient(provider, programId, composabilityProgramId, fbNftRewardProgramId, opts) {
|
80
81
|
var _this = this;
|
81
82
|
var _a;
|
82
83
|
this.addressLookupTables = [];
|
@@ -578,7 +579,7 @@ var PerpetualsClient = (function () {
|
|
578
579
|
if (inputTokenCustodyAccount.isVirtual) {
|
579
580
|
throw new Error("Virtual custody, cannot add liquidity");
|
580
581
|
}
|
581
|
-
if (!inputTokenPrice.exponent.eq(inputTokenEmaPrice.exponent)
|
582
|
+
if (!inputTokenPrice.exponent.eq(inputTokenEmaPrice.exponent)) {
|
582
583
|
throw new Error("exponent mistach");
|
583
584
|
}
|
584
585
|
var minMaxPrice = _this.getMinAndMaxOraclePriceSync(inputTokenPrice, inputTokenEmaPrice, inputTokenCustodyAccount);
|
@@ -597,7 +598,7 @@ var PerpetualsClient = (function () {
|
|
597
598
|
};
|
598
599
|
};
|
599
600
|
this.getRemoveLiquidityAmountAndFeeSync = function (lpAmountIn, poolAccount, outputTokenPrice, outputTokenEmaPrice, outputTokenCustodyAccount, lpTokenSupply, poolAumUsdMax, poolConfig) {
|
600
|
-
if (!outputTokenPrice.exponent.eq(outputTokenEmaPrice.exponent)
|
601
|
+
if (!outputTokenPrice.exponent.eq(outputTokenEmaPrice.exponent)) {
|
601
602
|
throw new Error("exponent mistach");
|
602
603
|
}
|
603
604
|
var minMaxPrice = _this.getMinAndMaxOraclePriceSync(outputTokenPrice, outputTokenEmaPrice, outputTokenCustodyAccount);
|
@@ -3282,9 +3283,7 @@ var PerpetualsClient = (function () {
|
|
3282
3283
|
for (_i = 0, flpStakeAccounts_1 = flpStakeAccounts; _i < flpStakeAccounts_1.length; _i++) {
|
3283
3284
|
flpStakeAccount = flpStakeAccounts_1[_i];
|
3284
3285
|
account = flpStakeAccount.account;
|
3285
|
-
|
3286
|
-
pendingActivationAccounts.push(flpStakeAccount.publicKey);
|
3287
|
-
}
|
3286
|
+
pendingActivationAccounts.push(flpStakeAccount.publicKey);
|
3288
3287
|
}
|
3289
3288
|
refreshStakeInstructions = [];
|
3290
3289
|
console.log("total no of pendingActivationAccounts: ", pendingActivationAccounts.length);
|
@@ -3574,8 +3573,155 @@ var PerpetualsClient = (function () {
|
|
3574
3573
|
}
|
3575
3574
|
});
|
3576
3575
|
}); };
|
3576
|
+
this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3577
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_16;
|
3578
|
+
return __generator(this, function (_a) {
|
3579
|
+
switch (_a.label) {
|
3580
|
+
case 0:
|
3581
|
+
publicKey = this.provider.wallet.publicKey;
|
3582
|
+
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
3583
|
+
instructions = [];
|
3584
|
+
additionalSigners = [];
|
3585
|
+
_a.label = 1;
|
3586
|
+
case 1:
|
3587
|
+
_a.trys.push([1, 3, , 4]);
|
3588
|
+
fbNftProgramData = web3_js_1.PublicKey.findProgramAddressSync([this.programFbnftReward.programId.toBuffer()], new web3_js_1.PublicKey("BPFLoaderUpgradeab1e11111111111111111111111"))[0];
|
3589
|
+
rewardVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reward_vault")], this.programFbnftReward.programId)[0];
|
3590
|
+
rewardTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reward_token_account")], this.programFbnftReward.programId)[0];
|
3591
|
+
nftTransferAuthority = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("transfer_authority")], this.programFbnftReward.programId)[0];
|
3592
|
+
return [4, this.programFbnftReward.methods
|
3593
|
+
.initRewardVault({
|
3594
|
+
nftCount: nftCount
|
3595
|
+
})
|
3596
|
+
.accounts({
|
3597
|
+
admin: publicKey,
|
3598
|
+
transferAuthority: nftTransferAuthority,
|
3599
|
+
rewardVault: rewardVault,
|
3600
|
+
rewardMint: rewardCustodyMint,
|
3601
|
+
rewardTokenAccount: rewardTokenAccount,
|
3602
|
+
collectionMint: collectionMint,
|
3603
|
+
programData: fbNftProgramData,
|
3604
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
3605
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3606
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY
|
3607
|
+
})
|
3608
|
+
.instruction()];
|
3609
|
+
case 2:
|
3610
|
+
initRewardVault = _a.sent();
|
3611
|
+
instructions.push(initRewardVault);
|
3612
|
+
return [3, 4];
|
3613
|
+
case 3:
|
3614
|
+
err_16 = _a.sent();
|
3615
|
+
console.log("perpClient InitRewardVault error:: ", err_16);
|
3616
|
+
throw err_16;
|
3617
|
+
case 4: return [2, {
|
3618
|
+
instructions: __spreadArray([], instructions, true),
|
3619
|
+
additionalSigners: additionalSigners
|
3620
|
+
}];
|
3621
|
+
}
|
3622
|
+
});
|
3623
|
+
}); };
|
3624
|
+
this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3625
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_17;
|
3626
|
+
return __generator(this, function (_a) {
|
3627
|
+
switch (_a.label) {
|
3628
|
+
case 0:
|
3629
|
+
publicKey = this.provider.wallet.publicKey;
|
3630
|
+
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
3631
|
+
instructions = [];
|
3632
|
+
additionalSigners = [];
|
3633
|
+
_a.label = 1;
|
3634
|
+
case 1:
|
3635
|
+
_a.trys.push([1, 4, , 5]);
|
3636
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(rewardCustodyMint, publicKey)];
|
3637
|
+
case 2:
|
3638
|
+
fundingAccount = _a.sent();
|
3639
|
+
rewardVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reward_vault")], this.programFbnftReward.programId)[0];
|
3640
|
+
rewardTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reward_token_account")], this.programFbnftReward.programId)[0];
|
3641
|
+
return [4, this.programFbnftReward.methods
|
3642
|
+
.distributeRewards({
|
3643
|
+
rewardAmount: rewardAmount
|
3644
|
+
})
|
3645
|
+
.accounts({
|
3646
|
+
admin: publicKey,
|
3647
|
+
fundingAccount: fundingAccount,
|
3648
|
+
rewardVault: rewardVault,
|
3649
|
+
rewardTokenAccount: rewardTokenAccount,
|
3650
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3651
|
+
})
|
3652
|
+
.instruction()];
|
3653
|
+
case 3:
|
3654
|
+
distributeReward = _a.sent();
|
3655
|
+
instructions.push(distributeReward);
|
3656
|
+
return [3, 5];
|
3657
|
+
case 4:
|
3658
|
+
err_17 = _a.sent();
|
3659
|
+
console.log("perpClient distributeReward error:: ", err_17);
|
3660
|
+
throw err_17;
|
3661
|
+
case 5: return [2, {
|
3662
|
+
instructions: __spreadArray([], instructions, true),
|
3663
|
+
additionalSigners: additionalSigners
|
3664
|
+
}];
|
3665
|
+
}
|
3666
|
+
});
|
3667
|
+
}); };
|
3668
|
+
this.collectNftReward = function (rewardSymbol, poolConfig, nftMint) { return __awaiter(_this, void 0, void 0, function () {
|
3669
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_18;
|
3670
|
+
return __generator(this, function (_a) {
|
3671
|
+
switch (_a.label) {
|
3672
|
+
case 0:
|
3673
|
+
publicKey = this.provider.wallet.publicKey;
|
3674
|
+
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
3675
|
+
instructions = [];
|
3676
|
+
additionalSigners = [];
|
3677
|
+
_a.label = 1;
|
3678
|
+
case 1:
|
3679
|
+
_a.trys.push([1, 5, , 6]);
|
3680
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(nftMint, publicKey)];
|
3681
|
+
case 2:
|
3682
|
+
nftTokenAccount = _a.sent();
|
3683
|
+
metadataAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
3684
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(rewardCustodyMint, publicKey)];
|
3685
|
+
case 3:
|
3686
|
+
receivingTokenAccount = _a.sent();
|
3687
|
+
rewardRecord = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reward_record"), nftMint.toBuffer()], this.programFbnftReward.programId)[0];
|
3688
|
+
rewardVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reward_vault")], this.programFbnftReward.programId)[0];
|
3689
|
+
rewardTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reward_token_account")], this.programFbnftReward.programId)[0];
|
3690
|
+
nftTransferAuthority = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("transfer_authority")], this.programFbnftReward.programId)[0];
|
3691
|
+
32 - 8 - 24 / 3;
|
3692
|
+
return [4, this.programFbnftReward.methods
|
3693
|
+
.collectReward()
|
3694
|
+
.accounts({
|
3695
|
+
owner: publicKey,
|
3696
|
+
feePayer: publicKey,
|
3697
|
+
nftMint: nftMint,
|
3698
|
+
nftTokenAccount: nftTokenAccount,
|
3699
|
+
metadataAccount: metadataAccount,
|
3700
|
+
receivingAccount: receivingTokenAccount,
|
3701
|
+
rewardRecord: rewardRecord,
|
3702
|
+
rewardVault: rewardVault,
|
3703
|
+
rewardTokenAccount: rewardTokenAccount,
|
3704
|
+
transferAuthority: nftTransferAuthority,
|
3705
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
3706
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3707
|
+
})
|
3708
|
+
.instruction()];
|
3709
|
+
case 4:
|
3710
|
+
collectNftReward = _a.sent();
|
3711
|
+
instructions.push(collectNftReward);
|
3712
|
+
return [3, 6];
|
3713
|
+
case 5:
|
3714
|
+
err_18 = _a.sent();
|
3715
|
+
throw err_18;
|
3716
|
+
case 6: return [2, {
|
3717
|
+
instructions: __spreadArray([], instructions, true),
|
3718
|
+
additionalSigners: additionalSigners
|
3719
|
+
}];
|
3720
|
+
}
|
3721
|
+
});
|
3722
|
+
}); };
|
3577
3723
|
this.setPoolConfig = function (permissions, oracleAuthority, maxAumUsd, stakingFeeShareBps, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3578
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPoolConfigInstruction,
|
3724
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPoolConfigInstruction, err_19;
|
3579
3725
|
return __generator(this, function (_a) {
|
3580
3726
|
switch (_a.label) {
|
3581
3727
|
case 0:
|
@@ -3605,9 +3751,9 @@ var PerpetualsClient = (function () {
|
|
3605
3751
|
instructions.push(setPoolConfigInstruction);
|
3606
3752
|
return [3, 4];
|
3607
3753
|
case 3:
|
3608
|
-
|
3609
|
-
console.log("perpClient setPool error:: ",
|
3610
|
-
throw
|
3754
|
+
err_19 = _a.sent();
|
3755
|
+
console.log("perpClient setPool error:: ", err_19);
|
3756
|
+
throw err_19;
|
3611
3757
|
case 4: return [2, {
|
3612
3758
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3613
3759
|
additionalSigners: additionalSigners
|
@@ -3616,7 +3762,7 @@ var PerpetualsClient = (function () {
|
|
3616
3762
|
});
|
3617
3763
|
}); };
|
3618
3764
|
this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
|
3619
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction,
|
3765
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_20;
|
3620
3766
|
return __generator(this, function (_a) {
|
3621
3767
|
switch (_a.label) {
|
3622
3768
|
case 0:
|
@@ -3643,9 +3789,9 @@ var PerpetualsClient = (function () {
|
|
3643
3789
|
instructions.push(setPermissionsInstruction);
|
3644
3790
|
return [3, 4];
|
3645
3791
|
case 3:
|
3646
|
-
|
3647
|
-
console.log("perpClient setPool error:: ",
|
3648
|
-
throw
|
3792
|
+
err_20 = _a.sent();
|
3793
|
+
console.log("perpClient setPool error:: ", err_20);
|
3794
|
+
throw err_20;
|
3649
3795
|
case 4: return [2, {
|
3650
3796
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3651
3797
|
additionalSigners: additionalSigners
|
@@ -3657,6 +3803,7 @@ var PerpetualsClient = (function () {
|
|
3657
3803
|
(0, anchor_1.setProvider)(provider);
|
3658
3804
|
this.program = new anchor_1.Program(perpetuals_1.IDL, programId);
|
3659
3805
|
this.programPerpComposability = new anchor_1.Program(perp_composability_1.IDL, composabilityProgramId);
|
3806
|
+
this.programFbnftReward = new anchor_1.Program(fbnft_rewards_1.IDL, fbNftRewardProgramId);
|
3660
3807
|
this.programId = programId;
|
3661
3808
|
this.composabilityProgramId = composabilityProgramId;
|
3662
3809
|
this.admin = this.provider.wallet.publicKey;
|
@@ -3686,7 +3833,7 @@ var PerpetualsClient = (function () {
|
|
3686
3833
|
};
|
3687
3834
|
PerpetualsClient.prototype.getNewRatioHelper = function (amountAdd, amountRemove, custodyAccount, maxPrice, poolAumUsdMax) {
|
3688
3835
|
var newRatio = constants_1.BN_ZERO;
|
3689
|
-
var maxPriceOracle = OraclePrice_1.OraclePrice.from({ price: new anchor_1.BN(maxPrice), exponent: new anchor_1.BN(-
|
3836
|
+
var maxPriceOracle = OraclePrice_1.OraclePrice.from({ price: new anchor_1.BN(maxPrice), exponent: new anchor_1.BN(-1 * constants_1.USD_DECIMALS), confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
3690
3837
|
var tokenAumUsd = maxPriceOracle.getAssetAmountUsd(custodyAccount.assets.owned, custodyAccount.decimals);
|
3691
3838
|
if (amountAdd.gt(constants_1.BN_ZERO) && amountRemove.gt(constants_1.BN_ZERO)) {
|
3692
3839
|
throw new Error("cannot add and remove liquidity together");
|
package/dist/PoolConfig.d.ts
CHANGED
@@ -39,6 +39,7 @@ export type Token = {
|
|
39
39
|
export declare class PoolConfig {
|
40
40
|
programId: PublicKey;
|
41
41
|
perpComposibilityProgramId: PublicKey;
|
42
|
+
fbNftRewardProgramId: PublicKey;
|
42
43
|
cluster: Cluster;
|
43
44
|
poolName: string;
|
44
45
|
poolAddress: PublicKey;
|
@@ -55,7 +56,7 @@ export declare class PoolConfig {
|
|
55
56
|
tokens: Token[];
|
56
57
|
custodies: CustodyConfig[];
|
57
58
|
markets: MarketConfig[];
|
58
|
-
constructor(programId: PublicKey, perpComposibilityProgramId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, lpTokenMint: PublicKey, flpTokenAccount: PublicKey, lpDecimals: number, lpTokenSymbol: string, perpetuals: PublicKey, transferAuthority: PublicKey, multisig: PublicKey, addressLookupTableAddresses: PublicKey[], backupOracle: PublicKey, nftCollectionAddress: PublicKey, tokens: Token[], custodies: CustodyConfig[], markets: MarketConfig[]);
|
59
|
+
constructor(programId: PublicKey, perpComposibilityProgramId: PublicKey, fbNftRewardProgramId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, lpTokenMint: PublicKey, flpTokenAccount: PublicKey, lpDecimals: number, lpTokenSymbol: string, perpetuals: PublicKey, transferAuthority: PublicKey, multisig: PublicKey, addressLookupTableAddresses: PublicKey[], backupOracle: PublicKey, nftCollectionAddress: PublicKey, tokens: Token[], custodies: CustodyConfig[], markets: MarketConfig[]);
|
59
60
|
getAllTokenMints(): PublicKey[];
|
60
61
|
getMarketConfigByPk(marketAccountPk: PublicKey): MarketConfig;
|
61
62
|
getMarketConfig(targetCustody: PublicKey, collateralCustody: PublicKey, side: Side): MarketConfig | null;
|
package/dist/PoolConfig.js
CHANGED
@@ -19,10 +19,11 @@ var web3_js_1 = require("@solana/web3.js");
|
|
19
19
|
var PoolConfig_json_1 = __importDefault(require("./PoolConfig.json"));
|
20
20
|
var types_1 = require("./types");
|
21
21
|
var PoolConfig = (function () {
|
22
|
-
function PoolConfig(programId, perpComposibilityProgramId, cluster, poolName, poolAddress, lpTokenMint, flpTokenAccount, lpDecimals, lpTokenSymbol, perpetuals, transferAuthority, multisig, addressLookupTableAddresses, backupOracle, nftCollectionAddress, tokens, custodies, markets) {
|
22
|
+
function PoolConfig(programId, perpComposibilityProgramId, fbNftRewardProgramId, cluster, poolName, poolAddress, lpTokenMint, flpTokenAccount, lpDecimals, lpTokenSymbol, perpetuals, transferAuthority, multisig, addressLookupTableAddresses, backupOracle, nftCollectionAddress, tokens, custodies, markets) {
|
23
23
|
var _this = this;
|
24
24
|
this.programId = programId;
|
25
25
|
this.perpComposibilityProgramId = perpComposibilityProgramId;
|
26
|
+
this.fbNftRewardProgramId = fbNftRewardProgramId;
|
26
27
|
this.cluster = cluster;
|
27
28
|
this.poolName = poolName;
|
28
29
|
this.poolAddress = poolAddress;
|
@@ -161,7 +162,7 @@ var PoolConfig = (function () {
|
|
161
162
|
catch (error) {
|
162
163
|
console.log("ERROR: buildPoolconfigFromJson unable to load markets ");
|
163
164
|
}
|
164
|
-
return new PoolConfig(new web3_js_1.PublicKey(poolConfig.programId), new web3_js_1.PublicKey(poolConfig.perpComposibilityProgramId), poolConfig.cluster, poolConfig.poolName, new web3_js_1.PublicKey(poolConfig.poolAddress), new web3_js_1.PublicKey(poolConfig.lpTokenMint), new web3_js_1.PublicKey(poolConfig.flpTokenAccount), poolConfig.lpDecimals, poolConfig.lpTokenSymbol, new web3_js_1.PublicKey(poolConfig.perpetuals), new web3_js_1.PublicKey(poolConfig.transferAuthority), new web3_js_1.PublicKey(poolConfig.multisig), addressLookupTableAddresses, new web3_js_1.PublicKey(poolConfig.backupOracle), new web3_js_1.PublicKey(poolConfig.nftCollectionAddress), tokens, custodies, markets);
|
165
|
+
return new PoolConfig(new web3_js_1.PublicKey(poolConfig.programId), new web3_js_1.PublicKey(poolConfig.perpComposibilityProgramId), new web3_js_1.PublicKey(poolConfig.fbNftRewardProgramId), poolConfig.cluster, poolConfig.poolName, new web3_js_1.PublicKey(poolConfig.poolAddress), new web3_js_1.PublicKey(poolConfig.lpTokenMint), new web3_js_1.PublicKey(poolConfig.flpTokenAccount), poolConfig.lpDecimals, poolConfig.lpTokenSymbol, new web3_js_1.PublicKey(poolConfig.perpetuals), new web3_js_1.PublicKey(poolConfig.transferAuthority), new web3_js_1.PublicKey(poolConfig.multisig), addressLookupTableAddresses, new web3_js_1.PublicKey(poolConfig.backupOracle), new web3_js_1.PublicKey(poolConfig.nftCollectionAddress), tokens, custodies, markets);
|
165
166
|
};
|
166
167
|
PoolConfig.fromIdsByName = function (name, cluster) {
|
167
168
|
var poolConfig = PoolConfig_json_1.default.pools.find(function (pool) { return pool['poolName'] === name && cluster === pool['cluster']; });
|
package/dist/PoolConfig.json
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
{
|
10
10
|
"programId": "FLASH6Lo6h3iasJKWDs2F8TkW2UKf3s15C8PMGuVfgBn",
|
11
11
|
"perpComposibilityProgramId": "FSWAPViR8ny5K96hezav8jynVubP2dJ2L7SbKzds2hwm",
|
12
|
+
"fbNftRewardProgramId": "FB8mxzFuW99ExD1B14hFqoeWWS1UdbuK6iY2PVPpKFQi",
|
12
13
|
"cluster": "mainnet-beta",
|
13
14
|
"poolName": "Crypto.1",
|
14
15
|
"poolAddress": "HfF7GCcEc76xubFCHLLXRdYcgRzwjEPdfKWqzRS8Ncog",
|
@@ -204,6 +205,7 @@
|
|
204
205
|
{
|
205
206
|
"programId": "FLASH6Lo6h3iasJKWDs2F8TkW2UKf3s15C8PMGuVfgBn",
|
206
207
|
"perpComposibilityProgramId": "FSWAPViR8ny5K96hezav8jynVubP2dJ2L7SbKzds2hwm",
|
208
|
+
"fbNftRewardProgramId": "FB8mxzFuW99ExD1B14hFqoeWWS1UdbuK6iY2PVPpKFQi",
|
207
209
|
"cluster": "mainnet-beta",
|
208
210
|
"poolName": "Virtual.1",
|
209
211
|
"poolAddress": "KwhpybQPe9xuZFmAfcjLHj3ukownWex1ratyascAC1X",
|
@@ -482,6 +484,7 @@
|
|
482
484
|
{
|
483
485
|
"programId": "FTN6rgbaaxwT8mpRuC55EFTwpHB3BwnHJ91Lqv4ZVCfW",
|
484
486
|
"perpComposibilityProgramId": "SWAP4AE4N1if9qKD7dgfQgmRBRv1CtWG8xDs4HP14ST",
|
487
|
+
"fbNftRewardProgramId": "FB8mxzFuW99ExD1B14hFqoeWWS1UdbuK6iY2PVPpKFQi",
|
485
488
|
"cluster": "devnet",
|
486
489
|
"poolName": "devnet.1",
|
487
490
|
"poolAddress": "7jA4ZSGwaBxXk5EmPKDCSc5RtZNHxyoxy22iQt3D2mH9",
|
@@ -677,6 +680,7 @@
|
|
677
680
|
{
|
678
681
|
"programId": "FTN6rgbaaxwT8mpRuC55EFTwpHB3BwnHJ91Lqv4ZVCfW",
|
679
682
|
"perpComposibilityProgramId": "SWAP4AE4N1if9qKD7dgfQgmRBRv1CtWG8xDs4HP14ST",
|
683
|
+
"fbNftRewardProgramId": "FB8mxzFuW99ExD1B14hFqoeWWS1UdbuK6iY2PVPpKFQi",
|
680
684
|
"cluster": "devnet",
|
681
685
|
"poolName": "devnet.2",
|
682
686
|
"poolAddress": "5MCtcNsF3dxna8ArzMamyciWDV3TBkiAzY1NqLtNiXvw",
|
@@ -0,0 +1,285 @@
|
|
1
|
+
export type FbnftRewards = {
|
2
|
+
"version": "0.1.0";
|
3
|
+
"name": "fbnft_rewards";
|
4
|
+
"instructions": [
|
5
|
+
{
|
6
|
+
"name": "initRewardVault";
|
7
|
+
"accounts": [
|
8
|
+
{
|
9
|
+
"name": "admin";
|
10
|
+
"isMut": true;
|
11
|
+
"isSigner": true;
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"name": "transferAuthority";
|
15
|
+
"isMut": true;
|
16
|
+
"isSigner": false;
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"name": "rewardVault";
|
20
|
+
"isMut": true;
|
21
|
+
"isSigner": false;
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "rewardMint";
|
25
|
+
"isMut": false;
|
26
|
+
"isSigner": false;
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"name": "rewardTokenAccount";
|
30
|
+
"isMut": true;
|
31
|
+
"isSigner": false;
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"name": "collectionMint";
|
35
|
+
"isMut": false;
|
36
|
+
"isSigner": false;
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "programData";
|
40
|
+
"isMut": false;
|
41
|
+
"isSigner": false;
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"name": "systemProgram";
|
45
|
+
"isMut": false;
|
46
|
+
"isSigner": false;
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "tokenProgram";
|
50
|
+
"isMut": false;
|
51
|
+
"isSigner": false;
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"name": "rent";
|
55
|
+
"isMut": false;
|
56
|
+
"isSigner": false;
|
57
|
+
}
|
58
|
+
];
|
59
|
+
"args": [
|
60
|
+
{
|
61
|
+
"name": "params";
|
62
|
+
"type": {
|
63
|
+
"defined": "InitRewardVaultParams";
|
64
|
+
};
|
65
|
+
}
|
66
|
+
];
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"name": "distributeRewards";
|
70
|
+
"accounts": [
|
71
|
+
{
|
72
|
+
"name": "admin";
|
73
|
+
"isMut": false;
|
74
|
+
"isSigner": true;
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"name": "fundingAccount";
|
78
|
+
"isMut": true;
|
79
|
+
"isSigner": false;
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"name": "rewardVault";
|
83
|
+
"isMut": true;
|
84
|
+
"isSigner": false;
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"name": "rewardTokenAccount";
|
88
|
+
"isMut": true;
|
89
|
+
"isSigner": false;
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"name": "tokenProgram";
|
93
|
+
"isMut": false;
|
94
|
+
"isSigner": false;
|
95
|
+
}
|
96
|
+
];
|
97
|
+
"args": [
|
98
|
+
{
|
99
|
+
"name": "params";
|
100
|
+
"type": {
|
101
|
+
"defined": "DistributeRewardsParams";
|
102
|
+
};
|
103
|
+
}
|
104
|
+
];
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"name": "collectReward";
|
108
|
+
"accounts": [
|
109
|
+
{
|
110
|
+
"name": "owner";
|
111
|
+
"isMut": true;
|
112
|
+
"isSigner": true;
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"name": "feePayer";
|
116
|
+
"isMut": true;
|
117
|
+
"isSigner": true;
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "nftMint";
|
121
|
+
"isMut": true;
|
122
|
+
"isSigner": false;
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"name": "nftTokenAccount";
|
126
|
+
"isMut": false;
|
127
|
+
"isSigner": false;
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"name": "metadataAccount";
|
131
|
+
"isMut": true;
|
132
|
+
"isSigner": false;
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "receivingAccount";
|
136
|
+
"isMut": true;
|
137
|
+
"isSigner": false;
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "rewardRecord";
|
141
|
+
"isMut": true;
|
142
|
+
"isSigner": false;
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"name": "rewardVault";
|
146
|
+
"isMut": true;
|
147
|
+
"isSigner": false;
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"name": "rewardTokenAccount";
|
151
|
+
"isMut": true;
|
152
|
+
"isSigner": false;
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"name": "transferAuthority";
|
156
|
+
"isMut": false;
|
157
|
+
"isSigner": false;
|
158
|
+
},
|
159
|
+
{
|
160
|
+
"name": "systemProgram";
|
161
|
+
"isMut": false;
|
162
|
+
"isSigner": false;
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"name": "tokenProgram";
|
166
|
+
"isMut": false;
|
167
|
+
"isSigner": false;
|
168
|
+
}
|
169
|
+
];
|
170
|
+
"args": [];
|
171
|
+
}
|
172
|
+
];
|
173
|
+
"accounts": [
|
174
|
+
{
|
175
|
+
"name": "rewardVault";
|
176
|
+
"type": {
|
177
|
+
"kind": "struct";
|
178
|
+
"fields": [
|
179
|
+
{
|
180
|
+
"name": "admin";
|
181
|
+
"type": "publicKey";
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"name": "collection";
|
185
|
+
"type": "publicKey";
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"name": "rewardMint";
|
189
|
+
"type": "publicKey";
|
190
|
+
},
|
191
|
+
{
|
192
|
+
"name": "transferAuthority";
|
193
|
+
"type": "publicKey";
|
194
|
+
},
|
195
|
+
{
|
196
|
+
"name": "rewardTokenAccount";
|
197
|
+
"type": "publicKey";
|
198
|
+
},
|
199
|
+
{
|
200
|
+
"name": "lpTokenAccount";
|
201
|
+
"type": "publicKey";
|
202
|
+
},
|
203
|
+
{
|
204
|
+
"name": "nftCount";
|
205
|
+
"type": "u64";
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"name": "accruedAmount";
|
209
|
+
"type": "u128";
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"name": "paidAmount";
|
213
|
+
"type": "u128";
|
214
|
+
},
|
215
|
+
{
|
216
|
+
"name": "rewardsPerNft";
|
217
|
+
"type": "u64";
|
218
|
+
},
|
219
|
+
{
|
220
|
+
"name": "bump";
|
221
|
+
"type": "u8";
|
222
|
+
},
|
223
|
+
{
|
224
|
+
"name": "transferAuthorityBump";
|
225
|
+
"type": "u8";
|
226
|
+
},
|
227
|
+
{
|
228
|
+
"name": "tokenAccountBump";
|
229
|
+
"type": "u8";
|
230
|
+
}
|
231
|
+
];
|
232
|
+
};
|
233
|
+
},
|
234
|
+
{
|
235
|
+
"name": "rewardRecord";
|
236
|
+
"type": {
|
237
|
+
"kind": "struct";
|
238
|
+
"fields": [
|
239
|
+
{
|
240
|
+
"name": "mint";
|
241
|
+
"type": "publicKey";
|
242
|
+
},
|
243
|
+
{
|
244
|
+
"name": "rewardDebt";
|
245
|
+
"type": "u64";
|
246
|
+
}
|
247
|
+
];
|
248
|
+
};
|
249
|
+
}
|
250
|
+
];
|
251
|
+
"types": [
|
252
|
+
{
|
253
|
+
"name": "InitRewardVaultParams";
|
254
|
+
"type": {
|
255
|
+
"kind": "struct";
|
256
|
+
"fields": [
|
257
|
+
{
|
258
|
+
"name": "nftCount";
|
259
|
+
"type": "u64";
|
260
|
+
}
|
261
|
+
];
|
262
|
+
};
|
263
|
+
},
|
264
|
+
{
|
265
|
+
"name": "DistributeRewardsParams";
|
266
|
+
"type": {
|
267
|
+
"kind": "struct";
|
268
|
+
"fields": [
|
269
|
+
{
|
270
|
+
"name": "rewardAmount";
|
271
|
+
"type": "u64";
|
272
|
+
}
|
273
|
+
];
|
274
|
+
};
|
275
|
+
}
|
276
|
+
];
|
277
|
+
"errors": [
|
278
|
+
{
|
279
|
+
"code": 6000;
|
280
|
+
"name": "InvalidCollection";
|
281
|
+
"msg": "Unsuppported NFT collection";
|
282
|
+
}
|
283
|
+
];
|
284
|
+
};
|
285
|
+
export declare const IDL: FbnftRewards;
|