Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 55 additions & 61 deletions lib/contracts/abis/mainnet/CarrotVesting.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
export const CarrotVesting = <const>[
{
type: 'function',
name: 'steps',
stateMutability: 'view',
outputs: [{ type: 'uint32', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'EXCHANGE_RATE',
stateMutability: 'view',
outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'PUFFER_RECOVERY_GRACE_PERIOD',
name: 'calculateClaimableAmount',
stateMutability: 'view',
inputs: [{ type: 'address', name: 'user', simpleType: 'address' }],
outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
Expand All @@ -29,85 +15,98 @@ export const CarrotVesting = <const>[
},
{
type: 'function',
name: 'startPufferRecovery',
name: 'claim',
stateMutability: 'nonpayable',
outputs: [{ type: 'uint128', name: '', simpleType: 'uint' }],
inputs: [],
outputs: [],
},
{
type: 'function',
name: 'TOTAL_PUFFER_REWARDS',
name: 'owner',
stateMutability: 'view',
outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'claim',
stateMutability: 'nonpayable',
outputs: [{ type: 'uint128', name: '', simpleType: 'uint' }],
outputs: [{ type: 'address', name: '', simpleType: 'address' }],
inputs: [],
},
{
type: 'function',
name: 'totalDepositedAmount',
name: 'getTotalDepositedAmount',
stateMutability: 'view',
outputs: [{ type: 'uint128', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'startVestingWithPermit',
stateMutability: 'nonpayable',
inputs: [
name: 'getVestings',
stateMutability: 'view',
inputs: [{ type: 'address', name: 'user', simpleType: 'address' }],
outputs: [
{
type: 'tuple',
name: 'permitData',
simpleType: 'tuple',
type: 'tuple[]',
name: '',
simpleType: 'slice',
nestedType: { type: 'tuple' },
components: [
{ type: 'uint256', name: 'deadline', simpleType: 'uint' },
{ type: 'uint256', name: 'amount', simpleType: 'uint' },
{ type: 'uint8', name: 'v', simpleType: 'uint' },
{ type: 'bytes32', name: 'r', simpleType: 'bytes' },
{ type: 'bytes32', name: 's', simpleType: 'bytes' },
{ type: 'uint128', name: 'depositedAmount', simpleType: 'uint' },
{ type: 'uint128', name: 'claimedAmount', simpleType: 'uint' },
{ type: 'uint48', name: 'lastClaimedTimestamp', simpleType: 'uint' },
{ type: 'uint48', name: 'depositedTimestamp', simpleType: 'uint' },
],
},
],
outputs: [],
},
{
type: 'function',
name: 'startTimestamp',
name: 'TOTAL_PUFFER_REWARDS',
stateMutability: 'view',
outputs: [{ type: 'uint48', name: '', simpleType: 'uint' }],
outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'MAX_CARROT_AMOUNT',
name: 'getDuration',
stateMutability: 'view',
outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],
outputs: [{ type: 'uint32', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'owner',
name: 'startVesting',
stateMutability: 'nonpayable',
inputs: [{ type: 'uint256', name: 'amount', simpleType: 'uint' }],
outputs: [],
},
{
type: 'function',
name: 'getSteps',
stateMutability: 'view',
outputs: [{ type: 'address', name: '', simpleType: 'address' }],
outputs: [{ type: 'uint32', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'duration',
name: 'EXCHANGE_RATE',
stateMutability: 'view',
outputs: [{ type: 'uint32', name: '', simpleType: 'uint' }],
outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'startVesting',
name: 'startVestingWithPermit',
stateMutability: 'nonpayable',
inputs: [{ type: 'uint256', name: 'amount', simpleType: 'uint' }],
inputs: [
{
type: 'tuple',
name: 'permitData',
simpleType: 'tuple',
components: [
{ type: 'uint256', name: 'deadline', simpleType: 'uint' },
{ type: 'uint256', name: 'amount', simpleType: 'uint' },
{ type: 'uint8', name: 'v', simpleType: 'uint' },
{ type: 'bytes32', name: 'r', simpleType: 'bytes' },
{ type: 'bytes32', name: 's', simpleType: 'bytes' },
],
},
],
outputs: [],
},
{
Expand All @@ -119,21 +118,16 @@ export const CarrotVesting = <const>[
},
{
type: 'function',
name: 'vestings',
name: 'getStartTimestamp',
stateMutability: 'view',
inputs: [{ type: 'address', name: 'user', simpleType: 'address' }],
outputs: [
{ type: 'uint128', name: 'depositedAmount', simpleType: 'uint' },
{ type: 'uint128', name: 'claimedAmount', simpleType: 'uint' },
{ type: 'uint48', name: 'lastClaimedTimestamp', simpleType: 'uint' },
{ type: 'uint48', name: 'depositedTimestamp', simpleType: 'uint' },
],
outputs: [{ type: 'uint48', name: '', simpleType: 'uint' }],
inputs: [],
},
{
type: 'function',
name: 'calculateClaimableAmount',
name: 'MAX_CARROT_AMOUNT',
stateMutability: 'view',
inputs: [{ type: 'address', name: 'user', simpleType: 'address' }],
outputs: [{ type: 'uint128', name: '', simpleType: 'uint' }],
outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],
inputs: [],
},
];
3 changes: 2 additions & 1 deletion lib/contracts/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const CONTRACT_ADDRESSES = {
PufferProtocol: '0xf7b6B32492c2e13799D921E84202450131bd238B',
GuardianModule: '0x628b183F248a142A598AA2dcCCD6f7E480a7CcF2',
GaugeRegistry: '0x0000000000000000000000000000000000000000',
CarrotVesting: '0xE4c36adB90E936041776Ddb87851Ec38aFfD1499',
// TODO: Replace this with the actual address when the contract is deployed.
CarrotVesting: '0x5e9c5f4553bceb4a1c3b66cc028e6ae2e2a52c6e',
},
[Chain.Holesky as number]: {
PufferVault: '0x9196830bB4c05504E0A8475A0aD566AceEB6BeC9',
Expand Down
29 changes: 12 additions & 17 deletions lib/contracts/handlers/__tests__/carrot-vesting-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ describe('CarrotVestingHandler', () => {

it('should get the number of vesting steps', async () => {
const steps = 10;
contractTestingUtils.mockCall('steps', [steps]);
contractTestingUtils.mockCall('getSteps', [steps]);

const result = await handler.steps();
const result = await handler.getSteps();
expect(result).toBe(steps);
});

Expand All @@ -103,28 +103,23 @@ describe('CarrotVestingHandler', () => {

it('should get vesting information for a user', async () => {
const user = generateAddress();
const vestingInfo = {
const vestingInfo = <const>{
depositedAmount: 1000n,
claimedAmount: 500n,
lastClaimedTimestamp: 1234567890,
depositedTimestamp: 1234567890,
};
contractTestingUtils.mockCall('vestings', [
vestingInfo.depositedAmount,
vestingInfo.claimedAmount,
vestingInfo.lastClaimedTimestamp,
vestingInfo.depositedTimestamp,
]);
contractTestingUtils.mockCall('getVestings', [[vestingInfo]]);

const result = await handler.vestings(user);
expect(result).toEqual(vestingInfo);
const result = await handler.getVestings(user);
expect(result).toEqual([vestingInfo]);
});

it('should get the start timestamp', async () => {
const startTimestamp = 1234567890;
contractTestingUtils.mockCall('startTimestamp', [startTimestamp]);
contractTestingUtils.mockCall('getStartTimestamp', [startTimestamp]);

const result = await handler.startTimestamp();
const result = await handler.getStartTimestamp();
expect(result).toBe(startTimestamp);
});

Expand Down Expand Up @@ -197,19 +192,19 @@ describe('CarrotVestingHandler', () => {

it('should get the total deposited amount', async () => {
const totalDepositedAmount = 50000n;
contractTestingUtils.mockCall('totalDepositedAmount', [
contractTestingUtils.mockCall('getTotalDepositedAmount', [
totalDepositedAmount,
]);

const result = await handler.totalDepositedAmount();
const result = await handler.getTotalDepositedAmount();
expect(result).toBe(totalDepositedAmount);
});

it('should get the duration of the vesting period', async () => {
const duration = 365;
contractTestingUtils.mockCall('duration', [duration]);
contractTestingUtils.mockCall('getDuration', [duration]);

const result = await handler.duration();
const result = await handler.getDuration();
expect(result).toBe(duration);
});
});
32 changes: 10 additions & 22 deletions lib/contracts/handlers/carrot-vesting-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ export class CarrotVestingHandler {
*
* @returns The number of vesting steps.
*/
public steps() {
return this.getContract().read.steps();
public getSteps() {
return this.getContract().read.getSteps();
}

/**
Expand All @@ -154,29 +154,17 @@ export class CarrotVestingHandler {
* @returns The vesting information including deposited amount,
* claimed amount, last claimed timestamp, and deposited timestamp.
*/
public async vestings(user: Address) {
const [
depositedAmount,
claimedAmount,
lastClaimedTimestamp,
depositedTimestamp,
] = await this.getContract().read.vestings([user]);

return {
depositedAmount,
claimedAmount,
lastClaimedTimestamp,
depositedTimestamp,
};
public async getVestings(user: Address) {
return await this.getContract().read.getVestings([user]);
}

/**
* Get the start timestamp.
*
* @returns The start timestamp.
*/
public startTimestamp() {
return this.getContract().read.startTimestamp();
public getStartTimestamp() {
return this.getContract().read.getStartTimestamp();
}

/**
Expand Down Expand Up @@ -231,16 +219,16 @@ export class CarrotVestingHandler {
*
* @returns The total deposited amount.
*/
public totalDepositedAmount() {
return this.getContract().read.totalDepositedAmount();
public getTotalDepositedAmount() {
return this.getContract().read.getTotalDepositedAmount();
}

/**
* Get the duration of the vesting period.
*
* @returns The duration of the vesting period.
*/
public duration() {
return this.getContract().read.duration();
public getDuration() {
return this.getContract().read.getDuration();
}
}
Loading