Skip to content

Commit

Permalink
feat: update sql db
Browse files Browse the repository at this point in the history
  • Loading branch information
RasenGUY committed Jan 2, 2024
1 parent 8b26606 commit 922de6c
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 120 deletions.
8 changes: 5 additions & 3 deletions contracts/escrow/WegaERC20Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,13 @@ contract WegaERC20Escrow is
}

function getClaimAmount(bytes32 escrowHash, address account) public view override returns (uint256 feeAmount, uint256 claimAmount) {
ERC20WagerRequest memory request = _wagerRequests[escrowHash];
if(APPLY_FEES && _feeManager.shouldApplyFees(address(this))){
(
,
feeAmount,
claimAmount
) = _feeManager.calculateFeesForTransfer(address(this), _getTotalBalance(escrowHash, account));
) = _feeManager.calculateFeesForTransfer(address(this), _getTotalBalance(escrowHash, account) - request.wagerAmount);
} else {
feeAmount = 0;
claimAmount = _getTotalBalance(escrowHash, account);
Expand All @@ -299,6 +300,7 @@ contract WegaERC20Escrow is
require(request.state == TransactionState.READY, INVALID_REQUEST_STATE);
require(_accountBalances[_msgSender()][escrowHash] > 0 ether, INVALID_WITHDRAW_BALANCE);
uint256 transferAmount = _getTotalBalance(escrowHash, _msgSender());
uint256 feeTransferAmount = transferAmount - request.wagerAmount;
_escrowBalances[escrowHash] -= transferAmount;
delete _accountBalances[_msgSender()][escrowHash];
_wagerRequests[escrowHash].state = TransactionState.CLOSED;
Expand All @@ -307,10 +309,10 @@ contract WegaERC20Escrow is
address feeTaker,
uint256 feeAmount,
uint256 sendAmount
) = _feeManager.calculateFeesForTransfer(address(this), transferAmount);
) = _feeManager.calculateFeesForTransfer(address(this), feeTransferAmount);
ERC20Upgradeable(request.tokenAddress).transfer(
_msgSender(),
sendAmount
(transferAmount + request.wagerAmount + sendAmount)
);
ERC20Upgradeable(request.tokenAddress).transfer(
feeTaker,
Expand Down
4 changes: 3 additions & 1 deletion deployed-addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"WegaERC20Escrow": {
"address": "0x1fFd5291E09264174d9956187cf8eFAE01E34875",
"legacyAddresses": [
"0x0C2Af2C8B3Ef546Bd2F9743Faa106e0C7b5f7F4A",
"0xed4a0cb18aF2D6b022F8f99Cf09b91aa06A9513d",
"0x2EE1d66d4c62a8c648f36fC8Faa7f8454F470520",
"0x65BdAB5722E4f5F7c377d73d5c0073Bb0671597d"
],
"deploymentBlock": null,
"implementation": "0xed4a0cb18aF2D6b022F8f99Cf09b91aa06A9513d"
"implementation": "0xd6957163fF4Cf665dA19f2bB70Ba90cc2c91d54D"
},
"WegaERC20Dummy": {
"address": "0x0000000000000000000000000000000000000000"
Expand Down
12 changes: 11 additions & 1 deletion src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,13 +788,23 @@ const upgradeContractTask: Task = {
artifactName: ArtifactName;
contractName: ContractName,
}[]) => {
const { owner } = ctx.accounts;
const nonceOwner = ctx.getNonceSigner(owner)

await Promise.all(inputs.map(async input => {
ctx.log(`Upgrade ${input.contractName}`, JSON.stringify(input));
const ContractConfig: DeployedContract = unwrap(dependencies, input.artifactName);
let provider = nonceOwner.signer.provider;
const baseFee = (await provider?.getBlock('latest'))?.baseFeePerGas as bigint;
const currentGasLimit = parseUnits('10', 'gwei');
const gasFee = baseFee + currentGasLimit

const { legacyAddress, contractInstance } = await upgradeContract({
implementationFactory: ctx.artifacts[input.artifactName],
deployedContractConfig: ContractConfig,
options: { kind: 'uups', redeployImplementation: 'always', txOverrides: { maxFeePerGas: parseUnits('900', 'gwei') } },
options: { kind: 'uups', redeployImplementation: 'always', txOverrides: {
maxFeePerGas: gasFee,
} },
forceImport: input.forceImportAddress ? {
address: input.forceImportAddress,
options: { kind: 'uups', redeployImplementation: 'always'}
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 922de6c

Please sign in to comment.