@gearbox-protocol/sdk 3.0.0-next.44 → 3.0.0-next.45

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.
@@ -0,0 +1,40 @@
1
+ import { GaugeQuotaParams } from "../payload/gauge";
2
+ export type BaseVoteType = "raise" | "lower";
3
+ export type VoteType = BaseVoteType | "remove";
4
+ export interface BaseVote {
5
+ amount: bigint;
6
+ type: BaseVoteType;
7
+ }
8
+ export interface Vote {
9
+ amount: bigint;
10
+ type: VoteType;
11
+ }
12
+ export interface SingleVoteState {
13
+ available: bigint;
14
+ vote?: BaseVote;
15
+ voteCalls: Array<Vote>;
16
+ }
17
+ export interface VoteProps {
18
+ state: Omit<SingleVoteState, "voteCalls">;
19
+ change?: Vote;
20
+ }
21
+ interface UnvoteProps {
22
+ initialVote?: BaseVote;
23
+ balanceAfter: bigint;
24
+ nextVoteType: BaseVoteType;
25
+ voteAfter?: Omit<SingleVoteState, "available">;
26
+ }
27
+ export interface GetGaugeApyProps {
28
+ quota: Pick<GaugeQuotaParams, "totalVotesCaSide" | "totalVotesLpSide" | "stakerVotesCaSide" | "stakerVotesLpSide" | "minRate" | "maxRate"> | undefined;
29
+ vote?: BaseVote;
30
+ voteAfter?: Omit<SingleVoteState, "available">;
31
+ }
32
+ export declare class GaugeMath {
33
+ static vote({ change, ...rest }: VoteProps): SingleVoteState | undefined;
34
+ private static addVotes;
35
+ private static removeVotes;
36
+ static revertVote({ balanceAfter, initialVote, nextVoteType, voteAfter, }: UnvoteProps): bigint | undefined;
37
+ static getBaseVote: (v: GaugeQuotaParams) => BaseVote | undefined;
38
+ static getGaugeApy({ quota, voteAfter, vote }: GetGaugeApyProps): number | null;
39
+ }
40
+ export {};
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GaugeMath = void 0;
4
+ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
+ const math_1 = require("../utils/math");
6
+ class GaugeMath {
7
+ static vote({ change, ...rest }) {
8
+ if (change?.type === "remove") {
9
+ return this.removeVotes({ ...rest, change });
10
+ }
11
+ if (change) {
12
+ return this.addVotes({
13
+ ...rest,
14
+ change: { ...change, type: change.type },
15
+ });
16
+ }
17
+ return { ...rest.state, voteCalls: [] };
18
+ }
19
+ static addVotes({ state, change }) {
20
+ const { available, vote } = state;
21
+ if (!vote) {
22
+ return {
23
+ available: available - change.amount,
24
+ vote: change,
25
+ voteCalls: [change],
26
+ };
27
+ }
28
+ if (vote.type === change.type) {
29
+ return {
30
+ available: available - change.amount,
31
+ vote: { ...change, amount: vote.amount + change.amount },
32
+ voteCalls: [change],
33
+ };
34
+ }
35
+ const remove = { type: "remove", amount: vote.amount };
36
+ return {
37
+ available: available + vote.amount - change.amount,
38
+ vote: { ...change, amount: change.amount },
39
+ voteCalls: [remove, change],
40
+ };
41
+ }
42
+ static removeVotes({ state, change }) {
43
+ const { available, vote } = state;
44
+ if (!vote)
45
+ return { ...state, voteCalls: [] };
46
+ const safeChange = math_1.BigIntMath.min(vote.amount, change.amount);
47
+ const afterVote = vote.amount - safeChange;
48
+ return {
49
+ available: available + safeChange,
50
+ vote: { ...vote, amount: afterVote },
51
+ voteCalls: [{ ...change, amount: safeChange }],
52
+ };
53
+ }
54
+ static revertVote({ balanceAfter, initialVote, nextVoteType, voteAfter, }) {
55
+ // on vote type change unvote previous vote
56
+ const prevUnvoted = !initialVote || initialVote.type === nextVoteType
57
+ ? balanceAfter
58
+ : balanceAfter + initialVote.amount;
59
+ if (!voteAfter)
60
+ return prevUnvoted;
61
+ // change call is always last, remove is always first
62
+ const [first, last = first] = voteAfter.voteCalls;
63
+ const removePart = first?.type === "remove" ? first?.amount || 0n : 0n;
64
+ const addPart = last?.type !== "remove" ? last?.amount || 0n : 0n;
65
+ // revert current changes
66
+ return prevUnvoted + addPart - removePart;
67
+ }
68
+ static getBaseVote = (v) => {
69
+ const voteDown = v.stakerVotesCaSide;
70
+ const voteUp = v.stakerVotesLpSide;
71
+ if (!voteDown && !voteUp)
72
+ return undefined;
73
+ if (voteDown > 0) {
74
+ return { type: "lower", amount: voteDown };
75
+ }
76
+ if (voteUp > 0) {
77
+ return { type: "raise", amount: voteUp };
78
+ }
79
+ return undefined;
80
+ };
81
+ // rate = (minRate *(votesFormin + yourvotesformin) +maxRate*(votesFormax +yourvotesformax)/( votesForMin + votesForMax+yourvotes)
82
+ static getGaugeApy({ quota, voteAfter, vote }) {
83
+ if (!quota)
84
+ return null;
85
+ const first = voteAfter?.voteCalls?.[0];
86
+ const last = voteAfter?.voteCalls?.[1] || first;
87
+ const isRemove = first?.type === "remove";
88
+ const removeCaPart = isRemove && vote?.type === "lower" ? first?.amount || 0n : 0n;
89
+ const removeLpPart = isRemove && vote?.type === "raise" ? first?.amount || 0n : 0n;
90
+ const caPart = last?.type === "lower" ? last?.amount || 0n : 0n;
91
+ const lpPart = last?.type === "raise" ? last?.amount || 0n : 0n;
92
+ const caImpact = (0, sdk_gov_1.toBigInt)(quota.minRate) *
93
+ (quota.totalVotesCaSide + caPart - removeCaPart);
94
+ const lpImpact = (0, sdk_gov_1.toBigInt)(quota.maxRate) *
95
+ (quota.totalVotesLpSide + lpPart - removeLpPart);
96
+ const total = quota.totalVotesCaSide +
97
+ quota.totalVotesLpSide +
98
+ caPart +
99
+ lpPart -
100
+ removeCaPart -
101
+ removeLpPart;
102
+ if (total === 0n)
103
+ return quota.minRate;
104
+ const r = (caImpact + lpImpact) / total;
105
+ return Number(r);
106
+ }
107
+ }
108
+ exports.GaugeMath = GaugeMath;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,388 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const gaugeMath_1 = require("./gaugeMath");
5
+ describe("GaugeMath vote() test", () => {
6
+ it("with empty state and with no changes", () => {
7
+ const s = { available: 0n, voteCalls: [] };
8
+ const v = { state: s };
9
+ const r = gaugeMath_1.GaugeMath.vote(v);
10
+ const res = { ...s, voteCalls: [] };
11
+ (0, chai_1.expect)(r).to.be.eql(res);
12
+ });
13
+ it("remove with no prev vote", () => {
14
+ const s = { available: 0n, voteCalls: [] };
15
+ const v = { state: s, change: { type: "remove", amount: 10n } };
16
+ const r = gaugeMath_1.GaugeMath.vote(v);
17
+ const res = { ...s, voteCalls: [] };
18
+ (0, chai_1.expect)(r).to.be.eql(res);
19
+ });
20
+ it("remove with prev vote - more than available", () => {
21
+ const s = {
22
+ available: 0n,
23
+ vote: { type: "lower", amount: 5n },
24
+ voteCalls: [],
25
+ };
26
+ const v = { state: s, change: { type: "remove", amount: 10n } };
27
+ const r = gaugeMath_1.GaugeMath.vote(v);
28
+ const res = {
29
+ available: 5n,
30
+ vote: { type: "lower", amount: 0n },
31
+ voteCalls: [{ type: "remove", amount: 5n }],
32
+ };
33
+ (0, chai_1.expect)(r).to.be.eql(res);
34
+ });
35
+ it("remove with prev vote - eq than available", () => {
36
+ const s = {
37
+ available: 0n,
38
+ vote: { type: "lower", amount: 5n },
39
+ voteCalls: [],
40
+ };
41
+ const v = { state: s, change: { type: "remove", amount: 5n } };
42
+ const r = gaugeMath_1.GaugeMath.vote(v);
43
+ const res = {
44
+ available: 5n,
45
+ vote: { type: "lower", amount: 0n },
46
+ voteCalls: [{ type: "remove", amount: 5n }],
47
+ };
48
+ (0, chai_1.expect)(r).to.be.eql(res);
49
+ });
50
+ it("remove with prev vote - more than available", () => {
51
+ const s = {
52
+ available: 0n,
53
+ vote: { type: "lower", amount: 10n },
54
+ voteCalls: [],
55
+ };
56
+ const v = { state: s, change: { type: "remove", amount: 5n } };
57
+ const r = gaugeMath_1.GaugeMath.vote(v);
58
+ const res = {
59
+ available: 5n,
60
+ vote: { type: "lower", amount: 5n },
61
+ voteCalls: [{ type: "remove", amount: 5n }],
62
+ };
63
+ (0, chai_1.expect)(r).to.be.eql(res);
64
+ });
65
+ it("add to zero", () => {
66
+ const s = { available: 10n, voteCalls: [] };
67
+ const v = { state: s, change: { type: "lower", amount: 10n } };
68
+ const r = gaugeMath_1.GaugeMath.vote(v);
69
+ const res = {
70
+ available: 0n,
71
+ vote: { type: "lower", amount: 10n },
72
+ voteCalls: [{ type: "lower", amount: 10n }],
73
+ };
74
+ (0, chai_1.expect)(r).to.be.eql(res);
75
+ });
76
+ it("add to same type", () => {
77
+ const s = {
78
+ available: 10n,
79
+ vote: { type: "lower", amount: 5n },
80
+ voteCalls: [],
81
+ };
82
+ const v = { state: s, change: { type: "lower", amount: 10n } };
83
+ const r = gaugeMath_1.GaugeMath.vote(v);
84
+ const res = {
85
+ available: 0n,
86
+ vote: { type: "lower", amount: 15n },
87
+ voteCalls: [{ type: "lower", amount: 10n }],
88
+ };
89
+ (0, chai_1.expect)(r).to.be.eql(res);
90
+ });
91
+ it("add different type", () => {
92
+ const s = {
93
+ available: 10n,
94
+ vote: { type: "lower", amount: 10n },
95
+ voteCalls: [],
96
+ };
97
+ const v = { state: s, change: { type: "raise", amount: 5n } };
98
+ const r = gaugeMath_1.GaugeMath.vote(v);
99
+ const res = {
100
+ available: 15n,
101
+ vote: { type: "raise", amount: 5n },
102
+ voteCalls: [
103
+ { type: "remove", amount: 10n },
104
+ { type: "raise", amount: 5n },
105
+ ],
106
+ };
107
+ (0, chai_1.expect)(r).to.be.eql(res);
108
+ });
109
+ it("available can be negative after add", () => {
110
+ const s = {
111
+ available: 5n,
112
+ vote: { type: "lower", amount: 5n },
113
+ voteCalls: [],
114
+ };
115
+ const v = { state: s, change: { type: "raise", amount: 15n } };
116
+ const r = gaugeMath_1.GaugeMath.vote(v);
117
+ const res = {
118
+ available: -5n,
119
+ vote: { type: "raise", amount: 15n },
120
+ voteCalls: [
121
+ { type: "remove", amount: 5n },
122
+ { type: "raise", amount: 15n },
123
+ ],
124
+ };
125
+ (0, chai_1.expect)(r).to.be.eql(res);
126
+ });
127
+ });
128
+ describe("GaugeMath revertVote() test", () => {
129
+ it("if no votes before & after, should return initial amount", () => {
130
+ const initialBalance = 21n;
131
+ const r = gaugeMath_1.GaugeMath.revertVote({
132
+ balanceAfter: initialBalance,
133
+ nextVoteType: "lower",
134
+ });
135
+ (0, chai_1.expect)(r).to.be.eql(initialBalance);
136
+ });
137
+ it("if no vote after and next expected type is not changed, should return initial amount", () => {
138
+ const initialBalance = 27n;
139
+ const initialVote = {
140
+ type: "lower",
141
+ amount: 99n,
142
+ };
143
+ const r = gaugeMath_1.GaugeMath.revertVote({
144
+ balanceAfter: initialBalance,
145
+ initialVote,
146
+ nextVoteType: "lower",
147
+ });
148
+ (0, chai_1.expect)(r).to.be.eql(initialBalance);
149
+ });
150
+ it("if no vote after and next expected type is changed, should revert initial vote", () => {
151
+ const initialBalance = 27n;
152
+ const initialVote = {
153
+ type: "lower",
154
+ amount: 99n,
155
+ };
156
+ const r = gaugeMath_1.GaugeMath.revertVote({
157
+ balanceAfter: initialBalance,
158
+ initialVote,
159
+ nextVoteType: "raise",
160
+ });
161
+ (0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
162
+ });
163
+ it("if no vote before, should revert vote after", () => {
164
+ const initialBalance = 26n;
165
+ const voteBy = 5n;
166
+ const voteAfter = {
167
+ available: initialBalance - voteBy,
168
+ vote: { type: "lower", amount: voteBy },
169
+ voteCalls: [{ type: "lower", amount: voteBy }],
170
+ };
171
+ const balanceAfter = voteAfter.available;
172
+ const r = gaugeMath_1.GaugeMath.revertVote({
173
+ balanceAfter,
174
+ nextVoteType: "lower",
175
+ voteAfter: voteAfter,
176
+ });
177
+ (0, chai_1.expect)(r).to.be.eql(initialBalance);
178
+ });
179
+ it("if vote before type matches expected type, should revert vote after", () => {
180
+ const initialBalance = 10n;
181
+ const voteBy = 6n;
182
+ const initialVote = {
183
+ type: "lower",
184
+ amount: 20n,
185
+ };
186
+ const voteAfter = {
187
+ available: initialBalance - voteBy,
188
+ vote: { type: "lower", amount: initialVote.amount + voteBy },
189
+ voteCalls: [{ type: "lower", amount: voteBy }],
190
+ };
191
+ const balanceAfter = voteAfter.available;
192
+ const r = gaugeMath_1.GaugeMath.revertVote({
193
+ initialVote,
194
+ balanceAfter,
195
+ nextVoteType: "lower",
196
+ voteAfter: voteAfter,
197
+ });
198
+ (0, chai_1.expect)(r).to.be.eql(initialBalance);
199
+ });
200
+ it("if vote before type doesn't match expected type, should revert vote before", () => {
201
+ const initialBalance = 10n;
202
+ const voteBy = 20n;
203
+ const initialVote = {
204
+ type: "raise",
205
+ amount: 61n,
206
+ };
207
+ const voteAfter = {
208
+ available: initialBalance + initialVote.amount - voteBy,
209
+ vote: { type: "lower", amount: voteBy },
210
+ voteCalls: [
211
+ { type: "remove", amount: initialVote.amount },
212
+ { type: "lower", amount: voteBy },
213
+ ],
214
+ };
215
+ const r = gaugeMath_1.GaugeMath.revertVote({
216
+ initialVote,
217
+ balanceAfter: voteAfter.available,
218
+ nextVoteType: "lower",
219
+ voteAfter: voteAfter,
220
+ });
221
+ (0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
222
+ });
223
+ it("on remove, if vote before type matches expected type, should revert removal", () => {
224
+ const initialBalance = 100n;
225
+ const voteBy = 13n;
226
+ const initialVote = {
227
+ type: "lower",
228
+ amount: 30n,
229
+ };
230
+ const voteAfter = {
231
+ available: initialBalance + voteBy,
232
+ vote: { type: "lower", amount: initialVote.amount - voteBy },
233
+ voteCalls: [{ type: "remove", amount: voteBy }],
234
+ };
235
+ const r = gaugeMath_1.GaugeMath.revertVote({
236
+ initialVote,
237
+ balanceAfter: voteAfter.available,
238
+ nextVoteType: "lower",
239
+ voteAfter: voteAfter,
240
+ });
241
+ (0, chai_1.expect)(r).to.be.eql(initialBalance);
242
+ });
243
+ it("on remove, if vote before type doesn't match expected type, should revert vote before", () => {
244
+ const initialBalance = 100n;
245
+ const voteBy = 13n;
246
+ const initialVote = {
247
+ type: "raise",
248
+ amount: 30n,
249
+ };
250
+ const voteAfter = {
251
+ available: initialBalance + voteBy,
252
+ vote: { type: "raise", amount: initialVote.amount - voteBy },
253
+ voteCalls: [{ type: "remove", amount: voteBy }],
254
+ };
255
+ const r = gaugeMath_1.GaugeMath.revertVote({
256
+ initialVote,
257
+ balanceAfter: voteAfter.available,
258
+ nextVoteType: "lower",
259
+ voteAfter: voteAfter,
260
+ });
261
+ (0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
262
+ });
263
+ });
264
+ describe("GaugeMath getGaugeApy() test", () => {
265
+ it("should return null if no quota", () => {
266
+ const vote = { amount: 0n, type: "lower" };
267
+ const voteAfter = {
268
+ vote: { amount: 5n, type: "lower" },
269
+ voteCalls: [{ amount: 5n, type: "lower" }],
270
+ };
271
+ const r = gaugeMath_1.GaugeMath.getGaugeApy({
272
+ quota: undefined,
273
+ vote,
274
+ voteAfter,
275
+ });
276
+ (0, chai_1.expect)(r).to.be.eql(null);
277
+ });
278
+ it("should return min rate if total is zero", () => {
279
+ const quota = {
280
+ totalVotesCaSide: 0n,
281
+ totalVotesLpSide: 0n,
282
+ stakerVotesCaSide: 0n,
283
+ stakerVotesLpSide: 0n,
284
+ minRate: 12,
285
+ maxRate: 12345,
286
+ };
287
+ const r = gaugeMath_1.GaugeMath.getGaugeApy({
288
+ quota,
289
+ });
290
+ (0, chai_1.expect)(r).to.be.eql(12);
291
+ });
292
+ it("should calculate quota without votes", () => {
293
+ const quota = {
294
+ totalVotesCaSide: 100n,
295
+ totalVotesLpSide: 100n,
296
+ stakerVotesCaSide: 10n,
297
+ stakerVotesLpSide: 0n,
298
+ minRate: 0,
299
+ maxRate: 10000,
300
+ };
301
+ const r = gaugeMath_1.GaugeMath.getGaugeApy({
302
+ quota,
303
+ });
304
+ (0, chai_1.expect)(r).to.be.eql(5000);
305
+ });
306
+ it("should calculate quota with prev vote", () => {
307
+ const quota = {
308
+ totalVotesCaSide: 100n,
309
+ totalVotesLpSide: 100n,
310
+ stakerVotesCaSide: 10n,
311
+ stakerVotesLpSide: 0n,
312
+ minRate: 0,
313
+ maxRate: 10000,
314
+ };
315
+ const vote = { amount: 10n, type: "lower" };
316
+ const r = gaugeMath_1.GaugeMath.getGaugeApy({
317
+ quota,
318
+ vote,
319
+ });
320
+ (0, chai_1.expect)(r).to.be.eql(5000);
321
+ });
322
+ it("should calculate quota with same vote increase", () => {
323
+ const quota = {
324
+ totalVotesCaSide: 100n,
325
+ totalVotesLpSide: 100n,
326
+ stakerVotesCaSide: 10n,
327
+ stakerVotesLpSide: 0n,
328
+ minRate: 0,
329
+ maxRate: 10000,
330
+ };
331
+ const vote = { amount: 10n, type: "lower" };
332
+ const voteAfter = {
333
+ vote: { amount: 20n, type: "lower" },
334
+ voteCalls: [{ amount: 10n, type: "lower" }],
335
+ };
336
+ const r = gaugeMath_1.GaugeMath.getGaugeApy({
337
+ quota,
338
+ vote,
339
+ voteAfter,
340
+ });
341
+ (0, chai_1.expect)(r).to.be.eql(4761);
342
+ });
343
+ it("should calculate quota with different vote increase", () => {
344
+ const quota = {
345
+ totalVotesCaSide: 100n,
346
+ totalVotesLpSide: 100n,
347
+ stakerVotesCaSide: 20n,
348
+ stakerVotesLpSide: 0n,
349
+ minRate: 0,
350
+ maxRate: 10000,
351
+ };
352
+ const vote = { amount: 30n, type: "lower" };
353
+ const voteAfter = {
354
+ vote: { amount: 20n, type: "raise" },
355
+ voteCalls: [
356
+ { amount: 30n, type: "remove" },
357
+ { amount: 20n, type: "raise" },
358
+ ],
359
+ };
360
+ const r = gaugeMath_1.GaugeMath.getGaugeApy({
361
+ quota,
362
+ vote,
363
+ voteAfter,
364
+ });
365
+ (0, chai_1.expect)(r).to.be.eql(6315);
366
+ });
367
+ it("should calculate quota with vote remove", () => {
368
+ const quota = {
369
+ totalVotesCaSide: 100n,
370
+ totalVotesLpSide: 100n,
371
+ stakerVotesCaSide: 20n,
372
+ stakerVotesLpSide: 0n,
373
+ minRate: 0,
374
+ maxRate: 10000,
375
+ };
376
+ const vote = { amount: 20n, type: "lower" };
377
+ const voteAfter = {
378
+ vote: { amount: 0n, type: "lower" },
379
+ voteCalls: [{ amount: 20n, type: "remove" }],
380
+ };
381
+ const r = gaugeMath_1.GaugeMath.getGaugeApy({
382
+ quota,
383
+ vote,
384
+ voteAfter,
385
+ });
386
+ (0, chai_1.expect)(r).to.be.eql(5555);
387
+ });
388
+ });
@@ -2,7 +2,7 @@ import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
2
  import { Asset } from "./assets";
3
3
  import { EVMTx, EVMTxProps } from "./eventOrTx";
4
4
  export interface TxSerialized {
5
- type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim";
5
+ type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote";
6
6
  content: string;
7
7
  }
8
8
  export declare class TxSerializer {
@@ -224,4 +224,17 @@ export declare class TxGaugeClaim extends EVMTx {
224
224
  toString(): string;
225
225
  serialize(): TxSerialized;
226
226
  }
227
+ interface TxGaugeVoteProps extends EVMTxProps {
228
+ tokens: Array<{
229
+ token: string;
230
+ }>;
231
+ }
232
+ export declare class TxGaugeVote extends EVMTx {
233
+ readonly tokens: Array<{
234
+ token: string;
235
+ }>;
236
+ constructor(opts: TxGaugeVoteProps);
237
+ toString(): string;
238
+ serialize(): TxSerialized;
239
+ }
227
240
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
3
+ exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
4
4
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
5
  const contractsRegister_1 = require("../contracts/contractsRegister");
6
6
  const math_1 = require("../utils/math");
@@ -51,6 +51,8 @@ class TxSerializer {
51
51
  return new TxGaugeUnstake(params);
52
52
  case "TxGaugeClaim":
53
53
  return new TxGaugeClaim(params);
54
+ case "TxGaugeVote":
55
+ return new TxGaugeVote(params);
54
56
  default:
55
57
  throw new Error(`Unknown transaction for parsing: ${e.type}`);
56
58
  }
@@ -478,3 +480,24 @@ class TxGaugeClaim extends eventOrTx_1.EVMTx {
478
480
  }
479
481
  }
480
482
  exports.TxGaugeClaim = TxGaugeClaim;
483
+ class TxGaugeVote extends eventOrTx_1.EVMTx {
484
+ tokens;
485
+ constructor(opts) {
486
+ super(opts);
487
+ this.tokens = opts.tokens;
488
+ }
489
+ toString() {
490
+ const votes = this.tokens.map(({ token }) => {
491
+ const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(token);
492
+ return tokenSymbol;
493
+ });
494
+ return `Gauge: voted for ${votes.join(", ")}`;
495
+ }
496
+ serialize() {
497
+ return {
498
+ type: "TxGaugeVote",
499
+ content: JSON.stringify(this),
500
+ };
501
+ }
502
+ }
503
+ exports.TxGaugeVote = TxGaugeVote;
package/lib/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./core/errors";
8
8
  export * from "./core/eventOrTx";
9
9
  export * from "./core/events";
10
10
  export * from "./core/gauge";
11
+ export * from "./core/gaugeMath";
11
12
  export * from "./core/pool";
12
13
  export * from "./core/rewardClaimer";
13
14
  export * from "./core/strategy";
package/lib/index.js CHANGED
@@ -25,6 +25,7 @@ __exportStar(require("./core/errors"), exports);
25
25
  __exportStar(require("./core/eventOrTx"), exports);
26
26
  __exportStar(require("./core/events"), exports);
27
27
  __exportStar(require("./core/gauge"), exports);
28
+ __exportStar(require("./core/gaugeMath"), exports);
28
29
  __exportStar(require("./core/pool"), exports);
29
30
  __exportStar(require("./core/rewardClaimer"), exports);
30
31
  __exportStar(require("./core/strategy"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.44",
3
+ "version": "3.0.0-next.45",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",