@metadaoproject/futarchy 0.6.0-alpha.2 → 0.6.0-alpha.20
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/v0.5/SharedLiquidityManagerClient.js.map +1 -1
- package/dist/v0.6/FutarchyClient.d.ts +249 -9
- package/dist/v0.6/FutarchyClient.js +96 -69
- package/dist/v0.6/FutarchyClient.js.map +1 -1
- package/dist/v0.6/LaunchpadClient.d.ts +168 -19
- package/dist/v0.6/LaunchpadClient.js +118 -50
- package/dist/v0.6/LaunchpadClient.js.map +1 -1
- package/dist/v0.6/PriceBasedPerformancePackageClient.d.ts +353 -0
- package/dist/v0.6/PriceBasedPerformancePackageClient.js +116 -0
- package/dist/v0.6/PriceBasedPerformancePackageClient.js.map +1 -0
- package/dist/v0.6/constants.d.ts +5 -1
- package/dist/v0.6/constants.js +6 -2
- package/dist/v0.6/constants.js.map +1 -1
- package/dist/v0.6/index.d.ts +1 -0
- package/dist/v0.6/index.js +1 -0
- package/dist/v0.6/index.js.map +1 -1
- package/dist/v0.6/types/futarchy.d.ts +754 -69
- package/dist/v0.6/types/futarchy.js +752 -67
- package/dist/v0.6/types/futarchy.js.map +1 -1
- package/dist/v0.6/types/index.d.ts +51 -6
- package/dist/v0.6/types/index.js +8 -2
- package/dist/v0.6/types/index.js.map +1 -1
- package/dist/v0.6/types/launchpad.d.ts +328 -26
- package/dist/v0.6/types/launchpad.js +328 -26
- package/dist/v0.6/types/launchpad.js.map +1 -1
- package/dist/v0.6/types/price_based_performance_package.d.ts +896 -0
- package/dist/v0.6/types/price_based_performance_package.js +896 -0
- package/dist/v0.6/types/price_based_performance_package.js.map +1 -0
- package/dist/v0.6/types/v0.6.0-futarchy.d.ts +2567 -0
- package/dist/v0.6/types/v0.6.0-futarchy.js +2567 -0
- package/dist/v0.6/types/v0.6.0-futarchy.js.map +1 -0
- package/dist/v0.6/types/v0.6.0-launchpad.d.ts +1277 -0
- package/dist/v0.6/types/v0.6.0-launchpad.js +1277 -0
- package/dist/v0.6/types/v0.6.0-launchpad.js.map +1 -0
- package/dist/v0.6/utils/pda.d.ts +18 -0
- package/dist/v0.6/utils/pda.js +23 -3
- package/dist/v0.6/utils/pda.js.map +1 -1
- package/package.json +25 -2
- package/dist/v0.6/types/shared_liquidity_manager.d.ts +0 -89
- package/dist/v0.6/types/shared_liquidity_manager.js +0 -89
- package/dist/v0.6/types/shared_liquidity_manager.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedLiquidityManagerClient.js","sourceRoot":"","sources":["../../src/v0.5/SharedLiquidityManagerClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"SharedLiquidityManagerClient.js","sourceRoot":"","sources":["../../src/v0.5/SharedLiquidityManagerClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAiBtE,OAAO,EAEL,GAAG,IAAI,yBAAyB,GACjC,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EACL,mCAAmC,EACnC,0BAA0B,EAC1B,iBAAiB,EAIjB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AAexB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,gBAAgB,EAAE,iBAAiB;IACnC,SAAS,EAAE,sBAAsB;IACjC,aAAa,EAAE,0BAA0B;IACzC,aAAa,EAAE,+BAA+B;CAC/C,CAAC;AAEF,MAAM,OAAO,4BAA4B;IACvB,QAAQ,CAAiB;IACzB,OAAO,CAAyC;IACzD,cAAc,CAAiB;IAEtC,YAAY,MAAgD;QAC1D,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CACxB,yBAAyB,EACzB,MAAM,CAAC,+BAA+B;YACpC,mCAAmC,EACrC,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC,YAAY,CAAC;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,yBAAyB,EAAE,MAAM,CAAC,yBAAyB;YAC3D,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,YAAY,CACxB,MAAgD;QAEhD,OAAO,IAAI,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAChC,CAAC;CA6vBF"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AnchorProvider, Program } from "@coral-xyz/anchor";
|
|
2
|
-
import { AccountInfo, AddressLookupTableAccount, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { AccountInfo, AddressLookupTableAccount, PublicKey, Transaction, TransactionInstruction } from "@solana/web3.js";
|
|
3
3
|
import { InitializeDaoParams, UpdateDaoParams } from "./types/index.js";
|
|
4
4
|
import { Futarchy } from "./types/futarchy.js";
|
|
5
|
+
import { Futarchy as v0_6_0_futarchy } from "./types/v0.6.0-futarchy.js";
|
|
5
6
|
import BN from "bn.js";
|
|
6
7
|
import { ConditionalVaultClient } from "./ConditionalVaultClient.js";
|
|
7
8
|
import { Dao, Proposal } from "./types/index.js";
|
|
8
9
|
export type CreateClientParams = {
|
|
9
10
|
provider: AnchorProvider;
|
|
10
|
-
|
|
11
|
+
futarchyProgramId?: PublicKey;
|
|
11
12
|
conditionalVaultProgramId?: PublicKey;
|
|
12
13
|
};
|
|
13
14
|
export type ProposalVaults = {
|
|
@@ -16,11 +17,12 @@ export type ProposalVaults = {
|
|
|
16
17
|
};
|
|
17
18
|
export declare class FutarchyClient {
|
|
18
19
|
readonly provider: AnchorProvider;
|
|
19
|
-
readonly
|
|
20
|
+
readonly futarchy: Program<Futarchy>;
|
|
21
|
+
readonly v0_6_0_futarchy: Program<v0_6_0_futarchy>;
|
|
20
22
|
readonly vaultClient: ConditionalVaultClient;
|
|
21
23
|
readonly luts: AddressLookupTableAccount[];
|
|
22
|
-
constructor(provider: AnchorProvider,
|
|
23
|
-
static createClient(
|
|
24
|
+
constructor(provider: AnchorProvider, futarchyProgramId: PublicKey, conditionalVaultProgramId: PublicKey, luts: AddressLookupTableAccount[]);
|
|
25
|
+
static createClient(params: CreateClientParams): FutarchyClient;
|
|
24
26
|
getProgramId(): PublicKey;
|
|
25
27
|
getProposal(proposal: PublicKey): Promise<Proposal>;
|
|
26
28
|
getDao(dao: PublicKey): Promise<Dao>;
|
|
@@ -214,7 +216,7 @@ export declare class FutarchyClient {
|
|
|
214
216
|
spotSwapIx({ dao, baseMint, quoteMint, swapType, inputAmount, minOutputAmount, trader, }: {
|
|
215
217
|
dao: PublicKey;
|
|
216
218
|
baseMint: PublicKey;
|
|
217
|
-
quoteMint
|
|
219
|
+
quoteMint?: PublicKey;
|
|
218
220
|
swapType: "buy" | "sell";
|
|
219
221
|
inputAmount: BN;
|
|
220
222
|
minOutputAmount?: BN;
|
|
@@ -318,6 +320,14 @@ export declare class FutarchyClient {
|
|
|
318
320
|
name: "tokenProgram";
|
|
319
321
|
isMut: false;
|
|
320
322
|
isSigner: false;
|
|
323
|
+
}, {
|
|
324
|
+
name: "eventAuthority";
|
|
325
|
+
isMut: false;
|
|
326
|
+
isSigner: false;
|
|
327
|
+
}, {
|
|
328
|
+
name: "program";
|
|
329
|
+
isMut: false;
|
|
330
|
+
isSigner: false;
|
|
321
331
|
}];
|
|
322
332
|
args: [{
|
|
323
333
|
name: "params";
|
|
@@ -328,16 +338,17 @@ export declare class FutarchyClient {
|
|
|
328
338
|
} & {
|
|
329
339
|
name: "provideLiquidity";
|
|
330
340
|
}>;
|
|
331
|
-
conditionalSwapIx({ dao, trader, payer, baseMint, quoteMint, proposal, market, swapType, inputAmount, }: {
|
|
341
|
+
conditionalSwapIx({ dao, trader, payer, baseMint, quoteMint, proposal, market, swapType, inputAmount, minOutputAmount, }: {
|
|
332
342
|
dao: PublicKey;
|
|
333
343
|
trader?: PublicKey;
|
|
334
344
|
payer?: PublicKey;
|
|
335
345
|
baseMint: PublicKey;
|
|
336
|
-
quoteMint
|
|
346
|
+
quoteMint?: PublicKey;
|
|
337
347
|
proposal: PublicKey;
|
|
338
348
|
market: "pass" | "fail";
|
|
339
349
|
swapType: "buy" | "sell";
|
|
340
350
|
inputAmount: BN;
|
|
351
|
+
minOutputAmount: BN;
|
|
341
352
|
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<Futarchy, {
|
|
342
353
|
name: "conditionalSwap";
|
|
343
354
|
accounts: [{
|
|
@@ -432,6 +443,14 @@ export declare class FutarchyClient {
|
|
|
432
443
|
name: "tokenProgram";
|
|
433
444
|
isMut: false;
|
|
434
445
|
isSigner: false;
|
|
446
|
+
}, {
|
|
447
|
+
name: "eventAuthority";
|
|
448
|
+
isMut: false;
|
|
449
|
+
isSigner: false;
|
|
450
|
+
}, {
|
|
451
|
+
name: "program";
|
|
452
|
+
isMut: false;
|
|
453
|
+
isSigner: false;
|
|
435
454
|
}];
|
|
436
455
|
args: [{
|
|
437
456
|
name: "params";
|
|
@@ -442,6 +461,15 @@ export declare class FutarchyClient {
|
|
|
442
461
|
} & {
|
|
443
462
|
name: "conditionalSwap";
|
|
444
463
|
}>;
|
|
464
|
+
squadsProposalCreateTx({ dao, instructions, transactionIndex, payer, }: {
|
|
465
|
+
dao: PublicKey;
|
|
466
|
+
instructions: TransactionInstruction[];
|
|
467
|
+
transactionIndex: bigint;
|
|
468
|
+
payer?: PublicKey;
|
|
469
|
+
}): {
|
|
470
|
+
tx: Transaction;
|
|
471
|
+
squadsProposal: PublicKey;
|
|
472
|
+
};
|
|
445
473
|
initializeProposal(dao: PublicKey, squadsProposal: PublicKey): Promise<PublicKey>;
|
|
446
474
|
initializeProposalIx(squadsProposal: PublicKey, dao: PublicKey, baseMint: PublicKey, quoteMint: PublicKey, question: PublicKey, proposer?: PublicKey): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<Futarchy, {
|
|
447
475
|
name: "initializeProposal";
|
|
@@ -495,7 +523,122 @@ export declare class FutarchyClient {
|
|
|
495
523
|
name: "initializeProposal";
|
|
496
524
|
}>;
|
|
497
525
|
finalizeProposal(proposal: PublicKey): Promise<string>;
|
|
498
|
-
|
|
526
|
+
finalizeProposalIxV2({ squadsProposal, dao, baseMint, quoteMint, }: {
|
|
527
|
+
squadsProposal: PublicKey;
|
|
528
|
+
dao: PublicKey;
|
|
529
|
+
baseMint: PublicKey;
|
|
530
|
+
quoteMint?: PublicKey;
|
|
531
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<Futarchy, {
|
|
532
|
+
name: "finalizeProposal";
|
|
533
|
+
accounts: [{
|
|
534
|
+
name: "proposal";
|
|
535
|
+
isMut: true;
|
|
536
|
+
isSigner: false;
|
|
537
|
+
}, {
|
|
538
|
+
name: "dao";
|
|
539
|
+
isMut: true;
|
|
540
|
+
isSigner: false;
|
|
541
|
+
}, {
|
|
542
|
+
name: "question";
|
|
543
|
+
isMut: true;
|
|
544
|
+
isSigner: false;
|
|
545
|
+
}, {
|
|
546
|
+
name: "squadsProposal";
|
|
547
|
+
isMut: true;
|
|
548
|
+
isSigner: false;
|
|
549
|
+
}, {
|
|
550
|
+
name: "squadsMultisig";
|
|
551
|
+
isMut: false;
|
|
552
|
+
isSigner: false;
|
|
553
|
+
}, {
|
|
554
|
+
name: "squadsMultisigProgram";
|
|
555
|
+
isMut: false;
|
|
556
|
+
isSigner: false;
|
|
557
|
+
}, {
|
|
558
|
+
name: "ammPassBaseVault";
|
|
559
|
+
isMut: true;
|
|
560
|
+
isSigner: false;
|
|
561
|
+
}, {
|
|
562
|
+
name: "ammPassQuoteVault";
|
|
563
|
+
isMut: true;
|
|
564
|
+
isSigner: false;
|
|
565
|
+
}, {
|
|
566
|
+
name: "ammFailBaseVault";
|
|
567
|
+
isMut: true;
|
|
568
|
+
isSigner: false;
|
|
569
|
+
}, {
|
|
570
|
+
name: "ammFailQuoteVault";
|
|
571
|
+
isMut: true;
|
|
572
|
+
isSigner: false;
|
|
573
|
+
}, {
|
|
574
|
+
name: "ammBaseVault";
|
|
575
|
+
isMut: true;
|
|
576
|
+
isSigner: false;
|
|
577
|
+
}, {
|
|
578
|
+
name: "ammQuoteVault";
|
|
579
|
+
isMut: true;
|
|
580
|
+
isSigner: false;
|
|
581
|
+
}, {
|
|
582
|
+
name: "vaultProgram";
|
|
583
|
+
isMut: false;
|
|
584
|
+
isSigner: false;
|
|
585
|
+
}, {
|
|
586
|
+
name: "vaultEventAuthority";
|
|
587
|
+
isMut: false;
|
|
588
|
+
isSigner: false;
|
|
589
|
+
}, {
|
|
590
|
+
name: "tokenProgram";
|
|
591
|
+
isMut: false;
|
|
592
|
+
isSigner: false;
|
|
593
|
+
}, {
|
|
594
|
+
name: "quoteVault";
|
|
595
|
+
isMut: true;
|
|
596
|
+
isSigner: false;
|
|
597
|
+
}, {
|
|
598
|
+
name: "quoteVaultUnderlyingTokenAccount";
|
|
599
|
+
isMut: true;
|
|
600
|
+
isSigner: false;
|
|
601
|
+
}, {
|
|
602
|
+
name: "passQuoteMint";
|
|
603
|
+
isMut: true;
|
|
604
|
+
isSigner: false;
|
|
605
|
+
}, {
|
|
606
|
+
name: "failQuoteMint";
|
|
607
|
+
isMut: true;
|
|
608
|
+
isSigner: false;
|
|
609
|
+
}, {
|
|
610
|
+
name: "passBaseMint";
|
|
611
|
+
isMut: true;
|
|
612
|
+
isSigner: false;
|
|
613
|
+
}, {
|
|
614
|
+
name: "failBaseMint";
|
|
615
|
+
isMut: true;
|
|
616
|
+
isSigner: false;
|
|
617
|
+
}, {
|
|
618
|
+
name: "baseVault";
|
|
619
|
+
isMut: true;
|
|
620
|
+
isSigner: false;
|
|
621
|
+
}, {
|
|
622
|
+
name: "baseVaultUnderlyingTokenAccount";
|
|
623
|
+
isMut: true;
|
|
624
|
+
isSigner: false;
|
|
625
|
+
}, {
|
|
626
|
+
name: "eventAuthority";
|
|
627
|
+
isMut: false;
|
|
628
|
+
isSigner: false;
|
|
629
|
+
}, {
|
|
630
|
+
name: "program";
|
|
631
|
+
isMut: false;
|
|
632
|
+
isSigner: false;
|
|
633
|
+
}];
|
|
634
|
+
args: [];
|
|
635
|
+
} & {
|
|
636
|
+
name: "finalizeProposal";
|
|
637
|
+
}>;
|
|
638
|
+
/**
|
|
639
|
+
* @deprecated use `finalizeProposalIxV2` instead
|
|
640
|
+
*/
|
|
641
|
+
finalizeProposalIx(proposal: PublicKey, squadsProposal: PublicKey, dao: PublicKey, daoToken: PublicKey, usdc: PublicKey): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<Futarchy, {
|
|
499
642
|
name: "finalizeProposal";
|
|
500
643
|
accounts: [{
|
|
501
644
|
name: "proposal";
|
|
@@ -700,6 +843,64 @@ export declare class FutarchyClient {
|
|
|
700
843
|
} & {
|
|
701
844
|
name: "stakeToProposal";
|
|
702
845
|
}>;
|
|
846
|
+
unstakeFromProposalIx({ proposal, dao, baseMint, amount, staker, }: {
|
|
847
|
+
proposal: PublicKey;
|
|
848
|
+
dao: PublicKey;
|
|
849
|
+
baseMint: PublicKey;
|
|
850
|
+
amount: BN;
|
|
851
|
+
staker?: PublicKey;
|
|
852
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<Futarchy, {
|
|
853
|
+
name: "unstakeFromProposal";
|
|
854
|
+
accounts: [{
|
|
855
|
+
name: "proposal";
|
|
856
|
+
isMut: true;
|
|
857
|
+
isSigner: false;
|
|
858
|
+
}, {
|
|
859
|
+
name: "dao";
|
|
860
|
+
isMut: true;
|
|
861
|
+
isSigner: false;
|
|
862
|
+
}, {
|
|
863
|
+
name: "stakerBaseAccount";
|
|
864
|
+
isMut: true;
|
|
865
|
+
isSigner: false;
|
|
866
|
+
}, {
|
|
867
|
+
name: "proposalBaseAccount";
|
|
868
|
+
isMut: true;
|
|
869
|
+
isSigner: false;
|
|
870
|
+
}, {
|
|
871
|
+
name: "stakeAccount";
|
|
872
|
+
isMut: true;
|
|
873
|
+
isSigner: false;
|
|
874
|
+
}, {
|
|
875
|
+
name: "staker";
|
|
876
|
+
isMut: false;
|
|
877
|
+
isSigner: true;
|
|
878
|
+
}, {
|
|
879
|
+
name: "tokenProgram";
|
|
880
|
+
isMut: false;
|
|
881
|
+
isSigner: false;
|
|
882
|
+
}, {
|
|
883
|
+
name: "associatedTokenProgram";
|
|
884
|
+
isMut: false;
|
|
885
|
+
isSigner: false;
|
|
886
|
+
}, {
|
|
887
|
+
name: "eventAuthority";
|
|
888
|
+
isMut: false;
|
|
889
|
+
isSigner: false;
|
|
890
|
+
}, {
|
|
891
|
+
name: "program";
|
|
892
|
+
isMut: false;
|
|
893
|
+
isSigner: false;
|
|
894
|
+
}];
|
|
895
|
+
args: [{
|
|
896
|
+
name: "params";
|
|
897
|
+
type: {
|
|
898
|
+
defined: "UnstakeFromProposalParams";
|
|
899
|
+
};
|
|
900
|
+
}];
|
|
901
|
+
} & {
|
|
902
|
+
name: "unstakeFromProposal";
|
|
903
|
+
}>;
|
|
703
904
|
collectFeesIx({ dao, baseMint, quoteMint, baseTokenAccount, quoteTokenAccount, }: {
|
|
704
905
|
dao: PublicKey;
|
|
705
906
|
baseMint: PublicKey;
|
|
@@ -736,9 +937,48 @@ export declare class FutarchyClient {
|
|
|
736
937
|
name: "tokenProgram";
|
|
737
938
|
isMut: false;
|
|
738
939
|
isSigner: false;
|
|
940
|
+
}, {
|
|
941
|
+
name: "eventAuthority";
|
|
942
|
+
isMut: false;
|
|
943
|
+
isSigner: false;
|
|
944
|
+
}, {
|
|
945
|
+
name: "program";
|
|
946
|
+
isMut: false;
|
|
947
|
+
isSigner: false;
|
|
739
948
|
}];
|
|
740
949
|
args: [];
|
|
741
950
|
} & {
|
|
742
951
|
name: "collectFees";
|
|
743
952
|
}>;
|
|
953
|
+
sponsorProposalIx({ proposal, dao, teamAddress, }: {
|
|
954
|
+
proposal: PublicKey;
|
|
955
|
+
dao: PublicKey;
|
|
956
|
+
teamAddress?: PublicKey;
|
|
957
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<Futarchy, {
|
|
958
|
+
name: "sponsorProposal";
|
|
959
|
+
accounts: [{
|
|
960
|
+
name: "proposal";
|
|
961
|
+
isMut: true;
|
|
962
|
+
isSigner: false;
|
|
963
|
+
}, {
|
|
964
|
+
name: "dao";
|
|
965
|
+
isMut: true;
|
|
966
|
+
isSigner: false;
|
|
967
|
+
}, {
|
|
968
|
+
name: "teamAddress";
|
|
969
|
+
isMut: false;
|
|
970
|
+
isSigner: true;
|
|
971
|
+
}, {
|
|
972
|
+
name: "eventAuthority";
|
|
973
|
+
isMut: false;
|
|
974
|
+
isSigner: false;
|
|
975
|
+
}, {
|
|
976
|
+
name: "program";
|
|
977
|
+
isMut: false;
|
|
978
|
+
isSigner: false;
|
|
979
|
+
}];
|
|
980
|
+
args: [];
|
|
981
|
+
} & {
|
|
982
|
+
name: "sponsorProposal";
|
|
983
|
+
}>;
|
|
744
984
|
}
|
|
@@ -1,53 +1,59 @@
|
|
|
1
1
|
import { Program } from "@coral-xyz/anchor";
|
|
2
|
-
import { ComputeBudgetProgram, PublicKey, SystemProgram, } from "@solana/web3.js";
|
|
2
|
+
import { ComputeBudgetProgram, PublicKey, SystemProgram, Transaction, } from "@solana/web3.js";
|
|
3
3
|
// import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js";
|
|
4
4
|
import { IDL as FutarchyIDL } from "./types/futarchy.js";
|
|
5
|
+
import { IDL as v0_6_0_futarchyIDL, } from "./types/v0.6.0-futarchy.js";
|
|
5
6
|
import BN from "bn.js";
|
|
6
|
-
import {
|
|
7
|
-
import { InstructionUtils, getConditionalTokenMintAddr, getDaoAddr, getEventAuthorityAddr, getProposalAddr, getQuestionAddr, getVaultAddr, } from "./utils/index.js";
|
|
7
|
+
import { FUTARCHY_PROGRAM_ID, CONDITIONAL_VAULT_PROGRAM_ID, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, SQUADS_PROGRAM_CONFIG, SQUADS_PROGRAM_CONFIG_TREASURY, SQUADS_PROGRAM_ID, } from "./constants.js";
|
|
8
|
+
import { InstructionUtils, getConditionalTokenMintAddr, getDaoAddr, getEventAuthorityAddr, getProposalAddr, getProposalAddrV2, getQuestionAddr, getVaultAddr, } from "./utils/index.js";
|
|
8
9
|
import { ConditionalVaultClient } from "./ConditionalVaultClient.js";
|
|
9
10
|
import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, } from "@solana/spl-token";
|
|
10
11
|
import { sha256 } from "@noble/hashes/sha256";
|
|
11
12
|
import * as multisig from "@sqds/multisig";
|
|
13
|
+
import { TransactionMessage } from "@solana/web3.js";
|
|
14
|
+
import { getStakeAddr } from "./utils/index.js";
|
|
12
15
|
export class FutarchyClient {
|
|
13
16
|
provider;
|
|
14
|
-
|
|
17
|
+
futarchy;
|
|
18
|
+
// useful for parsing old events
|
|
19
|
+
v0_6_0_futarchy;
|
|
15
20
|
vaultClient;
|
|
16
21
|
luts;
|
|
17
|
-
constructor(provider,
|
|
22
|
+
constructor(provider, futarchyProgramId, conditionalVaultProgramId, luts) {
|
|
18
23
|
this.provider = provider;
|
|
19
|
-
this.
|
|
24
|
+
this.futarchy = new Program(FutarchyIDL, futarchyProgramId, provider);
|
|
25
|
+
this.v0_6_0_futarchy = new Program(v0_6_0_futarchyIDL, futarchyProgramId, provider);
|
|
20
26
|
this.vaultClient = ConditionalVaultClient.createClient({
|
|
21
27
|
provider,
|
|
22
28
|
conditionalVaultProgramId,
|
|
23
29
|
});
|
|
24
30
|
this.luts = luts;
|
|
25
31
|
}
|
|
26
|
-
static createClient(
|
|
27
|
-
let { provider, autocratProgramId, conditionalVaultProgramId } =
|
|
32
|
+
static createClient(params) {
|
|
33
|
+
let { provider, futarchyProgramId: autocratProgramId, conditionalVaultProgramId, } = params;
|
|
28
34
|
const luts = [];
|
|
29
|
-
return new FutarchyClient(provider, autocratProgramId ||
|
|
35
|
+
return new FutarchyClient(provider, autocratProgramId || FUTARCHY_PROGRAM_ID, conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, luts);
|
|
30
36
|
}
|
|
31
37
|
getProgramId() {
|
|
32
|
-
return this.
|
|
38
|
+
return this.futarchy.programId;
|
|
33
39
|
}
|
|
34
40
|
async getProposal(proposal) {
|
|
35
|
-
return this.
|
|
41
|
+
return this.futarchy.account.proposal.fetch(proposal);
|
|
36
42
|
}
|
|
37
43
|
async getDao(dao) {
|
|
38
|
-
return this.
|
|
44
|
+
return this.futarchy.account.dao.fetch(dao);
|
|
39
45
|
}
|
|
40
46
|
async fetchProposal(proposal) {
|
|
41
|
-
return this.
|
|
47
|
+
return this.futarchy.account.proposal.fetchNullable(proposal);
|
|
42
48
|
}
|
|
43
49
|
async fetchDao(dao) {
|
|
44
|
-
return this.
|
|
50
|
+
return this.futarchy.account.dao.fetchNullable(dao);
|
|
45
51
|
}
|
|
46
52
|
async deserializeProposal(accountInfo) {
|
|
47
|
-
return this.
|
|
53
|
+
return this.futarchy.coder.accounts.decode("proposal", accountInfo.data);
|
|
48
54
|
}
|
|
49
55
|
async deserializeDao(accountInfo) {
|
|
50
|
-
return this.
|
|
56
|
+
return this.futarchy.coder.accounts.decode("dao", accountInfo.data);
|
|
51
57
|
}
|
|
52
58
|
getProposalPdas(proposal, baseMint, quoteMint, dao) {
|
|
53
59
|
let vaultProgramId = this.vaultClient.vaultProgram.programId;
|
|
@@ -88,7 +94,7 @@ export class FutarchyClient {
|
|
|
88
94
|
multisigPda,
|
|
89
95
|
createKey: dao,
|
|
90
96
|
})[0];
|
|
91
|
-
return this.
|
|
97
|
+
return this.futarchy.methods.initializeDao(params).accounts({
|
|
92
98
|
dao,
|
|
93
99
|
baseMint,
|
|
94
100
|
quoteMint,
|
|
@@ -104,7 +110,7 @@ export class FutarchyClient {
|
|
|
104
110
|
}
|
|
105
111
|
launchProposalIx({ proposal, dao, baseMint, quoteMint, }) {
|
|
106
112
|
const { baseVault, quoteVault, passBaseMint, passQuoteMint, failBaseMint, failQuoteMint, } = this.getProposalPdas(proposal, baseMint, quoteMint, dao);
|
|
107
|
-
return this.
|
|
113
|
+
return this.futarchy.methods
|
|
108
114
|
.launchProposal()
|
|
109
115
|
.accounts({
|
|
110
116
|
proposal,
|
|
@@ -125,8 +131,8 @@ export class FutarchyClient {
|
|
|
125
131
|
ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }),
|
|
126
132
|
]);
|
|
127
133
|
}
|
|
128
|
-
spotSwapIx({ dao, baseMint, quoteMint, swapType, inputAmount, minOutputAmount = new BN(0), trader = this.provider.publicKey, }) {
|
|
129
|
-
return this.
|
|
134
|
+
spotSwapIx({ dao, baseMint, quoteMint = MAINNET_USDC, swapType, inputAmount, minOutputAmount = new BN(0), trader = this.provider.publicKey, }) {
|
|
135
|
+
return this.futarchy.methods
|
|
130
136
|
.spotSwap({
|
|
131
137
|
swapType: swapType === "buy" ? { buy: {} } : { sell: {} },
|
|
132
138
|
inputAmount,
|
|
@@ -146,13 +152,12 @@ export class FutarchyClient {
|
|
|
146
152
|
]);
|
|
147
153
|
}
|
|
148
154
|
provideLiquidityIx({ dao, baseMint, quoteMint, quoteAmount, maxBaseAmount, minLiquidity = new BN(0), positionAuthority = this.provider.publicKey, liquidityProvider = this.provider.publicKey, }) {
|
|
149
|
-
console.log(positionAuthority);
|
|
150
155
|
const ammPosition = PublicKey.findProgramAddressSync([
|
|
151
156
|
Buffer.from("amm_position"),
|
|
152
157
|
dao.toBuffer(),
|
|
153
158
|
positionAuthority.toBuffer(),
|
|
154
159
|
], this.getProgramId())[0];
|
|
155
|
-
return this.
|
|
160
|
+
return this.futarchy.methods
|
|
156
161
|
.provideLiquidity({
|
|
157
162
|
quoteAmount,
|
|
158
163
|
maxBaseAmount,
|
|
@@ -175,7 +180,7 @@ export class FutarchyClient {
|
|
|
175
180
|
createAssociatedTokenAccountIdempotentInstruction(this.provider.publicKey, getAssociatedTokenAddressSync(quoteMint, liquidityProvider, true), liquidityProvider, quoteMint),
|
|
176
181
|
]);
|
|
177
182
|
}
|
|
178
|
-
conditionalSwapIx({ dao, trader = this.provider.publicKey, payer = this.provider.publicKey, baseMint, quoteMint, proposal, market, swapType, inputAmount, }) {
|
|
183
|
+
conditionalSwapIx({ dao, trader = this.provider.publicKey, payer = this.provider.publicKey, baseMint, quoteMint = MAINNET_USDC, proposal, market, swapType, inputAmount, minOutputAmount, }) {
|
|
179
184
|
const { passBaseMint, passQuoteMint, failBaseMint, failQuoteMint, baseVault, quoteVault, question, } = this.getProposalPdas(proposal, baseMint, quoteMint, dao);
|
|
180
185
|
let inputMint, outputMint;
|
|
181
186
|
if (market == "pass" && swapType == "buy") {
|
|
@@ -197,12 +202,12 @@ export class FutarchyClient {
|
|
|
197
202
|
else {
|
|
198
203
|
throw new Error("Either `market` or `swapType` is incorrectly configured");
|
|
199
204
|
}
|
|
200
|
-
return this.
|
|
205
|
+
return this.futarchy.methods
|
|
201
206
|
.conditionalSwap({
|
|
202
207
|
market: market == "pass" ? { pass: {} } : { fail: {} },
|
|
203
208
|
swapType: swapType == "buy" ? { buy: {} } : { sell: {} },
|
|
204
209
|
inputAmount,
|
|
205
|
-
minOutputAmount
|
|
210
|
+
minOutputAmount,
|
|
206
211
|
})
|
|
207
212
|
.accounts({
|
|
208
213
|
dao,
|
|
@@ -231,9 +236,38 @@ export class FutarchyClient {
|
|
|
231
236
|
createAssociatedTokenAccountIdempotentInstruction(payer, getAssociatedTokenAddressSync(outputMint, trader, true), trader, outputMint),
|
|
232
237
|
]);
|
|
233
238
|
}
|
|
239
|
+
squadsProposalCreateTx({ dao, instructions, transactionIndex, payer = this.provider.publicKey, }) {
|
|
240
|
+
const multisigPda = multisig.getMultisigPda({ createKey: dao })[0];
|
|
241
|
+
const transactionMessage = new TransactionMessage({
|
|
242
|
+
payerKey: payer,
|
|
243
|
+
recentBlockhash: "", // this doesn't get used
|
|
244
|
+
instructions,
|
|
245
|
+
});
|
|
246
|
+
const vaultTxCreate = multisig.instructions.vaultTransactionCreate({
|
|
247
|
+
multisigPda,
|
|
248
|
+
transactionIndex,
|
|
249
|
+
creator: PERMISSIONLESS_ACCOUNT.publicKey,
|
|
250
|
+
rentPayer: payer,
|
|
251
|
+
vaultIndex: 0,
|
|
252
|
+
ephemeralSigners: 0,
|
|
253
|
+
transactionMessage,
|
|
254
|
+
});
|
|
255
|
+
const proposalCreate = multisig.instructions.proposalCreate({
|
|
256
|
+
multisigPda,
|
|
257
|
+
transactionIndex,
|
|
258
|
+
creator: PERMISSIONLESS_ACCOUNT.publicKey,
|
|
259
|
+
rentPayer: payer,
|
|
260
|
+
});
|
|
261
|
+
const [squadsProposal] = multisig.getProposalPda({
|
|
262
|
+
multisigPda,
|
|
263
|
+
transactionIndex: transactionIndex,
|
|
264
|
+
});
|
|
265
|
+
const tx = new Transaction().add(vaultTxCreate, proposalCreate);
|
|
266
|
+
return { tx, squadsProposal };
|
|
267
|
+
}
|
|
234
268
|
async initializeProposal(dao, squadsProposal) {
|
|
235
269
|
const storedDao = await this.getDao(dao);
|
|
236
|
-
let [proposal] = getProposalAddr(this.
|
|
270
|
+
let [proposal] = getProposalAddr(this.futarchy.programId, squadsProposal);
|
|
237
271
|
await this.vaultClient.initializeQuestion(sha256(`Will ${proposal} pass?/FAIL/PASS`), proposal, 2);
|
|
238
272
|
const { question } = this.getProposalPdas(proposal, storedDao.baseMint, storedDao.quoteMint, dao);
|
|
239
273
|
// it's important that these happen in a single atomic transaction
|
|
@@ -249,10 +283,10 @@ export class FutarchyClient {
|
|
|
249
283
|
return proposal;
|
|
250
284
|
}
|
|
251
285
|
initializeProposalIx(squadsProposal, dao, baseMint, quoteMint, question, proposer = this.provider.publicKey) {
|
|
252
|
-
let [proposal] = getProposalAddr(this.
|
|
286
|
+
let [proposal] = getProposalAddr(this.futarchy.programId, squadsProposal);
|
|
253
287
|
const { baseVault, quoteVault, passBaseMint, passQuoteMint, failBaseMint, failQuoteMint, } = this.getProposalPdas(proposal, baseMint, quoteMint, dao);
|
|
254
288
|
let [futarchyAmm] = PublicKey.findProgramAddressSync([Buffer.from("futarchy_amm")], this.getProgramId());
|
|
255
|
-
return this.
|
|
289
|
+
return this.futarchy.methods
|
|
256
290
|
.initializeProposal()
|
|
257
291
|
.accounts({
|
|
258
292
|
question,
|
|
@@ -273,18 +307,24 @@ export class FutarchyClient {
|
|
|
273
307
|
async finalizeProposal(proposal) {
|
|
274
308
|
let storedProposal = await this.getProposal(proposal);
|
|
275
309
|
let storedDao = await this.getDao(storedProposal.dao);
|
|
276
|
-
return this.finalizeProposalIx(proposal, storedProposal.squadsProposal, storedProposal.dao, storedDao.baseMint, storedDao.quoteMint
|
|
310
|
+
return this.finalizeProposalIx(proposal, storedProposal.squadsProposal, storedProposal.dao, storedDao.baseMint, storedDao.quoteMint).rpc();
|
|
277
311
|
}
|
|
278
|
-
|
|
312
|
+
finalizeProposalIxV2({ squadsProposal, dao, baseMint, quoteMint = MAINNET_USDC, }) {
|
|
313
|
+
const [proposal] = getProposalAddrV2({ squadsProposal });
|
|
314
|
+
return this.finalizeProposalIx(proposal, squadsProposal, dao, baseMint, quoteMint);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* @deprecated use `finalizeProposalIxV2` instead
|
|
318
|
+
*/
|
|
319
|
+
finalizeProposalIx(proposal, squadsProposal, dao, daoToken, usdc) {
|
|
279
320
|
let vaultProgramId = this.vaultClient.vaultProgram.programId;
|
|
280
321
|
const multisigPda = multisig.getMultisigPda({ createKey: dao })[0];
|
|
281
322
|
const { question, quoteVault, passBaseMint, passQuoteMint, failBaseMint, failQuoteMint, baseVault, } = this.getProposalPdas(proposal, daoToken, usdc, dao);
|
|
282
323
|
const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId);
|
|
283
|
-
return this.
|
|
324
|
+
return this.futarchy.methods
|
|
284
325
|
.finalizeProposal()
|
|
285
326
|
.accounts({
|
|
286
327
|
proposal,
|
|
287
|
-
// futarchyAmm,
|
|
288
328
|
dao,
|
|
289
329
|
squadsProposal,
|
|
290
330
|
squadsMultisig: multisigPda,
|
|
@@ -304,8 +344,6 @@ export class FutarchyClient {
|
|
|
304
344
|
ammBaseVault: getAssociatedTokenAddressSync(daoToken, dao, true),
|
|
305
345
|
baseVault,
|
|
306
346
|
baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync(daoToken, baseVault, true),
|
|
307
|
-
// baseVault,
|
|
308
|
-
// quoteVault,
|
|
309
347
|
vaultProgram: this.vaultClient.vaultProgram.programId,
|
|
310
348
|
vaultEventAuthority,
|
|
311
349
|
})
|
|
@@ -313,51 +351,20 @@ export class FutarchyClient {
|
|
|
313
351
|
ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }),
|
|
314
352
|
]);
|
|
315
353
|
}
|
|
316
|
-
// async executeProposal(proposal: PublicKey) {
|
|
317
|
-
// let storedProposal = await this.getProposal(proposal);
|
|
318
|
-
// return this.executeProposalIx(
|
|
319
|
-
// proposal,
|
|
320
|
-
// storedProposal.dao,
|
|
321
|
-
// storedProposal.instruction
|
|
322
|
-
// ).rpc();
|
|
323
|
-
// }
|
|
324
|
-
// executeProposalIx(proposal: PublicKey, dao: PublicKey, instruction: any) {
|
|
325
|
-
// const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao);
|
|
326
|
-
// return this.autocrat.methods
|
|
327
|
-
// .executeProposal()
|
|
328
|
-
// .accounts({
|
|
329
|
-
// proposal,
|
|
330
|
-
// dao,
|
|
331
|
-
// // daoTreasury,
|
|
332
|
-
// })
|
|
333
|
-
// .remainingAccounts(
|
|
334
|
-
// instruction.accounts
|
|
335
|
-
// .concat({
|
|
336
|
-
// pubkey: instruction.programId,
|
|
337
|
-
// isWritable: false,
|
|
338
|
-
// isSigner: false,
|
|
339
|
-
// })
|
|
340
|
-
// .map((meta: AccountMeta) =>
|
|
341
|
-
// meta.pubkey.equals(daoTreasury)
|
|
342
|
-
// ? { ...meta, isSigner: false }
|
|
343
|
-
// : meta
|
|
344
|
-
// )
|
|
345
|
-
// );
|
|
346
|
-
// }
|
|
347
354
|
updateDaoIx({ dao, params }) {
|
|
348
355
|
const multisigPda = multisig.getMultisigPda({ createKey: dao })[0];
|
|
349
356
|
const squadsMultisigVault = multisig.getVaultPda({
|
|
350
357
|
multisigPda,
|
|
351
358
|
index: 0,
|
|
352
359
|
})[0];
|
|
353
|
-
return this.
|
|
360
|
+
return this.futarchy.methods.updateDao(params).accounts({
|
|
354
361
|
dao,
|
|
355
362
|
squadsMultisigVault,
|
|
356
363
|
});
|
|
357
364
|
}
|
|
358
365
|
stakeToProposalIx({ proposal, dao, baseMint, amount, staker = this.provider.publicKey, payer = this.provider.publicKey, }) {
|
|
359
|
-
const stakeAccount =
|
|
360
|
-
return this.
|
|
366
|
+
const stakeAccount = getStakeAddr(FUTARCHY_PROGRAM_ID, proposal, staker)[0];
|
|
367
|
+
return this.futarchy.methods
|
|
361
368
|
.stakeToProposal({ amount })
|
|
362
369
|
.accounts({
|
|
363
370
|
proposal,
|
|
@@ -376,8 +383,21 @@ export class FutarchyClient {
|
|
|
376
383
|
createAssociatedTokenAccountIdempotentInstruction(payer, getAssociatedTokenAddressSync(baseMint, proposal, true), proposal, baseMint),
|
|
377
384
|
]);
|
|
378
385
|
}
|
|
386
|
+
unstakeFromProposalIx({ proposal, dao, baseMint, amount, staker = this.provider.publicKey, }) {
|
|
387
|
+
const stakeAccount = getStakeAddr(FUTARCHY_PROGRAM_ID, proposal, staker)[0];
|
|
388
|
+
return this.futarchy.methods.unstakeFromProposal({ amount }).accounts({
|
|
389
|
+
proposal,
|
|
390
|
+
dao,
|
|
391
|
+
stakerBaseAccount: getAssociatedTokenAddressSync(baseMint, staker, true),
|
|
392
|
+
proposalBaseAccount: getAssociatedTokenAddressSync(baseMint, proposal, true),
|
|
393
|
+
stakeAccount,
|
|
394
|
+
staker,
|
|
395
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
396
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
379
399
|
collectFeesIx({ dao, baseMint, quoteMint, baseTokenAccount = getAssociatedTokenAddressSync(baseMint, this.provider.publicKey), quoteTokenAccount = getAssociatedTokenAddressSync(quoteMint, this.provider.publicKey), }) {
|
|
380
|
-
return this.
|
|
400
|
+
return this.futarchy.methods.collectFees().accounts({
|
|
381
401
|
dao,
|
|
382
402
|
admin: this.provider.publicKey,
|
|
383
403
|
ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true),
|
|
@@ -386,5 +406,12 @@ export class FutarchyClient {
|
|
|
386
406
|
quoteTokenAccount,
|
|
387
407
|
});
|
|
388
408
|
}
|
|
409
|
+
sponsorProposalIx({ proposal, dao, teamAddress = this.provider.publicKey, }) {
|
|
410
|
+
return this.futarchy.methods.sponsorProposal().accounts({
|
|
411
|
+
proposal,
|
|
412
|
+
dao,
|
|
413
|
+
teamAddress,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
389
416
|
}
|
|
390
417
|
//# sourceMappingURL=FutarchyClient.js.map
|