@pufferfinance/puffer-sdk 1.27.0 → 1.28.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.
@@ -0,0 +1,201 @@
1
+ var o = Object.defineProperty;
2
+ var c = (a, t, e) => t in a ? o(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var n = (a, t, e) => c(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import { V as h } from "../../constants-C9YZ6Ewc.js";
5
+ import { CarrotVesting as m } from "../abis/mainnet/CarrotVesting.js";
6
+ import { CONTRACT_ADDRESSES as C } from "../addresses.js";
7
+ import { Token as l } from "../tokens.js";
8
+ import { ERC20PermitHandler as u } from "./erc20-permit-handler.js";
9
+ import { g as d } from "../../getContract-DEPNMZxg.js";
10
+ class V {
11
+ /**
12
+ * Create the handler for the `CarrotVesting` contract exposing methods to
13
+ * interact with the contract.
14
+ *
15
+ * @param chain Chain to use for the client.
16
+ * @param walletClient The wallet client to use for wallet
17
+ * interactions.
18
+ * @param publicClient The public client to use for public
19
+ * interactions.
20
+ */
21
+ constructor(t, e, r) {
22
+ n(this, "viemChain");
23
+ n(this, "erc20PermitHandler");
24
+ this.chain = t, this.walletClient = e, this.publicClient = r, this.viemChain = h[t], this.erc20PermitHandler = new u(
25
+ t,
26
+ e,
27
+ r
28
+ );
29
+ }
30
+ /**
31
+ * Get the contract.
32
+ *
33
+ * @returns The viem contract.
34
+ */
35
+ getContract() {
36
+ const t = C[this.chain].CarrotVesting, e = m, r = { public: this.publicClient, wallet: this.walletClient };
37
+ return d({ address: t, abi: e, client: r });
38
+ }
39
+ /**
40
+ * Get the owner of the contract.
41
+ *
42
+ * @returns The owner address.
43
+ */
44
+ owner() {
45
+ return this.getContract().read.owner();
46
+ }
47
+ /**
48
+ * Calculate the claimable amount for a user.
49
+ *
50
+ * @param user The user address.
51
+ * @returns The claimable amount.
52
+ */
53
+ calculateClaimableAmount(t) {
54
+ return this.getContract().read.calculateClaimableAmount([t]);
55
+ }
56
+ /**
57
+ * Get the exchange rate.
58
+ *
59
+ * @returns The exchange rate.
60
+ */
61
+ exchangeRate() {
62
+ return this.getContract().read.EXCHANGE_RATE();
63
+ }
64
+ /**
65
+ * Claim vested tokens.
66
+ *
67
+ * @returns The transaction.
68
+ */
69
+ claim() {
70
+ return this.getContract().write.claim({
71
+ account: this.walletClient.account,
72
+ chain: this.viemChain
73
+ });
74
+ }
75
+ /**
76
+ * Get the CARROT token address.
77
+ *
78
+ * @returns The CARROT token address.
79
+ */
80
+ getCarrotAddress() {
81
+ return this.getContract().read.CARROT();
82
+ }
83
+ /**
84
+ * Get the PUFFER token address.
85
+ *
86
+ * @returns The PUFFER token address.
87
+ */
88
+ getPufferAddress() {
89
+ return this.getContract().read.PUFFER();
90
+ }
91
+ /**
92
+ * Get the total puffer rewards.
93
+ *
94
+ * @returns The total puffer rewards.
95
+ */
96
+ totalPufferRewards() {
97
+ return this.getContract().read.TOTAL_PUFFER_REWARDS();
98
+ }
99
+ /**
100
+ * Get the number of vesting steps.
101
+ *
102
+ * @returns The number of vesting steps.
103
+ */
104
+ steps() {
105
+ return this.getContract().read.steps();
106
+ }
107
+ /**
108
+ * Get the maximum carrot amount.
109
+ *
110
+ * @returns The maximum carrot amount.
111
+ */
112
+ maxCarrotAmount() {
113
+ return this.getContract().read.MAX_CARROT_AMOUNT();
114
+ }
115
+ /**
116
+ * Get vesting information for a user.
117
+ *
118
+ * @param user The user address.
119
+ * @returns The vesting information including deposited amount, claimed amount, last claimed timestamp, and deposited timestamp.
120
+ */
121
+ async vestings(t) {
122
+ const [
123
+ e,
124
+ r,
125
+ i,
126
+ s
127
+ ] = await this.getContract().read.vestings([t]);
128
+ return {
129
+ depositedAmount: e,
130
+ claimedAmount: r,
131
+ lastClaimedTimestamp: i,
132
+ depositedTimestamp: s
133
+ };
134
+ }
135
+ /**
136
+ * Get the start timestamp.
137
+ *
138
+ * @returns The start timestamp.
139
+ */
140
+ startTimestamp() {
141
+ return this.getContract().read.startTimestamp();
142
+ }
143
+ /**
144
+ * Start vesting for a user.
145
+ *
146
+ * @param amount The amount to vest.
147
+ * @returns The transaction.
148
+ */
149
+ startVestingPreapproved(t) {
150
+ return this.getContract().write.startVesting([t], {
151
+ account: this.walletClient.account,
152
+ chain: this.viemChain
153
+ });
154
+ }
155
+ /**
156
+ * Start vesting with permit.
157
+ *
158
+ * @param permitData The permit data including deadline, amount, v, r, and s values.
159
+ * @returns The transaction.
160
+ */
161
+ startVestingWithPermit(t) {
162
+ return this.getContract().write.startVestingWithPermit([t], {
163
+ account: this.walletClient.account,
164
+ chain: this.viemChain
165
+ });
166
+ }
167
+ /**
168
+ * Start vesting.
169
+ *
170
+ * @param amount The amount to vest.
171
+ * @param isPreapproved Whether the CARROT token is preapproved or
172
+ * should use permit.
173
+ * @returns The transaction.
174
+ */
175
+ async startVesting(t, e) {
176
+ if (e)
177
+ return this.startVestingPreapproved(t);
178
+ const r = this.walletClient.account, i = await this.erc20PermitHandler.withToken(l.CARROT).getPermitData(r.address, this.getContract().address, t);
179
+ return this.startVestingWithPermit(i);
180
+ }
181
+ /**
182
+ * Get the total deposited amount.
183
+ *
184
+ * @returns The total deposited amount.
185
+ */
186
+ totalDepositedAmount() {
187
+ return this.getContract().read.totalDepositedAmount();
188
+ }
189
+ /**
190
+ * Get the duration of the vesting period.
191
+ *
192
+ * @returns The duration of the vesting period.
193
+ */
194
+ duration() {
195
+ return this.getContract().read.duration();
196
+ }
197
+ }
198
+ export {
199
+ V as CarrotVestingHandler
200
+ };
201
+ //# sourceMappingURL=carrot-vesting-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carrot-vesting-handler.js","sources":["../../../lib/contracts/handlers/carrot-vesting-handler.ts"],"sourcesContent":["import {\n Address,\n GetContractReturnType,\n PublicClient,\n Chain as ViemChain,\n WalletClient,\n getContract,\n Account,\n} from 'viem';\nimport { Chain, VIEM_CHAINS } from '../../chains/constants';\nimport { CarrotVesting } from '../abis/mainnet/CarrotVesting';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { PermitData } from '../common/lib/types';\nimport { Token } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\n\n/**\n * Handler for the `CarrotVesting` contract exposing methods to interact\n * with the contract.\n */\nexport class CarrotVestingHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `CarrotVesting` contract exposing methods to\n * interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].CarrotVesting as Address;\n const abi = CarrotVesting;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof CarrotVesting,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get the owner of the contract.\n *\n * @returns The owner address.\n */\n public owner() {\n return this.getContract().read.owner();\n }\n\n /**\n * Calculate the claimable amount for a user.\n *\n * @param user The user address.\n * @returns The claimable amount.\n */\n public calculateClaimableAmount(user: Address) {\n return this.getContract().read.calculateClaimableAmount([user]);\n }\n\n /**\n * Get the exchange rate.\n *\n * @returns The exchange rate.\n */\n public exchangeRate() {\n return this.getContract().read.EXCHANGE_RATE();\n }\n\n /**\n * Claim vested tokens.\n *\n * @returns The transaction.\n */\n public claim() {\n return this.getContract().write.claim({\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the CARROT token address.\n *\n * @returns The CARROT token address.\n */\n public getCarrotAddress() {\n return this.getContract().read.CARROT();\n }\n\n /**\n * Get the PUFFER token address.\n *\n * @returns The PUFFER token address.\n */\n public getPufferAddress() {\n return this.getContract().read.PUFFER();\n }\n\n /**\n * Get the total puffer rewards.\n *\n * @returns The total puffer rewards.\n */\n public totalPufferRewards() {\n return this.getContract().read.TOTAL_PUFFER_REWARDS();\n }\n\n /**\n * Get the number of vesting steps.\n *\n * @returns The number of vesting steps.\n */\n public steps() {\n return this.getContract().read.steps();\n }\n\n /**\n * Get the maximum carrot amount.\n *\n * @returns The maximum carrot amount.\n */\n public maxCarrotAmount() {\n return this.getContract().read.MAX_CARROT_AMOUNT();\n }\n\n /**\n * Get vesting information for a user.\n *\n * @param user The user address.\n * @returns The vesting information including deposited amount, claimed amount, last claimed timestamp, and deposited timestamp.\n */\n public async vestings(user: Address) {\n const [\n depositedAmount,\n claimedAmount,\n lastClaimedTimestamp,\n depositedTimestamp,\n ] = await this.getContract().read.vestings([user]);\n\n return {\n depositedAmount,\n claimedAmount,\n lastClaimedTimestamp,\n depositedTimestamp,\n };\n }\n\n /**\n * Get the start timestamp.\n *\n * @returns The start timestamp.\n */\n public startTimestamp() {\n return this.getContract().read.startTimestamp();\n }\n\n /**\n * Start vesting for a user.\n *\n * @param amount The amount to vest.\n * @returns The transaction.\n */\n public startVestingPreapproved(amount: bigint) {\n return this.getContract().write.startVesting([amount], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Start vesting with permit.\n *\n * @param permitData The permit data including deadline, amount, v, r, and s values.\n * @returns The transaction.\n */\n public startVestingWithPermit(permitData: PermitData) {\n return this.getContract().write.startVestingWithPermit([permitData], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Start vesting.\n *\n * @param amount The amount to vest.\n * @param isPreapproved Whether the CARROT token is preapproved or\n * should use permit.\n * @returns The transaction.\n */\n public async startVesting(amount: bigint, isPreapproved: boolean) {\n if (isPreapproved) {\n return this.startVestingPreapproved(amount);\n }\n\n const account = this.walletClient.account as Account;\n const permitData = await this.erc20PermitHandler\n .withToken(Token.CARROT)\n .getPermitData(account.address, this.getContract().address, amount);\n\n return this.startVestingWithPermit(permitData);\n }\n\n /**\n * Get the total deposited amount.\n *\n * @returns The total deposited amount.\n */\n public totalDepositedAmount() {\n return this.getContract().read.totalDepositedAmount();\n }\n\n /**\n * Get the duration of the vesting period.\n *\n * @returns The duration of the vesting period.\n */\n public duration() {\n return this.getContract().read.duration();\n }\n}\n"],"names":["CarrotVestingHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","CarrotVesting","client","getContract","user","depositedAmount","claimedAmount","lastClaimedTimestamp","depositedTimestamp","amount","permitData","isPreapproved","account","Token"],"mappings":";;;;;;;;;AAoBO,MAAMA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAchC,YACUC,GACAC,GACAC,GACR;AAjBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AAaE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK,GAClC,KAAK,qBAAqB,IAAIK;AAAA,MAC5BL;AAAA,MACAC;AAAA,MACAC;AAAA,IACF;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQK,cAAc;AACnB,UAAMI,IAAUC,EAAmB,KAAK,KAAK,EAAE,eACzCC,IAAMC,GACNC,IAAS,EAAE,QAAQ,KAAK,cAAc,QAAQ,KAAK,aAAa;AAEtE,WAAOC,EAAY,EAAE,SAAAL,GAAS,KAAAE,GAAK,QAAAE,GAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYtC,QAAQ;AACb,WAAO,KAAK,cAAc,KAAK,MAAM;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShC,yBAAyBE,GAAe;AAC7C,WAAO,KAAK,YAAY,E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AA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzC,wBAAwBC,GAAgB;AAC7C,WAAO,KAAK,YAAY,EAAE,MAAM,aAAa,CAACA,CAAM,GAAG;AAAA,MACrD,SAAS,KAAK,aAAa;AAAA,MAC3B,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,uBAAuBC,GAAwB;AACpD,WAAO,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAACA,CAAU,GAAG;AAAA,MACnE,SAAS,KAAK,aAAa;AAAA,MAC3B,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWH,MAAa,aAAaD,GAAgBE,GAAwB;AAChE,QAAIA;AACK,aAAA,KAAK,wBAAwBF,CAAM;AAGtC,UAAAG,IAAU,KAAK,aAAa,SAC5BF,IAAa,MAAM,KAAK,mBAC3B,UAAUG,EAAM,MAAM,EACtB,cAAcD,EAAQ,SAAS,KAAK,YAAY,EAAE,SAASH,CAAM;AAE7D,WAAA,KAAK,uBAAuBC,CAAU;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxC,uBAAuB;AAC5B,WAAO,KAAK,cAAc,KAAK,qBAAqB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ/C,WAAW;AAChB,WAAO,KAAK,cAAc,KAAK,SAAS;AAAA,EAAA;AAE5C;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="1.26.2",o=e;exports.version=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="1.27.1",o=e;exports.version=o;
2
2
  //# sourceMappingURL=version.cjs.map
@@ -1,4 +1,4 @@
1
- const o = "1.26.2", n = o;
1
+ const o = "1.27.1", n = o;
2
2
  export {
3
3
  n as version
4
4
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pufferfinance/puffer-sdk",
3
3
  "description": "SDK for interacting with the puffer smart contracts",
4
- "version": "1.27.0",
4
+ "version": "1.28.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/PufferFinance/puffer-sdk.git"