ETH Price: $2,966.91 (-7.67%)
Gas: 12 Gwei

Contract

0xB4497A7351e4915182b3E577B3A2f411FA66b27f
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x61010060189404872024-01-05 10:29:4799 days ago1704450587IN
 Create: SaleHandler
0 ETH0.0081381416.87574536

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SaleHandler

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 1 : SaleHandler.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;

interface IERC20 {
    function approve(address,uint) external returns (bool);
    function balanceOf(address) external view returns (uint);
}

interface IAnDola {
    function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);
    function borrowBalanceStored(address account) external view returns (uint); // stored is good enough for our use case
}

contract SaleHandler {

    IERC20 public immutable dola;
    IAnDola public immutable anDola;
    address public immutable borrower1;
    address public immutable borrower2;

    constructor(
        address _dola,
        address _anDola,
        address _borrower1,
        address _borrower2
    ) {
        dola = IERC20(_dola);
        anDola = IAnDola(_anDola);
        borrower1 = _borrower1;
        borrower2 = _borrower2;
        dola.approve(_anDola,type(uint).max);
    }

    function onReceive() external {
        uint bal = dola.balanceOf(address(this));
        uint debt1 = getDebtOf(borrower1);
        uint debt2 = getDebtOf(borrower2);
        if(debt1 > debt2) {
            uint errCode = anDola.repayBorrowBehalf(borrower1, bal);
            if(errCode > 0) require(anDola.repayBorrowBehalf(borrower2, bal) == 0, "Failed to repay");
        } else {
            uint errCode = anDola.repayBorrowBehalf(borrower2, bal);
            if(errCode > 0) require(anDola.repayBorrowBehalf(borrower1, bal) == 0, "Failed to repay");
        }
    }

    function getDebtOf(address borrower) internal view returns (uint) {
        return anDola.borrowBalanceStored(borrower);
    }

    function getCapacity() external view returns (uint) {
        return getDebtOf(borrower1) + getDebtOf(borrower2) - dola.balanceOf(address(this));
    }

}

Settings
{
  "remappings": [
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_dola","type":"address"},{"internalType":"address","name":"_anDola","type":"address"},{"internalType":"address","name":"_borrower1","type":"address"},{"internalType":"address","name":"_borrower2","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"anDola","outputs":[{"internalType":"contract IAnDola","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrower1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrower2","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dola","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCapacity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onReceive","outputs":[],"stateMutability":"nonpayable","type":"function"}]

61010060405234801561001157600080fd5b50604051610937380380610937833981016040819052610030916100e4565b6001600160a01b03848116608081905284821660a081905284831660c05291831660e05260405163095ea7b360e01b8152600481019290925260001960248301529063095ea7b3906044016020604051808303816000875af115801561009a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100be9190610138565b5050505050610161565b80516001600160a01b03811681146100df57600080fd5b919050565b600080600080608085870312156100fa57600080fd5b610103856100c8565b9350610111602086016100c8565b925061011f604086016100c8565b915061012d606086016100c8565b905092959194509250565b60006020828403121561014a57600080fd5b8151801515811461015a57600080fd5b9392505050565b60805160a05160c05160e05161073761020060003960008181606c01528181610201015281816103060152818161040301526105b101526000818160b0015281816101d401528181610246015281816104c301526105da01526000818160e1015281816102780152818161033501528181610435015281816104f2015261063901526000818161011e01528181610158015261053901526107376000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80636e91eae6146100675780638ca296e5146100ab5780638e708bca146100d25780639a8365db146100dc578063c40000d414610103578063ea0593e414610119575b600080fd5b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6100da610140565b005b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61010b610521565b6040519081526020016100a2565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156101a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cb91906106ac565b905060006101f87f0000000000000000000000000000000000000000000000000000000000000000610617565b905060006102257f0000000000000000000000000000000000000000000000000000000000000000610617565b9050808211156103ec576040516304c11f0360e31b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018590526000917f000000000000000000000000000000000000000000000000000000000000000090911690632608f818906044016020604051808303816000875af11580156102c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e791906106ac565b905080156103e6576040516304c11f0360e31b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018690527f00000000000000000000000000000000000000000000000000000000000000001690632608f818906044015b6020604051808303816000875af115801561037f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a391906106ac565b156103e65760405162461bcd60e51b815260206004820152600f60248201526e4661696c656420746f20726570617960881b604482015260640160405180910390fd5b50505050565b6040516304c11f0360e31b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018590526000917f000000000000000000000000000000000000000000000000000000000000000090911690632608f818906044016020604051808303816000875af1158015610480573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a491906106ac565b905080156103e6576040516304c11f0360e31b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018690527f00000000000000000000000000000000000000000000000000000000000000001690632608f81890604401610360565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac91906106ac565b6105d57f0000000000000000000000000000000000000000000000000000000000000000610617565b6105fe7f0000000000000000000000000000000000000000000000000000000000000000610617565b61060891906106db565b61061291906106ee565b905090565b6040516395dd919360e01b81526001600160a01b0382811660048301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906395dd919390602401602060405180830381865afa158015610682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a691906106ac565b92915050565b6000602082840312156106be57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b808201808211156106a6576106a66106c5565b818103818111156106a6576106a66106c556fea264697066735822122065dc355997fb48c7303b1de49a1d10b3cf2b4c3ec46a107cb78ac0069bfb8e0a64736f6c63430008150033000000000000000000000000865377367054516e17014ccded1e7d814edc9ce40000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a670000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa1562

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100625760003560e01c80636e91eae6146100675780638ca296e5146100ab5780638e708bca146100d25780639a8365db146100dc578063c40000d414610103578063ea0593e414610119575b600080fd5b61008e7f000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa156281565b6040516001600160a01b0390911681526020015b60405180910390f35b61008e7f000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d81565b6100da610140565b005b61008e7f0000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a67081565b61010b610521565b6040519081526020016100a2565b61008e7f000000000000000000000000865377367054516e17014ccded1e7d814edc9ce481565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000865377367054516e17014ccded1e7d814edc9ce46001600160a01b0316906370a0823190602401602060405180830381865afa1580156101a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cb91906106ac565b905060006101f87f000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d610617565b905060006102257f000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa1562610617565b9050808211156103ec576040516304c11f0360e31b81526001600160a01b037f000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d81166004830152602482018590526000917f0000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a67090911690632608f818906044016020604051808303816000875af11580156102c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e791906106ac565b905080156103e6576040516304c11f0360e31b81526001600160a01b037f000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa156281166004830152602482018690527f0000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a6701690632608f818906044015b6020604051808303816000875af115801561037f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a391906106ac565b156103e65760405162461bcd60e51b815260206004820152600f60248201526e4661696c656420746f20726570617960881b604482015260640160405180910390fd5b50505050565b6040516304c11f0360e31b81526001600160a01b037f000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa156281166004830152602482018590526000917f0000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a67090911690632608f818906044016020604051808303816000875af1158015610480573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a491906106ac565b905080156103e6576040516304c11f0360e31b81526001600160a01b037f000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d81166004830152602482018690527f0000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a6701690632608f81890604401610360565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000865377367054516e17014ccded1e7d814edc9ce46001600160a01b0316906370a0823190602401602060405180830381865afa158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac91906106ac565b6105d57f000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa1562610617565b6105fe7f000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d610617565b61060891906106db565b61061291906106ee565b905090565b6040516395dd919360e01b81526001600160a01b0382811660048301526000917f0000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a670909116906395dd919390602401602060405180830381865afa158015610682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a691906106ac565b92915050565b6000602082840312156106be57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b808201808211156106a6576106a66106c5565b818103818111156106a6576106a66106c556fea264697066735822122065dc355997fb48c7303b1de49a1d10b3cf2b4c3ec46a107cb78ac0069bfb8e0a64736f6c63430008150033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000865377367054516e17014ccded1e7d814edc9ce40000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a670000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa1562

-----Decoded View---------------
Arg [0] : _dola (address): 0x865377367054516e17014CcdED1e7d814EDC9ce4
Arg [1] : _anDola (address): 0x7Fcb7DAC61eE35b3D4a51117A7c58D53f0a8a670
Arg [2] : _borrower1 (address): 0xf508c58ce37ce40a40997C715075172691F92e2D
Arg [3] : _borrower2 (address): 0xeA0c959BBb7476DDD6cD4204bDee82b790AA1562

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000865377367054516e17014ccded1e7d814edc9ce4
Arg [1] : 0000000000000000000000007fcb7dac61ee35b3d4a51117a7c58d53f0a8a670
Arg [2] : 000000000000000000000000f508c58ce37ce40a40997c715075172691f92e2d
Arg [3] : 000000000000000000000000ea0c959bbb7476ddd6cd4204bdee82b790aa1562


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.