@wireio/stake 0.7.3 → 0.9.0
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/lib/stake.browser.js +390 -795
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +132 -542
- package/lib/stake.js +390 -797
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +390 -795
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/solana/idl/liqsol_core.json +114 -377
- package/src/assets/solana/idl/validator_leaderboard.json +0 -146
- package/src/assets/solana/types/liqsol_core.ts +114 -377
- package/src/assets/solana/types/validator_leaderboard.ts +0 -146
- package/src/networks/ethereum/clients/opp.client.ts +20 -21
- package/src/networks/ethereum/clients/receipt.client.ts +8 -1
- package/src/networks/ethereum/contract.ts +40 -5
- package/src/networks/ethereum/ethereum.ts +148 -139
- package/src/networks/ethereum/types.ts +1 -2
- package/src/networks/solana/constants.ts +1 -1
- package/src/networks/solana/solana.ts +268 -220
- package/src/staker.ts +1 -1
package/lib/stake.js
CHANGED
|
@@ -14,68 +14,6 @@ var metadata$3 = {
|
|
|
14
14
|
description: "Created with Anchor"
|
|
15
15
|
};
|
|
16
16
|
var instructions$3 = [
|
|
17
|
-
{
|
|
18
|
-
name: "accumulate_unstake_request",
|
|
19
|
-
docs: [
|
|
20
|
-
"Accumulate unstake requests to be processed in next allocation cycle",
|
|
21
|
-
"Multiple requests can be accumulated before calculating allocations",
|
|
22
|
-
"Returns the target epoch when this unstake request will be processed",
|
|
23
|
-
"We should not be able to call this without development feature enabled",
|
|
24
|
-
""
|
|
25
|
-
],
|
|
26
|
-
discriminator: [
|
|
27
|
-
24,
|
|
28
|
-
73,
|
|
29
|
-
69,
|
|
30
|
-
139,
|
|
31
|
-
36,
|
|
32
|
-
209,
|
|
33
|
-
105,
|
|
34
|
-
252
|
|
35
|
-
],
|
|
36
|
-
accounts: [
|
|
37
|
-
{
|
|
38
|
-
name: "admin",
|
|
39
|
-
writable: true,
|
|
40
|
-
signer: true
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "stake_allocation_state",
|
|
44
|
-
docs: [
|
|
45
|
-
"Stake allocation state - to accumulate pending unstake requests"
|
|
46
|
-
],
|
|
47
|
-
writable: true
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "stake_metrics",
|
|
51
|
-
docs: [
|
|
52
|
-
"Stake metrics - to validate total unstake amount is available"
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: "maintenance_ledger",
|
|
57
|
-
docs: [
|
|
58
|
-
"Maintenance ledger - to determine target processing epoch"
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: "global_config",
|
|
63
|
-
docs: [
|
|
64
|
-
"Global config for min_unstake_request setting"
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "clock"
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
args: [
|
|
72
|
-
{
|
|
73
|
-
name: "amount",
|
|
74
|
-
type: "u64"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
returns: "u64"
|
|
78
|
-
},
|
|
79
17
|
{
|
|
80
18
|
name: "add_top_performers_batch",
|
|
81
19
|
docs: [
|
|
@@ -129,74 +67,6 @@ var instructions$3 = [
|
|
|
129
67
|
args: [
|
|
130
68
|
]
|
|
131
69
|
},
|
|
132
|
-
{
|
|
133
|
-
name: "add_validator_v2",
|
|
134
|
-
docs: [
|
|
135
|
-
"Add a new validator bbypassing the looking at leaderboard and getting validators form there"
|
|
136
|
-
],
|
|
137
|
-
discriminator: [
|
|
138
|
-
217,
|
|
139
|
-
158,
|
|
140
|
-
30,
|
|
141
|
-
19,
|
|
142
|
-
123,
|
|
143
|
-
99,
|
|
144
|
-
110,
|
|
145
|
-
30
|
|
146
|
-
],
|
|
147
|
-
accounts: [
|
|
148
|
-
{
|
|
149
|
-
name: "authority",
|
|
150
|
-
writable: true,
|
|
151
|
-
signer: true
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: "active_list",
|
|
155
|
-
docs: [
|
|
156
|
-
"Active list - will add the validator here"
|
|
157
|
-
],
|
|
158
|
-
writable: true
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: "validator_info",
|
|
162
|
-
docs: [
|
|
163
|
-
"Create the validator info account"
|
|
164
|
-
],
|
|
165
|
-
writable: true
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: "validator_transient",
|
|
169
|
-
docs: [
|
|
170
|
-
"Create the validator transient account"
|
|
171
|
-
],
|
|
172
|
-
writable: true
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
name: "stake_allocation_state",
|
|
176
|
-
docs: [
|
|
177
|
-
"Stake allocation state - to update total_active_vpp when adding validator"
|
|
178
|
-
],
|
|
179
|
-
writable: true
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
name: "system_program"
|
|
183
|
-
}
|
|
184
|
-
],
|
|
185
|
-
args: [
|
|
186
|
-
{
|
|
187
|
-
name: "vote_account",
|
|
188
|
-
type: "pubkey"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: "name",
|
|
192
|
-
type: "string"
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: "performance_score",
|
|
196
|
-
type: "u8"
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
},
|
|
200
70
|
{
|
|
201
71
|
name: "aggregate_stake_metrics",
|
|
202
72
|
docs: [
|
|
@@ -236,43 +106,6 @@ var instructions$3 = [
|
|
|
236
106
|
args: [
|
|
237
107
|
]
|
|
238
108
|
},
|
|
239
|
-
{
|
|
240
|
-
name: "blacklist_validator",
|
|
241
|
-
docs: [
|
|
242
|
-
"Blacklist a validator (user-facing, maintenance will handle graveyard movement)",
|
|
243
|
-
"UnderPerforming is set automatically when score is updated",
|
|
244
|
-
"Another serious emergency stop function"
|
|
245
|
-
],
|
|
246
|
-
discriminator: [
|
|
247
|
-
125,
|
|
248
|
-
42,
|
|
249
|
-
36,
|
|
250
|
-
229,
|
|
251
|
-
27,
|
|
252
|
-
38,
|
|
253
|
-
226,
|
|
254
|
-
62
|
|
255
|
-
],
|
|
256
|
-
accounts: [
|
|
257
|
-
{
|
|
258
|
-
name: "validator_info",
|
|
259
|
-
writable: true
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
name: "stake_allocation_state",
|
|
263
|
-
docs: [
|
|
264
|
-
"Stake allocation state - to update total_active_vpp when VPP changes"
|
|
265
|
-
],
|
|
266
|
-
writable: true
|
|
267
|
-
}
|
|
268
|
-
],
|
|
269
|
-
args: [
|
|
270
|
-
{
|
|
271
|
-
name: "vote_account",
|
|
272
|
-
type: "pubkey"
|
|
273
|
-
}
|
|
274
|
-
]
|
|
275
|
-
},
|
|
276
109
|
{
|
|
277
110
|
name: "bond_role",
|
|
278
111
|
discriminator: [
|
|
@@ -2862,147 +2695,6 @@ var instructions$3 = [
|
|
|
2862
2695
|
}
|
|
2863
2696
|
]
|
|
2864
2697
|
},
|
|
2865
|
-
{
|
|
2866
|
-
name: "reset_distribution_state",
|
|
2867
|
-
discriminator: [
|
|
2868
|
-
159,
|
|
2869
|
-
183,
|
|
2870
|
-
162,
|
|
2871
|
-
74,
|
|
2872
|
-
228,
|
|
2873
|
-
135,
|
|
2874
|
-
157,
|
|
2875
|
-
79
|
|
2876
|
-
],
|
|
2877
|
-
accounts: [
|
|
2878
|
-
{
|
|
2879
|
-
name: "admin",
|
|
2880
|
-
signer: true
|
|
2881
|
-
},
|
|
2882
|
-
{
|
|
2883
|
-
name: "distribution_state",
|
|
2884
|
-
writable: true
|
|
2885
|
-
}
|
|
2886
|
-
],
|
|
2887
|
-
args: [
|
|
2888
|
-
]
|
|
2889
|
-
},
|
|
2890
|
-
{
|
|
2891
|
-
name: "reset_global_state",
|
|
2892
|
-
discriminator: [
|
|
2893
|
-
252,
|
|
2894
|
-
41,
|
|
2895
|
-
117,
|
|
2896
|
-
110,
|
|
2897
|
-
248,
|
|
2898
|
-
165,
|
|
2899
|
-
48,
|
|
2900
|
-
88
|
|
2901
|
-
],
|
|
2902
|
-
accounts: [
|
|
2903
|
-
{
|
|
2904
|
-
name: "admin",
|
|
2905
|
-
signer: true
|
|
2906
|
-
},
|
|
2907
|
-
{
|
|
2908
|
-
name: "global_config"
|
|
2909
|
-
},
|
|
2910
|
-
{
|
|
2911
|
-
name: "global_state",
|
|
2912
|
-
writable: true
|
|
2913
|
-
},
|
|
2914
|
-
{
|
|
2915
|
-
name: "pool_authority"
|
|
2916
|
-
},
|
|
2917
|
-
{
|
|
2918
|
-
name: "liqsol_mint"
|
|
2919
|
-
},
|
|
2920
|
-
{
|
|
2921
|
-
name: "liqsol_pool_ata",
|
|
2922
|
-
writable: true
|
|
2923
|
-
},
|
|
2924
|
-
{
|
|
2925
|
-
name: "token_program"
|
|
2926
|
-
},
|
|
2927
|
-
{
|
|
2928
|
-
name: "associated_token_program"
|
|
2929
|
-
}
|
|
2930
|
-
],
|
|
2931
|
-
args: [
|
|
2932
|
-
]
|
|
2933
|
-
},
|
|
2934
|
-
{
|
|
2935
|
-
name: "reset_price_history",
|
|
2936
|
-
discriminator: [
|
|
2937
|
-
213,
|
|
2938
|
-
231,
|
|
2939
|
-
155,
|
|
2940
|
-
139,
|
|
2941
|
-
248,
|
|
2942
|
-
60,
|
|
2943
|
-
67,
|
|
2944
|
-
199
|
|
2945
|
-
],
|
|
2946
|
-
accounts: [
|
|
2947
|
-
{
|
|
2948
|
-
name: "admin",
|
|
2949
|
-
writable: true,
|
|
2950
|
-
signer: true
|
|
2951
|
-
},
|
|
2952
|
-
{
|
|
2953
|
-
name: "global_config"
|
|
2954
|
-
},
|
|
2955
|
-
{
|
|
2956
|
-
name: "tranche_state",
|
|
2957
|
-
writable: true
|
|
2958
|
-
},
|
|
2959
|
-
{
|
|
2960
|
-
name: "price_history",
|
|
2961
|
-
writable: true
|
|
2962
|
-
},
|
|
2963
|
-
{
|
|
2964
|
-
name: "system_program"
|
|
2965
|
-
}
|
|
2966
|
-
],
|
|
2967
|
-
args: [
|
|
2968
|
-
]
|
|
2969
|
-
},
|
|
2970
|
-
{
|
|
2971
|
-
name: "reset_tranche_state",
|
|
2972
|
-
discriminator: [
|
|
2973
|
-
106,
|
|
2974
|
-
102,
|
|
2975
|
-
143,
|
|
2976
|
-
40,
|
|
2977
|
-
152,
|
|
2978
|
-
173,
|
|
2979
|
-
165,
|
|
2980
|
-
168
|
|
2981
|
-
],
|
|
2982
|
-
accounts: [
|
|
2983
|
-
{
|
|
2984
|
-
name: "admin",
|
|
2985
|
-
writable: true,
|
|
2986
|
-
signer: true
|
|
2987
|
-
},
|
|
2988
|
-
{
|
|
2989
|
-
name: "global_config"
|
|
2990
|
-
},
|
|
2991
|
-
{
|
|
2992
|
-
name: "tranche_state",
|
|
2993
|
-
writable: true
|
|
2994
|
-
},
|
|
2995
|
-
{
|
|
2996
|
-
name: "price_history",
|
|
2997
|
-
writable: true
|
|
2998
|
-
},
|
|
2999
|
-
{
|
|
3000
|
-
name: "system_program"
|
|
3001
|
-
}
|
|
3002
|
-
],
|
|
3003
|
-
args: [
|
|
3004
|
-
]
|
|
3005
|
-
},
|
|
3006
2698
|
{
|
|
3007
2699
|
name: "set_admin",
|
|
3008
2700
|
discriminator: [
|
|
@@ -3025,8 +2717,7 @@ var instructions$3 = [
|
|
|
3025
2717
|
signer: true
|
|
3026
2718
|
},
|
|
3027
2719
|
{
|
|
3028
|
-
name: "new_authority"
|
|
3029
|
-
signer: true
|
|
2720
|
+
name: "new_authority"
|
|
3030
2721
|
}
|
|
3031
2722
|
],
|
|
3032
2723
|
args: [
|
|
@@ -3054,52 +2745,12 @@ var instructions$3 = [
|
|
|
3054
2745
|
signer: true
|
|
3055
2746
|
},
|
|
3056
2747
|
{
|
|
3057
|
-
name: "new_authority"
|
|
3058
|
-
signer: true
|
|
2748
|
+
name: "new_authority"
|
|
3059
2749
|
}
|
|
3060
2750
|
],
|
|
3061
2751
|
args: [
|
|
3062
2752
|
]
|
|
3063
2753
|
},
|
|
3064
|
-
{
|
|
3065
|
-
name: "set_last_state_change_epoch",
|
|
3066
|
-
docs: [
|
|
3067
|
-
"Admin function to directly set last_state_change_epoch (useful for testing cooldowns)"
|
|
3068
|
-
],
|
|
3069
|
-
discriminator: [
|
|
3070
|
-
94,
|
|
3071
|
-
57,
|
|
3072
|
-
139,
|
|
3073
|
-
195,
|
|
3074
|
-
123,
|
|
3075
|
-
224,
|
|
3076
|
-
227,
|
|
3077
|
-
106
|
|
3078
|
-
],
|
|
3079
|
-
accounts: [
|
|
3080
|
-
{
|
|
3081
|
-
name: "validator_info",
|
|
3082
|
-
writable: true
|
|
3083
|
-
},
|
|
3084
|
-
{
|
|
3085
|
-
name: "stake_allocation_state",
|
|
3086
|
-
docs: [
|
|
3087
|
-
"Stake allocation state - to update total_active_vpp when VPP changes"
|
|
3088
|
-
],
|
|
3089
|
-
writable: true
|
|
3090
|
-
}
|
|
3091
|
-
],
|
|
3092
|
-
args: [
|
|
3093
|
-
{
|
|
3094
|
-
name: "vote_account",
|
|
3095
|
-
type: "pubkey"
|
|
3096
|
-
},
|
|
3097
|
-
{
|
|
3098
|
-
name: "epoch",
|
|
3099
|
-
type: "u16"
|
|
3100
|
-
}
|
|
3101
|
-
]
|
|
3102
|
-
},
|
|
3103
2754
|
{
|
|
3104
2755
|
name: "set_paused",
|
|
3105
2756
|
discriminator: [
|
|
@@ -3589,35 +3240,6 @@ var instructions$3 = [
|
|
|
3589
3240
|
}
|
|
3590
3241
|
]
|
|
3591
3242
|
},
|
|
3592
|
-
{
|
|
3593
|
-
name: "test_clear_active_list",
|
|
3594
|
-
discriminator: [
|
|
3595
|
-
17,
|
|
3596
|
-
195,
|
|
3597
|
-
59,
|
|
3598
|
-
174,
|
|
3599
|
-
184,
|
|
3600
|
-
137,
|
|
3601
|
-
149,
|
|
3602
|
-
144
|
|
3603
|
-
],
|
|
3604
|
-
accounts: [
|
|
3605
|
-
{
|
|
3606
|
-
name: "active_list",
|
|
3607
|
-
writable: true
|
|
3608
|
-
},
|
|
3609
|
-
{
|
|
3610
|
-
name: "processing_state",
|
|
3611
|
-
writable: true
|
|
3612
|
-
},
|
|
3613
|
-
{
|
|
3614
|
-
name: "authority",
|
|
3615
|
-
signer: true
|
|
3616
|
-
}
|
|
3617
|
-
],
|
|
3618
|
-
args: [
|
|
3619
|
-
]
|
|
3620
|
-
},
|
|
3621
3243
|
{
|
|
3622
3244
|
name: "update_config_bool",
|
|
3623
3245
|
discriminator: [
|
|
@@ -4295,8 +3917,118 @@ var events = [
|
|
|
4295
3917
|
var errors$3 = [
|
|
4296
3918
|
{
|
|
4297
3919
|
code: 6000,
|
|
4298
|
-
name: "
|
|
4299
|
-
msg: "
|
|
3920
|
+
name: "DestinationAccountDoesNotExist",
|
|
3921
|
+
msg: "Destination stake account does not exist"
|
|
3922
|
+
},
|
|
3923
|
+
{
|
|
3924
|
+
code: 6001,
|
|
3925
|
+
name: "SourceAccountDoesNotExist",
|
|
3926
|
+
msg: "Source stake account does not exist"
|
|
3927
|
+
},
|
|
3928
|
+
{
|
|
3929
|
+
code: 6002,
|
|
3930
|
+
name: "InvalidDestinationOwner",
|
|
3931
|
+
msg: "Destination account not owned by stake program"
|
|
3932
|
+
},
|
|
3933
|
+
{
|
|
3934
|
+
code: 6003,
|
|
3935
|
+
name: "InvalidSourceOwner",
|
|
3936
|
+
msg: "Source account not owned by stake program"
|
|
3937
|
+
},
|
|
3938
|
+
{
|
|
3939
|
+
code: 6004,
|
|
3940
|
+
name: "ClockBorrowFailed",
|
|
3941
|
+
msg: "Failed to borrow clock data"
|
|
3942
|
+
},
|
|
3943
|
+
{
|
|
3944
|
+
code: 6005,
|
|
3945
|
+
name: "ClockDeserializeFailed",
|
|
3946
|
+
msg: "Failed to deserialize clock"
|
|
3947
|
+
},
|
|
3948
|
+
{
|
|
3949
|
+
code: 6006,
|
|
3950
|
+
name: "DestinationAnalysisFailed",
|
|
3951
|
+
msg: "Failed to analyze destination stake account"
|
|
3952
|
+
},
|
|
3953
|
+
{
|
|
3954
|
+
code: 6007,
|
|
3955
|
+
name: "SourceAnalysisFailed",
|
|
3956
|
+
msg: "Failed to analyze source stake account"
|
|
3957
|
+
},
|
|
3958
|
+
{
|
|
3959
|
+
code: 6008,
|
|
3960
|
+
name: "DestinationStillActivating",
|
|
3961
|
+
msg: "Destination stake is still activating"
|
|
3962
|
+
},
|
|
3963
|
+
{
|
|
3964
|
+
code: 6009,
|
|
3965
|
+
name: "DestinationDeactivating",
|
|
3966
|
+
msg: "Destination stake is deactivating"
|
|
3967
|
+
},
|
|
3968
|
+
{
|
|
3969
|
+
code: 6010,
|
|
3970
|
+
name: "SourceStillActivating",
|
|
3971
|
+
msg: "Source stake is still activating"
|
|
3972
|
+
},
|
|
3973
|
+
{
|
|
3974
|
+
code: 6011,
|
|
3975
|
+
name: "SourceDeactivating",
|
|
3976
|
+
msg: "Source stake is deactivating"
|
|
3977
|
+
},
|
|
3978
|
+
{
|
|
3979
|
+
code: 6012,
|
|
3980
|
+
name: "DestinationBorrowFailed",
|
|
3981
|
+
msg: "Failed to borrow destination account data"
|
|
3982
|
+
},
|
|
3983
|
+
{
|
|
3984
|
+
code: 6013,
|
|
3985
|
+
name: "DestinationParseFailed",
|
|
3986
|
+
msg: "Failed to parse destination stake state"
|
|
3987
|
+
},
|
|
3988
|
+
{
|
|
3989
|
+
code: 6014,
|
|
3990
|
+
name: "SourceBorrowFailed",
|
|
3991
|
+
msg: "Failed to borrow source account data"
|
|
3992
|
+
},
|
|
3993
|
+
{
|
|
3994
|
+
code: 6015,
|
|
3995
|
+
name: "SourceParseFailed",
|
|
3996
|
+
msg: "Failed to parse source stake state"
|
|
3997
|
+
},
|
|
3998
|
+
{
|
|
3999
|
+
code: 6016,
|
|
4000
|
+
name: "DifferentValidators",
|
|
4001
|
+
msg: "Stakes are delegated to different validators"
|
|
4002
|
+
},
|
|
4003
|
+
{
|
|
4004
|
+
code: 6017,
|
|
4005
|
+
name: "DifferentStakers",
|
|
4006
|
+
msg: "Stakes have different staker authorities"
|
|
4007
|
+
},
|
|
4008
|
+
{
|
|
4009
|
+
code: 6018,
|
|
4010
|
+
name: "DifferentWithdrawers",
|
|
4011
|
+
msg: "Stakes have different withdrawer authorities"
|
|
4012
|
+
},
|
|
4013
|
+
{
|
|
4014
|
+
code: 6019,
|
|
4015
|
+
name: "AuthoritiesNotFound",
|
|
4016
|
+
msg: "Could not extract authorities from accounts"
|
|
4017
|
+
},
|
|
4018
|
+
{
|
|
4019
|
+
code: 6020,
|
|
4020
|
+
name: "MergeInstructionFailed",
|
|
4021
|
+
msg: "Merge instruction failed"
|
|
4022
|
+
},
|
|
4023
|
+
{
|
|
4024
|
+
code: 6021,
|
|
4025
|
+
name: "EpochRewardsActive",
|
|
4026
|
+
msg: "Epoch rewards distribution is active - stake operations blocked"
|
|
4027
|
+
},
|
|
4028
|
+
{
|
|
4029
|
+
code: 6022,
|
|
4030
|
+
name: "DifferentCreditsObserved",
|
|
4031
|
+
msg: "Stakes have different credits_observed - cannot merge until both earn same rewards"
|
|
4300
4032
|
}
|
|
4301
4033
|
];
|
|
4302
4034
|
var types$5 = [
|
|
@@ -6749,153 +6481,6 @@ var instructions$1 = [
|
|
|
6749
6481
|
args: [
|
|
6750
6482
|
]
|
|
6751
6483
|
},
|
|
6752
|
-
{
|
|
6753
|
-
name: "test_clear_leaderboard",
|
|
6754
|
-
discriminator: [
|
|
6755
|
-
118,
|
|
6756
|
-
207,
|
|
6757
|
-
26,
|
|
6758
|
-
205,
|
|
6759
|
-
180,
|
|
6760
|
-
7,
|
|
6761
|
-
75,
|
|
6762
|
-
244
|
|
6763
|
-
],
|
|
6764
|
-
accounts: [
|
|
6765
|
-
{
|
|
6766
|
-
name: "leaderboard_state",
|
|
6767
|
-
writable: true
|
|
6768
|
-
},
|
|
6769
|
-
{
|
|
6770
|
-
name: "authority",
|
|
6771
|
-
signer: true
|
|
6772
|
-
}
|
|
6773
|
-
],
|
|
6774
|
-
args: [
|
|
6775
|
-
]
|
|
6776
|
-
},
|
|
6777
|
-
{
|
|
6778
|
-
name: "test_force_register_validator",
|
|
6779
|
-
discriminator: [
|
|
6780
|
-
136,
|
|
6781
|
-
156,
|
|
6782
|
-
132,
|
|
6783
|
-
32,
|
|
6784
|
-
96,
|
|
6785
|
-
240,
|
|
6786
|
-
7,
|
|
6787
|
-
115
|
|
6788
|
-
],
|
|
6789
|
-
accounts: [
|
|
6790
|
-
{
|
|
6791
|
-
name: "registrant",
|
|
6792
|
-
writable: true,
|
|
6793
|
-
signer: true
|
|
6794
|
-
},
|
|
6795
|
-
{
|
|
6796
|
-
name: "vote_account"
|
|
6797
|
-
},
|
|
6798
|
-
{
|
|
6799
|
-
name: "validator_record",
|
|
6800
|
-
writable: true
|
|
6801
|
-
},
|
|
6802
|
-
{
|
|
6803
|
-
name: "leaderboard_state",
|
|
6804
|
-
writable: true
|
|
6805
|
-
},
|
|
6806
|
-
{
|
|
6807
|
-
name: "system_program"
|
|
6808
|
-
},
|
|
6809
|
-
{
|
|
6810
|
-
name: "clock"
|
|
6811
|
-
}
|
|
6812
|
-
],
|
|
6813
|
-
args: [
|
|
6814
|
-
{
|
|
6815
|
-
name: "vpp",
|
|
6816
|
-
type: "u8"
|
|
6817
|
-
}
|
|
6818
|
-
]
|
|
6819
|
-
},
|
|
6820
|
-
{
|
|
6821
|
-
name: "test_force_update_vpp",
|
|
6822
|
-
discriminator: [
|
|
6823
|
-
67,
|
|
6824
|
-
51,
|
|
6825
|
-
28,
|
|
6826
|
-
174,
|
|
6827
|
-
200,
|
|
6828
|
-
214,
|
|
6829
|
-
203,
|
|
6830
|
-
162
|
|
6831
|
-
],
|
|
6832
|
-
accounts: [
|
|
6833
|
-
{
|
|
6834
|
-
name: "registrant",
|
|
6835
|
-
writable: true,
|
|
6836
|
-
signer: true
|
|
6837
|
-
},
|
|
6838
|
-
{
|
|
6839
|
-
name: "vote_account"
|
|
6840
|
-
},
|
|
6841
|
-
{
|
|
6842
|
-
name: "validator_record",
|
|
6843
|
-
writable: true
|
|
6844
|
-
},
|
|
6845
|
-
{
|
|
6846
|
-
name: "leaderboard_state",
|
|
6847
|
-
writable: true
|
|
6848
|
-
}
|
|
6849
|
-
],
|
|
6850
|
-
args: [
|
|
6851
|
-
{
|
|
6852
|
-
name: "vpp",
|
|
6853
|
-
type: "u8"
|
|
6854
|
-
}
|
|
6855
|
-
]
|
|
6856
|
-
},
|
|
6857
|
-
{
|
|
6858
|
-
name: "test_seed_random_validators",
|
|
6859
|
-
discriminator: [
|
|
6860
|
-
48,
|
|
6861
|
-
155,
|
|
6862
|
-
181,
|
|
6863
|
-
112,
|
|
6864
|
-
163,
|
|
6865
|
-
242,
|
|
6866
|
-
43,
|
|
6867
|
-
146
|
|
6868
|
-
],
|
|
6869
|
-
accounts: [
|
|
6870
|
-
{
|
|
6871
|
-
name: "registrant",
|
|
6872
|
-
writable: true,
|
|
6873
|
-
signer: true
|
|
6874
|
-
},
|
|
6875
|
-
{
|
|
6876
|
-
name: "leaderboard_state",
|
|
6877
|
-
writable: true
|
|
6878
|
-
}
|
|
6879
|
-
],
|
|
6880
|
-
args: [
|
|
6881
|
-
{
|
|
6882
|
-
name: "count",
|
|
6883
|
-
type: "u16"
|
|
6884
|
-
},
|
|
6885
|
-
{
|
|
6886
|
-
name: "seed",
|
|
6887
|
-
type: "u64"
|
|
6888
|
-
},
|
|
6889
|
-
{
|
|
6890
|
-
name: "min_vpp",
|
|
6891
|
-
type: "u8"
|
|
6892
|
-
},
|
|
6893
|
-
{
|
|
6894
|
-
name: "max_vpp",
|
|
6895
|
-
type: "u8"
|
|
6896
|
-
}
|
|
6897
|
-
]
|
|
6898
|
-
},
|
|
6899
6484
|
{
|
|
6900
6485
|
name: "update_commission",
|
|
6901
6486
|
discriminator: [
|
|
@@ -7829,7 +7414,7 @@ const deriveEphemeralStakeAddress = (user, seed) => __async$f(null, null, functi
|
|
|
7829
7414
|
return web3_js.PublicKey.createWithSeed(user, seedStr, web3_js.StakeProgram.programId);
|
|
7830
7415
|
});
|
|
7831
7416
|
const CHAINLINK_FEED = new web3_js.PublicKey(
|
|
7832
|
-
"
|
|
7417
|
+
"CH31Xns5z3M1cTAbKW34jcxPPciazARpijcHj9rxtemt"
|
|
7833
7418
|
);
|
|
7834
7419
|
const CHAINLINK_PROGRAM = new web3_js.PublicKey(
|
|
7835
7420
|
"HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny"
|
|
@@ -9262,13 +8847,16 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
9262
8847
|
if (amountLamports <= BigInt(0)) {
|
|
9263
8848
|
throw new Error("Deposit amount must be greater than zero.");
|
|
9264
8849
|
}
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
8850
|
+
try {
|
|
8851
|
+
const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
|
|
8852
|
+
const ix = yield this.depositClient.buildDepositTx(amountLamports);
|
|
8853
|
+
const tx = new web3_js.Transaction().add(cuIx, ix);
|
|
8854
|
+
const prepared = yield this.prepareTx(tx);
|
|
8855
|
+
const signed = yield this.signTransaction(prepared.tx);
|
|
8856
|
+
return this.sendAndConfirmHttp(signed, prepared);
|
|
8857
|
+
} catch (err) {
|
|
8858
|
+
throw new Error(`Failed to deposit Solana: ${err}`);
|
|
8859
|
+
}
|
|
9272
8860
|
});
|
|
9273
8861
|
}
|
|
9274
8862
|
withdraw(amountLamports) {
|
|
@@ -9277,13 +8865,16 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
9277
8865
|
if (amountLamports <= BigInt(0)) {
|
|
9278
8866
|
throw new Error("Withdraw amount must be greater than zero.");
|
|
9279
8867
|
}
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
8868
|
+
try {
|
|
8869
|
+
const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
|
|
8870
|
+
const ix = yield this.depositClient.buildWithdrawTx(amountLamports);
|
|
8871
|
+
const tx = new web3_js.Transaction().add(cuIx, ix);
|
|
8872
|
+
const prepared = yield this.prepareTx(tx);
|
|
8873
|
+
const signed = yield this.signTransaction(prepared.tx);
|
|
8874
|
+
return this.sendAndConfirmHttp(signed, prepared);
|
|
8875
|
+
} catch (err) {
|
|
8876
|
+
throw new Error(`Failed to withdraw Solana: ${err}`);
|
|
8877
|
+
}
|
|
9287
8878
|
});
|
|
9288
8879
|
}
|
|
9289
8880
|
stake(amountLamports) {
|
|
@@ -9292,13 +8883,17 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
9292
8883
|
if (!amountLamports || amountLamports <= BigInt(0)) {
|
|
9293
8884
|
throw new Error("Stake amount must be greater than zero.");
|
|
9294
8885
|
}
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
8886
|
+
try {
|
|
8887
|
+
const user = this.solPubKey;
|
|
8888
|
+
const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
|
|
8889
|
+
const ix = yield this.outpostClient.buildStakeIx(amountLamports, user);
|
|
8890
|
+
const tx = new web3_js.Transaction().add(cuIx, ix);
|
|
8891
|
+
const prepared = yield this.prepareTx(tx);
|
|
8892
|
+
const signed = yield this.signTransaction(prepared.tx);
|
|
8893
|
+
return this.sendAndConfirmHttp(signed, prepared);
|
|
8894
|
+
} catch (err) {
|
|
8895
|
+
throw new Error(`Failed to stake Solana: ${err}`);
|
|
8896
|
+
}
|
|
9302
8897
|
});
|
|
9303
8898
|
}
|
|
9304
8899
|
unstake(amountLamports) {
|
|
@@ -9307,13 +8902,17 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
9307
8902
|
if (!amountLamports || amountLamports <= BigInt(0)) {
|
|
9308
8903
|
throw new Error("Unstake amount must be greater than zero.");
|
|
9309
8904
|
}
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
8905
|
+
try {
|
|
8906
|
+
const user = this.solPubKey;
|
|
8907
|
+
const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
|
|
8908
|
+
const ix = yield this.outpostClient.buildUnstakeIx(amountLamports, user);
|
|
8909
|
+
const tx = new web3_js.Transaction().add(cuIx, ix);
|
|
8910
|
+
const prepared = yield this.prepareTx(tx);
|
|
8911
|
+
const signed = yield this.signTransaction(prepared.tx);
|
|
8912
|
+
return this.sendAndConfirmHttp(signed, prepared);
|
|
8913
|
+
} catch (err) {
|
|
8914
|
+
throw new Error(`Failed to unstake Solana: ${err}`);
|
|
8915
|
+
}
|
|
9317
8916
|
});
|
|
9318
8917
|
}
|
|
9319
8918
|
buy(amountLamports) {
|
|
@@ -9322,102 +8921,107 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
9322
8921
|
if (!amountLamports || amountLamports <= BigInt(0)) {
|
|
9323
8922
|
throw new Error("liqSOL pretoken purchase requires a positive amount.");
|
|
9324
8923
|
}
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
8924
|
+
try {
|
|
8925
|
+
const user = this.solPubKey;
|
|
8926
|
+
const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
|
|
8927
|
+
const ix = yield this.tokenClient.buildPurchaseIx(amountLamports, user);
|
|
8928
|
+
const tx = new web3_js.Transaction().add(cuIx, ix);
|
|
8929
|
+
const prepared = yield this.prepareTx(tx);
|
|
8930
|
+
const signed = yield this.signTransaction(prepared.tx);
|
|
8931
|
+
return this.sendAndConfirmHttp(signed, prepared);
|
|
8932
|
+
} catch (err) {
|
|
8933
|
+
throw new Error(`Failed to buy liqSOL pretokens: ${err}`);
|
|
8934
|
+
}
|
|
9335
8935
|
});
|
|
9336
8936
|
}
|
|
9337
8937
|
getPortfolio() {
|
|
9338
8938
|
return __async$8(this, null, function* () {
|
|
9339
8939
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
9340
8940
|
if (!this.pubKey) throw new Error("User pubKey is undefined");
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
8941
|
+
try {
|
|
8942
|
+
const user = this.solPubKey;
|
|
8943
|
+
const reservePoolPDA = deriveReservePoolPda();
|
|
8944
|
+
const vaultPDA = deriveVaultPda();
|
|
8945
|
+
const liqsolMint = deriveLiqsolMintPda();
|
|
8946
|
+
const userLiqsolAta = splToken.getAssociatedTokenAddressSync(
|
|
8947
|
+
liqsolMint,
|
|
8948
|
+
user,
|
|
8949
|
+
false,
|
|
8950
|
+
splToken.TOKEN_2022_PROGRAM_ID,
|
|
8951
|
+
splToken.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
8952
|
+
);
|
|
8953
|
+
const [nativeLamports, actualBalResp, snapshot] = yield Promise.all([
|
|
8954
|
+
this.connection.getBalance(user, "confirmed"),
|
|
8955
|
+
this.connection.getTokenAccountBalance(userLiqsolAta, "confirmed").catch(() => null),
|
|
8956
|
+
this.outpostClient.fetchWireState(user).catch(() => null)
|
|
8957
|
+
]);
|
|
8958
|
+
const LIQSOL_DECIMALS = 9;
|
|
8959
|
+
const actualAmountStr = (_b = (_a = actualBalResp == null ? void 0 : actualBalResp.value) == null ? void 0 : _a.amount) != null ? _b : "0";
|
|
8960
|
+
const globalState = (_c = snapshot == null ? void 0 : snapshot.globalState) != null ? _c : null;
|
|
8961
|
+
const outpostAccount = (_d = snapshot == null ? void 0 : snapshot.outpostAccount) != null ? _d : null;
|
|
8962
|
+
const trancheState = (_e = snapshot == null ? void 0 : snapshot.trancheState) != null ? _e : null;
|
|
8963
|
+
const userPretokenRecord = (_f = snapshot == null ? void 0 : snapshot.userPretokenRecord) != null ? _f : null;
|
|
8964
|
+
const stakedLiqsolStr = (_i = (_h = (_g = outpostAccount == null ? void 0 : outpostAccount.stakedLiqsol) == null ? void 0 : _g.toString) == null ? void 0 : _h.call(_g)) != null ? _i : "0";
|
|
8965
|
+
const wirePretokensStr = (_l = (_k = (_j = userPretokenRecord == null ? void 0 : userPretokenRecord.totalPretokensPurchased) == null ? void 0 : _j.toString) == null ? void 0 : _k.call(_j)) != null ? _l : "0";
|
|
8966
|
+
const currentIndexStr = (_o = (_n = (_m = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _m.toString) == null ? void 0 : _n.call(_m)) != null ? _o : "0";
|
|
8967
|
+
const totalSharesStr = (_r = (_q = (_p = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _p.toString) == null ? void 0 : _q.call(_p)) != null ? _r : "0";
|
|
8968
|
+
const userSharesStr = (_u = (_t = (_s = outpostAccount == null ? void 0 : outpostAccount.stakedShares) == null ? void 0 : _s.toString) == null ? void 0 : _t.call(_s)) != null ? _u : "0";
|
|
8969
|
+
const stakedLiqsol = BigInt(stakedLiqsolStr);
|
|
8970
|
+
const currentIndex = BigInt(currentIndexStr);
|
|
8971
|
+
const totalShares = BigInt(totalSharesStr);
|
|
8972
|
+
const userShares = BigInt(userSharesStr);
|
|
8973
|
+
let estimatedClaim = BigInt(0);
|
|
8974
|
+
let estimatedYield = BigInt(0);
|
|
8975
|
+
if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
|
|
8976
|
+
estimatedClaim = userShares * currentIndex / INDEX_SCALE$1;
|
|
8977
|
+
if (estimatedClaim > stakedLiqsol) {
|
|
8978
|
+
estimatedYield = estimatedClaim - stakedLiqsol;
|
|
8979
|
+
}
|
|
9378
8980
|
}
|
|
8981
|
+
return {
|
|
8982
|
+
native: {
|
|
8983
|
+
amount: BigInt(nativeLamports),
|
|
8984
|
+
symbol: "SOL",
|
|
8985
|
+
decimals: 9
|
|
8986
|
+
},
|
|
8987
|
+
liq: {
|
|
8988
|
+
amount: BigInt(actualAmountStr),
|
|
8989
|
+
symbol: "LiqSOL",
|
|
8990
|
+
decimals: LIQSOL_DECIMALS,
|
|
8991
|
+
ata: userLiqsolAta
|
|
8992
|
+
},
|
|
8993
|
+
staked: {
|
|
8994
|
+
amount: stakedLiqsol,
|
|
8995
|
+
symbol: "LiqSOL",
|
|
8996
|
+
decimals: LIQSOL_DECIMALS
|
|
8997
|
+
},
|
|
8998
|
+
wire: {
|
|
8999
|
+
amount: BigInt(wirePretokensStr),
|
|
9000
|
+
symbol: "$WIRE",
|
|
9001
|
+
decimals: 8
|
|
9002
|
+
},
|
|
9003
|
+
yield: {
|
|
9004
|
+
currentIndex,
|
|
9005
|
+
indexScale: INDEX_SCALE$1,
|
|
9006
|
+
totalShares,
|
|
9007
|
+
userShares,
|
|
9008
|
+
estimatedClaim,
|
|
9009
|
+
estimatedYield
|
|
9010
|
+
},
|
|
9011
|
+
extras: {
|
|
9012
|
+
userLiqsolAta: userLiqsolAta.toBase58(),
|
|
9013
|
+
reservePoolPDA: reservePoolPDA.toBase58(),
|
|
9014
|
+
vaultPDA: vaultPDA.toBase58(),
|
|
9015
|
+
globalIndex: (_v = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _v.toString(),
|
|
9016
|
+
totalShares: (_w = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _w.toString(),
|
|
9017
|
+
currentTrancheNumber: (_x = trancheState == null ? void 0 : trancheState.currentTrancheNumber) == null ? void 0 : _x.toString(),
|
|
9018
|
+
currentTranchePriceUsd: (_y = trancheState == null ? void 0 : trancheState.currentTranchePriceUsd) == null ? void 0 : _y.toString()
|
|
9019
|
+
},
|
|
9020
|
+
chainID: this.network.chainId
|
|
9021
|
+
};
|
|
9022
|
+
} catch (err) {
|
|
9023
|
+
throw new Error(`Failed to get Solana portfolio: ${err}`);
|
|
9379
9024
|
}
|
|
9380
|
-
return {
|
|
9381
|
-
native: {
|
|
9382
|
-
amount: BigInt(nativeLamports),
|
|
9383
|
-
symbol: "SOL",
|
|
9384
|
-
decimals: 9
|
|
9385
|
-
},
|
|
9386
|
-
liq: {
|
|
9387
|
-
amount: BigInt(actualAmountStr),
|
|
9388
|
-
symbol: "LiqSOL",
|
|
9389
|
-
decimals: LIQSOL_DECIMALS,
|
|
9390
|
-
ata: userLiqsolAta
|
|
9391
|
-
},
|
|
9392
|
-
staked: {
|
|
9393
|
-
amount: stakedLiqsol,
|
|
9394
|
-
symbol: "LiqSOL",
|
|
9395
|
-
decimals: LIQSOL_DECIMALS
|
|
9396
|
-
},
|
|
9397
|
-
wire: {
|
|
9398
|
-
amount: BigInt(wirePretokensStr),
|
|
9399
|
-
symbol: "$WIRE",
|
|
9400
|
-
decimals: 8
|
|
9401
|
-
},
|
|
9402
|
-
yield: {
|
|
9403
|
-
currentIndex,
|
|
9404
|
-
indexScale: INDEX_SCALE$1,
|
|
9405
|
-
totalShares,
|
|
9406
|
-
userShares,
|
|
9407
|
-
estimatedClaim,
|
|
9408
|
-
estimatedYield
|
|
9409
|
-
},
|
|
9410
|
-
extras: {
|
|
9411
|
-
userLiqsolAta: userLiqsolAta.toBase58(),
|
|
9412
|
-
reservePoolPDA: reservePoolPDA.toBase58(),
|
|
9413
|
-
vaultPDA: vaultPDA.toBase58(),
|
|
9414
|
-
globalIndex: (_v = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _v.toString(),
|
|
9415
|
-
totalShares: (_w = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _w.toString(),
|
|
9416
|
-
currentTrancheNumber: (_x = trancheState == null ? void 0 : trancheState.currentTrancheNumber) == null ? void 0 : _x.toString(),
|
|
9417
|
-
currentTranchePriceUsd: (_y = trancheState == null ? void 0 : trancheState.currentTranchePriceUsd) == null ? void 0 : _y.toString()
|
|
9418
|
-
},
|
|
9419
|
-
chainID: this.network.chainId
|
|
9420
|
-
};
|
|
9421
9025
|
});
|
|
9422
9026
|
}
|
|
9423
9027
|
getUserRecord() {
|
|
@@ -9428,44 +9032,56 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
9428
9032
|
}
|
|
9429
9033
|
getTrancheSnapshot(options) {
|
|
9430
9034
|
return __async$8(this, null, function* () {
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9035
|
+
try {
|
|
9036
|
+
const {
|
|
9037
|
+
chainID = core.SolChainID.WireTestnet,
|
|
9038
|
+
windowBefore,
|
|
9039
|
+
windowAfter
|
|
9040
|
+
} = options != null ? options : {};
|
|
9041
|
+
const [globalState, trancheState] = yield Promise.all([
|
|
9042
|
+
this.tokenClient.fetchGlobalState(),
|
|
9043
|
+
this.tokenClient.fetchTrancheState()
|
|
9044
|
+
]);
|
|
9045
|
+
const { price: solPriceUsd, timestamp } = yield this.tokenClient.getSolPriceUsdSafe();
|
|
9046
|
+
return buildSolanaTrancheSnapshot({
|
|
9047
|
+
chainID,
|
|
9048
|
+
globalState,
|
|
9049
|
+
trancheState,
|
|
9050
|
+
solPriceUsd,
|
|
9051
|
+
nativePriceTimestamp: timestamp,
|
|
9052
|
+
ladderWindowBefore: windowBefore,
|
|
9053
|
+
ladderWindowAfter: windowAfter
|
|
9054
|
+
});
|
|
9055
|
+
} catch (err) {
|
|
9056
|
+
throw new Error(`Failed to build Solana tranche snapshot: ${err}`);
|
|
9057
|
+
}
|
|
9450
9058
|
});
|
|
9451
9059
|
}
|
|
9452
9060
|
getSystemAPY() {
|
|
9453
9061
|
return __async$8(this, null, function* () {
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9062
|
+
try {
|
|
9063
|
+
const ratePerEpoch = yield this.getEpochRateDecimalFromProgram();
|
|
9064
|
+
const epochsPerYear = yield this.getEpochsPerYearFromCluster();
|
|
9065
|
+
const apyDecimal = Math.pow(1 + ratePerEpoch, epochsPerYear) - 1;
|
|
9066
|
+
const apyPercent = apyDecimal * 100;
|
|
9067
|
+
return apyPercent;
|
|
9068
|
+
} catch (err) {
|
|
9069
|
+
throw new Error(`Failed to compute Solana system APY: ${err}`);
|
|
9070
|
+
}
|
|
9459
9071
|
});
|
|
9460
9072
|
}
|
|
9461
9073
|
getEpochRateDecimalFromProgram() {
|
|
9462
9074
|
return __async$8(this, null, function* () {
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9075
|
+
try {
|
|
9076
|
+
const liqSolCoreProgram = this.program.getProgram("liqsolCore");
|
|
9077
|
+
const stakeMetricsPda = deriveStakeMetricsPda();
|
|
9078
|
+
const stakeMetrics = yield liqSolCoreProgram.account.stakeMetrics.fetch(stakeMetricsPda);
|
|
9079
|
+
const raw = BigInt(stakeMetrics.solSystemPayRate.toString());
|
|
9080
|
+
const rateDecimal = Number(raw) / Number(PAY_RATE_SCALE_FACTOR);
|
|
9081
|
+
return rateDecimal;
|
|
9082
|
+
} catch (err) {
|
|
9083
|
+
throw new Error(`Failed to read stakeMetrics from program: ${err}`);
|
|
9084
|
+
}
|
|
9469
9085
|
});
|
|
9470
9086
|
}
|
|
9471
9087
|
getEpochsPerYearFromCluster() {
|
|
@@ -35223,10 +34839,6 @@ const CONTRACTS = {
|
|
|
35223
34839
|
address: ADDRESSES.ReceiptNFT,
|
|
35224
34840
|
abi: ReceiptNFTArtifact.abi
|
|
35225
34841
|
},
|
|
35226
|
-
MockAggregator: {
|
|
35227
|
-
address: ADDRESSES.MockAggregator,
|
|
35228
|
-
abi: AggregatorArtifact.abi
|
|
35229
|
-
},
|
|
35230
34842
|
Pool: {
|
|
35231
34843
|
address: ADDRESSES.Pool,
|
|
35232
34844
|
abi: PoolArtifact.abi
|
|
@@ -35266,6 +34878,10 @@ const CONTRACTS = {
|
|
|
35266
34878
|
Depositor: {
|
|
35267
34879
|
address: ADDRESSES.Depositor,
|
|
35268
34880
|
abi: DepositorArtifact.abi
|
|
34881
|
+
},
|
|
34882
|
+
MockAggregator: {
|
|
34883
|
+
address: ADDRESSES.MockAggregator,
|
|
34884
|
+
abi: AggregatorArtifact.abi
|
|
35269
34885
|
}
|
|
35270
34886
|
};
|
|
35271
34887
|
class EthereumContractService {
|
|
@@ -35965,18 +35581,22 @@ class OPPClient {
|
|
|
35965
35581
|
}
|
|
35966
35582
|
getMessages(address) {
|
|
35967
35583
|
return __async$2(this, null, function* () {
|
|
35968
|
-
|
|
35969
|
-
|
|
35970
|
-
|
|
35971
|
-
|
|
35972
|
-
const
|
|
35973
|
-
|
|
35584
|
+
try {
|
|
35585
|
+
const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
|
|
35586
|
+
const events = yield this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
|
|
35587
|
+
const allAssertions = [];
|
|
35588
|
+
for (const event of events) {
|
|
35589
|
+
const assertions = yield this.extractAssertionsFromEvent(event);
|
|
35590
|
+
allAssertions.push(...assertions);
|
|
35591
|
+
}
|
|
35592
|
+
const normalized = address ? address.toLowerCase() : null;
|
|
35593
|
+
const filtered = allAssertions.filter(
|
|
35594
|
+
(a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
|
|
35595
|
+
);
|
|
35596
|
+
return filtered.reverse();
|
|
35597
|
+
} catch (error) {
|
|
35598
|
+
return [];
|
|
35974
35599
|
}
|
|
35975
|
-
const normalized = address ? address.toLowerCase() : null;
|
|
35976
|
-
const filtered = allAssertions.filter(
|
|
35977
|
-
(a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
|
|
35978
|
-
);
|
|
35979
|
-
return filtered.reverse();
|
|
35980
35600
|
});
|
|
35981
35601
|
}
|
|
35982
35602
|
extractAssertionsFromEvent(event) {
|
|
@@ -36239,7 +35859,12 @@ class ReceiptClient {
|
|
|
36239
35859
|
}
|
|
36240
35860
|
stakeReceipts(address) {
|
|
36241
35861
|
return __async$1(this, null, function* () {
|
|
36242
|
-
|
|
35862
|
+
try {
|
|
35863
|
+
const receipts = yield this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
|
|
35864
|
+
return receipts;
|
|
35865
|
+
} catch (err) {
|
|
35866
|
+
return [];
|
|
35867
|
+
}
|
|
36243
35868
|
});
|
|
36244
35869
|
}
|
|
36245
35870
|
pretokenReceipts(address) {
|
|
@@ -36408,10 +36033,6 @@ class EthereumStakingClient {
|
|
|
36408
36033
|
return __async(this, null, function* () {
|
|
36409
36034
|
this.ensureUser();
|
|
36410
36035
|
const buyer = yield this.signer.getAddress();
|
|
36411
|
-
const network = yield this.provider.getNetwork();
|
|
36412
|
-
const chainId = network.chainId;
|
|
36413
|
-
const allowedTestChains = new Set([560048]);
|
|
36414
|
-
if (allowedTestChains.has(chainId)) yield this.updateMockAggregatorPrice();
|
|
36415
36036
|
let result = yield this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
|
|
36416
36037
|
return result && result.txHash ? result.txHash : "Error - no resulting txHash";
|
|
36417
36038
|
});
|
|
@@ -36419,72 +36040,77 @@ class EthereumStakingClient {
|
|
|
36419
36040
|
getPortfolio() {
|
|
36420
36041
|
return __async(this, null, function* () {
|
|
36421
36042
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
36422
|
-
if (!this.signer) return Promise.resolve(null);
|
|
36423
|
-
const walletAddress = yield this.signer.getAddress();
|
|
36424
|
-
const nativeBalance = yield this.provider.getBalance(walletAddress);
|
|
36425
|
-
const nativeDecimals = (_c = (_b = (_a = this.network) == null ? void 0 : _a.nativeCurrency) == null ? void 0 : _b.decimals) != null ? _c : 18;
|
|
36426
|
-
const nativeSymbol = (_f = (_e = (_d = this.network) == null ? void 0 : _d.nativeCurrency) == null ? void 0 : _e.symbol) != null ? _f : "ETH";
|
|
36427
|
-
const liqBalance = yield this.contract.LiqEthToken.balanceOf(walletAddress);
|
|
36428
|
-
const liqSymbol = "Liq" + ((_i = (_h = (_g = this.network) == null ? void 0 : _g.nativeCurrency) == null ? void 0 : _h.symbol) != null ? _i : "ETH");
|
|
36429
|
-
let stakeReceipts = yield this.receiptClient.stakeReceipts(walletAddress);
|
|
36430
|
-
let stakeBalanceBN = ethers.BigNumber.from(0);
|
|
36431
|
-
for (let r of stakeReceipts) {
|
|
36432
|
-
stakeBalanceBN = stakeBalanceBN.add(ethers.BigNumber.from(r.receipt.principal.amount));
|
|
36433
|
-
}
|
|
36434
|
-
let stakeSharesBN = ethers.BigNumber.from(0);
|
|
36435
|
-
for (let r of stakeReceipts) {
|
|
36436
|
-
stakeSharesBN = stakeSharesBN.add(ethers.BigNumber.from(r.receipt.shares.amount));
|
|
36437
|
-
}
|
|
36438
|
-
const wireBalance = yield this.contract.Pretoken.balanceOf(walletAddress);
|
|
36439
|
-
let currentIndex = BigInt(0);
|
|
36440
|
-
let totalShares = BigInt(0);
|
|
36441
|
-
let userShares = BigInt(0);
|
|
36442
|
-
const indexScale = BigInt(1e27);
|
|
36443
36043
|
try {
|
|
36444
|
-
|
|
36445
|
-
|
|
36446
|
-
|
|
36447
|
-
|
|
36448
|
-
const
|
|
36449
|
-
|
|
36450
|
-
|
|
36451
|
-
|
|
36452
|
-
|
|
36044
|
+
if (!this.signer) return Promise.resolve(null);
|
|
36045
|
+
const walletAddress = yield this.signer.getAddress();
|
|
36046
|
+
const nativeBalance = yield this.provider.getBalance(walletAddress);
|
|
36047
|
+
const nativeDecimals = (_c = (_b = (_a = this.network) == null ? void 0 : _a.nativeCurrency) == null ? void 0 : _b.decimals) != null ? _c : 18;
|
|
36048
|
+
const nativeSymbol = (_f = (_e = (_d = this.network) == null ? void 0 : _d.nativeCurrency) == null ? void 0 : _e.symbol) != null ? _f : "ETH";
|
|
36049
|
+
const liqBalance = yield this.contract.LiqEthToken.balanceOf(walletAddress);
|
|
36050
|
+
const liqSymbol = "Liq" + ((_i = (_h = (_g = this.network) == null ? void 0 : _g.nativeCurrency) == null ? void 0 : _h.symbol) != null ? _i : "ETH");
|
|
36051
|
+
let stakeReceipts = yield this.receiptClient.stakeReceipts(walletAddress);
|
|
36052
|
+
let stakeBalanceBN = ethers.BigNumber.from(0);
|
|
36053
|
+
for (let r of stakeReceipts) {
|
|
36054
|
+
stakeBalanceBN = stakeBalanceBN.add(ethers.BigNumber.from(r.receipt.principal.amount));
|
|
36055
|
+
}
|
|
36056
|
+
let stakeSharesBN = ethers.BigNumber.from(0);
|
|
36057
|
+
for (let r of stakeReceipts) {
|
|
36058
|
+
stakeSharesBN = stakeSharesBN.add(ethers.BigNumber.from(r.receipt.shares.amount));
|
|
36059
|
+
}
|
|
36060
|
+
const wireBalance = yield this.contract.Pretoken.balanceOf(walletAddress);
|
|
36061
|
+
let currentIndex = BigInt(0);
|
|
36062
|
+
let totalShares = BigInt(0);
|
|
36063
|
+
let userShares = BigInt(0);
|
|
36064
|
+
const indexScale = BigInt(1e27);
|
|
36065
|
+
try {
|
|
36066
|
+
const [indexBn, totalSharesBn] = yield Promise.all([
|
|
36067
|
+
this.contract.Depositor.index().catch(() => ethers.BigNumber.from(0)),
|
|
36068
|
+
this.contract.Depositor.totalShares().catch(() => ethers.BigNumber.from(0))
|
|
36069
|
+
]);
|
|
36070
|
+
const userSharesBn = stakeSharesBN;
|
|
36071
|
+
currentIndex = BigInt(indexBn.toString());
|
|
36072
|
+
totalShares = BigInt(totalSharesBn.toString());
|
|
36073
|
+
userShares = BigInt(userSharesBn.toString());
|
|
36074
|
+
} catch (error) {
|
|
36075
|
+
console.log("Error fetching staking index/shares:", error);
|
|
36076
|
+
}
|
|
36077
|
+
let estimatedClaim = BigInt(0);
|
|
36078
|
+
let estimatedYield = BigInt(0);
|
|
36079
|
+
const portfolio = {
|
|
36080
|
+
native: {
|
|
36081
|
+
amount: nativeBalance.toBigInt(),
|
|
36082
|
+
decimals: nativeDecimals,
|
|
36083
|
+
symbol: nativeSymbol
|
|
36084
|
+
},
|
|
36085
|
+
liq: {
|
|
36086
|
+
amount: liqBalance.toBigInt(),
|
|
36087
|
+
decimals: nativeDecimals,
|
|
36088
|
+
symbol: liqSymbol
|
|
36089
|
+
},
|
|
36090
|
+
staked: {
|
|
36091
|
+
amount: stakeBalanceBN.toBigInt(),
|
|
36092
|
+
decimals: nativeDecimals,
|
|
36093
|
+
symbol: liqSymbol
|
|
36094
|
+
},
|
|
36095
|
+
wire: {
|
|
36096
|
+
amount: wireBalance.toBigInt(),
|
|
36097
|
+
decimals: 18,
|
|
36098
|
+
symbol: "$WIRE"
|
|
36099
|
+
},
|
|
36100
|
+
yield: {
|
|
36101
|
+
currentIndex,
|
|
36102
|
+
indexScale,
|
|
36103
|
+
totalShares,
|
|
36104
|
+
userShares,
|
|
36105
|
+
estimatedClaim,
|
|
36106
|
+
estimatedYield
|
|
36107
|
+
},
|
|
36108
|
+
chainID: this.network.chainId
|
|
36109
|
+
};
|
|
36110
|
+
return portfolio;
|
|
36111
|
+
} catch (error) {
|
|
36112
|
+
throw error;
|
|
36453
36113
|
}
|
|
36454
|
-
let estimatedClaim = BigInt(0);
|
|
36455
|
-
let estimatedYield = BigInt(0);
|
|
36456
|
-
const portfolio = {
|
|
36457
|
-
native: {
|
|
36458
|
-
amount: nativeBalance.toBigInt(),
|
|
36459
|
-
decimals: nativeDecimals,
|
|
36460
|
-
symbol: nativeSymbol
|
|
36461
|
-
},
|
|
36462
|
-
liq: {
|
|
36463
|
-
amount: liqBalance.toBigInt(),
|
|
36464
|
-
decimals: nativeDecimals,
|
|
36465
|
-
symbol: liqSymbol
|
|
36466
|
-
},
|
|
36467
|
-
staked: {
|
|
36468
|
-
amount: stakeBalanceBN.toBigInt(),
|
|
36469
|
-
decimals: nativeDecimals,
|
|
36470
|
-
symbol: liqSymbol
|
|
36471
|
-
},
|
|
36472
|
-
wire: {
|
|
36473
|
-
amount: wireBalance.toBigInt(),
|
|
36474
|
-
decimals: 18,
|
|
36475
|
-
symbol: "$WIRE"
|
|
36476
|
-
},
|
|
36477
|
-
yield: {
|
|
36478
|
-
currentIndex,
|
|
36479
|
-
indexScale,
|
|
36480
|
-
totalShares,
|
|
36481
|
-
userShares,
|
|
36482
|
-
estimatedClaim,
|
|
36483
|
-
estimatedYield
|
|
36484
|
-
},
|
|
36485
|
-
chainID: this.network.chainId
|
|
36486
|
-
};
|
|
36487
|
-
return portfolio;
|
|
36488
36114
|
});
|
|
36489
36115
|
}
|
|
36490
36116
|
fetchPrelaunchReceipts(address) {
|
|
@@ -36542,7 +36168,7 @@ class EthereumStakingClient {
|
|
|
36542
36168
|
getTrancheSnapshot(options) {
|
|
36543
36169
|
return __async(this, null, function* () {
|
|
36544
36170
|
const {
|
|
36545
|
-
chainID = core.EvmChainID.
|
|
36171
|
+
chainID = core.EvmChainID.Ethereum,
|
|
36546
36172
|
windowBefore,
|
|
36547
36173
|
windowAfter
|
|
36548
36174
|
} = options != null ? options : {};
|
|
@@ -36563,10 +36189,8 @@ class EthereumStakingClient {
|
|
|
36563
36189
|
]);
|
|
36564
36190
|
const totalTrancheSupply = BigInt(totalSupplyBn.toString()) / BigInt(1e10);
|
|
36565
36191
|
const currentTrancheSupply = BigInt(trancheSupplyBn.toString()) / BigInt(1e10);
|
|
36566
|
-
const [roundId, answer, startedAt, updatedAt, answeredInRound] = yield this.contract.MockAggregator.latestRoundData();
|
|
36567
36192
|
let ethPriceUsdBn = yield this.contract.EthUsdPriceConsumer.getPrice18Decimals();
|
|
36568
36193
|
let ethPriceUsd = BigInt(ethPriceUsdBn.toString()) / BigInt(1e10);
|
|
36569
|
-
let nativePriceTimestamp = Number(updatedAt);
|
|
36570
36194
|
const initialTrancheSupply = BigInt(INITIAL_TRANCHE_SUPPLY) * BigInt(1e8);
|
|
36571
36195
|
return buildEthereumTrancheSnapshot({
|
|
36572
36196
|
chainID,
|
|
@@ -36582,7 +36206,6 @@ class EthereumStakingClient {
|
|
|
36582
36206
|
minPriceUsd,
|
|
36583
36207
|
maxPriceUsd,
|
|
36584
36208
|
ethPriceUsd,
|
|
36585
|
-
nativePriceTimestamp,
|
|
36586
36209
|
ladderWindowBefore: windowBefore,
|
|
36587
36210
|
ladderWindowAfter: windowAfter
|
|
36588
36211
|
});
|
|
@@ -36619,36 +36242,6 @@ class EthereumStakingClient {
|
|
|
36619
36242
|
return bufferWei;
|
|
36620
36243
|
});
|
|
36621
36244
|
}
|
|
36622
|
-
updateMockAggregatorPrice() {
|
|
36623
|
-
return __async(this, null, function* () {
|
|
36624
|
-
const aggregator = this.contract.MockAggregator;
|
|
36625
|
-
const [roundId, answer, startedAt, updatedAt, answeredInRound] = yield aggregator.latestRoundData();
|
|
36626
|
-
const now = (yield this.provider.getBlock("latest")).timestamp;
|
|
36627
|
-
const ageSec = Number(now) - Number(updatedAt);
|
|
36628
|
-
const ONE_HOUR = 1 * 3600;
|
|
36629
|
-
if (ageSec > ONE_HOUR) {
|
|
36630
|
-
const network = yield this.provider.getNetwork();
|
|
36631
|
-
const chainId = network.chainId;
|
|
36632
|
-
const allowedTestChains = new Set([560048]);
|
|
36633
|
-
if (!allowedTestChains.has(chainId)) {
|
|
36634
|
-
console.warn(`MockAggregator is stale (${ageSec}s) but chainId ${chainId} is not a test/local network \u2014 skipping update.`);
|
|
36635
|
-
return;
|
|
36636
|
-
}
|
|
36637
|
-
const res = yield fetch("https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd");
|
|
36638
|
-
const data = yield res.json();
|
|
36639
|
-
const ethUsd = data.ethereum.usd;
|
|
36640
|
-
const currentEthPrice = ethers.ethers.utils.parseUnits(ethUsd.toString(), 8);
|
|
36641
|
-
try {
|
|
36642
|
-
const tx = yield aggregator.updateAnswer(currentEthPrice);
|
|
36643
|
-
const txreceipt = yield tx.wait(1);
|
|
36644
|
-
} catch (err) {
|
|
36645
|
-
console.error("MockAggregator updateAnswer failed", (err == null ? void 0 : err.message) || err);
|
|
36646
|
-
}
|
|
36647
|
-
} else {
|
|
36648
|
-
console.log(`MockAggregator updated ${ageSec}s ago \u2014 no update needed`);
|
|
36649
|
-
}
|
|
36650
|
-
});
|
|
36651
|
-
}
|
|
36652
36245
|
}
|
|
36653
36246
|
|
|
36654
36247
|
class Staker {
|
|
@@ -36658,8 +36251,8 @@ class Staker {
|
|
|
36658
36251
|
if (!Array.isArray(config)) config = [config];
|
|
36659
36252
|
config.forEach((cfg) => {
|
|
36660
36253
|
switch (cfg.network.chainId) {
|
|
36254
|
+
case core.SolChainID.Mainnet:
|
|
36661
36255
|
case core.SolChainID.Devnet:
|
|
36662
|
-
case core.SolChainID.WireTestnet:
|
|
36663
36256
|
this.clients.set(cfg.network.chainId, new SolanaStakingClient(cfg));
|
|
36664
36257
|
break;
|
|
36665
36258
|
case core.EvmChainID.Ethereum:
|
|
@@ -36703,7 +36296,6 @@ const CONTRACT_NAMES = [
|
|
|
36703
36296
|
"Base58",
|
|
36704
36297
|
"sysio_merkle",
|
|
36705
36298
|
"ReceiptNFT",
|
|
36706
|
-
"MockAggregator",
|
|
36707
36299
|
"Pool",
|
|
36708
36300
|
"OutpostManager",
|
|
36709
36301
|
"sysio_write",
|
|
@@ -36713,7 +36305,8 @@ const CONTRACT_NAMES = [
|
|
|
36713
36305
|
"OPP",
|
|
36714
36306
|
"Pretoken",
|
|
36715
36307
|
"OPPInbound",
|
|
36716
|
-
"Depositor"
|
|
36308
|
+
"Depositor",
|
|
36309
|
+
"MockAggregator"
|
|
36717
36310
|
];
|
|
36718
36311
|
|
|
36719
36312
|
var types$1 = /*#__PURE__*/Object.freeze({
|