Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate paraswap adapter #127

Merged
merged 8 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions contracts/ISwapCollateralParaswap.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

/**
* @title ParaSwapLiquiditySwapAdapter
* @notice Adapter to swap liquidity using ParaSwap.
* @author Jason Raymond Bell
*/
interface IParaSwapLiquiditySwapAdapter {
struct PermitSignature {
uint256 amount;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}

/**
* @dev Swaps an amount of an asset to another and deposits the new asset amount on behalf of the user without using a flash loan.
* This method can be used when the temporary transfer of the collateral asset to this contract does not affect the user position.
* The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset and perform the swap.
* @param assetToSwapFrom Address of the underlying asset to be swapped from
* @param assetToSwapTo Address of the underlying asset to be swapped to and deposited
* @param amountToSwap Amount to be swapped, or maximum amount when swapping all balance
* @param minAmountToReceive Minimum amount to be received from the swap
* @param swapAllBalanceOffset Set to offset of fromAmount in Augustus calldata if wanting to swap all balance, otherwise 0
* @param swapCalldata Calldata for ParaSwap's AugustusSwapper contract
* @param augustus Address of ParaSwap's AugustusSwapper contract
* @param permitParams Struct containing the permit signatures, set to all zeroes if not used
*/
function swapAndDeposit(
address assetToSwapFrom,
address assetToSwapTo,
uint256 amountToSwap,
uint256 minAmountToReceive,
uint256 swapAllBalanceOffset,
bytes calldata swapCalldata,
address augustus,
PermitSignature calldata permitParams
) external;
}
2 changes: 1 addition & 1 deletion src/tx-builder/config/v2/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const commonContractAddressBetweenMarketsV2: CommonConfigType = {
LEND_TO_AAVE_MIGRATOR: '0x317625234562b1526ea2fac4030ea499c5291de4',
WETH_GATEWAY: '0xcc9a0B7c43DC2a5F023Bb9b738E45B0Ef6B06E04',
FAUCET: '',
SWAP_COLLATERAL_ADAPTER: '0x63a3f444e97d14e671e7ee323c4234c8095e3516',
SWAP_COLLATERAL_ADAPTER: '0x135896DE8421be2ec868E0b811006171D9df802A',
REPAY_WITH_COLLATERAL_ADAPTER: '0x498c5431eb517101582988fbb36431ddaac8f4b1',
FLASHLIQUIDATION: '0xE377fB98512D7b04827e56BC84e1838804a8019D',
INCENTIVES_CONTROLLER: '0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5',
Expand Down
259 changes: 259 additions & 0 deletions src/tx-builder/contract-types/IParaSwapLiquiditySwapAdapter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */

import {
ethers,
EventFilter,
Signer,
BigNumber,
BigNumberish,
PopulatedTransaction,
} from "ethers";
import {
Contract,
ContractTransaction,
Overrides,
CallOverrides,
} from "@ethersproject/contracts";
import { BytesLike } from "@ethersproject/bytes";
import { Listener, Provider } from "@ethersproject/providers";
import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi";

interface IParaSwapLiquiditySwapAdapterInterface
extends ethers.utils.Interface {
functions: {
"swapAndDeposit(address,address,uint256,uint256,uint256,bytes,address,tuple)": FunctionFragment;
};

encodeFunctionData(
functionFragment: "swapAndDeposit",
values: [
string,
string,
BigNumberish,
BigNumberish,
BigNumberish,
BytesLike,
string,
{
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
}
]
): string;

decodeFunctionResult(
functionFragment: "swapAndDeposit",
data: BytesLike
): Result;

events: {};
}

export class IParaSwapLiquiditySwapAdapter extends Contract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

on(event: EventFilter | string, listener: Listener): this;
once(event: EventFilter | string, listener: Listener): this;
addListener(eventName: EventFilter | string, listener: Listener): this;
removeAllListeners(eventName: EventFilter | string): this;
removeListener(eventName: any, listener: Listener): this;

interface: IParaSwapLiquiditySwapAdapterInterface;

functions: {
swapAndDeposit(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<ContractTransaction>;

"swapAndDeposit(address,address,uint256,uint256,uint256,bytes,address,(uint256,uint256,uint8,bytes32,bytes32))"(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<ContractTransaction>;
};

swapAndDeposit(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<ContractTransaction>;

"swapAndDeposit(address,address,uint256,uint256,uint256,bytes,address,(uint256,uint256,uint8,bytes32,bytes32))"(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<ContractTransaction>;

callStatic: {
swapAndDeposit(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: CallOverrides
): Promise<void>;

"swapAndDeposit(address,address,uint256,uint256,uint256,bytes,address,(uint256,uint256,uint8,bytes32,bytes32))"(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: CallOverrides
): Promise<void>;
};

filters: {};

estimateGas: {
swapAndDeposit(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<BigNumber>;

"swapAndDeposit(address,address,uint256,uint256,uint256,bytes,address,(uint256,uint256,uint8,bytes32,bytes32))"(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<BigNumber>;
};

populateTransaction: {
swapAndDeposit(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<PopulatedTransaction>;

"swapAndDeposit(address,address,uint256,uint256,uint256,bytes,address,(uint256,uint256,uint8,bytes32,bytes32))"(
assetToSwapFrom: string,
assetToSwapTo: string,
amountToSwap: BigNumberish,
minAmountToReceive: BigNumberish,
swapAllBalanceOffset: BigNumberish,
swapCalldata: BytesLike,
augustus: string,
permitParams: {
amount: BigNumberish;
deadline: BigNumberish;
v: BigNumberish;
r: BytesLike;
s: BytesLike;
},
overrides?: Overrides
): Promise<PopulatedTransaction>;
};
}
Loading