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

deploy amber contracts to foucoco and test that it works #225

Closed
ashneverdawn opened this issue Apr 26, 2023 · 15 comments
Closed

deploy amber contracts to foucoco and test that it works #225

ashneverdawn opened this issue Apr 26, 2023 · 15 comments
Assignees
Labels
state:on-hold feature/fix is on hold due to external reasons (please specify)

Comments

@ashneverdawn
Copy link
Contributor

deploy amber contracts to foucoco and test that it works

amber compiled contracts:
https://app.zenhub.com/files/428984346/5ba8448e-f9df-4eb1-b9ab-76010834a767/download

amber compiled slippage curve:
https://app.zenhub.com/files/428984346/f18f9044-057a-43f3-b8d8-4f88912403d2/download

amber deployment scripts:
https://app.zenhub.com/files/428984346/b5e33e2d-68d1-48ee-a79f-b4454e54427d/download

deployment scripts were written for mumbai, so they cannot be used as is, however the deployment steps can be derived from them.

instead of regular erc20 tokens, we should use wrapped native tokens using our psp22pendulum contract found in our pendulum-ink-wrapper repo.

@prayagd
Copy link
Collaborator

prayagd commented May 8, 2023

Please add your planning poker estimate with Zenhub @ashneverdawn

@ashneverdawn ashneverdawn self-assigned this May 10, 2023
@ashneverdawn
Copy link
Contributor Author

ashneverdawn commented May 10, 2023

I followed the deployment scripts to deploy the following contracts on Foucoco, but got stuck on step 6/7. When I tried to deploy the SwapPool contract I got an error saying: Use of a function type with too many parameters. Full description of steps I took and error I got are below:

----- 01_deploy_router -----

Deploy Contract: Router
Args: []
Contract Address: 6ho8CHTdpPhM3sDinxRXR1VhhKFH7yZeARvrMimRf1efRCwW

----- 02_deploy_mock_tokens -----

Deploy Contract: MockERC20
Args: [
"Mock USD",
"mUSD"
]
Contract Address: 6her5bSPFkGDTSaZFv5rkpadiotkNcwTjNkwjAQisXNuHU4h

Deploy Contract: MockERC20
Args: [
"Mock EUR",
"mEUR"
]
Contract Address: 6mn5qqehcmrx7xCASQ7LUPSajVq7raKkpJg8XzGakSK7gYWv

Deploy Contract: MockERC20
Args: [
"Mock GBP",
"mGBP"
]
Contract Address: 6mWJGHUmSeQYMmUuZpRiZSGFfWbBqueC97hYFCr9RQaEKqwD

----- 03_deploy_mock_oracles -----

Deploy Contract: MockOracle
Args: [
mUSD.address,
1000000000000000000
]
Contract Address: 6hz2nmQABGPLci1fZLpLiaBcYca7GeLNVQFjcm9vT9i599CU

Deploy Contract: MockOracle
Args: [
mEUR.address,
1100000000000000000
]
Contract Address: 6mMuH8PHagXp33ovJCKnHZ2iA2uDBtbUkGi52WCsMEaHz5xa

Deploy Contract: MockOracle
Args: [
mGBP.address,
1200000000000000000
]
Contract Address: 6hvQ1gCBnTNR1vt438VbNS7MJecsFMmTo2feYYjeV2ZrncLD

Call Contract: Router
Method: setPriceOracle
Args: [
mUSD.address,
omUSD.address
]

Call Contract: Router
Method: setPriceOracle
Args: [
mEUR.address,
omEUR.address
]

Call Contract: Router
Method: setPriceOracle
Args: [
mGBP.address,
omGBP.address
]

----- 04_deploy_curves -----

Deploy Contract: AmberCurve
Args: [
0,
10000000000000000
]
Contract Address: 6jLmpLrTTSPjCaMkbzYyWJMEeocsqqvTNoaTbHb6RXxDNQMm

----- 05_deploy_backstop -----

Deploy Contract: BackstopPool
Args: [
router.address,
mUSD.address,
curve.address,
"0xAmber Backstop LP",
"mUSD-BLP"
]
Contract Address: 6iUQEdkbtTAeu3KEARwF2GvKrAoZ2EUNnEean3vHM2zj7b12

----- 06_deploy_swap_pools -----

Deploy Contract: SwapPool
Args: [
mUSD.address,
curve.address,
router.address,
backstop.address,
treasury,
"0xAmber mUSD Swap LP",
"mUSD-LP"
]
Error:
CodeRejected

The contract's code was found to be invalid during validation or instrumentation.The most likely cause of this is that an API was used which is not supported by thenode. This hapens if an older node is used with a new version of ink!. Try updatingyour node to the newest available version.A more detailed error can be found on the node console if debug messages are enabledby supplying -lruntime::contracts=debug.

Use of a function type with too many parameters.

@prayagd
Copy link
Collaborator

prayagd commented May 12, 2023

@ashneverdawn Can you please update the status here? Looks like the PR is merged.

@ashneverdawn
Copy link
Contributor Author

yes, PR got merged last week. Today, I'll do the runtime upgrade on Foucoco so I can resume the deployment.

@ashneverdawn
Copy link
Contributor Author

----- 06_deploy_swap_pools -----

Deploy Contract: SwapPool
Args: [
mUSD.address,
curve.address,
router.address,
backstop.address,
treasury,
"0xAmber mUSD Swap LP",
"mUSD-LP"
]
Contract Address: 6jkq3j4cq119eF6xZDD2NnohtKJnYEhgXpt8rUJgjJSWC5hY

Deploy Contract: SwapPool
Args: [
mEUR.address,
curve.address,
router.address,
backstop.address,
treasury,
"0xAmber mEUR Swap LP",
"mEUR-LP"
]
Contract Address: 6kS2LNht4gpHck8YwPWGxFADP8x1xRcNpYKg1DLBMNXtEeU8

Deploy Contract: SwapPool
Args: [
mGBP.address,
curve.address,
router.address,
backstop.address,
treasury,
"0xAmber mGBP Swap LP",
"mGBP-LP"
]
Contract Address: 6jxtvkaowhQ4RLgegD5wKYDoBspKAcZ7kh7F7ME6nMftXzYr

Call Contract: Router
Method: registerPool
Args: [
mUSD.address,
LPmUSD.address
]
Error:
Contract Reverted!
DispatchError
ContractTrapped

DispatchError docs
Contract trapped during execution.

@ashneverdawn
Copy link
Contributor Author

I was able to deploy all the swap pools successfully 👍
However, when trying to call registerPool of the Router the contract is failing.

This is the registerPool function from the solidity code:


    /**
     * @notice Registers a newly created swap pool.
     */
    function registerPool(address _asset, address _swapPool)
        external
        onlyOwner
    {
        require(_asset != address(0), "NO_ASSET");
        require(_swapPool != address(0), "NO_POOL");
        require(address(oracleByAsset[_asset]) != address(0), "NO_ORACLE");

        poolByAsset[_asset] = ISwapPoolPermissioned(_swapPool);
        IERC20(_asset).approve(_swapPool, 2**256  - 1);
    }

It's not obvious to me what could be the issue. Will investigate further tomorrow.

@ashneverdawn
Copy link
Contributor Author

Without a way to deploy all the contracts with a script, it's tedious to narrow down this issue. I'm putting this on hold until I've finished creating a way to do that.

@andywer
Copy link

andywer commented May 31, 2023

@ashneverdawn What was the error?

@ashneverdawn
Copy link
Contributor Author

The error was:

Contract Reverted!
DispatchError
ContractTrapped

DispatchError docs
Contract trapped during execution.

Which isn't very helpful, basically just tells me that the contract threw some kind of exception/panicked

@ashneverdawn
Copy link
Contributor Author

ashneverdawn commented May 31, 2023

@andywer Once I have a deployment script working, first thing I'll try is deploy the latest version of the contracts. If that doesn't solve it, then I'll dig into the registerPool function and check the solang docs: https://solang.readthedocs.io/en/latest/ to see if this is caused by any differences with EVM we may have overlooked.

@andywer
Copy link

andywer commented Jun 1, 2023

@ashneverdawn Did you register a price oracle via setPriceOracle() before you tried to register the pool?

@ashneverdawn
Copy link
Contributor Author

ashneverdawn commented Jun 1, 2023

@andywer yes, I did.

This comment documents the exact steps I took:
#225 (comment)

Then after I resolved the issue with deploying SwapPool, I continued here:
#225 (comment)

@ashneverdawn
Copy link
Contributor Author

To give an update here:

  • We have resolved the deployment issue a while ago already.
  • We also were able to use the wasm-deploy tool to deploy all the contracts successfully via script.
  • What's missing here is to test that it actually operates as expected. We don't have a good understanding yet on the flow of what needs to be called and in what order. Nabla does have some testing contracts that we could deploy and call with our wasm-deploy tool, however some changes are needed since they rely on some functionality from Foundry which is only for EVM chains.
  • Also note we've been semi-blocked by Foucoco being bricked. I say semi-blocked because we can of course still do some things locally. But ultimately we need to make sure this is live and working properly on Foucoco, which is also important for the ui and indexer that depend on this.

@TorstenStueber Since this was mostly worked on by you, is there anything I missed that you'd like to add?

@TorstenStueber
Copy link
Contributor

Exactly @ashneverdawn, I couldn't have put it better myself.

@ebma ebma added the state:on-hold feature/fix is on hold due to external reasons (please specify) label Oct 23, 2023
@TorstenStueber
Copy link
Contributor

Closing this ticket. Completed long time ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:on-hold feature/fix is on hold due to external reasons (please specify)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants