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

[SDK-CORE] GoodDollar sdk core fix #1734

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading