@glamsystems/glam-sdk 0.1.27 → 0.1.28
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/index.cjs.js +1789 -807
- package/index.esm.js +1786 -808
- package/package.json +1 -1
- package/src/client/base.d.ts +5 -3
- package/src/client/drift.d.ts +7 -1
- package/src/client/fees.d.ts +10 -0
- package/src/client/{investor.d.ts → invest.d.ts} +1 -1
- package/src/client/jupiter.d.ts +17 -2
- package/src/client/kamino.d.ts +3 -3
- package/src/client/price.d.ts +1 -2
- package/src/client/validator.d.ts +27 -0
- package/src/client.d.ts +9 -4
- package/src/clientConfig.d.ts +0 -1
- package/src/constants.d.ts +1 -0
- package/src/models.d.ts +10 -0
- package/src/react/glam.d.ts +3 -14
- package/src/utils/helpers.d.ts +5 -1
- package/target/idl/glam_protocol.json +1296 -621
- package/target/types/glam_protocol.d.ts +1298 -623
- package/target/types/glam_protocol.ts +1296 -621
package/index.cjs.js
CHANGED
|
@@ -34,7 +34,7 @@ var borsh__namespace = /*#__PURE__*/_interopNamespaceDefault(borsh);
|
|
|
34
34
|
var address = "GLAMbTqav9N9witRjswJ8enwp9vv5G8bsSJ2kPJ4rcyc";
|
|
35
35
|
var metadata = {
|
|
36
36
|
name: "glam_protocol",
|
|
37
|
-
version: "0.4.
|
|
37
|
+
version: "0.4.32",
|
|
38
38
|
spec: "0.1.0",
|
|
39
39
|
description: "Glam Protocol"
|
|
40
40
|
};
|
|
@@ -279,7 +279,7 @@ var instructions = [
|
|
|
279
279
|
},
|
|
280
280
|
{
|
|
281
281
|
kind: "account",
|
|
282
|
-
path: "
|
|
282
|
+
path: "claim_token_program"
|
|
283
283
|
},
|
|
284
284
|
{
|
|
285
285
|
kind: "account",
|
|
@@ -336,7 +336,7 @@ var instructions = [
|
|
|
336
336
|
},
|
|
337
337
|
{
|
|
338
338
|
kind: "account",
|
|
339
|
-
path: "
|
|
339
|
+
path: "claim_token_program"
|
|
340
340
|
},
|
|
341
341
|
{
|
|
342
342
|
kind: "account",
|
|
@@ -387,7 +387,11 @@ var instructions = [
|
|
|
387
387
|
address: "11111111111111111111111111111111"
|
|
388
388
|
},
|
|
389
389
|
{
|
|
390
|
-
name: "
|
|
390
|
+
name: "claim_token_program"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: "associated_token_program",
|
|
394
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
391
395
|
}
|
|
392
396
|
],
|
|
393
397
|
args: [
|
|
@@ -689,20 +693,21 @@ var instructions = [
|
|
|
689
693
|
]
|
|
690
694
|
},
|
|
691
695
|
{
|
|
692
|
-
name: "
|
|
696
|
+
name: "disburse_fees",
|
|
693
697
|
discriminator: [
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
698
|
+
205,
|
|
699
|
+
56,
|
|
700
|
+
198,
|
|
701
|
+
40,
|
|
702
|
+
225,
|
|
703
|
+
103,
|
|
704
|
+
141,
|
|
705
|
+
219
|
|
702
706
|
],
|
|
703
707
|
accounts: [
|
|
704
708
|
{
|
|
705
|
-
name: "glam_state"
|
|
709
|
+
name: "glam_state",
|
|
710
|
+
writable: true
|
|
706
711
|
},
|
|
707
712
|
{
|
|
708
713
|
name: "glam_vault",
|
|
@@ -726,79 +731,18 @@ var instructions = [
|
|
|
726
731
|
}
|
|
727
732
|
},
|
|
728
733
|
{
|
|
729
|
-
name: "
|
|
730
|
-
writable: true,
|
|
731
|
-
signer: true
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
name: "cpi_program",
|
|
735
|
-
address: "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
name: "state"
|
|
739
|
-
},
|
|
740
|
-
{
|
|
741
|
-
name: "user",
|
|
742
|
-
writable: true
|
|
743
|
-
}
|
|
744
|
-
],
|
|
745
|
-
args: [
|
|
746
|
-
{
|
|
747
|
-
name: "market_type",
|
|
748
|
-
type: {
|
|
749
|
-
option: {
|
|
750
|
-
defined: {
|
|
751
|
-
name: "MarketType"
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
},
|
|
756
|
-
{
|
|
757
|
-
name: "market_index",
|
|
758
|
-
type: {
|
|
759
|
-
option: "u16"
|
|
760
|
-
}
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
name: "direction",
|
|
764
|
-
type: {
|
|
765
|
-
option: {
|
|
766
|
-
defined: {
|
|
767
|
-
name: "PositionDirection"
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
]
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
name: "drift_cancel_orders_by_ids",
|
|
776
|
-
discriminator: [
|
|
777
|
-
172,
|
|
778
|
-
99,
|
|
779
|
-
108,
|
|
780
|
-
14,
|
|
781
|
-
81,
|
|
782
|
-
89,
|
|
783
|
-
228,
|
|
784
|
-
183
|
|
785
|
-
],
|
|
786
|
-
accounts: [
|
|
787
|
-
{
|
|
788
|
-
name: "glam_state"
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
name: "glam_vault",
|
|
734
|
+
name: "glam_escrow",
|
|
792
735
|
pda: {
|
|
793
736
|
seeds: [
|
|
794
737
|
{
|
|
795
738
|
kind: "const",
|
|
796
739
|
value: [
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
740
|
+
101,
|
|
741
|
+
115,
|
|
742
|
+
99,
|
|
743
|
+
114,
|
|
744
|
+
111,
|
|
745
|
+
119
|
|
802
746
|
]
|
|
803
747
|
},
|
|
804
748
|
{
|
|
@@ -809,132 +753,579 @@ var instructions = [
|
|
|
809
753
|
}
|
|
810
754
|
},
|
|
811
755
|
{
|
|
812
|
-
name: "
|
|
813
|
-
writable: true,
|
|
814
|
-
signer: true
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
name: "cpi_program",
|
|
818
|
-
address: "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
name: "state"
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
name: "user",
|
|
825
|
-
writable: true
|
|
826
|
-
}
|
|
827
|
-
],
|
|
828
|
-
args: [
|
|
829
|
-
{
|
|
830
|
-
name: "order_ids",
|
|
831
|
-
type: {
|
|
832
|
-
vec: "u32"
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
]
|
|
836
|
-
},
|
|
837
|
-
{
|
|
838
|
-
name: "drift_delete_user",
|
|
839
|
-
discriminator: [
|
|
840
|
-
179,
|
|
841
|
-
118,
|
|
842
|
-
20,
|
|
843
|
-
212,
|
|
844
|
-
145,
|
|
845
|
-
146,
|
|
846
|
-
49,
|
|
847
|
-
130
|
|
848
|
-
],
|
|
849
|
-
accounts: [
|
|
850
|
-
{
|
|
851
|
-
name: "glam_state",
|
|
756
|
+
name: "glam_mint",
|
|
852
757
|
writable: true
|
|
853
758
|
},
|
|
854
759
|
{
|
|
855
|
-
name: "
|
|
760
|
+
name: "escrow_mint_ata",
|
|
856
761
|
writable: true,
|
|
857
762
|
pda: {
|
|
858
763
|
seeds: [
|
|
859
764
|
{
|
|
860
|
-
kind: "
|
|
861
|
-
|
|
862
|
-
118,
|
|
863
|
-
97,
|
|
864
|
-
117,
|
|
865
|
-
108,
|
|
866
|
-
116
|
|
867
|
-
]
|
|
765
|
+
kind: "account",
|
|
766
|
+
path: "glam_escrow"
|
|
868
767
|
},
|
|
869
768
|
{
|
|
870
769
|
kind: "account",
|
|
871
|
-
path: "
|
|
770
|
+
path: "token_2022_program"
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
kind: "account",
|
|
774
|
+
path: "glam_mint"
|
|
872
775
|
}
|
|
873
|
-
]
|
|
776
|
+
],
|
|
777
|
+
program: {
|
|
778
|
+
kind: "const",
|
|
779
|
+
value: [
|
|
780
|
+
140,
|
|
781
|
+
151,
|
|
782
|
+
37,
|
|
783
|
+
143,
|
|
784
|
+
78,
|
|
785
|
+
36,
|
|
786
|
+
137,
|
|
787
|
+
241,
|
|
788
|
+
187,
|
|
789
|
+
61,
|
|
790
|
+
16,
|
|
791
|
+
41,
|
|
792
|
+
20,
|
|
793
|
+
142,
|
|
794
|
+
13,
|
|
795
|
+
131,
|
|
796
|
+
11,
|
|
797
|
+
90,
|
|
798
|
+
19,
|
|
799
|
+
153,
|
|
800
|
+
218,
|
|
801
|
+
255,
|
|
802
|
+
16,
|
|
803
|
+
132,
|
|
804
|
+
4,
|
|
805
|
+
142,
|
|
806
|
+
123,
|
|
807
|
+
216,
|
|
808
|
+
219,
|
|
809
|
+
233,
|
|
810
|
+
248,
|
|
811
|
+
89
|
|
812
|
+
]
|
|
813
|
+
}
|
|
874
814
|
}
|
|
875
815
|
},
|
|
876
816
|
{
|
|
877
|
-
name: "
|
|
817
|
+
name: "signer",
|
|
878
818
|
writable: true,
|
|
879
819
|
signer: true
|
|
880
820
|
},
|
|
881
821
|
{
|
|
882
|
-
name: "
|
|
883
|
-
address: "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
884
|
-
},
|
|
885
|
-
{
|
|
886
|
-
name: "user",
|
|
887
|
-
writable: true
|
|
888
|
-
},
|
|
889
|
-
{
|
|
890
|
-
name: "user_stats",
|
|
891
|
-
writable: true
|
|
892
|
-
},
|
|
893
|
-
{
|
|
894
|
-
name: "state",
|
|
895
|
-
writable: true
|
|
896
|
-
}
|
|
897
|
-
],
|
|
898
|
-
args: []
|
|
899
|
-
},
|
|
900
|
-
{
|
|
901
|
-
name: "drift_deposit",
|
|
902
|
-
discriminator: [
|
|
903
|
-
252,
|
|
904
|
-
63,
|
|
905
|
-
250,
|
|
906
|
-
201,
|
|
907
|
-
98,
|
|
908
|
-
55,
|
|
909
|
-
130,
|
|
910
|
-
12
|
|
911
|
-
],
|
|
912
|
-
accounts: [
|
|
913
|
-
{
|
|
914
|
-
name: "glam_state"
|
|
822
|
+
name: "deposit_asset"
|
|
915
823
|
},
|
|
916
824
|
{
|
|
917
|
-
name: "
|
|
825
|
+
name: "vault_deposit_ata",
|
|
918
826
|
writable: true,
|
|
919
827
|
pda: {
|
|
920
828
|
seeds: [
|
|
921
829
|
{
|
|
922
|
-
kind: "
|
|
923
|
-
|
|
924
|
-
118,
|
|
925
|
-
97,
|
|
926
|
-
117,
|
|
927
|
-
108,
|
|
928
|
-
116
|
|
929
|
-
]
|
|
830
|
+
kind: "account",
|
|
831
|
+
path: "glam_vault"
|
|
930
832
|
},
|
|
931
833
|
{
|
|
932
834
|
kind: "account",
|
|
933
|
-
path: "
|
|
835
|
+
path: "deposit_token_program"
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
kind: "account",
|
|
839
|
+
path: "deposit_asset"
|
|
934
840
|
}
|
|
935
|
-
]
|
|
936
|
-
|
|
937
|
-
|
|
841
|
+
],
|
|
842
|
+
program: {
|
|
843
|
+
kind: "const",
|
|
844
|
+
value: [
|
|
845
|
+
140,
|
|
846
|
+
151,
|
|
847
|
+
37,
|
|
848
|
+
143,
|
|
849
|
+
78,
|
|
850
|
+
36,
|
|
851
|
+
137,
|
|
852
|
+
241,
|
|
853
|
+
187,
|
|
854
|
+
61,
|
|
855
|
+
16,
|
|
856
|
+
41,
|
|
857
|
+
20,
|
|
858
|
+
142,
|
|
859
|
+
13,
|
|
860
|
+
131,
|
|
861
|
+
11,
|
|
862
|
+
90,
|
|
863
|
+
19,
|
|
864
|
+
153,
|
|
865
|
+
218,
|
|
866
|
+
255,
|
|
867
|
+
16,
|
|
868
|
+
132,
|
|
869
|
+
4,
|
|
870
|
+
142,
|
|
871
|
+
123,
|
|
872
|
+
216,
|
|
873
|
+
219,
|
|
874
|
+
233,
|
|
875
|
+
248,
|
|
876
|
+
89
|
|
877
|
+
]
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
name: "protocol_fee_authority_ata",
|
|
883
|
+
writable: true,
|
|
884
|
+
pda: {
|
|
885
|
+
seeds: [
|
|
886
|
+
{
|
|
887
|
+
kind: "account",
|
|
888
|
+
path: "glam_config.fee_authority",
|
|
889
|
+
account: "GlobalConfig"
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
kind: "account",
|
|
893
|
+
path: "deposit_token_program"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
kind: "account",
|
|
897
|
+
path: "deposit_asset"
|
|
898
|
+
}
|
|
899
|
+
],
|
|
900
|
+
program: {
|
|
901
|
+
kind: "const",
|
|
902
|
+
value: [
|
|
903
|
+
140,
|
|
904
|
+
151,
|
|
905
|
+
37,
|
|
906
|
+
143,
|
|
907
|
+
78,
|
|
908
|
+
36,
|
|
909
|
+
137,
|
|
910
|
+
241,
|
|
911
|
+
187,
|
|
912
|
+
61,
|
|
913
|
+
16,
|
|
914
|
+
41,
|
|
915
|
+
20,
|
|
916
|
+
142,
|
|
917
|
+
13,
|
|
918
|
+
131,
|
|
919
|
+
11,
|
|
920
|
+
90,
|
|
921
|
+
19,
|
|
922
|
+
153,
|
|
923
|
+
218,
|
|
924
|
+
255,
|
|
925
|
+
16,
|
|
926
|
+
132,
|
|
927
|
+
4,
|
|
928
|
+
142,
|
|
929
|
+
123,
|
|
930
|
+
216,
|
|
931
|
+
219,
|
|
932
|
+
233,
|
|
933
|
+
248,
|
|
934
|
+
89
|
|
935
|
+
]
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
name: "manager_fee_authority_ata",
|
|
941
|
+
writable: true,
|
|
942
|
+
pda: {
|
|
943
|
+
seeds: [
|
|
944
|
+
{
|
|
945
|
+
kind: "account",
|
|
946
|
+
path: "glam_state.owner",
|
|
947
|
+
account: "StateAccount"
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
kind: "account",
|
|
951
|
+
path: "deposit_token_program"
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
kind: "account",
|
|
955
|
+
path: "deposit_asset"
|
|
956
|
+
}
|
|
957
|
+
],
|
|
958
|
+
program: {
|
|
959
|
+
kind: "const",
|
|
960
|
+
value: [
|
|
961
|
+
140,
|
|
962
|
+
151,
|
|
963
|
+
37,
|
|
964
|
+
143,
|
|
965
|
+
78,
|
|
966
|
+
36,
|
|
967
|
+
137,
|
|
968
|
+
241,
|
|
969
|
+
187,
|
|
970
|
+
61,
|
|
971
|
+
16,
|
|
972
|
+
41,
|
|
973
|
+
20,
|
|
974
|
+
142,
|
|
975
|
+
13,
|
|
976
|
+
131,
|
|
977
|
+
11,
|
|
978
|
+
90,
|
|
979
|
+
19,
|
|
980
|
+
153,
|
|
981
|
+
218,
|
|
982
|
+
255,
|
|
983
|
+
16,
|
|
984
|
+
132,
|
|
985
|
+
4,
|
|
986
|
+
142,
|
|
987
|
+
123,
|
|
988
|
+
216,
|
|
989
|
+
219,
|
|
990
|
+
233,
|
|
991
|
+
248,
|
|
992
|
+
89
|
|
993
|
+
]
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
name: "glam_config",
|
|
999
|
+
pda: {
|
|
1000
|
+
seeds: [
|
|
1001
|
+
{
|
|
1002
|
+
kind: "const",
|
|
1003
|
+
value: [
|
|
1004
|
+
103,
|
|
1005
|
+
108,
|
|
1006
|
+
111,
|
|
1007
|
+
98,
|
|
1008
|
+
97,
|
|
1009
|
+
108,
|
|
1010
|
+
95,
|
|
1011
|
+
99,
|
|
1012
|
+
111,
|
|
1013
|
+
110,
|
|
1014
|
+
102,
|
|
1015
|
+
105,
|
|
1016
|
+
103
|
|
1017
|
+
]
|
|
1018
|
+
}
|
|
1019
|
+
],
|
|
1020
|
+
program: {
|
|
1021
|
+
kind: "const",
|
|
1022
|
+
value: [
|
|
1023
|
+
10,
|
|
1024
|
+
11,
|
|
1025
|
+
0,
|
|
1026
|
+
83,
|
|
1027
|
+
72,
|
|
1028
|
+
16,
|
|
1029
|
+
46,
|
|
1030
|
+
144,
|
|
1031
|
+
46,
|
|
1032
|
+
42,
|
|
1033
|
+
79,
|
|
1034
|
+
22,
|
|
1035
|
+
157,
|
|
1036
|
+
123,
|
|
1037
|
+
21,
|
|
1038
|
+
242,
|
|
1039
|
+
192,
|
|
1040
|
+
146,
|
|
1041
|
+
1,
|
|
1042
|
+
78,
|
|
1043
|
+
88,
|
|
1044
|
+
59,
|
|
1045
|
+
102,
|
|
1046
|
+
9,
|
|
1047
|
+
190,
|
|
1048
|
+
226,
|
|
1049
|
+
92,
|
|
1050
|
+
189,
|
|
1051
|
+
187,
|
|
1052
|
+
232,
|
|
1053
|
+
83,
|
|
1054
|
+
220
|
|
1055
|
+
]
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
name: "system_program",
|
|
1061
|
+
address: "11111111111111111111111111111111"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
name: "associated_token_program",
|
|
1065
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
name: "deposit_token_program"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
name: "token_2022_program",
|
|
1072
|
+
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
1073
|
+
}
|
|
1074
|
+
],
|
|
1075
|
+
args: [
|
|
1076
|
+
{
|
|
1077
|
+
name: "mint_id",
|
|
1078
|
+
type: "u8"
|
|
1079
|
+
}
|
|
1080
|
+
]
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
name: "drift_cancel_orders",
|
|
1084
|
+
discriminator: [
|
|
1085
|
+
98,
|
|
1086
|
+
107,
|
|
1087
|
+
48,
|
|
1088
|
+
79,
|
|
1089
|
+
97,
|
|
1090
|
+
60,
|
|
1091
|
+
99,
|
|
1092
|
+
58
|
|
1093
|
+
],
|
|
1094
|
+
accounts: [
|
|
1095
|
+
{
|
|
1096
|
+
name: "glam_state"
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
name: "glam_vault",
|
|
1100
|
+
pda: {
|
|
1101
|
+
seeds: [
|
|
1102
|
+
{
|
|
1103
|
+
kind: "const",
|
|
1104
|
+
value: [
|
|
1105
|
+
118,
|
|
1106
|
+
97,
|
|
1107
|
+
117,
|
|
1108
|
+
108,
|
|
1109
|
+
116
|
|
1110
|
+
]
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
kind: "account",
|
|
1114
|
+
path: "glam_state"
|
|
1115
|
+
}
|
|
1116
|
+
]
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
name: "glam_signer",
|
|
1121
|
+
writable: true,
|
|
1122
|
+
signer: true
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
name: "cpi_program",
|
|
1126
|
+
address: "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
name: "state"
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
name: "user",
|
|
1133
|
+
writable: true
|
|
1134
|
+
}
|
|
1135
|
+
],
|
|
1136
|
+
args: [
|
|
1137
|
+
{
|
|
1138
|
+
name: "market_type",
|
|
1139
|
+
type: {
|
|
1140
|
+
option: {
|
|
1141
|
+
defined: {
|
|
1142
|
+
name: "MarketType"
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
name: "market_index",
|
|
1149
|
+
type: {
|
|
1150
|
+
option: "u16"
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
name: "direction",
|
|
1155
|
+
type: {
|
|
1156
|
+
option: {
|
|
1157
|
+
defined: {
|
|
1158
|
+
name: "PositionDirection"
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
]
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
name: "drift_cancel_orders_by_ids",
|
|
1167
|
+
discriminator: [
|
|
1168
|
+
172,
|
|
1169
|
+
99,
|
|
1170
|
+
108,
|
|
1171
|
+
14,
|
|
1172
|
+
81,
|
|
1173
|
+
89,
|
|
1174
|
+
228,
|
|
1175
|
+
183
|
|
1176
|
+
],
|
|
1177
|
+
accounts: [
|
|
1178
|
+
{
|
|
1179
|
+
name: "glam_state"
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
name: "glam_vault",
|
|
1183
|
+
pda: {
|
|
1184
|
+
seeds: [
|
|
1185
|
+
{
|
|
1186
|
+
kind: "const",
|
|
1187
|
+
value: [
|
|
1188
|
+
118,
|
|
1189
|
+
97,
|
|
1190
|
+
117,
|
|
1191
|
+
108,
|
|
1192
|
+
116
|
|
1193
|
+
]
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
kind: "account",
|
|
1197
|
+
path: "glam_state"
|
|
1198
|
+
}
|
|
1199
|
+
]
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
name: "glam_signer",
|
|
1204
|
+
writable: true,
|
|
1205
|
+
signer: true
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
name: "cpi_program",
|
|
1209
|
+
address: "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
name: "state"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
name: "user",
|
|
1216
|
+
writable: true
|
|
1217
|
+
}
|
|
1218
|
+
],
|
|
1219
|
+
args: [
|
|
1220
|
+
{
|
|
1221
|
+
name: "order_ids",
|
|
1222
|
+
type: {
|
|
1223
|
+
vec: "u32"
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
]
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: "drift_delete_user",
|
|
1230
|
+
discriminator: [
|
|
1231
|
+
179,
|
|
1232
|
+
118,
|
|
1233
|
+
20,
|
|
1234
|
+
212,
|
|
1235
|
+
145,
|
|
1236
|
+
146,
|
|
1237
|
+
49,
|
|
1238
|
+
130
|
|
1239
|
+
],
|
|
1240
|
+
accounts: [
|
|
1241
|
+
{
|
|
1242
|
+
name: "glam_state",
|
|
1243
|
+
writable: true
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
name: "glam_vault",
|
|
1247
|
+
writable: true,
|
|
1248
|
+
pda: {
|
|
1249
|
+
seeds: [
|
|
1250
|
+
{
|
|
1251
|
+
kind: "const",
|
|
1252
|
+
value: [
|
|
1253
|
+
118,
|
|
1254
|
+
97,
|
|
1255
|
+
117,
|
|
1256
|
+
108,
|
|
1257
|
+
116
|
|
1258
|
+
]
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
kind: "account",
|
|
1262
|
+
path: "glam_state"
|
|
1263
|
+
}
|
|
1264
|
+
]
|
|
1265
|
+
}
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
name: "glam_signer",
|
|
1269
|
+
writable: true,
|
|
1270
|
+
signer: true
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
name: "cpi_program",
|
|
1274
|
+
address: "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
name: "user",
|
|
1278
|
+
writable: true
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
name: "user_stats",
|
|
1282
|
+
writable: true
|
|
1283
|
+
},
|
|
1284
|
+
{
|
|
1285
|
+
name: "state",
|
|
1286
|
+
writable: true
|
|
1287
|
+
}
|
|
1288
|
+
],
|
|
1289
|
+
args: []
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
name: "drift_deposit",
|
|
1293
|
+
discriminator: [
|
|
1294
|
+
252,
|
|
1295
|
+
63,
|
|
1296
|
+
250,
|
|
1297
|
+
201,
|
|
1298
|
+
98,
|
|
1299
|
+
55,
|
|
1300
|
+
130,
|
|
1301
|
+
12
|
|
1302
|
+
],
|
|
1303
|
+
accounts: [
|
|
1304
|
+
{
|
|
1305
|
+
name: "glam_state"
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
name: "glam_vault",
|
|
1309
|
+
writable: true,
|
|
1310
|
+
pda: {
|
|
1311
|
+
seeds: [
|
|
1312
|
+
{
|
|
1313
|
+
kind: "const",
|
|
1314
|
+
value: [
|
|
1315
|
+
118,
|
|
1316
|
+
97,
|
|
1317
|
+
117,
|
|
1318
|
+
108,
|
|
1319
|
+
116
|
|
1320
|
+
]
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
kind: "account",
|
|
1324
|
+
path: "glam_state"
|
|
1325
|
+
}
|
|
1326
|
+
]
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
938
1329
|
{
|
|
939
1330
|
name: "glam_signer",
|
|
940
1331
|
writable: true,
|
|
@@ -982,6 +1373,99 @@ var instructions = [
|
|
|
982
1373
|
}
|
|
983
1374
|
]
|
|
984
1375
|
},
|
|
1376
|
+
{
|
|
1377
|
+
name: "drift_distributor_new_claim",
|
|
1378
|
+
discriminator: [
|
|
1379
|
+
204,
|
|
1380
|
+
159,
|
|
1381
|
+
250,
|
|
1382
|
+
46,
|
|
1383
|
+
124,
|
|
1384
|
+
193,
|
|
1385
|
+
250,
|
|
1386
|
+
10
|
|
1387
|
+
],
|
|
1388
|
+
accounts: [
|
|
1389
|
+
{
|
|
1390
|
+
name: "glam_state"
|
|
1391
|
+
},
|
|
1392
|
+
{
|
|
1393
|
+
name: "glam_vault",
|
|
1394
|
+
writable: true,
|
|
1395
|
+
pda: {
|
|
1396
|
+
seeds: [
|
|
1397
|
+
{
|
|
1398
|
+
kind: "const",
|
|
1399
|
+
value: [
|
|
1400
|
+
118,
|
|
1401
|
+
97,
|
|
1402
|
+
117,
|
|
1403
|
+
108,
|
|
1404
|
+
116
|
|
1405
|
+
]
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
kind: "account",
|
|
1409
|
+
path: "glam_state"
|
|
1410
|
+
}
|
|
1411
|
+
]
|
|
1412
|
+
}
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
name: "glam_signer",
|
|
1416
|
+
writable: true,
|
|
1417
|
+
signer: true
|
|
1418
|
+
},
|
|
1419
|
+
{
|
|
1420
|
+
name: "cpi_program",
|
|
1421
|
+
address: "E7HtfkEMhmn9uwL7EFNydcXBWy5WCYN1vFmKKjipEH1x"
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
name: "distributor",
|
|
1425
|
+
writable: true
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
name: "claim_status",
|
|
1429
|
+
writable: true
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
name: "from",
|
|
1433
|
+
writable: true
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
name: "to",
|
|
1437
|
+
writable: true
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
name: "token_program"
|
|
1441
|
+
},
|
|
1442
|
+
{
|
|
1443
|
+
name: "system_program",
|
|
1444
|
+
address: "11111111111111111111111111111111"
|
|
1445
|
+
}
|
|
1446
|
+
],
|
|
1447
|
+
args: [
|
|
1448
|
+
{
|
|
1449
|
+
name: "amount_unlocked",
|
|
1450
|
+
type: "u64"
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
name: "amount_locked",
|
|
1454
|
+
type: "u64"
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
name: "proof",
|
|
1458
|
+
type: {
|
|
1459
|
+
vec: {
|
|
1460
|
+
array: [
|
|
1461
|
+
"u8",
|
|
1462
|
+
32
|
|
1463
|
+
]
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
]
|
|
1468
|
+
},
|
|
985
1469
|
{
|
|
986
1470
|
name: "drift_initialize_user",
|
|
987
1471
|
discriminator: [
|
|
@@ -1537,22 +2021,84 @@ var instructions = [
|
|
|
1537
2021
|
type: "u16"
|
|
1538
2022
|
},
|
|
1539
2023
|
{
|
|
1540
|
-
name: "delegate",
|
|
1541
|
-
type: "pubkey"
|
|
2024
|
+
name: "delegate",
|
|
2025
|
+
type: "pubkey"
|
|
2026
|
+
}
|
|
2027
|
+
]
|
|
2028
|
+
},
|
|
2029
|
+
{
|
|
2030
|
+
name: "drift_update_user_margin_trading_enabled",
|
|
2031
|
+
discriminator: [
|
|
2032
|
+
157,
|
|
2033
|
+
175,
|
|
2034
|
+
12,
|
|
2035
|
+
19,
|
|
2036
|
+
202,
|
|
2037
|
+
114,
|
|
2038
|
+
17,
|
|
2039
|
+
36
|
|
2040
|
+
],
|
|
2041
|
+
accounts: [
|
|
2042
|
+
{
|
|
2043
|
+
name: "glam_state"
|
|
2044
|
+
},
|
|
2045
|
+
{
|
|
2046
|
+
name: "glam_vault",
|
|
2047
|
+
pda: {
|
|
2048
|
+
seeds: [
|
|
2049
|
+
{
|
|
2050
|
+
kind: "const",
|
|
2051
|
+
value: [
|
|
2052
|
+
118,
|
|
2053
|
+
97,
|
|
2054
|
+
117,
|
|
2055
|
+
108,
|
|
2056
|
+
116
|
|
2057
|
+
]
|
|
2058
|
+
},
|
|
2059
|
+
{
|
|
2060
|
+
kind: "account",
|
|
2061
|
+
path: "glam_state"
|
|
2062
|
+
}
|
|
2063
|
+
]
|
|
2064
|
+
}
|
|
2065
|
+
},
|
|
2066
|
+
{
|
|
2067
|
+
name: "glam_signer",
|
|
2068
|
+
writable: true,
|
|
2069
|
+
signer: true
|
|
2070
|
+
},
|
|
2071
|
+
{
|
|
2072
|
+
name: "cpi_program",
|
|
2073
|
+
address: "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
name: "user",
|
|
2077
|
+
writable: true
|
|
2078
|
+
}
|
|
2079
|
+
],
|
|
2080
|
+
args: [
|
|
2081
|
+
{
|
|
2082
|
+
name: "sub_account_id",
|
|
2083
|
+
type: "u16"
|
|
2084
|
+
},
|
|
2085
|
+
{
|
|
2086
|
+
name: "margin_trading_enabled",
|
|
2087
|
+
type: "bool"
|
|
1542
2088
|
}
|
|
1543
2089
|
]
|
|
1544
2090
|
},
|
|
1545
2091
|
{
|
|
1546
|
-
name: "
|
|
2092
|
+
name: "drift_update_user_pool_id",
|
|
1547
2093
|
discriminator: [
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
2094
|
+
44,
|
|
2095
|
+
176,
|
|
2096
|
+
143,
|
|
2097
|
+
200,
|
|
2098
|
+
153,
|
|
2099
|
+
248,
|
|
2100
|
+
221,
|
|
2101
|
+
218
|
|
1556
2102
|
],
|
|
1557
2103
|
accounts: [
|
|
1558
2104
|
{
|
|
@@ -1599,8 +2145,8 @@ var instructions = [
|
|
|
1599
2145
|
type: "u16"
|
|
1600
2146
|
},
|
|
1601
2147
|
{
|
|
1602
|
-
name: "
|
|
1603
|
-
type: "
|
|
2148
|
+
name: "pool_id",
|
|
2149
|
+
type: "u8"
|
|
1604
2150
|
}
|
|
1605
2151
|
]
|
|
1606
2152
|
},
|
|
@@ -2505,41 +3051,8 @@ var instructions = [
|
|
|
2505
3051
|
path: "glam_vault"
|
|
2506
3052
|
},
|
|
2507
3053
|
{
|
|
2508
|
-
kind: "
|
|
2509
|
-
|
|
2510
|
-
6,
|
|
2511
|
-
221,
|
|
2512
|
-
246,
|
|
2513
|
-
225,
|
|
2514
|
-
215,
|
|
2515
|
-
101,
|
|
2516
|
-
161,
|
|
2517
|
-
147,
|
|
2518
|
-
217,
|
|
2519
|
-
203,
|
|
2520
|
-
225,
|
|
2521
|
-
70,
|
|
2522
|
-
206,
|
|
2523
|
-
235,
|
|
2524
|
-
121,
|
|
2525
|
-
172,
|
|
2526
|
-
28,
|
|
2527
|
-
180,
|
|
2528
|
-
133,
|
|
2529
|
-
237,
|
|
2530
|
-
95,
|
|
2531
|
-
91,
|
|
2532
|
-
55,
|
|
2533
|
-
145,
|
|
2534
|
-
58,
|
|
2535
|
-
140,
|
|
2536
|
-
245,
|
|
2537
|
-
133,
|
|
2538
|
-
126,
|
|
2539
|
-
255,
|
|
2540
|
-
0,
|
|
2541
|
-
169
|
|
2542
|
-
]
|
|
3054
|
+
kind: "account",
|
|
3055
|
+
path: "deposit_token_program"
|
|
2543
3056
|
},
|
|
2544
3057
|
{
|
|
2545
3058
|
kind: "account",
|
|
@@ -2595,41 +3108,8 @@ var instructions = [
|
|
|
2595
3108
|
path: "glam_escrow"
|
|
2596
3109
|
},
|
|
2597
3110
|
{
|
|
2598
|
-
kind: "
|
|
2599
|
-
|
|
2600
|
-
6,
|
|
2601
|
-
221,
|
|
2602
|
-
246,
|
|
2603
|
-
225,
|
|
2604
|
-
215,
|
|
2605
|
-
101,
|
|
2606
|
-
161,
|
|
2607
|
-
147,
|
|
2608
|
-
217,
|
|
2609
|
-
203,
|
|
2610
|
-
225,
|
|
2611
|
-
70,
|
|
2612
|
-
206,
|
|
2613
|
-
235,
|
|
2614
|
-
121,
|
|
2615
|
-
172,
|
|
2616
|
-
28,
|
|
2617
|
-
180,
|
|
2618
|
-
133,
|
|
2619
|
-
237,
|
|
2620
|
-
95,
|
|
2621
|
-
91,
|
|
2622
|
-
55,
|
|
2623
|
-
145,
|
|
2624
|
-
58,
|
|
2625
|
-
140,
|
|
2626
|
-
245,
|
|
2627
|
-
133,
|
|
2628
|
-
126,
|
|
2629
|
-
255,
|
|
2630
|
-
0,
|
|
2631
|
-
169
|
|
2632
|
-
]
|
|
3111
|
+
kind: "account",
|
|
3112
|
+
path: "deposit_token_program"
|
|
2633
3113
|
},
|
|
2634
3114
|
{
|
|
2635
3115
|
kind: "account",
|
|
@@ -2680,8 +3160,7 @@ var instructions = [
|
|
|
2680
3160
|
address: "11111111111111111111111111111111"
|
|
2681
3161
|
},
|
|
2682
3162
|
{
|
|
2683
|
-
name: "
|
|
2684
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
3163
|
+
name: "deposit_token_program"
|
|
2685
3164
|
},
|
|
2686
3165
|
{
|
|
2687
3166
|
name: "token_2022_program",
|
|
@@ -6288,6 +6767,12 @@ var instructions = [
|
|
|
6288
6767
|
},
|
|
6289
6768
|
{
|
|
6290
6769
|
name: "price_drift_users",
|
|
6770
|
+
docs: [
|
|
6771
|
+
"Extra accounts for pricing N drift users under the same user stats:",
|
|
6772
|
+
"- user_stats x 1",
|
|
6773
|
+
"- drift_user x N",
|
|
6774
|
+
"- markets and oracles used by all drift users (no specific order)"
|
|
6775
|
+
],
|
|
6291
6776
|
discriminator: [
|
|
6292
6777
|
12,
|
|
6293
6778
|
5,
|
|
@@ -6403,11 +6888,20 @@ var instructions = [
|
|
|
6403
6888
|
name: "PriceDenom"
|
|
6404
6889
|
}
|
|
6405
6890
|
}
|
|
6891
|
+
},
|
|
6892
|
+
{
|
|
6893
|
+
name: "num_users",
|
|
6894
|
+
type: "u8"
|
|
6406
6895
|
}
|
|
6407
6896
|
]
|
|
6408
6897
|
},
|
|
6409
6898
|
{
|
|
6410
6899
|
name: "price_drift_vault_depositors",
|
|
6900
|
+
docs: [
|
|
6901
|
+
"Extra accounts for pricing N vault depositors:",
|
|
6902
|
+
"- (vault_depositor, drift_vault, drift_user) x N",
|
|
6903
|
+
"- markets and oracles used by all drift users (no specific order)"
|
|
6904
|
+
],
|
|
6411
6905
|
discriminator: [
|
|
6412
6906
|
234,
|
|
6413
6907
|
16,
|
|
@@ -6523,6 +7017,10 @@ var instructions = [
|
|
|
6523
7017
|
name: "PriceDenom"
|
|
6524
7018
|
}
|
|
6525
7019
|
}
|
|
7020
|
+
},
|
|
7021
|
+
{
|
|
7022
|
+
name: "num_vault_depositors",
|
|
7023
|
+
type: "u8"
|
|
6526
7024
|
}
|
|
6527
7025
|
]
|
|
6528
7026
|
},
|
|
@@ -7409,41 +7907,8 @@ var instructions = [
|
|
|
7409
7907
|
path: "glam_escrow"
|
|
7410
7908
|
},
|
|
7411
7909
|
{
|
|
7412
|
-
kind: "
|
|
7413
|
-
|
|
7414
|
-
6,
|
|
7415
|
-
221,
|
|
7416
|
-
246,
|
|
7417
|
-
225,
|
|
7418
|
-
215,
|
|
7419
|
-
101,
|
|
7420
|
-
161,
|
|
7421
|
-
147,
|
|
7422
|
-
217,
|
|
7423
|
-
203,
|
|
7424
|
-
225,
|
|
7425
|
-
70,
|
|
7426
|
-
206,
|
|
7427
|
-
235,
|
|
7428
|
-
121,
|
|
7429
|
-
172,
|
|
7430
|
-
28,
|
|
7431
|
-
180,
|
|
7432
|
-
133,
|
|
7433
|
-
237,
|
|
7434
|
-
95,
|
|
7435
|
-
91,
|
|
7436
|
-
55,
|
|
7437
|
-
145,
|
|
7438
|
-
58,
|
|
7439
|
-
140,
|
|
7440
|
-
245,
|
|
7441
|
-
133,
|
|
7442
|
-
126,
|
|
7443
|
-
255,
|
|
7444
|
-
0,
|
|
7445
|
-
169
|
|
7446
|
-
]
|
|
7910
|
+
kind: "account",
|
|
7911
|
+
path: "deposit_token_program"
|
|
7447
7912
|
},
|
|
7448
7913
|
{
|
|
7449
7914
|
kind: "account",
|
|
@@ -7499,41 +7964,8 @@ var instructions = [
|
|
|
7499
7964
|
path: "signer"
|
|
7500
7965
|
},
|
|
7501
7966
|
{
|
|
7502
|
-
kind: "
|
|
7503
|
-
|
|
7504
|
-
6,
|
|
7505
|
-
221,
|
|
7506
|
-
246,
|
|
7507
|
-
225,
|
|
7508
|
-
215,
|
|
7509
|
-
101,
|
|
7510
|
-
161,
|
|
7511
|
-
147,
|
|
7512
|
-
217,
|
|
7513
|
-
203,
|
|
7514
|
-
225,
|
|
7515
|
-
70,
|
|
7516
|
-
206,
|
|
7517
|
-
235,
|
|
7518
|
-
121,
|
|
7519
|
-
172,
|
|
7520
|
-
28,
|
|
7521
|
-
180,
|
|
7522
|
-
133,
|
|
7523
|
-
237,
|
|
7524
|
-
95,
|
|
7525
|
-
91,
|
|
7526
|
-
55,
|
|
7527
|
-
145,
|
|
7528
|
-
58,
|
|
7529
|
-
140,
|
|
7530
|
-
245,
|
|
7531
|
-
133,
|
|
7532
|
-
126,
|
|
7533
|
-
255,
|
|
7534
|
-
0,
|
|
7535
|
-
169
|
|
7536
|
-
]
|
|
7967
|
+
kind: "account",
|
|
7968
|
+
path: "deposit_token_program"
|
|
7537
7969
|
},
|
|
7538
7970
|
{
|
|
7539
7971
|
kind: "account",
|
|
@@ -7584,8 +8016,7 @@ var instructions = [
|
|
|
7584
8016
|
address: "11111111111111111111111111111111"
|
|
7585
8017
|
},
|
|
7586
8018
|
{
|
|
7587
|
-
name: "
|
|
7588
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
8019
|
+
name: "deposit_token_program"
|
|
7589
8020
|
},
|
|
7590
8021
|
{
|
|
7591
8022
|
name: "associated_token_program",
|
|
@@ -9367,41 +9798,8 @@ var instructions = [
|
|
|
9367
9798
|
path: "glam_vault"
|
|
9368
9799
|
},
|
|
9369
9800
|
{
|
|
9370
|
-
kind: "
|
|
9371
|
-
|
|
9372
|
-
6,
|
|
9373
|
-
221,
|
|
9374
|
-
246,
|
|
9375
|
-
225,
|
|
9376
|
-
215,
|
|
9377
|
-
101,
|
|
9378
|
-
161,
|
|
9379
|
-
147,
|
|
9380
|
-
217,
|
|
9381
|
-
203,
|
|
9382
|
-
225,
|
|
9383
|
-
70,
|
|
9384
|
-
206,
|
|
9385
|
-
235,
|
|
9386
|
-
121,
|
|
9387
|
-
172,
|
|
9388
|
-
28,
|
|
9389
|
-
180,
|
|
9390
|
-
133,
|
|
9391
|
-
237,
|
|
9392
|
-
95,
|
|
9393
|
-
91,
|
|
9394
|
-
55,
|
|
9395
|
-
145,
|
|
9396
|
-
58,
|
|
9397
|
-
140,
|
|
9398
|
-
245,
|
|
9399
|
-
133,
|
|
9400
|
-
126,
|
|
9401
|
-
255,
|
|
9402
|
-
0,
|
|
9403
|
-
169
|
|
9404
|
-
]
|
|
9801
|
+
kind: "account",
|
|
9802
|
+
path: "deposit_token_program"
|
|
9405
9803
|
},
|
|
9406
9804
|
{
|
|
9407
9805
|
kind: "account",
|
|
@@ -9457,41 +9855,8 @@ var instructions = [
|
|
|
9457
9855
|
path: "signer"
|
|
9458
9856
|
},
|
|
9459
9857
|
{
|
|
9460
|
-
kind: "
|
|
9461
|
-
|
|
9462
|
-
6,
|
|
9463
|
-
221,
|
|
9464
|
-
246,
|
|
9465
|
-
225,
|
|
9466
|
-
215,
|
|
9467
|
-
101,
|
|
9468
|
-
161,
|
|
9469
|
-
147,
|
|
9470
|
-
217,
|
|
9471
|
-
203,
|
|
9472
|
-
225,
|
|
9473
|
-
70,
|
|
9474
|
-
206,
|
|
9475
|
-
235,
|
|
9476
|
-
121,
|
|
9477
|
-
172,
|
|
9478
|
-
28,
|
|
9479
|
-
180,
|
|
9480
|
-
133,
|
|
9481
|
-
237,
|
|
9482
|
-
95,
|
|
9483
|
-
91,
|
|
9484
|
-
55,
|
|
9485
|
-
145,
|
|
9486
|
-
58,
|
|
9487
|
-
140,
|
|
9488
|
-
245,
|
|
9489
|
-
133,
|
|
9490
|
-
126,
|
|
9491
|
-
255,
|
|
9492
|
-
0,
|
|
9493
|
-
169
|
|
9494
|
-
]
|
|
9858
|
+
kind: "account",
|
|
9859
|
+
path: "deposit_token_program"
|
|
9495
9860
|
},
|
|
9496
9861
|
{
|
|
9497
9862
|
kind: "account",
|
|
@@ -9538,53 +9903,230 @@ var instructions = [
|
|
|
9538
9903
|
}
|
|
9539
9904
|
},
|
|
9540
9905
|
{
|
|
9541
|
-
name: "signer_policy",
|
|
9906
|
+
name: "signer_policy",
|
|
9907
|
+
writable: true,
|
|
9908
|
+
optional: true
|
|
9909
|
+
},
|
|
9910
|
+
{
|
|
9911
|
+
name: "system_program",
|
|
9912
|
+
address: "11111111111111111111111111111111"
|
|
9913
|
+
},
|
|
9914
|
+
{
|
|
9915
|
+
name: "deposit_token_program"
|
|
9916
|
+
},
|
|
9917
|
+
{
|
|
9918
|
+
name: "token_2022_program",
|
|
9919
|
+
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
9920
|
+
},
|
|
9921
|
+
{
|
|
9922
|
+
name: "associated_token_program",
|
|
9923
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
9924
|
+
},
|
|
9925
|
+
{
|
|
9926
|
+
name: "policies_program",
|
|
9927
|
+
address: "po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"
|
|
9928
|
+
}
|
|
9929
|
+
],
|
|
9930
|
+
args: [
|
|
9931
|
+
{
|
|
9932
|
+
name: "mint_id",
|
|
9933
|
+
type: "u8"
|
|
9934
|
+
},
|
|
9935
|
+
{
|
|
9936
|
+
name: "amount_in",
|
|
9937
|
+
type: "u64"
|
|
9938
|
+
}
|
|
9939
|
+
]
|
|
9940
|
+
},
|
|
9941
|
+
{
|
|
9942
|
+
name: "system_transfer",
|
|
9943
|
+
discriminator: [
|
|
9944
|
+
167,
|
|
9945
|
+
164,
|
|
9946
|
+
195,
|
|
9947
|
+
155,
|
|
9948
|
+
219,
|
|
9949
|
+
152,
|
|
9950
|
+
191,
|
|
9951
|
+
230
|
|
9952
|
+
],
|
|
9953
|
+
accounts: [
|
|
9954
|
+
{
|
|
9955
|
+
name: "glam_state"
|
|
9956
|
+
},
|
|
9957
|
+
{
|
|
9958
|
+
name: "glam_vault",
|
|
9959
|
+
writable: true,
|
|
9960
|
+
pda: {
|
|
9961
|
+
seeds: [
|
|
9962
|
+
{
|
|
9963
|
+
kind: "const",
|
|
9964
|
+
value: [
|
|
9965
|
+
118,
|
|
9966
|
+
97,
|
|
9967
|
+
117,
|
|
9968
|
+
108,
|
|
9969
|
+
116
|
|
9970
|
+
]
|
|
9971
|
+
},
|
|
9972
|
+
{
|
|
9973
|
+
kind: "account",
|
|
9974
|
+
path: "glam_state"
|
|
9975
|
+
}
|
|
9976
|
+
]
|
|
9977
|
+
}
|
|
9978
|
+
},
|
|
9979
|
+
{
|
|
9980
|
+
name: "glam_signer",
|
|
9981
|
+
writable: true,
|
|
9982
|
+
signer: true
|
|
9983
|
+
},
|
|
9984
|
+
{
|
|
9985
|
+
name: "cpi_program",
|
|
9986
|
+
address: "11111111111111111111111111111111"
|
|
9987
|
+
},
|
|
9988
|
+
{
|
|
9989
|
+
name: "to",
|
|
9990
|
+
writable: true
|
|
9991
|
+
}
|
|
9992
|
+
],
|
|
9993
|
+
args: [
|
|
9994
|
+
{
|
|
9995
|
+
name: "lamports",
|
|
9996
|
+
type: "u64"
|
|
9997
|
+
}
|
|
9998
|
+
]
|
|
9999
|
+
},
|
|
10000
|
+
{
|
|
10001
|
+
name: "token_close_account",
|
|
10002
|
+
discriminator: [
|
|
10003
|
+
240,
|
|
10004
|
+
32,
|
|
10005
|
+
179,
|
|
10006
|
+
154,
|
|
10007
|
+
96,
|
|
10008
|
+
110,
|
|
10009
|
+
43,
|
|
10010
|
+
79
|
|
10011
|
+
],
|
|
10012
|
+
accounts: [
|
|
10013
|
+
{
|
|
10014
|
+
name: "glam_state"
|
|
10015
|
+
},
|
|
10016
|
+
{
|
|
10017
|
+
name: "glam_vault",
|
|
10018
|
+
writable: true,
|
|
10019
|
+
pda: {
|
|
10020
|
+
seeds: [
|
|
10021
|
+
{
|
|
10022
|
+
kind: "const",
|
|
10023
|
+
value: [
|
|
10024
|
+
118,
|
|
10025
|
+
97,
|
|
10026
|
+
117,
|
|
10027
|
+
108,
|
|
10028
|
+
116
|
|
10029
|
+
]
|
|
10030
|
+
},
|
|
10031
|
+
{
|
|
10032
|
+
kind: "account",
|
|
10033
|
+
path: "glam_state"
|
|
10034
|
+
}
|
|
10035
|
+
]
|
|
10036
|
+
}
|
|
10037
|
+
},
|
|
10038
|
+
{
|
|
10039
|
+
name: "glam_signer",
|
|
10040
|
+
writable: true,
|
|
10041
|
+
signer: true
|
|
10042
|
+
},
|
|
10043
|
+
{
|
|
10044
|
+
name: "cpi_program"
|
|
10045
|
+
},
|
|
10046
|
+
{
|
|
10047
|
+
name: "system_program",
|
|
10048
|
+
address: "11111111111111111111111111111111"
|
|
10049
|
+
},
|
|
10050
|
+
{
|
|
10051
|
+
name: "token_account",
|
|
10052
|
+
writable: true
|
|
10053
|
+
}
|
|
10054
|
+
],
|
|
10055
|
+
args: []
|
|
10056
|
+
},
|
|
10057
|
+
{
|
|
10058
|
+
name: "token_transfer",
|
|
10059
|
+
discriminator: [
|
|
10060
|
+
210,
|
|
10061
|
+
16,
|
|
10062
|
+
52,
|
|
10063
|
+
5,
|
|
10064
|
+
247,
|
|
10065
|
+
164,
|
|
10066
|
+
59,
|
|
10067
|
+
18
|
|
10068
|
+
],
|
|
10069
|
+
accounts: [
|
|
10070
|
+
{
|
|
10071
|
+
name: "glam_state"
|
|
10072
|
+
},
|
|
10073
|
+
{
|
|
10074
|
+
name: "glam_vault",
|
|
10075
|
+
writable: true,
|
|
10076
|
+
pda: {
|
|
10077
|
+
seeds: [
|
|
10078
|
+
{
|
|
10079
|
+
kind: "const",
|
|
10080
|
+
value: [
|
|
10081
|
+
118,
|
|
10082
|
+
97,
|
|
10083
|
+
117,
|
|
10084
|
+
108,
|
|
10085
|
+
116
|
|
10086
|
+
]
|
|
10087
|
+
},
|
|
10088
|
+
{
|
|
10089
|
+
kind: "account",
|
|
10090
|
+
path: "glam_state"
|
|
10091
|
+
}
|
|
10092
|
+
]
|
|
10093
|
+
}
|
|
10094
|
+
},
|
|
10095
|
+
{
|
|
10096
|
+
name: "glam_signer",
|
|
9542
10097
|
writable: true,
|
|
9543
|
-
|
|
9544
|
-
},
|
|
9545
|
-
{
|
|
9546
|
-
name: "system_program",
|
|
9547
|
-
address: "11111111111111111111111111111111"
|
|
9548
|
-
},
|
|
9549
|
-
{
|
|
9550
|
-
name: "token_program",
|
|
9551
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
10098
|
+
signer: true
|
|
9552
10099
|
},
|
|
9553
10100
|
{
|
|
9554
|
-
name: "
|
|
9555
|
-
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
10101
|
+
name: "cpi_program"
|
|
9556
10102
|
},
|
|
9557
10103
|
{
|
|
9558
|
-
name: "
|
|
9559
|
-
|
|
10104
|
+
name: "from",
|
|
10105
|
+
writable: true
|
|
9560
10106
|
},
|
|
9561
10107
|
{
|
|
9562
|
-
name: "
|
|
9563
|
-
|
|
10108
|
+
name: "to",
|
|
10109
|
+
writable: true
|
|
9564
10110
|
}
|
|
9565
10111
|
],
|
|
9566
10112
|
args: [
|
|
9567
10113
|
{
|
|
9568
|
-
name: "
|
|
9569
|
-
type: "u8"
|
|
9570
|
-
},
|
|
9571
|
-
{
|
|
9572
|
-
name: "amount_in",
|
|
10114
|
+
name: "lamports",
|
|
9573
10115
|
type: "u64"
|
|
9574
10116
|
}
|
|
9575
10117
|
]
|
|
9576
10118
|
},
|
|
9577
10119
|
{
|
|
9578
|
-
name: "
|
|
10120
|
+
name: "token_transfer_checked",
|
|
9579
10121
|
discriminator: [
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
152,
|
|
10122
|
+
169,
|
|
10123
|
+
178,
|
|
10124
|
+
117,
|
|
10125
|
+
156,
|
|
10126
|
+
169,
|
|
9586
10127
|
191,
|
|
9587
|
-
|
|
10128
|
+
199,
|
|
10129
|
+
116
|
|
9588
10130
|
],
|
|
9589
10131
|
accounts: [
|
|
9590
10132
|
{
|
|
@@ -9618,8 +10160,14 @@ var instructions = [
|
|
|
9618
10160
|
signer: true
|
|
9619
10161
|
},
|
|
9620
10162
|
{
|
|
9621
|
-
name: "cpi_program"
|
|
9622
|
-
|
|
10163
|
+
name: "cpi_program"
|
|
10164
|
+
},
|
|
10165
|
+
{
|
|
10166
|
+
name: "from",
|
|
10167
|
+
writable: true
|
|
10168
|
+
},
|
|
10169
|
+
{
|
|
10170
|
+
name: "mint"
|
|
9623
10171
|
},
|
|
9624
10172
|
{
|
|
9625
10173
|
name: "to",
|
|
@@ -9630,20 +10178,167 @@ var instructions = [
|
|
|
9630
10178
|
{
|
|
9631
10179
|
name: "lamports",
|
|
9632
10180
|
type: "u64"
|
|
10181
|
+
},
|
|
10182
|
+
{
|
|
10183
|
+
name: "decimals",
|
|
10184
|
+
type: "u8"
|
|
9633
10185
|
}
|
|
9634
10186
|
]
|
|
9635
10187
|
},
|
|
9636
10188
|
{
|
|
9637
|
-
name: "
|
|
10189
|
+
name: "update_mint",
|
|
9638
10190
|
discriminator: [
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
10191
|
+
212,
|
|
10192
|
+
203,
|
|
10193
|
+
57,
|
|
10194
|
+
78,
|
|
10195
|
+
75,
|
|
10196
|
+
245,
|
|
10197
|
+
222,
|
|
10198
|
+
5
|
|
10199
|
+
],
|
|
10200
|
+
accounts: [
|
|
10201
|
+
{
|
|
10202
|
+
name: "glam_state",
|
|
10203
|
+
writable: true
|
|
10204
|
+
},
|
|
10205
|
+
{
|
|
10206
|
+
name: "glam_signer",
|
|
10207
|
+
writable: true,
|
|
10208
|
+
signer: true
|
|
10209
|
+
},
|
|
10210
|
+
{
|
|
10211
|
+
name: "glam_mint",
|
|
10212
|
+
writable: true
|
|
10213
|
+
},
|
|
10214
|
+
{
|
|
10215
|
+
name: "token_2022_program",
|
|
10216
|
+
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
10217
|
+
}
|
|
10218
|
+
],
|
|
10219
|
+
args: [
|
|
10220
|
+
{
|
|
10221
|
+
name: "mint_id",
|
|
10222
|
+
type: "u8"
|
|
10223
|
+
},
|
|
10224
|
+
{
|
|
10225
|
+
name: "mint_model",
|
|
10226
|
+
type: {
|
|
10227
|
+
defined: {
|
|
10228
|
+
name: "MintModel"
|
|
10229
|
+
}
|
|
10230
|
+
}
|
|
10231
|
+
}
|
|
10232
|
+
]
|
|
10233
|
+
},
|
|
10234
|
+
{
|
|
10235
|
+
name: "update_mint_apply_timelock",
|
|
10236
|
+
discriminator: [
|
|
10237
|
+
223,
|
|
10238
|
+
241,
|
|
10239
|
+
80,
|
|
10240
|
+
24,
|
|
10241
|
+
120,
|
|
10242
|
+
25,
|
|
10243
|
+
82,
|
|
10244
|
+
134
|
|
10245
|
+
],
|
|
10246
|
+
accounts: [
|
|
10247
|
+
{
|
|
10248
|
+
name: "glam_state",
|
|
10249
|
+
writable: true
|
|
10250
|
+
},
|
|
10251
|
+
{
|
|
10252
|
+
name: "glam_signer",
|
|
10253
|
+
writable: true,
|
|
10254
|
+
signer: true
|
|
10255
|
+
},
|
|
10256
|
+
{
|
|
10257
|
+
name: "glam_mint",
|
|
10258
|
+
writable: true
|
|
10259
|
+
},
|
|
10260
|
+
{
|
|
10261
|
+
name: "token_2022_program",
|
|
10262
|
+
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
10263
|
+
}
|
|
10264
|
+
],
|
|
10265
|
+
args: [
|
|
10266
|
+
{
|
|
10267
|
+
name: "mint_id",
|
|
10268
|
+
type: "u8"
|
|
10269
|
+
}
|
|
10270
|
+
]
|
|
10271
|
+
},
|
|
10272
|
+
{
|
|
10273
|
+
name: "update_state",
|
|
10274
|
+
discriminator: [
|
|
10275
|
+
135,
|
|
10276
|
+
112,
|
|
10277
|
+
215,
|
|
10278
|
+
75,
|
|
10279
|
+
247,
|
|
10280
|
+
185,
|
|
10281
|
+
53,
|
|
10282
|
+
176
|
|
10283
|
+
],
|
|
10284
|
+
accounts: [
|
|
10285
|
+
{
|
|
10286
|
+
name: "glam_state",
|
|
10287
|
+
writable: true
|
|
10288
|
+
},
|
|
10289
|
+
{
|
|
10290
|
+
name: "glam_signer",
|
|
10291
|
+
writable: true,
|
|
10292
|
+
signer: true
|
|
10293
|
+
}
|
|
10294
|
+
],
|
|
10295
|
+
args: [
|
|
10296
|
+
{
|
|
10297
|
+
name: "state",
|
|
10298
|
+
type: {
|
|
10299
|
+
defined: {
|
|
10300
|
+
name: "StateModel"
|
|
10301
|
+
}
|
|
10302
|
+
}
|
|
10303
|
+
}
|
|
10304
|
+
]
|
|
10305
|
+
},
|
|
10306
|
+
{
|
|
10307
|
+
name: "update_state_apply_timelock",
|
|
10308
|
+
discriminator: [
|
|
10309
|
+
66,
|
|
10310
|
+
12,
|
|
10311
|
+
138,
|
|
10312
|
+
80,
|
|
10313
|
+
133,
|
|
10314
|
+
85,
|
|
10315
|
+
46,
|
|
10316
|
+
220
|
|
10317
|
+
],
|
|
10318
|
+
accounts: [
|
|
10319
|
+
{
|
|
10320
|
+
name: "glam_state",
|
|
10321
|
+
writable: true
|
|
10322
|
+
},
|
|
10323
|
+
{
|
|
10324
|
+
name: "glam_signer",
|
|
10325
|
+
writable: true,
|
|
10326
|
+
signer: true
|
|
10327
|
+
}
|
|
10328
|
+
],
|
|
10329
|
+
args: []
|
|
10330
|
+
},
|
|
10331
|
+
{
|
|
10332
|
+
name: "vote_authorize",
|
|
10333
|
+
discriminator: [
|
|
10334
|
+
61,
|
|
10335
|
+
48,
|
|
10336
|
+
136,
|
|
10337
|
+
95,
|
|
10338
|
+
88,
|
|
10339
|
+
65,
|
|
10340
|
+
161,
|
|
10341
|
+
215
|
|
9647
10342
|
],
|
|
9648
10343
|
accounts: [
|
|
9649
10344
|
{
|
|
@@ -9677,30 +10372,44 @@ var instructions = [
|
|
|
9677
10372
|
signer: true
|
|
9678
10373
|
},
|
|
9679
10374
|
{
|
|
9680
|
-
name: "cpi_program"
|
|
10375
|
+
name: "cpi_program",
|
|
10376
|
+
address: "Vote111111111111111111111111111111111111111"
|
|
9681
10377
|
},
|
|
9682
10378
|
{
|
|
9683
|
-
name: "
|
|
9684
|
-
|
|
10379
|
+
name: "vote",
|
|
10380
|
+
writable: true
|
|
9685
10381
|
},
|
|
9686
10382
|
{
|
|
9687
|
-
name: "
|
|
9688
|
-
|
|
10383
|
+
name: "clock",
|
|
10384
|
+
address: "SysvarC1ock11111111111111111111111111111111"
|
|
9689
10385
|
}
|
|
9690
10386
|
],
|
|
9691
|
-
args: [
|
|
10387
|
+
args: [
|
|
10388
|
+
{
|
|
10389
|
+
name: "new_authority",
|
|
10390
|
+
type: "pubkey"
|
|
10391
|
+
},
|
|
10392
|
+
{
|
|
10393
|
+
name: "vote_authorize",
|
|
10394
|
+
type: {
|
|
10395
|
+
defined: {
|
|
10396
|
+
name: "VoteAuthorizeEnum"
|
|
10397
|
+
}
|
|
10398
|
+
}
|
|
10399
|
+
}
|
|
10400
|
+
]
|
|
9692
10401
|
},
|
|
9693
10402
|
{
|
|
9694
|
-
name: "
|
|
9695
|
-
discriminator: [
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
10403
|
+
name: "vote_update_commission",
|
|
10404
|
+
discriminator: [
|
|
10405
|
+
193,
|
|
10406
|
+
83,
|
|
10407
|
+
224,
|
|
10408
|
+
17,
|
|
10409
|
+
218,
|
|
10410
|
+
144,
|
|
10411
|
+
211,
|
|
10412
|
+
60
|
|
9704
10413
|
],
|
|
9705
10414
|
accounts: [
|
|
9706
10415
|
{
|
|
@@ -9734,35 +10443,32 @@ var instructions = [
|
|
|
9734
10443
|
signer: true
|
|
9735
10444
|
},
|
|
9736
10445
|
{
|
|
9737
|
-
name: "cpi_program"
|
|
9738
|
-
|
|
9739
|
-
{
|
|
9740
|
-
name: "from",
|
|
9741
|
-
writable: true
|
|
10446
|
+
name: "cpi_program",
|
|
10447
|
+
address: "Vote111111111111111111111111111111111111111"
|
|
9742
10448
|
},
|
|
9743
10449
|
{
|
|
9744
|
-
name: "
|
|
10450
|
+
name: "vote",
|
|
9745
10451
|
writable: true
|
|
9746
10452
|
}
|
|
9747
10453
|
],
|
|
9748
10454
|
args: [
|
|
9749
10455
|
{
|
|
9750
|
-
name: "
|
|
9751
|
-
type: "
|
|
10456
|
+
name: "new_commission",
|
|
10457
|
+
type: "u8"
|
|
9752
10458
|
}
|
|
9753
10459
|
]
|
|
9754
10460
|
},
|
|
9755
10461
|
{
|
|
9756
|
-
name: "
|
|
10462
|
+
name: "vote_update_validator_identity",
|
|
9757
10463
|
discriminator: [
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
10464
|
+
164,
|
|
10465
|
+
111,
|
|
10466
|
+
105,
|
|
10467
|
+
150,
|
|
10468
|
+
248,
|
|
10469
|
+
104,
|
|
10470
|
+
150,
|
|
10471
|
+
8
|
|
9766
10472
|
],
|
|
9767
10473
|
accounts: [
|
|
9768
10474
|
{
|
|
@@ -9796,93 +10502,58 @@ var instructions = [
|
|
|
9796
10502
|
signer: true
|
|
9797
10503
|
},
|
|
9798
10504
|
{
|
|
9799
|
-
name: "cpi_program"
|
|
10505
|
+
name: "cpi_program",
|
|
10506
|
+
address: "Vote111111111111111111111111111111111111111"
|
|
9800
10507
|
},
|
|
9801
10508
|
{
|
|
9802
|
-
name: "
|
|
10509
|
+
name: "vote",
|
|
9803
10510
|
writable: true
|
|
9804
10511
|
},
|
|
9805
10512
|
{
|
|
9806
|
-
name: "
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
name: "to",
|
|
9810
|
-
writable: true
|
|
10513
|
+
name: "identity",
|
|
10514
|
+
writable: true,
|
|
10515
|
+
signer: true
|
|
9811
10516
|
}
|
|
9812
10517
|
],
|
|
9813
|
-
args: [
|
|
9814
|
-
{
|
|
9815
|
-
name: "lamports",
|
|
9816
|
-
type: "u64"
|
|
9817
|
-
},
|
|
9818
|
-
{
|
|
9819
|
-
name: "decimals",
|
|
9820
|
-
type: "u8"
|
|
9821
|
-
}
|
|
9822
|
-
]
|
|
10518
|
+
args: []
|
|
9823
10519
|
},
|
|
9824
10520
|
{
|
|
9825
|
-
name: "
|
|
10521
|
+
name: "vote_withdraw",
|
|
9826
10522
|
discriminator: [
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
10523
|
+
193,
|
|
10524
|
+
3,
|
|
10525
|
+
236,
|
|
10526
|
+
192,
|
|
10527
|
+
122,
|
|
10528
|
+
146,
|
|
10529
|
+
217,
|
|
10530
|
+
149
|
|
9835
10531
|
],
|
|
9836
10532
|
accounts: [
|
|
9837
10533
|
{
|
|
9838
|
-
name: "glam_state"
|
|
9839
|
-
writable: true
|
|
10534
|
+
name: "glam_state"
|
|
9840
10535
|
},
|
|
9841
10536
|
{
|
|
9842
|
-
name: "
|
|
10537
|
+
name: "glam_vault",
|
|
9843
10538
|
writable: true,
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
name: "mint_model",
|
|
9862
|
-
type: {
|
|
9863
|
-
defined: {
|
|
9864
|
-
name: "MintModel"
|
|
9865
|
-
}
|
|
10539
|
+
pda: {
|
|
10540
|
+
seeds: [
|
|
10541
|
+
{
|
|
10542
|
+
kind: "const",
|
|
10543
|
+
value: [
|
|
10544
|
+
118,
|
|
10545
|
+
97,
|
|
10546
|
+
117,
|
|
10547
|
+
108,
|
|
10548
|
+
116
|
|
10549
|
+
]
|
|
10550
|
+
},
|
|
10551
|
+
{
|
|
10552
|
+
kind: "account",
|
|
10553
|
+
path: "glam_state"
|
|
10554
|
+
}
|
|
10555
|
+
]
|
|
9866
10556
|
}
|
|
9867
|
-
}
|
|
9868
|
-
]
|
|
9869
|
-
},
|
|
9870
|
-
{
|
|
9871
|
-
name: "update_mint_apply_timelock",
|
|
9872
|
-
discriminator: [
|
|
9873
|
-
223,
|
|
9874
|
-
241,
|
|
9875
|
-
80,
|
|
9876
|
-
24,
|
|
9877
|
-
120,
|
|
9878
|
-
25,
|
|
9879
|
-
82,
|
|
9880
|
-
134
|
|
9881
|
-
],
|
|
9882
|
-
accounts: [
|
|
9883
|
-
{
|
|
9884
|
-
name: "glam_state",
|
|
9885
|
-
writable: true
|
|
9886
10557
|
},
|
|
9887
10558
|
{
|
|
9888
10559
|
name: "glam_signer",
|
|
@@ -9890,80 +10561,25 @@ var instructions = [
|
|
|
9890
10561
|
signer: true
|
|
9891
10562
|
},
|
|
9892
10563
|
{
|
|
9893
|
-
name: "
|
|
9894
|
-
|
|
10564
|
+
name: "cpi_program",
|
|
10565
|
+
address: "Vote111111111111111111111111111111111111111"
|
|
9895
10566
|
},
|
|
9896
10567
|
{
|
|
9897
|
-
name: "
|
|
9898
|
-
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
9899
|
-
}
|
|
9900
|
-
],
|
|
9901
|
-
args: [
|
|
9902
|
-
{
|
|
9903
|
-
name: "mint_id",
|
|
9904
|
-
type: "u8"
|
|
9905
|
-
}
|
|
9906
|
-
]
|
|
9907
|
-
},
|
|
9908
|
-
{
|
|
9909
|
-
name: "update_state",
|
|
9910
|
-
discriminator: [
|
|
9911
|
-
135,
|
|
9912
|
-
112,
|
|
9913
|
-
215,
|
|
9914
|
-
75,
|
|
9915
|
-
247,
|
|
9916
|
-
185,
|
|
9917
|
-
53,
|
|
9918
|
-
176
|
|
9919
|
-
],
|
|
9920
|
-
accounts: [
|
|
9921
|
-
{
|
|
9922
|
-
name: "glam_state",
|
|
10568
|
+
name: "vote",
|
|
9923
10569
|
writable: true
|
|
9924
10570
|
},
|
|
9925
10571
|
{
|
|
9926
|
-
name: "
|
|
9927
|
-
writable: true
|
|
9928
|
-
signer: true
|
|
10572
|
+
name: "recipient",
|
|
10573
|
+
writable: true
|
|
9929
10574
|
}
|
|
9930
10575
|
],
|
|
9931
10576
|
args: [
|
|
9932
10577
|
{
|
|
9933
|
-
name: "
|
|
9934
|
-
type:
|
|
9935
|
-
defined: {
|
|
9936
|
-
name: "StateModel"
|
|
9937
|
-
}
|
|
9938
|
-
}
|
|
10578
|
+
name: "lamports",
|
|
10579
|
+
type: "u64"
|
|
9939
10580
|
}
|
|
9940
10581
|
]
|
|
9941
10582
|
},
|
|
9942
|
-
{
|
|
9943
|
-
name: "update_state_apply_timelock",
|
|
9944
|
-
discriminator: [
|
|
9945
|
-
66,
|
|
9946
|
-
12,
|
|
9947
|
-
138,
|
|
9948
|
-
80,
|
|
9949
|
-
133,
|
|
9950
|
-
85,
|
|
9951
|
-
46,
|
|
9952
|
-
220
|
|
9953
|
-
],
|
|
9954
|
-
accounts: [
|
|
9955
|
-
{
|
|
9956
|
-
name: "glam_state",
|
|
9957
|
-
writable: true
|
|
9958
|
-
},
|
|
9959
|
-
{
|
|
9960
|
-
name: "glam_signer",
|
|
9961
|
-
writable: true,
|
|
9962
|
-
signer: true
|
|
9963
|
-
}
|
|
9964
|
-
],
|
|
9965
|
-
args: []
|
|
9966
|
-
},
|
|
9967
10583
|
{
|
|
9968
10584
|
name: "withdraw",
|
|
9969
10585
|
discriminator: [
|
|
@@ -10211,16 +10827,21 @@ var errors = [
|
|
|
10211
10827
|
},
|
|
10212
10828
|
{
|
|
10213
10829
|
code: 48006,
|
|
10830
|
+
name: "CannotApplyChanges",
|
|
10831
|
+
msg: "Pending changes cannot be applied due to unfulfilled subscriptions or redemptions"
|
|
10832
|
+
},
|
|
10833
|
+
{
|
|
10834
|
+
code: 48007,
|
|
10214
10835
|
name: "AssetNotBorrowable",
|
|
10215
10836
|
msg: "Asset is not allowed to borrow"
|
|
10216
10837
|
},
|
|
10217
10838
|
{
|
|
10218
|
-
code:
|
|
10839
|
+
code: 48008,
|
|
10219
10840
|
name: "InvalidAccountOwner",
|
|
10220
10841
|
msg: "Account owned by an invalid program"
|
|
10221
10842
|
},
|
|
10222
10843
|
{
|
|
10223
|
-
code:
|
|
10844
|
+
code: 48009,
|
|
10224
10845
|
name: "InvalidAuthority",
|
|
10225
10846
|
msg: "Invalid authority"
|
|
10226
10847
|
},
|
|
@@ -10928,7 +11549,7 @@ var types = [
|
|
|
10928
11549
|
name: "MinRedemption"
|
|
10929
11550
|
},
|
|
10930
11551
|
{
|
|
10931
|
-
name: "
|
|
11552
|
+
name: "RedemptionNotifyAndSettle"
|
|
10932
11553
|
},
|
|
10933
11554
|
{
|
|
10934
11555
|
name: "Ledger"
|
|
@@ -10995,6 +11616,12 @@ var types = [
|
|
|
10995
11616
|
},
|
|
10996
11617
|
{
|
|
10997
11618
|
name: "BorrowableAssets"
|
|
11619
|
+
},
|
|
11620
|
+
{
|
|
11621
|
+
name: "DriftVaultsAllowlist"
|
|
11622
|
+
},
|
|
11623
|
+
{
|
|
11624
|
+
name: "KaminoVaultsAllowlist"
|
|
10998
11625
|
}
|
|
10999
11626
|
]
|
|
11000
11627
|
}
|
|
@@ -11781,6 +12408,9 @@ var types = [
|
|
|
11781
12408
|
},
|
|
11782
12409
|
{
|
|
11783
12410
|
name: "KaminoVaults"
|
|
12411
|
+
},
|
|
12412
|
+
{
|
|
12413
|
+
name: "Validator"
|
|
11784
12414
|
}
|
|
11785
12415
|
]
|
|
11786
12416
|
}
|
|
@@ -12366,9 +12996,9 @@ var types = [
|
|
|
12366
12996
|
}
|
|
12367
12997
|
},
|
|
12368
12998
|
{
|
|
12369
|
-
name: "
|
|
12999
|
+
name: "bit_flags",
|
|
12370
13000
|
type: {
|
|
12371
|
-
option: "
|
|
13001
|
+
option: "u8"
|
|
12372
13002
|
}
|
|
12373
13003
|
},
|
|
12374
13004
|
{
|
|
@@ -12663,8 +13293,8 @@ var types = [
|
|
|
12663
13293
|
}
|
|
12664
13294
|
},
|
|
12665
13295
|
{
|
|
12666
|
-
name: "
|
|
12667
|
-
type: "
|
|
13296
|
+
name: "bit_flags",
|
|
13297
|
+
type: "u8"
|
|
12668
13298
|
},
|
|
12669
13299
|
{
|
|
12670
13300
|
name: "max_ts",
|
|
@@ -12822,7 +13452,7 @@ var types = [
|
|
|
12822
13452
|
name: "Unstake"
|
|
12823
13453
|
},
|
|
12824
13454
|
{
|
|
12825
|
-
name: "
|
|
13455
|
+
name: "DriftCancelOrders"
|
|
12826
13456
|
},
|
|
12827
13457
|
{
|
|
12828
13458
|
name: "JupiterSwapAllowlisted"
|
|
@@ -12834,7 +13464,7 @@ var types = [
|
|
|
12834
13464
|
name: "WSol"
|
|
12835
13465
|
},
|
|
12836
13466
|
{
|
|
12837
|
-
name: "
|
|
13467
|
+
name: "DriftClaim"
|
|
12838
13468
|
},
|
|
12839
13469
|
{
|
|
12840
13470
|
name: "MintMintTokens"
|
|
@@ -12913,6 +13543,21 @@ var types = [
|
|
|
12913
13543
|
},
|
|
12914
13544
|
{
|
|
12915
13545
|
name: "KaminoVaultsWithdraw"
|
|
13546
|
+
},
|
|
13547
|
+
{
|
|
13548
|
+
name: "ValidatorAdmin"
|
|
13549
|
+
},
|
|
13550
|
+
{
|
|
13551
|
+
name: "ValidatorWithdraw"
|
|
13552
|
+
},
|
|
13553
|
+
{
|
|
13554
|
+
name: "ValidatorWithdrawToAny"
|
|
13555
|
+
},
|
|
13556
|
+
{
|
|
13557
|
+
name: "ValidatorWithdrawToIdentity"
|
|
13558
|
+
},
|
|
13559
|
+
{
|
|
13560
|
+
name: "Fulfill"
|
|
12916
13561
|
}
|
|
12917
13562
|
]
|
|
12918
13563
|
}
|
|
@@ -13651,6 +14296,22 @@ var types = [
|
|
|
13651
14296
|
option: "u32"
|
|
13652
14297
|
}
|
|
13653
14298
|
},
|
|
14299
|
+
{
|
|
14300
|
+
name: "drift_vaults_allowlist",
|
|
14301
|
+
type: {
|
|
14302
|
+
option: {
|
|
14303
|
+
vec: "pubkey"
|
|
14304
|
+
}
|
|
14305
|
+
}
|
|
14306
|
+
},
|
|
14307
|
+
{
|
|
14308
|
+
name: "kamino_vaults_allowlist",
|
|
14309
|
+
type: {
|
|
14310
|
+
option: {
|
|
14311
|
+
vec: "pubkey"
|
|
14312
|
+
}
|
|
14313
|
+
}
|
|
14314
|
+
},
|
|
13654
14315
|
{
|
|
13655
14316
|
name: "metadata",
|
|
13656
14317
|
type: {
|
|
@@ -13770,6 +14431,20 @@ var types = [
|
|
|
13770
14431
|
]
|
|
13771
14432
|
}
|
|
13772
14433
|
},
|
|
14434
|
+
{
|
|
14435
|
+
name: "VoteAuthorizeEnum",
|
|
14436
|
+
type: {
|
|
14437
|
+
kind: "enum",
|
|
14438
|
+
variants: [
|
|
14439
|
+
{
|
|
14440
|
+
name: "Voter"
|
|
14441
|
+
},
|
|
14442
|
+
{
|
|
14443
|
+
name: "Withdrawer"
|
|
14444
|
+
}
|
|
14445
|
+
]
|
|
14446
|
+
}
|
|
14447
|
+
},
|
|
13773
14448
|
{
|
|
13774
14449
|
name: "WithdrawUnit",
|
|
13775
14450
|
type: {
|
|
@@ -13856,6 +14531,7 @@ const STAKE_ACCOUNT_SIZE = 200;
|
|
|
13856
14531
|
const METEORA_POSITION_SIZE = 8120;
|
|
13857
14532
|
const KAMINO_OBTRIGATION_SIZE = 3344;
|
|
13858
14533
|
const DRIFT_VAULT_DEPOSITOR_SIZE = 272;
|
|
14534
|
+
const JUPITER_API_DEFAULT = "https://lite-api.jup.ag";
|
|
13859
14535
|
const JITO_TIP_DEFAULT = new web3_js.PublicKey("96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5");
|
|
13860
14536
|
const KAMINO_SCOPE_PRICES = new web3_js.PublicKey("3NJYftD5sjVfxSnUdZ1wVML8f3aC6mp1CXCL6L7TnU8C");
|
|
13861
14537
|
const MARINADE_NATIVE_STAKE_AUTHORITY = new web3_js.PublicKey("stWirqFCf2Uts1JBL1Jsd3r6VBWhgnpdPxCTe1MFjrq");
|
|
@@ -13923,6 +14599,8 @@ class StateIdlModel {
|
|
|
13923
14599
|
this.kaminoLendingMarkets = data.kaminoLendingMarkets ?? null;
|
|
13924
14600
|
this.meteoraDlmmPools = data.meteoraDlmmPools ?? null;
|
|
13925
14601
|
this.maxSwapSlippageBps = data.maxSwapSlippageBps ?? null;
|
|
14602
|
+
this.driftVaultsAllowlist = data.driftVaultsAllowlist ?? null;
|
|
14603
|
+
this.kaminoVaultsAllowlist = data.kaminoVaultsAllowlist ?? null;
|
|
13926
14604
|
this.metadata = data.metadata ?? null;
|
|
13927
14605
|
this.rawOpenfunds = data.rawOpenfunds ?? null;
|
|
13928
14606
|
}
|
|
@@ -14274,6 +14952,14 @@ TimeUnit.Slot = {
|
|
|
14274
14952
|
TimeUnit.Second = {
|
|
14275
14953
|
second: {}
|
|
14276
14954
|
};
|
|
14955
|
+
class VoteAuthorize {
|
|
14956
|
+
}
|
|
14957
|
+
VoteAuthorize.Voter = {
|
|
14958
|
+
voter: {}
|
|
14959
|
+
};
|
|
14960
|
+
VoteAuthorize.Withdrawer = {
|
|
14961
|
+
withdrawer: {}
|
|
14962
|
+
};
|
|
14277
14963
|
|
|
14278
14964
|
var ClusterNetwork = /*#__PURE__*/ function(ClusterNetwork) {
|
|
14279
14965
|
ClusterNetwork["Mainnet"] = "mainnet-beta";
|
|
@@ -14283,6 +14969,12 @@ var ClusterNetwork = /*#__PURE__*/ function(ClusterNetwork) {
|
|
|
14283
14969
|
return ClusterNetwork;
|
|
14284
14970
|
}({});
|
|
14285
14971
|
|
|
14972
|
+
const LOOKUP_TABLES_MAP = new Map([
|
|
14973
|
+
[
|
|
14974
|
+
"3tfbxaHBDjczQo3eyNJGGG64ChZ9nG4V3Gywa4k59d5a",
|
|
14975
|
+
new web3_js.PublicKey("8HUXT9abWS2z3z92QyDzg51nMcc18LyWFvaEQZJMPixu")
|
|
14976
|
+
]
|
|
14977
|
+
]);
|
|
14286
14978
|
const findStakeAccounts = async (connection, withdrawAuthority)=>{
|
|
14287
14979
|
// stake authority offset: 12
|
|
14288
14980
|
// withdraw authority offset: 44
|
|
@@ -14388,22 +15080,42 @@ const parseMeteoraPosition = async (connection, position)=>{
|
|
|
14388
15080
|
};
|
|
14389
15081
|
};
|
|
14390
15082
|
async function fetchLookupTables(connection, authority, firstEntry) {
|
|
14391
|
-
new web3_js.PublicKey("AddressLookupTab1e1111111111111111111111111");
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
15083
|
+
const ALT_PROGRAM_ID = new web3_js.PublicKey("AddressLookupTab1e1111111111111111111111111");
|
|
15084
|
+
const tablePubkey = LOOKUP_TABLES_MAP.get(firstEntry.toBase58());
|
|
15085
|
+
if (tablePubkey) {
|
|
15086
|
+
const accountInfo = await connection.getAccountInfo(tablePubkey);
|
|
15087
|
+
if (accountInfo) {
|
|
15088
|
+
return [
|
|
15089
|
+
new web3_js.AddressLookupTableAccount({
|
|
15090
|
+
key: tablePubkey,
|
|
15091
|
+
state: web3_js.AddressLookupTableAccount.deserialize(accountInfo.data)
|
|
15092
|
+
})
|
|
15093
|
+
];
|
|
15094
|
+
}
|
|
15095
|
+
} else {
|
|
15096
|
+
// Fetch all accounts owned by the ALT program
|
|
15097
|
+
// This is currently disabled due to RPC error "Request deprioritized due to number of accounts requested. Slow down requests or add filters to narrow down results"
|
|
15098
|
+
const accounts = await connection.getProgramAccounts(ALT_PROGRAM_ID, {
|
|
15099
|
+
filters: [
|
|
15100
|
+
{
|
|
15101
|
+
memcmp: {
|
|
15102
|
+
offset: 22,
|
|
15103
|
+
bytes: authority.toBase58()
|
|
15104
|
+
}
|
|
15105
|
+
},
|
|
15106
|
+
{
|
|
15107
|
+
memcmp: {
|
|
15108
|
+
offset: 56,
|
|
15109
|
+
bytes: firstEntry.toBase58()
|
|
15110
|
+
}
|
|
15111
|
+
}
|
|
15112
|
+
]
|
|
15113
|
+
});
|
|
15114
|
+
return accounts.map(({ pubkey, account })=>new web3_js.AddressLookupTableAccount({
|
|
15115
|
+
key: pubkey,
|
|
15116
|
+
state: web3_js.AddressLookupTableAccount.deserialize(account.data)
|
|
15117
|
+
}));
|
|
15118
|
+
}
|
|
14407
15119
|
return [];
|
|
14408
15120
|
}
|
|
14409
15121
|
/**
|
|
@@ -14422,8 +15134,8 @@ async function fetchLookupTables(connection, authority, firstEntry) {
|
|
|
14422
15134
|
}
|
|
14423
15135
|
return "Unknown error";
|
|
14424
15136
|
}
|
|
14425
|
-
const
|
|
14426
|
-
const
|
|
15137
|
+
const getSimulationResult = async (connection, instructions, payer, lookupTables)=>{
|
|
15138
|
+
const testIxs = [
|
|
14427
15139
|
// Set an arbitrarily high number in simulation
|
|
14428
15140
|
// so we can be sure the transaction will succeed
|
|
14429
15141
|
// and get the real compute units used
|
|
@@ -14432,19 +15144,30 @@ const getSimulationComputeUnits = async (connection, instructions, payer, lookup
|
|
|
14432
15144
|
}),
|
|
14433
15145
|
...instructions
|
|
14434
15146
|
];
|
|
14435
|
-
const
|
|
14436
|
-
instructions:
|
|
15147
|
+
const testTx = new web3_js.VersionedTransaction(new web3_js.TransactionMessage({
|
|
15148
|
+
instructions: testIxs,
|
|
14437
15149
|
payerKey: payer,
|
|
14438
15150
|
// RecentBlockhash can by any public key during simulation
|
|
14439
15151
|
// since 'replaceRecentBlockhash' is set to 'true' below
|
|
14440
15152
|
recentBlockhash: web3_js.PublicKey.default.toString()
|
|
14441
15153
|
}).compileToV0Message(lookupTables));
|
|
14442
|
-
const
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
15154
|
+
const serializedTx = Buffer.from(testTx.serialize()).toString("base64");
|
|
15155
|
+
try {
|
|
15156
|
+
const rpcResponse = await connection.simulateTransaction(testTx, {
|
|
15157
|
+
replaceRecentBlockhash: true,
|
|
15158
|
+
sigVerify: false
|
|
15159
|
+
});
|
|
15160
|
+
getErrorFromRPCResponse(rpcResponse);
|
|
15161
|
+
return {
|
|
15162
|
+
unitsConsumed: rpcResponse.value.unitsConsumed,
|
|
15163
|
+
serializedTx
|
|
15164
|
+
};
|
|
15165
|
+
} catch (e) {
|
|
15166
|
+
return {
|
|
15167
|
+
error: e,
|
|
15168
|
+
serializedTx
|
|
15169
|
+
};
|
|
15170
|
+
}
|
|
14448
15171
|
};
|
|
14449
15172
|
const getErrorFromRPCResponse = (rpcResponse)=>{
|
|
14450
15173
|
// Note: `confirmTransaction` does not throw an error if the confirmation does not succeed,
|
|
@@ -14798,7 +15521,6 @@ function getAccountPolicyPda(tokenAccount) {
|
|
|
14798
15521
|
], TRANSFER_HOOK_PROGRAM)[0];
|
|
14799
15522
|
}
|
|
14800
15523
|
|
|
14801
|
-
const JUPITER_API_DEFAULT = "https://lite-api.jup.ag";
|
|
14802
15524
|
const DEFAULT_PRIORITY_FEE = 10000; // microLamports
|
|
14803
15525
|
const LOOKUP_TABLES = [
|
|
14804
15526
|
new web3_js.PublicKey("284iwGtA9X9aLy3KsyV8uT2pXLARhYbiSi5SiM2g47M2"),
|
|
@@ -14829,10 +15551,15 @@ class BaseClient {
|
|
|
14829
15551
|
get isMainnet() {
|
|
14830
15552
|
return this.cluster === ClusterNetwork.Mainnet;
|
|
14831
15553
|
}
|
|
14832
|
-
|
|
15554
|
+
isPhantomConnected() {
|
|
14833
15555
|
if (!isBrowser) return false;
|
|
14834
|
-
//
|
|
14835
|
-
|
|
15556
|
+
// Phantom automatically estimates fees
|
|
15557
|
+
// https://docs.phantom.app/developer-powertools/solana-priority-fees#how-phantom-applies-priority-fees-to-dapp-transactions
|
|
15558
|
+
// @ts-ignore
|
|
15559
|
+
const isPhantom = !!window?.phantom?.solana?.isPhantom;
|
|
15560
|
+
// @ts-ignore
|
|
15561
|
+
const isConnected = !!window?.phantom?.solana?.isConnected;
|
|
15562
|
+
return isPhantom && isConnected;
|
|
14836
15563
|
}
|
|
14837
15564
|
/**
|
|
14838
15565
|
* Get metadata of an asset for pricing
|
|
@@ -14850,9 +15577,6 @@ class BaseClient {
|
|
|
14850
15577
|
return assetMeta;
|
|
14851
15578
|
}
|
|
14852
15579
|
async getComputeBudgetIxs(vTx, computeUnitLimit, getPriorityFeeMicroLamports, maxFeeLamports, useMaxFee) {
|
|
14853
|
-
if (this.isPhantom()) {
|
|
14854
|
-
return [];
|
|
14855
|
-
}
|
|
14856
15580
|
// ComputeBudgetProgram.setComputeUnitLimit costs 150 CUs
|
|
14857
15581
|
// Add 20% more CUs to account for variable execution
|
|
14858
15582
|
computeUnitLimit += 150;
|
|
@@ -14897,24 +15621,17 @@ class BaseClient {
|
|
|
14897
15621
|
}
|
|
14898
15622
|
lookupTables.push(...await this.getAdressLookupTableAccounts(LOOKUP_TABLES));
|
|
14899
15623
|
const recentBlockhash = (await this.blockhashWithCache.get()).blockhash;
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
recentBlockhash: web3_js.PublicKey.default.toString()
|
|
14912
|
-
}).compileToV0Message(lookupTables));
|
|
14913
|
-
console.log("Lookup tables:", lookupTables.map((lt)=>lt.key.toString()));
|
|
14914
|
-
console.log("Tx (base64):", Buffer.from(vTx.serialize()).toString("base64"));
|
|
14915
|
-
console.error("Simulation failed. If error message is too obscure, inspect and simulate the tx in explorer: https://explorer.solana.com/tx/inspector");
|
|
14916
|
-
throw e;
|
|
14917
|
-
}
|
|
15624
|
+
const { unitsConsumed, error, serializedTx } = await getSimulationResult(this.provider.connection, instructions, signer, lookupTables);
|
|
15625
|
+
computeUnitLimit = unitsConsumed;
|
|
15626
|
+
// by default, a simulation error doesn't prevent the tx from being sent
|
|
15627
|
+
// - gui: wallet apps usually do the simulation themselves, we should ignore the simulation error here by default
|
|
15628
|
+
// - cli: we should set simulate=true
|
|
15629
|
+
if (error && simulate) {
|
|
15630
|
+
console.log("Lookup tables:", lookupTables.map((lt)=>lt.key.toString()));
|
|
15631
|
+
console.log("Tx (base64):", serializedTx);
|
|
15632
|
+
console.error("Simulation failed:", error.message);
|
|
15633
|
+
console.error("If error message is too obscure, inspect and simulate the tx in explorer: https://explorer.solana.com/tx/inspector");
|
|
15634
|
+
throw error;
|
|
14918
15635
|
}
|
|
14919
15636
|
if (computeUnitLimit) {
|
|
14920
15637
|
const vTx = new web3_js.VersionedTransaction(new web3_js.TransactionMessage({
|
|
@@ -15086,7 +15803,7 @@ class BaseClient {
|
|
|
15086
15803
|
try {
|
|
15087
15804
|
const account = await splToken.getAccount(this.provider.connection, ata, "confirmed", tokenProgram);
|
|
15088
15805
|
return {
|
|
15089
|
-
amount: new anchor.BN(account.amount),
|
|
15806
|
+
amount: new anchor.BN(account.amount.toString()),
|
|
15090
15807
|
uiAmount: Number(account.amount) / Math.pow(10, mint.decimals)
|
|
15091
15808
|
};
|
|
15092
15809
|
} catch (e) {
|
|
@@ -15099,6 +15816,21 @@ class BaseClient {
|
|
|
15099
15816
|
throw e;
|
|
15100
15817
|
}
|
|
15101
15818
|
}
|
|
15819
|
+
async fetchMintsAndTokenPrograms(mintPubkeys) {
|
|
15820
|
+
const connection = this.provider.connection;
|
|
15821
|
+
const accountsInfo = await connection.getMultipleAccountsInfo(mintPubkeys, "confirmed");
|
|
15822
|
+
return accountsInfo.map((info, i)=>{
|
|
15823
|
+
if (!info) {
|
|
15824
|
+
throw new Error(`Mint ${mintPubkeys[i]} not found`);
|
|
15825
|
+
}
|
|
15826
|
+
const tokenProgram = info.owner;
|
|
15827
|
+
const mint = splToken.unpackMint(mintPubkeys[i], info, tokenProgram);
|
|
15828
|
+
return {
|
|
15829
|
+
mint,
|
|
15830
|
+
tokenProgram
|
|
15831
|
+
};
|
|
15832
|
+
});
|
|
15833
|
+
}
|
|
15102
15834
|
async fetchMintAndTokenProgram(mintPubkey) {
|
|
15103
15835
|
const connection = this.provider.connection;
|
|
15104
15836
|
const info = await connection.getAccountInfo(mintPubkey, "confirmed");
|
|
@@ -15128,6 +15860,7 @@ class BaseClient {
|
|
|
15128
15860
|
if (!this.statePda) {
|
|
15129
15861
|
throw new Error("State PDA is not specified");
|
|
15130
15862
|
}
|
|
15863
|
+
// @ts-ignore
|
|
15131
15864
|
const state = await this.fetchStateAccount();
|
|
15132
15865
|
if (state.params.length < 2) {
|
|
15133
15866
|
throw new Error("Invalid mint index");
|
|
@@ -15283,7 +16016,6 @@ class BaseClient {
|
|
|
15283
16016
|
if (config?.statePda) {
|
|
15284
16017
|
this.statePda = config.statePda;
|
|
15285
16018
|
}
|
|
15286
|
-
this.jupiterApi = config?.jupiterApi || JUPITER_API_DEFAULT;
|
|
15287
16019
|
this.blockhashWithCache = new BlockhashWithCache(this.provider, false);
|
|
15288
16020
|
}
|
|
15289
16021
|
}
|
|
@@ -16264,6 +16996,8 @@ function decodeUser(buffer) {
|
|
|
16264
16996
|
};
|
|
16265
16997
|
}
|
|
16266
16998
|
|
|
16999
|
+
const DRIFT_DISTRIBUTOR_PROGRAM = new web3_js.PublicKey("E7HtfkEMhmn9uwL7EFNydcXBWy5WCYN1vFmKKjipEH1x");
|
|
17000
|
+
const DRIFT = new web3_js.PublicKey("DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7");
|
|
16267
17001
|
const DRIFT_SIGNER = new web3_js.PublicKey("JCNCMFXo5M5qwUPg2Utu1u6YWp3MbygxqBsBeXXJfrw");
|
|
16268
17002
|
const DRIFT_MARGIN_PRECISION = 10000;
|
|
16269
17003
|
class DriftClient {
|
|
@@ -16420,7 +17154,7 @@ class DriftClient {
|
|
|
16420
17154
|
// If not, it means some market indexes are invalid and we throw an error
|
|
16421
17155
|
const spotMarkets = marketIndexes.map((marketIndex)=>this.spotMarkets.get(marketIndex)).filter((m)=>m);
|
|
16422
17156
|
const invalidIndexes = marketIndexes.filter((marketIndex)=>!this.spotMarkets.has(marketIndex));
|
|
16423
|
-
if (invalidIndexes.length > 0) {
|
|
17157
|
+
if (invalidIndexes.length > 0 && process.env.NODE_ENV === "development") {
|
|
16424
17158
|
console.warn(`The following spot markets could not be found: ${invalidIndexes.join(", ")}`);
|
|
16425
17159
|
}
|
|
16426
17160
|
return spotMarkets;
|
|
@@ -16470,7 +17204,7 @@ class DriftClient {
|
|
|
16470
17204
|
}
|
|
16471
17205
|
const data = await response.json();
|
|
16472
17206
|
const { orderConstants, perp, spot } = data;
|
|
16473
|
-
// Transform
|
|
17207
|
+
// Transform market data from API to `PerpMarket`/`SpotMarket` objects
|
|
16474
17208
|
const perpMarkets = perp.map((m)=>({
|
|
16475
17209
|
name: m.symbol,
|
|
16476
17210
|
marketIndex: m.marketIndex,
|
|
@@ -16478,10 +17212,6 @@ class DriftClient {
|
|
|
16478
17212
|
oracle: new web3_js.PublicKey(m.oracle),
|
|
16479
17213
|
oracleSource: OracleSource.fromString(m.oracleSource)
|
|
16480
17214
|
}));
|
|
16481
|
-
perpMarkets.forEach((m)=>{
|
|
16482
|
-
this.perpMarkets.set(m.marketIndex, m);
|
|
16483
|
-
});
|
|
16484
|
-
// Transform spot market from API to `SpotMarket` type
|
|
16485
17215
|
const spotMarkets = spot.map((m)=>({
|
|
16486
17216
|
name: m.symbol,
|
|
16487
17217
|
marketIndex: m.marketIndex,
|
|
@@ -16495,6 +17225,10 @@ class DriftClient {
|
|
|
16495
17225
|
cumulativeDepositInterest: new anchor.BN(m.cumulativeDepositInterest),
|
|
16496
17226
|
cumulativeBorrowInterest: new anchor.BN(m.cumulativeBorrowInterest)
|
|
16497
17227
|
}));
|
|
17228
|
+
// Cache market objects
|
|
17229
|
+
perpMarkets.forEach((m)=>{
|
|
17230
|
+
this.perpMarkets.set(m.marketIndex, m);
|
|
17231
|
+
});
|
|
16498
17232
|
spotMarkets.forEach((m)=>{
|
|
16499
17233
|
this.spotMarkets.set(m.marketIndex, m);
|
|
16500
17234
|
});
|
|
@@ -16507,7 +17241,8 @@ class DriftClient {
|
|
|
16507
17241
|
return marketConfigs;
|
|
16508
17242
|
}
|
|
16509
17243
|
// If glam API is not available, fetch market configs from RPC
|
|
16510
|
-
if
|
|
17244
|
+
// Force refetching if skipCache is true
|
|
17245
|
+
if (!this.marketConfigs || skipCache) {
|
|
16511
17246
|
const perpMarkets = await this.fetchAndParsePerpMarkets(Array.from(Array(100).keys()), skipCache);
|
|
16512
17247
|
const spotMarkets = await this.fetchAndParseSpotMarkets(Array.from(Array(100).keys()), skipCache);
|
|
16513
17248
|
this.marketConfigs = {
|
|
@@ -16524,18 +17259,19 @@ class DriftClient {
|
|
|
16524
17259
|
charsToName(chars) {
|
|
16525
17260
|
return String.fromCharCode(...chars).replace(/\0/g, "").trim();
|
|
16526
17261
|
}
|
|
16527
|
-
async
|
|
16528
|
-
const {
|
|
16529
|
-
|
|
16530
|
-
|
|
16531
|
-
|
|
16532
|
-
|
|
16533
|
-
|
|
16534
|
-
|
|
16535
|
-
|
|
17262
|
+
async parseDriftUser(accountInfo, subAccountId) {
|
|
17263
|
+
const { delegate, name, spotPositions, marginMode, perpPositions, isMarginTradingEnabled, maxMarginRatio, orders, poolId } = decodeUser(accountInfo.data);
|
|
17264
|
+
// Fetch spot and perp markets used by this user
|
|
17265
|
+
const spotMarketIndexes = spotPositions.map((p)=>p.marketIndex);
|
|
17266
|
+
const perpMarketIndexes = perpPositions.map((p)=>p.marketIndex);
|
|
17267
|
+
await Promise.all([
|
|
17268
|
+
this.fetchAndParseSpotMarkets(spotMarketIndexes),
|
|
17269
|
+
this.fetchAndParsePerpMarkets(perpMarketIndexes)
|
|
17270
|
+
]);
|
|
17271
|
+
// Extend spot positions with market info
|
|
16536
17272
|
const spotPositionsExt = await Promise.all(spotPositions.map(async (p)=>{
|
|
16537
17273
|
const { amount, uiAmount } = await this.calcSpotBalance(p.marketIndex, p.scaledBalance, p.balanceType);
|
|
16538
|
-
const spotMarket =
|
|
17274
|
+
const spotMarket = this.spotMarkets.get(p.marketIndex);
|
|
16539
17275
|
return {
|
|
16540
17276
|
...p,
|
|
16541
17277
|
amount,
|
|
@@ -16554,9 +17290,39 @@ class DriftClient {
|
|
|
16554
17290
|
marginMode,
|
|
16555
17291
|
subAccountId,
|
|
16556
17292
|
isMarginTradingEnabled,
|
|
16557
|
-
maxMarginRatio
|
|
17293
|
+
maxMarginRatio,
|
|
17294
|
+
poolId
|
|
16558
17295
|
};
|
|
16559
17296
|
}
|
|
17297
|
+
async fetchDriftUser(subAccountId = 0, skipCache = false) {
|
|
17298
|
+
const { user } = this.getDriftUserPdas(subAccountId);
|
|
17299
|
+
const accountInfo = await this.base.provider.connection.getAccountInfo(user);
|
|
17300
|
+
if (!accountInfo) {
|
|
17301
|
+
return null;
|
|
17302
|
+
}
|
|
17303
|
+
// Prefetch market configs
|
|
17304
|
+
await this.fetchMarketConfigs(skipCache);
|
|
17305
|
+
return await this.parseDriftUser(accountInfo, subAccountId);
|
|
17306
|
+
}
|
|
17307
|
+
async fetchDriftUsers(skipCache = false) {
|
|
17308
|
+
const userPdas = Array.from(Array(8).keys()).map((subAccountId)=>{
|
|
17309
|
+
const { user } = this.getDriftUserPdas(subAccountId);
|
|
17310
|
+
return user;
|
|
17311
|
+
});
|
|
17312
|
+
const accountsInfo = await this.base.provider.connection.getMultipleAccountsInfo(userPdas);
|
|
17313
|
+
const subAccountsInfoAndIds = [];
|
|
17314
|
+
accountsInfo.forEach((a, i)=>{
|
|
17315
|
+
if (a) {
|
|
17316
|
+
subAccountsInfoAndIds.push([
|
|
17317
|
+
a,
|
|
17318
|
+
i
|
|
17319
|
+
]);
|
|
17320
|
+
}
|
|
17321
|
+
});
|
|
17322
|
+
// Prefetch market configs
|
|
17323
|
+
await this.fetchMarketConfigs(skipCache);
|
|
17324
|
+
return await Promise.all(subAccountsInfoAndIds.map(([accountInfo, subAccountId])=>this.parseDriftUser(accountInfo, subAccountId)));
|
|
17325
|
+
}
|
|
16560
17326
|
/**
|
|
16561
17327
|
* @deprecated
|
|
16562
17328
|
*/ async fetchPolicyConfig(stateModel) {
|
|
@@ -16616,6 +17382,36 @@ class DriftClient {
|
|
|
16616
17382
|
isSigner: false
|
|
16617
17383
|
})));
|
|
16618
17384
|
}
|
|
17385
|
+
getClaimStatus(claimant, distributor) {
|
|
17386
|
+
const [claimStatus] = web3_js.PublicKey.findProgramAddressSync([
|
|
17387
|
+
Buffer.from("ClaimStatus"),
|
|
17388
|
+
claimant.toBuffer(),
|
|
17389
|
+
distributor.toBuffer()
|
|
17390
|
+
], DRIFT_DISTRIBUTOR_PROGRAM);
|
|
17391
|
+
return claimStatus;
|
|
17392
|
+
}
|
|
17393
|
+
async claim(distributor, amountUnlocked, amountLocked, proof, txOptions = {}) {
|
|
17394
|
+
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
17395
|
+
const vault = this.base.vaultPda;
|
|
17396
|
+
const vaultAta = this.base.getVaultAta(DRIFT);
|
|
17397
|
+
const distributorAta = this.base.getAta(DRIFT, distributor);
|
|
17398
|
+
const preInstructions = [
|
|
17399
|
+
splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, vaultAta, vault, DRIFT)
|
|
17400
|
+
];
|
|
17401
|
+
const tx = await this.base.program.methods.driftDistributorNewClaim(amountUnlocked, amountLocked, proof).accounts({
|
|
17402
|
+
glamState: this.base.statePda,
|
|
17403
|
+
glamSigner,
|
|
17404
|
+
distributor,
|
|
17405
|
+
claimStatus: this.getClaimStatus(vault, distributor),
|
|
17406
|
+
from: distributorAta,
|
|
17407
|
+
to: vaultAta,
|
|
17408
|
+
tokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
17409
|
+
}).preInstructions(preInstructions).transaction();
|
|
17410
|
+
const vTx = await this.base.intoVersionedTransaction(tx, {
|
|
17411
|
+
...txOptions
|
|
17412
|
+
});
|
|
17413
|
+
return await this.base.sendAndConfirm(vTx);
|
|
17414
|
+
}
|
|
16619
17415
|
async initializeUserStatsIx(glamSigner) {
|
|
16620
17416
|
const { userStats } = this.getDriftUserPdas();
|
|
16621
17417
|
// @ts-ignore
|
|
@@ -16650,6 +17446,13 @@ class DriftClient {
|
|
|
16650
17446
|
glamSigner
|
|
16651
17447
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
16652
17448
|
}
|
|
17449
|
+
async updateUserPoolIdIx(subAccountId, poolId) {
|
|
17450
|
+
const { user } = this.getDriftUserPdas(subAccountId);
|
|
17451
|
+
return await this.base.program.methods.driftUpdateUserPoolId(subAccountId, poolId).accounts({
|
|
17452
|
+
glamState: this.base.statePda,
|
|
17453
|
+
user
|
|
17454
|
+
}).instruction();
|
|
17455
|
+
}
|
|
16653
17456
|
async initializeTx(subAccountId = 0, txOptions = {}) {
|
|
16654
17457
|
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
16655
17458
|
const tx = new web3_js.Transaction();
|
|
@@ -16720,13 +17523,23 @@ class DriftClient {
|
|
|
16720
17523
|
async depositTx(amount, marketIndex = 1, subAccountId = 0, txOptions = {}) {
|
|
16721
17524
|
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
16722
17525
|
const { user, userStats } = this.getDriftUserPdas(subAccountId);
|
|
16723
|
-
const { mint, oracle, tokenProgram, marketPda, vault: driftVault } = await this.fetchAndParseSpotMarket(marketIndex);
|
|
17526
|
+
const { mint, oracle, tokenProgram, marketPda, vault: driftVault, name } = await this.fetchAndParseSpotMarket(marketIndex);
|
|
16724
17527
|
console.log(`Spot market ${marketIndex} mint ${mint}, oracle: ${oracle}, marketPda: ${marketPda}, vault: ${driftVault}`);
|
|
16725
17528
|
const preInstructions = [];
|
|
16726
17529
|
const postInstructions = [];
|
|
16727
|
-
// If drift user doesn't exist, prepend
|
|
17530
|
+
// If drift user doesn't exist, prepend initialization ixs
|
|
16728
17531
|
if (!await this.fetchDriftUser(subAccountId)) {
|
|
16729
|
-
preInstructions.push(await this.
|
|
17532
|
+
preInstructions.push(await this.initializeUserIx(glamSigner, subAccountId));
|
|
17533
|
+
// Only add ix to initialize user stats if subAccountId is 0
|
|
17534
|
+
if (subAccountId === 0) {
|
|
17535
|
+
preInstructions.push(await this.initializeUserStatsIx(glamSigner));
|
|
17536
|
+
}
|
|
17537
|
+
// If market name ends with "-N", it means we're depositing to an isolated pool
|
|
17538
|
+
const isolatedPoolMatch = name.match(/-(\d+)$/);
|
|
17539
|
+
if (isolatedPoolMatch) {
|
|
17540
|
+
const poolId = parseInt(isolatedPoolMatch[1]);
|
|
17541
|
+
preInstructions.push(await this.updateUserPoolIdIx(subAccountId, poolId));
|
|
17542
|
+
}
|
|
16730
17543
|
}
|
|
16731
17544
|
if (mint.equals(WSOL)) {
|
|
16732
17545
|
const wrapSolIxs = await this.base.maybeWrapSol(amount, glamSigner);
|
|
@@ -17103,6 +17916,35 @@ class DriftVaultsClient {
|
|
|
17103
17916
|
}
|
|
17104
17917
|
|
|
17105
17918
|
const BASE = new web3_js.PublicKey("bJ1TRoFo2P6UHVwqdiipp6Qhp2HaaHpLowZ5LHet8Gm");
|
|
17919
|
+
const JUPITER_API = process.env.NEXT_PUBLIC_JUPITER_API || process.env.JUPITER_API || JUPITER_API_DEFAULT;
|
|
17920
|
+
async function fetchProgramLabels() {
|
|
17921
|
+
const res = await fetch(`${JUPITER_API}/swap/v1/program-id-to-label`);
|
|
17922
|
+
const data = await res.json();
|
|
17923
|
+
return data;
|
|
17924
|
+
}
|
|
17925
|
+
async function fetchTokenPrices(pubkeys) {
|
|
17926
|
+
const res = await fetch(`${JUPITER_API}/price/v3?ids=${pubkeys.join(",")}`);
|
|
17927
|
+
const data = await res.json();
|
|
17928
|
+
return Object.entries(data).map(([key, val])=>{
|
|
17929
|
+
return {
|
|
17930
|
+
mint: key,
|
|
17931
|
+
price: val.usdPrice
|
|
17932
|
+
};
|
|
17933
|
+
});
|
|
17934
|
+
}
|
|
17935
|
+
async function fetchTokensList() {
|
|
17936
|
+
const response = await fetch(`${JUPITER_API}/tokens/v2/tag?query=verified`);
|
|
17937
|
+
const data = await response.json();
|
|
17938
|
+
const tokenList = data?.map((t)=>({
|
|
17939
|
+
address: t.id,
|
|
17940
|
+
name: t.name,
|
|
17941
|
+
symbol: t.symbol,
|
|
17942
|
+
decimals: t.decimals,
|
|
17943
|
+
logoURI: t.icon,
|
|
17944
|
+
tags: t.tags
|
|
17945
|
+
}));
|
|
17946
|
+
return tokenList;
|
|
17947
|
+
}
|
|
17106
17948
|
class JupiterSwapClient {
|
|
17107
17949
|
/*
|
|
17108
17950
|
* Client methods
|
|
@@ -17114,16 +17956,6 @@ class JupiterSwapClient {
|
|
|
17114
17956
|
const tx = await this.setMaxSwapSlippageTx(slippageBps, txOptions);
|
|
17115
17957
|
return await this.base.sendAndConfirm(tx);
|
|
17116
17958
|
}
|
|
17117
|
-
async fetchProgramLabels() {
|
|
17118
|
-
const res = await fetch(`${this.base.jupiterApi}/swap/v1/program-id-to-label`);
|
|
17119
|
-
const data = await res.json();
|
|
17120
|
-
return data;
|
|
17121
|
-
}
|
|
17122
|
-
async fetchTokenPrices(pubkeys) {
|
|
17123
|
-
const res = await fetch(`${this.base.jupiterApi}/price/v2?ids=${pubkeys.join(",")}`);
|
|
17124
|
-
const data = await res.json();
|
|
17125
|
-
return data;
|
|
17126
|
-
}
|
|
17127
17959
|
/*
|
|
17128
17960
|
* API methods
|
|
17129
17961
|
*/ async swapTx(options, txOptions = {}) {
|
|
@@ -17167,11 +17999,10 @@ class JupiterSwapClient {
|
|
|
17167
17999
|
}
|
|
17168
18000
|
const lookupTables = await this.base.getAdressLookupTableAccounts(addressLookupTableAddresses);
|
|
17169
18001
|
const swapIx = this.toTransactionInstruction(swapInstruction, glamVault.toBase58());
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
]);
|
|
18002
|
+
const [inputTokenProgram, outputTokenProgram] = (await this.base.fetchMintsAndTokenPrograms([
|
|
18003
|
+
inputMint,
|
|
18004
|
+
outputMint
|
|
18005
|
+
])).map((x)=>x.tokenProgram);
|
|
17175
18006
|
const inputStakePool = STAKE_POOLS_MAP.get(inputMint.toBase58())?.poolState || null;
|
|
17176
18007
|
const outputStakePool = STAKE_POOLS_MAP.get(outputMint.toBase58())?.poolState || null;
|
|
17177
18008
|
const preInstructions = await this.getPreInstructions(glamSigner, inputMint, outputMint, amount, inputTokenProgram, outputTokenProgram);
|
|
@@ -17206,7 +18037,7 @@ class JupiterSwapClient {
|
|
|
17206
18037
|
return tx.instructions[0];
|
|
17207
18038
|
}
|
|
17208
18039
|
async getQuoteResponse(quoteParams) {
|
|
17209
|
-
const res = await fetch(`${
|
|
18040
|
+
const res = await fetch(`${JUPITER_API}/swap/v1/quote?` + new URLSearchParams(Object.entries(quoteParams).map(([key, val])=>[
|
|
17210
18041
|
key,
|
|
17211
18042
|
String(val)
|
|
17212
18043
|
])));
|
|
@@ -17217,7 +18048,7 @@ class JupiterSwapClient {
|
|
|
17217
18048
|
return data;
|
|
17218
18049
|
}
|
|
17219
18050
|
async getSwapInstructions(quoteResponse, from) {
|
|
17220
|
-
const res = await fetch(`${
|
|
18051
|
+
const res = await fetch(`${JUPITER_API}/swap/v1/swap-instructions`, {
|
|
17221
18052
|
method: "POST",
|
|
17222
18053
|
headers: {
|
|
17223
18054
|
Accept: "application/json",
|
|
@@ -18305,6 +19136,7 @@ class StateClient {
|
|
|
18305
19136
|
async create(partialStateModel, singleTx = false, txOptions = {}) {
|
|
18306
19137
|
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
18307
19138
|
let stateModel = this.enrichStateModel(partialStateModel);
|
|
19139
|
+
// @ts-ignore
|
|
18308
19140
|
const statePda = getStatePda(stateModel, this.base.program.programId);
|
|
18309
19141
|
this.base.statePda = statePda;
|
|
18310
19142
|
console.log(`State PDA set to GlamClient: ${statePda}`);
|
|
@@ -18586,6 +19418,7 @@ class MintClient {
|
|
|
18586
19418
|
});
|
|
18587
19419
|
}
|
|
18588
19420
|
async update(mintModel, txOptions = {}) {
|
|
19421
|
+
// @ts-ignore
|
|
18589
19422
|
const tx = await this.base.program.methods.updateMint(0, new MintIdlModel(mintModel)).accounts({
|
|
18590
19423
|
glamState: this.base.statePda,
|
|
18591
19424
|
glamMint: this.base.mintPda
|
|
@@ -19390,6 +20223,7 @@ class KaminoLendingClient {
|
|
|
19390
20223
|
const vault = this.base.vaultPda;
|
|
19391
20224
|
const userMetadata = this.getUserMetadataPda(vault);
|
|
19392
20225
|
const lookupTable = new web3_js.PublicKey(0); // FIXME: create lookup table
|
|
20226
|
+
// @ts-ignore
|
|
19393
20227
|
const tx = await this.base.program.methods.kaminoLendingInitUserMetadata(lookupTable).accounts({
|
|
19394
20228
|
glamState: this.base.statePda,
|
|
19395
20229
|
glamSigner,
|
|
@@ -19914,11 +20748,11 @@ class KaminoFarmClient {
|
|
|
19914
20748
|
}
|
|
19915
20749
|
class KaminoVaultsClient {
|
|
19916
20750
|
async deposit(vault, amount, txOptions = {}) {
|
|
19917
|
-
const tx = await this.depositTx(vault, amount, txOptions);
|
|
20751
|
+
const tx = await this.depositTx(vault, new anchor.BN(amount), txOptions);
|
|
19918
20752
|
return await this.base.sendAndConfirm(tx);
|
|
19919
20753
|
}
|
|
19920
20754
|
async withdraw(vault, amount, txOptions = {}) {
|
|
19921
|
-
const tx = await this.withdrawTx(vault, amount, txOptions);
|
|
20755
|
+
const tx = await this.withdrawTx(vault, new anchor.BN(amount), txOptions);
|
|
19922
20756
|
return await this.base.sendAndConfirm(tx);
|
|
19923
20757
|
}
|
|
19924
20758
|
async findAndParseKaminoVaults() {
|
|
@@ -19984,7 +20818,7 @@ class KaminoVaultsClient {
|
|
|
19984
20818
|
async depositTx(vault, amount, txOptions = {}) {
|
|
19985
20819
|
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
19986
20820
|
const vaultState = await this.fetchAndParseVaultState(vault);
|
|
19987
|
-
const amountBN = new anchor.BN(
|
|
20821
|
+
const amountBN = amount.mul(new anchor.BN(10).pow(vaultState.tokenMintDecimals));
|
|
19988
20822
|
const { tokenProgram: sharesTokenProgram } = await this.base.fetchMintAndTokenProgram(vaultState.sharesMint);
|
|
19989
20823
|
const userTokenAta = this.base.getVaultAta(vaultState.tokenMint, vaultState.tokenProgram);
|
|
19990
20824
|
const userSharesAta = this.base.getVaultAta(vaultState.sharesMint, sharesTokenProgram);
|
|
@@ -20019,7 +20853,7 @@ class KaminoVaultsClient {
|
|
|
20019
20853
|
const userTokenAta = this.base.getVaultAta(vaultState.tokenMint, vaultState.tokenProgram);
|
|
20020
20854
|
const { tokenProgram: sharesTokenProgram } = await this.base.fetchMintAndTokenProgram(vaultState.sharesMint);
|
|
20021
20855
|
const userSharesAta = this.base.getVaultAta(vaultState.sharesMint, sharesTokenProgram);
|
|
20022
|
-
const amountBN = new anchor.BN(
|
|
20856
|
+
const amountBN = amount.mul(new anchor.BN(10).pow(vaultState.sharesMintDecimals));
|
|
20023
20857
|
const reserves = vaultState.vaultAllocationStrategy.filter(({ reserve })=>!reserve.equals(web3_js.PublicKey.default));
|
|
20024
20858
|
// Withdraw from the first reserve when kvault does not have enough liquidity
|
|
20025
20859
|
const idx = 0;
|
|
@@ -20300,7 +21134,7 @@ class MeteoraDlmmClient {
|
|
|
20300
21134
|
}
|
|
20301
21135
|
}
|
|
20302
21136
|
|
|
20303
|
-
class
|
|
21137
|
+
class InvestClient {
|
|
20304
21138
|
async subscribe(asset, amount, mintId = 0, queued = false, txOptions = {}) {
|
|
20305
21139
|
const tx = await (queued ? this.queuedSubscribeTx(asset, amount, mintId, txOptions) : this.subscribeTx(asset, amount, mintId, txOptions));
|
|
20306
21140
|
return await this.base.sendAndConfirm(tx);
|
|
@@ -20333,26 +21167,22 @@ class InvestorClient {
|
|
|
20333
21167
|
const glamMint = this.base.mintPda;
|
|
20334
21168
|
const mintTo = this.base.getMintAta(signer);
|
|
20335
21169
|
// asset token to transfer to vault
|
|
20336
|
-
const
|
|
20337
|
-
const vaultInput = this.base.getAta(asset, vault);
|
|
20338
|
-
const signerInput = this.base.getAta(asset, signer);
|
|
21170
|
+
const signerAta = this.base.getAta(asset, signer);
|
|
20339
21171
|
const wrapSolIxs = asset.equals(WSOL) ? [
|
|
20340
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer,
|
|
21172
|
+
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, signerAta, signer, asset),
|
|
20341
21173
|
web3_js.SystemProgram.transfer({
|
|
20342
21174
|
fromPubkey: signer,
|
|
20343
|
-
toPubkey:
|
|
21175
|
+
toPubkey: signerAta,
|
|
20344
21176
|
lamports: amount.toNumber()
|
|
20345
21177
|
}),
|
|
20346
|
-
splToken.createSyncNativeInstruction(
|
|
21178
|
+
splToken.createSyncNativeInstruction(signerAta)
|
|
20347
21179
|
] : [];
|
|
20348
|
-
|
|
20349
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, vaultInput, vault, asset),
|
|
20350
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, mintTo, signer, glamMint, splToken.TOKEN_2022_PROGRAM_ID),
|
|
21180
|
+
const preInstructions = [
|
|
20351
21181
|
...wrapSolIxs,
|
|
20352
21182
|
...txOptions.preInstructions || []
|
|
20353
21183
|
];
|
|
20354
21184
|
const postInstructions = asset.equals(WSOL) ? [
|
|
20355
|
-
splToken.createCloseAccountInstruction(
|
|
21185
|
+
splToken.createCloseAccountInstruction(signerAta, signer, signer)
|
|
20356
21186
|
] : [];
|
|
20357
21187
|
// Check if lockup is enabled on the fund, if so, add signerPolicy
|
|
20358
21188
|
let signerPolicy = null;
|
|
@@ -20366,7 +21196,8 @@ class InvestorClient {
|
|
|
20366
21196
|
glamMint,
|
|
20367
21197
|
signer,
|
|
20368
21198
|
depositAsset: asset,
|
|
20369
|
-
signerPolicy
|
|
21199
|
+
signerPolicy,
|
|
21200
|
+
depositTokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
20370
21201
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
20371
21202
|
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
20372
21203
|
}
|
|
@@ -20376,8 +21207,6 @@ class InvestorClient {
|
|
|
20376
21207
|
}
|
|
20377
21208
|
const signer = txOptions.signer || this.base.getSigner();
|
|
20378
21209
|
// asset token to transfer to escrow
|
|
20379
|
-
const escrow = this.base.escrowPda;
|
|
20380
|
-
const escrowAta = this.base.getAta(asset, escrow);
|
|
20381
21210
|
const signerAta = this.base.getAta(asset, signer);
|
|
20382
21211
|
const wrapSolIxs = asset.equals(WSOL) ? [
|
|
20383
21212
|
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, signerAta, signer, asset),
|
|
@@ -20388,19 +21217,18 @@ class InvestorClient {
|
|
|
20388
21217
|
}),
|
|
20389
21218
|
splToken.createSyncNativeInstruction(signerAta)
|
|
20390
21219
|
] : [];
|
|
20391
|
-
|
|
20392
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, escrowAta, escrow, asset),
|
|
21220
|
+
const preInstructions = [
|
|
20393
21221
|
...wrapSolIxs,
|
|
20394
21222
|
...txOptions.preInstructions || []
|
|
20395
21223
|
];
|
|
20396
21224
|
const postInstructions = asset.equals(WSOL) ? [
|
|
20397
21225
|
splToken.createCloseAccountInstruction(signerAta, signer, signer)
|
|
20398
21226
|
] : [];
|
|
20399
|
-
// @ts-ignore
|
|
20400
21227
|
const tx = await this.base.program.methods.queuedSubscribe(0, amount).accounts({
|
|
20401
21228
|
glamState: this.base.statePda,
|
|
20402
21229
|
signer,
|
|
20403
|
-
depositAsset: asset
|
|
21230
|
+
depositAsset: asset,
|
|
21231
|
+
depositTokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
20404
21232
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
20405
21233
|
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
20406
21234
|
}
|
|
@@ -20410,9 +21238,6 @@ class InvestorClient {
|
|
|
20410
21238
|
}
|
|
20411
21239
|
const signer = txOptions.signer || this.base.getSigner();
|
|
20412
21240
|
const glamMint = this.base.mintPda;
|
|
20413
|
-
const preInstructions = [
|
|
20414
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, this.base.getMintAta(signer), signer, glamMint, splToken.TOKEN_2022_PROGRAM_ID)
|
|
20415
|
-
];
|
|
20416
21241
|
const remainingAccounts = [];
|
|
20417
21242
|
if (await this.base.isLockupEnabled()) {
|
|
20418
21243
|
const extraMetasAccount = this.base.extraMetasPda;
|
|
@@ -20430,7 +21255,7 @@ class InvestorClient {
|
|
|
20430
21255
|
glamState: this.base.statePda,
|
|
20431
21256
|
glamMint,
|
|
20432
21257
|
signer
|
|
20433
|
-
}).
|
|
21258
|
+
}).remainingAccounts(remainingAccounts.map((pubkey)=>({
|
|
20434
21259
|
pubkey,
|
|
20435
21260
|
isSigner: false,
|
|
20436
21261
|
isWritable: false
|
|
@@ -20444,24 +21269,14 @@ class InvestorClient {
|
|
|
20444
21269
|
const signer = txOptions.signer || this.base.getSigner();
|
|
20445
21270
|
const stateModel = await this.base.fetchStateModel();
|
|
20446
21271
|
const baseAsset = stateModel.baseAsset;
|
|
20447
|
-
const vault = this.base.vaultPda;
|
|
20448
|
-
const vaultAssetAta = this.base.getAta(baseAsset, vault);
|
|
20449
21272
|
const glamMint = this.base.mintPda;
|
|
20450
|
-
const escrow = this.base.escrowPda;
|
|
20451
|
-
const escrowMintAta = this.base.getMintAta(escrow);
|
|
20452
|
-
const escrowAssetAta = this.base.getAta(baseAsset, escrow);
|
|
20453
|
-
let preInstructions = [
|
|
20454
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, escrowMintAta, escrow, glamMint, splToken.TOKEN_2022_PROGRAM_ID),
|
|
20455
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, escrowAssetAta, escrow, baseAsset),
|
|
20456
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, vaultAssetAta, vault, baseAsset),
|
|
20457
|
-
...txOptions.preInstructions || []
|
|
20458
|
-
];
|
|
20459
21273
|
const tx = await this.base.program.methods.fulfill(mintId).accounts({
|
|
20460
21274
|
glamState: this.base.statePda,
|
|
20461
21275
|
glamMint,
|
|
20462
21276
|
signer,
|
|
20463
|
-
asset: baseAsset
|
|
20464
|
-
|
|
21277
|
+
asset: baseAsset,
|
|
21278
|
+
depositTokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
21279
|
+
}).preInstructions(txOptions.preInstructions || []).transaction();
|
|
20465
21280
|
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
20466
21281
|
}
|
|
20467
21282
|
async claimAssetTx(asset, mintId = 0, txOptions = {}) {
|
|
@@ -20469,7 +21284,6 @@ class InvestorClient {
|
|
|
20469
21284
|
throw new Error("mintId must be 0");
|
|
20470
21285
|
}
|
|
20471
21286
|
const signer = txOptions.signer || this.base.getSigner();
|
|
20472
|
-
this.base.mintPda;
|
|
20473
21287
|
const signerAta = this.base.getAta(asset, signer);
|
|
20474
21288
|
// Close wSOL ata so user gets SOL
|
|
20475
21289
|
const postInstructions = asset.equals(WSOL) ? [
|
|
@@ -20479,7 +21293,7 @@ class InvestorClient {
|
|
|
20479
21293
|
glamState: this.base.statePda,
|
|
20480
21294
|
signer,
|
|
20481
21295
|
tokenMint: asset,
|
|
20482
|
-
|
|
21296
|
+
claimTokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
20483
21297
|
}).preInstructions([
|
|
20484
21298
|
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, signerAta, signer, asset)
|
|
20485
21299
|
]).postInstructions(postInstructions).transaction();
|
|
@@ -20490,8 +21304,6 @@ class InvestorClient {
|
|
|
20490
21304
|
throw new Error("mintId must be 0");
|
|
20491
21305
|
}
|
|
20492
21306
|
const signer = txOptions.signer || this.base.getSigner();
|
|
20493
|
-
this.base.mintPda;
|
|
20494
|
-
const signerAta = this.base.getAta(asset, signer, splToken.TOKEN_2022_PROGRAM_ID);
|
|
20495
21307
|
const escrow = this.base.escrowPda;
|
|
20496
21308
|
const remainingAccounts = [];
|
|
20497
21309
|
if (await this.base.isLockupEnabled()) {
|
|
@@ -20509,10 +21321,8 @@ class InvestorClient {
|
|
|
20509
21321
|
glamState: this.base.statePda,
|
|
20510
21322
|
signer,
|
|
20511
21323
|
tokenMint: asset,
|
|
20512
|
-
|
|
20513
|
-
}).
|
|
20514
|
-
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, signerAta, signer, asset, splToken.TOKEN_2022_PROGRAM_ID)
|
|
20515
|
-
]).remainingAccounts(remainingAccounts.map((pubkey)=>({
|
|
21324
|
+
claimTokenProgram: splToken.TOKEN_2022_PROGRAM_ID
|
|
21325
|
+
}).remainingAccounts(remainingAccounts.map((pubkey)=>({
|
|
20516
21326
|
pubkey,
|
|
20517
21327
|
isSigner: false,
|
|
20518
21328
|
isWritable: false
|
|
@@ -20554,6 +21364,7 @@ class PriceClient {
|
|
|
20554
21364
|
isSigner: false,
|
|
20555
21365
|
isWritable: true
|
|
20556
21366
|
}));
|
|
21367
|
+
// @ts-ignore
|
|
20557
21368
|
const priceIx = await this.base.program.methods.priceKaminoObligations(priceDenom).accounts({
|
|
20558
21369
|
glamState: this.base.statePda,
|
|
20559
21370
|
solOracle: SOL_ORACLE,
|
|
@@ -20605,33 +21416,62 @@ class PriceClient {
|
|
|
20605
21416
|
return priceIx;
|
|
20606
21417
|
}
|
|
20607
21418
|
/**
|
|
20608
|
-
* Returns an instruction that prices
|
|
20609
|
-
* These Drift users must share the same user_stats that's also controlled by the GLAM vault.
|
|
21419
|
+
* Returns an instruction that prices all Drift users (aka sub-accounts) controlled by the GLAM vault.
|
|
20610
21420
|
*/ async priceDriftUsersIx(priceDenom) {
|
|
20611
|
-
//
|
|
20612
|
-
const {
|
|
20613
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20616
|
-
|
|
20617
|
-
|
|
20618
|
-
}
|
|
20619
|
-
|
|
20620
|
-
|
|
20621
|
-
|
|
20622
|
-
|
|
20623
|
-
|
|
20624
|
-
|
|
20625
|
-
|
|
21421
|
+
// 1st remaining account is user_stats
|
|
21422
|
+
const { userStats } = this.drift.getDriftUserPdas();
|
|
21423
|
+
const remainingAccounts = [
|
|
21424
|
+
{
|
|
21425
|
+
pubkey: userStats,
|
|
21426
|
+
isSigner: false,
|
|
21427
|
+
isWritable: false
|
|
21428
|
+
}
|
|
21429
|
+
];
|
|
21430
|
+
// Fetch first 8 sub accounts
|
|
21431
|
+
const userPdas = Array.from(Array(8).keys()).map((subAccountId)=>{
|
|
21432
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
21433
|
+
return user;
|
|
21434
|
+
});
|
|
21435
|
+
const accountsInfo = await this.base.provider.connection.getMultipleAccountsInfo(userPdas);
|
|
21436
|
+
// Parse valid sub accounts
|
|
21437
|
+
const driftUsers = [];
|
|
21438
|
+
for(let i = 0; i < accountsInfo.length; i++){
|
|
21439
|
+
const accountInfo = accountsInfo[i];
|
|
21440
|
+
if (accountInfo) {
|
|
21441
|
+
const user = await this.drift.parseDriftUser(accountInfo, i);
|
|
21442
|
+
driftUsers.push(user);
|
|
21443
|
+
remainingAccounts.push({
|
|
21444
|
+
pubkey: userPdas[i],
|
|
20626
21445
|
isSigner: false,
|
|
20627
21446
|
isWritable: false
|
|
20628
|
-
}
|
|
20629
|
-
|
|
20630
|
-
]).instruction();
|
|
20631
|
-
return priceDriftUsersIx;
|
|
20632
|
-
} catch (error) {
|
|
20633
|
-
return null;
|
|
21447
|
+
});
|
|
21448
|
+
}
|
|
20634
21449
|
}
|
|
21450
|
+
// Build a set of markets and oracles that are used by all sub accounts
|
|
21451
|
+
const marketsAndOracles = new Set();
|
|
21452
|
+
const spotMarketIndexes = new Set(driftUsers.map((u)=>u.spotPositions.map((p)=>p.marketIndex)).flat());
|
|
21453
|
+
const perpMarketIndexes = new Set(driftUsers.map((u)=>u.perpPositions.map((p)=>p.marketIndex)).flat());
|
|
21454
|
+
const spotMarkets = await this.drift.fetchAndParseSpotMarkets(Array.from(spotMarketIndexes));
|
|
21455
|
+
const perpMarkets = await this.drift.fetchAndParsePerpMarkets(Array.from(perpMarketIndexes));
|
|
21456
|
+
spotMarkets.forEach((m)=>{
|
|
21457
|
+
marketsAndOracles.add(m.oracle.toBase58());
|
|
21458
|
+
marketsAndOracles.add(m.marketPda.toBase58());
|
|
21459
|
+
});
|
|
21460
|
+
perpMarkets.forEach((m)=>{
|
|
21461
|
+
marketsAndOracles.add(m.oracle.toBase58());
|
|
21462
|
+
marketsAndOracles.add(m.marketPda.toBase58());
|
|
21463
|
+
});
|
|
21464
|
+
// Add markets and oracles to remaining accounts
|
|
21465
|
+
Array.from(marketsAndOracles).map((pubkey)=>remainingAccounts.push({
|
|
21466
|
+
pubkey: new web3_js.PublicKey(pubkey),
|
|
21467
|
+
isSigner: false,
|
|
21468
|
+
isWritable: false
|
|
21469
|
+
}));
|
|
21470
|
+
const priceDriftUsersIx = await this.base.program.methods.priceDriftUsers(priceDenom, driftUsers.length).accounts({
|
|
21471
|
+
glamState: this.base.statePda,
|
|
21472
|
+
solOracle: SOL_ORACLE
|
|
21473
|
+
}).remainingAccounts(remainingAccounts).instruction();
|
|
21474
|
+
return priceDriftUsersIx;
|
|
20635
21475
|
}
|
|
20636
21476
|
/**
|
|
20637
21477
|
* Returns an instruction that prices a drift vault depositor.
|
|
@@ -20648,23 +21488,36 @@ class PriceClient {
|
|
|
20648
21488
|
// - oracles
|
|
20649
21489
|
// - spot & perp markets
|
|
20650
21490
|
// There might be overlaps between markets and oracles so we use a set to avoid duplicates
|
|
20651
|
-
const
|
|
21491
|
+
const remainingAccounts = [];
|
|
21492
|
+
const marketsAndOracles = new Set();
|
|
20652
21493
|
for (const depositor of parsedVaultDepositors){
|
|
20653
|
-
remainingAccountsKeys.add(depositor.address.toBase58());
|
|
20654
|
-
remainingAccountsKeys.add(depositor.driftVault.toBase58());
|
|
20655
21494
|
const { user: driftUser } = await this.dvaults.parseDriftVault(depositor.driftVault);
|
|
20656
|
-
|
|
21495
|
+
remainingAccounts.push({
|
|
21496
|
+
pubkey: depositor.address,
|
|
21497
|
+
isSigner: false,
|
|
21498
|
+
isWritable: false
|
|
21499
|
+
});
|
|
21500
|
+
remainingAccounts.push({
|
|
21501
|
+
pubkey: depositor.driftVault,
|
|
21502
|
+
isSigner: false,
|
|
21503
|
+
isWritable: false
|
|
21504
|
+
});
|
|
21505
|
+
remainingAccounts.push({
|
|
21506
|
+
pubkey: driftUser,
|
|
21507
|
+
isSigner: false,
|
|
21508
|
+
isWritable: false
|
|
21509
|
+
});
|
|
20657
21510
|
const markets_and_oracles = (await this.dvaults.composeRemainingAccounts(driftUser)).map((a)=>a.pubkey.toBase58());
|
|
20658
21511
|
for (const k of markets_and_oracles){
|
|
20659
|
-
|
|
21512
|
+
marketsAndOracles.add(k);
|
|
20660
21513
|
}
|
|
20661
21514
|
}
|
|
20662
|
-
|
|
21515
|
+
Array.from(marketsAndOracles).forEach((k)=>remainingAccounts.push({
|
|
20663
21516
|
pubkey: new web3_js.PublicKey(k),
|
|
20664
21517
|
isSigner: false,
|
|
20665
21518
|
isWritable: false
|
|
20666
21519
|
}));
|
|
20667
|
-
const priceIx = await this.base.program.methods.priceDriftVaultDepositors(priceDenom).accounts({
|
|
21520
|
+
const priceIx = await this.base.program.methods.priceDriftVaultDepositors(priceDenom, parsedVaultDepositors.length).accounts({
|
|
20668
21521
|
glamState: this.base.statePda,
|
|
20669
21522
|
solOracle: SOL_ORACLE
|
|
20670
21523
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
@@ -20729,19 +21582,22 @@ class PriceClient {
|
|
|
20729
21582
|
priceVaultIx
|
|
20730
21583
|
];
|
|
20731
21584
|
}
|
|
20732
|
-
const
|
|
20733
|
-
const
|
|
20734
|
-
|
|
20735
|
-
|
|
20736
|
-
|
|
20737
|
-
|
|
20738
|
-
|
|
20739
|
-
|
|
20740
|
-
|
|
20741
|
-
|
|
20742
|
-
|
|
20743
|
-
|
|
20744
|
-
|
|
21585
|
+
const integrations = (stateModel.integrations || []).map((i)=>Object.keys(i)[0]);
|
|
21586
|
+
const integrationsToPricingFns = {
|
|
21587
|
+
drift: this.priceDriftUsersIx.bind(this),
|
|
21588
|
+
kaminoLending: this.priceKaminoObligationsIx.bind(this),
|
|
21589
|
+
nativeStaking: this.priceStakesIx.bind(this),
|
|
21590
|
+
meteoraDlmm: this.priceMeteoraPositionsIx.bind(this),
|
|
21591
|
+
driftVaults: this.priceDriftVaultDepositorsIx.bind(this),
|
|
21592
|
+
kaminoVaults: this.priceKaminoVaultSharesIx.bind(this)
|
|
21593
|
+
};
|
|
21594
|
+
const pricingFns = integrations.map((integration)=>integrationsToPricingFns[integration]).filter(Boolean);
|
|
21595
|
+
const pricingIxs = [];
|
|
21596
|
+
for (const fn of pricingFns){
|
|
21597
|
+
const ix = await fn(priceDenom);
|
|
21598
|
+
pricingIxs.push(ix);
|
|
21599
|
+
}
|
|
21600
|
+
return pricingIxs.filter(Boolean);
|
|
20745
21601
|
}
|
|
20746
21602
|
constructor(base, klend, kvaults, drift, dvaults){
|
|
20747
21603
|
this.base = base;
|
|
@@ -20808,6 +21664,116 @@ class PriceClient {
|
|
|
20808
21664
|
}
|
|
20809
21665
|
}
|
|
20810
21666
|
|
|
21667
|
+
class ValidatorClient {
|
|
21668
|
+
/**
|
|
21669
|
+
* Authorize a new authority for the vote account.
|
|
21670
|
+
*/ async voteAuthorize(vote, newAuthority, voteAuthorize, txOptions = {}) {
|
|
21671
|
+
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
21672
|
+
// @ts-ignore
|
|
21673
|
+
const tx = await this.base.program.methods.voteAuthorize(newAuthority, voteAuthorize).accounts({
|
|
21674
|
+
glamState: this.base.statePda,
|
|
21675
|
+
glamSigner,
|
|
21676
|
+
vote
|
|
21677
|
+
}).transaction();
|
|
21678
|
+
return await this.base.sendAndConfirm(await this.base.intoVersionedTransaction(tx, txOptions));
|
|
21679
|
+
}
|
|
21680
|
+
/**
|
|
21681
|
+
* Update the validator identity for the vote account.
|
|
21682
|
+
*/ async voteUpdateValidatorIdentity(vote, identity, txOptions = {}) {
|
|
21683
|
+
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
21684
|
+
const tx = await this.base.program.methods.voteUpdateValidatorIdentity().accounts({
|
|
21685
|
+
glamState: this.base.statePda,
|
|
21686
|
+
glamSigner,
|
|
21687
|
+
vote,
|
|
21688
|
+
identity: identity.publicKey
|
|
21689
|
+
}).transaction();
|
|
21690
|
+
return await this.base.sendAndConfirm(await this.base.intoVersionedTransaction(tx, txOptions), [
|
|
21691
|
+
identity
|
|
21692
|
+
]);
|
|
21693
|
+
}
|
|
21694
|
+
/**
|
|
21695
|
+
* Update the commission for the vote account.
|
|
21696
|
+
*/ async voteUpdateCommission(vote, newCommission, txOptions = {}) {
|
|
21697
|
+
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
21698
|
+
const tx = await this.base.program.methods.voteUpdateCommission(newCommission).accounts({
|
|
21699
|
+
glamState: this.base.statePda,
|
|
21700
|
+
glamSigner,
|
|
21701
|
+
vote
|
|
21702
|
+
}).transaction();
|
|
21703
|
+
return await this.base.sendAndConfirm(await this.base.intoVersionedTransaction(tx, txOptions));
|
|
21704
|
+
}
|
|
21705
|
+
/**
|
|
21706
|
+
* Withdraw lamports from the vote account to a recipient.
|
|
21707
|
+
*/ async voteWithdraw(vote, recipient, lamports, txOptions = {}) {
|
|
21708
|
+
const glamSigner = txOptions.signer || this.base.getSigner();
|
|
21709
|
+
const tx = await this.base.program.methods.voteWithdraw(new anchor.BN(lamports)).accounts({
|
|
21710
|
+
glamState: this.base.statePda,
|
|
21711
|
+
glamSigner,
|
|
21712
|
+
vote,
|
|
21713
|
+
recipient
|
|
21714
|
+
}).transaction();
|
|
21715
|
+
return await this.base.sendAndConfirm(await this.base.intoVersionedTransaction(tx, txOptions));
|
|
21716
|
+
}
|
|
21717
|
+
constructor(base){
|
|
21718
|
+
this.base = base;
|
|
21719
|
+
}
|
|
21720
|
+
}
|
|
21721
|
+
|
|
21722
|
+
class FeesClient {
|
|
21723
|
+
async crystallizeFees(txOptions = {}) {
|
|
21724
|
+
const stateModel = await this.base.fetchStateModel();
|
|
21725
|
+
const { baseAsset } = stateModel;
|
|
21726
|
+
if (!baseAsset) {
|
|
21727
|
+
throw new Error("Base asset not found");
|
|
21728
|
+
}
|
|
21729
|
+
const priceVaultIxs = await this.price.priceVaultIxs(PriceDenom.fromAsset(baseAsset));
|
|
21730
|
+
const tx = await this.base.program.methods.crystallizeFees(0).accounts({
|
|
21731
|
+
glamState: this.base.statePda,
|
|
21732
|
+
glamMint: this.base.mintPda
|
|
21733
|
+
}).preInstructions(priceVaultIxs).transaction();
|
|
21734
|
+
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
21735
|
+
return await this.base.sendAndConfirm(vTx);
|
|
21736
|
+
}
|
|
21737
|
+
async disburseFees(txOptions = {}) {
|
|
21738
|
+
const signer = txOptions.signer || this.base.getSigner();
|
|
21739
|
+
const stateModel = await this.base.fetchStateModel();
|
|
21740
|
+
const { baseAsset } = stateModel;
|
|
21741
|
+
if (!baseAsset) {
|
|
21742
|
+
throw new Error("Base asset not found");
|
|
21743
|
+
}
|
|
21744
|
+
// TODO: parse from glam config account
|
|
21745
|
+
const protocolFeeAuthority = new web3_js.PublicKey("gLJHKPrZLGBiBZ33hFgZh6YnsEhTVxuRT17UCqNp6ff");
|
|
21746
|
+
const managerFeeAuthority = stateModel?.owner?.pubkey;
|
|
21747
|
+
if (!managerFeeAuthority) {
|
|
21748
|
+
throw new Error("Manager fee authority not found");
|
|
21749
|
+
}
|
|
21750
|
+
const { tokenProgram } = await this.base.fetchMintAndTokenProgram(baseAsset);
|
|
21751
|
+
const protocolFeeAuthorityAta = this.base.getAta(baseAsset, protocolFeeAuthority, tokenProgram);
|
|
21752
|
+
const managerFeeAuthorityAta = this.base.getAta(baseAsset, managerFeeAuthority, tokenProgram);
|
|
21753
|
+
const priceVaultIxs = await this.price.priceVaultIxs(PriceDenom.fromAsset(baseAsset));
|
|
21754
|
+
const preInstructions = [
|
|
21755
|
+
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, protocolFeeAuthorityAta, protocolFeeAuthority, baseAsset, tokenProgram),
|
|
21756
|
+
splToken.createAssociatedTokenAccountIdempotentInstruction(signer, managerFeeAuthorityAta, managerFeeAuthority, baseAsset, tokenProgram),
|
|
21757
|
+
...priceVaultIxs
|
|
21758
|
+
];
|
|
21759
|
+
const tx = await this.base.program.methods.disburseFees(0).accounts({
|
|
21760
|
+
glamState: this.base.statePda,
|
|
21761
|
+
glamMint: this.base.mintPda,
|
|
21762
|
+
// @ts-ignore
|
|
21763
|
+
protocolFeeAuthorityAta,
|
|
21764
|
+
managerFeeAuthorityAta,
|
|
21765
|
+
depositAsset: baseAsset,
|
|
21766
|
+
depositTokenProgram: tokenProgram
|
|
21767
|
+
}).preInstructions(preInstructions).transaction();
|
|
21768
|
+
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
21769
|
+
return await this.base.sendAndConfirm(vTx);
|
|
21770
|
+
}
|
|
21771
|
+
constructor(base, price){
|
|
21772
|
+
this.base = base;
|
|
21773
|
+
this.price = price;
|
|
21774
|
+
}
|
|
21775
|
+
}
|
|
21776
|
+
|
|
20811
21777
|
/**
|
|
20812
21778
|
* Main entrypoint for the GLAM SDK
|
|
20813
21779
|
*
|
|
@@ -20825,11 +21791,17 @@ class PriceClient {
|
|
|
20825
21791
|
}
|
|
20826
21792
|
return this._driftVaults;
|
|
20827
21793
|
}
|
|
20828
|
-
get
|
|
20829
|
-
if (!this.
|
|
20830
|
-
this.
|
|
21794
|
+
get invest() {
|
|
21795
|
+
if (!this._invest) {
|
|
21796
|
+
this._invest = new InvestClient(this);
|
|
20831
21797
|
}
|
|
20832
|
-
return this.
|
|
21798
|
+
return this._invest;
|
|
21799
|
+
}
|
|
21800
|
+
get fees() {
|
|
21801
|
+
if (!this._fees) {
|
|
21802
|
+
this._fees = new FeesClient(this, this.price);
|
|
21803
|
+
}
|
|
21804
|
+
return this._fees;
|
|
20833
21805
|
}
|
|
20834
21806
|
get jupiterSwap() {
|
|
20835
21807
|
if (!this._jupiterSwap) {
|
|
@@ -20903,6 +21875,12 @@ class PriceClient {
|
|
|
20903
21875
|
}
|
|
20904
21876
|
return this._meteoraDlmm;
|
|
20905
21877
|
}
|
|
21878
|
+
get validator() {
|
|
21879
|
+
if (!this._validator) {
|
|
21880
|
+
this._validator = new ValidatorClient(this);
|
|
21881
|
+
}
|
|
21882
|
+
return this._validator;
|
|
21883
|
+
}
|
|
20906
21884
|
constructor(config){
|
|
20907
21885
|
super(config);
|
|
20908
21886
|
}
|
|
@@ -21082,11 +22060,15 @@ exports.TradeSide = TradeSide;
|
|
|
21082
22060
|
exports.USDC = USDC;
|
|
21083
22061
|
exports.USDC_ORACLE = USDC_ORACLE;
|
|
21084
22062
|
exports.UserStatus = UserStatus;
|
|
22063
|
+
exports.VoteAuthorize = VoteAuthorize;
|
|
21085
22064
|
exports.WSOL = WSOL;
|
|
21086
22065
|
exports.ZERO = ZERO;
|
|
21087
22066
|
exports.decodeUser = decodeUser;
|
|
21088
22067
|
exports.fetchLookupTables = fetchLookupTables;
|
|
21089
22068
|
exports.fetchMeteoraPositions = fetchMeteoraPositions;
|
|
22069
|
+
exports.fetchProgramLabels = fetchProgramLabels;
|
|
22070
|
+
exports.fetchTokenPrices = fetchTokenPrices;
|
|
22071
|
+
exports.fetchTokensList = fetchTokensList;
|
|
21090
22072
|
exports.findStakeAccounts = findStakeAccounts;
|
|
21091
22073
|
exports.getAccountPolicyPda = getAccountPolicyPda;
|
|
21092
22074
|
exports.getEscrowPda = getEscrowPda;
|
|
@@ -21099,7 +22081,7 @@ exports.getMintPda = getMintPda;
|
|
|
21099
22081
|
exports.getOpenfundsPda = getOpenfundsPda;
|
|
21100
22082
|
exports.getOrderParams = getOrderParams;
|
|
21101
22083
|
exports.getPriorityFeeEstimate = getPriorityFeeEstimate;
|
|
21102
|
-
exports.
|
|
22084
|
+
exports.getSimulationResult = getSimulationResult;
|
|
21103
22085
|
exports.getStakeAccountsWithStates = getStakeAccountsWithStates;
|
|
21104
22086
|
exports.getStatePda = getStatePda;
|
|
21105
22087
|
exports.getTriggerLimitOrderParams = getTriggerLimitOrderParams;
|