Skip to content

Commit

Permalink
[SDK-CORE] GoodDollar sdk core fix (#1734)
Browse files Browse the repository at this point in the history
* fix supertoken initialization for gooddollar

* bump version + update changelog

* use governance address from networkData

* gooddollar symbol

---------

Co-authored-by: Kaspar Kallas <[email protected]>
  • Loading branch information
0xdavinchee and kasparkallas authored Oct 24, 2023
1 parent ffe6790 commit 8ab5829
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
5 changes: 5 additions & 0 deletions packages/sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

## [0.6.12] - 2023-10-23

### Fixed
- Support for `CustomSuperToken` contracts without `CONSTANT_OUTFLOW_NFT()` and `CONSTANT_INFLOW_NFT()` function implemented

## [0.6.11] - 2023-10-20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superfluid-finance/sdk-core",
"version": "0.6.11",
"version": "0.6.12",
"description": "SDK Core for building with Superfluid Protocol",
"homepage": "https://github.com/superfluid-finance/protocol-monorepo/tree/dev/packages/sdk-core#readme",
"repository": {
Expand Down
19 changes: 7 additions & 12 deletions packages/sdk-core/src/Framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,13 @@ export default class Framework {
};

// supported networks scenario
if (
networkData != null &&
baseSettings.protocolReleaseVersion === V1
) {
let governanceAddress = ethers.constants.AddressZero;

if (networkData.addresses.governance == null) {
governanceAddress = await Superfluid__factory.connect(
networkData.addresses.host,
provider
).getGovernance();
}
if (networkData && baseSettings.protocolReleaseVersion === V1) {
const governanceAddress = networkData.addresses.governance
? networkData.addresses.governance
: await Superfluid__factory.connect(
networkData.addresses.host,
provider
).getGovernance();

const settings: IFrameworkSettings = {
...baseSettings,
Expand Down
46 changes: 42 additions & 4 deletions packages/sdk-core/src/SuperToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,48 @@ export default abstract class SuperToken extends ERC20Token {
const nativeTokenSymbol = resolverData.nativeTokenSymbol || "ETH";
const nativeSuperTokenSymbol = nativeTokenSymbol + "x";

const constantOutflowNFTProxy =
await superToken.CONSTANT_OUTFLOW_NFT();
const constantInflowNFTProxy =
await superToken.CONSTANT_INFLOW_NFT();
// @note This is tech debt and should be reverted once GoodDollar upgrades their token contract
// @note We are using tryGet here just to handle GoodDollar not having
// CONSTANT_OUTFLOW_NFT in its SuperToken implementation.
let constantOutflowNFTProxy = await tryGet(
superToken.CONSTANT_OUTFLOW_NFT(),
ethers.constants.AddressZero
);
let constantInflowNFTProxy = await tryGet(
superToken.CONSTANT_INFLOW_NFT(),
ethers.constants.AddressZero
);

// @note We only want to run this bit of code for GoodDollar SuperTokens
// (dev and mainnet)
const GOOD_DOLLAR_SYMBOL = "G$";
if (tokenSymbol === GOOD_DOLLAR_SYMBOL) {
// @note we need to create a new interface for the old GoodDollar SuperToken
// which contains the functions for constantInflowNFT and constantOutflowNFT
const oldSuperTokenInterface = new ethers.utils.Interface([
"function constantInflowNFT() view returns (address)",
"function constantOutflowNFT() view returns (address)",
]);
const goodDollarSpecificToken = new ethers.Contract(
superToken.address,
oldSuperTokenInterface
);

// @note we attempt to get the constantInflowNFT and constantOutflowNFT
if (constantOutflowNFTProxy === ethers.constants.AddressZero) {
constantOutflowNFTProxy = await tryGet(
goodDollarSpecificToken.constantOutflowNFT(),
ethers.constants.AddressZero
);
}
if (constantInflowNFTProxy === ethers.constants.AddressZero) {
constantInflowNFTProxy = await tryGet(
goodDollarSpecificToken.constantInflowNFT(),
ethers.constants.AddressZero
);
}
}

const nftAddresses: NFTAddresses = {
constantOutflowNFTProxy,
constantInflowNFTProxy,
Expand Down

0 comments on commit 8ab5829

Please sign in to comment.