Skip to content

Conversation

gmbronco
Copy link

@gmbronco gmbronco commented May 8, 2021

This is a simple claim adapter that allows managers to claim COMP from assets deposited on Compound.

It's interfacing with Comptroller and conforms to the IClaimAdapter interface used by the Set Protocol V2 ClaimModule.

Tests are using mocked Comptroller contract and are limited to ClaimAdapter <> ClaimModule integration.

@gmbronco gmbronco force-pushed the comp-claim-adapter branch from b1001ae to 06bf2da Compare May 9, 2021 15:57

// Address of COMP token
// https://compound.finance/docs#networks
// address public immutable compToken;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to delete if it's not needed


/**
* @title CompClaimAdapter
* @author Set Protocol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author is yourself!

const amount: number = 1;

before(async () => {
await comptroller.mock.compAccrued.returns(amount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow nice, I didn't realize waffle had the ability to mock contracts and mock values

const receipt = await claim.wait();

// Get RewardClaimed event dispatched in a ClaimModule#_claim call
const rewardClaimed: any = receipt.events.find((e: any): any => e.event == "RewardClaimed");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the actual claimComp doesn't transfer any tokens? Ideally it would be a mock to transfer reward token to the SetToken and check the balance of:
https://github.com/SetProtocol/set-protocol-v2/blob/master/test/protocol/modules/claimModule.spec.ts#L970

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I used ComptrollerMock that was already in the repo. It's claiming function is triggering a transfer on a mocked Comp ERC20 token. New test is added below and it's checking how the balance changes after the #claim is executed.

@gmbronco gmbronco force-pushed the comp-claim-adapter branch from 06bf2da to 81b4f6b Compare May 13, 2021 16:58
Copy link
Contributor

@richardliang richardliang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@richardliang richardliang merged commit aa894d7 into SetProtocol:master May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants