Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into kris/total-donation…
Browse files Browse the repository at this point in the history
…s-as-sum
  • Loading branch information
krisbitney committed Feb 5, 2024
2 parents 018284a + 29215b3 commit 6d3580f
Show file tree
Hide file tree
Showing 20 changed files with 515 additions and 226 deletions.
312 changes: 156 additions & 156 deletions .yarn/releases/yarn-3.6.0.cjs → .yarn/releases/yarn-3.6.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.0.cjs
yarnPath: .yarn/releases/yarn-3.6.1.cjs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"packages/*"
]
},
"packageManager": "[email protected].0",
"packageManager": "[email protected].1",
"devDependencies": {
"chalk": "^4.1.2",
"commander": "^9.4.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/components/DonateComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ function DonateComponent({ collective }: DonateComponentProps) {
currency,
decimalDonationAmount,
duration,
(value: boolean) => setApproveSwapModalVisible(value)
(value: boolean) => setApproveSwapModalVisible(value),
collectiveId
);
const approvalNotReady = handleApproveToken === undefined && currency !== 'G$';

Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/hooks/useApproveSwapTokenCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { calculateRawTotalDonation } from '../lib/calculateRawTotalDonation';
import Decimal from 'decimal.js';
import ERC20 from '../abi/ERC20.json';
import { useToken } from './useTokenList';
import { UNISWAP_V3_ROUTER_ADDRESS } from '../models/constants';

export function useApproveSwapTokenCallback(
currencyIn: string,
decimalAmountIn: number,
duration: number,
toggleApproveSwapModalVisible: (value: boolean) => void
toggleApproveSwapModalVisible: (value: boolean) => void,
collectiveAddress: string
): {
isLoading: boolean;
isSuccess: boolean;
Expand All @@ -32,7 +32,7 @@ export function useApproveSwapTokenCallback(
abi: ERC20,
account: address,
functionName: 'approve',
args: [UNISWAP_V3_ROUTER_ADDRESS, rawAmountIn],
args: [collectiveAddress, rawAmountIn],
});

const { isLoading, isSuccess, isError, writeAsync } = useContractWrite(config);
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/subgraph/useSubgraphCollective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SubgraphCollective } from './subgraphModels';

export const collectivesById = gql`
query COLLECTIVES_BY_ID($ids: [String!]) {
collectives(where: { id_in: $ids }) {
collectives(where: { id_in: $ids, ipfs_: { name_not: null } }) {
id
ipfs {
id
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/subgraph/useSubgraphIpfsCollective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { gql } from '@apollo/client';
import { IpfsCollectivesSubgraphResponse, useSubgraphData } from './useSubgraphData';
import { SubgraphIpfsCollective } from './subgraphModels';

// filter by name not null, because it can take time until thegraph index from ipfs, and if ipfs fields are null it will break the query
const allIpfsCollectives = gql`
query IPFS_COLLECTIVES {
collectives {
collectives(where: { ipfs_: { name_not: null } }) {
id
ipfs {
id
Expand Down
17 changes: 10 additions & 7 deletions packages/app/vercel.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/"
}
]
}
"git": {
"deploymentEnabled": false
},
"rewrites": [
{
"source": "/(.*)",
"destination": "/"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ contract DirectPaymentsPool is
DirectPaymentsFactory public registry;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(ISuperfluid _host, ISwapRouter _swapRouter) GoodCollectiveSuperApp(_host, _swapRouter) {}
constructor(ISuperfluid _host, IV3SwapRouter _swapRouter) GoodCollectiveSuperApp(_host, _swapRouter) {}

/**
* @dev Authorizes an upgrade for the implementation contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/cont
import { CFAv1Library, IConstantFlowAgreementV1 } from "@superfluid-finance/ethereum-contracts/contracts/apps/CFAv1Library.sol";

import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol";

import "../DirectPayments/DirectPaymentsFactory.sol";
import "../utils/HelperLibrary.sol";
Expand Down Expand Up @@ -51,7 +51,7 @@ abstract contract GoodCollectiveSuperApp is SuperAppBaseFlow {
// ask about "receiver" can it be different then app?

/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
ISwapRouter public immutable swapRouter;
IV3SwapRouter public immutable swapRouter;

struct SupporterData {
uint256 contribution;
Expand All @@ -71,7 +71,7 @@ abstract contract GoodCollectiveSuperApp is SuperAppBaseFlow {
uint256[48] private _reserved;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(ISuperfluid _host, ISwapRouter _swapRouter) SuperAppBaseFlow(_host) {
constructor(ISuperfluid _host, IV3SwapRouter _swapRouter) SuperAppBaseFlow(_host) {
if (address(_host) == address(0)) revert ZERO_ADDRESS();
swapRouter = _swapRouter;
}
Expand Down
10 changes: 4 additions & 6 deletions packages/contracts/contracts/utils/HelperLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity >=0.8.0;

import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol";
import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";

Expand All @@ -29,7 +29,7 @@ library HelperLibrary {
}

function handleSwap(
ISwapRouter swapRouter,
IV3SwapRouter swapRouter,
SwapData memory _customData,
address outTokenIfNoPath,
address _sender
Expand All @@ -42,22 +42,20 @@ library HelperLibrary {

if (_customData.path.length > 0) {
// If a path is provided, execute a multi-hop swap
ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
IV3SwapRouter.ExactInputParams memory params = IV3SwapRouter.ExactInputParams({
path: _customData.path,
recipient: _sender,
deadline: _customData.deadline,
amountIn: _customData.amount,
amountOutMinimum: _customData.minReturn
});
swapRouter.exactInput(params);
} else {
// If no path is provided, execute a single-hop swap
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
IV3SwapRouter.ExactInputSingleParams memory params = IV3SwapRouter.ExactInputSingleParams({
tokenIn: _customData.swapFrom,
tokenOut: outTokenIfNoPath,
fee: 10000,
recipient: _sender,
deadline: _customData.deadline,
amountIn: _customData.amount,
amountOutMinimum: _customData.minReturn,
sqrtPriceLimitX96: 0
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/contracts/utils/SwapRouterMock.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract SwapRouterMock {
Expand All @@ -14,15 +14,15 @@ contract SwapRouterMock {
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(ISwapRouter.ExactInputParams calldata params) external payable returns (uint256 amountOut) {
function exactInput(IV3SwapRouter.ExactInputParams calldata params) external payable returns (uint256 amountOut) {
amountOut = params.amountOutMinimum;

// Transfer the output token to the recipient
_token.transfer(params.recipient, amountOut);
}

function exactInputSingle(
ISwapRouter.ExactInputSingleParams memory params
IV3SwapRouter.ExactInputSingleParams memory params
) external payable returns (uint256 amountOut) {
amountOut = params.amountOutMinimum;

Expand Down
1 change: 1 addition & 0 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/prettier": "^2",
"@types/sinon-chai": "^3.2.3",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@uniswap/swap-router-contracts": "^1.3.1",
"@uniswap/v3-periphery": "^1.4.3",
"chai": "^4.2.0",
"dotenv": "^16.3.1",
Expand Down
Loading

0 comments on commit 6d3580f

Please sign in to comment.