Address Contract Verified
Address
0x90dD9A085f126C79992bb07da65b5abBE85c81c2
Balance
0 ETH
Nonce
1
Code Size
6388 bytes
Creator
0x873A45Fc...29ac at tx 0x94b9a2f6...57f2b8
Indexed Transactions
0
Contract Bytecode
6388 bytes
0x6080604052600436106100705760003560e01c8063776c23fb1161004e578063776c23fb146100f4578063b07506111461011f578063b231c4b51461014a578063cde69b6b1461017557610070565b806315e7ea35146100755780631885c2f9146100a057806333fca8b1146100c9575b600080fd5b34801561008157600080fd5b5061008a610191565b6040516100979190610e7f565b60405180910390f35b3480156100ac57600080fd5b506100c760048036038101906100c29190610f75565b6101b5565b005b3480156100d557600080fd5b506100de6103ea565b6040516100eb9190610ff8565b60405180910390f35b34801561010057600080fd5b5061010961040e565b6040516101169190610e7f565b60405180910390f35b34801561012b57600080fd5b50610134610432565b6040516101419190610ff8565b60405180910390f35b34801561015657600080fd5b5061015f610456565b60405161016c9190610e7f565b60405180910390f35b61018f600480360381019061018a9190611013565b61047a565b005b7f000000000000000000000000f0000058000021003e4754dca700c766de7601c281565b7f000000000000000000000000f0000058000021003e4754dca700c766de7601c273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461023a576040517ff7f5e02c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461029f576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600082828101906102b09190611134565b90506000670de0b6b3a76400007f000000000000000000000000000000000000000000000000000000000000000083600001516102ed9190611190565b6102f79190611201565b90507f0000000000000000000000009c9d06c7378909c6d0a2a0017bb409f7fb8004e073ffffffffffffffffffffffffffffffffffffffff16636e553f658284602001516040518363ffffffff1660e01b8152600401610358929190611232565b600060405180830381600087803b15801561037257600080fd5b505af1158015610386573d6000803e3d6000fd5b50505050816020015173ffffffffffffffffffffffffffffffffffffffff167fa358eb0a2221125d2929ba22f79e4ac9e4f7e218295628d6f552eb6f5c423c198284600001516040516103da92919061125b565b60405180910390a2505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000026f01fe3be55361b0643bc9d5d60980e37a2770d81565b7f000000000000000000000000000000000000000000000000000000000000210581565b7f0000000000000000000000009c9d06c7378909c6d0a2a0017bb409f7fb8004e081565b46600181146104b5576040517f10dfc03300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361051b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f00000000000000000000000026f01fe3be55361b0643bc9d5d60980e37a2770d73ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b81526004016105769190610e7f565b602060405180830381865afa158015610593573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b79190611299565b905060008111156106105761060f3330837f00000000000000000000000026f01fe3be55361b0643bc9d5d60980e37a2770d73ffffffffffffffffffffffffffffffffffffffff16610af0909392919063ffffffff16565b5b60007f0000000000000000000000009c9d06c7378909c6d0a2a0017bb409f7fb8004e073ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b815260040161066b9190610e7f565b6020604051808303816000875af115801561068a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ae9190611299565b9050600081111561082e577f0000000000000000000000009c9d06c7378909c6d0a2a0017bb409f7fb8004e073ffffffffffffffffffffffffffffffffffffffff166384e9bd7e336040518263ffffffff1660e01b81526004016107129190610e7f565b600060405180830381600087803b15801561072c57600080fd5b505af1158015610740573d6000803e3d6000fd5b505050506107913330837f0000000000000000000000009c9d06c7378909c6d0a2a0017bb409f7fb8004e073ffffffffffffffffffffffffffffffffffffffff16610af0909392919063ffffffff16565b7f0000000000000000000000009c9d06c7378909c6d0a2a0017bb409f7fb8004e073ffffffffffffffffffffffffffffffffffffffff166338d074368260006040518363ffffffff1660e01b81526004016107ed9291906112e1565b600060405180830381600087803b15801561080757600080fd5b505af115801561081b573d6000803e3d6000fd5b50505050808261082b919061130a565b91505b60008203610868576040517f9890af6000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f00000000000000000000000026f01fe3be55361b0643bc9d5d60980e37a2770d73ffffffffffffffffffffffffffffffffffffffff16639dc29fac30846040518363ffffffff1660e01b81526004016108c392919061133e565b600060405180830381600087803b1580156108dd57600080fd5b505af11580156108f1573d6000803e3d6000fd5b50505050600060405180604001604052808481526020018773ffffffffffffffffffffffffffffffffffffffff1681525060405160200161093291906113b4565b6040516020818303038152906040529050600060405180608001604052807f000000000000000000000000000000000000000000000000000000000000210581526020013073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff8111156109ad576109ac611069565b5b6040519080825280602002602001820160405280156109e657816020015b6109d3610e0e565b8152602001906001900390816109cb5790505b5081526020018381525090507f000000000000000000000000f0000058000021003e4754dca700c766de7601c273ffffffffffffffffffffffffffffffffffffffff16632be9a5fc3483898b6040518563ffffffff1660e01b8152600401610a5093929190611596565b6000604051808303818588803b158015610a6957600080fd5b505af1158015610a7d573d6000803e3d6000fd5b50505050508673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f3f99987c7ac0452402bf8d577a8444d018cc2983888941a3b1dfec925d30fdaf86604051610adf9190610ff8565b60405180910390a350505050505050565b610b73846323b872dd60e01b858585604051602401610b11939291906115d4565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610b79565b50505050565b6000610bdb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610c419092919063ffffffff16565b9050600081511480610bfd575080806020019051810190610bfc9190611637565b5b610c3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c33906116e7565b60405180910390fd5b505050565b6060610c508484600085610c59565b90509392505050565b606082471015610c9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9590611779565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610cc791906117d5565b60006040518083038185875af1925050503d8060008114610d04576040519150601f19603f3d011682016040523d82523d6000602084013e610d09565b606091505b5091509150610d1a87838387610d26565b92505050949350505050565b60608315610d88576000835103610d8057610d4085610d9b565b610d7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7690611838565b60405180910390fd5b5b829050610d93565b610d928383610dbe565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610dd15781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e05919061189c565b60405180910390fd5b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610e6982610e3e565b9050919050565b610e7981610e5e565b82525050565b6000602082019050610e946000830184610e70565b92915050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b610ec181610eae565b8114610ecc57600080fd5b50565b600081359050610ede81610eb8565b92915050565b610eed81610e5e565b8114610ef857600080fd5b50565b600081359050610f0a81610ee4565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112610f3557610f34610f10565b5b8235905067ffffffffffffffff811115610f5257610f51610f15565b5b602083019150836001820283011115610f6e57610f6d610f1a565b5b9250929050565b60008060008060608587031215610f8f57610f8e610ea4565b5b6000610f9d87828801610ecf565b9450506020610fae87828801610efb565b935050604085013567ffffffffffffffff811115610fcf57610fce610ea9565b5b610fdb87828801610f1f565b925092505092959194509250565b610ff281610eae565b82525050565b600060208201905061100d6000830184610fe9565b92915050565b6000806040838503121561102a57611029610ea4565b5b600061103885828601610efb565b925050602061104985828601610ecf565b9150509250929050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6110a182611058565b810181811067ffffffffffffffff821117156110c0576110bf611069565b5b80604052505050565b60006110d3610e9a565b90506110df8282611098565b919050565b6000604082840312156110fa576110f9611053565b5b61110460406110c9565b9050600061111484828501610ecf565b600083015250602061112884828501610efb565b60208301525092915050565b60006040828403121561114a57611149610ea4565b5b6000611158848285016110e4565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061119b82610eae565b91506111a683610eae565b92508282026111b481610eae565b915082820484148315176111cb576111ca611161565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061120c82610eae565b915061121783610eae565b925082611227576112266111d2565b5b828204905092915050565b60006040820190506112476000830185610fe9565b6112546020830184610e70565b9392505050565b60006040820190506112706000830185610fe9565b61127d6020830184610fe9565b9392505050565b60008151905061129381610eb8565b92915050565b6000602082840312156112af576112ae610ea4565b5b60006112bd84828501611284565b91505092915050565b60008115159050919050565b6112db816112c6565b82525050565b60006040820190506112f66000830185610fe9565b61130360208301846112d2565b9392505050565b600061131582610eae565b915061132083610eae565b925082820190508082111561133857611337611161565b5b92915050565b60006040820190506113536000830185610e70565b6113606020830184610fe9565b9392505050565b61137081610eae565b82525050565b61137f81610e5e565b82525050565b60408201600082015161139b6000850182611367565b5060208201516113ae6020850182611376565b50505050565b60006040820190506113c96000830184611385565b92915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6040820160008201516114116000850182611376565b5060208201516114246020850182611367565b50505050565b600061143683836113fb565b60408301905092915050565b6000602082019050919050565b600061145a826113cf565b61146481856113da565b935061146f836113eb565b8060005b838110156114a0578151611487888261142a565b975061149283611442565b925050600181019050611473565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156114e75780820151818401526020810190506114cc565b60008484015250505050565b60006114fe826114ad565b61150881856114b8565b93506115188185602086016114c9565b61152181611058565b840191505092915050565b60006080830160008301516115446000860182611367565b5060208301516115576020860182611376565b506040830151848203604086015261156f828261144f565b9150506060830151848203606086015261158982826114f3565b9150508091505092915050565b600060608201905081810360008301526115b0818661152c565b90506115bf6020830185610fe9565b6115cc6040830184610e70565b949350505050565b60006060820190506115e96000830186610e70565b6115f66020830185610e70565b6116036040830184610fe9565b949350505050565b611614816112c6565b811461161f57600080fd5b50565b6000815190506116318161160b565b92915050565b60006020828403121561164d5761164c610ea4565b5b600061165b84828501611622565b91505092915050565b600082825260208201905092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b60006116d1602a83611664565b91506116dc82611675565b604082019050919050565b60006020820190508181036000830152611700816116c4565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000611763602683611664565b915061176e82611707565b604082019050919050565b6000602082019050818103600083015261179281611756565b9050919050565b600081905092915050565b60006117af826114ad565b6117b98185611799565b93506117c98185602086016114c9565b80840191505092915050565b60006117e182846117a4565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000611822601d83611664565b915061182d826117ec565b602082019050919050565b6000602082019050818103600083015261185181611815565b9050919050565b600081519050919050565b600061186e82611858565b6118788185611664565b93506118888185602086016114c9565b61189181611058565b840191505092915050565b600060208201905081810360008301526118b68184611863565b90509291505056fea2646970667358221220ab35a924aa72affaa64f0164cd53ff846376627f1643a3eb30505c3f7d6ee6e164736f6c63430008130033
Verified Source Code Full Match
Compiler: v0.8.19+commit.7dd6d404
EVM: paris
Optimization: No
Converter.sol 180 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ISdToken} from "src/common/interfaces/ISdToken.sol";
import {ILaPoste} from "src/common/interfaces/ILaPoste.sol";
import {ILiquidityGauge} from "src/common/interfaces/ILiquidityGauge.sol";
contract Converter {
using SafeERC20 for IERC20;
/////////////////////////////
/// --- Structs
/////////////////////////////
struct Payload {
uint256 amount;
address receiver;
}
/////////////////////////////
/// --- VARIABLES
/////////////////////////////
/// @notice The sdToken use for conversion.
address public immutable sdToken;
/// @notice The sdToken staking contract.
address public immutable sdTokenGauge;
/// @notice The La Poste address.
address public immutable laPoste;
/// @notice The chain id to send messages.
uint256 public immutable destinationChainId;
/// @notice Conversion rate for old sdToken to new sdToken, 18 decimals basis
uint256 public immutable conversionRatio;
/////////////////////////////
/// --- ERRORS
/////////////////////////////
error WrongChain();
error NotLaPoste();
error ZeroAddress();
error InvalidSender();
error NothingToRedeem();
/////////////////////////////
/// --- EVENTS
/////////////////////////////
/// @notice Emitted when conversion is initiated
/// @param user Address sending the tokens on initial chain
/// @param receiver Address receiving the tokens on destination chain
/// @param amount Amount of tokens burnt and to be converted
event ConvertedAmount(address indexed user, address indexed receiver, uint256 amount);
/// @notice Emitted when conversion is resumed
/// @param user Address receiving the tokens on destination chain
/// @param receivedAmount Amount of tokens received after conversion
/// @param convertedAmount Amount of tokens used for conversion
event ReceivedAmount(address indexed user, uint256 receivedAmount, uint256 convertedAmount);
/////////////////////////////
/// --- CONSTRUCTOR
/////////////////////////////
/// @notice Initializes the Convertor contract with required dependencies
/// @param _sdToken sdToken address, should be old sdToken on departure chain, and new sdToken on destination chain
/// @param _sdTokenGauge gauge address, should be old gauge on departure chain, and new gauge on destination chain
/// @param _laPoste Address of La Poste messaging system
/// @param _destinationChainId Destination chain id to send message to, only used on departure chain
/// @param _conversionRatio Conversion ratio between old sdToken and new sdToken, with 18 decimals
constructor(
address _sdToken,
address _sdTokenGauge,
address _laPoste,
uint256 _destinationChainId,
uint256 _conversionRatio
) {
sdToken = _sdToken;
sdTokenGauge = _sdTokenGauge;
laPoste = _laPoste;
destinationChainId = _destinationChainId;
conversionRatio = _conversionRatio;
if (block.chainid != 1) {
IERC20(sdToken).approve(sdTokenGauge, type(uint256).max);
}
}
/////////////////////////////
/// --- MODIFIERS
/////////////////////////////
modifier onlyMainnet(uint256 chainId) {
if (chainId != 1) revert WrongChain();
_;
}
modifier onlyLaPoste() {
if (msg.sender != laPoste) revert NotLaPoste();
_;
}
/////////////////////////////
/// --- PUBLIC FUNCTIONS
/////////////////////////////
/// @notice Initializes a conversion of old sdToken to a new sdToken, by sending a message to La Poste
/// @param _receiver Address of the address receiving the new sdToken on destination chain
/// @param _additionalGasLimit Additional gas limit for transaction execution on destination chain
function initConvert(address _receiver, uint256 _additionalGasLimit) external payable onlyMainnet(block.chainid) {
if (_receiver == address(0)) revert ZeroAddress();
// 1. Transfer sdTokens from user to this contract
uint256 redeemAmount = IERC20(sdToken).balanceOf(msg.sender);
if (redeemAmount > 0) {
IERC20(sdToken).safeTransferFrom(msg.sender, address(this), redeemAmount);
}
// 2. Unstake from gauge: claim rewards + withdraw
uint256 sdTokenGaugeBalance = ILiquidityGauge(sdTokenGauge).balanceOf(msg.sender);
if (sdTokenGaugeBalance > 0) {
// Claim rewards to msg.sender
ILiquidityGauge(sdTokenGauge).claim_rewards(msg.sender);
// Transfer gauge shares from user to this contract
IERC20(sdTokenGauge).safeTransferFrom(msg.sender, address(this), sdTokenGaugeBalance);
// Withdraw staked tokens from gauge to this contract
ILiquidityGauge(sdTokenGauge).withdraw(sdTokenGaugeBalance, false);
// Add the gauge balance to the redeem amount
redeemAmount += sdTokenGaugeBalance;
}
// 3. Check if there is anything to redeem
if (redeemAmount == 0) revert NothingToRedeem();
// 4. Burn sdTokens
ISdToken(sdToken).burn(address(this), redeemAmount);
// 5. Build and send message to La Poste to initiate conversion
bytes memory payload = abi.encode(Payload({amount: redeemAmount, receiver: _receiver}));
ILaPoste.MessageParams memory messageParams = ILaPoste.MessageParams({
destinationChainId: destinationChainId,
to: address(this),
tokens: new ILaPoste.Token[](0),
payload: payload
});
ILaPoste(laPoste).sendMessage{value: msg.value}(messageParams, _additionalGasLimit, _receiver);
emit ConvertedAmount(msg.sender, _receiver, redeemAmount);
}
/// @notice Resolution of the conversion, should only be called by La Poste on destination chain
/// @param (unused) Departure chain of the message
/// @param sender Address sending the message from the departure chain, should be the same as address(this)
/// @param payload bytes of data for parameters, should fit the Payload structure when decoded
function receiveMessage(uint256, address sender, bytes calldata payload) external onlyLaPoste {
if (sender != address(this)) revert InvalidSender();
// 1. Decode payload
Payload memory _payload = abi.decode(payload, (Payload));
// 2. Compute amount of sdTokens and stake them for the receiver
uint256 toSend = _payload.amount * conversionRatio / 10 ** 18;
ILiquidityGauge(sdTokenGauge).deposit(toSend, _payload.receiver);
emit ReceivedAmount(_payload.receiver, toSend, _payload.amount);
}
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
ISdToken.sol 22 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
interface ISdToken {
function balanceOf(address account) external view returns (uint256);
function burn(uint256 amount) external;
function burn(address _to, uint256 _amount) external;
function mint(address _to, uint256 _amount) external;
function operator() external view returns (address);
function burner() external view returns (address);
function setOperator(address _operator) external;
function setBurnerOperator(address _burner) external;
function approve(address _spender, uint256 _amount) external;
}
ILaPoste.sol 39 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
interface ILaPoste {
struct Token {
address tokenAddress;
uint256 amount;
}
struct TokenMetadata {
string name;
string symbol;
uint8 decimals;
}
struct MessageParams {
uint256 destinationChainId;
address to;
Token[] tokens;
bytes payload;
}
struct Message {
uint256 destinationChainId;
address to;
address sender;
Token[] tokens;
TokenMetadata[] tokenMetadata;
bytes payload;
uint256 nonce;
}
function tokenFactory() external view returns (address);
function receiveMessage(uint256 chainId, bytes calldata payload) external;
function sendMessage(MessageParams memory params, uint256 additionalGasLimit, address refundAddress)
external
payable;
}
ILiquidityGauge.sol 96 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
interface ILiquidityGauge {
struct Reward {
address token;
address distributor;
// solhint-disable-next-line
uint256 period_finish;
uint256 rate;
// solhint-disable-next-line
uint256 last_update;
uint256 integral;
}
// solhint-disable-next-line
function deposit_reward_token(address _rewardToken, uint256 _amount) external;
// solhint-disable-next-line
function claim_rewards_for(address _user, address _recipient) external;
// solhint-disable-next-line
function working_balances(address _address) external view returns (uint256);
// solhint-disable-next-line
function deposit(uint256 _value, address _addr) external;
// solhint-disable-next-line
function reward_tokens(uint256 _i) external view returns (address);
// solhint-disable-next-line
function reward_data(address _tokenReward) external view returns (Reward memory);
function balanceOf(address) external returns (uint256);
// solhint-disable-next-line
function claimable_reward(address _user, address _reward_token) external view returns (uint256);
// solhint-disable-next-line
function claimable_tokens(address _user) external returns (uint256);
// solhint-disable-next-line
function user_checkpoint(address _user) external returns (bool);
// solhint-disable-next-line
function commit_transfer_ownership(address) external;
// solhint-disable-next-line
function claim_rewards() external;
// solhint-disable-next-line
function claim_rewards(address) external;
// solhint-disable-next-line
function claim_rewards(address, address) external;
// solhint-disable-next-line
function add_reward(address, address) external;
// solhint-disable-next-line
function set_claimer(address) external;
function admin() external view returns (address);
function future_admin() external view returns (address);
// solhint-disable-next-line
function set_reward_distributor(address _rewardToken, address _newDistrib) external;
function initialize(
// solhint-disable-next-line
address staking_token,
address admin,
address sdt,
// solhint-disable-next-line
address voting_escrow,
// solhint-disable-next-line
address veBoost_proxy,
address distributor
) external;
function totalSupply() external returns (uint256);
function withdraw(uint256 _value, bool _claimReward) external;
function withdraw(uint256 _value, address _user, bool _claimReward) external;
// solhint-disable-next-line
function accept_transfer_ownership() external;
// solhint-disable-next-line
function claimed_reward(address _addr, address _token) external view returns (uint256);
// solhint-disable-next-line
function set_rewards_receiver(address _receiver) external;
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Read Contract
conversionRatio 0x33fca8b1 → uint256
destinationChainId 0xb0750611 → uint256
laPoste 0x15e7ea35 → address
sdToken 0x776c23fb → address
sdTokenGauge 0xb231c4b5 → address
Write Contract 2 functions
These functions modify contract state and require a wallet transaction to execute.
initConvert 0xcde69b6b
address _receiver
uint256 _additionalGasLimit
receiveMessage 0x1885c2f9
uint256
address sender
bytes payload
Recent Transactions
No transactions found for this address