Skip to content

Commit

Permalink
Feat/repay bundle (#557)
Browse files Browse the repository at this point in the history
* feat: added tests

* feat: added test for stable debt

* fix: bad merge

* feat: added encoded tx data

* feat: added test for signed repay with l2 pool

* feat: -1 handle

* feat: added test for repay with max input (-1)

* feat: added encode functions for using optimized path

* fix: rate mode and max repay

* test: repay amount and interest rate mode

---------

Co-authored-by: Mark Grothe <grothem@gmail.com>
  • Loading branch information
JoaquinBattilana and grothem authored Nov 20, 2023
1 parent 9080310 commit 77f4128
Show file tree
Hide file tree
Showing 14 changed files with 1,250 additions and 291 deletions.
133 changes: 33 additions & 100 deletions packages/contract-helpers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
All notable changes to this project will be documented in this file. See
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# 1.21.0 (2023-10-04)

Expand All @@ -16,180 +16,117 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

# 1.20.0 (2023-08-22)


### Features

* withdraw and swap ([#555](https://github.com/aave/aave-utilities/issues/555)) ([ca6c230](https://github.com/aave/aave-utilities/commit/ca6c230f39536ba34313ba5ec8295267742216a3))




- withdraw and swap ([#555](https://github.com/aave/aave-utilities/issues/555))
([ca6c230](https://github.com/aave/aave-utilities/commit/ca6c230f39536ba34313ba5ec8295267742216a3))

# 1.19.0 (2023-08-21)


### Features

* add Scroll Sepolia and Scroll chainIds ([#554](https://github.com/aave/aave-utilities/issues/554)) ([7510d22](https://github.com/aave/aave-utilities/commit/7510d227dd358f3420d7788a9feaaa72f09e8e9e))




- add Scroll Sepolia and Scroll chainIds
([#554](https://github.com/aave/aave-utilities/issues/554))
([7510d22](https://github.com/aave/aave-utilities/commit/7510d227dd358f3420d7788a9feaaa72f09e8e9e))

## 1.18.3 (2023-08-18)

**Note:** Version bump only for package @aave/contract-helpers





## 1.18.2 (2023-07-14)


### Bug Fixes

* remove commented imports ([#552](https://github.com/aave/aave-utilities/issues/552)) ([91a2772](https://github.com/aave/aave-utilities/commit/91a2772477ce2d9a809114dcbe2535c234603c38))




- remove commented imports
([#552](https://github.com/aave/aave-utilities/issues/552))
([91a2772](https://github.com/aave/aave-utilities/commit/91a2772477ce2d9a809114dcbe2535c234603c38))

## 1.18.1 (2023-07-12)

**Note:** Version bump only for package @aave/contract-helpers





# 1.18.0 (2023-07-12)


### Features

* debt switch ([#548](https://github.com/aave/aave-utilities/issues/548)) ([8c943d7](https://github.com/aave/aave-utilities/commit/8c943d78eda94f6e330e343d3cded9286ac2079c))




- debt switch ([#548](https://github.com/aave/aave-utilities/issues/548))
([8c943d7](https://github.com/aave/aave-utilities/commit/8c943d78eda94f6e330e343d3cded9286ac2079c))

## 1.17.8 (2023-06-22)

**Note:** Version bump only for package @aave/contract-helpers





## 1.17.7 (2023-06-16)

**Note:** Version bump only for package @aave/contract-helpers





## 1.17.6 (2023-06-01)


### Bug Fixes

* gas limits ([#543](https://github.com/aave/aave-utilities/issues/543)) ([cd4e533](https://github.com/aave/aave-utilities/commit/cd4e533c8c469306abaf4a9c1b0a1066b59cf875))




- gas limits ([#543](https://github.com/aave/aave-utilities/issues/543))
([cd4e533](https://github.com/aave/aave-utilities/commit/cd4e533c8c469306abaf4a9c1b0a1066b59cf875))

## 1.17.5 (2023-05-23)

**Note:** Version bump only for package @aave/contract-helpers





## 1.17.4 (2023-05-05)

**Note:** Version bump only for package @aave/contract-helpers





## 1.17.3 (2023-05-02)


### Bug Fixes

* decimal formatting in credit delegation approval checks ([#538](https://github.com/aave/aave-utilities/issues/538)) ([27eef6b](https://github.com/aave/aave-utilities/commit/27eef6b182f671fc9b4eb13cbd3712be17949c5c))




- decimal formatting in credit delegation approval checks
([#538](https://github.com/aave/aave-utilities/issues/538))
([27eef6b](https://github.com/aave/aave-utilities/commit/27eef6b182f671fc9b4eb13cbd3712be17949c5c))

## 1.17.2 (2023-05-01)


### Bug Fixes

* integer rounding for migration credit delegation approval buffer ([#537](https://github.com/aave/aave-utilities/issues/537)) ([3eef29e](https://github.com/aave/aave-utilities/commit/3eef29eb2e79bce2e1289c951fa00628bc5d4868))




- integer rounding for migration credit delegation approval buffer
([#537](https://github.com/aave/aave-utilities/issues/537))
([3eef29e](https://github.com/aave/aave-utilities/commit/3eef29eb2e79bce2e1289c951fa00628bc5d4868))

## 1.17.1 (2023-05-01)

**Note:** Version bump only for package @aave/contract-helpers





# 1.17.0 (2023-04-27)


### Features

* fixed available debt in isolated reserve in case that debt > ma… ([#532](https://github.com/aave/aave-utilities/issues/532)) ([7a2ea1e](https://github.com/aave/aave-utilities/commit/7a2ea1e94a26008247b4c4c045641291ff20261b))




- fixed available debt in isolated reserve in case that debt > ma…
([#532](https://github.com/aave/aave-utilities/issues/532))
([7a2ea1e](https://github.com/aave/aave-utilities/commit/7a2ea1e94a26008247b4c4c045641291ff20261b))

# 1.16.0 (2023-04-17)


### Features

* update borrow methods SDK ([#527](https://github.com/aave/aave-utilities/issues/527)) ([da31b83](https://github.com/aave/aave-utilities/commit/da31b836dd7a85da0dbfe664b67612b1f261c7a7))




- update borrow methods SDK
([#527](https://github.com/aave/aave-utilities/issues/527))
([da31b83](https://github.com/aave/aave-utilities/commit/da31b836dd7a85da0dbfe664b67612b1f261c7a7))

# 1.15.0 (2023-04-12)


### Features

* add Scroll Alpha chainId ([#528](https://github.com/aave/aave-utilities/issues/528)) ([3418c70](https://github.com/aave/aave-utilities/commit/3418c7087796397ed535fc7a3522445fb44f94c5))




- add Scroll Alpha chainId
([#528](https://github.com/aave/aave-utilities/issues/528))
([3418c70](https://github.com/aave/aave-utilities/commit/3418c7087796397ed535fc7a3522445fb44f94c5))

# 1.14.0 (2023-04-05)


### Features

* tx bundle refactor ([#514](https://github.com/aave/aave-utilities/issues/514)) ([fc5c937](https://github.com/aave/aave-utilities/commit/fc5c9378b48a14a31df9fdbe435095a3e81390a2)), closes [#524](https://github.com/aave/aave-utilities/issues/524) [#504](https://github.com/aave/aave-utilities/issues/504)




- tx bundle refactor ([#514](https://github.com/aave/aave-utilities/issues/514))
([fc5c937](https://github.com/aave/aave-utilities/commit/fc5c9378b48a14a31df9fdbe435095a3e81390a2)),
closes [#524](https://github.com/aave/aave-utilities/issues/524)
[#504](https://github.com/aave/aave-utilities/issues/504)

# Change Log

Expand All @@ -200,10 +137,6 @@ All notable changes to this project will be documented in this file. See

**Note:** Version bump only for package @aave/contract-helpers





## 1.13.6 (2023-03-03)

**Note:** Version bump only for package @aave/contract-helpers
Expand Down
46 changes: 45 additions & 1 deletion packages/contract-helpers/src/commons/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { BigNumber, BytesLike, PopulatedTransaction } from 'ethers';
import { LPBorrowParamsType } from '../v3-pool-contract/lendingPoolTypes';
import {
LPBorrowParamsType,
LPRepayParamsType,
LPRepayWithATokensType,
LPSignedRepayParamsType,
} from '../v3-pool-contract/lendingPoolTypes';

export type tEthereumAddress = string;
export type ENS = string; // something.eth
Expand Down Expand Up @@ -115,6 +120,8 @@ export enum ProtocolAction {
liquidationCall = 'liquidationCall',
liquidationFlash = 'liquidationFlash',
repay = 'repay',
repayETH = 'repayETH',
repayWithATokens = 'repayWithATokens',
swapCollateral = 'swapCollateral',
repayCollateral = 'repayCollateral',
withdrawETH = 'withdrawETH',
Expand Down Expand Up @@ -344,4 +351,41 @@ export type BorrowTxBuilder = {
useOptimizedPath,
encodedTxData,
}: LPBorrowParamsType) => PopulatedTransaction;
encodeBorrowParams: ({
reserve,
amount,
interestRateMode,
referralCode,
}: Omit<LPBorrowParamsType, 'user'>) => Promise<string>;
};

export type RepayTxBuilder = {
generateTxData: (params: LPRepayParamsType) => PopulatedTransaction;
generateSignedTxData: (
params: LPSignedRepayParamsType,
) => PopulatedTransaction;
encodeRepayParams: ({
reserve,
amount,
interestRateMode,
}: Omit<LPRepayParamsType, 'user'>) => Promise<string>;
encodeRepayWithPermitParams: ({
reserve,
amount,
interestRateMode,
deadline,
signature,
}: Pick<
LPSignedRepayParamsType,
'reserve' | 'amount' | 'interestRateMode' | 'signature' | 'deadline'
>) => Promise<[string, string, string]>;
};

export type RepayWithATokensTxBuilder = {
generateTxData: (params: LPRepayWithATokensType) => PopulatedTransaction;
encodeRepayWithATokensParams: ({
reserve,
amount,
rateMode,
}: Omit<LPRepayWithATokensType, 'user'>) => Promise<string>;
};
16 changes: 12 additions & 4 deletions packages/contract-helpers/src/commons/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export const gasLimitRecommendations: GasRecommendationType = {
limit: '300000',
recommended: '300000',
},
[ProtocolAction.repayETH]: {
limit: '350000',
recommended: '300000',
},
[ProtocolAction.borrowETH]: {
limit: '450000',
recommended: '450000',
Expand Down Expand Up @@ -106,6 +110,10 @@ export const gasLimitRecommendations: GasRecommendationType = {
limit: '350000',
recommended: '350000',
},
[ProtocolAction.stake]: {
limit: '350000',
recommended: '350000',
},
[ProtocolAction.stakeWithPermit]: {
limit: '400000',
recommended: '400000',
Expand All @@ -114,10 +122,6 @@ export const gasLimitRecommendations: GasRecommendationType = {
limit: '125000',
recommended: '125000',
},
[ProtocolAction.stake]: {
limit: '395000',
recommended: '395000',
},
[ProtocolAction.claimRewards]: {
limit: '275000',
recommended: '275000',
Expand All @@ -126,6 +130,10 @@ export const gasLimitRecommendations: GasRecommendationType = {
limit: '138000',
recommended: '138000',
},
[ProtocolAction.repayWithATokens]: {
limit: '300000',
recommended: '300000',
},
[ProtocolAction.withdrawAndSwitch]: {
limit: '1000000',
recommended: '1000000',
Expand Down
Loading

0 comments on commit 77f4128

Please sign in to comment.