Last active
September 17, 2020 02:52
-
-
Save hav-noms/fd61119ed84054e81b94613b8722e4a7 to your computer and use it in GitHub Desktop.
Burn, Claim & Mint on behalf in 1 tx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.22 <0.7.0; | |
interface ISynthetix { | |
function burnSynthsToTargetOnBehalf(address burnForAddress) external; | |
function issueMaxSynthsOnBehalf(address issueForAddress) external; | |
function remainingIssuableSynths(address issuer) external returns (uint256); | |
} | |
interface IFeePool { | |
function claimOnBehalf(address claimingForAddress) external; | |
function isFeesClaimable(address account) external returns (bool); | |
} | |
/** | |
* @title Burn, Claim & Mint on behalf in 1 tx | |
* 1. Delegate this contract address in mintr.synthetix.io | |
* 2. Call burnClaimMintSNX(your SNX account adddress) | |
*/ | |
contract SNXClaimerZap { | |
address synthetixProxy = 0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F; | |
address feePoolProxy = 0xb440DD674e1243644791a4AdfE3A2AbB0A92d309; | |
ISynthetix synthetix = ISynthetix(synthetixProxy); | |
IFeePool feePool = IFeePool(feePoolProxy); | |
function burnClaimMintSNX(address msg.sender) external returns (uint256) { | |
if (!feePool.isFeesClaimable(delegator)) { | |
synthetix.burnSynthsToTargetOnBehalf(delegator); | |
} | |
feePool.claimOnBehalf(delegator); | |
if (synthetix.remainingIssuableSynths(delegator) > 0) { | |
synthetix.issueMaxSynthsOnBehalf(delegator); | |
} | |
emit SNXClaimerZappedForAccount(delegator); | |
} | |
event SNXClaimerZappedForAccount(address delegator); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you removed
address delegator
and usedmsg.sender
instead, it would prevent third parties from being able to initiate the ZAP on your behalf, which while they'd pay the gas, it could cause you to have claimed when you weren't prepared to...Also, you should use
external
overpublic
for gas savings.