Source Code
Overview
ETH Balance
0.0001 ETH
Eth Value
$0.21 (@ $2,080.12/ETH)Latest 1 from a total of 1 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Swap ET Hfor BTC | 15709904 | 1252 days ago | IN | 0.0001 ETH | 0.00125859 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
BTCETHSwap
Compiler Version
v0.8.17+commit.8df45f5f
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2022-10-09
*/
pragma solidity ^0.8.7;
/* Interface for ERC20 Tokens */
abstract contract Token {
function transferFrom(address _from, address _to, uint256 _value) public virtual returns (bool success);
function approve(address _spender, uint256 _value) public virtual returns (bool success);
}
abstract contract pToken {
function redeem(uint256 _value, string memory destinationAddress, bytes4 destinationChainId) public virtual returns (bool _success);
}
interface Curve {
function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 min_dy, address receiver) external returns (uint256);
}
interface WETH {
function deposit() external payable;
function withdraw(uint256 amount) external;
function approve(address guy, uint256 wad) external;
}
interface UniswapRouter {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
function exactInputSingle(ExactInputSingleParams calldata params) external returns (uint256 amountOut);
}
contract BTCETHSwap {
fallback() external {
revert();
}
// ARB
address public PBTC_ADDRESS = address(0x62199B909FB8B8cf870f97BEf2cE6783493c4908);
address public WBTC_ADDRESS = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);
address payable WETH_ADDRESS = payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address public CURVE_PBTC_POOL = address(0xC9467E453620f16b57a34a770C6bceBECe002587);
address public UNISWAP_ROUTER = address(0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45);
int128 public CURVE_WBTC_INDEX = 2;
int128 public CURVE_PBTC_INDEX = 0;
bytes4 public PTOKENS_BTC_CHAINID = 0x01ec97de;
// Constructor function, initializes the contract and sets the core variables
constructor() {}
// Swap PBTC for ETH
function swapBTCforETH (uint256 amount, address payable recipient) public payable
{
Token(PBTC_ADDRESS).transferFrom(msg.sender, address(this), amount);
// Curve pBTC for wBTC
uint256 amount_wbtc = CurveSwap(
false,
amount
);
// Uniswap wBTC for ETH
uint256 amountETH = Uniswap(
WBTC_ADDRESS,
WETH_ADDRESS,
amount_wbtc,
recipient,
3000
);
WETH(WETH_ADDRESS).withdraw(amountETH);
}
// Swap ETH for PBTC
function swapETHforBTC (string memory recipient) public payable {
WETH(WETH_ADDRESS).deposit{value: msg.value};
WETH(WETH_ADDRESS).approve(UNISWAP_ROUTER, msg.value);
// Uniswap ETH for WBTC
// uint256 amount_WBTC = Uniswap(
// WETH_ADDRESS,
// WBTC_ADDRESS,
// msg.value,
// address(this),
// 500
// );
// Token(WBTC_ADDRESS).approve(CURVE_PBTC_POOL, amount_WBTC);
// // Curve wBTC to pBTC
// uint256 amount_pbtc = CurveSwap(
// true,
// amount_WBTC
// );
// // Redeem pBTC to recipient address
// pToken(PBTC_ADDRESS).redeem(
// amount_pbtc,
// recipient,
// PTOKENS_BTC_CHAINID
// );
}
// Uniswap
function Uniswap(
address tokenIn,
address tokenOut,
uint256 amountIn,
address recipient,
uint24 fee) internal returns (uint256)
{
UniswapRouter.ExactInputSingleParams memory params = UniswapRouter.ExactInputSingleParams(
tokenIn,
tokenOut,
fee,
recipient,
block.timestamp,
amountIn,
0,
0
);
uint256 amountOut = UniswapRouter(UNISWAP_ROUTER).exactInputSingle(params);
return amountOut;
}
// Curve
function CurveSwap(bool wtop, uint256 amountSell) internal returns (uint256)
{
int128 i;
int128 j;
if (wtop)
{
i = CURVE_WBTC_INDEX;
j = CURVE_PBTC_INDEX;
}
else
{
i = CURVE_PBTC_INDEX;
j = CURVE_WBTC_INDEX;
}
Curve(CURVE_PBTC_POOL).exchange_underlying(i, j, amountSell, 0, address(this));
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"CURVE_PBTC_INDEX","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CURVE_PBTC_POOL","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CURVE_WBTC_INDEX","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PBTC_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PTOKENS_BTC_CHAINID","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNISWAP_ROUTER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WBTC_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"}],"name":"swapBTCforETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"recipient","type":"string"}],"name":"swapETHforBTC","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
6080604052600080546001600160a01b03199081167362199b909fb8b8cf870f97bef2ce6783493c490817909155600180548216732260fac5e5542a773aa44fbcfedf7c193bc2c59917905560028054821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc217815560038054831673c9467e453620f16b57a34a770c6bcebece002587179055600480549092167368b3465833fb72a70ecdf485e0e4c7bd8665fc45179091556005556006805463ffffffff19166301ec97de1790553480156100c957600080fd5b506106b4806100d96000396000f3fe6080604052600436106100865760003560e01c806378969a6a1161005957806378969a6a1461015b578063bdd5915f14610175578063d347f61614610195578063d8264920146101aa578063f32622f2146101ca57610086565b806309128a211461009757806311f1002b146100cf5780632ff71e47146101075780634377f1901461013b575b34801561009257600080fd5b600080fd5b3480156100a357600080fd5b506006546100b19060e01b81565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100db57600080fd5b506003546100ef906001600160a01b031681565b6040516001600160a01b0390911681526020016100c6565b34801561011357600080fd5b5060055461012890600160801b9004600f0b81565b604051600f9190910b81526020016100c6565b34801561014757600080fd5b506000546100ef906001600160a01b031681565b34801561016757600080fd5b5060055461012890600f0b81565b34801561018157600080fd5b506001546100ef906001600160a01b031681565b6101a86101a336600461054f565b6101dd565b005b3480156101b657600080fd5b506004546100ef906001600160a01b031681565b6101a86101d8366004610600565b61024b565b6002546004805460405163095ea7b360e01b81526001600160a01b03918216928101929092523460248301529091169063095ea7b390604401600060405180830381600087803b15801561023057600080fd5b505af1158015610244573d6000803e3d6000fd5b5050505050565b6000546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303816000875af11580156102a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c6919061063c565b5060006102d4600084610360565b6001546002549192506000916102fb916001600160a01b0390811691168486610bb8610430565b600254604051632e1a7d4d60e01b8152600481018390529192506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561034257600080fd5b505af1158015610356573d6000803e3d6000fd5b5050505050505050565b60008060008415610384575050600554600f81810b91600160801b9004900b610399565b5050600554600160801b8104600f90810b91900b5b6003546040516322770cc360e11b8152600f84810b600483015283900b602482015260448101869052600060648201523060848201526001600160a01b03909116906344ee19869060a4016020604051808303816000875af1158015610403573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104279190610665565b50505092915050565b60408051610100810182526001600160a01b0387811682528681166020830190815262ffffff85811684860190815287841660608601908152426080870190815260a087018b8152600060c0890181815260e08a01828152600480549c5163414bf38960e01b81528c518c169181019190915298518a1660248a015295519096166044880152925187166064870152905160848601525160a4850152915160c484015251831660e4830152938492169063414bf38990610104016020604051808303816000875af1158015610509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052d9190610665565b98975050505050505050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561056157600080fd5b813567ffffffffffffffff8082111561057957600080fd5b818401915084601f83011261058d57600080fd5b81358181111561059f5761059f610539565b604051601f8201601f19908116603f011681019083821181831017156105c7576105c7610539565b816040528281528760208487010111156105e057600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806040838503121561061357600080fd5b8235915060208301356001600160a01b038116811461063157600080fd5b809150509250929050565b60006020828403121561064e57600080fd5b8151801515811461065e57600080fd5b9392505050565b60006020828403121561067757600080fd5b505191905056fea26469706673582212206cc4ea45f75d2631f577aede0a7f902b8ced999dcc96b53b2875534071fec5e464736f6c63430008110033
Deployed Bytecode
0x6080604052600436106100865760003560e01c806378969a6a1161005957806378969a6a1461015b578063bdd5915f14610175578063d347f61614610195578063d8264920146101aa578063f32622f2146101ca57610086565b806309128a211461009757806311f1002b146100cf5780632ff71e47146101075780634377f1901461013b575b34801561009257600080fd5b600080fd5b3480156100a357600080fd5b506006546100b19060e01b81565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100db57600080fd5b506003546100ef906001600160a01b031681565b6040516001600160a01b0390911681526020016100c6565b34801561011357600080fd5b5060055461012890600160801b9004600f0b81565b604051600f9190910b81526020016100c6565b34801561014757600080fd5b506000546100ef906001600160a01b031681565b34801561016757600080fd5b5060055461012890600f0b81565b34801561018157600080fd5b506001546100ef906001600160a01b031681565b6101a86101a336600461054f565b6101dd565b005b3480156101b657600080fd5b506004546100ef906001600160a01b031681565b6101a86101d8366004610600565b61024b565b6002546004805460405163095ea7b360e01b81526001600160a01b03918216928101929092523460248301529091169063095ea7b390604401600060405180830381600087803b15801561023057600080fd5b505af1158015610244573d6000803e3d6000fd5b5050505050565b6000546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303816000875af11580156102a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c6919061063c565b5060006102d4600084610360565b6001546002549192506000916102fb916001600160a01b0390811691168486610bb8610430565b600254604051632e1a7d4d60e01b8152600481018390529192506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561034257600080fd5b505af1158015610356573d6000803e3d6000fd5b5050505050505050565b60008060008415610384575050600554600f81810b91600160801b9004900b610399565b5050600554600160801b8104600f90810b91900b5b6003546040516322770cc360e11b8152600f84810b600483015283900b602482015260448101869052600060648201523060848201526001600160a01b03909116906344ee19869060a4016020604051808303816000875af1158015610403573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104279190610665565b50505092915050565b60408051610100810182526001600160a01b0387811682528681166020830190815262ffffff85811684860190815287841660608601908152426080870190815260a087018b8152600060c0890181815260e08a01828152600480549c5163414bf38960e01b81528c518c169181019190915298518a1660248a015295519096166044880152925187166064870152905160848601525160a4850152915160c484015251831660e4830152938492169063414bf38990610104016020604051808303816000875af1158015610509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052d9190610665565b98975050505050505050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561056157600080fd5b813567ffffffffffffffff8082111561057957600080fd5b818401915084601f83011261058d57600080fd5b81358181111561059f5761059f610539565b604051601f8201601f19908116603f011681019083821181831017156105c7576105c7610539565b816040528281528760208487010111156105e057600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806040838503121561061357600080fd5b8235915060208301356001600160a01b038116811461063157600080fd5b809150509250929050565b60006020828403121561064e57600080fd5b8151801515811461065e57600080fd5b9392505050565b60006020828403121561067757600080fd5b505191905056fea26469706673582212206cc4ea45f75d2631f577aede0a7f902b8ced999dcc96b53b2875534071fec5e464736f6c63430008110033
Deployed Bytecode Sourcemap
1213:3358:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1273:8;;;1850:46;;;;;;;;;;-1:-1:-1;1850:46:0;;;;;;;;;;;-1:-1:-1;;;;;;176:33:1;;;158:52;;146:2;131:18;1850:46:0;;;;;;;;1576:85;;;;;;;;;;-1:-1:-1;1576:85:0;;;;-1:-1:-1;;;;;1576:85:0;;;;;;-1:-1:-1;;;;;385:32:1;;;367:51;;355:2;340:18;1576:85:0;221:203:1;1803:34:0;;;;;;;;;;-1:-1:-1;1803:34:0;;;;-1:-1:-1;;;1803:34:0;;;;;;;;;602:2:1;591:22;;;;573:41;;561:2;546:18;1803:34:0;429:191:1;1309:81:0;;;;;;;;;;-1:-1:-1;1309:81:0;;;;-1:-1:-1;;;;;1309:81:0;;;1762:34;;;;;;;;;;-1:-1:-1;1762:34:0;;;;;;;;1398:81;;;;;;;;;;-1:-1:-1;1398:81:0;;;;-1:-1:-1;;;;;1398:81:0;;;2633:840;;;;;;:::i;:::-;;:::i;:::-;;1668:85;;;;;;;;;;-1:-1:-1;1668:85:0;;;;-1:-1:-1;;;;;1668:85:0;;;2040:559;;;;;;:::i;:::-;;:::i;2633:840::-;2713:12;;2790:14;;;2763:53;;-1:-1:-1;;;2763:53:0;;-1:-1:-1;;;;;2790:14:0;;;2763:53;;;2225:51:1;;;;2806:9:0;2292:18:1;;;2285:34;2768:12:0;;;;2763:26;;2198:18:1;;2763:53:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2633:840;:::o;2040:559::-;2144:12;;2138:67;;-1:-1:-1;;;2138:67:0;;2171:10;2138:67;;;2570:34:1;2191:4:0;2620:18:1;;;2613:43;2672:18;;;2665:34;;;-1:-1:-1;;;;;2144:12:0;;;;2138:32;;2505:18:1;;2138:67:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;2250:19;2272:61;2296:5;2316:6;2272:9;:61::i;:::-;2421:12;;2448;;2250:83;;-1:-1:-1;2379:17:0;;2399:141;;-1:-1:-1;;;;;2421:12:0;;;;2448;2250:83;2501:9;2525:4;2399:7;:141::i;:::-;2558:12;;2553:38;;-1:-1:-1;;;2553:38:0;;;;;3138:25:1;;;2379:161:0;;-1:-1:-1;;;;;;2558:12:0;;2553:27;;3111:18:1;;2553:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2127:472;;2040:559;;:::o;4118:446::-;4186:7;4211:8;4230;4255:4;4251:207;;;-1:-1:-1;;4289:16:0;;;;;;;-1:-1:-1;;;4324:16:0;;;;4251:207;;;-1:-1:-1;;4395:16:0;;-1:-1:-1;;;4395:16:0;;;;;;;4430;;4251:207;4484:15;;4478:78;;-1:-1:-1;;;4478:78:0;;3466:2:1;3455:22;;;4478:78:0;;;3437:41:1;3514:22;;;3494:18;;;3487:50;3553:18;;;3546:34;;;4484:15:0;3596:18:1;;;3589:34;4550:4:0;3639:19:1;;;3632:61;-1:-1:-1;;;;;4484:15:0;;;;4478:42;;3409:19:1;;4478:78:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;4200:364;;4118:446;;;;:::o;3510:586::-;3755:219;;;;;;;;-1:-1:-1;;;;;3755:219:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3893:15;3755:219;;;;;;;;;;;;-1:-1:-1;3755:219:0;;;;;;;;;;;;4021:14;;;4007:54;;-1:-1:-1;;;4007:54:0;;4176:13:1;;4172:22;;4007:54:0;;;4154:41:1;;;;4237:24;;4233:33;;4211:20;;;4204:63;4309:24;;4305:39;;;4283:20;;;4276:69;4387:24;;4383:33;;4361:20;;;4354:63;4455:24;;4433:20;;;4426:54;4518:24;4496:20;;;4489:54;4581:24;;4559:20;;;4552:54;4648:24;4644:33;;4622:20;;;4615:63;-1:-1:-1;;;4021:14:0;;4007:46;;4088:19:1;;4007:54:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3987:74;3510:586;-1:-1:-1;;;;;;;;3510:586:0:o;625:127:1:-;686:10;681:3;677:20;674:1;667:31;717:4;714:1;707:15;741:4;738:1;731:15;757:922;826:6;879:2;867:9;858:7;854:23;850:32;847:52;;;895:1;892;885:12;847:52;935:9;922:23;964:18;1005:2;997:6;994:14;991:34;;;1021:1;1018;1011:12;991:34;1059:6;1048:9;1044:22;1034:32;;1104:7;1097:4;1093:2;1089:13;1085:27;1075:55;;1126:1;1123;1116:12;1075:55;1162:2;1149:16;1184:2;1180;1177:10;1174:36;;;1190:18;;:::i;:::-;1265:2;1259:9;1233:2;1319:13;;-1:-1:-1;;1315:22:1;;;1339:2;1311:31;1307:40;1295:53;;;1363:18;;;1383:22;;;1360:46;1357:72;;;1409:18;;:::i;:::-;1449:10;1445:2;1438:22;1484:2;1476:6;1469:18;1524:7;1519:2;1514;1510;1506:11;1502:20;1499:33;1496:53;;;1545:1;1542;1535:12;1496:53;1601:2;1596;1592;1588:11;1583:2;1575:6;1571:15;1558:46;1646:1;1624:15;;;1641:2;1620:24;1613:35;;;;-1:-1:-1;1628:6:1;757:922;-1:-1:-1;;;;;757:922:1:o;1684:362::-;1760:6;1768;1821:2;1809:9;1800:7;1796:23;1792:32;1789:52;;;1837:1;1834;1827:12;1789:52;1860:23;;;-1:-1:-1;1933:2:1;1918:18;;1905:32;-1:-1:-1;;;;;1966:31:1;;1956:42;;1946:70;;2012:1;2009;2002:12;1946:70;2035:5;2025:15;;;1684:362;;;;;:::o;2710:277::-;2777:6;2830:2;2818:9;2809:7;2805:23;2801:32;2798:52;;;2846:1;2843;2836:12;2798:52;2878:9;2872:16;2931:5;2924:13;2917:21;2910:5;2907:32;2897:60;;2953:1;2950;2943:12;2897:60;2976:5;2710:277;-1:-1:-1;;;2710:277:1:o;3704:184::-;3774:6;3827:2;3815:9;3806:7;3802:23;3798:32;3795:52;;;3843:1;3840;3833:12;3795:52;-1:-1:-1;3866:16:1;;3704:184;-1:-1:-1;3704:184:1:o
Swarm Source
ipfs://6cc4ea45f75d2631f577aede0a7f902b8ced999dcc96b53b2875534071fec5e4
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.21
Net Worth in ETH
0.0001
Token Allocations
ETH
100.00%
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| ETH | 100.00% | $2,078.94 | 0.0001 | $0.207894 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.