Skip to content

Commit

Permalink
FluentSdkRustPrbMathTestValues.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusWentz committed Feb 22, 2025
1 parent ec44caf commit 82ff2eb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
46 changes: 46 additions & 0 deletions Contracts/FluentSdkRustPrbMathTestValues.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

interface IFluentRust {
// Make sure type interfaces are defined here or else there will be a compiler error.
function rustLnUint256() external view returns (uint256);
function rustLog10Uint256() external view returns (uint256);
function rustLog2Uint256() external view returns (uint256);
function rustSqrtUint256() external view returns (uint256);
function rustExpUint256() external view returns (uint256);
}

contract FluentSdkRustPrbMathTestValues {

IFluentRust public fluentRust;

constructor(address FluentRustAddress) {
fluentRust = IFluentRust(FluentRustAddress);
}

function getRustLnUint256() external view returns (uint256) {
uint256 rustUint256 = fluentRust.rustLnUint256();
return rustUint256;
}

function getRustLog10Uint256() external view returns (uint256) {
uint256 rustUint256 = fluentRust.rustLog10Uint256();
return rustUint256;
}

function getRustLog2Uint256() external view returns (uint256) {
uint256 rustUint256 = fluentRust.rustLog2Uint256();
return rustUint256;
}

function getRustSqrtUint256() external view returns (uint256) {
uint256 rustUint256 = fluentRust.rustSqrtUint256();
return rustUint256;
}

function getRustExpUint256() external view returns (uint256) {
uint256 rustUint256 = fluentRust.rustExpUint256();
return rustUint256;
}

}
5 changes: 4 additions & 1 deletion Scripts/rust/fluent/prb_math_return_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ impl<SDK: SharedAPI> RouterAPI for ROUTER<SDK> {

let ln_result_float: f64 = libm::log(input); // Natural log (ln)
let ln_result_uint : u32 = libm::round(ln_result_float) as u32;

// let uint256_test = U256::from(10);

let uint256_test = U256::from(ln_result_uint);

return uint256_test;
}

Expand Down Expand Up @@ -81,7 +84,7 @@ impl<SDK: SharedAPI> RouterAPI for ROUTER<SDK> {
let log2_result_uint : u32 = libm::round(log2_result_float) as u32;
// println!("{}",log2_result_uint);

let uint256_test = U256::from(10);
let uint256_test = U256::from(log2_result_uint);
return uint256_test;
}

Expand Down

0 comments on commit 82ff2eb

Please sign in to comment.