Skip to content

Commit

Permalink
Squashed, rebased composable stable pool v2 deployment (#2065)
Browse files Browse the repository at this point in the history
* Prevent invariant overflow (#1690)

* Add check to prevent invariant overflow

* Update pkg/pool-stable/contracts/ComposableStablePoolProtocolFees.sol

Co-authored-by: Tom French <[email protected]>

Co-authored-by: Tom French <[email protected]>

* Composable stable pool versioning (#2034)

* WIP: version for ComposableStablePool.

* Fix stack too deep error and adjust tests.

* ComposableStablePoolFactory test.

* Remove unused var.

* Add factory version / pool version.

* Fix benchmarks.

* Remove IVersionProvider.

* feat: add proportional joins/exits

* Deployment preparation: Composable stable pool v2 (#2028)

* feat: add proportional joins/exits to ComposableStablePool

* deprecate 20220906-composable-stable-pool task

* add new task

* add artifacts

* checkpoint

* refactor: finish fork test

* refactor: remove weighted encoder name change (extraneous for this deployment)

* feat: add deprecations section to stable pool, and update deployments readme

* fix: deprecated paths

* Update README.md

Co-authored-by: Nicolás Venturo <[email protected]>

* fix: re-add _computeProportionalAmountsOut

* test: update test to remove use of deprecated function

Co-authored-by: Nicolás Venturo <[email protected]>
Co-authored-by: Juan Ignacio Ubeira <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2022
1 parent 0f434b5 commit 3251913
Show file tree
Hide file tree
Showing 35 changed files with 242,300 additions and 43 deletions.
18 changes: 17 additions & 1 deletion pkg/balancer-js/src/pool-stable/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export enum StablePoolJoinKind {
INIT = 0,
EXACT_TOKENS_IN_FOR_BPT_OUT,
TOKEN_IN_FOR_EXACT_BPT_OUT,
ALL_TOKENS_IN_FOR_EXACT_BPT_OUT,
}

export enum StablePoolExitKind {
EXACT_BPT_IN_FOR_ONE_TOKEN_OUT = 0,
BPT_IN_FOR_EXACT_TOKENS_OUT,
EXACT_BPT_IN_FOR_ALL_TOKENS_OUT,
}

export class StablePoolEncoder {
Expand Down Expand Up @@ -49,10 +51,17 @@ export class StablePoolEncoder {
[StablePoolJoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT, bptAmountOut, enterTokenIndex]
);

/**
* Encodes the userData parameter for joining a StablePool proportionally
* @param bptAmountOut - the amount of BPT to be minted
*/
static joinAllTokensInForExactBptOut = (bptAmountOut: BigNumberish): string =>
defaultAbiCoder.encode(['uint256', 'uint256'], [StablePoolJoinKind.ALL_TOKENS_IN_FOR_EXACT_BPT_OUT, bptAmountOut]);

/**
* Encodes the userData parameter for exiting a StablePool by removing a single token in return for an exact amount of BPT
* @param bptAmountIn - the amount of BPT to be burned
* @param enterTokenIndex - the index of the token to removed from the pool
* @param exitTokenIndex - the index of the token to removed from the pool
*/
static exitExactBPTInForOneTokenOut = (bptAmountIn: BigNumberish, exitTokenIndex: number): string =>
defaultAbiCoder.encode(
Expand All @@ -70,4 +79,11 @@ export class StablePoolEncoder {
['uint256', 'uint256[]', 'uint256'],
[StablePoolExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT, amountsOut, maxBPTAmountIn]
);

/**
* Encodes the userData parameter for exiting a StablePool proportionally
* @param bptAmountIn - the amount of BPT to burn in exchange for withdrawn tokens
*/
static exitExactBptInForTokensOut = (bptAmountIn: BigNumberish): string =>
defaultAbiCoder.encode(['uint256', 'uint256'], [StablePoolExitKind.EXACT_BPT_IN_FOR_ALL_TOKENS_OUT, bptAmountIn]);
}
2 changes: 2 additions & 0 deletions pkg/deployments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Returns an object with all contracts from a deployment and their addresses.
| Protocol Fee Splitter | [`20221027-fee-splitter`](./tasks/20221027-fee-splitter) |
| Linear Pools for Aave aTokens with built-in rebalancing | [`20221115-aave-rebalanced-linear-pool`](./tasks/20221115-aave-rebalanced-linear-pool) |
| Pool Recovery Helper | [`20221123-pool-recovery-helper`](./tasks/20221123-pool-recovery-helper) |
| Composable Stable Pools V2 | [`20221122-composable-stable-pool-v2`](./tasks/20221122-composable-stable-pool-v2) |
| Authorizer Adaptor Entrypoint | [`20221124-authorizer-adaptor-entrypoint`](./tasks/20221124-authorizer-adaptor-entrypoint) |
| Timelock Authorizer, governance contract | [`20221202-timelock-authorizer`](./tasks/20221202-timelock-authorizer) |

Expand Down Expand Up @@ -151,4 +152,5 @@ Go to each deprecated deployment's readme file to learn more about why it is dep
| Optimism Root Gauges, for veBAL voting | [`20220628-optimism-root-gauge-factory`](./tasks/deprecated/20220628-optimism-root-gauge-factory) |
| Batch Relayer V3 | [`20220720-batch-relayer-v3`](./tasks/deprecated/20220720-batch-relayer-v3) |
| Linear Pools for Aave aTokens with built-in rebalancing | [`20220817-aave-rebalanced-linear-pool`](./tasks/deprecated/20220817-aave-rebalanced-linear-pool) |
| Composable Stable Pools | [`20220906-composable-stable-pool`](./tasks/deprecated/20220906-composable-stable-pool) |
| Managed Pool | [`20221021-managed-pool`](./tasks/deprecated/20221021-managed-pool) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
[
{
"inputs": [
{
"internalType": "contract IVault",
"name": "vault",
"type": "address"
},
{
"internalType": "contract IProtocolFeePercentagesProvider",
"name": "protocolFeeProvider",
"type": "address"
},
{
"internalType": "string",
"name": "factoryVersion",
"type": "string"
},
{
"internalType": "string",
"name": "poolVersion",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [],
"name": "FactoryDisabled",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "pool",
"type": "address"
}
],
"name": "PoolCreated",
"type": "event"
},
{
"inputs": [
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
},
{
"internalType": "contract IERC20[]",
"name": "tokens",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "amplificationParameter",
"type": "uint256"
},
{
"internalType": "contract IRateProvider[]",
"name": "rateProviders",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "tokenRateCacheDurations",
"type": "uint256[]"
},
{
"internalType": "bool[]",
"name": "exemptFromYieldProtocolFeeFlags",
"type": "bool[]"
},
{
"internalType": "uint256",
"name": "swapFeePercentage",
"type": "uint256"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "create",
"outputs": [
{
"internalType": "contract ComposableStablePool",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "disable",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "selector",
"type": "bytes4"
}
],
"name": "getActionId",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getAuthorizer",
"outputs": [
{
"internalType": "contract IAuthorizer",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCreationCode",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCreationCodeContracts",
"outputs": [
{
"internalType": "address",
"name": "contractA",
"type": "address"
},
{
"internalType": "address",
"name": "contractB",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getPauseConfiguration",
"outputs": [
{
"internalType": "uint256",
"name": "pauseWindowDuration",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "bufferPeriodDuration",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getPoolVersion",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getProtocolFeePercentagesProvider",
"outputs": [
{
"internalType": "contract IProtocolFeePercentagesProvider",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getVault",
"outputs": [
{
"internalType": "contract IVault",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isDisabled",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "pool",
"type": "address"
}
],
"name": "isPoolFromFactory",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "version",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
]
Loading

0 comments on commit 3251913

Please sign in to comment.