Fix: replace where relevant with address(this)

This commit is contained in:
eccheung4 2021-09-02 10:35:02 -07:00
parent a8ad815814
commit f9762d8dfc
2 changed files with 24 additions and 34 deletions

View File

@ -21,7 +21,6 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
* @dev Deposit into Prize Pool * @dev Deposit into Prize Pool
* @notice Deposit assets into the Prize Pool in exchange for tokens * @notice Deposit assets into the Prize Pool in exchange for tokens
* @param prizePool PrizePool address to deposit to * @param prizePool PrizePool address to deposit to
* @param to The address receiving the newly minted tokens
* @param amount The amount of the underlying asset the user wishes to deposit. The Prize Pool contract should have been pre-approved by the caller to transfer the underlying ERC20 tokens. * @param amount The amount of the underlying asset the user wishes to deposit. The Prize Pool contract should have been pre-approved by the caller to transfer the underlying ERC20 tokens.
* @param controlledToken The address of the token that they wish to mint. For our default Prize Strategy this will either be the Ticket address or the Sponsorship address. Those addresses can be looked up on the Prize Strategy. * @param controlledToken The address of the token that they wish to mint. For our default Prize Strategy this will either be the Ticket address or the Sponsorship address. Those addresses can be looked up on the Prize Strategy.
* @param referrer The address that should receive referral awards, if any. * @param referrer The address that should receive referral awards, if any.
@ -31,7 +30,6 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
function depositTo( function depositTo(
address prizePool, address prizePool,
address to,
uint256 amount, uint256 amount,
address controlledToken, address controlledToken,
address referrer, address referrer,
@ -47,19 +45,18 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
TokenInterface tokenContract = TokenInterface(prizePoolToken); TokenInterface tokenContract = TokenInterface(prizePoolToken);
tokenContract.approve(prizePool, _amount); tokenContract.approve(prizePool, _amount);
prizePoolContract.depositTo(to, _amount, controlledToken, referrer); prizePoolContract.depositTo(address(this), _amount, controlledToken, referrer);
setUint(setId, _amount); setUint(setId, _amount);
_eventName = "LogDepositTo(address,address,uint256,address,address,uint256, uint256)"; _eventName = "LogDepositTo(address,address,uint256,address,address,uint256, uint256)";
_eventParam = abi.encode(address(prizePool), address(to), _amount, address(controlledToken), address(referrer), getId, setId); _eventParam = abi.encode(address(prizePool), address(this), _amount, address(controlledToken), address(referrer), getId, setId);
} }
/** /**
* @dev Withdraw from Prize Pool * @dev Withdraw from Prize Pool
* @notice Withdraw assets from the Prize Pool instantly. A fairness fee may be charged for an early exit. * @notice Withdraw assets from the Prize Pool instantly. A fairness fee may be charged for an early exit.
* @param prizePool PrizePool address to deposit to * @param prizePool PrizePool address to deposit to
* @param from The address to redeem tokens from.. This means you can withdraw on another user's behalf if you have an allowance for the controlled token.
* @param amount The amount of tokens to redeem for assets. * @param amount The amount of tokens to redeem for assets.
* @param controlledToken The address of the token to redeem (i.e. ticket or sponsorship) * @param controlledToken The address of the token to redeem (i.e. ticket or sponsorship)
* @param maximumExitFee The maximum early exit fee the caller is willing to pay. This prevents the Prize Strategy from changing the fee on the fly. This should be pre-calculated by the calculateExitFee() fxn. * @param maximumExitFee The maximum early exit fee the caller is willing to pay. This prevents the Prize Strategy from changing the fee on the fly. This should be pre-calculated by the calculateExitFee() fxn.
@ -69,7 +66,6 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
function withdrawInstantlyFrom ( function withdrawInstantlyFrom (
address prizePool, address prizePool,
address from,
uint256 amount, uint256 amount,
address controlledToken, address controlledToken,
uint256 maximumExitFee, uint256 maximumExitFee,
@ -80,54 +76,50 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
PrizePoolInterface prizePoolContract = PrizePoolInterface(prizePool); PrizePoolInterface prizePoolContract = PrizePoolInterface(prizePool);
prizePoolContract.withdrawInstantlyFrom(from, _amount, controlledToken, maximumExitFee); prizePoolContract.withdrawInstantlyFrom(address(this), _amount, controlledToken, maximumExitFee);
setUint(setId, _amount); setUint(setId, _amount);
_eventName = "LogWithdrawInstantlyFrom(address,address,uint256,address,uint256,uint256,uint256)"; _eventName = "LogWithdrawInstantlyFrom(address,address,uint256,address,uint256,uint256,uint256)";
_eventParam = abi.encode(address(prizePool), address(from), _amount, address(controlledToken), maximumExitFee, getId, setId); _eventParam = abi.encode(address(prizePool), address(this), _amount, address(controlledToken), maximumExitFee, getId, setId);
} }
/** /**
* @dev Claim token from a Token Faucet * @dev Claim token from a Token Faucet
* @notice Claim token from a Token Faucet * @notice Claim token from a Token Faucet
* @param tokenFaucet TokenFaucet address * @param tokenFaucet TokenFaucet address
* @param user The user to claim tokens for
* @param setId Set claimed amount at this ID in `InstaMemory` Contract. * @param setId Set claimed amount at this ID in `InstaMemory` Contract.
*/ */
function claim ( function claim (
address tokenFaucet, address tokenFaucet,
address user,
uint256 setId uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) { ) external payable returns (string memory _eventName, bytes memory _eventParam) {
TokenFaucetInterface tokenFaucetContract = TokenFaucetInterface(tokenFaucet); TokenFaucetInterface tokenFaucetContract = TokenFaucetInterface(tokenFaucet);
uint256 claimed = tokenFaucetContract.claim(user); uint256 claimed = tokenFaucetContract.claim(address(this));
setUint(setId, claimed); setUint(setId, claimed);
_eventName = "LogClaim(address,address, uint256, uint256)"; _eventName = "LogClaim(address,address, uint256, uint256)";
_eventParam = abi.encode(address(tokenFaucet), address(user), claimed, setId); _eventParam = abi.encode(address(tokenFaucet), address(this), claimed, setId);
} }
/** /**
* @dev Runs claim on all passed comptrollers for a user. * @dev Runs claim on all passed comptrollers for a user.
* @notice Runs claim on all passed comptrollers for a user. * @notice Runs claim on all passed comptrollers for a user.
* @param tokenFaucetProxyFactory The TokenFaucetProxyFactory address * @param tokenFaucetProxyFactory The TokenFaucetProxyFactory address
* @param user The user to claim tokens for
* @param tokenFaucets The tokenFaucets to call claim on. * @param tokenFaucets The tokenFaucets to call claim on.
*/ */
function claimAll ( function claimAll (
address tokenFaucetProxyFactory, address tokenFaucetProxyFactory,
address user,
TokenFaucetInterface[] calldata tokenFaucets TokenFaucetInterface[] calldata tokenFaucets
) external payable returns (string memory _eventName, bytes memory _eventParam) { ) external payable returns (string memory _eventName, bytes memory _eventParam) {
TokenFaucetProxyFactoryInterface tokenFaucetProxyFactoryContract = TokenFaucetProxyFactoryInterface(tokenFaucetProxyFactory); TokenFaucetProxyFactoryInterface tokenFaucetProxyFactoryContract = TokenFaucetProxyFactoryInterface(tokenFaucetProxyFactory);
tokenFaucetProxyFactoryContract.claimAll(user, tokenFaucets); tokenFaucetProxyFactoryContract.claimAll(address(this), tokenFaucets);
_eventName = "LogClaimAll(address,address,TokenFaucetInterface[])"; _eventName = "LogClaimAll(address,address,TokenFaucetInterface[])";
_eventParam = abi.encode(address(tokenFaucetProxyFactory), address(user), tokenFaucets); _eventParam = abi.encode(address(tokenFaucetProxyFactory), address(this), tokenFaucets);
} }
/** /**
@ -135,7 +127,6 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
* @notice Deposit assets into the Pod in exchange for share tokens * @notice Deposit assets into the Pod in exchange for share tokens
* @param prizePool PrizePool address to deposit to * @param prizePool PrizePool address to deposit to
* @param pod Pod address to deposit to * @param pod Pod address to deposit to
* @param to The address that shall receive the Pod shares
* @param tokenAmount The amount of tokens to deposit. These are the same tokens used to deposit into the underlying prize pool. * @param tokenAmount The amount of tokens to deposit. These are the same tokens used to deposit into the underlying prize pool.
* @param getId Get token amount at this ID from `InstaMemory` Contract. * @param getId Get token amount at this ID from `InstaMemory` Contract.
* @param setId Set token amount at this ID in `InstaMemory` Contract. * @param setId Set token amount at this ID in `InstaMemory` Contract.
@ -143,7 +134,6 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
function depositToPod( function depositToPod(
address prizePool, address prizePool,
address pod, address pod,
address to,
uint256 tokenAmount, uint256 tokenAmount,
uint256 getId, uint256 getId,
uint256 setId uint256 setId
@ -159,12 +149,12 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
TokenInterface tokenContract = TokenInterface(prizePoolToken); TokenInterface tokenContract = TokenInterface(prizePoolToken);
tokenContract.approve(pod, _tokenAmount); tokenContract.approve(pod, _tokenAmount);
podContract.depositTo(to, _tokenAmount); podContract.depositTo(address(this), _tokenAmount);
setUint(setId, _tokenAmount); setUint(setId, _tokenAmount);
_eventName = "LogDepositToPod(address,address,address,uint256,uint256, uint256)"; _eventName = "LogDepositToPod(address,address,address,uint256,uint256, uint256)";
_eventParam = abi.encode(address(prizePool), address(pod), address(to), _tokenAmount, getId, setId); _eventParam = abi.encode(address(prizePool), address(pod), address(this), _tokenAmount, getId, setId);
} }
/** /**

View File

@ -129,7 +129,7 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "depositTo", method: "depositTo",
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, constants.address_zero, setId, 0] args: [DAI_PRIZE_POOL_ADDR, amount, PT_DAI_TICKET_ADDR, constants.address_zero, setId, 0]
} }
] ]
// Before Spell // Before Spell
@ -162,12 +162,12 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "withdrawInstantlyFrom", method: "withdrawInstantlyFrom",
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, amount, 0, 0] args: [DAI_PRIZE_POOL_ADDR, amount, PT_DAI_TICKET_ADDR, amount, 0, 0]
}, },
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "claim", method: "claim",
args: [DAI_POOL_FAUCET_ADDR, dsaWallet0.address, 0] args: [DAI_POOL_FAUCET_ADDR, 0]
} }
] ]
@ -210,12 +210,12 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "depositTo", method: "depositTo",
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, constants.address_zero, 0, 0] args: [DAI_PRIZE_POOL_ADDR, amount, PT_DAI_TICKET_ADDR, constants.address_zero, 0, 0]
}, },
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "withdrawInstantlyFrom", method: "withdrawInstantlyFrom",
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, amount, 0, 0] args: [DAI_PRIZE_POOL_ADDR, amount, PT_DAI_TICKET_ADDR, amount, 0, 0]
} }
] ]
@ -256,7 +256,7 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "depositTo", method: "depositTo",
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, constants.address_zero, 0, 0] args: [DAI_PRIZE_POOL_ADDR, amount, PT_DAI_TICKET_ADDR, constants.address_zero, 0, 0]
} }
] ]
@ -264,12 +264,12 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "withdrawInstantlyFrom", method: "withdrawInstantlyFrom",
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, amount, 0, 0] args: [DAI_PRIZE_POOL_ADDR, amount, PT_DAI_TICKET_ADDR, amount, 0, 0]
}, },
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "claimAll", method: "claimAll",
args: [TOKEN_FAUCET_PROXY_FACTORY_ADDR, dsaWallet0.address, [DAI_POOL_FAUCET_ADDR]] args: [TOKEN_FAUCET_PROXY_FACTORY_ADDR, [DAI_POOL_FAUCET_ADDR]]
} }
] ]
@ -317,7 +317,7 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "depositToPod", method: "depositToPod",
args: [DAI_PRIZE_POOL_ADDR, DAI_POD_ADDR, dsaWallet0.address, amount, 0, 0] args: [DAI_PRIZE_POOL_ADDR, DAI_POD_ADDR, amount, 0, 0]
} }
] ]
@ -401,7 +401,7 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "depositToPod", method: "depositToPod",
args: [DAI_PRIZE_POOL_ADDR, DAI_POD_ADDR, dsaWallet0.address, amount, 0, 0] args: [DAI_PRIZE_POOL_ADDR, DAI_POD_ADDR, amount, 0, 0]
}, },
{ {
connector: ptConnectorName, connector: ptConnectorName,
@ -472,7 +472,7 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "depositTo", method: "depositTo",
args: [UNISWAP_POOLETHLP_PRIZE_POOL_ADDR, dsaWallet0.address, 0, PT_UNISWAP_POOLETHLP_TICKET_ADDR, constants.address_zero, setId, 0] args: [UNISWAP_POOLETHLP_PRIZE_POOL_ADDR, 0, PT_UNISWAP_POOLETHLP_TICKET_ADDR, constants.address_zero, setId, 0]
} }
] ]
@ -519,17 +519,17 @@ describe("PoolTogether", function () {
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "withdrawInstantlyFrom", method: "withdrawInstantlyFrom",
args: [UNISWAP_POOLETHLP_PRIZE_POOL_ADDR, dsaWallet0.address, ptUniswapPoolEthBalance, PT_UNISWAP_POOLETHLP_TICKET_ADDR, 0, 0, 0] args: [UNISWAP_POOLETHLP_PRIZE_POOL_ADDR, ptUniswapPoolEthBalance, PT_UNISWAP_POOLETHLP_TICKET_ADDR, 0, 0, 0]
}, },
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "claim", method: "claim",
args: [UNISWAP_POOLETHLP_FAUCET_ADDR , dsaWallet0.address, setId] args: [UNISWAP_POOLETHLP_FAUCET_ADDR , setId]
}, },
{ {
connector: ptConnectorName, connector: ptConnectorName,
method: "depositTo", method: "depositTo",
args: [POOL_PRIZE_POOL_ADDR, dsaWallet0.address, 0, PT_POOL_TICKET_ADDR, constants.address_zero, setId, 0] args: [POOL_PRIZE_POOL_ADDR, 0, PT_POOL_TICKET_ADDR, constants.address_zero, setId, 0]
} }
] ]