-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate paraswap adapter (#127)
* feat: paraswap feat: add initial paraswap integration fix: use test deployment fix: add some logging info fix: remove valiation debug: print network fix: fml fix: use paraswap * fix: proper offset fix: reuse function for offset fix: remove import * fix: remove the log * fix: add log * fix: remove console.log * fix: alter interface * fix: updadte offsets * fix: update address for audit
- Loading branch information
Showing
11 changed files
with
514 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
259 changes: 259 additions & 0 deletions
259
src/tx-builder/contract-types/IParaSwapLiquiditySwapAdapter.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; | ||
} |
Oops, something went wrong.