Skip to content

Commit

Permalink
remove encoding + decoding of collateral value from api response in a…
Browse files Browse the repository at this point in the history
…utoredemption
  • Loading branch information
ewansheldon committed Dec 20, 2024
1 parent a03f0d5 commit 20f3b13
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions contracts/AutoRedemption.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract AutoRedemption is AutomationCompatibleInterface, FunctionsClient, Confi
mapping(address => bytes) swapPaths;

string private constant source =
"const { ethers } = await import('npm:[email protected]'); const apiResponse = await Functions.makeHttpRequest({ url: 'https://smart-vault-api.thestandard.io/redemption' }); if (apiResponse.error) { throw Error('Request failed'); } const { data } = apiResponse; const encoded = ethers.AbiCoder.defaultAbiCoder().encode(['uint256', 'address', 'uint256'], [data.tokenID, data.collateral, data.value]); return ethers.getBytes(encoded)";
"const { ethers } = await import('npm:[email protected]'); const apiResponse = await Functions.makeHttpRequest({ url: 'https://smart-vault-api.thestandard.io/redemption' }); if (apiResponse.error) { throw Error('Request failed'); } const { data } = apiResponse; const encoded = ethers.AbiCoder.defaultAbiCoder().encode(['uint256', 'address'], [data.tokenID, data.collateral]); return ethers.getBytes(encoded)";

constructor(
address _smartVaultManager,
Expand Down Expand Up @@ -136,8 +136,7 @@ contract AutoRedemption is AutomationCompatibleInterface, FunctionsClient, Confi
if (requestId != lastRequestId) revert("wrong request");
if (redemptionRequired()) {
uint256 _USDsTargetAmount = calculateUSDsToTargetPrice();
(uint256 _tokenID, address _token, uint256 _estimatedCollateralValueUSD) =
abi.decode(response, (uint256, address, uint256));
(uint256 _tokenID, address _token) = abi.decode(response, (uint256, address));
bytes memory _collateralToUSDsPath = swapPaths[_token];
ISmartVaultManager.SmartVaultData memory _vaultData = ISmartVaultManager(smartVaultManager).vaultData(_tokenID);
if (_USDsTargetAmount > _vaultData.status.minted) _USDsTargetAmount = _vaultData.status.minted;
Expand Down

0 comments on commit 20f3b13

Please sign in to comment.