Skip to content
Verified contractPartialLicenseRef-DCL-1.0

GenericPoolRaindexV7FlashBorrower

Address0x8b305551e2ee577f3a4f42cb44cb2aa2f03cc82e
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.25

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.25+commit.b61c2a91
Language
solidity
Optimization
Yes, 800 runs
EVM version
cancun
License
LicenseRef-DCL-1.0
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,282,658
Creation transaction
0x4a20591d31…121f86485f

69 files

The source code is large: one file is shown at a time. Choose a file in the list.

src/concrete/arb/GenericPoolRaindexV7FlashBorrower.sol

// SPDX-License-Identifier: LicenseRef-DCL-1.0
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {RaindexV7FlashBorrower, TakeOrdersConfigV6} from "../../abstract/RaindexV7FlashBorrower.sol";
import {LibGenericPoolExchange} from "../../lib/LibGenericPoolExchange.sol";

/// @title GenericPoolRaindexV7FlashBorrower
/// @notice Flash-loan arb that swaps via an arbitrary external pool call.
/// @dev Implements the RaindexV7FlashBorrower interface for an external
/// liquidity source that behaves vaguely like a standard AMM. The
/// `exchangeData` from `arb` is decoded into a spender, pool and callData.
/// The `callData` is literally the encoded function call to the pool. This
/// allows the `arb` caller to process a trade against any liquidity source
/// that can swap tokens within a single function call.
/// The `spender` is the address that will be approved to spend the input token
/// on `takeOrders`, which is almost always going to be the pool itself. If you
/// are unsure, simply set it to the pool address.
contract GenericPoolRaindexV7FlashBorrower is RaindexV7FlashBorrower {
    constructor() {}

    /// @inheritdoc RaindexV7FlashBorrower
    /// @dev Decodes `exchangeData` as `(spender, pool, encodedFunctionCall)`
    /// and routes the swap through the specified pool via `LibGenericPoolExchange`.
    function _exchange(TakeOrdersConfigV6 memory takeOrders, bytes memory exchangeData) internal virtual override {
        address borrowedToken = takeOrders.orders[0].order.validOutputs[takeOrders.orders[0].outputIOIndex].token;
        LibGenericPoolExchange.exchange(borrowedToken, exchangeData);
    }

    /// Allow arbitrary calls and ETH transfers to this contract without
    /// reverting. Any ETH still held when `finalizeArb` runs is swept to
    /// `msg.sender`. The arb holds no ETH between operations, so anyone who
    /// sends ETH outside an `arb` call forfeits it: an in-flight generic pool
    /// exchange forwards the contract's entire ETH balance to the pool before
    /// `finalizeArb` is reached.
    receive() external payable {}
    fallback() external payable {}
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": false,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 800,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@openzeppelin-contracts-5.7.0/=dependencies/@openzeppelin-contracts-5.7.0/",
    "forge-std-1.17.0/=dependencies/forge-std-1.17.0/",
    "rain-deploy-0.1.25/=dependencies/rain-deploy-0.1.25/",
    "rain-extrospection-0.1.16/=dependencies/rain-extrospection-0.1.16/",
    "rain-factory-0.2.5/=dependencies/rain-factory-0.2.5/",
    "rain-intorastring-0.1.4/=dependencies/rain-intorastring-0.1.4/",
    "rain-lib-hash-0.1.27/=dependencies/rain-lib-hash-0.1.27/",
    "rain-lib-memkv-0.2.0/=dependencies/rain-lib-memkv-0.2.0/",
    "rain-lib-typecast-0.1.4/=dependencies/rain-lib-typecast-0.1.4/",
    "rain-math-binary-0.1.4/=dependencies/rain-math-binary-0.1.4/",
    "rain-math-float-0.3.11/=dependencies/rain-math-float-0.3.11/",
    "rain-math-float-deploy-0.1.9/=dependencies/rain-math-float-deploy-0.1.9/",
    "rain-metadata-0.1.43/=dependencies/rain-metadata-0.1.43/",
    "rain-metadata-deploy-0.1.4/=dependencies/rain-metadata-deploy-0.1.4/",
    "rain-sol-codegen-0.1.39/=dependencies/rain-sol-codegen-0.1.39/",
    "rain-solmem-0.1.28/=dependencies/rain-solmem-0.1.28/",
    "rain-string-0.3.9/=dependencies/rain-string-0.3.9/",
    "rain-tofu-erc20-decimals-0.1.4/=dependencies/rain-tofu-erc20-decimals-0.1.4/",
    "rain-tofu-erc20-decimals-deploy-0.1.4/=dependencies/rain-tofu-erc20-decimals-deploy-0.1.4/",
    "raindex-interface-0.1.13/=dependencies/raindex-interface-0.1.13/",
    "rainlang-0.2.30/=dependencies/rainlang-0.2.30/",
    "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.7.0/",
    "mut/=dependencies/rain-string-0.3.9/src/lib/mut/",
    "parse/=dependencies/rain-string-0.3.9/src/lib/parse/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.