Skip to content

Instantly share code, notes, and snippets.

@hav-noms
Last active September 17, 2020 02:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hav-noms/fd61119ed84054e81b94613b8722e4a7 to your computer and use it in GitHub Desktop.
Save hav-noms/fd61119ed84054e81b94613b8722e4a7 to your computer and use it in GitHub Desktop.
Burn, Claim & Mint on behalf in 1 tx
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);
}
@jjgonecrypto
Copy link

If you removed address delegator and used msg.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 over public for gas savings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment