Assessment reports>Awaken Swap>Informational findings>There is no way to set ,ExternalInfo, for LP tokens
Category: Business Logic

There is no way to set ExternalInfo for LP tokens

Informational Severity
Informational Impact
N/A Likelihood

Description

The ExternalInfo feature of the TokenContract allows tokens to have arbitrary key-value metadata, with one constant key, awaken_transfer_callback, having the special behavior that it specifies a callback to be called upon token transfers.

However, the only ways this ExternalInfo state can change are during Create and ResetExternalInfo:

public override Empty Create(CreateInput input)
{
    // [...]

    var tokenInfo = new TokenInfo
    {
        // [...]

        ExternalInfo = input.ExternalInfo
    };

    // [...]
}

public override Empty ResetExternalInfo(ResetExternalInfoInput input)
{
    var tokenInfo = State.TokenInfoMap[input.Symbol];
    Assert(tokenInfo.Issuer == Context.Sender, "No permission to reset external info.");
    tokenInfo.ExternalInfo = input.ExternalInfo;
    State.TokenInfoMap[input.Symbol] = tokenInfo;
    Context.Fire(new ExternalInfoChanged
    {
        Symbol = input.Symbol,
        ExternalInfo = input.ExternalInfo
    });
    return new Empty();
}

For the TokenContract owned by the AwakenSwapContract, the Create call is hardcoded to not specify any ExternalInfo:

public override Address CreatePair(CreatePairInput input)
{
    // [...]

    State.LPTokenContract.Create.Send(new Token.CreateInput
    {
        Symbol = GetTokenPairSymbol(tokenPair[0], tokenPair[1]),
        Decimals = 8,
        TokenName = $"Awaken {GetTokenPair(tokenPair[0], tokenPair[1])} LP Token",
        Issuer = Context.Self,
        IsBurnable = true,
        TotalSupply = long.MaxValue
    });

    // [...]
}

And the TokenContract contract never calls ResetExternalInfo. Since there is only one issuer of a token, and only the issuer may call ResetExternalInfo, this means it is not possible to set the ExternalInfo for an LP token.

Impact

For LP tokens created by the AwakenSwapContract, the ExternalInfo feature cannot be used.

Recommendations

We recommend either removing this feature, if it is unnecessary, or allowing an admin to be able to call ResetExternalInfo on LP tokens through the AwakenSwapContract in order to be able to add this feature to LP tokens in the future.

Remediation

As ExternalInfo cannot be set in the current implementation of the contract, Awaken Finance has chosen to defer implementing the fix for this issue.

Zellic © 2024Back to top ↑