Add atomic DODO seeding helper
Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m6s
CI/CD Pipeline / Security Scanning (push) Successful in 2m34s
CI/CD Pipeline / Lint and Format (push) Failing after 37s
CI/CD Pipeline / Terraform Validation (push) Failing after 22s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 21s
Validation / validate-genesis (push) Successful in 33s
Validation / validate-terraform (push) Failing after 29s
Validation / validate-kubernetes (push) Failing after 11s
Validation / validate-smart-contracts (push) Failing after 12s
Validation / validate-security (push) Failing after 58s
Validation / validate-documentation (push) Failing after 19s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 23s
Verify Deployment / Verify Deployment (push) Failing after 49s

This commit is contained in:
defiQUG
2026-04-30 03:06:42 -07:00
parent bbf1f6ba89
commit c0173f3132

View File

@@ -0,0 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20AtomicSeeder {
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
interface IDODOAtomicSeedPool {
function buyShares(address to) external returns (uint256 baseShare, uint256 quoteShare, uint256 lpShare);
}
/**
* @title DODOAtomicSeeder
* @notice Pulls both DODO DVM seed tokens and mints LP shares in one transaction.
* @dev This avoids exposing half-seeded pools between separate ERC-20 transfers.
*/
contract DODOAtomicSeeder {
error TransferFromFailed(address token);
error ZeroAddress();
function seed(
address pool,
address baseToken,
address quoteToken,
uint256 baseAmount,
uint256 quoteAmount,
address recipient
) external returns (uint256 baseShare, uint256 quoteShare, uint256 lpShare) {
if (pool == address(0) || baseToken == address(0) || quoteToken == address(0) || recipient == address(0)) {
revert ZeroAddress();
}
_safeTransferFrom(baseToken, msg.sender, pool, baseAmount);
_safeTransferFrom(quoteToken, msg.sender, pool, quoteAmount);
return IDODOAtomicSeedPool(pool).buyShares(recipient);
}
function _safeTransferFrom(address token, address from, address to, uint256 amount) internal {
if (amount == 0) return;
(bool ok, bytes memory data) = token.call(
abi.encodeWithSelector(IERC20AtomicSeeder.transferFrom.selector, from, to, amount)
);
if (!ok || (data.length != 0 && !abi.decode(data, (bool)))) {
revert TransferFromFailed(token);
}
}
}