Petting Aavegotchis

GotchiCare

GotchiCare uses Gelato Ops to provide an automated Aavegotchi petting service.
Gelato calls exec here which pets the Aavegotchis and settles the fee.
1
function exec(CareInfo calldata _careInfo) external {
2
require(msg.sender == executor, "Carer: Only executor");
3
4
bytes32 _receipt = getReceipt(_careInfo.owner, _careInfo);
5
6
require(
7
caringOwners.contains(_careInfo.owner),
8
"Carer: exec: Owner has not started"
9
);
10
require(
11
_careInfo.owner == ownerOfReceipt[_receipt],
12
"Carer: exec: Receipt does not match"
13
);
14
15
operator.pet(_careInfo.gotchis, _careInfo.owner);
16
17
payWages(_careInfo.owner, _careInfo.rate);
18
19
20
CareInfo memory newCareInfo = CareInfo(
21
_careInfo.owner,
22
_careInfo.pets.add(1),
23
_careInfo.rate,
24
_careInfo.gotchis
25
);
26
27
updateOwnerInfo(newCareInfo);
28
29
}
Copied!
This resolver loops through an array of subscribed users. For each user, it checks if their aavegotchi's petting time has reached.
1
function checker()
2
external
3
view
4
returns (bool canExec, bytes memory execPayload)
5
{
6
address[] memory _caringOwners = careCentre.getCaringOwners();
7
uint256 _length = _caringOwners.length;
8
9
for (uint256 i = 0; i < _length; i++) {
10
ICareCentre.CareInfo memory _careInfo = careCentre.getCareInfoByOwner(
11
_caringOwners[i]
12
);
13
14
if (!ownerHasBalance(_caringOwners[i], _careInfo.rate)) continue;
15
if (!isApproved(_caringOwners[i])) continue;
16
17
uint256[] memory _gotchis = _careInfo.gotchis;
18
19
uint256 _lastInteracted = gotchiFacet
20
.getAavegotchi(_gotchis[0])
21
.lastInteracted;
22
23
uint256 _nextInteract = _lastInteracted + 12 hours;
24
25
if (block.timestamp >= _nextInteract) {
26
canExec = true;
27
28
execPayload = abi.encodeWithSelector(
29
ICareCentre.exec.selector,
30
_careInfo
31
);
32
33
return (canExec, execPayload);
34
}
35
}
36
37
canExec = false;
38
}
Copied!
Last modified 13d ago
Copy link